main(void) { set_eflags(); /* Define the kernel segment registers and a stack to execute the 'main' code */ // It is necessary to use a global static array for the stack, because the // compiler will know its final memory location. Otherwise it will try to use the // 'ds' register to access the address... but we are not ready for that yet // (we are still in real mode). set_seg_regs(__KERNEL_DS, __KERNEL_DS, (DWord) &protected_tasks[2]); printk("Kernel Loaded! "); /* Initialize hardware data */ setGdt(); /* Definicio de la taula de segments de memoria */ setIdt(); /* Definicio del vector de interrupcions */ setTSS(); /* Definicio de la TSS */ /* Initialize Memory */ init_mm(); /* Initialize an address space to be used for the monoprocess version of ZeOS */ //monoprocess_init_addr_space(); /* TO BE DELETED WHEN ADDED THE PROCESS MANAGEMENT CODE TO BECOME MULTIPROCESS */ /* Initialize Scheduling */ init_sched(); /* Initialize idle task data */ init_idle(); /* Initialize task 1 data */ init_task1(); zeos_console_init(); /* Move user code/data now (after the page table initialization) */ copy_data((void *) KERNEL_START + *p_sys_size, usr_main, *p_usr_size); printk("Entering user mode..."); enable_int(); /* * We return from a 'theorical' call to a 'call gate' to reduce our privileges * and going to execute 'magically' at 'usr_main'... */ return_gate(__USER_DS, __USER_DS, USER_ESP, __USER_CS, L_USER_START); /* The execution never arrives to this point */ return 0; }
main(void) { set_eflags(); /* Define the kernel segment registers */ set_seg_regs(__KERNEL_DS, __KERNEL_DS, INITIAL_ESP); printk("Kernel Loaded! "); /* Initialize hardware data */ setGdt(); /* Definicio de la taula de segments de memoria */ setIdt(); /* Definicio del vector de interrupcions */ setTSS(); /* Definicio de la TSS */ /* Initialize Memory */ init_mm(); /* Initialize an address space to be used for the monoprocess version of ZeOS */ //monoprocess_init_addr_space(); /* TO BE DELETED WHEN ADDED THE PROCESS MANAGEMENT CODE TO BECOME MULTIPROCESS */ /* Initialize Scheduling */ init_sched(); /* Initialize idle task data */ init_idle(); /* Initialize task 1 data */ init_task1(); zeos_console_init(); /* Move user code/data now (after the page table initialization) */ copy_data((void *) KERNEL_START + *p_sys_size, usr_main, *p_usr_size); zeos_ticks = 0; printk("Entering user mode..."); enable_int(); /* * We return from a 'theorical' call to a 'call gate' to reduce our privileges * and going to execute 'magically' at 'usr_main'... */ // zeos_init_auxjp(); return_gate(__USER_DS, __USER_DS, USER_ESP, __USER_CS, L_USER_START); /* The execution never arrives to this point */ return 0; }