vbl
This commit is contained in:
@@ -7,12 +7,26 @@
|
||||
; and populates the registers from the the next context.
|
||||
align 16
|
||||
context_switch:
|
||||
mov [rsi + 0], rbx
|
||||
mov [rsi + 8], rbp
|
||||
mov [rsi + 16], r12
|
||||
mov [rsi + 24], r13
|
||||
mov [rsi + 32], r14
|
||||
mov [rsi + 40], r15
|
||||
mov [rsi + 48], rsp
|
||||
|
||||
; context_launch populates the register set from the next context structure.
|
||||
; It does not save the current registers.
|
||||
align 16 ; When only one parameter is used for `align`, it will use NOP
|
||||
context_launch:
|
||||
|
||||
mov rbx, [rdi + 0]
|
||||
mov rbp, [rdi + 8]
|
||||
mov r12, [rdi + 16]
|
||||
mov r13, [rdi + 24]
|
||||
mov r14, [rdi + 32]
|
||||
mov r15, [rdi + 40]
|
||||
mov rsp, [rdi + 48]
|
||||
ret
|
||||
; fake_systemv_abi is used to populate the volatile argument registers used by the systemv abi (rdi, rsi, ...)
|
||||
; with values from the non-volatile registers saved within the thread context (r15, r14, ...)
|
||||
align 16
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
#include "context.h"
|
||||
#include "../debug/output.h"
|
||||
|
||||
void panic(){
|
||||
DBG << "panic!\n" << flush;
|
||||
while(1);
|
||||
}
|
||||
|
||||
void prepareContext(void* tos, Context& context, void (*kickoff)(void*),
|
||||
void* param1) {
|
||||
(void)tos;
|
||||
(void)context;
|
||||
(void)kickoff;
|
||||
(void)param1;
|
||||
((uint64_t*)tos)[0] = (uint64_t)panic;
|
||||
((uint64_t*)tos)[-1] = (uint64_t)kickoff;
|
||||
context.rsp = tos;
|
||||
context.rbx = 0;
|
||||
context.rbp = 0;
|
||||
context.r12 = 0;
|
||||
context.r13 = 0;
|
||||
context.r14 = 0;
|
||||
context.r15 = (uint64_t)param1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user