Changeset 335
- Timestamp:
- Aug 7, 2017, 11:19:27 AM (7 years ago)
- Location:
- trunk/hal/x86_64
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_context.c
r311 r335 37 37 error_t hal_cpu_context_create(struct thread_s *thread) 38 38 { 39 hal_cpu_context_t *context; 39 hal_trapframe_t *tf; 40 hal_cpu_context_t *ctx; 40 41 kmem_req_t req; 41 42 … … 45 46 req.flags = AF_KERNEL | AF_ZERO; 46 47 47 c ontext= (hal_cpu_context_t *)kmem_alloc(&req);48 if (c ontext== NULL)48 ctx = (hal_cpu_context_t *)kmem_alloc(&req); 49 if (ctx == NULL) 49 50 return ENOMEM; 50 51 51 52 /* set cpu context pointer in thread */ 52 thread->cpu_context = (void *)c ontext;53 thread->cpu_context = (void *)ctx; 53 54 54 /* build the context */ 55 /* tf_gs */ 56 /* tf_fs */ 57 context->tf_es = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 58 context->tf_ds = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 59 context->tf_rip = (uint64_t)thread->entry_func; 60 context->tf_rflags = PSL_USERSET; 55 /* 56 * Build the context 57 */ 58 ctx->ctx_rsp0 = ((uint64_t)thread->k_stack_base) + thread->k_stack_size; 59 ctx->ctx_rsp0 &= ~0xF; 60 /* XXX: ctx_rsp */ 61 62 /* 63 * Build the trap frame 64 */ 65 tf = (void *)(((uint64_t)thread->k_stack_base + 66 thread->k_stack_size) & ~0xF); 67 tf->tf_gs = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 68 tf->tf_fs = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 69 tf->tf_es = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 70 tf->tf_ds = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 71 tf->tf_rip = (uint64_t)thread->entry_func; 72 tf->tf_rflags = PSL_USERSET; 61 73 62 74 if (thread->type == THREAD_USER) { 63 context->tf_cs = GDT_FIXED_SEL(GDT_UCODE_SEL, SEL_UPL);64 context->tf_rsp = ((uint64_t)thread->u_stack_base) +75 tf->tf_cs = GDT_FIXED_SEL(GDT_UCODE_SEL, SEL_UPL); 76 tf->tf_rsp = ((uint64_t)thread->u_stack_base) + 65 77 thread->u_stack_size; 66 78 } else { 67 context->tf_cs = GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL);68 context->tf_rsp = ((uint64_t)thread->k_stack_base) +79 tf->tf_cs = GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL); 80 tf->tf_rsp = ((uint64_t)thread->k_stack_base) + 69 81 thread->k_stack_size; 70 82 } … … 73 85 } 74 86 75 error_t hal_cpu_context_copy( thread_t * dst, 76 thread_t * src ) 87 error_t hal_cpu_context_copy(thread_t *dst, thread_t *src) 77 88 { 78 89 x86_panic((char *)__func__); … … 80 91 } 81 92 82 void hal_cpu_context_destroy( thread_t * thread ) 93 void hal_cpu_context_destroy(thread_t *thread) 94 { 95 x86_panic((char *)__func__); 96 } 97 98 void hal_cpu_context_switch(thread_t *old, thread_t *new) 99 { 100 x86_panic((char *)__func__); 101 } 102 103 void hal_cpu_context_load( thread_t * thread ) 83 104 { 84 105 x86_panic((char *)__func__); … … 103 124 } 104 125 105 void hal_cpu_context_switch( thread_t * old , thread_t * new )106 {107 x86_panic((char *)__func__);108 }109 110 void hal_cpu_context_load( thread_t * thread )111 {112 x86_panic((char *)__func__);113 }114 115 126 void hal_fpu_context_save( thread_t * thread ) 116 127 { -
trunk/hal/x86_64/core/hal_exception.c
r308 r335 59 59 * Hexception handler. 60 60 */ 61 void hal_exception_entry(hal_ cpu_context_t *ctx)61 void hal_exception_entry(hal_trapframe_t *ctx) 62 62 { 63 63 uint64_t excno = ctx->tf_trapno; -
trunk/hal/x86_64/core/hal_interrupt.c
r274 r335 37 37 * Timer interrupt 38 38 */ 39 void hal_timer_intr(hal_ cpu_context_t *tf)39 void hal_timer_intr(hal_trapframe_t *tf) 40 40 { 41 41 if (hal_get_gid() != 0) { … … 58 58 * Serial Port (COM1) interrupt 59 59 */ 60 void hal_com1_intr(hal_ cpu_context_t *tf)60 void hal_com1_intr(hal_trapframe_t *tf) 61 61 { 62 62 static char prev; … … 132 132 * Keyboard interrupt (8042 PS/2) 133 133 */ 134 void hal_keyboard_intr(hal_ cpu_context_t *tf)134 void hal_keyboard_intr(hal_trapframe_t *tf) 135 135 { 136 136 uint64_t val; -
trunk/hal/x86_64/core/hal_kentry.h
r308 r335 128 128 129 129 /* 130 * The x86_64 CPU context.130 * The x86_64 CPU trap frame. 131 131 */ 132 typedef struct hal_ cpu_context_s {132 typedef struct hal_trapframe_s { 133 133 /* Pushed by INTR_SAVE_REGS */ 134 134 uint64_t tf_rax; … … 164 164 uint64_t tf_rsp; 165 165 uint64_t tf_ss; 166 } hal_trapframe_t; 167 168 typedef struct hal_cpu_context_s { 169 uint64_t ctx_rsp0; 170 uint64_t ctx_rsp; 171 uint64_t ctx_rbp; 166 172 } hal_cpu_context_t; 167 173 -
trunk/hal/x86_64/drivers/ioc_ata.c
r322 r335 226 226 } 227 227 228 void ioc_ata_isr(hal_ cpu_context_t *ctx)228 void ioc_ata_isr(hal_trapframe_t *ctx) 229 229 { 230 230 x86_printf("rip = %Z\n", ctx->tf_rip);
Note: See TracChangeset
for help on using the changeset viewer.