Changeset 45
- Timestamp:
- Jun 23, 2017, 11:55:08 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.x86
r36 r45 63 63 build/kernel/hal/hal_kentry.o \ 64 64 build/kernel/hal/hal_acpi.o \ 65 build/kernel/hal/hal_lapic.o \ 65 66 build/kernel/hal/x86_printf.o \ 66 67 build/kernel/hal/hal_special.o \ … … 307 308 $(DU) -D $@ > $@.txt 308 309 309 build/kernel/hal/hal_init.o: hal/x86_64/hal_init.c \310 hal/x86_64/hal_boot.h \311 hal/x86_64/hal_multiboot.h \310 build/kernel/hal/hal_init.o: hal/x86_64/hal_init.c \ 311 hal/x86_64/hal_boot.h \ 312 hal/x86_64/hal_multiboot.h \ 312 313 hal/x86_64/hal_segmentation.h \ 313 kernel_config.h \ 314 hal/x86_64/hal_acpi.h \ 315 hal/x86_64/hal_lapic.h \ 316 hal/x86_64/hal_internal.h \ 317 kernel_config.h \ 314 318 hal/x86_64/hal_types.h 315 319 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< … … 342 346 build/kernel/hal/hal_acpi.o: hal/x86_64/hal_acpi.c \ 343 347 hal/x86_64/hal_acpi.h \ 348 kernel_config.h \ 349 hal/x86_64/hal_types.h 350 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 351 $(DU) -D $@ > $@.txt 352 353 build/kernel/hal/hal_lapic.o: hal/x86_64/hal_lapic.c \ 354 hal/x86_64/hal_lapic.h \ 344 355 kernel_config.h \ 345 356 hal/x86_64/hal_types.h -
trunk/hal/x86_64/hal_acpi.c
r43 r45 111 111 static void hal_acpi_parse_madt(madt_t *madt) 112 112 { 113 paddr_t lapic_pa = (paddr_t)madt->Address; 113 extern paddr_t lapic_pa; 114 lapic_pa = (paddr_t)madt->Address; 114 115 x86_printf("-> LAPIC address: %Z\n", lapic_pa); 115 116 } -
trunk/hal/x86_64/hal_gpt.c
r44 r45 65 65 } 66 66 67 /* 68 * Reset the bootstrap VA we've used in cluster0 so far. After this 69 * function, cluster0's heap is empty. 70 */ 71 void hal_gpt_bootstrap_reset() 72 { 73 size_t npages = (va_avail - CLUSTER_HEAP_MIN_VA(0)) / PAGE_SIZE; 74 hal_gpt_leave_range(CLUSTER_HEAP_MIN_VA(0), npages); 75 } 76 77 67 78 void hal_gpt_enter(vaddr_t va, paddr_t pa) 68 79 { 69 XASSERT((va % PAGE_SIZE == 0)); 70 XASSERT((pa % PAGE_SIZE == 0)); 80 XASSERT(va % PAGE_SIZE == 0); 81 XASSERT(pa % PAGE_SIZE == 0); 82 XASSERT(va == tmpva || PTE_BASE[pl1_i(va)] == 0); 71 83 PTE_BASE[pl1_i(va)] = (pa & PG_FRAME) | PG_V | PG_KW | PG_NX; 72 84 } … … 77 89 for (i = 0; i < n; i++) { 78 90 hal_gpt_enter(va + i * PAGE_SIZE, pa + i * PAGE_SIZE); 91 invlpg(va + i * PAGE_SIZE); 92 } 93 } 94 95 void hal_gpt_leave(vaddr_t va) 96 { 97 XASSERT(va % PAGE_SIZE == 0); 98 XASSERT(PTE_BASE[pl1_i(va)] != 0); 99 PTE_BASE[pl1_i(va)] = 0; 100 } 101 102 void hal_gpt_leave_range(vaddr_t va, size_t n) 103 { 104 size_t i; 105 for (i = 0; i < n; i++) { 106 hal_gpt_leave(va + i * PAGE_SIZE); 79 107 invlpg(va + i * PAGE_SIZE); 80 108 } -
trunk/hal/x86_64/hal_init.c
r44 r45 24 24 #include <hal_multiboot.h> 25 25 #include <hal_segmentation.h> 26 #include <hal_acpi.h> 27 #include <hal_lapic.h> 26 28 #include <hal_internal.h> 27 29 … … 98 100 hal_acpi_init(); 99 101 x86_printf("[+] hal_acpi_init called\n"); 102 103 hal_gpt_bootstrap_reset(); 104 x86_printf("[+] hal_gpt_bootstrap_reset called\n"); 105 106 hal_init_lapic(); 107 x86_printf("[+] hal_init_lapic called\n"); 100 108 101 109 x86_printf("-> mytest = %z\n", mytest); … … 207 215 static void idt_create() 208 216 { 209 extern uint64_t x86_traps[] ;217 extern uint64_t x86_traps[], x86_intrs[]; 210 218 struct idt_seg *idt; 211 219 size_t i; 212 220 213 221 idt = (struct idt_seg *)&idtstore; 214 for (i = 0; i < NCPUIDT; i++) { 215 idt_set_seg(&idt[i], (void *)x86_traps[i], 0, SDT_SYS386IGT, 216 SEL_KPL, GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL)); 222 223 /* General exceptions */ 224 for (i = CPUVEC_MIN; i < CPUVEC_MAX; i++) { 225 idt_set_seg(&idt[i], (void *)x86_traps[i - CPUVEC_MIN], 0, 226 SDT_SYS386IGT, SEL_KPL, GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL)); 217 227 } 228 229 /* LAPIC interrupts */ 230 for (i = LAPICVEC_MIN; i < LAPICVEC_MAX; i++) { 231 idt_set_seg(&idt[i], (void *)x86_intrs[i - LAPICVEC_MIN], 0, 232 SDT_SYS386IGT, SEL_KPL, GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL)); 233 } 234 218 235 } 219 236 -
trunk/hal/x86_64/hal_internal.h
r39 r45 34 34 paddr_t hal_gpt_bootstrap_palloc(size_t npages); 35 35 vaddr_t hal_gpt_bootstrap_valloc(size_t npages); 36 void hal_gpt_bootstrap_reset(); 36 37 void hal_gpt_enter(vaddr_t va, paddr_t pa); 37 38 void hal_gpt_enter_range(vaddr_t va, paddr_t pa, size_t n); 39 void hal_gpt_leave(vaddr_t va); 40 void hal_gpt_leave_range(vaddr_t va, size_t n); 38 41 void hal_gpt_init(paddr_t firstpa); 39 42 -
trunk/hal/x86_64/hal_kentry.S
r29 r45 36 36 .type hal_trap_entry, @function 37 37 38 /* 39 * General exceptions. 40 */ 38 41 ASM_ENTRY(x86_trap00) 39 42 ZTRAPENTRY(T_DIVIDE) … … 111 114 ZTRAPENTRY(T_RESERVED) 112 115 116 /* 117 * LAPIC interrupts. 118 */ 119 ASM_ENTRY(x86_spurious) 120 ZTRAPENTRY(T_ASTFLT) 121 122 123 113 124 /* 114 125 * Arguments pushed on the stack: … … 128 139 .data 129 140 .globl x86_traps 141 .globl x86_intrs 130 142 .type x86_traps, @object 143 .type x86_intrs, @object 131 144 132 145 .align 64 … … 149 162 .quad x86_trap1e, x86_trap1f 150 163 164 x86_intrs: 165 .quad x86_spurious 166 -
trunk/hal/x86_64/hal_segmentation.h
r31 r45 191 191 * Entries in the Interrupt Descriptor Table (IDT) 192 192 */ 193 #define NCPUIDT 32 /* reserved entries for CPU exceptions */ 193 #define CPUVEC_MIN 0 194 #define CPUVEC_MAX 32 /* reserved entries for CPU exceptions */ 195 #define LAPICVEC_MIN CPUVEC_MAX 196 #define LAPICVEC_MAX (LAPICVEC_MIN + 1) 197 194 198 #define NIDT 256 /* total number of IDT entries */ 195 199
Note: See TracChangeset
for help on using the changeset viewer.