main(void) { InitKernel(TIMESLICE, AtInterrupt); if( CreateProcess("P1", P1) == -1) { // Fel, ingen process skapades ExitKernel(); } if( CreateProcess("P2", P2) == -1) { // Fel, ingen process skapades ExitKernel(); } if( CreateProcess("P3", P3) == -1) { // Fel, ingen process skapades ExitKernel(); } // StartKernel(); StartKernelForSim(); }
int main(){ int * first_swi_instruction_address = (int *)(0x8); int * swi_call_entry_address = (int *)(0x20); // The first thing on the stack, is going to be the sp value we always want a kernel function to start wtih. int * kernel_saved_sp_loc = (int *)(KERNEL_STACK_START); void (*swi_entry)() = asm_SwiCallEntry; *swi_call_entry_address = (int)swi_entry; // 1110(always) 010 (load/store immediate ) 1(offset based) 0(subtracted from base) 0(word access) 0(not updating base) 1(load) 1111(r15) 1111(r15) 0000 0000 0000 // /* From the doc: 'If R15 is specified as register Rn, the value used is the address of the instruction plus eight. * ' WHAT??? WHY??? I WASTED A WHOLE DAY BECAUSE OF THIS!!! * * LRD PC [PC, #-4]*/ *first_swi_instruction_address = 0xE51FF004; first_swi_instruction_address++; // Put the address of the fcn here *first_swi_instruction_address = (int)&asm_SwiCallEntry; // Initialize the value of the saved kernel stack pointer that we will load every time we do an SWI call *kernel_saved_sp_loc = (int)(KERNEL_STACK_START - sizeof(KernelState)); InitKernel(); return 0; }
int main(void) { InitKernel();//Initialize all kernel data structures USERMODE; //Switch to user mode mymain(); //Now call what you would normally call main() return 0; }