summaryrefslogtreecommitdiff
path: root/InOsEmuPkg/Unix
diff options
context:
space:
mode:
Diffstat (limited to 'InOsEmuPkg/Unix')
-rw-r--r--InOsEmuPkg/Unix/Sec/EmuThunk.c19
-rw-r--r--InOsEmuPkg/Unix/Sec/Gasket.h10
-rw-r--r--InOsEmuPkg/Unix/Sec/Ia32/Gasket.S28
-rw-r--r--InOsEmuPkg/Unix/Sec/X64/Gasket.S28
4 files changed, 85 insertions, 0 deletions
diff --git a/InOsEmuPkg/Unix/Sec/EmuThunk.c b/InOsEmuPkg/Unix/Sec/EmuThunk.c
index 97c339d241..50afbb5cd6 100644
--- a/InOsEmuPkg/Unix/Sec/EmuThunk.c
+++ b/InOsEmuPkg/Unix/Sec/EmuThunk.c
@@ -118,6 +118,23 @@ SecPollStdIn (
}
+VOID *
+SecMalloc (
+ IN UINTN Size
+ )
+{
+ return malloc ((size_t)Size);
+}
+
+VOID
+SecFree (
+ IN VOID *Ptr
+ )
+{
+ free (Ptr);
+ return;
+}
+
void
settimer_handler (int sig)
@@ -370,6 +387,8 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GasketSecWriteStdOut,
GasketSecReadStdIn,
GasketSecPollStdIn,
+ GasketSecMalloc,
+ GasketSecFree,
GasketSecPeCoffGetEntryPoint,
GasketSecPeCoffRelocateImageExtraAction,
GasketSecPeCoffUnloadImageExtraAction,
diff --git a/InOsEmuPkg/Unix/Sec/Gasket.h b/InOsEmuPkg/Unix/Sec/Gasket.h
index 725e250eb3..90c2aa8ee7 100644
--- a/InOsEmuPkg/Unix/Sec/Gasket.h
+++ b/InOsEmuPkg/Unix/Sec/Gasket.h
@@ -53,6 +53,16 @@ GasketSecPollStdIn (
VOID
);
+VOID *
+EFIAPI
+GasketSecMalloc (
+ IN UINTN Size
+ );
+
+VOID
+GasketSecFree (
+ IN VOID *Ptr
+ );
RETURN_STATUS
diff --git a/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S b/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S
index f1b974e18a..b8d9c0470f 100644
--- a/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S
+++ b/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S
@@ -107,6 +107,34 @@ ASM_PFX(GasketSecPollStdIn):
leave
ret
+ASM_GLOBAL ASM_PFX(GasketSecMalloc)
+ASM_PFX(GasketSecMalloc):
+ pushl %ebp
+ movl %esp, %ebp
+ subl $24, %esp // sub extra 16 from the stack for alignment
+ and $-16, %esp // stack needs to end in 0xFFFFFFF0 before call
+ movl 8(%ebp), %eax
+ movl %eax, (%esp)
+
+ call ASM_PFX(SecMalloc)
+
+ leave
+ ret
+
+ASM_GLOBAL ASM_PFX(GasketSecFree)
+ASM_PFX(GasketSecFree):
+ pushl %ebp
+ movl %esp, %ebp
+ subl $24, %esp // sub extra 16 from the stack for alignment
+ and $-16, %esp // stack needs to end in 0xFFFFFFF0 before call
+ movl 8(%ebp), %eax
+ movl %eax, (%esp)
+
+ call ASM_PFX(SecFree)
+
+ leave
+ ret
+
ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
ASM_PFX(GasketSecSetTimer):
diff --git a/InOsEmuPkg/Unix/Sec/X64/Gasket.S b/InOsEmuPkg/Unix/Sec/X64/Gasket.S
index d30aed617b..6b5e782413 100644
--- a/InOsEmuPkg/Unix/Sec/X64/Gasket.S
+++ b/InOsEmuPkg/Unix/Sec/X64/Gasket.S
@@ -126,6 +126,34 @@ ASM_PFX(GasketSecPollStdIn):
popq %rbp
ret
+ASM_GLOBAL ASM_PFX(GasketSecMalloc)
+ASM_PFX(GasketSecMalloc):
+ pushq %rbp // stack frame is for the debugger
+ movq %rsp, %rbp
+
+ pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+
+ call ASM_PFX(SecMalloc)
+
+ popq %rdi // restore state
+ popq %rsi
+ popq %rbp
+ ret
+
+ASM_GLOBAL ASM_PFX(GasketSecFree)
+ASM_PFX(GasketSecFree):
+ pushq %rbp // stack frame is for the debugger
+ movq %rsp, %rbp
+
+ pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+
+ call ASM_PFX(SecFree)
+
+ popq %rdi // restore state
+ popq %rsi
+ popq %rbp
+ ret
+
ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
ASM_PFX(GasketSecSetTimer):