Changeset 296426ad in mainline for kernel/arch/amd64/src/asm_utils.S
- Timestamp:
- 2007-11-16T16:17:18Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9c2fb97
- Parents:
- e686744c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/asm_utils.S
re686744c r296426ad 221 221 222 222 /* 223 * Choose between version with error code and version without error code. 224 * Both versions have to be of the same size. amd64 assembly is, however, 225 * a little bit tricky. For instance, subq $0x80, %rsp and subq $0x78, %rsp 226 * can result in two instructions with different op-code lengths. 223 * Choose between version with error code and version without error 224 * code. Both versions have to be of the same size. amd64 assembly is, 225 * however, a little bit tricky. For instance, subq $0x80, %rsp and 226 * subq $0x78, %rsp can result in two instructions with different 227 * op-code lengths. 227 228 * Therefore we align the interrupt handlers. 228 229 */ … … 270 271 h_end: 271 272 272 273 ## Low-level syscall handler 274 # 275 # Registers on entry: 276 # 277 # @param rcx Userspace return address. 278 # @param r11 Userspace RLFAGS. 279 # 280 # @param rax Syscall number. 281 # @param rdi 1st syscall argument. 282 # @param rsi 2nd syscall argument. 283 # @param rdx 3rd syscall argument. 284 # @param r10 4th syscall argument. Used instead of RCX because the 285 # SYSCALL instruction clobbers it. 286 # @param r8 5th syscall argument. 287 # @param r9 6th syscall argument. 288 # 289 # @return Return value is in rax. 290 # 273 291 syscall_entry: 274 # Switch to hidden gs 275 swapgs 276 # %gs:0 now points to pointer to stack page 277 mov %gs:0, %r10 # We have a ptr to stack page in r10 278 addq $PAGE_SIZE-16, %r10 # We need some space to store old %sp 279 280 movq %rsp, 0(%r10) # Save old stack pointer to stack 281 movq %r10, %rsp # Change to new stack 282 pushq %rcx # Return address 283 pushq %r11 # Save flags 284 285 # Switch back to remain consistent 286 swapgs 287 292 swapgs # Switch to hidden gs 293 # 294 # %gs:0 Scratch space for this thread's user RSP 295 # %gs:8 Address to be used as this thread's kernel RSP 296 # 297 movq %rsp, %gs:0 # Save this thread's user RSP 298 movq %gs:8, %rsp # Set this thread's kernel RSP 299 swapgs # Switch back to remain consistent 288 300 sti 289 movq %r9, %rcx # Exchange last parameter as a third 290 301 302 pushq %rcx 303 pushq %r11 304 305 movq %r10, %rcx # Copy the 4th argument where it is expected 306 pushq %rax 291 307 call syscall_handler 292 cli # We will be touching stack pointer308 addq $8, %rsp 293 309 294 310 popq %r11 295 311 popq %rcx 296 movq 0(%rsp), %rsp 312 313 cli 314 swapgs 315 movq %gs:0, %rsp # Restore the user RSP 316 swapgs 317 297 318 sysretq 298 299 319 300 320 .data 301 321 .global interrupt_handler_size
Note:
See TracChangeset
for help on using the changeset viewer.