Skip to content

switch to intel syntax for assembly code #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-05-11"
channel = "nightly-2021-05-19"
components = [ "rustfmt", "rust-src", "llvm-tools-preview"]
10 changes: 5 additions & 5 deletions src/arch/x86_64/kernel/start.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
.align 16
_start:
// initialize stack pointer
mov $0x7ff0,%rax
add 0x38(%rdi),%rax
mov %rax, %rsp
mov %rsp, %rbp
mov rax, 0x7ff0
add rax, [rdi+0x38]
mov rsp, rax
mov rbp, rsp

call pre_init

Expand All @@ -26,7 +26,7 @@ l1:

.align 16
task_start:
mov %rdx, %rsp
mov rsp, rdx
sti
jmp task_entry
jmp l1
166 changes: 83 additions & 83 deletions src/arch/x86_64/kernel/switch.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,58 @@ switch_to_task:
// rsi = new_stack => stack pointer of the new task

pushfq
push %rax
push %rcx
push %rdx
push %rbx
push %rbp
push %rsi
push %rdi
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
push rax
push rcx
push rdx
push rbx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
// push fs registers
mov $0xc0000100, %ecx
mov ecx, 0xc0000100
rdmsr
sub $8, %rsp
mov %edx, 4(%rsp)
mov %eax, (%rsp)
sub rsp, 8
mov [rsp+4], edx
mov [rsp], eax
// store the old stack pointer in the dereferenced first parameter\n\t\
// and load the new stack pointer in the second parameter.\n\t\
mov %rsp, (%rdi)
mov %rsi, %rsp
mov [rdi], rsp
mov rsp, rsi
// Set task switched flag
mov %cr0, %rax
or $8, %rax
mov %rax, %cr0
mov rax, cr0
or rax, 8
mov cr0, rax
// set stack pointer in TSS
call set_current_kernel_stack
// restore context
mov $0xc0000100, %ecx
mov 4(%rsp), %edx
mov (%rsp), %eax
add $8, %rsp
mov ecx, 0xc0000100
mov edx, [rsp+4]
mov eax, [rsp]
add rsp, 8
wrmsr
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rdi
pop %rsi
pop %rbp
pop %rbx
pop %rdx
pop %rcx
pop %rax
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rbx
pop rdx
pop rcx
pop rax
popfq
ret

Expand All @@ -81,53 +81,53 @@ switch_to_fpu_owner:

// store context
pushfq
push %rax
push %rcx
push %rdx
push %rbx
push %rbp
push %rsi
push %rdi
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
push rax
push rcx
push rdx
push rbx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
// push fs registers
mov $0xc0000100, %ecx
mov ecx, 0xc0000100
rdmsr
sub $8, %rsp
mov %edx, 4(%rsp)
mov %eax, (%rsp)
sub rsp, 8
mov [rsp+4], edx
mov [rsp], eax
// store the old stack pointer in the dereferenced first parameter\n\t\
// and load the new stack pointer in the second parameter.\n\t\
mov %rsp, (%rdi)
mov %rsi, %rsp
mov [rdi], rsp
mov rsp, rsi
// set stack pointer in TSS
call set_current_kernel_stack
// restore context
mov $0xc0000100, %ecx
mov 4(%rsp), %edx
mov (%rsp), %eax
add $8, %rsp
mov ecx, 0xc0000100
mov edx, [rsp+4]
mov eax, [rsp]
add rsp, 8
wrmsr
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rdi
pop %rsi
pop %rbp
pop %rbx
pop %rdx
pop %rcx
pop %rax
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rbx
pop rdx
pop rcx
pop rax
popfq
ret
Loading