void start_kernel(void)分析 ! \linux-1.0\init\main.c
生活随笔
收集整理的這篇文章主要介紹了
void start_kernel(void)分析 ! \linux-1.0\init\main.c
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//啟動系統內核
//asmlinkage 為通過堆棧傳遞參數,默認為通過寄存器傳遞參數。
asmlinkage void start_kernel(void)
{
/** Interrupts are still disabled. Do necessary setups, then* enable them*///設置中斷向量表set_call_gate(&default_ldt,lcall7);//設定初始化設備地址ROOT_DEV = ORIG_ROOT_DEV;// 設定設備信息地址drive_info = DRIVE_INFO;//設定屏幕信息地址screen_info = SCREEN_INFO;//設定aux 設備當前地址aux_device_present = AUX_DEVICE_INFO;//設定內存末端值memory_end = (1<<20) + (EXT_MEM_K<<10);memory_end &= PAGE_MASK;//設定臨時盤的大小ramdisk_size = RAMDISK_SIZE;//拷貝命令行copy_options(command_line,COMMAND_LINE);//如果內存大于16M 設定內存末端為16M
#ifdef CONFIG_MAX_16Mif (memory_end > 16*1024*1024)memory_end = 16*1024*1024;
#endif//設定root 的多位標志位if (MOUNT_ROOT_RDONLY)root_mountflags |= MS_RDONLY;//如果最末端大于1M 設定內存開始點和最低內存開始點if ((unsigned long)&end >= (1024*1024)) {memory_start = (unsigned long) &end;low_memory_start = PAGE_SIZE;} else{//如果內存不大于1M ;設定內存開始點為1M處, 最低內存開始為end;memory_start = 1024*1024;low_memory_start = (unsigned long) &end;}//低內存開始點對齊low_memory_start = PAGE_ALIGN(low_memory_start);//頁緩存區初始化memory_start = paging_init(memory_start,memory_end);//設定EISA 線路標志 if (strncmp((char*)0x0FFFD9, "EISA", 4) == 0)EISA_bus = 1;//設置各個中斷向量表.trap_init();//初始化中斷請求init_IRQ();//日程初始化sched_init();//解析命令行parse_options(command_line);
#ifdef CONFIG_PROFILEprof_buffer = (unsigned long *) memory_start;prof_len = (unsigned long) &end;prof_len >>= 2;memory_start += prof_len * sizeof(unsigned long);
#endif//分配內存 初始化memory_start = kmalloc_init(memory_start,memory_end);//memory_start = chr_dev_init(memory_start,memory_end);memory_start = blk_dev_init(memory_start,memory_end);//設定允許中斷sti();//校準延時calibrate_delay();
#ifdef CONFIG_INET//網絡初始化memory_start = net_dev_init(memory_start,memory_end);
#endif
#ifdef CONFIG_SCSI//scsi 設備初始化memory_start = scsi_dev_init(memory_start,memory_end);
#endif//節點初始化memory_start = inode_init(memory_start,memory_end);//文件表初始化memory_start = file_table_init(memory_start,memory_end);//內存區初始化mem_init(low_memory_start,memory_start,memory_end);//緩存初始化buffer_init();// 時間初始化time_init();//軟盤初始化floppy_init();//sock 初始化sock_init();
#ifdef CONFIG_SYSVIPC//ipc 初始化ipc_init();
#endif//設定允許中斷sti();/** check if exception 16 works correctly.. This is truly evil* code: it disables the high 8 interrupts to make sure that* the irq13 doesn't happen. But as this will lead to a lockup* if no exception16 arrives, it depends on the fact that the* high 8 interrupts will be re-enabled by the next timer tick.* So the irq13 will happen eventually, but the exception 16* should get there first..*///hard_math設定為是時進行響應處理if (hard_math) {unsigned short control_word;printk("Checking 386/387 coupling... ");timer_table[COPRO_TIMER].expires = jiffies+50;timer_table[COPRO_TIMER].fn = copro_timeout;timer_active |= 1<<COPRO_TIMER;__asm__("clts ; fninit ; fnstcw %0 ; fwait":"=m" (*&control_word));control_word &= 0xffc0;__asm__("fldcw %0 ; fwait": :"m" (*&control_word));outb_p(inb_p(0x21) | (1 << 2), 0x21);__asm__("fldz ; fld1 ; fdiv %st,%st(1) ; fwait");timer_active &= ~(1<<COPRO_TIMER);if (!fpu_error)printk("Ok, fpu using %s error reporting.\n",ignore_irq13?"exception 16":"irq13");}//如果沒有設定數字仿真設定進行報錯
#ifndef CONFIG_MATH_EMULATIONelse {printk("No coprocessor found and no math emulation present.\n");printk("Giving up.\n");for (;;) ;}
#endif//設定系統版本 并打印出來system_utsname.machine[1] = '0' + x86;printk(linux_banner);//設定到用戶模式move_to_user_mode();//初始化完成, 創建子進程進入到shell界面.if (!fork()) /* we count on this going ok */init();
/** task[0] is meant to be used as an "idle" task: it may not sleep, but* it might do some general things like count free pages or it could be* used to implement a reasonable LRU algorithm for the paging routines:* anything that can be useful, but shouldn't take time from the real* processes.** Right now task[0] just does a infinite idle loop.*///父進程進行休眠。for(;;)idle();
}
總結
以上是生活随笔為你收集整理的void start_kernel(void)分析 ! \linux-1.0\init\main.c的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机网络第七版和课后答案百度网盘下载
- 下一篇: mysql拼接字符串的方式_mysql