Changes in kernel/arch/ia32/src/pm.c [d6f9fff:0f17bff] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/pm.c
rd6f9fff r0f17bff 47 47 #include <arch/boot/boot.h> 48 48 #include <interrupt.h> 49 #include <arch/cpu.h> 49 50 50 51 /* … … 61 62 */ 62 63 descriptor_t gdt[GDT_ITEMS] = { 63 /* NULL descriptor */ 64 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 65 /* KTEXT descriptor */ 66 { 0xffff, 0, 0, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 1, 1, 0 }, 67 /* KDATA descriptor */ 68 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 0xf, 0, 0, 1, 1, 0 }, 69 /* UTEXT descriptor */ 70 { 0xffff, 0, 0, AR_PRESENT | AR_CODE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 71 /* UDATA descriptor */ 72 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 73 /* TSS descriptor - set up will be completed later */ 74 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 75 /* VREG descriptor - segment used for virtual registers, will be reinitialized later */ 76 { 0xffff, 0 , 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 64 [NULL_DES] = { 65 0 66 }, 67 [KTEXT_DES] = { 68 .limit_0_15 = 0xffff, 69 .limit_16_19 = 0xf, 70 .access = AR_PRESENT | AR_CODE | DPL_KERNEL, 71 .special = 1, 72 .granularity = 1 73 }, 74 [KDATA_DES] = { 75 .limit_0_15 = 0xffff, 76 .limit_16_19 = 0xf, 77 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 78 .special = 1, 79 .granularity = 1 80 }, 81 [UTEXT_DES] = { 82 .limit_0_15 = 0xffff, 83 .limit_16_19 = 0xf, 84 .access = AR_PRESENT | AR_CODE | DPL_USER, 85 .special = 1, 86 .granularity = 1 87 }, 88 [UDATA_DES] = { 89 .limit_0_15 = 0xffff, 90 .limit_16_19 = 0xf, 91 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 92 .special = 1, 93 .granularity = 1 94 }, 95 [TSS_DES] = { /* set up will be completed later */ 96 0, 97 }, 98 [VREG_DES] = { /* will be reinitialized later */ 99 .limit_0_15 = 0xffff, 100 .limit_16_19 = 0xf, 101 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 102 .special = 1, 103 .granularity = 1 104 }, 77 105 /* VESA Init descriptor */ 78 106 #ifdef CONFIG_FB 79 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | AR_READABLE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 }, 80 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 } 107 [VESA_INIT_CODE_DES] = { 108 .limit_0_15 = 0xffff, 109 .limit_16_19 = 0xf, 110 .base_16_23 = VESA_INIT_SEGMENT >> 12, 111 .access = AR_PRESENT | AR_CODE | AR_READABLE | DPL_KERNEL 112 }, 113 [VESA_INIT_DATA_DES] = { 114 .limit_0_15 = 0xffff, 115 .limit_16_19 = 0xf, 116 .base_16_23 = VESA_INIT_SEGMENT >> 12, 117 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL 118 } 81 119 #endif 82 120 }; … … 219 257 } 220 258 221 /* Clean IOPL(12,13) and NT(14) flags in EFLAGS register */222 static void clean_IOPL_NT_flags(void)223 {224 asm volatile (225 "pushfl\n"226 "pop %%eax\n"227 "and $0xffff8fff, %%eax\n"228 "push %%eax\n"229 "popfl\n"230 ::: "eax"231 );232 }233 234 /* Clean AM(18) flag in CR0 register */235 static void clean_AM_flag(void)236 {237 asm volatile (238 "mov %%cr0, %%eax\n"239 "and $0xfffbffff, %%eax\n"240 "mov %%eax, %%cr0\n"241 ::: "eax"242 );243 }244 245 259 void pm_init(void) 246 260 { … … 289 303 tr_load(GDT_SELECTOR(TSS_DES)); 290 304 291 clean_IOPL_NT_flags(); /* Disable I/O on nonprivileged levels and clear NT flag. */ 292 clean_AM_flag(); /* Disable alignment check */ 305 /* Disable I/O on nonprivileged levels and clear NT flag. */ 306 write_eflags(read_eflags() & ~(EFLAGS_IOPL | EFLAGS_NT)); 307 308 /* Disable alignment check */ 309 write_cr0(read_cr0() & ~CR0_AM); 293 310 } 294 311
Note:
See TracChangeset
for help on using the changeset viewer.