4.4.2절의 (5)에서 start_kernel이 불리는데 여기 부터가 일반 적인 커널의 시작이라고 생각하면 된다.
start_kernel 전 까지는 리눅스 커널이 실행되기 위한 기본 적인 초기화 등을 해놓은 상태라고 생각하면 된다. 아래에 start_kernel()만을 발췌해 놨다. 또 커널 부팅 중 남은 기록은 5.8절를 참조 바란다.
/*
* Activate the first processor.
*/
asmlinkage void __init start_kernel(void)
{
char * command_line;
unsigned long mempages;
extern char saved_command_line[];
/*
* Interrupts are still disabled. Do necessary setups, then
* enable them
*/
(1)
lock_kernel();
(2)
printk(linux_banner);
(3)
setup_arch(&command_line);
(4)
printk("Kernel command line: %s\n", saved_command_line);
(5)
parse_options(command_line);
(6)
trap_init();
(7)
init_IRQ();
(8)
sched_init();
(9)
softirq_init();
(10)
time_init();
/*
* HACK ALERT! This is early. We're enabling the console before
* we've done PCI setups etc, and console_init() must be aware of
* this. But we do want output early, in case something goes wrong.
*/
(11)
console_init();
#ifdef CONFIG_MODULES
(12)
init_modules();
#endif
if (prof_shift) {
unsigned int size;
/* only text is profiled */
prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
prof_len >>= prof_shift;
size = prof_len * sizeof(unsigned int) + PAGE_SIZE-1;
prof_buffer = (unsigned int *) alloc_bootmem(size);
}
(13)
kmem_cache_init();
(14)
sti();
(15)
calibrate_delay();
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start && !initrd_below_start_ok &&
initrd_start < min_low_pfn << PAGE_SHIFT) {
printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
"disabling it.\n",initrd_start,min_low_pfn << PAGE_SHIFT);
initrd_start = 0;
}
#endif
(16)
mem_init();
(17)
kmem_cache_sizes_init();
pgtable_cache_init();
mempages = num_physpages;
(18)
fork_init(mempages);
(19)
proc_caches_init();
(20)
vfs_caches_init(mempages);
buffer_init(mempages);
page_cache_init(mempages);
#if defined(CONFIG_ARCH_S390)
ccwcache_init();
#endif
signals_init();
#ifdef CONFIG_PROC_FS
proc_root_init();
#endif
#if defined(CONFIG_SYSVIPC)
(21)
ipc_init();
#endif
(22)
check_bugs();
printk("POSIX conformance testing by UNIFIX\n");
/*
* We count on the initial thread going ok
* Like idlers init is an unlocked kernel thread, which will
* make syscalls (and thus be locked).
*/
(23)
smp_init();
(24)
rest_init();
} |
const char *linux_banner =
"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; |
이 내용은 부팅할 때 아래와 같이 출력되고 /var/log/dmesg의 첫 줄에 기록된다.
Linux version 2.4.16 (root@localhost) (gcc version 2.95.3 20010315 (release)) #22 2002. 02. 27. (수) 13:30:14 KST |
해석된 옵션은 '='가 있으면 환경 변수로 취급되고 없으면 옵션을 처리되 환경 변수는 envp_init[]에 담기고 옵션은 argv_init[]에 담긴다.
나머지에 대해선 5.7절 참조