Changeset 37b451f7 in mainline
- Timestamp:
- 2006-02-07T02:22:44Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 65640fef
- Parents:
- dd4d6b0
- Location:
- arch/amd64
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/asm.h
rdd4d6b0 r37b451f7 73 73 static inline void outb(__u16 port, __u8 val) { __asm__ volatile ("outb %b0, %w1\n" : : "a" (val), "d" (port) ); } 74 74 75 /** Swap Hidden part of GS register with visible one */ 76 static inline void swapgs(void) { __asm__ volatile("swapgs"); } 77 75 78 /** Enable interrupts. 76 79 * -
arch/amd64/include/cpu.h
rdd4d6b0 r37b451f7 42 42 #define AMD_MSR_LSTAR 0xc0000082 43 43 #define AMD_MSR_SFMASK 0xc0000084 44 #define AMD_MSR_GS 0xc0000101 44 45 45 46 #ifndef __ASM__ -
arch/amd64/src/asm_utils.S
rdd4d6b0 r37b451f7 193 193 194 194 syscall_entry: 195 # TODO: Switch to kernel stack 195 # Switch to hidden gs 196 swapgs 197 198 # TODO: I would like LEA instead of thes 2 instrs, 199 # why does not it work??? 200 mov %gs:0, %r10 # We have a stack in r10 201 addq $0x0ff0, %r10 202 203 movq %rsp, 0(%r10) # Save old stack pointer to stack 204 movq %r10, %rsp # Change to new stack 205 pushq %rcx # Return address 206 pushq %r11 # Save flags 207 208 # Switch back to remain consistent 209 swapgs 210 211 movq %r9, %rcx # Exchange last parameter as a third 196 212 call syscall_handler 197 # Switch back 198 sysret 213 214 popq %r11 215 popq %rcx 216 movq 0(%rsp), %rsp 217 sysretq 199 218 200 219 .data -
arch/amd64/src/proc/scheduler.c
rdd4d6b0 r37b451f7 32 32 #include <arch.h> 33 33 #include <arch/context.h> /* SP_DELTA */ 34 #include <arch/asm.h> 34 35 35 36 void before_thread_runs_arch(void) 36 37 { 37 38 CPU->arch.tss->rsp0 = (__address) &THREAD->kstack[THREAD_STACK_SIZE-SP_DELTA]; 39 40 /* Syscall support - write thread address to hidden part of gs */ 41 swapgs(); 42 write_msr(AMD_MSR_GS, 43 (__u64)&THREAD->kstack); 44 swapgs(); 38 45 } -
arch/amd64/src/syscall.c
rdd4d6b0 r37b451f7 35 35 36 36 #include <print.h> 37 #include <arch/cpu.h> 37 38 38 39 extern void syscall_entry(void); … … 55 56 write_msr(AMD_MSR_LSTAR, (__u64)syscall_entry); 56 57 /* Mask RFLAGS on syscall 57 * - we do not care what is in the flags field 58 * - disable interrupts, until we exchange the stack register 59 * (mask the IE bit) 58 60 */ 59 write_msr(AMD_MSR_SFMASK, 0 );61 write_msr(AMD_MSR_SFMASK, 0x200); 60 62 } 61 63 … … 63 65 __native syscall_handler(__native id, __native a1, __native a2, __native a3) 64 66 { 67 interrupts_enable(); 65 68 if (id < SYSCALL_END) 66 69 return syscall_table[id](a1,a2,a3); 67 70 else 68 71 panic("Undefined syscall %d", id); 69 72 interrupts_disable(); 70 73 }
Note:
See TracChangeset
for help on using the changeset viewer.