Update kernel

This commit is contained in:
EnderIce2
2024-01-19 06:47:42 +02:00
parent fd15592608
commit 96daa43d38
282 changed files with 25486 additions and 15700 deletions

View File

@ -21,14 +21,14 @@
"\talong with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.",
"*/",
"",
"#ifndef __FENNIX_KERNEL_${2:header}_H__",
"#define __FENNIX_KERNEL_${2:header}_H__",
"#ifndef __FENNIX_KERNEL_${1:header}_H__",
"#define __FENNIX_KERNEL_${1:header}_H__",
"",
"#include <types.h>",
"",
"$0",
"",
"#endif // !__FENNIX_KERNEL_${2:header}_H__",
"#endif // !__FENNIX_KERNEL_${1:header}_H__",
""
],
"description": "Create kernel header."
@ -42,7 +42,7 @@
],
"description": "Create kernel documentation brief."
},
"For Iteratoion": {
"For Iteration": {
"prefix": [
"foritr",
],
@ -77,5 +77,134 @@
"*/"
],
"description": "Create kernel license."
},
"Driver Code": {
"prefix": [
"driver",
],
"body": [
"/*",
"\tThis file is part of Fennix Kernel.",
"",
"\tFennix Kernel is free software: you can redistribute it and/or",
"\tmodify it under the terms of the GNU General Public License as",
"\tpublished by the Free Software Foundation, either version 3 of",
"\tthe License, or (at your option) any later version.",
"",
"\tFennix Kernel is distributed in the hope that it will be useful,",
"\tbut WITHOUT ANY WARRANTY; without even the implied warranty of",
"\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
"\tGNU General Public License for more details.",
"",
"\tYou should have received a copy of the GNU General Public License",
"\talong with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.",
"*/",
"",
"#include \"${1:driver}.hpp\"",
"",
"#include <debug.h>",
"",
"#include \"../../../kernel.h\"",
"",
"namespace Driver",
"{",
"\tint ${2:driver}::drvOpen(int Flags, mode_t Mode) { return 0; }",
"",
"\tint ${2:driver}::drvClose() { return 0; }",
"",
"\tsize_t ${2:driver}::drvRead(uint8_t *Buffer, size_t Size, off_t Offset) { return 0; }",
"",
"\tsize_t ${2:driver}::drvWrite(uint8_t *Buffer, size_t Size, off_t Offset) { return 0; }",
"",
"\tint ${2:driver}::drvIoctl(unsigned long Request, void *Argp) { return 0; }",
"",
"\tvoid ${2:driver}::OnInterruptReceived(CPU::TrapFrame *) {}",
"",
"\tvoid ${2:driver}::Panic() {}",
"",
"\t${2:driver}::${2:driver}(PCI::PCIDevice dev)",
"\t\t: Object(dev),",
"\t\t Interrupts::Handler(dev)",
"\t{",
"\t}",
"",
"\t${2:driver}::${2:driver}(int irq)",
"\t\t: Object(irq),",
"\t\t Interrupts::Handler(irq)",
"\t{",
"\t}",
"",
"\t${2:driver}::${2:driver}()",
"\t{",
"\t}",
"",
"\t${2:driver}::~${2:driver}()",
"\t{",
"\t\tif (GetError() != 0)",
"\t\t\treturn;",
"\t}",
"}",
"",
],
"description": "Kernel driver code template."
},
"Driver Header": {
"prefix": [
"driver",
],
"body": [
"/*",
"\tThis file is part of Fennix Kernel.",
"",
"\tFennix Kernel is free software: you can redistribute it and/or",
"\tmodify it under the terms of the GNU General Public License as",
"\tpublished by the Free Software Foundation, either version 3 of",
"\tthe License, or (at your option) any later version.",
"",
"\tFennix Kernel is distributed in the hope that it will be useful,",
"\tbut WITHOUT ANY WARRANTY; without even the implied warranty of",
"\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
"\tGNU General Public License for more details.",
"",
"\tYou should have received a copy of the GNU General Public License",
"\talong with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.",
"*/",
"",
"#pragma once",
"#include <driver.hpp>",
"",
"namespace Driver",
"{",
"\tclass ${1:driver} : public Object, public Interrupts::Handler",
"\t{",
"\tprivate:",
"\t\tvoid OnInterruptReceived(CPU::TrapFrame *Frame) final;",
"\t\tvoid Panic(Driver::DriverContext *ctx) final;",
"",
"\tpublic:",
"\t\tint drvOpen(int Flags, mode_t Mode);",
"\t\tint drvClose();",
"\t\tsize_t drvRead(uint8_t *Buffer, size_t Size, off_t Offset);",
"\t\tsize_t drvWrite(uint8_t *Buffer, size_t Size, off_t Offset);",
"\t\tint drvIoctl(unsigned long Request, void *Argp);",
"",
"\t\tconst char *drvName() final { return \"${2:MyDriver}\"; }",
"\t\tconst char *drvDescription() final { return \"${3:MyDescription}\"; }",
"\t\tconst char *drvVersion() final { return \"${4:0.0.0}\"; }",
"\t\tconst char *drvAuthor() final { return \"${5:Author}\"; }",
"\t\tconst char *drvLicense() final { return \"${6:License}\"; }",
"\t\tDriverType drvType() final { return DriverType_${7:Generic}; }",
"",
"\t\t${1:driver}(PCI::PCIDevice dev);",
"\t\t${1:driver}(int irq);",
"\t\t${1:driver}();",
"\t\t~${1:driver}();",
"\t};",
"}",
"",
],
"description": "Kernel driver header template."
}
}

View File

