Changeset 167
- Timestamp:
- Jul 10, 2017, 10:23:29 AM (7 years ago)
- Location:
- trunk/hal/x86_64/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_segmentation.h
r164 r167 145 145 146 146 #define IOMAP_INVALOFF 0xffff 147 148 /* 149 * Our definition of Thread-Local Storage. 150 */ 151 struct tls { 152 void *tls_self; 153 uint32_t tls_gid; 154 uint32_t tls_lid; 155 void *tls_thr; 156 } __packed; 157 typedef struct tls tls_t; 147 158 148 159 void lgdt(struct region_descriptor *); -
trunk/hal/x86_64/core/hal_special.c
r146 r167 25 25 #include <hal_register.h> 26 26 #include <hal_internal.h> 27 #include <hal_segmentation.h> 27 28 28 29 #include <core.h> … … 31 32 struct thread_s; 32 33 33 struct cpu_info { 34 void *ci_self; 35 uint32_t ci_gid; 36 uint32_t ci_lid; 37 struct thread_s *ci_thr; 38 } __packed; 39 typedef struct cpu_info cpu_info_t; 34 tls_t cpu0 __in_kdata; 40 35 41 cpu_info_t cpu0 __in_kdata; 42 43 cpu_info_t *curcpu() 36 tls_t *curcpu() 44 37 { 45 cpu_info_t *ci;38 tls_t *cputls; 46 39 47 40 __asm volatile("movq %%gs:%1, %0" : 48 "=r" (c i) :41 "=r" (cputls) : 49 42 "m" 50 (*( cpu_info_t * const *)offsetof(cpu_info_t, ci_self)));51 return c i;43 (*(tls_t * const *)offsetof(tls_t, tls_self))); 44 return cputls; 52 45 } 53 46 54 static void hal_tls_load_cpu( cpu_info_t *ci)47 static void hal_tls_load_cpu(tls_t *cputls) 55 48 { 56 49 wrmsr(MSR_FSBASE, 0); 57 wrmsr(MSR_GSBASE, (uint64_t)c i);50 wrmsr(MSR_GSBASE, (uint64_t)cputls); 58 51 wrmsr(MSR_KERNELGSBASE, 0); 59 52 } … … 61 54 void hal_tls_init_cpu0() 62 55 { 63 cpu_info_t *ci= &cpu0;56 tls_t *cputls = &cpu0; 64 57 65 memset(c i, 0, sizeof(cpu_info_t));58 memset(cputls, 0, sizeof(tls_t)); 66 59 67 c i->ci_self = ci;68 c i->ci_gid = hal_lapic_gid();69 c i->ci_lid = 0; /* XXX */60 cputls->tls_self = cputls; 61 cputls->tls_gid = hal_lapic_gid(); 62 cputls->tls_lid = 0; /* XXX */ 70 63 71 hal_tls_load_cpu(c i);64 hal_tls_load_cpu(cputls); 72 65 } 73 66 74 67 gid_t hal_get_gid() 75 68 { 76 return curcpu()-> ci_gid;69 return curcpu()->tls_gid; 77 70 } 78 71 … … 99 92 struct thread_s *hal_get_current_thread() 100 93 { 101 return curcpu()-> ci_thr;94 return curcpu()->tls_thr; 102 95 } 103 96 104 97 void hal_set_current_thread( struct thread_s * thread ) 105 98 { 106 curcpu()-> ci_thr = thread;99 curcpu()->tls_thr = thread; 107 100 } 108 101
Note: See TracChangeset
for help on using the changeset viewer.