-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86_64: allocate signal trampoline in thread user space
- Loading branch information
1 parent
f756686
commit 2eae8de
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* lux - a lightweight unix-like operating system | ||
* Omar Elghoul, 2024 | ||
* | ||
* Platform-Specific Code for x86_64 | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <platform/platform.h> | ||
#include <platform/context.h> | ||
#include <kernel/signal.h> | ||
#include <kernel/sched.h> | ||
|
||
extern size_t sigstubSize; | ||
extern uint8_t sigstub[]; | ||
|
||
/* platformSignalSetup(): sets up the signal trampoline code in a user process | ||
* params: t - thread structure | ||
* returns: zero on success | ||
*/ | ||
|
||
int platformSignalSetup(Thread *t) { | ||
void *trampoline = uxmalloc(sigstubSize); | ||
if(!trampoline) return -1; | ||
|
||
memcpy(trampoline, sigstub, sigstubSize); | ||
t->signalTrampoline = (uintptr_t) trampoline; | ||
return 0; | ||
} |