diff options
Diffstat (limited to 'arch/x86_64/src/context_switching')
| -rw-r--r-- | arch/x86_64/src/context_switching/syscall/main.cpp | 6 | ||||
| -rw-r--r-- | arch/x86_64/src/context_switching/syscall/syscall_handler.cpp | 50 |
2 files changed, 36 insertions, 20 deletions
diff --git a/arch/x86_64/src/context_switching/syscall/main.cpp b/arch/x86_64/src/context_switching/syscall/main.cpp index 996d7fb..e291c10 100644 --- a/arch/x86_64/src/context_switching/syscall/main.cpp +++ b/arch/x86_64/src/context_switching/syscall/main.cpp @@ -18,9 +18,6 @@ namespace teachos::arch::context_switching::syscall asm volatile("syscall"); - error error_code{}; - asm volatile("mov %%rax, %[output]" : [output] "=m"(error_code)); - arguments values{}; asm volatile("mov %%rdi, %[output]" : [output] "=m"(values.arg_0)); asm volatile("mov %%rsi, %[output]" : [output] "=m"(values.arg_1)); @@ -29,6 +26,9 @@ namespace teachos::arch::context_switching::syscall asm volatile("mov %%r8, %[output]" : [output] "=m"(values.arg_4)); asm volatile("mov %%r9, %[output]" : [output] "=m"(values.arg_5)); + error error_code{}; + asm volatile("mov %%rax, %[output]" : [output] "=m"(error_code)); + return {error_code, values}; } diff --git a/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp b/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp index 7272e9e..9cc6edf 100644 --- a/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp +++ b/arch/x86_64/src/context_switching/syscall/syscall_handler.cpp @@ -11,30 +11,21 @@ namespace teachos::arch::context_switching::syscall namespace { - auto write_to_vga_buffer(uint64_t buffer) -> error + auto write_to_vga_buffer(uint64_t buffer) -> response { video::vga::text::write(reinterpret_cast<const char *>(buffer), video::vga::text::common_attributes::green_on_black); video::vga::text::newline(); - return error::OK; + return {error::OK}; } - auto expand_user_heap() -> error + auto expand_user_heap() -> response { static auto current_heap_end = memory::heap::USER_HEAP_START; - memory::remap_heap(current_heap_end, memory::heap::USER_HEAP_SIZE, memory::paging::entry::USER_ACCESSIBLE); - - arguments args{current_heap_end, memory::heap::USER_HEAP_SIZE}; - asm volatile("mov %[input], %%rdi" - : /* no output from call */ - : [input] "m"(args.arg_0) - : "memory"); - asm volatile("mov %[input], %%rsi" - : /* no output from call */ - : [input] "m"(args.arg_1) - : "memory"); + uint64_t const heap_start = current_heap_end; + memory::remap_heap(heap_start, memory::heap::USER_HEAP_SIZE, memory::paging::entry::USER_ACCESSIBLE); current_heap_end += memory::heap::USER_HEAP_SIZE; - return error::OK; + return {error::OK, {heap_start, memory::heap::USER_HEAP_SIZE}}; } } // namespace @@ -60,7 +51,7 @@ namespace teachos::arch::context_switching::syscall // and now. asm volatile("mov %%rax, %[output]" : [output] "=m"(syscall_number)); - error result = error::OK; + response result; switch (static_cast<type>(syscall_number)) { case type::WRITE: @@ -76,7 +67,32 @@ namespace teachos::arch::context_switching::syscall asm volatile("mov %[input], %%rax" : /* no output from call */ - : [input] "m"(result) + : [input] "m"(result.error_code) + : "memory"); + + asm volatile("mov %[input], %%rdi" + : /* no output from call */ + : [input] "m"(result.values.arg_0) + : "memory"); + asm volatile("mov %[input], %%rsi" + : /* no output from call */ + : [input] "m"(result.values.arg_1) + : "memory"); + asm volatile("mov %[input], %%rdx" + : /* no output from call */ + : [input] "m"(result.values.arg_2) + : "memory"); + asm volatile("mov %[input], %%r10" + : /* no output from call */ + : [input] "m"(result.values.arg_3) + : "memory"); + asm volatile("mov %[input], %%r8" + : /* no output from call */ + : [input] "m"(result.values.arg_4) + : "memory"); + asm volatile("mov %[input], %%r9" + : /* no output from call */ + : [input] "m"(result.values.arg_5) : "memory"); asm volatile("mov %[input], %%rcx" |
