ia64.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2005 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #include <arch.h>
00036 #include <arch/ski/ski.h>
00037 #include <arch/drivers/it.h>
00038 #include <arch/interrupt.h>
00039 #include <arch/barrier.h>
00040 #include <arch/asm.h>
00041 #include <arch/register.h>
00042 #include <arch/types.h>
00043 #include <arch/context.h>
00044 #include <arch/stack.h>
00045 #include <arch/mm/page.h>
00046 #include <mm/as.h>
00047 #include <config.h>
00048 #include <userspace.h>
00049 #include <console/console.h>
00050 #include <proc/uarg.h>
00051 #include <syscall/syscall.h>
00052 
00053 static int kbd_release=0;
00054 
00055 void arch_pre_main(void)
00056 {
00057         /* Setup usermode init tasks. */
00058         init.cnt = 8;
00059         init.tasks[0].addr = INIT0_ADDRESS;
00060         init.tasks[0].size = INIT0_SIZE;
00061         init.tasks[1].addr = INIT0_ADDRESS + 0x400000;
00062         init.tasks[1].size = INIT0_SIZE;
00063         init.tasks[2].addr = INIT0_ADDRESS + 0x800000;
00064         init.tasks[2].size = INIT0_SIZE;
00065         init.tasks[3].addr = INIT0_ADDRESS + 0xc00000;
00066         init.tasks[3].size = INIT0_SIZE;
00067         init.tasks[4].addr = INIT0_ADDRESS + 0x1000000;
00068         init.tasks[4].size = INIT0_SIZE;
00069         init.tasks[5].addr = INIT0_ADDRESS + 0x1400000;
00070         init.tasks[5].size = INIT0_SIZE;
00071         init.tasks[6].addr = INIT0_ADDRESS + 0x1800000;
00072         init.tasks[6].size = INIT0_SIZE;
00073         init.tasks[7].addr = INIT0_ADDRESS + 0x1c00000;
00074         init.tasks[7].size = INIT0_SIZE;
00075 }
00076 
00077 void arch_pre_mm_init(void)
00078 {
00079         /* Set Interruption Vector Address (i.e. location of interruption vector table). */
00080         iva_write((__address) &ivt);
00081         srlz_d();
00082         
00083         ski_init_console();
00084         it_init();      
00085 }
00086 
00087 void arch_post_mm_init(void)
00088 {
00089         ski_set_console_sysinfo();
00090 }
00091 
00092 void arch_pre_smp_init(void)
00093 {
00094 }
00095 
00096 void arch_post_smp_init(void)
00097 {
00098 }
00099 
00101 void userspace(uspace_arg_t *kernel_uarg)
00102 {
00103         psr_t psr;
00104         rsc_t rsc;
00105 
00106         psr.value = psr_read();
00107         psr.cpl = PL_USER;
00108         psr.i = true;                           /* start with interrupts enabled */
00109         psr.ic = true;
00110         psr.ri = 0;                             /* start with instruction #0 */
00111         psr.bn = 1;                             /* start in bank 0 */
00112 
00113         __asm__ volatile ("mov %0 = ar.rsc\n" : "=r" (rsc.value));
00114         rsc.loadrs = 0;
00115         rsc.be = false;
00116         rsc.pl = PL_USER;
00117         rsc.mode = 3;                           /* eager mode */
00118 
00119         switch_to_userspace((__address) kernel_uarg->uspace_entry,
00120                             ((__address) kernel_uarg->uspace_stack)+PAGE_SIZE-ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),
00121                             ((__address) kernel_uarg->uspace_stack)+PAGE_SIZE,
00122                             (__address) kernel_uarg->uspace_uarg,
00123                             psr.value, rsc.value);
00124 
00125         while (1) {
00126                 ;
00127         }
00128 }
00129 
00134 __native sys_tls_set(__native addr)
00135 {
00136         return 0;
00137 }
00138 
00142 void arch_grab_console(void)
00143 {
00144     kbd_release=kbd_uspace;
00145     kbd_uspace=0;
00146 }
00150 void arch_release_console(void)
00151 {
00152     kbd_uspace=kbd_release;
00153 }
00154 

Generated on Sun Jun 18 16:51:20 2006 for HelenOS Kernel (ia64) by  doxygen 1.4.6