Changeset 281b607 in mainline
- Timestamp:
- 2006-03-23T10:29:39Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0bb10ef
- Parents:
- 9aa72b4
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/cpu.h
r9aa72b4 r281b607 43 43 #define AMD_MSR_LSTAR 0xc0000082 44 44 #define AMD_MSR_SFMASK 0xc0000084 45 #define AMD_MSR_FS 0xc0000100 45 46 #define AMD_MSR_GS 0xc0000101 46 47 -
arch/amd64/include/thread.h
r9aa72b4 r281b607 30 30 #define __amd64_THREAD_H__ 31 31 32 #define ARCH_THREAD_DATA 32 #define ARCH_THREAD_DATA __native tls; 33 33 34 34 #endif -
arch/amd64/src/amd64.c
r9aa72b4 r281b607 33 33 #include <config.h> 34 34 35 #include <proc/thread.h> 35 36 #include <arch/ega.h> 36 37 #include <genarch/i8042/i8042.h> … … 48 49 #include <arch/syscall.h> 49 50 #include <arch/debugger.h> 51 #include <syscall/syscall.h> 52 50 53 51 54 /** Disable I/O on non-privileged levels … … 160 163 i8254_normal_operation(); 161 164 } 165 166 /** Set Thread-local-storeage pointer 167 * 168 * TLS pointer is set in FS register. Unfortunately the 64-bit 169 * part can be set only in CPL0 mode. 170 * 171 * The specs says, that on %fs:0 there is stored contents of %fs register, 172 * we need not to go to CPL0 to read it. 173 */ 174 __native sys_tls_set(__native addr) 175 { 176 THREAD->tls = addr; 177 write_msr(AMD_MSR_FS, addr); 178 return 0; 179 } -
arch/amd64/src/proc/scheduler.c
r9aa72b4 r281b607 46 46 swapgs(); 47 47 48 /* TLS support - set FS to thread local storage */ 49 write_msr(AMD_MSR_FS, THREAD->tls); 50 48 51 #ifdef CONFIG_DEBUG_AS_WATCHPOINT 49 52 /* Set watchpoint on AS to ensure that nobody sets it to zero */ -
arch/ia32/include/pm.h
r9aa72b4 r281b607 31 31 32 32 #define IDT_ITEMS 64 33 #define GDT_ITEMS 633 #define GDT_ITEMS 7 34 34 35 35 #define NULL_DES 0 … … 39 39 #define UDATA_DES 4 40 40 #define TSS_DES 5 41 #define TLS_DES 6 /* Pointer to Thread-Local-Storage data */ 41 42 42 43 #define selector(des) ((des)<<3) … … 147 148 148 149 extern void tss_initialize(struct tss *t); 150 extern void set_tls_desc(__address tls); 149 151 150 152 #endif /* __ASM__ */ -
arch/ia32/include/thread.h
r9aa72b4 r281b607 30 30 #define __ia32_THREAD_H__ 31 31 32 #define ARCH_THREAD_DATA 32 #define ARCH_THREAD_DATA __native tls; 33 33 34 34 #endif -
arch/ia32/src/ia32.c
r9aa72b4 r281b607 52 52 #include <interrupt.h> 53 53 #include <arch/debugger.h> 54 #include <proc/thread.h> 55 #include <syscall/syscall.h> 54 56 55 57 void arch_pre_mm_init(void) … … 107 109 } 108 110 } 111 112 /** Set Thread-local-storeage pointer 113 * 114 * TLS pointer is set in FS register. Unfortunately the 64-bit 115 * part can be set only in CPL0 mode. 116 * 117 * The specs says, that on %fs:0 there is stored contents of %fs register, 118 * we need not to go to CPL0 to read it. 119 */ 120 __native sys_tls_set(__native addr) 121 { 122 THREAD->tls = addr; 123 set_tls_desc(addr); 124 125 return 0; 126 } -
arch/ia32/src/pm.c
r9aa72b4 r281b607 49 49 * mode, we use, for each privilege level, two segments spanning the 50 50 * whole memory. One is for code and one is for data. 51 * 52 * One is for GS register which holds pointer to the TLS thread 53 * structure in it's base. 51 54 */ 52 55 struct descriptor gdt[GDT_ITEMS] = { … … 62 65 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 63 66 /* TSS descriptor - set up will be completed later */ 64 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } 67 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 68 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 } 65 69 }; 66 70 … … 215 219 clean_AM_flag(); /* Disable alignment check */ 216 220 } 221 222 void set_tls_desc(__address tls) 223 { 224 struct ptr_16_32 cpugdtr; 225 struct descriptor *gdt_p = (struct descriptor *) cpugdtr.base; 226 227 __asm__ volatile ("sgdt %0\n" : : "m" (cpugdtr)); 228 229 gdt_setbase(&gdt_p[TLS_DES], tls); 230 /* Reload gdt register to update GS in CPU */ 231 __asm__ volatile ("lgdt %0\n" : : "m" (cpugdtr)); 232 } -
arch/ia32/src/proc/scheduler.c
r9aa72b4 r281b607 33 33 #include <arch/context.h> /* SP_DELTA */ 34 34 #include <arch/debugger.h> 35 #include <arch/pm.h> 35 36 36 37 void before_thread_runs_arch(void) … … 38 39 CPU->arch.tss->esp0 = (__address) &THREAD->kstack[THREAD_STACK_SIZE-SP_DELTA]; 39 40 CPU->arch.tss->ss0 = selector(KDATA_DES); 41 42 /* Set up TLS in GS register */ 43 set_tls_desc(THREAD->tls); 40 44 41 45 #ifdef CONFIG_DEBUG_AS_WATCHPOINT -
arch/ia32/src/userspace.c
r9aa72b4 r281b607 56 56 "popfl\n" 57 57 58 /* Set up GS register (TLS) */ 59 "movl %6, %%gs\n" 60 58 61 "pushl %0\n" 59 62 "pushl %1\n" … … 66 69 : "i" (selector(UDATA_DES) | PL_USER), "r" (kernel_uarg->uspace_stack+THREAD_STACK_SIZE), 67 70 "r" (ipl), "i" (selector(UTEXT_DES) | PL_USER), "r" (kernel_uarg->uspace_entry), 68 "r" (kernel_uarg->uspace_uarg) 71 "r" (kernel_uarg->uspace_uarg), 72 "r" (selector(TLS_DES)) 69 73 : "eax"); 70 74 -
arch/mips32/src/mips32.c
r9aa72b4 r281b607 40 40 #include <proc/uarg.h> 41 41 #include <print.h> 42 #include <syscall/syscall.h> 42 43 43 44 #include <arch/interrupt.h> … … 142 143 { 143 144 } 145 146 /** Set Thread-local-storeage pointer 147 * 148 * We have it currently in K1, it is 149 * possible to have it separately in the future. 150 */ 151 __native sys_tls_set(__native addr) 152 { 153 return 0; 154 } -
generic/include/syscall/syscall.h
r9aa72b4 r281b607 32 32 typedef enum { 33 33 SYS_IO = 0, 34 SYS_TLS_SET = 1, /* Hardcoded in AMD64,IA32 uspace - psthread.S */ 34 35 SYS_THREAD_CREATE, 35 36 SYS_THREAD_EXIT, … … 60 61 extern __native syscall_handler(__native a1, __native a2, __native a3, 61 62 __native a4, __native id); 63 extern __native sys_tls_set(__native addr); 64 62 65 63 66 #endif -
generic/src/syscall/syscall.c
r9aa72b4 r281b607 76 76 syshandler_t syscall_table[SYSCALL_END] = { 77 77 sys_io, 78 sys_tls_set, 78 79 sys_thread_create, 79 80 sys_thread_exit,
Note:
See TracChangeset
for help on using the changeset viewer.