- Timestamp:
- Jun 28, 2017, 3:24:02 PM (8 years ago)
- Location:
- trunk/hal/x86_64/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_apic.c
r83 r86 105 105 hal_lapic_write(LAPIC_LVT_THM, LAPIC_THM_M); 106 106 hal_lapic_write(LAPIC_LVT_ERR, LAPIC_ERR_M); 107 108 /* Now, enable the timer in repeated mode. */ 109 hal_lapic_write(LAPIC_LVT_TMR, LAPIC_TMR_TM|LAPIC_TMR_M); 110 hal_lapic_write(LAPIC_DCR_TIMER, LAPIC_DCRT_DIV1); 111 hal_lapic_write(LAPIC_ICR_TIMER, 1000000000); // XXX calibrate 112 hal_lapic_write(LAPIC_LVT_TMR, LAPIC_TMR_TM|LAPIC_TIMER_VECTOR); 107 113 } 108 114 -
trunk/hal/x86_64/core/hal_apic.h
r82 r86 20 20 */ 21 21 22 #ifndef x86_ASM 22 23 uint32_t hal_lapic_gid(); 23 24 void hal_apic_init(); 25 #endif 24 26 25 27 #define LAPIC_SPURIOUS_VECTOR LAPICVEC_MIN -
trunk/hal/x86_64/core/hal_init.c
r82 r86 191 191 192 192 sti(); 193 while (1); 193 194 194 195 int m = 0; -
trunk/hal/x86_64/core/hal_kentry.S
r82 r86 23 23 #include <hal_boot.h> 24 24 #include <hal_kentry.h> 25 #include <hal_apic.h> 25 26 26 27 #define TRAPENTRY(a) \ 27 pushq 28 jmp 28 pushq $(a); \ 29 jmp alltraps; 29 30 30 31 #define ZTRAPENTRY(a) \ 31 pushq 32 pushq $0; \ 32 33 TRAPENTRY(a) 33 34 34 35 .text 35 36 .globl hal_trap_entry 37 .globl hal_timer_intr 36 38 .type hal_trap_entry, @function 39 .type hal_timer_intr, @function 37 40 38 41 /* … … 118 121 * LAPIC interrupts. 119 122 */ 120 ASM_ENTRY(x86_ spurious)123 ASM_ENTRY(x86_lapic_spurious) 121 124 ZTRAPENTRY(T_ASTFLT) 122 ASM_ENTRY(x86_timer) 123 ZTRAPENTRY(T_ASTFLT) 125 126 ASM_ENTRY(x86_lapic_timer) 127 pushq $0 128 pushq $T_ASTFLT 129 INTR_SAVE_REGS 130 131 movq %rsp,%rdi 132 call hal_timer_intr 133 134 movq lapic_va(%rip),%rax 135 movl $0,LAPIC_EOI(%rax) 136 137 INTR_RESTORE_REGS 138 addq $16,%rsp 139 iretq 124 140 125 141 /* … … 164 180 165 181 x86_intrs: 166 .quad x86_ spurious167 .quad x86_ timer182 .quad x86_lapic_spurious 183 .quad x86_lapic_timer 168 184 -
trunk/hal/x86_64/core/hal_kentry.h
r51 r86 45 45 #define T_USER 0x100 46 46 47 #define TF_REGSIZE (19 * 8) 48 49 #define INTR_SAVE_REGS \ 50 subq $TF_REGSIZE,%rsp ; \ 51 movq %rax,TF_RAX(%rsp) ; \ 52 movq %rbx,TF_RBX(%rsp) ; \ 53 movq %rcx,TF_RCX(%rsp) ; \ 54 movq %rdx,TF_RDX(%rsp) ; \ 55 movq %rbp,TF_RBP(%rsp) ; \ 56 movq %rdi,TF_RDI(%rsp) ; \ 57 movq %rsi,TF_RSI(%rsp) ; \ 58 movq %r8,TF_R8(%rsp) ; \ 59 movq %r9,TF_R9(%rsp) ; \ 60 movq %r10,TF_R10(%rsp) ; \ 61 movq %r11,TF_R11(%rsp) ; \ 62 movq %r12,TF_R12(%rsp) ; \ 63 movq %r13,TF_R13(%rsp) ; \ 64 movq %r14,TF_R14(%rsp) ; \ 65 movq %r15,TF_R15(%rsp) ; \ 66 movw %gs,TF_GS(%rsp) ; \ 67 movw %fs,TF_FS(%rsp) ; \ 68 movw %es,TF_ES(%rsp) ; \ 69 movw %ds,TF_DS(%rsp) ; \ 70 cld 71 72 #define INTR_RESTORE_REGS \ 73 movq TF_RAX(%rsp),%rax ; \ 74 movq TF_RBX(%rsp),%rbx ; \ 75 movq TF_RCX(%rsp),%rcx ; \ 76 movq TF_RDX(%rsp),%rdx ; \ 77 movq TF_RBP(%rsp),%rbp ; \ 78 movq TF_RDI(%rsp),%rdi ; \ 79 movq TF_RSI(%rsp),%rsi ; \ 80 movq TF_R8(%rsp),%r8 ; \ 81 movq TF_R9(%rsp),%r9 ; \ 82 movq TF_R10(%rsp),%r10 ; \ 83 movq TF_R11(%rsp),%r11 ; \ 84 movq TF_R12(%rsp),%r12 ; \ 85 movq TF_R13(%rsp),%r13 ; \ 86 movq TF_R14(%rsp),%r14 ; \ 87 movq TF_R15(%rsp),%r15 ; \ 88 movw TF_GS(%rsp),%gs ; \ 89 movw TF_FS(%rsp),%fs ; \ 90 movw TF_ES(%rsp),%es ; \ 91 movw TF_DS(%rsp),%ds ; \ 92 addq $TF_REGSIZE,%rsp ; \ 93 cld 94 47 95 #ifndef x86_ASM 48 96 … … 51 99 */ 52 100 struct trapframe { 101 /* Pushed by INTR_SAVE_REGS */ 102 uint64_t tf_rax; 103 uint64_t tf_rbx; 104 uint64_t tf_rcx; 105 uint64_t tf_rdx; 53 106 uint64_t tf_rdi; 54 107 uint64_t tf_rsi; 55 uint64_t tf_rdx; 56 uint64_t tf_r10; 108 uint64_t tf_rbp; 57 109 uint64_t tf_r8; 58 110 uint64_t tf_r9; 59 60 uint64_t tf_arg6; 61 uint64_t tf_arg7; 62 uint64_t tf_arg8; 63 uint64_t tf_arg9; 64 65 uint64_t tf_rcx; 111 uint64_t tf_r10; 66 112 uint64_t tf_r11; 67 113 uint64_t tf_r12; … … 69 115 uint64_t tf_r14; 70 116 uint64_t tf_r15; 71 uint64_t tf_rbp;72 uint64_t tf_rbx;73 uint64_t tf_rax;74 75 117 uint64_t tf_gs; 76 118 uint64_t tf_fs; … … 78 120 uint64_t tf_ds; 79 121 122 /* Pushed by the ISR */ 80 123 uint64_t tf_trapno; 81 124 … … 98 141 99 142 /* These are pushed for a trap */ 100 uint64_t tf_err; 143 uint64_t tf_err; /* in fact, this one may not... */ 101 144 uint64_t tf_rip; 102 145 uint64_t tf_cs; … … 108 151 }; 109 152 153 #else 154 155 /* offsets in the trapframe structure */ 156 #define TF_RAX 0 157 #define TF_RBX 8 158 #define TF_RCX 16 159 #define TF_RDX 24 160 #define TF_RDI 32 161 #define TF_RSI 40 162 #define TF_RBP 48 163 #define TF_R8 56 164 #define TF_R9 64 165 #define TF_R10 72 166 #define TF_R11 80 167 #define TF_R12 88 168 #define TF_R13 96 169 #define TF_R14 104 170 #define TF_R15 112 171 #define TF_GS 120 172 #define TF_FS 128 173 #define TF_ES 136 174 #define TF_DS 144 175 110 176 #endif 111 177 -
trunk/hal/x86_64/core/hal_trap.c
r82 r86 52 52 * Trap handler. 53 53 */ 54 void 55 hal_trap_entry(struct small_trapframe *tf) 54 void hal_trap_entry(struct small_trapframe *tf) 56 55 { 57 56 uint64_t trapno = tf->tf_trapno; … … 68 67 x86_printf("-> rip = %Z\n", tf->tf_rip); 69 68 x86_printf("-> rsp = %Z\n", tf->tf_rsp); 69 x86_printf("-> err = %Z\n", tf->tf_err); 70 70 x86_printf("****** FAULT OCCURRED ******\n\n"); 71 71 … … 73 73 } 74 74 75 /* 76 * Timer interrupt 77 */ 78 void hal_timer_intr(struct trapframe *tf) 79 { 80 x86_printf("-> got timer: rip=%Z\n", tf->tf_rip); 81 return; 82 } 75 83
Note: See TracChangeset
for help on using the changeset viewer.