00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00036 #include <arch.h>
00037 #include <arch/boot.h>
00038 #include <arch/cp0.h>
00039 #include <arch/exception.h>
00040 #include <arch/asm.h>
00041 #include <mm/as.h>
00042
00043 #include <userspace.h>
00044 #include <arch/console.h>
00045 #include <memstr.h>
00046 #include <proc/thread.h>
00047 #include <proc/uarg.h>
00048 #include <print.h>
00049 #include <syscall/syscall.h>
00050 #include <sysinfo/sysinfo.h>
00051
00052 #include <arch/interrupt.h>
00053 #include <arch/drivers/arc.h>
00054 #include <console/chardev.h>
00055 #include <arch/debugger.h>
00056 #include <genarch/fb/fb.h>
00057 #include <debug.h>
00058
00059 #include <arch/asm/regname.h>
00060
00061
00062
00063
00064 #define EXCEPTION_JUMP_SIZE 8
00065
00066 #define TLB_EXC ((char *) 0x80000000)
00067 #define NORM_EXC ((char *) 0x80000180)
00068 #define CACHE_EXC ((char *) 0x80000100)
00069
00070 bootinfo_t bootinfo;
00071
00072 void arch_pre_main(void)
00073 {
00074
00075 init.cnt = bootinfo.cnt;
00076
00077 __u32 i;
00078
00079 for (i = 0; i < bootinfo.cnt; i++) {
00080 init.tasks[i].addr = bootinfo.tasks[i].addr;
00081 init.tasks[i].size = bootinfo.tasks[i].size;
00082 }
00083 }
00084
00085 void arch_pre_mm_init(void)
00086 {
00087
00088 interrupts_disable();
00089
00090
00091 exception_init();
00092 arc_init();
00093
00094
00095 memcpy(TLB_EXC, (char *)tlb_refill_entry, EXCEPTION_JUMP_SIZE);
00096 memcpy(NORM_EXC, (char *)exception_entry, EXCEPTION_JUMP_SIZE);
00097 memcpy(CACHE_EXC, (char *)cache_error_entry, EXCEPTION_JUMP_SIZE);
00098
00099 interrupt_init();
00100
00101
00102
00103
00104 cp0_status_write(cp0_status_read() & ~(cp0_status_bev_bootstrap_bit|cp0_status_erl_error_bit));
00105
00106
00107
00108
00109 cp0_mask_all_int();
00110
00111
00112
00113
00114 cp0_unmask_int(TIMER_IRQ);
00115
00116 console_init();
00117 debugger_init();
00118 }
00119
00120 void arch_post_mm_init(void)
00121 {
00122 #ifdef CONFIG_FB
00123 fb_init(0x12000000, 640, 480, 24, 1920);
00124 #endif
00125 sysinfo_set_item_val("machine." STRING(MACHINE),NULL,1);
00126 }
00127
00128 void arch_pre_smp_init(void)
00129 {
00130 }
00131
00132 void arch_post_smp_init(void)
00133 {
00134 }
00135
00136
00137
00138
00139
00140
00141
00142 __address supervisor_sp __attribute__ ((section (".text")));
00143
00144 void userspace(uspace_arg_t *kernel_uarg)
00145 {
00146
00147 cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit |
00148 cp0_status_um_bit |
00149 cp0_status_ie_enabled_bit));
00150 cp0_epc_write((__address) kernel_uarg->uspace_entry);
00151 userspace_asm(((__address) kernel_uarg->uspace_stack+PAGE_SIZE),
00152 (__address) kernel_uarg->uspace_uarg,
00153 (__address) kernel_uarg->uspace_entry);
00154 while (1)
00155 ;
00156 }
00157
00159 void before_task_runs_arch(void)
00160 {
00161 }
00162
00164 void before_thread_runs_arch(void)
00165 {
00166 supervisor_sp = (__address) &THREAD->kstack[THREAD_STACK_SIZE-SP_DELTA];
00167 }
00168
00169 void after_thread_ran_arch(void)
00170 {
00171 }
00172
00178 __native sys_tls_set(__native addr)
00179 {
00180 return 0;
00181 }
00182
00183