@ -19,6 +19,9 @@
"a86",
"DEBUG=\"1\""
],
"forcedInclude": [
"${workspaceFolder}/.vscode/preinclude.h"
],
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
"cStandard": "c17",
"cppStandard": "c++20",
@ -34,7 +37,6 @@
"-mcmodel=kernel",
"-fno-builtin",
"-m64",
// Warnings
"-Wall",
"-Wextra",
@ -46,11 +48,9 @@
"-Wswitch-default",
"-Wstrict-overflow=5",
"-Wconversion",
// C++ flags
"-fno-rtti",
"-fno-exceptions",
// Linker flags
"-T${workspaceFolder}/arch/amd64/linker.ld",
"-Wl,-static,--no-dynamic-linker,-ztext",
@ -59,7 +59,6 @@
"-nolibc",
"-zmax-page-size=0x1000",
"-shared",
// Debug flags
"-ggdb3",
"-O0",
@ -68,7 +67,6 @@
"-fstack-usage",
"-fstack-check",
"-fsanitize=undefined",
// VSCode flags
"-ffreestanding",
"-nostdinc",
@ -112,7 +110,6 @@
"-msoft-float",
"-fno-builtin",
"-m32",
// Warnings
"-Wall",
"-Wextra",
@ -124,11 +121,9 @@
"-Wswitch-default",
"-Wstrict-overflow=5",
"-Wconversion",
// C++ flags
"-fno-rtti",
"-fno-exceptions",
// Linker flags
"-T${workspaceFolder}/arch/i386/linker.ld",
"-Wl,-static,--no-dynamic-linker,-ztext",
@ -137,7 +132,6 @@
"-nolibc",
"-zmax-page-size=0x1000",
"-shared",
// Debug flags
"-ggdb3",
"-O0",
@ -146,7 +140,6 @@
"-fstack-usage",
"-fstack-check",
"-fsanitize=undefined",
// VSCode flags
"-ffreestanding",
"-nostdinc",
@ -183,7 +176,6 @@
"-msoft-float",
"-fPIC",
"-Wstack-protector",
// Warnings
"-Wall",
"-Wextra",
@ -195,15 +187,12 @@
"-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",
@ -212,7 +201,6 @@
"-fstack-usage",
"-fstack-check",
"-fsanitize=undefined",
// VSCode flags
"-ffreestanding",
"-nostdinc",

86
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"name": "Attach to a running VM instance",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel.fsys",
"program": "${workspaceFolder}/fennix.elf",
"cwd": "${workspaceFolder}",
"args": [],
"targetArchitecture": "x64",
@ -31,63 +31,20 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "file ${workspaceFolder}/kernel.fsys",
"description": "Load binary."
}
]
},
{
"name": "Attach to VM w/userspace binaries",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel.fsys",
"cwd": "${workspaceFolder}",
"args": [],
"targetArchitecture": "x64",
"MIMode": "gdb",
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
"miDebuggerArgs": "",
"externalConsole": false,
"additionalSOLibSearchPath": "${workspaceFolder}",
"customLaunchSetupCommands": [
{
"text": "target remote localhost:1234",
"description": "Connect to QEMU remote debugger"
}
],
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "set breakpoint pending on",
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "file ${workspaceFolder}/kernel.fsys",
"text": "file ${workspaceFolder}/fennix.elf",
"description": "Load binary."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/init",
"description": "Load /bin/init."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
"description": "Load /bin/utest."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/usr/bin/doom",
"description": "Load /usr/bin/doom."
},
"text": "source ${workspaceFolder}/.gdbinit"
}
],
"preLaunchTask": "launch-qemu"
},
{
"name": "Attach to VM w/utest",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel.fsys",
"program": "${workspaceFolder}/fennix.elf",
"cwd": "${workspaceFolder}",
"args": [],
"targetArchitecture": "x64",
@ -113,20 +70,25 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "file ${workspaceFolder}/kernel.fsys",
"text": "file ${workspaceFolder}/fennix.elf",
"description": "Load binary."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
"description": "Load /bin/utest."
"description": "Load /bin/utest.",
"ignoreFailures": true
},
{
"text": "source ${workspaceFolder}/.gdbinit"
}
],
"preLaunchTask": "launch-qemu",
},
{
"name": "Attach to VM w/doom",
"name": "Attach to VM w/utest_linux",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel.fsys",
"program": "${workspaceFolder}/fennix.elf",
"cwd": "${workspaceFolder}",
"args": [],
"targetArchitecture": "x64",
@ -152,14 +114,24 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "file ${workspaceFolder}/kernel.fsys",
"text": "file ${workspaceFolder}/fennix.elf",
"description": "Load binary."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/usr/bin/doom",
"description": "Load /usr/bin/doom."
"text": "set debug-file-directory /usr/lib/debug",
"description": "Set debug-file-directory to /usr/lib/debug.",
"ignoreFailures": true
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest_linux",
"description": "Load /bin/utest_linux.",
"ignoreFailures": true
},
{
"text": "source ${workspaceFolder}/.gdbinit"
}
],
}
"preLaunchTask": "launch-qemu",
},
]
}

7
.vscode/preinclude.h vendored Normal file
View File

@ -0,0 +1,7 @@
#undef __linux__
#undef __WIN32__
#undef __WIN64__
#undef _WIN32
#undef _WIN64
#undef __APPLE__
#undef __clang__

26
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "launch-qemu",
"type": "shell",
"command": "make -j$(shell nproc) build && make -C ../ build_image && make -C ../ vscode_debug_only",
"isBackground": true,
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared"
},
"options": {
"shell": {
"executable": "bash",
"args": ["-c"]
}
}
}
]
}