mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
Compare commits
2 Commits
07abdd9f6c
...
fbe9fbfbd1
Author | SHA1 | Date | |
---|---|---|---|
fbe9fbfbd1 | |||
e6933acfb0 |
251
Drivers/.vscode/c_cpp_properties.json
vendored
251
Drivers/.vscode/c_cpp_properties.json
vendored
@ -1,118 +1,137 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Fennix x64 (Linux, GCC, debug)",
|
"name": "Fennix x64 (Linux, GCC, debug)",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/include",
|
"${workspaceFolder}/include",
|
||||||
"${workspaceFolder}/include/**"
|
"${workspaceFolder}/include/**"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"__debug_vscode__",
|
"__debug_vscode__",
|
||||||
"KERNEL_NAME=\"Fennix\"",
|
"KERNEL_NAME=\"Fennix\"",
|
||||||
"KERNEL_VERSION=\"1.0\"",
|
"KERNEL_VERSION=\"1.0\"",
|
||||||
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
||||||
"GIT_COMMIT_SHORT=\"0000000\"",
|
"GIT_COMMIT_SHORT=\"0000000\"",
|
||||||
"DEBUG=\"1\""
|
"DEBUG=\"1\""
|
||||||
],
|
],
|
||||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
|
||||||
"cStandard": "c17",
|
"cStandard": "c17",
|
||||||
"cppStandard": "c++20",
|
"cppStandard": "c++20",
|
||||||
"intelliSenseMode": "gcc-x64",
|
"intelliSenseMode": "gcc-x64",
|
||||||
"configurationProvider": "ms-vscode.makefile-tools",
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
"compilerArgs": [
|
"compilerArgs": [
|
||||||
// Compiler flags
|
// Compiler flags
|
||||||
"-fPIC",
|
"-fPIC",
|
||||||
"-fPIE",
|
"-fPIE",
|
||||||
"-pie",
|
"-pie",
|
||||||
"-mno-80387",
|
"-mno-80387",
|
||||||
"-mno-mmx",
|
"-mno-mmx",
|
||||||
"-mno-3dnow",
|
"-mno-3dnow",
|
||||||
"-mno-red-zone",
|
"-mno-red-zone",
|
||||||
"-mno-sse",
|
"-mno-sse",
|
||||||
"-mno-sse2",
|
"-mno-sse2",
|
||||||
"-march=x86-64",
|
"-march=x86-64",
|
||||||
"-pipe",
|
"-pipe",
|
||||||
"-ffunction-sections",
|
"-ffunction-sections",
|
||||||
"-msoft-float",
|
"-msoft-float",
|
||||||
"-fno-builtin",
|
"-fno-builtin",
|
||||||
|
// C++ flags
|
||||||
// C++ flags
|
"-fexceptions",
|
||||||
"-fexceptions",
|
// Linker flags
|
||||||
|
"-fPIC",
|
||||||
// Linker flags
|
"-fPIE",
|
||||||
"-fPIC",
|
"-pie",
|
||||||
"-fPIE",
|
"-Wl,-eDriverEntry",
|
||||||
"-pie",
|
"-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment",
|
||||||
"-Wl,-eDriverEntry",
|
"-nostdlib",
|
||||||
"-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment",
|
"-nodefaultlibs",
|
||||||
"-nostdlib",
|
"-nolibc",
|
||||||
"-nodefaultlibs",
|
"-zmax-page-size=0x1000",
|
||||||
"-nolibc",
|
"-static",
|
||||||
"-zmax-page-size=0x1000",
|
// VSCode flags
|
||||||
"-static",
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
// VSCode flags
|
"-nostdinc++"
|
||||||
"-ffreestanding",
|
]
|
||||||
"-nostdinc",
|
},
|
||||||
"-nostdinc++"
|
{
|
||||||
]
|
"name": "Fennix x32 (Linux, GCC, debug)",
|
||||||
},
|
"includePath": [
|
||||||
{
|
"${workspaceFolder}/include/**"
|
||||||
"name": "Fennix x32 (Linux, GCC, debug)",
|
],
|
||||||
"includePath": [
|
"defines": [
|
||||||
"${workspaceFolder}/include/**"
|
"__debug_vscode__",
|
||||||
],
|
"KERNEL_NAME=\"Fennix\"",
|
||||||
"defines": [
|
"KERNEL_VERSION=\"1.0\"",
|
||||||
"__debug_vscode__",
|
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
||||||
"KERNEL_NAME=\"Fennix\"",
|
"GIT_COMMIT_SHORT=\"0000000\"",
|
||||||
"KERNEL_VERSION=\"1.0\"",
|
"DEBUG=\"1\""
|
||||||
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
],
|
||||||
"GIT_COMMIT_SHORT=\"0000000\"",
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-elf-gcc",
|
||||||
"DEBUG=\"1\""
|
"cStandard": "c17",
|
||||||
],
|
"cppStandard": "c++20",
|
||||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-elf-gcc",
|
"intelliSenseMode": "gcc-x86",
|
||||||
"cStandard": "c17",
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
"cppStandard": "c++20",
|
"compilerArgs": [
|
||||||
"intelliSenseMode": "gcc-x86",
|
// Compiler flags
|
||||||
"configurationProvider": "ms-vscode.makefile-tools",
|
"-fPIC",
|
||||||
"compilerArgs": [
|
"-fPIE",
|
||||||
// Compiler flags
|
"-pie",
|
||||||
"-fPIC",
|
"-mno-80387",
|
||||||
"-fPIE",
|
"-mno-mmx",
|
||||||
"-pie",
|
"-mno-3dnow",
|
||||||
"-mno-80387",
|
"-mno-red-zone",
|
||||||
"-mno-mmx",
|
"-mno-sse",
|
||||||
"-mno-3dnow",
|
"-mno-sse2",
|
||||||
"-mno-red-zone",
|
"-march=i386",
|
||||||
"-mno-sse",
|
"-pipe",
|
||||||
"-mno-sse2",
|
"-ffunction-sections",
|
||||||
"-march=i386",
|
"-msoft-float",
|
||||||
"-pipe",
|
"-fno-builtin",
|
||||||
"-ffunction-sections",
|
// C++ flags
|
||||||
"-msoft-float",
|
"-fexceptions",
|
||||||
"-fno-builtin",
|
// Linker flags
|
||||||
|
"-fPIC",
|
||||||
// C++ flags
|
"-fPIE",
|
||||||
"-fexceptions",
|
"-pie",
|
||||||
|
"-Wl,-eDriverEntry",
|
||||||
// Linker flags
|
"-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment",
|
||||||
"-fPIC",
|
"-nostdlib",
|
||||||
"-fPIE",
|
"-nodefaultlibs",
|
||||||
"-pie",
|
"-nolibc",
|
||||||
"-Wl,-eDriverEntry",
|
"-zmax-page-size=0x1000",
|
||||||
"-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment",
|
"-static",
|
||||||
"-nostdlib",
|
// VSCode flags
|
||||||
"-nodefaultlibs",
|
"-ffreestanding",
|
||||||
"-nolibc",
|
"-nostdinc",
|
||||||
"-zmax-page-size=0x1000",
|
"-nostdinc++"
|
||||||
"-static",
|
]
|
||||||
|
},
|
||||||
// VSCode flags
|
{
|
||||||
"-ffreestanding",
|
"name": "Fennix Aarch64 (Linux, GCC, debug)",
|
||||||
"-nostdinc",
|
"includePath": [
|
||||||
"-nostdinc++"
|
"${workspaceFolder}/include",
|
||||||
]
|
"${workspaceFolder}/include/**"
|
||||||
}
|
],
|
||||||
],
|
"defines": [
|
||||||
"version": 4
|
"__debug_vscode__",
|
||||||
|
"KERNEL_NAME=\"Fennix\"",
|
||||||
|
"KERNEL_VERSION=\"1.0\"",
|
||||||
|
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
||||||
|
"GIT_COMMIT_SHORT=\"0000000\"",
|
||||||
|
"DEBUG=\"1\""
|
||||||
|
],
|
||||||
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"intelliSenseMode": "linux-gcc-arm64",
|
||||||
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
}
|
}
|
@ -47,12 +47,14 @@ build:
|
|||||||
cp -rf ../Kernel/include/interface/* include/
|
cp -rf ../Kernel/include/interface/* include/
|
||||||
mkdir -p out
|
mkdir -p out
|
||||||
make -C library build
|
make -C library build
|
||||||
|
ifneq ($(filter amd64 i386,$(OSARCH)),)
|
||||||
make -C audio build
|
make -C audio build
|
||||||
make -C input build
|
make -C input build
|
||||||
make -C misc build
|
make -C misc build
|
||||||
make -C network build
|
make -C network build
|
||||||
make -C storage build
|
make -C storage build
|
||||||
make -C filesystem build
|
make -C filesystem build
|
||||||
|
endif
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
$(info Nothing to prepare)
|
$(info Nothing to prepare)
|
||||||
@ -60,9 +62,11 @@ prepare:
|
|||||||
clean:
|
clean:
|
||||||
rm -rf out
|
rm -rf out
|
||||||
make -C library clean
|
make -C library clean
|
||||||
|
ifneq ($(filter amd64 i386,$(OSARCH)),)
|
||||||
make -C audio clean
|
make -C audio clean
|
||||||
make -C input clean
|
make -C input clean
|
||||||
make -C misc clean
|
make -C misc clean
|
||||||
make -C network clean
|
make -C network clean
|
||||||
make -C storage clean
|
make -C storage clean
|
||||||
make -C filesystem clean
|
make -C filesystem clean
|
||||||
|
endif
|
||||||
|
@ -40,6 +40,15 @@ static inline scarg syscall0(scarg syscall)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0");
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(x0)
|
||||||
|
: "r"(x8)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -65,6 +74,15 @@ static inline scarg syscall1(scarg syscall, scarg arg1)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -91,6 +109,16 @@ static inline scarg syscall2(scarg syscall, scarg arg1, scarg arg2)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -118,6 +146,17 @@ static inline scarg syscall3(scarg syscall, scarg arg1, scarg arg2, scarg arg3)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -147,6 +186,18 @@ static inline scarg syscall4(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -178,6 +229,19 @@ static inline scarg syscall5(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
register long x4 __asm__("x4") = arg5;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -211,6 +275,20 @@ static inline scarg syscall6(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
register long x4 __asm__("x4") = arg5;
|
||||||
|
register long x5 __asm__("x5") = arg6;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,7 +36,15 @@ CFLAGS += -pipe -fno-builtin -fPIC
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CRT_CFLAGS := -fPIC -fPIE -pie -mno-red-zone -std=c++20 -I$(INCLUDE_DIR)
|
CRT_CFLAGS := -fPIC -fPIE -pie -std=c++20 -I$(INCLUDE_DIR)
|
||||||
|
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
CRT_CFLAGS += -mno-red-zone
|
||||||
|
else ifeq ($(OSARCH), i386)
|
||||||
|
CRT_CFLAGS += -mno-red-zone
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
CRT_CFLAGS +=
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
|
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
|
||||||
|
@ -73,7 +73,11 @@ DefineFunction(void, KernelPrint, const char *format, ...)
|
|||||||
{
|
{
|
||||||
__builtin_va_list args;
|
__builtin_va_list args;
|
||||||
__builtin_va_start(args, format);
|
__builtin_va_start(args, format);
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
__KernelPrint(DriverID, (long)format, (long)args);
|
__KernelPrint(DriverID, (long)format, (long)args);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
__KernelPrint(DriverID, (long)format, (long)__builtin_va_arg(args, void *));
|
||||||
|
#endif
|
||||||
__builtin_va_end(args);
|
__builtin_va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +85,11 @@ DefineFunction(void, KernelLog, const char *format, ...)
|
|||||||
{
|
{
|
||||||
__builtin_va_list args;
|
__builtin_va_list args;
|
||||||
__builtin_va_start(args, format);
|
__builtin_va_start(args, format);
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
__KernelLog(DriverID, (long)format, (long)args);
|
__KernelLog(DriverID, (long)format, (long)args);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
__KernelLog(DriverID, (long)format, (long)__builtin_va_arg(args, void *));
|
||||||
|
#endif
|
||||||
__builtin_va_end(args);
|
__builtin_va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
59
Kernel/.vscode/c_cpp_properties.json
vendored
59
Kernel/.vscode/c_cpp_properties.json
vendored
@ -137,6 +137,33 @@
|
|||||||
"-nostdinc++"
|
"-nostdinc++"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Fennix Arm (Linux, GCC, debug)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/include",
|
||||||
|
"${workspaceFolder}/include/**",
|
||||||
|
"${workspaceFolder}/include_std",
|
||||||
|
"${workspaceFolder}/include_std/**",
|
||||||
|
"${workspaceFolder}/arch/aarch64/include"
|
||||||
|
],
|
||||||
|
"forcedInclude": [
|
||||||
|
"${workspaceFolder}/.vscode/preinclude.h"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"DEBUG=\"1\""
|
||||||
|
],
|
||||||
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/arm-fennix-gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"intelliSenseMode": "linux-gcc-arm",
|
||||||
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
|
"compilerArgs": [
|
||||||
|
// VSCode flags
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Fennix Aarch64 (Linux, GCC, debug)",
|
"name": "Fennix Aarch64 (Linux, GCC, debug)",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
@ -158,38 +185,6 @@
|
|||||||
"intelliSenseMode": "linux-gcc-arm64",
|
"intelliSenseMode": "linux-gcc-arm64",
|
||||||
"configurationProvider": "ms-vscode.makefile-tools",
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
"compilerArgs": [
|
"compilerArgs": [
|
||||||
// Compiler flags
|
|
||||||
"-pipe",
|
|
||||||
"-fno-builtin",
|
|
||||||
"-msoft-float",
|
|
||||||
"-fPIC",
|
|
||||||
"-Wstack-protector",
|
|
||||||
"-fcoroutines",
|
|
||||||
// Warnings
|
|
||||||
"-Wall",
|
|
||||||
"-Wextra",
|
|
||||||
"-Wfloat-equal",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-Wcast-align",
|
|
||||||
"-Wredundant-decls",
|
|
||||||
"-Winit-self",
|
|
||||||
"-Wswitch-default",
|
|
||||||
"-Wstrict-overflow=5",
|
|
||||||
"-Wconversion",
|
|
||||||
// C++ flags
|
|
||||||
"-fno-rtti",
|
|
||||||
"-fno-exceptions",
|
|
||||||
// Linker flags
|
|
||||||
"-T${workspaceFolder}/arch/aarch64/linker.ld",
|
|
||||||
"-fPIC",
|
|
||||||
// Debug flags
|
|
||||||
"-ggdb3",
|
|
||||||
"-O0",
|
|
||||||
"-fdiagnostics-color=always",
|
|
||||||
"-fverbose-asm",
|
|
||||||
"-fstack-usage",
|
|
||||||
"-fstack-check",
|
|
||||||
"-fsanitize=undefined",
|
|
||||||
// VSCode flags
|
// VSCode flags
|
||||||
"-ffreestanding",
|
"-ffreestanding",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
|
@ -45,16 +45,20 @@ CFLAGS := \
|
|||||||
-DKERNEL_VERSION='"$(KERNEL_VERSION)"' \
|
-DKERNEL_VERSION='"$(KERNEL_VERSION)"' \
|
||||||
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
||||||
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' \
|
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' \
|
||||||
-fno-pic -fno-pie -mno-red-zone -fno-builtin
|
-fno-pic -fno-pie -fno-builtin
|
||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
CFLAGS += -march=core2 -mcmodel=kernel -m64
|
CFLAGS += -march=core2 -mcmodel=kernel -m64 -mno-red-zone
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
LDFLAGS += -Tarch/amd64/linker.ld
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
CFLAGS += -march=pentium -m32
|
CFLAGS += -march=pentium -m32 -mno-red-zone
|
||||||
LDFLAGS += -Tarch/i386/linker.ld
|
LDFLAGS += -Tarch/i386/linker.ld
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
CFLAGS += -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16
|
||||||
|
LDFLAGS += -Tarch/arm/linker.ld
|
||||||
|
WARNCFLAG += -w
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
CFLAGS +=
|
CFLAGS += -march=armv9.4-a -mtune=cortex-a72 -mlittle-endian -mcmodel=large
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||||
endif # OSARCH
|
endif # OSARCH
|
||||||
|
|
||||||
@ -67,8 +71,11 @@ ifeq ($(DEBUG), 1)
|
|||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
CFLAGS += -fverbose-asm
|
CFLAGS += -fverbose-asm
|
||||||
endif # amd64
|
endif # amd64
|
||||||
ifneq ($(OSARCH), aarch64)
|
ifeq ($(OSARCH), arm)
|
||||||
CFLAGS += -fstack-check
|
CFLAGS += -fstack-check -fverbose-asm
|
||||||
|
endif # arm
|
||||||
|
ifeq ($(OSARCH), aarch64)
|
||||||
|
CFLAGS += -fstack-check -fverbose-asm
|
||||||
endif # aarch64
|
endif # aarch64
|
||||||
LDFLAGS += -ggdb3 -O0
|
LDFLAGS += -ggdb3 -O0
|
||||||
ASFLAGS += -g --gstabs+ --gdwarf-5 -D
|
ASFLAGS += -g --gstabs+ --gdwarf-5 -D
|
||||||
@ -119,6 +126,8 @@ ifeq ($(OSARCH), amd64)
|
|||||||
$(__CONF_OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
$(__CONF_OBJCOPY) -O elf32-i386 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf32-i386 -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
$(__CONF_OBJCOPY) -O elf32-littlearm -I binary $< $@
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
$(__CONF_OBJCOPY) -O elf64-littleaarch64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-littleaarch64 -I binary $< $@
|
||||||
endif
|
endif
|
||||||
@ -129,6 +138,8 @@ ifeq ($(OSARCH), amd64)
|
|||||||
$(__CONF_OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
$(__CONF_OBJCOPY) -O elf32-i386 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf32-i386 -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
$(__CONF_OBJCOPY) -O elf32-littlearm -I binary $< $@
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
$(__CONF_OBJCOPY) -O elf64-littlearch64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-littlearch64 -I binary $< $@
|
||||||
endif
|
endif
|
||||||
|
97
Kernel/arch/aarch64/madt.cpp
Normal file
97
Kernel/arch/aarch64/madt.cpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "acpi.hpp"
|
||||||
|
|
||||||
|
#include <memory.hpp>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include "../../kernel.h"
|
||||||
|
|
||||||
|
namespace ACPI
|
||||||
|
{
|
||||||
|
MADT::MADT(ACPI::MADTHeader *madt)
|
||||||
|
{
|
||||||
|
trace("Initializing MADT");
|
||||||
|
if (!madt)
|
||||||
|
{
|
||||||
|
error("MADT is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUCores = 0;
|
||||||
|
LAPICAddress = (LAPIC *)(uintptr_t)madt->LocalControllerAddress;
|
||||||
|
for (uint8_t *ptr = (uint8_t *)(madt->Entries);
|
||||||
|
(uintptr_t)(ptr) < (uintptr_t)(madt) + madt->Header.Length;
|
||||||
|
ptr += *(ptr + 1))
|
||||||
|
{
|
||||||
|
switch (*(ptr))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (ptr[4] & 1)
|
||||||
|
{
|
||||||
|
lapic.push_back((LocalAPIC *)ptr);
|
||||||
|
KPrint("Local APIC %d (APIC %d) found.", lapic.back()->ACPIProcessorId, lapic.back()->APICId);
|
||||||
|
CPUCores++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
ioapic.push_back((MADTIOApic *)ptr);
|
||||||
|
KPrint("I/O APIC %d (Address %#lx) found.", ioapic.back()->APICID, ioapic.back()->Address);
|
||||||
|
Memory::Virtual(KernelPageTable).Map((void *)(uintptr_t)ioapic.back()->Address, (void *)(uintptr_t)ioapic.back()->Address, Memory::PTFlag::RW | Memory::PTFlag::PCD); // Make sure that the address is mapped.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
iso.push_back((MADTIso *)ptr);
|
||||||
|
KPrint("ISO (IRQ:%#lx, BUS:%#lx, GSI:%#lx, %s/%s) found.",
|
||||||
|
iso.back()->IRQSource, iso.back()->BuSSource, iso.back()->GSI,
|
||||||
|
iso.back()->Flags & 0x00000004 ? "Active High" : "Active Low",
|
||||||
|
iso.back()->Flags & 0x00000100 ? "Edge Triggered" : "Level Triggered");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
nmi.push_back((MADTNmi *)ptr);
|
||||||
|
KPrint("NMI %#lx (lint:%#lx) found.", nmi.back()->processor, nmi.back()->lint);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
LAPICAddress = (LAPIC *)ptr;
|
||||||
|
KPrint("APIC found at %#lx", LAPICAddress);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
KPrint("Unknown MADT entry %#lx", *(ptr));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Memory::Virtual(KernelPageTable).Map((void *)LAPICAddress, (void *)LAPICAddress, Memory::PTFlag::RW | Memory::PTFlag::PCD); // I should map more than one page?
|
||||||
|
}
|
||||||
|
CPUCores--; // We start at 0 (BSP) and end at 11 (APs), so we have 12 cores.
|
||||||
|
KPrint("Total CPU cores: %d", CPUCores + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MADT::~MADT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -24,17 +24,46 @@ namespace Memory
|
|||||||
{
|
{
|
||||||
bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type)
|
bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type)
|
||||||
{
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Virtual::GetPhysical(void *VirtualAddress)
|
void *Virtual::GetPhysical(void *VirtualAddress)
|
||||||
{
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Virtual::MapType Virtual::GetMapType(void *VirtualAddress)
|
||||||
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
return MapType::NoMapType;
|
||||||
|
}
|
||||||
|
|
||||||
|
PageDirectoryEntry *Virtual::GetPDE(void *VirtualAddress, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PageTableEntry *Virtual::GetPTE(void *VirtualAddress, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
|
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
|
||||||
{
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
}
|
}
|
||||||
|
|
||||||
void Virtual::Unmap(void *VirtualAddress, MapType Type)
|
void Virtual::Unmap(void *VirtualAddress, MapType Type)
|
||||||
{
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
}
|
||||||
|
|
||||||
|
void Virtual::Remap(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,8 @@
|
|||||||
|
|
||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
|
|
||||||
extern "C" __naked __used __no_stack_protector void SystemCallHandlerStub()
|
extern "C" __used __no_stack_protector void SystemCallHandlerStub()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs);
|
extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs);
|
||||||
|
38
Kernel/arch/aarch64/tasking/signal.cpp
Normal file
38
Kernel/arch/aarch64/tasking/signal.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <signal.hpp>
|
||||||
|
#include <dumper.hpp>
|
||||||
|
#include <task.hpp>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* subsystem/linux/syscall.cpp */
|
||||||
|
extern int ConvertSignalToLinux(signal_t sig);
|
||||||
|
|
||||||
|
namespace Tasking
|
||||||
|
{
|
||||||
|
bool Signal::HandleSignal(CPU::SchedulerFrame *tf, void *thread)
|
||||||
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal::RestoreHandleSignal(SyscallsFrame *sf, void *thread)
|
||||||
|
{
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
}
|
||||||
|
}
|
28
Kernel/arch/aarch64/tasking/signal_trampoline.s
Normal file
28
Kernel/arch/aarch64/tasking/signal_trampoline.s
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.global _sig_native_trampoline_start
|
||||||
|
_sig_native_trampoline_start:
|
||||||
|
|
||||||
|
.global _sig_native_trampoline_end
|
||||||
|
_sig_native_trampoline_end:
|
||||||
|
|
||||||
|
.global _sig_linux_trampoline_start
|
||||||
|
_sig_linux_trampoline_start:
|
||||||
|
|
||||||
|
.global _sig_linux_trampoline_end
|
||||||
|
_sig_linux_trampoline_end:
|
40
Kernel/arch/arm/aeabi.c
Normal file
40
Kernel/arch/arm/aeabi.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned __aeabi_uidiv(unsigned a, unsigned b) { return a / b; }
|
||||||
|
unsigned __aeabi_idiv(unsigned a, unsigned b) { return a / b; }
|
||||||
|
unsigned __aeabi_l2d(unsigned a) { return a; }
|
||||||
|
unsigned __aeabi_d2lz(unsigned a) { return a; }
|
||||||
|
|
||||||
|
unsigned __aeabi_ldivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
|
||||||
|
|
||||||
|
unsigned __aeabi_uldivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
|
||||||
|
|
||||||
|
unsigned __aeabi_uidivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
|
||||||
|
|
||||||
|
|
||||||
|
unsigned __aeabi_idivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
|
||||||
|
|
||||||
|
|
||||||
|
unsigned __aeabi_unwind_cpp_pr1(void) { return 0; }
|
||||||
|
unsigned __aeabi_atexit(void) { return 0; }
|
||||||
|
unsigned __cxa_end_cleanup(void) { return 0; }
|
||||||
|
unsigned __aeabi_unwind_cpp_pr0(void) { return 0; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
18
Kernel/arch/arm/bootstrap/boot.S
Normal file
18
Kernel/arch/arm/bootstrap/boot.S
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* Based on this tutorial:
|
||||||
|
https://github.com/s-matyukevich/raspberry-pi-os */
|
||||||
|
|
||||||
|
.section ".text.boot", "a"
|
||||||
|
|
||||||
|
.extern _bss_start
|
||||||
|
.extern _bss_end
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
b CPU_Loop
|
||||||
|
|
||||||
|
Halt:
|
||||||
|
wfe
|
||||||
|
b Halt
|
||||||
|
|
||||||
|
CPU_Loop:
|
||||||
|
b CPU_Loop
|
46
Kernel/arch/arm/core/panic/ui.cpp
Normal file
46
Kernel/arch/arm/core/panic/ui.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <display.hpp>
|
||||||
|
#include <bitmap.hpp>
|
||||||
|
#include <convert.h>
|
||||||
|
#include <printf.h>
|
||||||
|
#include <lock.hpp>
|
||||||
|
#include <rand.hpp>
|
||||||
|
#include <uart.hpp>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <smp.hpp>
|
||||||
|
#include <cpu.hpp>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
#if defined(__amd64__)
|
||||||
|
#include "../../arch/amd64/cpu/gdt.hpp"
|
||||||
|
#include "../arch/amd64/cpu/apic.hpp"
|
||||||
|
#elif defined(__i386__)
|
||||||
|
#include "../../arch/i386/cpu/gdt.hpp"
|
||||||
|
#include "../arch/i386/cpu/apic.hpp"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../../../../kernel.h"
|
||||||
|
|
||||||
|
extern void ExPrint(const char *Format, ...);
|
||||||
|
|
||||||
|
arch nsa void DisplayDetailsScreen(CPU::ExceptionFrame *Frame)
|
||||||
|
{
|
||||||
|
ExPrint("\nException Frame:\n");
|
||||||
|
}
|
59
Kernel/arch/arm/cpu/smp.cpp
Normal file
59
Kernel/arch/arm/cpu/smp.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <smp.hpp>
|
||||||
|
|
||||||
|
#include <ints.hpp>
|
||||||
|
#include <memory.hpp>
|
||||||
|
#include <cpu.hpp>
|
||||||
|
|
||||||
|
#include "../../../kernel.h"
|
||||||
|
|
||||||
|
volatile bool CPUEnabled = false;
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||||
|
static __aligned(0x1000) CPUData CPUs[MAX_CPU] = {0};
|
||||||
|
|
||||||
|
CPUData *GetCPU(uint64_t id) { return &CPUs[id]; }
|
||||||
|
|
||||||
|
CPUData *GetCurrentCPU()
|
||||||
|
{
|
||||||
|
uint64_t ret = 0;
|
||||||
|
|
||||||
|
if (!CPUs[ret].IsActive)
|
||||||
|
{
|
||||||
|
error("CPU %d is not active!", ret);
|
||||||
|
return &CPUs[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CPUs[ret].Checksum != CPU_DATA_CHECKSUM)
|
||||||
|
{
|
||||||
|
error("CPU %d data is corrupted!", ret);
|
||||||
|
return &CPUs[0];
|
||||||
|
}
|
||||||
|
return &CPUs[ret];
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace SMP
|
||||||
|
{
|
||||||
|
int CPUCores = 0;
|
||||||
|
|
||||||
|
void Initialize(void *madt)
|
||||||
|
{
|
||||||
|
fixme("SMP::Initialize() is not implemented!");
|
||||||
|
}
|
||||||
|
}
|
27
Kernel/arch/arm/entry.cpp
Normal file
27
Kernel/arch/arm/entry.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
#include <cpu.hpp>
|
||||||
|
|
||||||
|
EXTERNC void arm64Entry(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3)
|
||||||
|
{
|
||||||
|
trace("Hello, World!");
|
||||||
|
CPU::Halt(true);
|
||||||
|
}
|
0
Kernel/arch/arm/include/.gitkeep
Normal file
0
Kernel/arch/arm/include/.gitkeep
Normal file
89
Kernel/arch/arm/linker.ld
Normal file
89
Kernel/arch/arm/linker.ld
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
_bootstrap_start = .;
|
||||||
|
.text.boot :
|
||||||
|
{
|
||||||
|
*(.text.boot)
|
||||||
|
. += CONSTANT(MAXPAGESIZE);
|
||||||
|
_bss_start = .;
|
||||||
|
*(.text.bss)
|
||||||
|
_bss_end = .;
|
||||||
|
}
|
||||||
|
_bootstrap_end = .;
|
||||||
|
|
||||||
|
_kernel_start = .;
|
||||||
|
_kernel_text_start = .;
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
KEEP(*(.text.boot))
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
_kernel_text_end = .;
|
||||||
|
|
||||||
|
_kernel_data_start = .;
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
_kernel_data_end = .;
|
||||||
|
|
||||||
|
_kernel_rodata_start = .;
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
|
||||||
|
.init_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN(__init_array_start = .);
|
||||||
|
KEEP(*(.init_array .ctors))
|
||||||
|
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fini_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||||
|
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||||
|
KEEP(*(.fini_array .dtors))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
}
|
||||||
|
_kernel_rodata_end = .;
|
||||||
|
|
||||||
|
_kernel_bss_start = .;
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
_kernel_bss_end = .;
|
||||||
|
_kernel_end = .;
|
||||||
|
_bss_size = _kernel_end - _kernel_rodata_end;
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.comment*)
|
||||||
|
}
|
||||||
|
}
|
97
Kernel/arch/arm/madt.cpp
Normal file
97
Kernel/arch/arm/madt.cpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "acpi.hpp"
|
||||||
|
|
||||||
|
#include <memory.hpp>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include "../../kernel.h"
|
||||||
|
|
||||||
|
namespace ACPI
|
||||||
|
{
|
||||||
|
MADT::MADT(ACPI::MADTHeader *madt)
|
||||||
|
{
|
||||||
|
trace("Initializing MADT");
|
||||||
|
if (!madt)
|
||||||
|
{
|
||||||
|
error("MADT is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUCores = 0;
|
||||||
|
LAPICAddress = (LAPIC *)(uintptr_t)madt->LocalControllerAddress;
|
||||||
|
for (uint8_t *ptr = (uint8_t *)(madt->Entries);
|
||||||
|
(uintptr_t)(ptr) < (uintptr_t)(madt) + madt->Header.Length;
|
||||||
|
ptr += *(ptr + 1))
|
||||||
|
{
|
||||||
|
switch (*(ptr))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (ptr[4] & 1)
|
||||||
|
{
|
||||||
|
lapic.push_back((LocalAPIC *)ptr);
|
||||||
|
KPrint("Local APIC %d (APIC %d) found.", lapic.back()->ACPIProcessorId, lapic.back()->APICId);
|
||||||
|
CPUCores++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
ioapic.push_back((MADTIOApic *)ptr);
|
||||||
|
KPrint("I/O APIC %d (Address %#lx) found.", ioapic.back()->APICID, ioapic.back()->Address);
|
||||||
|
Memory::Virtual(KernelPageTable).Map((void *)(uintptr_t)ioapic.back()->Address, (void *)(uintptr_t)ioapic.back()->Address, Memory::PTFlag::RW | Memory::PTFlag::PCD); // Make sure that the address is mapped.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
iso.push_back((MADTIso *)ptr);
|
||||||
|
KPrint("ISO (IRQ:%#lx, BUS:%#lx, GSI:%#lx, %s/%s) found.",
|
||||||
|
iso.back()->IRQSource, iso.back()->BuSSource, iso.back()->GSI,
|
||||||
|
iso.back()->Flags & 0x00000004 ? "Active High" : "Active Low",
|
||||||
|
iso.back()->Flags & 0x00000100 ? "Edge Triggered" : "Level Triggered");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
nmi.push_back((MADTNmi *)ptr);
|
||||||
|
KPrint("NMI %#lx (lint:%#lx) found.", nmi.back()->processor, nmi.back()->lint);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
LAPICAddress = (LAPIC *)ptr;
|
||||||
|
KPrint("APIC found at %#lx", LAPICAddress);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
KPrint("Unknown MADT entry %#lx", *(ptr));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Memory::Virtual(KernelPageTable).Map((void *)LAPICAddress, (void *)LAPICAddress, Memory::PTFlag::RW | Memory::PTFlag::PCD); // I should map more than one page?
|
||||||
|
}
|
||||||
|
CPUCores--; // We start at 0 (BSP) and end at 11 (APs), so we have 12 cores.
|
||||||
|
KPrint("Total CPU cores: %d", CPUCores + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MADT::~MADT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
69
Kernel/arch/arm/memory/vmm.cpp
Normal file
69
Kernel/arch/arm/memory/vmm.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory.hpp>
|
||||||
|
|
||||||
|
#include <convert.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
namespace Memory
|
||||||
|
{
|
||||||
|
bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Virtual::GetPhysical(void *VirtualAddress)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Virtual::MapType Virtual::GetMapType(void *VirtualAddress)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
return MapType::NoMapType;
|
||||||
|
}
|
||||||
|
|
||||||
|
PageDirectoryEntry *Virtual::GetPDE(void *VirtualAddress, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PageTableEntry *Virtual::GetPTE(void *VirtualAddress, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
}
|
||||||
|
|
||||||
|
void Virtual::Unmap(void *VirtualAddress, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
}
|
||||||
|
|
||||||
|
void Virtual::Remap(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
}
|
||||||
|
}
|
30
Kernel/arch/arm/syscalls.cpp
Normal file
30
Kernel/arch/arm/syscalls.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <syscalls.hpp>
|
||||||
|
|
||||||
|
#include <cpu.hpp>
|
||||||
|
|
||||||
|
extern "C" __used __no_stack_protector void SystemCallHandlerStub()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs);
|
||||||
|
|
||||||
|
void InitializeSystemCalls()
|
||||||
|
{
|
||||||
|
}
|
38
Kernel/arch/arm/tasking/signal.cpp
Normal file
38
Kernel/arch/arm/tasking/signal.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <signal.hpp>
|
||||||
|
#include <dumper.hpp>
|
||||||
|
#include <task.hpp>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* subsystem/linux/syscall.cpp */
|
||||||
|
extern int ConvertSignalToLinux(signal_t sig);
|
||||||
|
|
||||||
|
namespace Tasking
|
||||||
|
{
|
||||||
|
bool Signal::HandleSignal(CPU::SchedulerFrame *tf, void *thread)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal::RestoreHandleSignal(SyscallsFrame *sf, void *thread)
|
||||||
|
{
|
||||||
|
#warning "arm not implemented"
|
||||||
|
}
|
||||||
|
}
|
28
Kernel/arch/arm/tasking/signal_trampoline.s
Normal file
28
Kernel/arch/arm/tasking/signal_trampoline.s
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.global _sig_native_trampoline_start
|
||||||
|
_sig_native_trampoline_start:
|
||||||
|
|
||||||
|
.global _sig_native_trampoline_end
|
||||||
|
_sig_native_trampoline_end:
|
||||||
|
|
||||||
|
.global _sig_linux_trampoline_start
|
||||||
|
_sig_linux_trampoline_start:
|
||||||
|
|
||||||
|
.global _sig_linux_trampoline_end
|
||||||
|
_sig_linux_trampoline_end:
|
@ -194,10 +194,14 @@ namespace ACPI
|
|||||||
|
|
||||||
if (FADT)
|
if (FADT)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
outb(s_cst(uint16_t, FADT->SMI_CommandPort), FADT->AcpiEnable);
|
outb(s_cst(uint16_t, FADT->SMI_CommandPort), FADT->AcpiEnable);
|
||||||
/* TODO: Sleep for ~5 seconds before polling PM1a CB? */
|
/* TODO: Sleep for ~5 seconds before polling PM1a CB? */
|
||||||
while (!(inw(s_cst(uint16_t, FADT->PM1aControlBlock)) & 1))
|
while (!(inw(s_cst(uint16_t, FADT->PM1aControlBlock)) & 1))
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
warn("aarch64 is not supported yet");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace CPU
|
|||||||
memcpy(Vendor + 4, &edx, 4);
|
memcpy(Vendor + 4, &edx, 4);
|
||||||
memcpy(Vendor + 8, &ecx, 4);
|
memcpy(Vendor + 8, &ecx, 4);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
#error "Not implemented"
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
return Vendor;
|
return Vendor;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ namespace CPU
|
|||||||
memcpy(Name + 40, &ecx, 4);
|
memcpy(Name + 40, &ecx, 4);
|
||||||
memcpy(Name + 44, &edx, 4);
|
memcpy(Name + 44, &edx, 4);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
#error "Not implemented"
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ namespace CPU
|
|||||||
memcpy(Hypervisor + 4, &ecx, 4);
|
memcpy(Hypervisor + 4, &ecx, 4);
|
||||||
memcpy(Hypervisor + 8, &edx, 4);
|
memcpy(Hypervisor + 8, &edx, 4);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
#error "Not implemented"
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
return Hypervisor;
|
return Hypervisor;
|
||||||
}
|
}
|
||||||
@ -164,9 +164,8 @@ namespace CPU
|
|||||||
: "=r"(Flags));
|
: "=r"(Flags));
|
||||||
return Flags & (1 << 9);
|
return Flags & (1 << 9);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("mrs %0, cpsr"
|
#warning "aarch64 not implemented"
|
||||||
: "=r"(Flags));
|
return 0;
|
||||||
return Flags & (1 << 7);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
case Enable:
|
case Enable:
|
||||||
@ -174,7 +173,7 @@ namespace CPU
|
|||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("sti");
|
asmv("sti");
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("cpsie i");
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -183,7 +182,7 @@ namespace CPU
|
|||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("cli");
|
asmv("cli");
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("cpsid i");
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -225,10 +224,7 @@ namespace CPU
|
|||||||
|
|
||||||
if (PT)
|
if (PT)
|
||||||
{
|
{
|
||||||
asmv("msr ttbr0_el1, %0"
|
#warning "aarch64 not implemented"
|
||||||
:
|
|
||||||
: "r"(PT)
|
|
||||||
: "memory");
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
@ -275,6 +271,7 @@ namespace CPU
|
|||||||
|
|
||||||
void InitializeFeatures(int Core)
|
void InitializeFeatures(int Core)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
static int BSP = 0;
|
static int BSP = 0;
|
||||||
SupportedFeat feat = GetCPUFeat();
|
SupportedFeat feat = GetCPUFeat();
|
||||||
|
|
||||||
@ -386,6 +383,7 @@ namespace CPU
|
|||||||
SSEEnabled = true;
|
SSEEnabled = true;
|
||||||
debug("SSE support enabled.");
|
debug("SSE support enabled.");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Counter()
|
uint64_t Counter()
|
||||||
@ -399,8 +397,8 @@ namespace CPU
|
|||||||
"=d"(edx));
|
"=d"(edx));
|
||||||
Counter = ((uint64_t)eax) | (((uint64_t)edx) << 32);
|
Counter = ((uint64_t)eax) | (((uint64_t)edx) << 32);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("mrs %0, cntvct_el0"
|
#warning "aarch64 not implemented"
|
||||||
: "=r"(Counter));
|
Counter = 0;
|
||||||
#endif
|
#endif
|
||||||
return Counter;
|
return Counter;
|
||||||
}
|
}
|
||||||
|
@ -76,17 +76,15 @@ namespace v0
|
|||||||
cs = Flags & (1 << 9);
|
cs = Flags & (1 << 9);
|
||||||
asmv("cli");
|
asmv("cli");
|
||||||
|
|
||||||
#elif defined(__arm__) || defined(__aarch64__)
|
return cs;
|
||||||
|
|
||||||
uintptr_t Flags;
|
#elif defined(__aarch64__)
|
||||||
asmv("mrs %0, cpsr"
|
|
||||||
: "=r"(Flags));
|
stub;
|
||||||
cs = Flags & (1 << 7);
|
|
||||||
asmv("cpsid i");
|
return 0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return cs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeaveCriticalSection(dev_t DriverID, CriticalState PreviousState)
|
void LeaveCriticalSection(dev_t DriverID, CriticalState PreviousState)
|
||||||
@ -101,7 +99,7 @@ namespace v0
|
|||||||
#elif defined(__arm__) || defined(__aarch64__)
|
#elif defined(__arm__) || defined(__aarch64__)
|
||||||
|
|
||||||
if (PreviousState)
|
if (PreviousState)
|
||||||
asmv("cpsie i");
|
stub;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -284,15 +282,18 @@ namespace v0
|
|||||||
{
|
{
|
||||||
dbg_api("%d, %d", DriverID, IRQ);
|
dbg_api("%d, %d", DriverID, IRQ);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (IRQ >= 8)
|
if (IRQ >= 8)
|
||||||
outb(PIC2_CMD, _PIC_EOI);
|
outb(PIC2_CMD, _PIC_EOI);
|
||||||
outb(PIC1_CMD, _PIC_EOI);
|
outb(PIC1_CMD, _PIC_EOI);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRQ_MASK(dev_t DriverID, uint8_t IRQ)
|
void IRQ_MASK(dev_t DriverID, uint8_t IRQ)
|
||||||
{
|
{
|
||||||
dbg_api("%d, %d", DriverID, IRQ);
|
dbg_api("%d, %d", DriverID, IRQ);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
|
||||||
@ -306,12 +307,14 @@ namespace v0
|
|||||||
|
|
||||||
value = inb(port) | (1 << IRQ);
|
value = inb(port) | (1 << IRQ);
|
||||||
outb(port, value);
|
outb(port, value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRQ_UNMASK(dev_t DriverID, uint8_t IRQ)
|
void IRQ_UNMASK(dev_t DriverID, uint8_t IRQ)
|
||||||
{
|
{
|
||||||
dbg_api("%d, %d", DriverID, IRQ);
|
dbg_api("%d, %d", DriverID, IRQ);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
|
||||||
@ -325,12 +328,14 @@ namespace v0
|
|||||||
|
|
||||||
value = inb(port) & ~(1 << IRQ);
|
value = inb(port) & ~(1 << IRQ);
|
||||||
outb(port, value);
|
outb(port, value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS2Wait(dev_t DriverID, const bool Output)
|
void PS2Wait(dev_t DriverID, const bool Output)
|
||||||
{
|
{
|
||||||
dbg_api("%d, %d", DriverID, Output);
|
dbg_api("%d, %d", DriverID, Output);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
int Timeout = 100000;
|
int Timeout = 100000;
|
||||||
PS2_STATUSES Status = {.Raw = inb(PS2_STATUS)};
|
PS2_STATUSES Status = {.Raw = inb(PS2_STATUS)};
|
||||||
while (Timeout--)
|
while (Timeout--)
|
||||||
@ -349,38 +354,51 @@ namespace v0
|
|||||||
}
|
}
|
||||||
|
|
||||||
warn("PS/2 controller timeout! (Status: %#x, %d)", Status, Output);
|
warn("PS/2 controller timeout! (Status: %#x, %d)", Status, Output);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS2WriteCommand(dev_t DriverID, uint8_t Command)
|
void PS2WriteCommand(dev_t DriverID, uint8_t Command)
|
||||||
{
|
{
|
||||||
dbg_api("%d, %d", DriverID, Command);
|
dbg_api("%d, %d", DriverID, Command);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
WaitInput;
|
WaitInput;
|
||||||
outb(PS2_CMD, Command);
|
outb(PS2_CMD, Command);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS2WriteData(dev_t DriverID, uint8_t Data)
|
void PS2WriteData(dev_t DriverID, uint8_t Data)
|
||||||
{
|
{
|
||||||
dbg_api("%d, %d", DriverID, Data);
|
dbg_api("%d, %d", DriverID, Data);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
WaitInput;
|
WaitInput;
|
||||||
outb(PS2_DATA, Data);
|
outb(PS2_DATA, Data);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PS2ReadData(dev_t DriverID)
|
uint8_t PS2ReadData(dev_t DriverID)
|
||||||
{
|
{
|
||||||
dbg_api("%d", DriverID);
|
dbg_api("%d", DriverID);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
WaitOutput;
|
WaitOutput;
|
||||||
return inb(PS2_DATA);
|
return inb(PS2_DATA);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PS2ReadStatus(dev_t DriverID)
|
uint8_t PS2ReadStatus(dev_t DriverID)
|
||||||
{
|
{
|
||||||
dbg_api("%d", DriverID);
|
dbg_api("%d", DriverID);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
WaitOutput;
|
WaitOutput;
|
||||||
return inb(PS2_STATUS);
|
return inb(PS2_STATUS);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PS2ReadAfterACK(dev_t DriverID)
|
uint8_t PS2ReadAfterACK(dev_t DriverID)
|
||||||
@ -388,11 +406,13 @@ namespace v0
|
|||||||
dbg_api("%d", DriverID);
|
dbg_api("%d", DriverID);
|
||||||
|
|
||||||
uint8_t ret = PS2ReadData(DriverID);
|
uint8_t ret = PS2ReadData(DriverID);
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
while (ret == PS2_ACK)
|
while (ret == PS2_ACK)
|
||||||
{
|
{
|
||||||
WaitOutput;
|
WaitOutput;
|
||||||
ret = inb(PS2_DATA);
|
ret = inb(PS2_DATA);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,6 +420,7 @@ namespace v0
|
|||||||
{
|
{
|
||||||
dbg_api("%d", DriverID);
|
dbg_api("%d", DriverID);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
PS2_STATUSES Status;
|
PS2_STATUSES Status;
|
||||||
int timeout = 0x500;
|
int timeout = 0x500;
|
||||||
while (timeout--)
|
while (timeout--)
|
||||||
@ -409,6 +430,7 @@ namespace v0
|
|||||||
return;
|
return;
|
||||||
inb(PS2_DATA);
|
inb(PS2_DATA);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS2ACKTimeout(dev_t DriverID)
|
int PS2ACKTimeout(dev_t DriverID)
|
||||||
|
@ -61,6 +61,7 @@ namespace ACPI
|
|||||||
debug("SCI Handle Triggered");
|
debug("SCI Handle Triggered");
|
||||||
uint16_t Event = 0;
|
uint16_t Event = 0;
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint16_t a = 0, b = 0;
|
uint16_t a = 0, b = 0;
|
||||||
if (acpi->FADT->PM1aEventBlock)
|
if (acpi->FADT->PM1aEventBlock)
|
||||||
{
|
{
|
||||||
@ -73,6 +74,7 @@ namespace ACPI
|
|||||||
outw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock), b);
|
outw(s_cst(uint16_t, acpi->FADT->PM1bEventBlock), b);
|
||||||
}
|
}
|
||||||
Event = a | b;
|
Event = a | b;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -161,6 +163,7 @@ namespace ACPI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (inw(s_cst(uint16_t, PM1a_CNT) & SCI_EN) == 0)
|
if (inw(s_cst(uint16_t, PM1a_CNT) & SCI_EN) == 0)
|
||||||
{
|
{
|
||||||
KPrint("ACPI was disabled, enabling...");
|
KPrint("ACPI was disabled, enabling...");
|
||||||
@ -195,6 +198,9 @@ namespace ACPI
|
|||||||
outw(s_cst(uint16_t, PM1a_CNT), SLP_TYPa | SLP_EN);
|
outw(s_cst(uint16_t, PM1a_CNT), SLP_TYPa | SLP_EN);
|
||||||
if (PM1b_CNT)
|
if (PM1b_CNT)
|
||||||
outw(s_cst(uint16_t, PM1b_CNT), SLP_TYPb | SLP_EN);
|
outw(s_cst(uint16_t, PM1b_CNT), SLP_TYPb | SLP_EN);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
warn("ACPI Shutdown not supported");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSDT::Reboot()
|
void DSDT::Reboot()
|
||||||
@ -209,7 +215,11 @@ namespace ACPI
|
|||||||
}
|
}
|
||||||
case ACPI_GAS_IO:
|
case ACPI_GAS_IO:
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
outb(s_cst(uint16_t, acpi->FADT->ResetReg.Address), acpi->FADT->ResetValue);
|
outb(s_cst(uint16_t, acpi->FADT->ResetReg.Address), acpi->FADT->ResetValue);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
warn("ACPI_GAS_IO not supported");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACPI_GAS_PCI:
|
case ACPI_GAS_PCI:
|
||||||
@ -294,6 +304,7 @@ namespace ACPI
|
|||||||
KPrint("ACPI Shutdown is supported");
|
KPrint("ACPI Shutdown is supported");
|
||||||
ACPIShutdownSupported = true;
|
ACPIShutdownSupported = true;
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
{
|
{
|
||||||
const uint16_t value = /*ACPI_TIMER |*/ ACPI_BUSMASTER | ACPI_GLOBAL |
|
const uint16_t value = /*ACPI_TIMER |*/ ACPI_BUSMASTER | ACPI_GLOBAL |
|
||||||
ACPI_POWER_BUTTON | ACPI_SLEEP_BUTTON | ACPI_RTC_ALARM |
|
ACPI_POWER_BUTTON | ACPI_SLEEP_BUTTON | ACPI_RTC_ALARM |
|
||||||
@ -322,6 +333,7 @@ namespace ACPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
((APIC::APIC *)Interrupts::apic[0])->RedirectIRQ(0, uint8_t(acpi->FADT->SCI_Interrupt), 1);
|
((APIC::APIC *)Interrupts::apic[0])->RedirectIRQ(0, uint8_t(acpi->FADT->SCI_Interrupt), 1);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
warn("Failed to parse _S5_ in ACPI");
|
warn("Failed to parse _S5_ in ACPI");
|
||||||
|
@ -110,6 +110,8 @@ namespace Interrupts
|
|||||||
/* APIC::APIC */ void *apic[MAX_CPU] = {nullptr};
|
/* APIC::APIC */ void *apic[MAX_CPU] = {nullptr};
|
||||||
/* APIC::Timer */ void *apicTimer[MAX_CPU] = {nullptr};
|
/* APIC::Timer */ void *apicTimer[MAX_CPU] = {nullptr};
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
|
/* APIC::APIC */ void *apic[MAX_CPU] = {nullptr};
|
||||||
|
/* APIC::Timer */ void *apicTimer[MAX_CPU] = {nullptr};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Initialize(int Core)
|
void Initialize(int Core)
|
||||||
@ -264,6 +266,7 @@ namespace Interrupts
|
|||||||
|
|
||||||
nsa inline void ReturnFromInterrupt()
|
nsa inline void ReturnFromInterrupt()
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
CPUData *CoreData = GetCurrentCPU();
|
CPUData *CoreData = GetCurrentCPU();
|
||||||
int Core = CoreData->ID;
|
int Core = CoreData->ID;
|
||||||
|
|
||||||
@ -299,8 +302,9 @@ namespace Interrupts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
fixme("APIC not found for core %d", Core);
|
fixme("APIC not found for core %d", Core);
|
||||||
// TODO: Handle PIC too
|
// TODO: Handle PIC too
|
||||||
|
|
||||||
|
#endif
|
||||||
assert(!"EOI not handled.");
|
assert(!"EOI not handled.");
|
||||||
CPU::Stop();
|
CPU::Stop();
|
||||||
}
|
}
|
||||||
@ -317,24 +321,23 @@ namespace Interrupts
|
|||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %%cr3, %0" : "=r"(Original));
|
asmv("mov %%cr3, %0" : "=r"(Original));
|
||||||
#endif
|
|
||||||
if (likely(Original == KernelPageTable))
|
if (likely(Original == KernelPageTable))
|
||||||
return;
|
return;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
asmv("mov %0, %%cr3" : : "r"(KernelPageTable));
|
asmv("mov %0, %%cr3" : : "r"(KernelPageTable));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoSwitchPageTable()
|
~AutoSwitchPageTable()
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (likely(Original == KernelPageTable))
|
if (likely(Original == KernelPageTable))
|
||||||
return;
|
return;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
asmv("mov %0, %%cr3" : : "r"(Original));
|
asmv("mov %0, %%cr3" : : "r"(Original));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} SwitchPageTable;
|
} SwitchPageTable;
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
CPU::TrapFrame *Frame = (CPU::TrapFrame *)Data;
|
CPU::TrapFrame *Frame = (CPU::TrapFrame *)Data;
|
||||||
// debug("IRQ%ld", Frame->InterruptNumber - 32);
|
// debug("IRQ%ld", Frame->InterruptNumber - 32);
|
||||||
|
|
||||||
@ -378,10 +381,12 @@ namespace Interrupts
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnFromInterrupt();
|
ReturnFromInterrupt();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" nsa void SchedulerInterruptHandler(void *Data)
|
extern "C" nsa void SchedulerInterruptHandler(void *Data)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
KernelPageTable->Update();
|
KernelPageTable->Update();
|
||||||
CPU::SchedulerFrame *Frame = (CPU::SchedulerFrame *)Data;
|
CPU::SchedulerFrame *Frame = (CPU::SchedulerFrame *)Data;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
@ -411,6 +416,7 @@ namespace Interrupts
|
|||||||
Handler *hnd = (Handler *)it->Data;
|
Handler *hnd = (Handler *)it->Data;
|
||||||
hnd->OnInterruptReceived(Frame);
|
hnd->OnInterruptReceived(Frame);
|
||||||
ReturnFromInterrupt();
|
ReturnFromInterrupt();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler::Handler(int InterruptNumber, bool Critical)
|
Handler::Handler(int InterruptNumber, bool Critical)
|
||||||
@ -469,11 +475,15 @@ namespace Interrupts
|
|||||||
|
|
||||||
void Handler::OnInterruptReceived(CPU::TrapFrame *Frame)
|
void Handler::OnInterruptReceived(CPU::TrapFrame *Frame)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
debug("Unhandled interrupt %d", Frame->InterruptNumber);
|
debug("Unhandled interrupt %d", Frame->InterruptNumber);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handler::OnInterruptReceived(CPU::SchedulerFrame *Frame)
|
void Handler::OnInterruptReceived(CPU::SchedulerFrame *Frame)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
debug("Unhandled scheduler interrupt %d", Frame->InterruptNumber);
|
debug("Unhandled scheduler interrupt %d", Frame->InterruptNumber);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,9 +551,9 @@ struct heap_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Keep in sync with heap_t inside rpmalloc_compat.cpp */
|
/* Keep in sync with heap_t inside rpmalloc_compat.cpp */
|
||||||
#ifndef __i386__
|
#if !defined(__i386__) && !defined(__arm__)
|
||||||
static_assert(sizeof(heap_t) == 56408, "heap_t size mismatch");
|
static_assert(sizeof(heap_t) == 56408, "heap_t size mismatch");
|
||||||
#endif // __i386__
|
#endif // __i386__ || __arm__
|
||||||
|
|
||||||
// Size class for defining a block size bucket
|
// Size class for defining a block size bucket
|
||||||
struct size_class_t
|
struct size_class_t
|
||||||
@ -3105,7 +3105,11 @@ rpcalloc(size_t num, size_t size)
|
|||||||
{
|
{
|
||||||
size_t total;
|
size_t total;
|
||||||
#if ENABLE_VALIDATE_ARGS
|
#if ENABLE_VALIDATE_ARGS
|
||||||
|
#ifdef __arm__
|
||||||
|
int err = __builtin_umull_overflow(num, size, (unsigned long *)&total);
|
||||||
|
#else
|
||||||
int err = __builtin_umull_overflow(num, size, &total);
|
int err = __builtin_umull_overflow(num, size, &total);
|
||||||
|
#endif
|
||||||
assert(!err && (total < MAX_ALLOC_SIZE));
|
assert(!err && (total < MAX_ALLOC_SIZE));
|
||||||
#else
|
#else
|
||||||
total = num * size;
|
total = num * size;
|
||||||
@ -3150,7 +3154,11 @@ rpaligned_calloc(size_t alignment, size_t num, size_t size)
|
|||||||
{
|
{
|
||||||
size_t total;
|
size_t total;
|
||||||
#if ENABLE_VALIDATE_ARGS
|
#if ENABLE_VALIDATE_ARGS
|
||||||
|
#ifdef __arm__
|
||||||
|
int err = __builtin_umull_overflow(num, size, (unsigned long *)&total);
|
||||||
|
#else
|
||||||
int err = __builtin_umull_overflow(num, size, &total);
|
int err = __builtin_umull_overflow(num, size, &total);
|
||||||
|
#endif
|
||||||
assert(!err && (total < MAX_ALLOC_SIZE));
|
assert(!err && (total < MAX_ALLOC_SIZE));
|
||||||
#else
|
#else
|
||||||
total = num * size;
|
total = num * size;
|
||||||
|
@ -93,7 +93,7 @@ namespace Memory
|
|||||||
#if defined(__amd64__) || defined(__aarch64__)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
Elf64_Xword SymbolSize = 0;
|
Elf64_Xword SymbolSize = 0;
|
||||||
Elf64_Xword StringSize = 0;
|
Elf64_Xword StringSize = 0;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
Elf32_Word SymbolSize = 0;
|
Elf32_Word SymbolSize = 0;
|
||||||
Elf32_Word StringSize = 0;
|
Elf32_Word StringSize = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -194,6 +194,7 @@ namespace Memory
|
|||||||
bool VirtualMemoryArea::HandleCoW(uintptr_t PFA)
|
bool VirtualMemoryArea::HandleCoW(uintptr_t PFA)
|
||||||
{
|
{
|
||||||
func("%#lx", PFA);
|
func("%#lx", PFA);
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
Virtual vmm(this->Table);
|
Virtual vmm(this->Table);
|
||||||
PageTableEntry *pte = vmm.GetPTE((void *)PFA);
|
PageTableEntry *pte = vmm.GetPTE((void *)PFA);
|
||||||
|
|
||||||
@ -252,6 +253,9 @@ namespace Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#warning "Not implemented"
|
||||||
|
#endif
|
||||||
debug("%#lx not found in CoW regions", PFA);
|
debug("%#lx not found in CoW regions", PFA);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -325,7 +329,7 @@ namespace Memory
|
|||||||
this->Map(AddressToMap, RealAddress, PAGE_SIZE, Flags);
|
this->Map(AddressToMap, RealAddress, PAGE_SIZE, Flags);
|
||||||
MgrLock.Lock(__FUNCTION__);
|
MgrLock.Lock(__FUNCTION__);
|
||||||
#else
|
#else
|
||||||
#error "Not implemented"
|
#warning "Not implemented"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,10 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
|||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
|
|
||||||
ExPrint("\x1b[0m-----------------------------------------------\n");
|
ExPrint("\x1b[0m-----------------------------------------------\n");
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("\x1b[30;41mUnrecoverable exception %#lx on CPU %d\n",
|
ExPrint("\x1b[30;41mUnrecoverable exception %#lx on CPU %d\n",
|
||||||
Frame->InterruptNumber, core->ID);
|
Frame->InterruptNumber, core->ID);
|
||||||
|
#endif
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
||||||
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
||||||
@ -222,7 +224,9 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
|||||||
#endif /* a86 */
|
#endif /* a86 */
|
||||||
|
|
||||||
Display->UpdateBuffer();
|
Display->UpdateBuffer();
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
error("Unrecoverable Exception: %#lx", Frame->InterruptNumber);
|
error("Unrecoverable Exception: %#lx", Frame->InterruptNumber);
|
||||||
|
#endif
|
||||||
|
|
||||||
UnrecoverableLock.store(false, std::memory_order_release);
|
UnrecoverableLock.store(false, std::memory_order_release);
|
||||||
CPU::Stop();
|
CPU::Stop();
|
||||||
@ -231,6 +235,7 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
|||||||
nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
||||||
{
|
{
|
||||||
ExPrint("\x1b[0m-----------------------------------------------\n");
|
ExPrint("\x1b[0m-----------------------------------------------\n");
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("Exception inside exception: %#lx at %#lx\n",
|
ExPrint("Exception inside exception: %#lx at %#lx\n",
|
||||||
Frame->InterruptNumber,
|
Frame->InterruptNumber,
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
@ -240,6 +245,7 @@ nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
|||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
Frame->pc);
|
Frame->pc);
|
||||||
#endif
|
#endif
|
||||||
|
#endif // __amd64__ || __i386__
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
||||||
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
||||||
@ -286,6 +292,8 @@ nsa void HandleException(CPU::ExceptionFrame *Frame)
|
|||||||
CPU::PageTable(KernelPageTable);
|
CPU::PageTable(KernelPageTable);
|
||||||
InitFont();
|
InitFont();
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
|
|
||||||
/* First check the exception */
|
/* First check the exception */
|
||||||
if (unlikely(Frame->InterruptNumber == CPU::x86::DoubleFault))
|
if (unlikely(Frame->InterruptNumber == CPU::x86::DoubleFault))
|
||||||
{
|
{
|
||||||
@ -343,6 +351,7 @@ nsa void HandleException(CPU::ExceptionFrame *Frame)
|
|||||||
|
|
||||||
ExceptionExit:
|
ExceptionExit:
|
||||||
ExceptionLock.store(false, std::memory_order_release);
|
ExceptionLock.store(false, std::memory_order_release);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa void BaseBufferStackError(bool Stack)
|
nsa void BaseBufferStackError(bool Stack)
|
||||||
|
@ -65,7 +65,9 @@ __no_sanitize("undefined") nsa bool CrashUHCIKeyboardDriver::Initialize()
|
|||||||
/* FIXME: stub */
|
/* FIXME: stub */
|
||||||
|
|
||||||
debug("Initializing controller");
|
debug("Initializing controller");
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
outw((uint16_t)((uintptr_t)io + 0xC0), 0x8F00); /* Disable Legacy Mode Support */
|
outw((uint16_t)((uintptr_t)io + 0xC0), 0x8F00); /* Disable Legacy Mode Support */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Disable All Interrupts */
|
/* Disable All Interrupts */
|
||||||
io->USBINTR.TOCRC = 0;
|
io->USBINTR.TOCRC = 0;
|
||||||
|
@ -137,9 +137,7 @@ nsa const char *ExGetKSymbol(CPU::ExceptionFrame *Frame)
|
|||||||
Frame->eip > (uintptr_t)&_kernel_end)
|
Frame->eip > (uintptr_t)&_kernel_end)
|
||||||
return "<OUTSIDE KERNEL>";
|
return "<OUTSIDE KERNEL>";
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
if (Frame->pc < (uintptr_t)&_kernel_start &&
|
#warning "aarch64 not implemented"
|
||||||
Frame->pc > (uintptr_t)&_kernel_end)
|
|
||||||
return "<OUTSIDE KERNEL>";
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
@ -147,7 +145,8 @@ nsa const char *ExGetKSymbol(CPU::ExceptionFrame *Frame)
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return ExGetKSymbolByAddress(Frame->eip);
|
return ExGetKSymbolByAddress(Frame->eip);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return ExGetKSymbolByAddress(Frame->pc);
|
#warning "aarch64 not implemented"
|
||||||
|
return "stub";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,9 +301,23 @@ nsa void DisplayMainScreen(CPU::ExceptionFrame *Frame)
|
|||||||
x86Exceptions[Frame->InterruptNumber].Name,
|
x86Exceptions[Frame->InterruptNumber].Name,
|
||||||
x86Exceptions[Frame->InterruptNumber].Mnemonic,
|
x86Exceptions[Frame->InterruptNumber].Mnemonic,
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
#error "AA64 not implemented"
|
"stub",
|
||||||
|
"stub",
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
"stub",
|
||||||
|
"stub",
|
||||||
|
#warning "arm not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
Frame->InterruptNumber);
|
Frame->InterruptNumber);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
0);
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
0);
|
||||||
|
#warning "arm not implemented"
|
||||||
|
#endif
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("Cause: %s\n", x86Exceptions[Frame->InterruptNumber].Cause);
|
ExPrint("Cause: %s\n", x86Exceptions[Frame->InterruptNumber].Cause);
|
||||||
#endif
|
#endif
|
||||||
@ -314,8 +327,11 @@ nsa void DisplayMainScreen(CPU::ExceptionFrame *Frame)
|
|||||||
Frame->rip);
|
Frame->rip);
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
Frame->eip);
|
Frame->eip);
|
||||||
|
#elif defined(__arm__)
|
||||||
|
0);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
Frame->pc);
|
0);
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPUData *core = GetCurrentCPU();
|
CPUData *core = GetCurrentCPU();
|
||||||
@ -342,7 +358,7 @@ arch void DisplayDetailsScreen(CPU::ExceptionFrame *Frame);
|
|||||||
nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
||||||
{
|
{
|
||||||
Memory::Virtual vmm;
|
Memory::Virtual vmm;
|
||||||
struct StackFrame *sf;
|
struct StackFrame *sf = nullptr;
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
sf = (struct StackFrame *)Frame->rbp;
|
sf = (struct StackFrame *)Frame->rbp;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
@ -353,6 +369,7 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
|||||||
|
|
||||||
if (!vmm.Check(sf))
|
if (!vmm.Check(sf))
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
void *ptr = ((Memory::PageTable *)Frame->cr3)->Get(sf);
|
void *ptr = ((Memory::PageTable *)Frame->cr3)->Get(sf);
|
||||||
debug("Virtual pointer %#lx -> %#lx", sf, ptr);
|
debug("Virtual pointer %#lx -> %#lx", sf, ptr);
|
||||||
if (vmm.Check(ptr))
|
if (vmm.Check(ptr))
|
||||||
@ -362,17 +379,18 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint("\x1b[31m< No stack trace available. >\x1b[0m\n");
|
ExPrint("\x1b[31m< No stack trace available. >\x1b[0m\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Get symbol offset more efficiently */
|
/* FIXME: Get symbol offset more efficiently */
|
||||||
|
|
||||||
uintptr_t fIP;
|
uintptr_t fIP = 0;
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
fIP = Frame->rip;
|
fIP = Frame->rip;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
fIP = Frame->eip;
|
fIP = Frame->eip;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
fIP = Frame->pc;
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExPrint("%p", (void *)fIP);
|
ExPrint("%p", (void *)fIP);
|
||||||
@ -557,6 +575,7 @@ nsa void DisplayCrashScreen(CPU::ExceptionFrame *Frame)
|
|||||||
DisplayBottomOverlay();
|
DisplayBottomOverlay();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
static int once = 0;
|
static int once = 0;
|
||||||
static uint8_t com4 = 0xFF;
|
static uint8_t com4 = 0xFF;
|
||||||
if (!once++)
|
if (!once++)
|
||||||
@ -657,6 +676,7 @@ nsa void DisplayCrashScreen(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint(keyBuf);
|
ExPrint(keyBuf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif // DEBUG
|
||||||
debug("cpu halted");
|
debug("cpu halted");
|
||||||
CPU::Halt(true);
|
CPU::Halt(true);
|
||||||
}
|
}
|
||||||
@ -965,8 +985,10 @@ nsa void UserInput(char *Input)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else if (strcmp(Input, "pt") == 0)
|
else if (strcmp(Input, "pt") == 0)
|
||||||
{
|
{
|
||||||
/* Helpful for qemu "info tlb" command */
|
/* Helpful for qemu "info tlb" command */
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
CPU::PageTable((void *)ExFrame->cr3);
|
CPU::PageTable((void *)ExFrame->cr3);
|
||||||
|
#endif
|
||||||
ExPrint("Here be dragons\n");
|
ExPrint("Here be dragons\n");
|
||||||
}
|
}
|
||||||
else if (strcmp(Input, "ps") == 0)
|
else if (strcmp(Input, "ps") == 0)
|
||||||
|
@ -86,6 +86,7 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int sigRet = -1;
|
int sigRet = -1;
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
switch (Frame->InterruptNumber)
|
switch (Frame->InterruptNumber)
|
||||||
{
|
{
|
||||||
case CPU::x86::PageFault:
|
case CPU::x86::PageFault:
|
||||||
@ -153,6 +154,7 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sigRet == 0)
|
if (sigRet == 0)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@ namespace Power
|
|||||||
if (((ACPI::DSDT *)this->dsdt)->ACPIShutdownSupported)
|
if (((ACPI::DSDT *)this->dsdt)->ACPIShutdownSupported)
|
||||||
((ACPI::DSDT *)this->dsdt)->Reboot();
|
((ACPI::DSDT *)this->dsdt)->Reboot();
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("cli");
|
asmv("cli");
|
||||||
uint8_t temp;
|
uint8_t temp;
|
||||||
do
|
do
|
||||||
@ -41,6 +42,9 @@ namespace Power
|
|||||||
inb(0x60);
|
inb(0x60);
|
||||||
} while (((temp) & (1 << (1))) != 0);
|
} while (((temp) & (1 << (1))) != 0);
|
||||||
outb(0x64, 0xFE);
|
outb(0x64, 0xFE);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
warn("aarch64 is not supported yet");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Power::Shutdown()
|
void Power::Shutdown()
|
||||||
@ -55,9 +59,11 @@ namespace Power
|
|||||||
}
|
}
|
||||||
/* FIXME: Detect emulators and use their shutdown methods */
|
/* FIXME: Detect emulators and use their shutdown methods */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
outl(0xB004, 0x2000); // for qemu
|
outl(0xB004, 0x2000); // for qemu
|
||||||
outl(0x604, 0x2000); // if qemu not working, bochs and older versions of qemu
|
outl(0x604, 0x2000); // if qemu not working, bochs and older versions of qemu
|
||||||
outl(0x4004, 0x3400); // virtual box
|
outl(0x4004, 0x3400); // virtual box
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,7 @@ EXTERNC __noreturn __no_stack_protector void __stack_chk_fail(void)
|
|||||||
asmv("movl %%esp, %0"
|
asmv("movl %%esp, %0"
|
||||||
: "=r"(Stack));
|
: "=r"(Stack));
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("mov %%sp, %0"
|
#warning "aarch64 not implemented"
|
||||||
: "=r"(Stack));
|
|
||||||
#endif
|
#endif
|
||||||
error("Stack address: %#lx", Stack);
|
error("Stack address: %#lx", Stack);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace SymbolResolver
|
|||||||
#if defined(__amd64__) || defined(__aarch64__)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
Elf64_Xword SymbolSize = 0;
|
Elf64_Xword SymbolSize = 0;
|
||||||
// Elf64_Xword StringSize = 0;
|
// Elf64_Xword StringSize = 0;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
Elf32_Word SymbolSize = 0;
|
Elf32_Word SymbolSize = 0;
|
||||||
// Elf32_Word StringSize = 0;
|
// Elf32_Word StringSize = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -220,7 +220,7 @@ namespace SymbolResolver
|
|||||||
|
|
||||||
#if defined(__amd64__) || defined(__aarch64__)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
||||||
#endif
|
#endif
|
||||||
if (Header->e_ident[0] != 0x7F &&
|
if (Header->e_ident[0] != 0x7F &&
|
||||||
|
@ -36,16 +36,16 @@ public:
|
|||||||
asmv("mov %0, %%cr3"
|
asmv("mov %0, %%cr3"
|
||||||
:
|
:
|
||||||
: "r"(KernelPageTable));
|
: "r"(KernelPageTable));
|
||||||
#endif
|
|
||||||
debug(" + %#lx %s(%d)", Original,
|
debug(" + %#lx %s(%d)", Original,
|
||||||
thisProcess->Name, thisProcess->ID);
|
thisProcess->Name, thisProcess->ID);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoSwitchPageTable()
|
~AutoSwitchPageTable()
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
debug("- %#lx %s(%d)", Original,
|
debug("- %#lx %s(%d)", Original,
|
||||||
thisProcess->Name, thisProcess->ID);
|
thisProcess->Name, thisProcess->ID);
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
asmv("mov %0, %%cr3"
|
asmv("mov %0, %%cr3"
|
||||||
:
|
:
|
||||||
: "r"(Original));
|
: "r"(Original));
|
||||||
|
@ -48,6 +48,8 @@ namespace Time
|
|||||||
return mminq(&hpet->MainCounterValue);
|
return mminq(&hpet->MainCounterValue);
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return mminl(&hpet->MainCounterValue);
|
return mminl(&hpet->MainCounterValue);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +59,8 @@ namespace Time
|
|||||||
return mminq(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
return mminq(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return mminl(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
return mminl(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +73,8 @@ namespace Time
|
|||||||
|
|
||||||
Subtraction *= ConvertUnit(Units::Nanoseconds);
|
Subtraction *= ConvertUnit(Units::Nanoseconds);
|
||||||
return uint64_t(Subtraction / this->clk);
|
return uint64_t(Subtraction / this->clk);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ namespace Time
|
|||||||
while (this->GetCounter() < Target)
|
while (this->GetCounter() < Target)
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
return true;
|
return true;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +42,8 @@ namespace Time
|
|||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
return CPU::Counter();
|
return CPU::Counter();
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +51,8 @@ namespace Time
|
|||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
return uint64_t((this->GetCounter() + (Target * ConvertUnit(Unit))) / this->clk);
|
return uint64_t((this->GetCounter() + (Target * ConvertUnit(Unit))) / this->clk);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +60,8 @@ namespace Time
|
|||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
return uint64_t((this->GetCounter() - this->ClassCreationTime) / this->clk);
|
return uint64_t((this->GetCounter() - this->ClassCreationTime) / this->clk);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ namespace UART
|
|||||||
while ((inb(s_cst(uint16_t, COM1 + 5)) & 1) == 0)
|
while ((inb(s_cst(uint16_t, COM1 + 5)) & 1) == 0)
|
||||||
;
|
;
|
||||||
return inb(COM1);
|
return inb(COM1);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +84,8 @@ namespace UART
|
|||||||
while ((inb(s_cst(uint16_t, COM4 + 5)) & 1) == 0)
|
while ((inb(s_cst(uint16_t, COM4 + 5)) & 1) == 0)
|
||||||
;
|
;
|
||||||
return inb(COM4);
|
return inb(COM4);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +188,8 @@ namespace Execute
|
|||||||
}
|
}
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return 0xdead;
|
return 0xdead;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
return 0xdead;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,11 @@ typedef struct
|
|||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
typedef Elf64_auxv_t Elf_auxv_t;
|
typedef Elf64_auxv_t Elf_auxv_t;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
typedef Elf64_auxv_t Elf_auxv_t;
|
typedef Elf32_auxv_t Elf_auxv_t;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
typedef Elf64_auxv_t Elf_auxv_t;
|
typedef Elf64_auxv_t Elf_auxv_t;
|
||||||
|
#elif defined(__arm__)
|
||||||
|
typedef Elf32_auxv_t Elf_auxv_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -90,8 +90,8 @@ extern "C"
|
|||||||
long unsigned strlen_sse4_1(const char s[]);
|
long unsigned strlen_sse4_1(const char s[]);
|
||||||
long unsigned strlen_sse4_2(const char s[]);
|
long unsigned strlen_sse4_2(const char s[]);
|
||||||
|
|
||||||
long unsigned strlen(const char s[]);
|
size_t strlen(const char s[]);
|
||||||
int strncmp(const char *s1, const char *s2, unsigned long n);
|
int strncmp(const char *s1, const char *s2, size_t n);
|
||||||
char *strcat_unsafe(char *destination, const char *source);
|
char *strcat_unsafe(char *destination, const char *source);
|
||||||
char *strcpy_unsafe(char *destination, const char *source);
|
char *strcpy_unsafe(char *destination, const char *source);
|
||||||
char *strncpy(char *destination, const char *source, unsigned long num);
|
char *strncpy(char *destination, const char *source, unsigned long num);
|
||||||
|
@ -163,8 +163,6 @@ namespace CPU
|
|||||||
"jmp CPUStopLoop");
|
"jmp CPUStopLoop");
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("CPUStopLoop:\n"
|
asmv("CPUStopLoop:\n"
|
||||||
"cpsid i\n"
|
|
||||||
"wfe\n"
|
|
||||||
"wfi\n"
|
"wfi\n"
|
||||||
"b CPUStopLoop");
|
"b CPUStopLoop");
|
||||||
#endif
|
#endif
|
||||||
@ -1074,48 +1072,102 @@ namespace CPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace arm
|
||||||
|
{
|
||||||
|
struct TrapFrame
|
||||||
|
{
|
||||||
|
uint32_t R0; /* Register R0 (argument / scratch) */
|
||||||
|
uint32_t R1; /* Register R1 (argument / scratch) */
|
||||||
|
uint32_t R2; /* Register R2 (argument / scratch) */
|
||||||
|
uint32_t R3; /* Register R3 (argument / scratch) */
|
||||||
|
uint32_t R4; /* Register R4 (callee-saved) */
|
||||||
|
uint32_t R5; /* Register R5 (callee-saved) */
|
||||||
|
uint32_t R6; /* Register R6 (callee-saved) */
|
||||||
|
uint32_t R7; /* Register R7 (callee-saved) */
|
||||||
|
uint32_t R8; /* Register R8 (callee-saved) */
|
||||||
|
uint32_t R9; /* Register R9 (platform-specific) */
|
||||||
|
uint32_t R10; /* Register R10 (callee-saved) */
|
||||||
|
uint32_t FP; /* Frame Pointer (R11) */
|
||||||
|
uint32_t IP; /* Intra-Procedure Scratch (R12) */
|
||||||
|
uint32_t SP; /* Stack Pointer (R13) */
|
||||||
|
uint32_t LR; /* Link Register (R14) */
|
||||||
|
uint32_t PC; /* Program Counter (R15) */
|
||||||
|
uint32_t CPSR; /* Current Program Status Register */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SchedulerFrame
|
||||||
|
{
|
||||||
|
uint32_t R0; /* Register R0 (argument / scratch) */
|
||||||
|
uint32_t R1; /* Register R1 (argument / scratch) */
|
||||||
|
uint32_t R2; /* Register R2 (argument / scratch) */
|
||||||
|
uint32_t R3; /* Register R3 (argument / scratch) */
|
||||||
|
uint32_t R4; /* Register R4 (callee-saved) */
|
||||||
|
uint32_t R5; /* Register R5 (callee-saved) */
|
||||||
|
uint32_t R6; /* Register R6 (callee-saved) */
|
||||||
|
uint32_t R7; /* Register R7 (callee-saved) */
|
||||||
|
uint32_t R8; /* Register R8 (callee-saved) */
|
||||||
|
uint32_t R9; /* Register R9 (platform-specific) */
|
||||||
|
uint32_t R10; /* Register R10 (callee-saved) */
|
||||||
|
uint32_t FP; /* Frame Pointer (R11) */
|
||||||
|
uint32_t IP; /* Intra-Procedure Scratch (R12) */
|
||||||
|
uint32_t SP; /* Stack Pointer (R13) */
|
||||||
|
uint32_t LR; /* Link Register (R14) */
|
||||||
|
uint32_t PC; /* Program Counter (R15) */
|
||||||
|
uint32_t CPSR; /* Current Program Status Register */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ExceptionFrame
|
||||||
|
{
|
||||||
|
uint32_t R0; /* Register R0 (argument / scratch) */
|
||||||
|
uint32_t R1; /* Register R1 (argument / scratch) */
|
||||||
|
uint32_t R2; /* Register R2 (argument / scratch) */
|
||||||
|
uint32_t R3; /* Register R3 (argument / scratch) */
|
||||||
|
uint32_t R4; /* Register R4 (callee-saved) */
|
||||||
|
uint32_t R5; /* Register R5 (callee-saved) */
|
||||||
|
uint32_t R6; /* Register R6 (callee-saved) */
|
||||||
|
uint32_t R7; /* Register R7 (callee-saved) */
|
||||||
|
uint32_t R8; /* Register R8 (callee-saved) */
|
||||||
|
uint32_t R9; /* Register R9 (platform-specific) */
|
||||||
|
uint32_t R10; /* Register R10 (callee-saved) */
|
||||||
|
uint32_t FP; /* Frame Pointer (R11) */
|
||||||
|
uint32_t IP; /* Intra-Procedure Scratch (R12) */
|
||||||
|
uint32_t SP; /* Stack Pointer (R13) */
|
||||||
|
uint32_t LR; /* Link Register (R14) */
|
||||||
|
uint32_t PC; /* Program Counter (R15) */
|
||||||
|
uint32_t CPSR; /* Current Program Status Register */
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace aarch64
|
namespace aarch64
|
||||||
{
|
{
|
||||||
struct TrapFrame
|
struct TrapFrame
|
||||||
{
|
{
|
||||||
uint64_t x0; // General purpose
|
uint64_t x[31];
|
||||||
uint64_t x1; // General purpose
|
uint64_t SP; /* Stack Pointer */
|
||||||
uint64_t x2; // General purpose
|
uint64_t ELR; /* Exception Link Register */
|
||||||
uint64_t x3; // General purpose
|
uint64_t ESR; /* Exception Syndrome Register */
|
||||||
uint64_t x4; // General purpose
|
uint64_t FAR; /* Fault Address Register */
|
||||||
uint64_t x5; // General purpose
|
uint64_t SPSR; /* Saved Program Status Register */
|
||||||
uint64_t x6; // General purpose
|
};
|
||||||
uint64_t x7; // General purpose
|
|
||||||
uint64_t x8; // General purpose
|
|
||||||
uint64_t x9; // General purpose
|
|
||||||
uint64_t x10; // General purpose
|
|
||||||
uint64_t x11; // General purpose
|
|
||||||
uint64_t x12; // General purpose
|
|
||||||
uint64_t x13; // General purpose
|
|
||||||
uint64_t x14; // General purpose
|
|
||||||
uint64_t x15; // General purpose
|
|
||||||
uint64_t x16; // General purpose
|
|
||||||
uint64_t x17; // General purpose
|
|
||||||
uint64_t x18; // General purpose
|
|
||||||
uint64_t x19; // General purpose
|
|
||||||
uint64_t x20; // General purpose
|
|
||||||
uint64_t x21; // General purpose
|
|
||||||
uint64_t x22; // General purpose
|
|
||||||
uint64_t x23; // General purpose
|
|
||||||
uint64_t x24; // General purpose
|
|
||||||
uint64_t x25; // General purpose
|
|
||||||
uint64_t x26; // General purpose
|
|
||||||
uint64_t x27; // General purpose
|
|
||||||
uint64_t x28; // General purpose
|
|
||||||
|
|
||||||
uint64_t fp; // Frame Pointer (meant for stack frames)
|
struct SchedulerFrame
|
||||||
uint64_t lr; // Link Register
|
{
|
||||||
|
uint64_t x[31];
|
||||||
|
uint64_t SP; /* Stack Pointer */
|
||||||
|
uint64_t ELR; /* Exception Link Register */
|
||||||
|
uint64_t ESR; /* Exception Syndrome Register */
|
||||||
|
uint64_t FAR; /* Fault Address Register */
|
||||||
|
uint64_t SPSR; /* Saved Program Status Register */
|
||||||
|
};
|
||||||
|
|
||||||
uint64_t sp; // Stack Pointer
|
struct ExceptionFrame
|
||||||
uint64_t pc; // Program Counter
|
{
|
||||||
uint64_t pstate; // Processor State (flags)
|
uint64_t x[31];
|
||||||
uint64_t esr; // Exception Syndrome Register
|
uint64_t SP; /* Stack Pointer */
|
||||||
uint64_t far; // Fault Address Register
|
uint64_t ELR; /* Exception Link Register */
|
||||||
|
uint64_t ESR; /* Exception Syndrome Register */
|
||||||
|
uint64_t FAR; /* Fault Address Register */
|
||||||
|
uint64_t SPSR; /* Saved Program Status Register */
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,6 +1189,15 @@ namespace CPU
|
|||||||
typedef x32::TrapFrame TrapFrame;
|
typedef x32::TrapFrame TrapFrame;
|
||||||
typedef x32::SchedulerFrame SchedulerFrame;
|
typedef x32::SchedulerFrame SchedulerFrame;
|
||||||
typedef x32::ExceptionFrame ExceptionFrame;
|
typedef x32::ExceptionFrame ExceptionFrame;
|
||||||
|
#elif defined(__arm__)
|
||||||
|
/**
|
||||||
|
* CPU trap frame for the current architecture
|
||||||
|
*
|
||||||
|
* @note This is for arm
|
||||||
|
*/
|
||||||
|
typedef arm::TrapFrame TrapFrame;
|
||||||
|
typedef arm::SchedulerFrame SchedulerFrame;
|
||||||
|
typedef arm::ExceptionFrame ExceptionFrame;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
/**
|
/**
|
||||||
* CPU trap frame for the current architecture
|
* CPU trap frame for the current architecture
|
||||||
@ -1145,7 +1206,7 @@ namespace CPU
|
|||||||
*/
|
*/
|
||||||
typedef aarch64::TrapFrame TrapFrame;
|
typedef aarch64::TrapFrame TrapFrame;
|
||||||
typedef aarch64::SchedulerFrame SchedulerFrame;
|
typedef aarch64::SchedulerFrame SchedulerFrame;
|
||||||
typedef aarch64::TrapFrame ExceptionFrame;
|
typedef aarch64::ExceptionFrame ExceptionFrame;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,13 +55,11 @@ typedef uint64_t cpuid_t;
|
|||||||
#define __amd_cpuid_init(leaf) \
|
#define __amd_cpuid_init(leaf) \
|
||||||
CPUID##leaf() \
|
CPUID##leaf() \
|
||||||
{ \
|
{ \
|
||||||
assert(!"cpuid not implemented for this architecture"); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __amd_cpuid_init2(leaf, leaf2, suffix) \
|
#define __amd_cpuid_init2(leaf, leaf2, suffix) \
|
||||||
CPUID##leaf##suffix() \
|
CPUID##leaf##suffix() \
|
||||||
{ \
|
{ \
|
||||||
assert(!"cpuid not implemented for this architecture"); \
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -55,13 +55,11 @@ typedef uint64_t cpuid_t;
|
|||||||
#define __intel_cpuid_init(leaf) \
|
#define __intel_cpuid_init(leaf) \
|
||||||
CPUID##leaf() \
|
CPUID##leaf() \
|
||||||
{ \
|
{ \
|
||||||
assert(!"cpuid not implemented for this architecture"); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __intel_cpuid_init2(leaf, leaf2, suffix) \
|
#define __intel_cpuid_init2(leaf, leaf2, suffix) \
|
||||||
CPUID##leaf##suffix() \
|
CPUID##leaf##suffix() \
|
||||||
{ \
|
{ \
|
||||||
assert(!"cpuid not implemented for this architecture"); \
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ typedef Elf64_Rel Elf_Rel;
|
|||||||
typedef Elf64_Sym Elf_Sym;
|
typedef Elf64_Sym Elf_Sym;
|
||||||
typedef Elf64_Dyn Elf_Dyn;
|
typedef Elf64_Dyn Elf_Dyn;
|
||||||
typedef Elf64_Rela Elf_Rela;
|
typedef Elf64_Rela Elf_Rela;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
typedef Elf32_Addr Elf_Addr;
|
typedef Elf32_Addr Elf_Addr;
|
||||||
typedef Elf32_Half Elf_Half;
|
typedef Elf32_Half Elf_Half;
|
||||||
typedef Elf32_Off Elf_Off;
|
typedef Elf32_Off Elf_Off;
|
||||||
|
@ -40,6 +40,15 @@ static inline scarg syscall0(scarg syscall)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0");
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(x0)
|
||||||
|
: "r"(x8)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -65,6 +74,15 @@ static inline scarg syscall1(scarg syscall, scarg arg1)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -91,6 +109,16 @@ static inline scarg syscall2(scarg syscall, scarg arg1, scarg arg2)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -118,6 +146,17 @@ static inline scarg syscall3(scarg syscall, scarg arg1, scarg arg2, scarg arg3)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -147,6 +186,18 @@ static inline scarg syscall4(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -178,6 +229,19 @@ static inline scarg syscall5(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
register long x4 __asm__("x4") = arg5;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -211,6 +275,20 @@ static inline scarg syscall6(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
register long x4 __asm__("x4") = arg5;
|
||||||
|
register long x5 __asm__("x5") = arg6;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
#define USER_STACK_END 0xFFFFEFFF00000000 /* 256 MiB */
|
#define USER_STACK_END 0xFFFFEFFF00000000 /* 256 MiB */
|
||||||
#define USER_STACK_BASE 0xFFFFEFFFFFFF0000
|
#define USER_STACK_BASE 0xFFFFEFFFFFFF0000
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
#define KERNEL_VMA_OFFSET 0xC0000000
|
#define KERNEL_VMA_OFFSET 0xC0000000
|
||||||
|
|
||||||
#define USER_ALLOC_BASE 0x80000000
|
#define USER_ALLOC_BASE 0x80000000
|
||||||
|
@ -60,8 +60,21 @@ typedef struct SyscallsFrame
|
|||||||
uint32_t StackPointer;
|
uint32_t StackPointer;
|
||||||
uint32_t StackSegment;
|
uint32_t StackSegment;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
uint32_t ReturnAddress;
|
uint64_t ReturnAddress; /* x0 */
|
||||||
|
uint64_t x[30];
|
||||||
|
uint64_t StackPointer;
|
||||||
|
uint64_t ExceptionLinkRegister;
|
||||||
|
uint64_t ExceptionSyndromeRegister;
|
||||||
|
uint64_t FaultAddressRegister;
|
||||||
|
uint64_t SavedProgramStatusRegister;
|
||||||
|
#elif defined(__arm__)
|
||||||
|
uint32_t ReturnAddress; /* r0 */
|
||||||
|
uint32_t x[14];
|
||||||
uint32_t StackPointer;
|
uint32_t StackPointer;
|
||||||
|
uint32_t ExceptionLinkRegister;
|
||||||
|
uint32_t ExceptionSyndromeRegister;
|
||||||
|
uint32_t FaultAddressRegister;
|
||||||
|
uint32_t SavedProgramStatusRegister;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uintptr_t ReturnValue() const
|
uintptr_t ReturnValue() const
|
||||||
@ -71,7 +84,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return ax;
|
return ax;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x0;
|
return x[0];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +95,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return di;
|
return di;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x0;
|
return x[0];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +106,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return cx;
|
return cx;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x1;
|
return x[1];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +117,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return dx;
|
return dx;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x2;
|
return x[2];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +128,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return si;
|
return si;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x3;
|
return x[3];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +139,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return di;
|
return di;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x4;
|
return x[4];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +150,7 @@ typedef struct SyscallsFrame
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return bp;
|
return bp;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return x5;
|
return x[5];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} SyscallsFrame;
|
} SyscallsFrame;
|
||||||
|
@ -358,12 +358,13 @@ namespace Tasking
|
|||||||
CPU::SchedulerFrame Registers{};
|
CPU::SchedulerFrame Registers{};
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
uintptr_t ShadowGSBase, GSBase, FSBase;
|
uintptr_t ShadowGSBase, GSBase, FSBase;
|
||||||
|
__aligned(16) CPU::x64::FXState FPU;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
uintptr_t ShadowGSBase, GSBase, FSBase;
|
uintptr_t ShadowGSBase, GSBase, FSBase;
|
||||||
#elif defined(__aarch64__)
|
|
||||||
uintptr_t Registers; // TODO
|
|
||||||
#endif
|
|
||||||
__aligned(16) CPU::x64::FXState FPU;
|
__aligned(16) CPU::x64::FXState FPU;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
uintptr_t __todo; // TODO
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Info & Security info */
|
/* Info & Security info */
|
||||||
struct
|
struct
|
||||||
@ -552,6 +553,8 @@ namespace Tasking
|
|||||||
return x64;
|
return x64;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
return x32;
|
return x32;
|
||||||
|
#elif defined(__arm__)
|
||||||
|
return ARM32;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
return ARM64;
|
return ARM64;
|
||||||
#endif
|
#endif
|
||||||
|
@ -171,7 +171,7 @@ typedef uint32_t uid_t;
|
|||||||
typedef uint32_t gid_t;
|
typedef uint32_t gid_t;
|
||||||
typedef int64_t clock_t;
|
typedef int64_t clock_t;
|
||||||
typedef int32_t pid_t;
|
typedef int32_t pid_t;
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
typedef int32_t off_t;
|
typedef int32_t off_t;
|
||||||
typedef long long off64_t;
|
typedef long long off64_t;
|
||||||
typedef uint32_t mode_t;
|
typedef uint32_t mode_t;
|
||||||
|
@ -27,4 +27,12 @@
|
|||||||
#define DBL_MANT_DIG 24
|
#define DBL_MANT_DIG 24
|
||||||
#define DBL_MAX_10_EXP 38
|
#define DBL_MAX_10_EXP 38
|
||||||
#define DBL_MAX 3.4028234663852886e+38
|
#define DBL_MAX 3.4028234663852886e+38
|
||||||
|
#elif __arm__
|
||||||
|
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||||
|
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
|
||||||
|
#define DBL_MAX __DBL_MAX__
|
||||||
|
#elif __aarch64__
|
||||||
|
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||||
|
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
|
||||||
|
#define DBL_MAX __DBL_MAX__
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,14 @@ namespace std
|
|||||||
static_assert(sizeof(uintptr_t) == sizeof(uint32_t));
|
static_assert(sizeof(uintptr_t) == sizeof(uint32_t));
|
||||||
const uint32_t FNV_OFFSET_BASIS = 2166136261u;
|
const uint32_t FNV_OFFSET_BASIS = 2166136261u;
|
||||||
const uint32_t FNV_PRIME = 16777619u;
|
const uint32_t FNV_PRIME = 16777619u;
|
||||||
|
#elif defined(__arm__)
|
||||||
|
static_assert(sizeof(uintptr_t) == sizeof(uint32_t));
|
||||||
|
const uint32_t FNV_OFFSET_BASIS = 2166136261u;
|
||||||
|
const uint32_t FNV_PRIME = 16777619u;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
static_assert(sizeof(uintptr_t) == sizeof(uint64_t));
|
||||||
|
const uint64_t FNV_OFFSET_BASIS = 14695981039346656037ull;
|
||||||
|
const uint64_t FNV_PRIME = 1099511628211ull;
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,13 +79,13 @@ namespace std
|
|||||||
|
|
||||||
[[nodiscard]] void *operator new(std::size_t count);
|
[[nodiscard]] void *operator new(std::size_t count);
|
||||||
[[nodiscard]] void *operator new[](std::size_t count);
|
[[nodiscard]] void *operator new[](std::size_t count);
|
||||||
// [[nodiscard]] void *operator new(std::size_t count, std::align_val_t al);
|
[[nodiscard]] void *operator new(std::size_t count, std::align_val_t al);
|
||||||
// [[nodiscard]] void *operator new[](std::size_t count, std::align_val_t al);
|
[[nodiscard]] void *operator new[](std::size_t count, std::align_val_t al);
|
||||||
|
|
||||||
// [[nodiscard]] void *operator new(std::size_t count, const std::nothrow_t &tag) noexcept;
|
[[nodiscard]] void *operator new(std::size_t count, const std::nothrow_t &tag) noexcept;
|
||||||
// [[nodiscard]] void *operator new[](std::size_t count, const std::nothrow_t &tag) noexcept;
|
[[nodiscard]] void *operator new[](std::size_t count, const std::nothrow_t &tag) noexcept;
|
||||||
// [[nodiscard]] void *operator new(std::size_t count, std::align_val_t al, const std::nothrow_t &) noexcept;
|
[[nodiscard]] void *operator new(std::size_t count, std::align_val_t al, const std::nothrow_t &) noexcept;
|
||||||
// [[nodiscard]] void *operator new[](std::size_t count, std::align_val_t al, const std::nothrow_t &) noexcept;
|
[[nodiscard]] void *operator new[](std::size_t count, std::align_val_t al, const std::nothrow_t &) noexcept;
|
||||||
|
|
||||||
[[nodiscard]] void *operator new(std::size_t count, void *ptr) noexcept;
|
[[nodiscard]] void *operator new(std::size_t count, void *ptr) noexcept;
|
||||||
[[nodiscard]] void *operator new[](std::size_t count, void *ptr) noexcept;
|
[[nodiscard]] void *operator new[](std::size_t count, void *ptr) noexcept;
|
||||||
|
@ -25,6 +25,10 @@ using namespace vfs;
|
|||||||
|
|
||||||
nsa void cmd_panic(const char *)
|
nsa void cmd_panic(const char *)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("int $0x0");
|
asmv("int $0x0");
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
asmv("brk #0");
|
||||||
|
#endif
|
||||||
__unreachable;
|
__unreachable;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ EXTERNC int strncmp(const char *s1, const char *s2, size_t n)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTERNC long unsigned strlen(const char s[])
|
EXTERNC size_t strlen(const char s[])
|
||||||
{
|
{
|
||||||
if (Config.SIMD)
|
if (Config.SIMD)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,9 @@ extern "C" __noreturn void __cxa_throw(void *thrown_object,
|
|||||||
Exception->terminateHandler = &terminate_header_stub;
|
Exception->terminateHandler = &terminate_header_stub;
|
||||||
Exception->unwindHeader.exception_cleanup = &exception_cleanup_stub;
|
Exception->unwindHeader.exception_cleanup = &exception_cleanup_stub;
|
||||||
INIT_EXCEPTION_CLASS(&Exception->unwindHeader.exception_class);
|
INIT_EXCEPTION_CLASS(&Exception->unwindHeader.exception_class);
|
||||||
|
#ifndef __arm__
|
||||||
Exception->adjustedPtr = thrown_object;
|
Exception->adjustedPtr = thrown_object;
|
||||||
|
#endif
|
||||||
|
|
||||||
_Unwind_RaiseException(&Exception->unwindHeader);
|
_Unwind_RaiseException(&Exception->unwindHeader);
|
||||||
__cxa_begin_catch(&Exception->unwindHeader);
|
__cxa_begin_catch(&Exception->unwindHeader);
|
||||||
|
@ -134,7 +134,7 @@ void md5Finalize(MD5Context *ctx)
|
|||||||
(uint32_t)(ctx->input[(j * 4)]);
|
(uint32_t)(ctx->input[(j * 4)]);
|
||||||
}
|
}
|
||||||
input[14] = (uint32_t)(ctx->size * 8);
|
input[14] = (uint32_t)(ctx->size * 8);
|
||||||
#ifdef __i386__
|
#if defined(__i386__) || defined(__arm__)
|
||||||
input[15] = (uint32_t)((uint64_t)(((uint64_t)ctx->size >> 32) | ((uint64_t)ctx->size << 32)) >> 32);
|
input[15] = (uint32_t)((uint64_t)(((uint64_t)ctx->size >> 32) | ((uint64_t)ctx->size << 32)) >> 32);
|
||||||
#else
|
#else
|
||||||
input[15] = (uint32_t)((ctx->size * 8) >> 32);
|
input[15] = (uint32_t)((ctx->size * 8) >> 32);
|
||||||
|
@ -42,10 +42,12 @@ EXTERNC void *memset_sse2(void *dest, int c, size_t n)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (((size_t)dest + i) & (16 - 1) && i < n)
|
while (((size_t)dest + i) & (16 - 1) && i < n)
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("stosb\n"
|
asmv("stosb\n"
|
||||||
:
|
:
|
||||||
: "D"((size_t)dest + i),
|
: "D"((size_t)dest + i),
|
||||||
"a"(c));
|
"a"(c));
|
||||||
|
#endif
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,9 +70,11 @@ EXTERNC void *memset_sse2(void *dest, int c, size_t n)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("rep stosb\n" ::"a"((size_t)(c)),
|
asmv("rep stosb\n" ::"a"((size_t)(c)),
|
||||||
"D"(((size_t)dest) + i),
|
"D"(((size_t)dest) + i),
|
||||||
"c"(n - i));
|
"c"(n - i));
|
||||||
|
#endif
|
||||||
|
|
||||||
i += n - i;
|
i += n - i;
|
||||||
return (void *)(((size_t)dest) + i);
|
return (void *)(((size_t)dest) + i);
|
||||||
|
@ -31,6 +31,7 @@ long unsigned __strlen(const char s[])
|
|||||||
{
|
{
|
||||||
size_t ret = (size_t)s;
|
size_t ret = (size_t)s;
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("._strlenLoop:"
|
asmv("._strlenLoop:"
|
||||||
"cmpb $0, 0(%1)\n"
|
"cmpb $0, 0(%1)\n"
|
||||||
"jz ._strlenExit\n"
|
"jz ._strlenExit\n"
|
||||||
@ -76,6 +77,7 @@ long unsigned __strlen(const char s[])
|
|||||||
"._strlenExit:"
|
"._strlenExit:"
|
||||||
"mov %1, %0\n"
|
"mov %1, %0\n"
|
||||||
: "=r"(ret) : "0"(ret));
|
: "=r"(ret) : "0"(ret));
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret - (size_t)s;
|
return ret - (size_t)s;
|
||||||
}
|
}
|
||||||
@ -107,7 +109,8 @@ long unsigned strlen_sse4_1(const char s[])
|
|||||||
|
|
||||||
long unsigned strlen_sse4_2(const char s[])
|
long unsigned strlen_sse4_2(const char s[])
|
||||||
{
|
{
|
||||||
size_t ret;
|
size_t ret = 0;
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov $-16, %0\n"
|
asmv("mov $-16, %0\n"
|
||||||
"pxor %%xmm0, %%xmm0\n"
|
"pxor %%xmm0, %%xmm0\n"
|
||||||
".strlen42Loop:"
|
".strlen42Loop:"
|
||||||
@ -117,6 +120,6 @@ long unsigned strlen_sse4_2(const char s[])
|
|||||||
"add %2, %0\n"
|
"add %2, %0\n"
|
||||||
: "=a"(ret)
|
: "=a"(ret)
|
||||||
: "d"((size_t)s), "c"((size_t)s));
|
: "d"((size_t)s), "c"((size_t)s));
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,37 @@ void *operator new[](std::size_t count)
|
|||||||
throw std::bad_alloc{};
|
throw std::bad_alloc{};
|
||||||
}
|
}
|
||||||
|
|
||||||
// void *operator new(std::size_t count, std::align_val_t al)
|
void *operator new(std::size_t count, std::align_val_t al)
|
||||||
// void *operator new[](std::size_t count, std::align_val_t al)
|
{
|
||||||
|
if (count == 0)
|
||||||
|
++count;
|
||||||
|
|
||||||
|
std::size_t alignment = static_cast<std::size_t>(al);
|
||||||
|
void *ptr = kmalloc(count + alignment - 1 + sizeof(void *));
|
||||||
|
if (!ptr)
|
||||||
|
throw std::bad_alloc{};
|
||||||
|
|
||||||
|
void *aligned_ptr = reinterpret_cast<void *>(
|
||||||
|
(reinterpret_cast<std::size_t>(ptr) + sizeof(void *) + alignment - 1) & ~(alignment - 1));
|
||||||
|
reinterpret_cast<void **>(aligned_ptr)[-1] = ptr;
|
||||||
|
return aligned_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *operator new[](std::size_t count, std::align_val_t al)
|
||||||
|
{
|
||||||
|
if (count == 0)
|
||||||
|
++count;
|
||||||
|
|
||||||
|
std::size_t alignment = static_cast<std::size_t>(al);
|
||||||
|
void *ptr = kmalloc(count + alignment - 1 + sizeof(void *));
|
||||||
|
if (!ptr)
|
||||||
|
throw std::bad_alloc{};
|
||||||
|
|
||||||
|
void *aligned_ptr = reinterpret_cast<void *>(
|
||||||
|
(reinterpret_cast<std::size_t>(ptr) + sizeof(void *) + alignment - 1) & ~(alignment - 1));
|
||||||
|
reinterpret_cast<void **>(aligned_ptr)[-1] = ptr;
|
||||||
|
return aligned_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
// void *operator new(std::size_t count, const std::nothrow_t &tag)
|
// void *operator new(std::size_t count, const std::nothrow_t &tag)
|
||||||
// void *operator new[](std::size_t count, const std::nothrow_t &tag)
|
// void *operator new[](std::size_t count, const std::nothrow_t &tag)
|
||||||
@ -62,8 +91,24 @@ void operator delete(void *ptr) noexcept { kfree(ptr); }
|
|||||||
|
|
||||||
void operator delete[](void *ptr) noexcept { kfree(ptr); }
|
void operator delete[](void *ptr) noexcept { kfree(ptr); }
|
||||||
|
|
||||||
// void operator delete(void *ptr, std::align_val_t al) noexcept
|
void operator delete(void *ptr, std::align_val_t al) noexcept
|
||||||
// void operator delete[](void *ptr, std::align_val_t al) noexcept
|
{
|
||||||
|
if (!ptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
void *original_ptr = reinterpret_cast<void **>(ptr)[-1];
|
||||||
|
kfree(original_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete[](void *ptr, std::align_val_t al) noexcept
|
||||||
|
{
|
||||||
|
if (!ptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
void *original_ptr = reinterpret_cast<void **>(ptr)[-1];
|
||||||
|
kfree(original_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
void operator delete(void *ptr, std::size_t) noexcept { kfree(ptr); }
|
void operator delete(void *ptr, std::size_t) noexcept { kfree(ptr); }
|
||||||
|
|
||||||
void operator delete[](void *ptr, std::size_t sz) noexcept { kfree(ptr); }
|
void operator delete[](void *ptr, std::size_t sz) noexcept { kfree(ptr); }
|
||||||
|
@ -314,6 +314,44 @@ struct linux_kstat
|
|||||||
unsigned long st_ctime_nsec;
|
unsigned long st_ctime_nsec;
|
||||||
unsigned long __unused4;
|
unsigned long __unused4;
|
||||||
unsigned long __unused5;
|
unsigned long __unused5;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
__kernel_ulong_t st_dev;
|
||||||
|
__kernel_ulong_t st_ino;
|
||||||
|
__kernel_ulong_t st_nlink;
|
||||||
|
unsigned int st_mode;
|
||||||
|
unsigned int st_uid;
|
||||||
|
unsigned int st_gid;
|
||||||
|
unsigned int __pad0;
|
||||||
|
__kernel_ulong_t st_rdev;
|
||||||
|
__kernel_long_t st_size;
|
||||||
|
__kernel_long_t st_blksize;
|
||||||
|
__kernel_long_t st_blocks;
|
||||||
|
__kernel_ulong_t st_atime;
|
||||||
|
__kernel_ulong_t st_atime_nsec;
|
||||||
|
__kernel_ulong_t st_mtime;
|
||||||
|
__kernel_ulong_t st_mtime_nsec;
|
||||||
|
__kernel_ulong_t st_ctime;
|
||||||
|
__kernel_ulong_t st_ctime_nsec;
|
||||||
|
#undef __unused
|
||||||
|
__kernel_long_t __unused[3];
|
||||||
|
#elif defined(__arm__)
|
||||||
|
__kernel_ulong_t st_dev;
|
||||||
|
__kernel_ulong_t st_ino;
|
||||||
|
__kernel_ulong_t st_nlink;
|
||||||
|
unsigned int st_mode;
|
||||||
|
unsigned int st_uid;
|
||||||
|
unsigned int st_gid;
|
||||||
|
unsigned int __pad0;
|
||||||
|
__kernel_ulong_t st_rdev;
|
||||||
|
__kernel_long_t st_size;
|
||||||
|
__kernel_long_t st_blksize;
|
||||||
|
__kernel_long_t st_blocks;
|
||||||
|
__kernel_ulong_t st_atime;
|
||||||
|
__kernel_ulong_t st_atime_nsec;
|
||||||
|
__kernel_ulong_t st_mtime;
|
||||||
|
__kernel_ulong_t st_mtime_nsec;
|
||||||
|
__kernel_ulong_t st_ctime;
|
||||||
|
__kernel_ulong_t st_ctime_nsec;
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -351,7 +389,7 @@ struct __old_kernel_stat
|
|||||||
unsigned short st_uid;
|
unsigned short st_uid;
|
||||||
unsigned short st_gid;
|
unsigned short st_gid;
|
||||||
unsigned short st_rdev;
|
unsigned short st_rdev;
|
||||||
#ifdef __i386__
|
#if defined(__i386__) || defined(__arm__)
|
||||||
unsigned long st_size;
|
unsigned long st_size;
|
||||||
unsigned long st_atime;
|
unsigned long st_atime;
|
||||||
unsigned long st_mtime;
|
unsigned long st_mtime;
|
||||||
|
@ -1077,6 +1077,7 @@ static int linux_mprotect(SysFrm *, void *addr, size_t len, int prot)
|
|||||||
return -linux_ENOMEM;
|
return -linux_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (!pte->Present ||
|
if (!pte->Present ||
|
||||||
(!pte->UserSupervisor && p_Read) ||
|
(!pte->UserSupervisor && p_Read) ||
|
||||||
(!pte->ReadWrite && p_Write))
|
(!pte->ReadWrite && p_Write))
|
||||||
@ -1089,7 +1090,8 @@ static int linux_mprotect(SysFrm *, void *addr, size_t len, int prot)
|
|||||||
// pte->Present = !p_None;
|
// pte->Present = !p_None;
|
||||||
pte->UserSupervisor = p_Read;
|
pte->UserSupervisor = p_Read;
|
||||||
pte->ReadWrite = p_Write;
|
pte->ReadWrite = p_Write;
|
||||||
// pte->ExecuteDisable = p_Exec;
|
// pte->ExecuteDisable = p_Exec;
|
||||||
|
#endif
|
||||||
|
|
||||||
debug("Changed permissions of page %#lx to %s %s %s %s",
|
debug("Changed permissions of page %#lx to %s %s %s %s",
|
||||||
(void *)i,
|
(void *)i,
|
||||||
@ -1484,7 +1486,9 @@ static pid_t linux_fork(SysFrm *sf)
|
|||||||
|
|
||||||
TaskManager->UpdateFrame();
|
TaskManager->UpdateFrame();
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
NewThread->FPU = Thread->FPU;
|
NewThread->FPU = Thread->FPU;
|
||||||
|
#endif
|
||||||
NewThread->Stack->Fork(Thread->Stack);
|
NewThread->Stack->Fork(Thread->Stack);
|
||||||
NewThread->Info.Architecture = Thread->Info.Architecture;
|
NewThread->Info.Architecture = Thread->Info.Architecture;
|
||||||
NewThread->Info.Compatibility = Thread->Info.Compatibility;
|
NewThread->Info.Compatibility = Thread->Info.Compatibility;
|
||||||
@ -1564,7 +1568,9 @@ static pid_t linux_vfork(SysFrm *sf)
|
|||||||
|
|
||||||
TaskManager->UpdateFrame();
|
TaskManager->UpdateFrame();
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
NewThread->FPU = Thread->FPU;
|
NewThread->FPU = Thread->FPU;
|
||||||
|
#endif
|
||||||
delete NewThread->Stack;
|
delete NewThread->Stack;
|
||||||
NewThread->Stack = Thread->Stack;
|
NewThread->Stack = Thread->Stack;
|
||||||
NewThread->Info.Architecture = Thread->Info.Architecture;
|
NewThread->Info.Architecture = Thread->Info.Architecture;
|
||||||
|
@ -103,7 +103,11 @@
|
|||||||
#define wut_schedbg(m, ...)
|
#define wut_schedbg(m, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__naked __used nsa void __custom_sched_idle_loop()
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
|
__naked
|
||||||
|
#endif
|
||||||
|
__used nsa void
|
||||||
|
__custom_sched_idle_loop()
|
||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("IdleLoop:");
|
asmv("IdleLoop:");
|
||||||
@ -668,10 +672,12 @@ namespace Tasking::Scheduler
|
|||||||
CurrentCPU->CurrentProcess->State.store(TaskState::Running);
|
CurrentCPU->CurrentProcess->State.store(TaskState::Running);
|
||||||
CurrentCPU->CurrentThread->State.store(TaskState::Running);
|
CurrentCPU->CurrentThread->State.store(TaskState::Running);
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (CurrentCPU->CurrentThread->Registers.cs != GDT_KERNEL_CODE)
|
if (CurrentCPU->CurrentThread->Registers.cs != GDT_KERNEL_CODE)
|
||||||
CurrentCPU->CurrentThread->Registers.ppt = (uint64_t)(void *)CurrentCPU->CurrentProcess->PageTable;
|
CurrentCPU->CurrentThread->Registers.ppt = (uint64_t)(void *)CurrentCPU->CurrentProcess->PageTable;
|
||||||
else
|
else
|
||||||
CurrentCPU->CurrentThread->Registers.ppt = (uint64_t)(void *)KernelPageTable;
|
CurrentCPU->CurrentThread->Registers.ppt = (uint64_t)(void *)KernelPageTable;
|
||||||
|
#endif
|
||||||
|
|
||||||
// if (!SchedulerUpdateTrapFrame) {} // TODO
|
// if (!SchedulerUpdateTrapFrame) {} // TODO
|
||||||
|
|
||||||
@ -701,12 +707,14 @@ namespace Tasking::Scheduler
|
|||||||
CurrentCPU->CurrentThread->Registers.rip,
|
CurrentCPU->CurrentThread->Registers.rip,
|
||||||
CurrentCPU->CurrentThread->Registers.rbp,
|
CurrentCPU->CurrentThread->Registers.rbp,
|
||||||
CurrentCPU->CurrentThread->Registers.rsp);
|
CurrentCPU->CurrentThread->Registers.rsp);
|
||||||
#else
|
#elif defined(__i386__)
|
||||||
trace("%s[%ld]: EIP=%#lx EBP=%#lx ESP=%#lx",
|
trace("%s[%ld]: EIP=%#lx EBP=%#lx ESP=%#lx",
|
||||||
CurrentCPU->CurrentThread->Name, CurrentCPU->CurrentThread->ID,
|
CurrentCPU->CurrentThread->Name, CurrentCPU->CurrentThread->ID,
|
||||||
CurrentCPU->CurrentThread->Registers.eip,
|
CurrentCPU->CurrentThread->Registers.eip,
|
||||||
CurrentCPU->CurrentThread->Registers.ebp,
|
CurrentCPU->CurrentThread->Registers.ebp,
|
||||||
CurrentCPU->CurrentThread->Registers.esp);
|
CurrentCPU->CurrentThread->Registers.esp);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#warning "aarch64 not implemented yet"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ namespace Tasking
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
this->Registers.esp = StackPointerReg;
|
this->Registers.esp = StackPointerReg;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
this->Registers.sp = StackPointerReg;
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argvLen > 0)
|
if (argvLen > 0)
|
||||||
@ -349,10 +349,7 @@ namespace Tasking
|
|||||||
this->Registers.ecx = (uintptr_t)envpLen; // envc
|
this->Registers.ecx = (uintptr_t)envpLen; // envc
|
||||||
this->Registers.edx = (uintptr_t)(this->Registers.esp + 4 + (4 * argvLen) + 4); // envp
|
this->Registers.edx = (uintptr_t)(this->Registers.esp + 4 + (4 * argvLen) + 4); // envp
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
this->Registers.x0 = (uintptr_t)argvLen; // argc
|
#warning "aarch64 not implemented"
|
||||||
this->Registers.x1 = (uintptr_t)(this->Registers.sp + 8); // argv
|
|
||||||
this->Registers.x2 = (uintptr_t)envpLen; // envc
|
|
||||||
this->Registers.x3 = (uintptr_t)(this->Registers.sp + 8 + (8 * argvLen) + 8); // envp
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,8 +407,10 @@ namespace Tasking
|
|||||||
uintptr_t *pTLSPointer = (uintptr_t *)this->TLS.pBase + this->TLS.Size;
|
uintptr_t *pTLSPointer = (uintptr_t *)this->TLS.pBase + this->TLS.Size;
|
||||||
*pTLSPointer = this->TLS.pBase + this->TLS.Size;
|
*pTLSPointer = this->TLS.pBase + this->TLS.Size;
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
this->GSBase = r_cst(uintptr_t, pTLSPointer);
|
this->GSBase = r_cst(uintptr_t, pTLSPointer);
|
||||||
this->FSBase = r_cst(uintptr_t, pTLSPointer);
|
this->FSBase = r_cst(uintptr_t, pTLSPointer);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TCB::TCB(Task *ctx, PCB *Parent, IP EntryPoint,
|
TCB::TCB(Task *ctx, PCB *Parent, IP EntryPoint,
|
||||||
@ -470,7 +469,7 @@ namespace Tasking
|
|||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
this->Registers.eip = EntryPoint;
|
this->Registers.eip = EntryPoint;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
this->Registers.pc = EntryPoint;
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (this->Parent->Security.ExecutionMode)
|
switch (this->Parent->Security.ExecutionMode)
|
||||||
@ -506,9 +505,7 @@ namespace Tasking
|
|||||||
this->Registers.esp = ((uintptr_t)this->Stack->GetStackTop());
|
this->Registers.esp = ((uintptr_t)this->Stack->GetStackTop());
|
||||||
POKE(uintptr_t, this->Registers.esp) = (uintptr_t)ThreadDoExit;
|
POKE(uintptr_t, this->Registers.esp) = (uintptr_t)ThreadDoExit;
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
this->Registers.pc = EntryPoint;
|
#warning "aarch64 not implemented"
|
||||||
this->Registers.sp = ((uintptr_t)this->Stack->GetStackTop());
|
|
||||||
POKE(uintptr_t, this->Registers.sp) = (uintptr_t)ThreadDoExit;
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -612,10 +609,12 @@ namespace Tasking
|
|||||||
this->Parent->Info.RootNode = this->Info.RootNode;
|
this->Parent->Info.RootNode = this->Info.RootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Is really a good idea to use the FPU in kernel mode?
|
// TODO: Is really a good idea to use the FPU in kernel mode?
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
this->FPU.mxcsr = 0b0001111110000000;
|
this->FPU.mxcsr = 0b0001111110000000;
|
||||||
this->FPU.mxcsrmask = 0b1111111110111111;
|
this->FPU.mxcsrmask = 0b1111111110111111;
|
||||||
this->FPU.fcw = 0b0000001100111111;
|
this->FPU.fcw = 0b0000001100111111;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#ifdef __amd64__
|
#ifdef __amd64__
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
__constructor void TestRandom()
|
__constructor void TestRandom()
|
||||||
{
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
int RDRANDFlag = 0;
|
int RDRANDFlag = 0;
|
||||||
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
|
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
|
||||||
{
|
{
|
||||||
@ -38,7 +39,6 @@ __constructor void TestRandom()
|
|||||||
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) == 0)
|
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) == 0)
|
||||||
RDRANDFlag = 0;
|
RDRANDFlag = 0;
|
||||||
|
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
if (RDRANDFlag)
|
if (RDRANDFlag)
|
||||||
{
|
{
|
||||||
uintptr_t RDSEEDValue = 0;
|
uintptr_t RDSEEDValue = 0;
|
||||||
@ -46,7 +46,6 @@ __constructor void TestRandom()
|
|||||||
: "=r"(RDSEEDValue));
|
: "=r"(RDSEEDValue));
|
||||||
debug("RDSEED: %ld", RDSEEDValue);
|
debug("RDSEED: %ld", RDSEEDValue);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
Random::ChangeSeed(0xdeadbeef);
|
Random::ChangeSeed(0xdeadbeef);
|
||||||
uint16_t Seeds16[16];
|
uint16_t Seeds16[16];
|
||||||
@ -61,6 +60,7 @@ __constructor void TestRandom()
|
|||||||
debug("Random 16: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds16[0], Seeds16[1], Seeds16[2], Seeds16[3], Seeds16[4], Seeds16[5], Seeds16[6], Seeds16[7], Seeds16[8], Seeds16[9], Seeds16[10], Seeds16[11], Seeds16[12], Seeds16[13], Seeds16[14], Seeds16[15]);
|
debug("Random 16: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds16[0], Seeds16[1], Seeds16[2], Seeds16[3], Seeds16[4], Seeds16[5], Seeds16[6], Seeds16[7], Seeds16[8], Seeds16[9], Seeds16[10], Seeds16[11], Seeds16[12], Seeds16[13], Seeds16[14], Seeds16[15]);
|
||||||
debug("Random 32: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds32[0], Seeds32[1], Seeds32[2], Seeds32[3], Seeds32[4], Seeds32[5], Seeds32[6], Seeds32[7], Seeds32[8], Seeds32[9], Seeds32[10], Seeds32[11], Seeds32[12], Seeds32[13], Seeds32[14], Seeds32[15]);
|
debug("Random 32: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds32[0], Seeds32[1], Seeds32[2], Seeds32[3], Seeds32[4], Seeds32[5], Seeds32[6], Seeds32[7], Seeds32[8], Seeds32[9], Seeds32[10], Seeds32[11], Seeds32[12], Seeds32[13], Seeds32[14], Seeds32[15]);
|
||||||
debug("Random 64: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds64[0], Seeds64[1], Seeds64[2], Seeds64[3], Seeds64[4], Seeds64[5], Seeds64[6], Seeds64[7], Seeds64[8], Seeds64[9], Seeds64[10], Seeds64[11], Seeds64[12], Seeds64[13], Seeds64[14], Seeds64[15]);
|
debug("Random 64: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds64[0], Seeds64[1], Seeds64[2], Seeds64[3], Seeds64[4], Seeds64[5], Seeds64[6], Seeds64[7], Seeds64[8], Seeds64[9], Seeds64[10], Seeds64[11], Seeds64[12], Seeds64[13], Seeds64[14], Seeds64[15]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
@ -146,6 +146,8 @@ void TaskMgr()
|
|||||||
Statuses[State], Proc->Name, StatusesSign[State],
|
Statuses[State], Proc->Name, StatusesSign[State],
|
||||||
ProcessCpuUsage, Proc->Info.KernelTime, Proc->Info.UserTime);
|
ProcessCpuUsage, Proc->Info.KernelTime, Proc->Info.UserTime);
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
|
UNUSED(State);
|
||||||
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (auto Thd in Proc->Threads)
|
foreach (auto Thd in Proc->Threads)
|
||||||
|
@ -454,6 +454,7 @@ namespace KernelConsole
|
|||||||
void VirtualTerminal::Process(char c)
|
void VirtualTerminal::Process(char c)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
static int once = 0;
|
static int once = 0;
|
||||||
static uint8_t com4 = 0xFF;
|
static uint8_t com4 = 0xFF;
|
||||||
if (!once++)
|
if (!once++)
|
||||||
@ -476,12 +477,13 @@ namespace KernelConsole
|
|||||||
outb(0x2E8, c);
|
outb(0x2E8, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// while (true)
|
// while (true)
|
||||||
// {
|
// {
|
||||||
// while ((inb(0x2E8 + 5) & 1) == 0)
|
// while ((inb(0x2E8 + 5) & 1) == 0)
|
||||||
// ;
|
// ;
|
||||||
// outb(0x2E8, inb(0x2E8));
|
// outb(0x2E8, inb(0x2E8));
|
||||||
// }
|
// }
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ANSIParser *parser = &this->Parser;
|
ANSIParser *parser = &this->Parser;
|
||||||
|
@ -96,6 +96,7 @@ bool IsVMwareBackdoorAvailable()
|
|||||||
cmd.magic = VMWARE_MAGIC;
|
cmd.magic = VMWARE_MAGIC;
|
||||||
cmd.port = VMWARE_PORT;
|
cmd.port = VMWARE_PORT;
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("in %%dx, %0"
|
asmv("in %%dx, %0"
|
||||||
: "+a"(cmd.ax),
|
: "+a"(cmd.ax),
|
||||||
"+b"(cmd.bx),
|
"+b"(cmd.bx),
|
||||||
@ -103,6 +104,7 @@ bool IsVMwareBackdoorAvailable()
|
|||||||
"+d"(cmd.dx),
|
"+d"(cmd.dx),
|
||||||
"+S"(cmd.si),
|
"+S"(cmd.si),
|
||||||
"+D"(cmd.di));
|
"+D"(cmd.di));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cmd.bx != VMWARE_MAGIC || cmd.ax == 0xFFFFFFFF)
|
if (cmd.bx != VMWARE_MAGIC || cmd.ax == 0xFFFFFFFF)
|
||||||
return false;
|
return false;
|
||||||
|
21
Makefile
21
Makefile
@ -66,6 +66,15 @@ QEMUFLAGS += -M q35 \
|
|||||||
-device intel-hda \
|
-device intel-hda \
|
||||||
-device ich9-intel-hda \
|
-device ich9-intel-hda \
|
||||||
-acpitable file=tools/acpi/SSDT1.dat
|
-acpitable file=tools/acpi/SSDT1.dat
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
QEMUFLAGS += -M raspi2b \
|
||||||
|
-monitor pty \
|
||||||
|
-cpu cortex-a15 \
|
||||||
|
-serial file:serial.log \
|
||||||
|
-serial file:COM2.dmp \
|
||||||
|
-serial file:COM3.dmp \
|
||||||
|
-serial stdio \
|
||||||
|
-kernel $(OSNAME).img
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
QEMUFLAGS += -M raspi3b \
|
QEMUFLAGS += -M raspi3b \
|
||||||
-monitor pty \
|
-monitor pty \
|
||||||
@ -74,8 +83,7 @@ QEMUFLAGS += -M raspi3b \
|
|||||||
-serial file:COM2.dmp \
|
-serial file:COM2.dmp \
|
||||||
-serial file:COM3.dmp \
|
-serial file:COM3.dmp \
|
||||||
-serial stdio \
|
-serial stdio \
|
||||||
-kernel $(OSNAME).img \
|
-kernel $(OSNAME).img
|
||||||
-acpitable file=tools/acpi/SSDT1.dat
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
doxygen:
|
doxygen:
|
||||||
@ -161,7 +169,7 @@ ifeq ($(BOOTLOADER), grub)
|
|||||||
cp tools/grub.cfg iso_tmp_data/boot/grub/
|
cp tools/grub.cfg iso_tmp_data/boot/grub/
|
||||||
grub-mkrescue -o $(OSNAME).iso iso_tmp_data
|
grub-mkrescue -o $(OSNAME).iso iso_tmp_data
|
||||||
endif
|
endif
|
||||||
ifeq ($(OSARCH), aarch64)
|
ifneq ($(filter aarch64 arm,$(OSARCH)),)
|
||||||
$(__CONF_OBJCOPY) Kernel/fennix.elf -O binary $(OSNAME).img
|
$(__CONF_OBJCOPY) Kernel/fennix.elf -O binary $(OSNAME).img
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -180,6 +188,10 @@ ifeq ($(OSARCH), i386)
|
|||||||
QEMU_SMP = -smp $(shell nproc)
|
QEMU_SMP = -smp $(shell nproc)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OSARCH), arm)
|
||||||
|
QEMU_SMP = -smp 4
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(OSARCH), aarch64)
|
ifeq ($(OSARCH), aarch64)
|
||||||
QEMU_SMP = -smp 4
|
QEMU_SMP = -smp 4
|
||||||
endif
|
endif
|
||||||
@ -190,6 +202,9 @@ QEMUMEMORY = -m 4G
|
|||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
QEMUHWACCELERATION = -machine q35 -enable-kvm
|
QEMUHWACCELERATION = -machine q35 -enable-kvm
|
||||||
QEMUMEMORY = -m 4G
|
QEMUMEMORY = -m 4G
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
QEMUHWACCELERATION =
|
||||||
|
QEMUMEMORY = -m 1G
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
QEMUHWACCELERATION =
|
QEMUHWACCELERATION =
|
||||||
QEMUMEMORY = -m 1G
|
QEMUMEMORY = -m 1G
|
||||||
|
42
Userspace/.vscode/c_cpp_properties.json
vendored
42
Userspace/.vscode/c_cpp_properties.json
vendored
@ -81,6 +81,48 @@
|
|||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdinc++"
|
"-nostdinc++"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fennix Arm (Linux, GCC, debug)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/libc/include/**",
|
||||||
|
"${workspaceFolder}/libs/include/**"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"__debug_vscode__",
|
||||||
|
"DEBUG=\"1\""
|
||||||
|
],
|
||||||
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/arm-fennix-gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"intelliSenseMode": "linux-gcc-arm",
|
||||||
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fennix Aarch64 (Linux, GCC, debug)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/libc/include/**",
|
||||||
|
"${workspaceFolder}/libs/include/**"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"__debug_vscode__",
|
||||||
|
"DEBUG=\"1\""
|
||||||
|
],
|
||||||
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"intelliSenseMode": "linux-gcc-arm64",
|
||||||
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
@ -40,6 +40,15 @@ static inline scarg syscall0(scarg syscall)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0");
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(x0)
|
||||||
|
: "r"(x8)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -65,6 +74,15 @@ static inline scarg syscall1(scarg syscall, scarg arg1)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -91,6 +109,16 @@ static inline scarg syscall2(scarg syscall, scarg arg1, scarg arg2)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -118,6 +146,17 @@ static inline scarg syscall3(scarg syscall, scarg arg1, scarg arg2, scarg arg3)
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -147,6 +186,18 @@ static inline scarg syscall4(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -178,6 +229,19 @@ static inline scarg syscall5(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
register long x4 __asm__("x4") = arg5;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -211,6 +275,20 @@ static inline scarg syscall6(scarg syscall, scarg arg1, scarg arg2, scarg arg3,
|
|||||||
: "rcx", "r11", "memory");
|
: "rcx", "r11", "memory");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 syscall wrapper not implemented"
|
#warning "i386 syscall wrapper not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm syscall wrapper not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
register long x8 __asm__("x8") = syscall;
|
||||||
|
register long x0 __asm__("x0") = arg1;
|
||||||
|
register long x1 __asm__("x1") = arg2;
|
||||||
|
register long x2 __asm__("x2") = arg3;
|
||||||
|
register long x3 __asm__("x3") = arg4;
|
||||||
|
register long x4 __asm__("x4") = arg5;
|
||||||
|
register long x5 __asm__("x5") = arg6;
|
||||||
|
__asm__ __volatile__("svc 0"
|
||||||
|
: "=r"(ret)
|
||||||
|
: "r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5)
|
||||||
|
: "memory", "cc");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +50,7 @@ extern "C"
|
|||||||
#define P_tmpdir "/tmp/"
|
#define P_tmpdir "/tmp/"
|
||||||
|
|
||||||
typedef long fpos_t;
|
typedef long fpos_t;
|
||||||
typedef unsigned long size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
|
||||||
struct _IO_FILE
|
struct _IO_FILE
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ extern "C"
|
|||||||
long rem;
|
long rem;
|
||||||
} ldiv_t;
|
} ldiv_t;
|
||||||
|
|
||||||
typedef unsigned long size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
// typedef __WCHAR_TYPE__ wchar_t;
|
// typedef __WCHAR_TYPE__ wchar_t;
|
||||||
|
|
||||||
long a64l(const char *);
|
long a64l(const char *);
|
||||||
|
@ -108,7 +108,7 @@ extern "C"
|
|||||||
char __data;
|
char __data;
|
||||||
} pthread_barrier_t;
|
} pthread_barrier_t;
|
||||||
|
|
||||||
typedef unsigned long size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
typedef long ssize_t;
|
typedef long ssize_t;
|
||||||
|
|
||||||
typedef long suseconds_t;
|
typedef long suseconds_t;
|
||||||
|
@ -182,6 +182,22 @@ enum RelocationTypes
|
|||||||
R_X86_64_REX_GOTPCRELX = 42,
|
R_X86_64_REX_GOTPCRELX = 42,
|
||||||
R_X86_64_NUM = 43,
|
R_X86_64_NUM = 43,
|
||||||
|
|
||||||
|
R_AARCH64_NONE = 0,
|
||||||
|
R_AARCH64_COPY = 1024,
|
||||||
|
R_AARCH64_GLOB_DAT = 1025,
|
||||||
|
R_AARCH64_JUMP_SLOT = 1026,
|
||||||
|
R_AARCH64_RELATIVE = 1027,
|
||||||
|
R_AARCH64_TLS_DTPMOD64 = 1028,
|
||||||
|
|
||||||
|
R_ARM_NONE = 0,
|
||||||
|
R_ARM_COPY = 1024,
|
||||||
|
R_ARM_GLOB_DAT = 1025,
|
||||||
|
R_ARM_JUMP_SLOT = 1026,
|
||||||
|
R_ARM_RELATIVE = 1027,
|
||||||
|
R_ARM_TLS_DTPMOD32 = 1028,
|
||||||
|
R_ARM_TLS_DTPOFF32 = 1029,
|
||||||
|
R_ARM_TLS_TPOFF32 = 1030,
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
R_NONE = R_X86_64_NONE,
|
R_NONE = R_X86_64_NONE,
|
||||||
R_COPY = R_X86_64_COPY,
|
R_COPY = R_X86_64_COPY,
|
||||||
@ -200,6 +216,24 @@ enum RelocationTypes
|
|||||||
R_DTPMOD64 = R_386_NONE,
|
R_DTPMOD64 = R_386_NONE,
|
||||||
R_DTPOFF64 = R_386_NONE,
|
R_DTPOFF64 = R_386_NONE,
|
||||||
R_TPOFF64 = R_386_NONE,
|
R_TPOFF64 = R_386_NONE,
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
R_NONE = R_AARCH64_NONE,
|
||||||
|
R_COPY = R_AARCH64_COPY,
|
||||||
|
R_GLOB_DAT = R_AARCH64_GLOB_DAT,
|
||||||
|
R_JMP_SLOT = R_AARCH64_JUMP_SLOT,
|
||||||
|
R_RELATIVE = R_AARCH64_RELATIVE,
|
||||||
|
R_DTPMOD64 = R_AARCH64_TLS_DTPMOD64,
|
||||||
|
R_DTPOFF64 = R_AARCH64_NONE,
|
||||||
|
R_TPOFF64 = R_AARCH64_NONE,
|
||||||
|
#elif defined(__arm__)
|
||||||
|
R_NONE = R_ARM_NONE,
|
||||||
|
R_COPY = R_ARM_COPY,
|
||||||
|
R_GLOB_DAT = R_ARM_GLOB_DAT,
|
||||||
|
R_JMP_SLOT = R_ARM_JUMP_SLOT,
|
||||||
|
R_RELATIVE = R_ARM_RELATIVE,
|
||||||
|
R_DTPMOD64 = R_ARM_TLS_DTPMOD32,
|
||||||
|
R_DTPOFF64 = R_ARM_TLS_DTPOFF32,
|
||||||
|
R_TPOFF64 = R_ARM_TLS_TPOFF32,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -986,7 +1020,7 @@ typedef Elf64_Rela Elf_Rela;
|
|||||||
#define ELF_ST_BIND(info) ELF64_ST_BIND(info)
|
#define ELF_ST_BIND(info) ELF64_ST_BIND(info)
|
||||||
#define ELF_ST_TYPE(info) ELF64_ST_TYPE(info)
|
#define ELF_ST_TYPE(info) ELF64_ST_TYPE(info)
|
||||||
#define ELF_ST_INFO(bind, type) ELF64_ST_INFO(bind, type)
|
#define ELF_ST_INFO(bind, type) ELF64_ST_INFO(bind, type)
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
typedef Elf32_Addr Elf_Addr;
|
typedef Elf32_Addr Elf_Addr;
|
||||||
typedef Elf32_Half Elf_Half;
|
typedef Elf32_Half Elf_Half;
|
||||||
typedef Elf32_Off Elf_Off;
|
typedef Elf32_Off Elf_Off;
|
||||||
|
@ -151,8 +151,8 @@ __attribute__((naked, used, no_stack_protector)) void _dl_runtime_resolve()
|
|||||||
"jmp *%r11\n"); /* Jump to the return value */
|
"jmp *%r11\n"); /* Jump to the return value */
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 _dl_runtime_resolve not implemented"
|
#warning "i386 _dl_runtime_resolve not implemented"
|
||||||
#else
|
#elif defined(__aarch64__)
|
||||||
#error "Unsupported architecture"
|
#warning "aarch64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,6 +817,7 @@ int RelocateHelper(ElfInfo *Info, Elf_Rela *Rela, short IsRel, void **Relocated)
|
|||||||
reloc = Info->BaseAddress;
|
reloc = Info->BaseAddress;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if defined(__amd64__)
|
||||||
case R_DTPOFF64:
|
case R_DTPOFF64:
|
||||||
{
|
{
|
||||||
printf("dl: i don't know what to do with DTPOFF64\n");
|
printf("dl: i don't know what to do with DTPOFF64\n");
|
||||||
@ -829,6 +830,7 @@ int RelocateHelper(ElfInfo *Info, Elf_Rela *Rela, short IsRel, void **Relocated)
|
|||||||
reloc = symAddress + Rela->r_addend;
|
reloc = symAddress + Rela->r_addend;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif // __LP64__
|
#endif // __LP64__
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -128,6 +128,10 @@ __attribute__((naked, used, no_stack_protector)) void _start()
|
|||||||
"call _exit\n"); /* Call _exit */
|
"call _exit\n"); /* Call _exit */
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 _start not implemented"
|
#warning "i386 _start not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm _start not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#warning "aarch64 _start not implemented"
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,7 +17,7 @@ build: $(OBJ)
|
|||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
$(CC) -nostdlib -mno-red-zone -std=c17 -DLIBC_GIT_COMMIT='"$(shell git rev-parse HEAD)"' -c $< -o $@
|
$(CC) -nostdlib -std=c17 -DLIBC_GIT_COMMIT='"$(shell git rev-parse HEAD)"' -c $< -o $@
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
|
@ -68,6 +68,10 @@ __attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
|
|||||||
"call _exit\n");
|
"call _exit\n");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 _start not implemented"
|
#warning "i386 _start not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm _start not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#warning "aarch64 _start not implemented"
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,6 +68,10 @@ __attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
|
|||||||
"call _exit\n");
|
"call _exit\n");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#warning "i386 _start not implemented"
|
#warning "i386 _start not implemented"
|
||||||
|
#elif defined(__arm__)
|
||||||
|
#warning "arm _start not implemented"
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#warning "aarch64 _start not implemented"
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
194
Userspace/libc/src/softfloat.c
Normal file
194
Userspace/libc/src/softfloat.c
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Fennix C Library.
|
||||||
|
|
||||||
|
Fennix C Library is free software: you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fennix C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
double __trunctfdf2(long double a)
|
||||||
|
{
|
||||||
|
return (double)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __aeabi_dcmple(long double a, long double b)
|
||||||
|
{
|
||||||
|
return a <= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long __aeabi_d2lz(double a)
|
||||||
|
{
|
||||||
|
return (long long)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __aeabi_dcmplt(long double a, long double b)
|
||||||
|
{
|
||||||
|
return a < b;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
__UINT64_TYPE__ mantissa : 52;
|
||||||
|
__UINT64_TYPE__ exponent : 11;
|
||||||
|
__UINT64_TYPE__ sign : 1;
|
||||||
|
} parts;
|
||||||
|
} aeabi_double_t;
|
||||||
|
|
||||||
|
aeabi_double_t __aeabi_ddiv(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
aeabi_double_t result;
|
||||||
|
result.d = a.d / b.d;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
aeabi_double_t __aeabi_dmul(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
aeabi_double_t result;
|
||||||
|
result.d = a.d * b.d;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
aeabi_double_t __aeabi_dadd(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
aeabi_double_t result;
|
||||||
|
result.d = a.d + b.d;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __aeabi_dcmpgt(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
return a.d > b.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __aeabi_dcmpge(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
return a.d >= b.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
aeabi_double_t __aeabi_dsub(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
aeabi_double_t result;
|
||||||
|
result.d = a.d - b.d;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
aeabi_double_t __aeabi_i2d(int a)
|
||||||
|
{
|
||||||
|
aeabi_double_t result;
|
||||||
|
result.d = (double)a;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
aeabi_double_t __aeabi_l2d(long long a)
|
||||||
|
{
|
||||||
|
aeabi_double_t result;
|
||||||
|
result.d = (double)a;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __aeabi_dcmpeq(aeabi_double_t a, aeabi_double_t b)
|
||||||
|
{
|
||||||
|
return a.d == b.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __aeabi_d2iz(aeabi_double_t a)
|
||||||
|
{
|
||||||
|
return (int)a.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ldivmod_result
|
||||||
|
{
|
||||||
|
long quot;
|
||||||
|
long rem;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ldivmod_result __aeabi_ldivmod(long numerator, long denominator)
|
||||||
|
{
|
||||||
|
struct ldivmod_result result;
|
||||||
|
result.quot = numerator / denominator;
|
||||||
|
result.rem = numerator % denominator;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed __aeabi_idiv(signed numerator, signed denominator)
|
||||||
|
{
|
||||||
|
return numerator / denominator;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed __aeabi_idivmod(signed numerator, signed denominator)
|
||||||
|
{
|
||||||
|
signed quotient = numerator / denominator;
|
||||||
|
signed remainder = numerator % denominator;
|
||||||
|
return (quotient << 16) | remainder;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator)
|
||||||
|
{
|
||||||
|
return numerator / denominator;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned __aeabi_uidivmod(unsigned numerator, unsigned denominator)
|
||||||
|
{
|
||||||
|
unsigned quotient = numerator / denominator;
|
||||||
|
unsigned remainder = numerator % denominator;
|
||||||
|
return (quotient << 16) | remainder;
|
||||||
|
}
|
||||||
|
|
||||||
|
__UINT64_TYPE__ __udivmoddi4(__UINT64_TYPE__ numerator, __UINT64_TYPE__ denominator, __UINT64_TYPE__ *remainder)
|
||||||
|
{
|
||||||
|
__UINT64_TYPE__ quotient = 0;
|
||||||
|
__UINT64_TYPE__ bit = 1;
|
||||||
|
|
||||||
|
if (denominator == 0)
|
||||||
|
{
|
||||||
|
*remainder = numerator;
|
||||||
|
return ~0ULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (denominator < numerator && (denominator & (1ULL << 63)) == 0)
|
||||||
|
{
|
||||||
|
denominator <<= 1;
|
||||||
|
bit <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (bit)
|
||||||
|
{
|
||||||
|
if (numerator >= denominator)
|
||||||
|
{
|
||||||
|
numerator -= denominator;
|
||||||
|
quotient |= bit;
|
||||||
|
}
|
||||||
|
denominator >>= 1;
|
||||||
|
bit >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainder)
|
||||||
|
*remainder = numerator;
|
||||||
|
|
||||||
|
return quotient;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct udivmod_result
|
||||||
|
{
|
||||||
|
__UINT64_TYPE__ quot;
|
||||||
|
__UINT64_TYPE__ rem;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct udivmod_result __aeabi_uldivmod(__UINT64_TYPE__ numerator, __UINT64_TYPE__ denominator)
|
||||||
|
{
|
||||||
|
struct udivmod_result result;
|
||||||
|
result.quot = __udivmoddi4(numerator, denominator, &result.rem);
|
||||||
|
return result;
|
||||||
|
}
|
@ -108,8 +108,12 @@ export int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
|
|||||||
export pthread_t pthread_self(void)
|
export pthread_t pthread_self(void)
|
||||||
{
|
{
|
||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
__asm__ __volatile__("mov %%fs:0, %0"
|
__asm__ __volatile__("mov %%fs:0, %0"
|
||||||
: "=r"(tid));
|
: "=r"(tid));
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
tid = 0;
|
||||||
|
#endif
|
||||||
return tid;
|
return tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@
|
|||||||
|
|
||||||
export __attribute__((naked, used, no_stack_protector)) void *__tls_get_addr(void *__data)
|
export __attribute__((naked, used, no_stack_protector)) void *__tls_get_addr(void *__data)
|
||||||
{
|
{
|
||||||
|
#warning "__tls_get_addr not implemented"
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
__asm__("ud2");
|
__asm__("ud2");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int __init_pthread(void)
|
int __init_pthread(void)
|
||||||
|
@ -287,6 +287,74 @@ index 6a9833e5..bf4c134d 100644
|
|||||||
eelf_x86_64_haiku.c \
|
eelf_x86_64_haiku.c \
|
||||||
eelf_x86_64_sol2.c \
|
eelf_x86_64_sol2.c \
|
||||||
ehppa64linux.c \
|
ehppa64linux.c \
|
||||||
|
diff --git a/ld/Makefile.in b/ld/Makefile.in
|
||||||
|
index 8639e782..24738803 100644
|
||||||
|
--- a/ld/Makefile.in
|
||||||
|
+++ b/ld/Makefile.in
|
||||||
|
@@ -676,6 +676,7 @@ ALL_EMULATION_SOURCES = \
|
||||||
|
earcv2elfx.c \
|
||||||
|
earm_wince_pe.c \
|
||||||
|
earmelf.c \
|
||||||
|
+ earmelf_fennix.c \
|
||||||
|
earmelf_fbsd.c \
|
||||||
|
earmelf_fuchsia.c \
|
||||||
|
earmelf_haiku.c \
|
||||||
|
@@ -790,6 +791,7 @@ ALL_EMULATION_SOURCES = \
|
||||||
|
eelf_i386.c \
|
||||||
|
eelf_i386_be.c \
|
||||||
|
eelf_i386_fbsd.c \
|
||||||
|
+ eelf_i386_fennix.c \
|
||||||
|
eelf_i386_haiku.c \
|
||||||
|
eelf_i386_ldso.c \
|
||||||
|
eelf_i386_sol2.c \
|
||||||
|
@@ -893,6 +895,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||||
|
eaarch64elf32.c \
|
||||||
|
eaarch64elf32b.c \
|
||||||
|
eaarch64elfb.c \
|
||||||
|
+ eaarch64fennix.c \
|
||||||
|
eaarch64fbsd.c \
|
||||||
|
eaarch64fbsdb.c \
|
||||||
|
eaarch64haiku.c \
|
||||||
|
@@ -973,6 +976,7 @@ ALL_64_EMULATION_SOURCES = \
|
||||||
|
eelf_x86_64.c \
|
||||||
|
eelf_x86_64_cloudabi.c \
|
||||||
|
eelf_x86_64_fbsd.c \
|
||||||
|
+ eelf_x86_64_fennix.c \
|
||||||
|
eelf_x86_64_haiku.c \
|
||||||
|
eelf_x86_64_sol2.c \
|
||||||
|
ehppa64linux.c \
|
||||||
|
@@ -1279,6 +1283,7 @@ distclean-compile:
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64elfb.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fbsd.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fbsdb.Po@am__quote@
|
||||||
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fennix.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64haiku.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux32.Po@am__quote@
|
||||||
|
@@ -1301,6 +1306,7 @@ distclean-compile:
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm_wince_pe.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fbsd.Po@am__quote@
|
||||||
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fennix.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fuchsia.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_haiku.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux.Po@am__quote@
|
||||||
|
@@ -1480,6 +1486,7 @@ distclean-compile:
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Po@am__quote@
|
||||||
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fennix.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_ldso.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_sol2.Po@am__quote@
|
||||||
|
@@ -1490,6 +1497,7 @@ distclean-compile:
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Po@am__quote@
|
||||||
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fennix.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_haiku.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf.Po@am__quote@
|
||||||
diff --git a/ld/configure.tgt b/ld/configure.tgt
|
diff --git a/ld/configure.tgt b/ld/configure.tgt
|
||||||
index f937f78b..3aa8c738 100644
|
index f937f78b..3aa8c738 100644
|
||||||
--- a/ld/configure.tgt
|
--- a/ld/configure.tgt
|
||||||
|
@ -104,10 +104,10 @@ index 95c91ee02..cbcaac06b 100644
|
|||||||
;;
|
;;
|
||||||
diff --git a/gcc/config/aarch64/aarch64-fennix.h b/gcc/config/aarch64/aarch64-fennix.h
|
diff --git a/gcc/config/aarch64/aarch64-fennix.h b/gcc/config/aarch64/aarch64-fennix.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 000000000..dafd8f253
|
index 000000000..cf9b0136e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/gcc/config/aarch64/aarch64-fennix.h
|
+++ b/gcc/config/aarch64/aarch64-fennix.h
|
||||||
@@ -0,0 +1,34 @@
|
@@ -0,0 +1,23 @@
|
||||||
+/* Definitions for AArch64 running Fennix
|
+/* Definitions for AArch64 running Fennix
|
||||||
+ Copyright (C) 2016-2024 Free Software Foundation, Inc.
|
+ Copyright (C) 2016-2024 Free Software Foundation, Inc.
|
||||||
+
|
+
|
||||||
@ -130,17 +130,6 @@ index 000000000..dafd8f253
|
|||||||
+#ifndef GCC_AARCH64_FENNIX_H
|
+#ifndef GCC_AARCH64_FENNIX_H
|
||||||
+#define GCC_AARCH64_FENNIX_H
|
+#define GCC_AARCH64_FENNIX_H
|
||||||
+
|
+
|
||||||
+// #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
|
|
||||||
+
|
|
||||||
+// #undef TARGET_BINDS_LOCAL_P
|
|
||||||
+// #define TARGET_BINDS_LOCAL_P default_binds_local_p_2
|
|
||||||
+
|
|
||||||
+// #undef MCOUNT_NAME
|
|
||||||
+// #define MCOUNT_NAME ".mcount"
|
|
||||||
+
|
|
||||||
+// #undef ASM_GENERATE_INTERNAL_LABEL
|
|
||||||
+// #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) sprintf(LABEL, "*.L%s%lu", PREFIX, (unsigned long)(NUM))
|
|
||||||
+
|
|
||||||
+#endif /* GCC_AARCH64_FENNIX_H */
|
+#endif /* GCC_AARCH64_FENNIX_H */
|
||||||
diff --git a/gcc/config/aarch64/t-aarch64-fennix b/gcc/config/aarch64/t-aarch64-fennix
|
diff --git a/gcc/config/aarch64/t-aarch64-fennix b/gcc/config/aarch64/t-aarch64-fennix
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
@ -304,14 +293,15 @@ index 000000000..632634dac
|
|||||||
+MULTILIB_OPTIONS += mno-red-zone
|
+MULTILIB_OPTIONS += mno-red-zone
|
||||||
+MULTILIB_DIRNAMES += no-red-zone
|
+MULTILIB_DIRNAMES += no-red-zone
|
||||||
diff --git a/libgcc/config.host b/libgcc/config.host
|
diff --git a/libgcc/config.host b/libgcc/config.host
|
||||||
index e75a7af64..572fff51e 100644
|
index e75a7af64..10d8017b0 100644
|
||||||
--- a/libgcc/config.host
|
--- a/libgcc/config.host
|
||||||
+++ b/libgcc/config.host
|
+++ b/libgcc/config.host
|
||||||
@@ -418,6 +418,14 @@ aarch64*-*-elf | aarch64*-*-rtems*)
|
@@ -418,6 +418,15 @@ aarch64*-*-elf | aarch64*-*-rtems*)
|
||||||
tmake_file="${tmake_file} t-dfprules"
|
tmake_file="${tmake_file} t-dfprules"
|
||||||
md_unwind_header=aarch64/aarch64-unwind.h
|
md_unwind_header=aarch64/aarch64-unwind.h
|
||||||
;;
|
;;
|
||||||
+aarch64*-*-fennix*)
|
+aarch64*-*-fennix*)
|
||||||
|
+ extra_parts="$extra_parts crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o"
|
||||||
+ extra_parts="$extra_parts crtfastmath.o"
|
+ extra_parts="$extra_parts crtfastmath.o"
|
||||||
+ tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
|
+ tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
|
||||||
+ tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
|
+ tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
|
||||||
@ -322,7 +312,7 @@ index e75a7af64..572fff51e 100644
|
|||||||
aarch64*-*-freebsd*)
|
aarch64*-*-freebsd*)
|
||||||
extra_parts="$extra_parts crtfastmath.o"
|
extra_parts="$extra_parts crtfastmath.o"
|
||||||
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
|
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
|
||||||
@@ -512,6 +520,12 @@ arm-wrs-vxworks7*)
|
@@ -512,6 +521,13 @@ arm-wrs-vxworks7*)
|
||||||
unwind_header=config/arm/unwind-arm.h
|
unwind_header=config/arm/unwind-arm.h
|
||||||
extra_parts="$extra_parts crti.o crtn.o"
|
extra_parts="$extra_parts crti.o crtn.o"
|
||||||
;;
|
;;
|
||||||
@ -331,11 +321,12 @@ index e75a7af64..572fff51e 100644
|
|||||||
+ tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
|
+ tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
|
||||||
+ tm_file="${tm_file} arm/bpabi-lib.h"
|
+ tm_file="${tm_file} arm/bpabi-lib.h"
|
||||||
+ unwind_header=config/arm/unwind-arm.h
|
+ unwind_header=config/arm/unwind-arm.h
|
||||||
|
+ extra_parts="$extra_parts crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o"
|
||||||
+ ;;
|
+ ;;
|
||||||
arm*-*-freebsd*) # ARM FreeBSD EABI
|
arm*-*-freebsd*) # ARM FreeBSD EABI
|
||||||
tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix arm/t-elf"
|
tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix arm/t-elf"
|
||||||
tmake_file="${tmake_file} arm/t-bpabi arm/t-freebsd"
|
tmake_file="${tmake_file} arm/t-bpabi arm/t-freebsd"
|
||||||
@@ -760,6 +774,14 @@ x86_64-*-dragonfly*)
|
@@ -760,6 +776,14 @@ x86_64-*-dragonfly*)
|
||||||
tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
|
tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
|
||||||
md_unwind_header=i386/dragonfly-unwind.h
|
md_unwind_header=i386/dragonfly-unwind.h
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user