Changeset 193
- Timestamp:
- Jul 13, 2017, 9:28:06 AM (7 years ago)
- Location:
- trunk/hal/x86_64/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_boot.S
r145 r193 26 26 #include <hal_multiboot.h> 27 27 #include <hal_register.h> 28 #include <hal_kentry.h> 28 29 #include <hal_segmentation.h> 29 30 -
trunk/hal/x86_64/core/hal_boot.h
r147 r193 39 39 40 40 /* -------------------------------------------------------------------------- */ 41 42 #define PSL_MBO 0x0000000243 41 44 42 #define STKPAGES 4 -
trunk/hal/x86_64/core/hal_context.c
r51 r193 33 33 34 34 #include <hal_context.h> 35 #include <hal_kentry.h> 36 #include <hal_internal.h> 37 #include <hal_segmentation.h> 35 38 36 #include <hal_internal.h> 39 error_t hal_cpu_context_create(struct thread_s *thread) 40 { 41 hal_cpu_context_t *context; 42 kmem_req_t req; 37 43 38 error_t hal_cpu_context_create( struct thread_s * thread ) 39 { 40 x86_panic((char *)__func__); 44 /* allocate memory for cpu_context */ 45 req.type = KMEM_CPU_CTX; 46 req.size = sizeof(hal_cpu_context_t); 47 req.flags = AF_KERNEL | AF_ZERO; 48 49 context = (hal_cpu_context_t *)kmem_alloc(&req); 50 if (context == NULL) 51 return ENOMEM; 52 53 /* set cpu context pointer in thread */ 54 thread->cpu_context = (void*)context; 55 56 /* build the context */ 57 /* tf_gs */ 58 /* tf_fs */ 59 context->tf_es = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 60 context->tf_ds = GDT_FIXED_SEL(GDT_UDATA_SEL, SEL_UPL); 61 context->tf_rip = (uint64_t)thread->entry_func; 62 context->tf_rflags = PSL_USERSET; 63 64 if (thread->type == THREAD_USER) { 65 context->tf_cs = GDT_FIXED_SEL(GDT_UCODE_SEL, SEL_UPL); 66 context->tf_rsp = ((uint64_t)thread->u_stack_base) + 67 thread->u_stack_size; 68 } else { 69 context->tf_cs = GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL); 70 context->tf_rsp = ((uint64_t)thread->k_stack_base) + 71 thread->k_stack_size; 72 } 73 41 74 return 0; 42 75 } -
trunk/hal/x86_64/core/hal_interrupt.c
r168 r193 36 36 * Timer interrupt 37 37 */ 38 void hal_timer_intr( struct trapframe*tf)38 void hal_timer_intr(hal_cpu_context_t *tf) 39 39 { 40 40 x86_printf("-> got timer: rip=%Z (th=%Z)\n", tf->tf_rip, … … 48 48 * Serial Port (COM1) interrupt 49 49 */ 50 void hal_com1_intr( struct trapframe*tf)50 void hal_com1_intr(hal_cpu_context_t *tf) 51 51 { 52 52 static char prev; … … 122 122 * Keyboard interrupt (8042 PS/2) 123 123 */ 124 void hal_keyboard_intr( struct trapframe*tf)124 void hal_keyboard_intr(hal_cpu_context_t *tf) 125 125 { 126 126 uint64_t val; -
trunk/hal/x86_64/core/hal_kentry.h
r146 r193 49 49 #define TF_REGSIZE (19 * 8) 50 50 51 #define PSL_I 0x00000200 52 #define PSL_MBO 0x00000002 53 #define PSL_USERSET (PSL_MBO | PSL_I) 54 51 55 #define INTR_SAVE_REGS \ 52 56 subq $TF_REGSIZE,%rsp ; \ … … 98 102 99 103 /* 100 * The x86_64 trap frame.104 * The x86_64 CPU context. 101 105 */ 102 struct trapframe{106 typedef struct hal_cpu_context_s { 103 107 /* Pushed by INTR_SAVE_REGS */ 104 108 uint64_t tf_rax; … … 125 129 uint64_t tf_trapno; 126 130 127 /* These are pushed for atrap */131 /* Pushed by the hardware if trap */ 128 132 uint64_t tf_err; 129 133 uint64_t tf_rip; … … 131 135 uint64_t tf_rflags; 132 136 133 /* These are always pushed*/137 /* Always pushed by the hardware */ 134 138 uint64_t tf_rsp; 135 139 uint64_t tf_ss; 136 } ;140 } hal_cpu_context_t; 137 141 138 142 /*
Note: See TracChangeset
for help on using the changeset viewer.