Changeset 46 for trunk/hal/x86_64/hal_special.c
- Timestamp:
- Jun 23, 2017, 1:31:23 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/hal_special.c
r25 r46 1 1 /* 2 * hal_special.c - implementation of Generic Special Register Access API for TSAR-MIPS322 * hal_special.c - implementation of TLS API for x86_64 3 3 * 4 * Author Ghassan Almaless (2008,2009,2010,2011,2012) 5 * Alain Greiner (2016) 4 * Copyright (c) 2017 Maxime Villard 5 * 6 * This file is part of ALMOS-MKH. 6 7 * 7 * Copyright (c) UPMC Sorbonne Universites 8 * 9 * This file is part of ALMOS-MKH.. 10 * 11 * ALMOS-MKH. is free software; you can redistribute it and/or modify it 8 * ALMOS-MKH is free software; you can redistribute it and/or modify it 12 9 * under the terms of the GNU General Public License as published by 13 10 * the Free Software Foundation; version 2.0 of the License. 14 11 * 15 * ALMOS-MKH .is distributed in the hope that it will be useful, but12 * ALMOS-MKH is distributed in the hope that it will be useful, but 16 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 23 20 */ 24 21 25 26 22 #include <hal_types.h> 23 #include <hal_lapic.h> 27 24 #include <hal_special.h> 28 29 /**** Forward declarations ****/ 25 #include <hal_register.h> 26 #include <hal_internal.h> 30 27 31 28 struct thread_s; 32 29 30 typedef struct cpu_info { 31 void *ci_self; 32 uint32_t ci_gid; 33 uint32_t ci_lid; 34 struct thread_s *ci_thr; 35 } cpu_info_t; 36 37 cpu_info_t cpu0 __in_kdata; 38 39 cpu_info_t *curcpu() 40 { 41 cpu_info_t *ci; 42 43 __asm volatile("movq %%gs:%1, %0" : 44 "=r" (ci) : 45 "m" 46 (*(cpu_info_t * const *)offsetof(cpu_info_t, ci_self))); 47 return ci; 48 } 49 50 static void hal_tls_load_cpu(cpu_info_t *ci) 51 { 52 wrmsr(MSR_FSBASE, 0); 53 wrmsr(MSR_GSBASE, (uint64_t)ci); 54 wrmsr(MSR_KERNELGSBASE, 0); 55 } 56 57 void hal_tls_init_cpu0() 58 { 59 cpu_info_t *ci = &cpu0; 60 61 memset(ci, 0, sizeof(cpu_info_t)); 62 63 ci->ci_self = ci; 64 ci->ci_gid = hal_lapic_gid(); 65 ci->ci_lid = 0; /* XXX */ 66 67 hal_tls_load_cpu(ci); 68 } 69 33 70 gid_t hal_get_gid() 34 71 { 35 return 0; 72 x86_panic((char *)__func__); 73 return curcpu()->ci_gid; 36 74 } 37 75 38 76 uint32_t hal_time_stamp() 39 77 { 78 x86_panic((char *)__func__); 40 79 return 0; 41 80 } … … 43 82 struct thread_s * hal_get_current_thread() 44 83 { 45 return NULL; 84 x86_panic((char *)__func__); 85 return curcpu()->ci_thr; 46 86 } 47 87 48 88 void hal_set_current_thread( struct thread_s * thread ) 49 89 { 90 x86_panic((char *)__func__); 91 curcpu()->ci_thr = thread; 92 } 50 93 51 } 94 /* -------------------------------------------------------------------------- */ 52 95 53 96 void hal_fpu_enable() 54 97 { 55 98 x86_panic((char *)__func__); 56 99 } 57 100 58 101 void hal_fpu_disable() 59 102 { 60 103 x86_panic((char *)__func__); 61 104 } 62 105 63 106 uint32_t hal_get_stack() 64 107 { 108 x86_panic((char *)__func__); 65 109 return 0; 66 110 } … … 68 112 uint32_t hal_set_stack( void * new_val ) 69 113 { 114 x86_panic((char *)__func__); 70 115 return 0; 71 116 } … … 73 118 uint32_t hal_get_bad_vaddr() 74 119 { 120 x86_panic((char *)__func__); 75 121 return 0; 76 122 } … … 78 124 uint32_t hal_uncached_read( uint32_t * ptr ) 79 125 { 126 x86_panic((char *)__func__); 80 127 return 0; 81 128 } … … 83 130 void hal_invalid_dcache_line( void * ptr ) 84 131 { 85 132 x86_panic((char *)__func__); 86 133 } 87 134 88 135 void hal_wbflush() 89 136 { 90 137 x86_panic((char *)__func__); 91 138 } 92 139 93 140 void hal_rdbar() 94 141 { 95 142 x86_panic((char *)__func__); 96 143 } 97 144 98 145 void hal_core_sleep() 99 146 { 100 147 x86_panic((char *)__func__); 101 148 } 102 149 103 150 void hal_fixed_delay( uint32_t delay ) 104 151 { 105 152 x86_panic((char *)__func__); 106 153 } 107 154 … … 111 158 intptr_t * mmu_dat_bad_vaddr ) 112 159 { 113 160 x86_panic((char *)__func__); 114 161 }
Note: See TracChangeset
for help on using the changeset viewer.