void os_init_cont(void) { /* Reset the GDT. Although user processes in Nanos run in Ring 0, they have their own virtual address space. Therefore, the old GDT located in physical address 0x7C00 cannot be used again. */ init_segment(); /* Initialize the serial port. After that, you can use printk() */ init_serial(); /* Set up interrupt and exception handlers, just as we did in the game. */ init_idt(); /* Initialize the intel 8259 PIC. */ init_intr(); /* Initialize processes. You should fill this. */ init_proc(); welcome(); sti(); /* This context now becomes the idle process. */ while (1) { wait_intr(); } }
/* 主循环,bootloader载入game二进制文件后,就跳转到这里执行 */ void game_init(void) { init_timer(); init_idt(); init_intr(); enable_interrupt(); play(); /* 这里是演示代码,显示浮动的文字和键盘扫描码 */ assert(0); /* 此处永远不应该返回,为什么? */ }
void game_init(void) { init_serial(); init_timer(); init_idt(); init_intr(); set_timer_intr_handler(timer_event); set_keyboard_intr_handler(keyboard_event); printk("game start!\n"); enable_interrupt(); main_loop(); assert(0); /* main_loop是死循环,永远无法返回这里 */ }
void init_cond() { init_segment(); init_idt(); init_intr(); init_serial(); init_timer(); init_mem(); sem_init(); readsect((void *)directory_d.entries,201 + 256); printk("Filename = %s\n",directory_d.entries[0].filename); env_init(); kernel_env.file[0].opened = true; kernel_env.file[0].offset = 0; curenv = &kernel_env; set_timer_intr_handler(kernel_timer_event); //asm volatile("cli"); env_create(200,0,ENV_TYPE_USER); env_run(&envs[0]); }
int main (void) { init_system(); init_intr(); GLCD_DisplayString(1, 1, 1, "PRESS COUNT: "); sprintf(curr_count, "%02d", 0); GLCD_DisplayString(1, 14, 1, (unsigned char *)curr_count); while (1) { GLCD_DisplayString(7,1,1,"STATUS: RUNNING"); sprintf(curr_count, "%02d", button_press_count); GLCD_DisplayString(1, 14, 1, (unsigned char *)curr_count); GLCD_DisplayString(3,1,1,"LOGIC: BURSTY ;)"); sprintf(cur_time, "%02d:%02d", ((g_ms)/ms_in_min),((g_ms)/ms_coeff)%sec_in_min); GLCD_DisplayString(5, 5, 1, (unsigned char *)cur_time); // Turn off the LED LPC_GPIO1->FIOCLR = 1 << LED_PIN; } }
int main(void) { init_pmm(); if (init_mm()) return(1); vid_init(); vid_set_attr(FG_COLOR, RED); printf("\naMOS BOSS V.%s %s\n", STRING_VERSION, BUILD_ARCH); printf("Build %s %s by %s on %s\n\n", COMPILE_DATE, COMPILE_TIME, COMPILE_BY, COMPILE_HOST); vid_set_attr(FG_COLOR, WHITE); init_pit(); init_tss(); if (init_intr()) return(1); init_cpu(); if (init_sched()) return(1); init_fd(); printf("System memory: %d Mb\n\n", (int)pmm_get_size_mb()); printf("Free kernel mem: %d bytes\nUsed kernel mem: %d bytes\n", (int)get_free_mem(), (int)get_used_mem()); for (;;) {} return(0); }
void game_init(void) { /* Setting up a 100Hz timer */ init_100hz_timer(); /* Setting up the interrupt descriptor table, this procedure installs ``actual'' interrupt handlers */ init_idt(); /* Setting up the interrupt controller i8259, the interrupt code will start at 32, and i8259 will send end-of-interrupt signal automatically */ init_intr(); /* Setting up the game interrupt handlers. the start_frame and key_stroke procedures are wrapped by our interrupt handler to make interrupts transparent. For implementation, you simply need to know that start_frame is called for every timer interrupt, and so does key_stroke for every keyboard interrupt (press or release). */ set_timer_intr_handler(start_frame); set_keyboard_intr_handler(key_stroke); /* Calls the game logic. All game logic related codes are in game.c */ init_game(); /* Just a ``sti'' instruction */ enable_interrupt(); /* The main loop now needs to do nothing but wait for coming endless interrupts. All game tasks are done in the interrupt handler. */ while (1) { idle_cpu(); } }
void kentry(void) { init_serial(); //初始化串口输出 init_idt(); init_timer(); init_intr(); init_seg(); //getKeyCode(); uint32_t entry = load_umain(); init_pcb(entry); //putchar('A'); asm volatile("movl %%eax, %%esp" ::"a"(&idle.regs.esp)); enable_interrupt(); while(1){ //putchar('^'); wait_for_interrupt(); } ///p_idle(); //enter_user_space(entry); while(1); }
void os_init_cont(void) { /* Reset the GDT. Although user processes in Nanos run in Ring 0, they have their own virtual address space. Therefore, the old GDT located in physical address 0x7C00 cannot be used again. */ init_segment(); /* Initialize the serial port. After that, you can use printk() */ init_serial(); /* Set up interrupt and exception handlers, just as we did in the game. */ init_idt(); /* Initialize the intel 8259 PIC. */ //The Intel 8259 is a Programmable Interrupt Controller (PIC) init_intr(); /** initialize kmalloc -- have to initialize it before init process, for using it in allocating memory for PCB */ init_kmalloc(); // make it NOINTR, can receive msg, can schedule init_idle(); NOINTR; /** init_driver() have to before init_file_system() for FM have to send message to `ide` to read file system */ init_driver(); init_manager(); NOINTR; init_error_msg(); // init_proc() and init_manager() can replace?? // solved by split set count_of_lock out of init_proc(); //more_frequent(); // init empty thread init_proc_test(); // here is to initialize shell process, which must later // than init_manager -- for it will send message to // managers //ram_user_process(); // @checked: move from locked state to unlocked state init_file_system(); unlock(); // set interrupt enabled INTR; /** init_file_system() have to before init_proc() for init_proc() will using the `default_cwd` which is initialized by FM */ /* Initialize the state of process idle, ie the running process for set up right lock num to avoid other initialization enable the interrupt and cause problem */ // @checked: move from locked state to unlocked state welcome(); user_process(); // set idle not to using cpu time // for it is originally set to sleep when send message current->state = SLEEPED; /* This context now becomes the idle process. */ while (1) { printk("!"); wait_intr(); } }