Rewrite init app in C, introduce MSL (MOP3 System Library)
All checks were successful
Build documentation / build-and-deploy (push) Successful in 35s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 35s
This commit is contained in:
1
libmsl/amd64/.gitignore
vendored
Normal file
1
libmsl/amd64/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.o
|
||||
8
libmsl/amd64/_start.S
Normal file
8
libmsl/amd64/_start.S
Normal file
@@ -0,0 +1,8 @@
|
||||
.global _start
|
||||
_start:
|
||||
xorq %rbp, %rbp
|
||||
movq %rsp, %rbp
|
||||
andq $-16, %rsp
|
||||
subq $8, %rsp
|
||||
|
||||
callq __premain
|
||||
6
libmsl/amd64/src.mk
Normal file
6
libmsl/amd64/src.mk
Normal file
@@ -0,0 +1,6 @@
|
||||
c += amd64/syscall.c
|
||||
|
||||
S += amd64/_start.S
|
||||
|
||||
o += amd64/_start.o \
|
||||
amd64/syscall.o
|
||||
23
libmsl/amd64/syscall.c
Normal file
23
libmsl/amd64/syscall.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <amd64/syscall.h>
|
||||
|
||||
int msl_amd64_syscall (int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6) {
|
||||
uint64_t result;
|
||||
__asm__ volatile (
|
||||
"movq %1, %%rax\n"
|
||||
"movq %2, %%rdi\n"
|
||||
"movq %3, %%rsi\n"
|
||||
"movq %4, %%rdx\n"
|
||||
"movq %5, %%r10\n"
|
||||
"movq %6, %%r8\n"
|
||||
"movq %7, %%r9\n"
|
||||
"syscall\n"
|
||||
"movq %%rax, %0\n"
|
||||
: "=r"(result)
|
||||
: "r"((uint64_t)syscall_num), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), "r"(a6)
|
||||
: "memory", "cc", "rcx", "r11"
|
||||
);
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
8
libmsl/amd64/syscall.h
Normal file
8
libmsl/amd64/syscall.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _LIBMSL_AMD64_SYSCALL_H
|
||||
#define _LIBMSL_AMD64_SYSCALL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int msl_amd64_syscall (int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6);
|
||||
|
||||
#endif // _LIBMSL_AMD64_SYSCALL_H
|
||||
Reference in New Issue
Block a user