2009年8月24日月曜日

lock_kernel

start_kernelは少し進みます。

======
/*
* Interrupts are still disabled. Do necessary setups, then
* enable them
*/
lock_kernel();
tick_init();
boot_cpu_init();
page_address_init();
printk(KERN_NOTICE);
printk(linux_banner);
setup_arch(&command_line);
mm_init_owner(&init_mm, &init_task);
setup_command_line(command_line);
unwind_setup();
setup_per_cpu_areas();
setup_nr_cpu_ids();
smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */

======

今回はlock_kernelを見てみましょう。
実体は「__acquires」という名前でarch/x86/kernel/cpu/mtrr/generic.cにあります。

======
static void prepare_set(void) __acquires(set_atomicity_lock)
{
unsigned long cr0;

/* スピンロックを獲得 */
spin_lock(&set_atomicity_lock);

/* CR0レジストをCD=1、NW=0の状態にする */
cr0 = read_cr0() | X86_CR0_CD;
write_cr0(cr0);
wbinvd();

/* グローバルページ機能をDisableにする */
if ( cpu_has_pge ) {
cr4 = read_cr4();
write_cr4(cr4 & ~X86_CR4_PGE);
}

/* TLBをクリア */
__flush_tlb();

/* MTRRの値を読み取る */
rdmsr(MTRRdefType_MSR, deftype_lo, deftype_hi);

/* MTRRを無効にしてuncachableに設定する */
mtrr_wrmsr(MTRRdefType_MSR, deftype_lo & ~0xcff, deftype_hi);
}

======

まあ、なんか、いろいろとクリアしているみたいです。

0 件のコメント:

コメントを投稿