mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
Compare commits
16 Commits
58f3442c6d
...
7ce73ab813
Author | SHA1 | Date | |
---|---|---|---|
7ce73ab813 | |||
0ab1833034 | |||
495a0ea609 | |||
72232d8bd2 | |||
6bd705f06a | |||
0912d4b383 | |||
4350393610 | |||
a8ff50541a | |||
a4c5ab7ef3 | |||
e147e1eff5 | |||
c09bdee89a | |||
3fa7acb116 | |||
749a1b1810 | |||
210e06429c | |||
137f16bc55 | |||
995ef471ab |
17
.editorconfig
Normal file
17
.editorconfig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# EditorConfig is awesome: https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[.github/**]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
20
.github/workflows/makefile.yml
vendored
20
.github/workflows/makefile.yml
vendored
@ -124,9 +124,7 @@ jobs:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo
|
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo
|
||||||
make --quiet -C tools do_limine
|
make --quiet -C tools do_limine
|
||||||
make --quiet -C Drivers prepare
|
make --quiet prepare
|
||||||
make --quiet -C Userspace prepare
|
|
||||||
make --quiet -C Kernel prepare
|
|
||||||
|
|
||||||
- name: Cache cross
|
- name: Cache cross
|
||||||
id: cache-cross
|
id: cache-cross
|
||||||
@ -187,9 +185,7 @@ jobs:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
||||||
make --quiet -C tools do_limine
|
make --quiet -C tools do_limine
|
||||||
make --quiet -C Drivers prepare
|
make --quiet prepare
|
||||||
make --quiet -C Userspace prepare
|
|
||||||
make --quiet -C Kernel prepare
|
|
||||||
|
|
||||||
- name: Cache cross Folder
|
- name: Cache cross Folder
|
||||||
id: cache-cross
|
id: cache-cross
|
||||||
@ -236,9 +232,7 @@ jobs:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
||||||
make --quiet -C tools do_limine
|
make --quiet -C tools do_limine
|
||||||
make --quiet -C Drivers prepare
|
make --quiet prepare
|
||||||
make --quiet -C Userspace prepare
|
|
||||||
make --quiet -C Kernel prepare
|
|
||||||
|
|
||||||
- name: Cache cross Folder
|
- name: Cache cross Folder
|
||||||
id: cache-cross
|
id: cache-cross
|
||||||
@ -285,9 +279,7 @@ jobs:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
||||||
make --quiet -C tools do_limine
|
make --quiet -C tools do_limine
|
||||||
make --quiet -C Drivers prepare
|
make --quiet prepare
|
||||||
make --quiet -C Userspace prepare
|
|
||||||
make --quiet -C Kernel prepare
|
|
||||||
|
|
||||||
- name: Cache cross Folder
|
- name: Cache cross Folder
|
||||||
id: cache-cross
|
id: cache-cross
|
||||||
@ -334,9 +326,7 @@ jobs:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
sudo apt --no-install-recommends -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64
|
||||||
make --quiet -C tools do_limine
|
make --quiet -C tools do_limine
|
||||||
make --quiet -C Drivers prepare
|
make --quiet prepare
|
||||||
make --quiet -C Userspace prepare
|
|
||||||
make --quiet -C Kernel prepare
|
|
||||||
|
|
||||||
- name: Cache cross Folder
|
- name: Cache cross Folder
|
||||||
id: cache-cross
|
id: cache-cross
|
||||||
|
14
.gitignore
vendored
14
.gitignore
vendored
@ -2,20 +2,6 @@ iso_tmp_data
|
|||||||
initrd_tmp_data
|
initrd_tmp_data
|
||||||
initrd/usr/include/*
|
initrd/usr/include/*
|
||||||
!initrd/usr/include/.gitkeep
|
!initrd/usr/include/.gitkeep
|
||||||
tools/*
|
|
||||||
!tools/ExtMemDbg
|
|
||||||
!tools/stage2_eltorito
|
|
||||||
!tools/*.md
|
|
||||||
!tools/README.md
|
|
||||||
!tools/website
|
|
||||||
!tools/Makefile
|
|
||||||
!tools/*.c
|
|
||||||
!tools/*.patch
|
|
||||||
!tools/*.cpp
|
|
||||||
!tools/*.cfg
|
|
||||||
!tools/acpi
|
|
||||||
!tools/doxygen
|
|
||||||
!tools/.gdbinit
|
|
||||||
doxygen-doc
|
doxygen-doc
|
||||||
initrd.tar
|
initrd.tar
|
||||||
.dccache
|
.dccache
|
||||||
|
104
.vscode/launch.json
vendored
104
.vscode/launch.json
vendored
@ -2,39 +2,105 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Launch QEMU & debug the kernel",
|
"name": "Debug Kernel (x64)",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/../Kernel/fennix.elf",
|
"program": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"args": [],
|
|
||||||
"targetArchitecture": "x64",
|
"targetArchitecture": "x64",
|
||||||
"MIMode": "gdb",
|
"MIMode": "gdb",
|
||||||
"miDebuggerServerAddress": "/tmp/gdb-fennix",
|
"miDebuggerServerAddress": "/tmp/gdb-fennix",
|
||||||
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
||||||
"miDebuggerArgs": "",
|
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"additionalSOLibSearchPath": "${workspaceFolder}",
|
|
||||||
"internalConsoleOptions": "neverOpen",
|
"internalConsoleOptions": "neverOpen",
|
||||||
"customLaunchSetupCommands": [
|
|
||||||
// {
|
|
||||||
// "text": "target remote localhost:1234",
|
|
||||||
// "description": "Connect to QEMU remote debugger"
|
|
||||||
// }
|
|
||||||
],
|
|
||||||
"setupCommands": [
|
"setupCommands": [
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"text": "set breakpoint pending on",
|
"text": "set breakpoint pending on",
|
||||||
"description": "Make breakpoint pending on future shared library load."
|
"description": "Make breakpoint pending on future shared library load."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "file ${workspaceFolder}/../Kernel/fennix.elf",
|
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
||||||
"description": "Load binary"
|
"description": "Load /bin/utest",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "source ${workspaceFolder}/../tools/.gdbinit"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "launch-qemu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug Kernel (x86)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"targetArchitecture": "x86",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerServerAddress": "/tmp/gdb-fennix",
|
||||||
|
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/i386-fennix-gdb",
|
||||||
|
"externalConsole": false,
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"text": "set breakpoint pending on",
|
||||||
|
"description": "Make breakpoint pending on future shared library load."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
||||||
|
"description": "Load /bin/utest",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "source ${workspaceFolder}/../tools/.gdbinit"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "launch-qemu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug Kernel (arm64)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"targetArchitecture": "arm64",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerServerAddress": "/tmp/gdb-fennix",
|
||||||
|
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gdb",
|
||||||
|
"externalConsole": false,
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"text": "set breakpoint pending on",
|
||||||
|
"description": "Make breakpoint pending on future shared library load."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
||||||
|
"description": "Load /bin/utest",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "source ${workspaceFolder}/../tools/.gdbinit"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "launch-qemu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug Kernel (arm)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerServerAddress": "/tmp/gdb-fennix",
|
||||||
|
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/arm-fennix-gdb",
|
||||||
|
"externalConsole": false,
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"text": "set breakpoint pending on",
|
||||||
|
"description": "Make breakpoint pending on future shared library load."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
||||||
@ -50,7 +116,7 @@
|
|||||||
{
|
{
|
||||||
"type": "gdb",
|
"type": "gdb",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"name": "Launch QEMU & attach to gdbserver",
|
"name": "Launch QEMU & attach to gdbserver (x64)",
|
||||||
"executable": "${workspaceFolder}/../Kernel/fennix.elf",
|
"executable": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
"target": "/tmp/gdb-fennix",
|
"target": "/tmp/gdb-fennix",
|
||||||
"remote": true,
|
"remote": true,
|
||||||
@ -66,4 +132,4 @@
|
|||||||
"preLaunchTask": "launch-qemu"
|
"preLaunchTask": "launch-qemu"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
13
Bootloader/.editorconfig
Normal file
13
Bootloader/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# EditorConfig is awesome: https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
10
Bootloader/.gitignore
vendored
Normal file
10
Bootloader/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
gnu-efi
|
||||||
|
include/*
|
||||||
|
!include/stdbool.h
|
||||||
|
!include/types.h
|
||||||
|
*.o
|
||||||
|
*.su
|
||||||
|
*.EFI
|
||||||
|
*.map
|
||||||
|
*.bin
|
||||||
|
*.elf
|
96
Bootloader/.vscode/c_boilerplates.code-snippets
vendored
Normal file
96
Bootloader/.vscode/c_boilerplates.code-snippets
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"Lynx Bootloader C++ Header": {
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"scope": "c,cpp",
|
||||||
|
"prefix": [
|
||||||
|
"head",
|
||||||
|
],
|
||||||
|
"body": [
|
||||||
|
"/*",
|
||||||
|
"\tThis file is part of Lynx Bootloader.",
|
||||||
|
"",
|
||||||
|
"\tLynx Bootloader 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.",
|
||||||
|
"",
|
||||||
|
"\tLynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.",
|
||||||
|
"*/",
|
||||||
|
"",
|
||||||
|
"#pragma once",
|
||||||
|
"",
|
||||||
|
"$0",
|
||||||
|
"",
|
||||||
|
"$1",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"description": "Create kernel header."
|
||||||
|
},
|
||||||
|
"Lynx Bootloader C Header": {
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"scope": "c,cpp",
|
||||||
|
"prefix": [
|
||||||
|
"headc",
|
||||||
|
],
|
||||||
|
"body": [
|
||||||
|
"/*",
|
||||||
|
"\tThis file is part of Lynx Bootloader.",
|
||||||
|
"",
|
||||||
|
"\tLynx Bootloader 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.",
|
||||||
|
"",
|
||||||
|
"\tLynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.",
|
||||||
|
"*/",
|
||||||
|
"",
|
||||||
|
"#ifndef __LYNX_BOOTLOADER_${1:header}_H__",
|
||||||
|
"#define __LYNX_BOOTLOADER_${1:header}_H__",
|
||||||
|
"",
|
||||||
|
"#include <types.h>",
|
||||||
|
"",
|
||||||
|
"$0",
|
||||||
|
"",
|
||||||
|
"#endif // !__LYNX_BOOTLOADER_${1:header}_H__",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"description": "Create kernel header."
|
||||||
|
},
|
||||||
|
"License": {
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"prefix": [
|
||||||
|
"license",
|
||||||
|
],
|
||||||
|
"body": [
|
||||||
|
"/*",
|
||||||
|
"\tThis file is part of Lynx Bootloader.",
|
||||||
|
"",
|
||||||
|
"\tLynx Bootloader 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.",
|
||||||
|
"",
|
||||||
|
"\tLynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.",
|
||||||
|
"*/"
|
||||||
|
],
|
||||||
|
"description": "Create kernel license."
|
||||||
|
}
|
||||||
|
}
|
184
Bootloader/.vscode/c_cpp_properties.json
vendored
Normal file
184
Bootloader/.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Fennix x64 (Linux, GCC, debug)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/include",
|
||||||
|
"${workspaceFolder}/include/**"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"DEBUG=\"1\""
|
||||||
|
],
|
||||||
|
"forcedInclude": [
|
||||||
|
"${workspaceFolder}/.vscode/preinclude.h"
|
||||||
|
],
|
||||||
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"intelliSenseMode": "gcc-x64",
|
||||||
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
|
"compilerArgs": [
|
||||||
|
// Compiler flags
|
||||||
|
"-fno-pic",
|
||||||
|
"-fno-pie",
|
||||||
|
"-mno-red-zone",
|
||||||
|
"-march=core2",
|
||||||
|
"-pipe",
|
||||||
|
"-mcmodel=kernel",
|
||||||
|
"-fno-builtin",
|
||||||
|
"-m64",
|
||||||
|
"-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/amd64/linker.ld",
|
||||||
|
"-Wl,-static,--no-dynamic-linker,-ztext",
|
||||||
|
"-nostdlib",
|
||||||
|
"-nodefaultlibs",
|
||||||
|
"-nolibc",
|
||||||
|
"-zmax-page-size=0x1000",
|
||||||
|
"-shared",
|
||||||
|
// Debug flags
|
||||||
|
"-ggdb3",
|
||||||
|
"-O0",
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-fverbose-asm",
|
||||||
|
"-fstack-usage",
|
||||||
|
"-fstack-check",
|
||||||
|
"-fsanitize=undefined",
|
||||||
|
// VSCode flags
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fennix x32 (Linux, GCC, debug)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/include",
|
||||||
|
"${workspaceFolder}/include/**"
|
||||||
|
],
|
||||||
|
"forcedInclude": [
|
||||||
|
"${workspaceFolder}/.vscode/preinclude.h"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"DEBUG=\"1\""
|
||||||
|
],
|
||||||
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-fennix-gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"intelliSenseMode": "gcc-x86",
|
||||||
|
"configurationProvider": "ms-vscode.makefile-tools",
|
||||||
|
"compilerArgs": [
|
||||||
|
// Compiler flags
|
||||||
|
"-fno-pic",
|
||||||
|
"-fno-pie",
|
||||||
|
"-mno-80387",
|
||||||
|
"-mno-mmx",
|
||||||
|
"-mno-3dnow",
|
||||||
|
"-mno-red-zone",
|
||||||
|
"-march=pentium",
|
||||||
|
"-pipe",
|
||||||
|
"-msoft-float",
|
||||||
|
"-fno-builtin",
|
||||||
|
"-m32",
|
||||||
|
"-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/i386/linker.ld",
|
||||||
|
"-Wl,-static,--no-dynamic-linker,-ztext",
|
||||||
|
"-nostdlib",
|
||||||
|
"-nodefaultlibs",
|
||||||
|
"-nolibc",
|
||||||
|
"-zmax-page-size=0x1000",
|
||||||
|
"-shared",
|
||||||
|
// Debug flags
|
||||||
|
"-ggdb3",
|
||||||
|
"-O0",
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-fverbose-asm",
|
||||||
|
"-fstack-usage",
|
||||||
|
"-fstack-check",
|
||||||
|
"-fsanitize=undefined",
|
||||||
|
// VSCode flags
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fennix Arm (Linux, GCC, debug)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/include",
|
||||||
|
"${workspaceFolder}/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)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/include",
|
||||||
|
"${workspaceFolder}/include/**"
|
||||||
|
],
|
||||||
|
"forcedInclude": [
|
||||||
|
"${workspaceFolder}/.vscode/preinclude.h"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"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": [
|
||||||
|
// VSCode flags
|
||||||
|
"-ffreestanding",
|
||||||
|
"-nostdinc",
|
||||||
|
"-nostdinc++"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
1
Bootloader/.vscode/launch.json
vendored
Symbolic link
1
Bootloader/.vscode/launch.json
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../.vscode/launch.json
|
11
Bootloader/.vscode/preinclude.h
vendored
Normal file
11
Bootloader/.vscode/preinclude.h
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#undef __linux__
|
||||||
|
#undef __WIN32__
|
||||||
|
#undef __WIN64__
|
||||||
|
#undef _WIN32
|
||||||
|
#undef _WIN64
|
||||||
|
#undef __APPLE__
|
||||||
|
#undef __clang__
|
||||||
|
#define __vscode__ 1
|
||||||
|
#define __kernel__ 1
|
||||||
|
#define GIT_COMMIT "0000000000000000000000000000000000000000"
|
||||||
|
#define GIT_COMMIT_SHORT "0000000"
|
23
Bootloader/.vscode/settings.json
vendored
Normal file
23
Bootloader/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.errorSquiggles": "enabled",
|
||||||
|
"C_Cpp.autocompleteAddParentheses": true,
|
||||||
|
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
|
||||||
|
"C_Cpp.clang_format_style": "Visual Studio",
|
||||||
|
"C_Cpp.default.intelliSenseMode": "gcc-x64",
|
||||||
|
"C_Cpp.default.cStandard": "c17",
|
||||||
|
"C_Cpp.default.cppStandard": "c++20",
|
||||||
|
"C_Cpp.intelliSenseMemoryLimit": 16384,
|
||||||
|
"editor.smoothScrolling": true,
|
||||||
|
"editor.cursorSmoothCaretAnimation": "on",
|
||||||
|
"C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
|
||||||
|
"clang-analyzer-security.insecureAPI.strcpy",
|
||||||
|
"clang-diagnostic-unknown-warning-option",
|
||||||
|
"clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling",
|
||||||
|
"clang-diagnostic-implicit-exception-spec-mismatch",
|
||||||
|
"clang-diagnostic-unknown-attributes",
|
||||||
|
"clang-diagnostic-user-defined-literals",
|
||||||
|
"clang-diagnostic-non-pod-varargs",
|
||||||
|
"clang-diagnostic-non-pod-varargs",
|
||||||
|
"clang-diagnostic-non-pod-varargs"
|
||||||
|
]
|
||||||
|
}
|
1
Bootloader/.vscode/tasks.json
vendored
Symbolic link
1
Bootloader/.vscode/tasks.json
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../.vscode/tasks.json
|
56
Bootloader/Makefile
Normal file
56
Bootloader/Makefile
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
GNUEFI_RELEASE_VERSION=3.0.18
|
||||||
|
|
||||||
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||||
|
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
export CC := $(__CONF_CC)
|
||||||
|
export CXX := $(__CONF_CXX)
|
||||||
|
export LD := $(__CONF_LD)
|
||||||
|
export AS := $(__CONF_AS)
|
||||||
|
export AR := $(__CONF_AR)
|
||||||
|
export NM := $(__CONF_NM)
|
||||||
|
export OBJCOPY := $(__CONF_OBJCOPY)
|
||||||
|
export OBJDUMP := $(__CONF_OBJDUMP)
|
||||||
|
export GDB := $(__CONF_GDB)
|
||||||
|
|
||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
prepare:
|
||||||
|
ifeq ("$(wildcard ./gnu-efi)", "")
|
||||||
|
wget https://freefr.dl.sourceforge.net/project/gnu-efi/gnu-efi-$(GNUEFI_RELEASE_VERSION).tar.bz2
|
||||||
|
tar -xf gnu-efi-$(GNUEFI_RELEASE_VERSION).tar.bz2
|
||||||
|
rm gnu-efi-$(GNUEFI_RELEASE_VERSION).tar.bz2
|
||||||
|
mv ./gnu-efi-$(GNUEFI_RELEASE_VERSION) ./gnu-efi
|
||||||
|
cp -a ./gnu-efi/inc/. ./include
|
||||||
|
endif
|
||||||
|
echo "PREPARE > Compiling gnu-efi for x86_64"
|
||||||
|
make -C gnu-efi all ARCH=x86_64 \
|
||||||
|
AR=$(TOOLCHAIN_AMD64_PREFIX)ar \
|
||||||
|
AS=$(TOOLCHAIN_AMD64_PREFIX)as \
|
||||||
|
CC=$(TOOLCHAIN_AMD64_PREFIX)gcc \
|
||||||
|
LD=$(TOOLCHAIN_AMD64_PREFIX)ld
|
||||||
|
# echo "PREPARE > Compiling gnu-efi for arm"
|
||||||
|
# make -C gnu-efi all ARCH=arm \
|
||||||
|
# AR=$(TOOLCHAIN_ARM_PREFIX)ar \
|
||||||
|
# AS=$(TOOLCHAIN_ARM_PREFIX)as \
|
||||||
|
# CC=$(TOOLCHAIN_ARM_PREFIX)gcc \
|
||||||
|
# LD=$(TOOLCHAIN_ARM_PREFIX)ld \
|
||||||
|
# CFLAGS="-I$(CURDIR)/gnu-efi/inc"
|
||||||
|
# echo "PREPARE > Compiling gnu-efi for aarch64"
|
||||||
|
# make -C gnu-efi all ARCH=aarch64 \
|
||||||
|
# AR=$(TOOLCHAIN_AARCH64_PREFIX)ar \
|
||||||
|
# AS=$(TOOLCHAIN_AARCH64_PREFIX)as \
|
||||||
|
# CC=$(TOOLCHAIN_AARCH64_PREFIX)gcc \
|
||||||
|
# LD=$(TOOLCHAIN_AARCH64_PREFIX)ld
|
||||||
|
|
||||||
|
build:
|
||||||
|
$(MAKE) -C common build
|
||||||
|
$(MAKE) -C firmware build
|
||||||
|
# $(MAKE) -C uefi build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(MAKE) -C common clean
|
||||||
|
$(MAKE) -C firmware clean
|
||||||
|
# $(MAKE) -C uefi clean
|
||||||
|
rm -f boot.bin
|
13
Bootloader/README.md
Normal file
13
Bootloader/README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Lynx Bootloader
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
> The project is in early stages of development and is not yet ready for production use.
|
||||||
|
>
|
||||||
|
> Use at your own risk.
|
||||||
|
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
### [bios](bios)
|
||||||
|
|
||||||
|
### [uefi](uefi)
|
19
Bootloader/common/Makefile
Normal file
19
Bootloader/common/Makefile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
define find-sources
|
||||||
|
$(shell find ./ -type f -name '$1' -print0 | xargs -0)
|
||||||
|
endef
|
||||||
|
|
||||||
|
BMP_SOURCES := $(call find-sources,*.bmp)
|
||||||
|
PSF_SOURCES := $(call find-sources,*.psf)
|
||||||
|
S_SOURCES := $(call find-sources,*.S)
|
||||||
|
s_SOURCES := $(call find-sources,*.s)
|
||||||
|
C_SOURCES := $(call find-sources,*.c)
|
||||||
|
CXX_SOURCES := $(call find-sources,*.cpp)
|
||||||
|
|
||||||
|
OBJ = $(BMP_SOURCES:.bmp=.o) $(PSF_SOURCES:.psf=.o) $(s_SOURCES:.s=.o) $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o)
|
||||||
|
|
||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
clean:
|
21
Bootloader/common/main.c
Normal file
21
Bootloader/common/main.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
8
Bootloader/firmware/Makefile
Normal file
8
Bootloader/firmware/Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build:
|
||||||
|
$(MAKE) -C $(OSARCH) build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(MAKE) -C $(OSARCH) clean
|
64
Bootloader/firmware/aarch64/Makefile
Normal file
64
Bootloader/firmware/aarch64/Makefile
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
define find-sources
|
||||||
|
$(shell find ./ -type f -name '$1' $(shell echo $(foreach board,$(filter-out $(BOARD_TYPE),$(AVAILABLE_BOARDS)), -not -path \"./$(board)/*\")) -print0 | xargs -0)
|
||||||
|
endef
|
||||||
|
|
||||||
|
S_SOURCES := $(call find-sources,*.S)
|
||||||
|
s_SOURCES := $(call find-sources,*.s)
|
||||||
|
C_SOURCES := $(call find-sources,*.c)
|
||||||
|
|
||||||
|
define find-common-sources
|
||||||
|
$(shell find ../../common -type f -name '$1' -print0 | xargs -0)
|
||||||
|
endef
|
||||||
|
|
||||||
|
C_COMMON_SOURCES := $(call find-common-sources,*.c)
|
||||||
|
|
||||||
|
OBJ = $(s_SOURCES:.s=.o) $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(C_COMMON_SOURCES:.c=.o)
|
||||||
|
|
||||||
|
LDFLAGS = -static -nostdlib -nodefaultlibs -nolibc \
|
||||||
|
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||||
|
-zmax-page-size=0x1000 \
|
||||||
|
-Wl,-Map boot.map -fno-pic -fno-pie
|
||||||
|
|
||||||
|
CFLAGS := \
|
||||||
|
$(INCLUDE_DIR) \
|
||||||
|
-D__kernel__='1' \
|
||||||
|
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
||||||
|
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' \
|
||||||
|
-fno-pic -fno-pie -fno-builtin -I../../include
|
||||||
|
|
||||||
|
CFLAGS += -mcmodel=large
|
||||||
|
LDFLAGS += -T$(BOARD_TYPE)/linker.ld
|
||||||
|
|
||||||
|
ifeq ($(DEBUG), 1)
|
||||||
|
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always
|
||||||
|
# CFLAGS += -fsanitize=undefined
|
||||||
|
CFLAGS += -fstack-check -fverbose-asm
|
||||||
|
LDFLAGS += -ggdb3 -O0
|
||||||
|
ASFLAGS += -g --gstabs+ --gdwarf-5 -D
|
||||||
|
endif # DEBUG
|
||||||
|
|
||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build: boot.bin
|
||||||
|
|
||||||
|
boot.bin: $(OBJ)
|
||||||
|
$(info Linking $@)
|
||||||
|
$(CC) $(LDFLAGS) $(OBJ) -o tmp.elf
|
||||||
|
$(OBJCOPY) tmp.elf -O binary ../../boot.bin
|
||||||
|
# rm tmp.elf
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(CFLAGS) -fstack-protector-all -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.s
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJ) boot.map
|
1
Bootloader/firmware/aarch64/raspi3
Symbolic link
1
Bootloader/firmware/aarch64/raspi3
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
./raspi4
|
49
Bootloader/firmware/aarch64/raspi4/boot.S
Normal file
49
Bootloader/firmware/aarch64/raspi4/boot.S
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section ".text.boot"
|
||||||
|
|
||||||
|
.extern __bss_start
|
||||||
|
.extern __bss_end
|
||||||
|
.extern __bss_size
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
/* Keep only the main core */
|
||||||
|
mrs x1, mpidr_el1
|
||||||
|
and x1, x1, #3
|
||||||
|
cbz x1, 2f
|
||||||
|
|
||||||
|
/* Halt */
|
||||||
|
1: wfe
|
||||||
|
b 1b
|
||||||
|
|
||||||
|
/* Initialize the stack */
|
||||||
|
2: ldr x1, =_start
|
||||||
|
mov sp, x1
|
||||||
|
|
||||||
|
/* Clear the BSS */
|
||||||
|
ldr x1, =__bss_start
|
||||||
|
ldr w2, =__bss_size
|
||||||
|
3: cbz w2, 4f
|
||||||
|
str xzr, [x1], #8
|
||||||
|
sub w2, w2, #1
|
||||||
|
cbnz w2, 3b
|
||||||
|
|
||||||
|
/* Start the kernel */
|
||||||
|
4: bl _aarch64_start
|
||||||
|
b 1b
|
32
Bootloader/firmware/aarch64/raspi4/init.c
Normal file
32
Bootloader/firmware/aarch64/raspi4/init.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
uintptr_t __stack_chk_guard = 0;
|
||||||
|
|
||||||
|
__noreturn __no_stack_protector void __stack_chk_fail(void)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main();
|
||||||
|
__attribute__((section(".bootstrap.text"))) void _aarch64_start(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3)
|
||||||
|
{
|
||||||
|
main();
|
||||||
|
}
|
70
Bootloader/firmware/aarch64/raspi4/linker.ld
Normal file
70
Bootloader/firmware/aarch64/raspi4/linker.ld
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
OUTPUT_FORMAT("elf64-littleaarch64")
|
||||||
|
OUTPUT_ARCH(aarch64)
|
||||||
|
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0x80000;
|
||||||
|
__start = .;
|
||||||
|
__text_start = .;
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
KEEP(*(.text.boot))
|
||||||
|
*(.text)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
__text_end = .;
|
||||||
|
|
||||||
|
__rodata_start = .;
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
__rodata_end = .;
|
||||||
|
|
||||||
|
__data_start = .;
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
__data_end = .;
|
||||||
|
|
||||||
|
__bss_start = .;
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
bss = .;
|
||||||
|
*(.bss)
|
||||||
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
|
__bss_end = .;
|
||||||
|
__bss_size = __bss_end - __bss_start; /* SIZEOF(.bss); */
|
||||||
|
__end = .;
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.comment*)
|
||||||
|
*(.gnu*)
|
||||||
|
*(.note*)
|
||||||
|
*(.eh_frame*)
|
||||||
|
}
|
||||||
|
}
|
6
Bootloader/firmware/amd64/Makefile
Normal file
6
Bootloader/firmware/amd64/Makefile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
clean:
|
6
Bootloader/firmware/arm/Makefile
Normal file
6
Bootloader/firmware/arm/Makefile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
clean:
|
6
Bootloader/firmware/i386/Makefile
Normal file
6
Bootloader/firmware/i386/Makefile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
clean:
|
26
Bootloader/include/stdbool.h
Normal file
26
Bootloader/include/stdbool.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __STDBOOL_H__
|
||||||
|
#define __STDBOOL_H__
|
||||||
|
|
||||||
|
|
||||||
|
typedef int bool;
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
|
||||||
|
#endif /* __STDBOOL_H__ */
|
496
Bootloader/include/types.h
Normal file
496
Bootloader/include/types.h
Normal file
@ -0,0 +1,496 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FENNIX_KERNEL_TYPES_H__
|
||||||
|
#define __FENNIX_KERNEL_TYPES_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It doesn't do anything.
|
||||||
|
*
|
||||||
|
* Used to specify a function that is dependent on the architecture.
|
||||||
|
* It's architecture specific variant is defined in arch/<arch>/...
|
||||||
|
*/
|
||||||
|
#define arch
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERNC extern "C"
|
||||||
|
#define START_EXTERNC \
|
||||||
|
EXTERNC \
|
||||||
|
{
|
||||||
|
#define END_EXTERNC \
|
||||||
|
}
|
||||||
|
#else // __cplusplus
|
||||||
|
#define EXTERNC
|
||||||
|
#define START_EXTERNC
|
||||||
|
#define END_EXTERNC
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define NULL 0
|
||||||
|
#else // __cplusplus
|
||||||
|
#define NULL ((void *)0)
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#define asm __asm__
|
||||||
|
#define asmv __asm__ volatile
|
||||||
|
|
||||||
|
#define inf_loop while (1)
|
||||||
|
#define ilp inf_loop; /* Used for debugging */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define foreach for
|
||||||
|
#define in :
|
||||||
|
|
||||||
|
#define forItr(itr, container) \
|
||||||
|
for (auto itr = container.begin(); \
|
||||||
|
itr != container.end(); ++itr)
|
||||||
|
|
||||||
|
#define r_cst(t, v) reinterpret_cast<t>(v)
|
||||||
|
#define c_cst(t, v) const_cast<t>(v)
|
||||||
|
#define s_cst(t, v) static_cast<t>(v)
|
||||||
|
#define d_cst(t, v) dynamic_cast<t>(v)
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#define UNUSED(x) (void)(x)
|
||||||
|
#define CONCAT(x, y) x##y
|
||||||
|
|
||||||
|
#ifndef __va_list__
|
||||||
|
typedef __builtin_va_list va_list;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define va_start(v, l) __builtin_va_start(v, l)
|
||||||
|
#define va_end(v) __builtin_va_end(v)
|
||||||
|
#define va_arg(v, l) __builtin_va_arg(v, l)
|
||||||
|
|
||||||
|
#define ALIGN_UP(x, align) ((__typeof__(x))(((uintptr_t)(x) + ((align) - 1)) & (~((align) - 1))))
|
||||||
|
#define ALIGN_DOWN(x, align) ((__typeof__(x))((x) & (~((align) - 1))))
|
||||||
|
|
||||||
|
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||||
|
|
||||||
|
#define RGB_TO_HEX(r, g, b) ((r << 16) | (g << 8) | (b))
|
||||||
|
|
||||||
|
#define MAX(a, b) \
|
||||||
|
({ \
|
||||||
|
__typeof__(a) _a = (a); \
|
||||||
|
__typeof__(b) _b = (b); \
|
||||||
|
_a > _b ? _a : _b; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define MIN(a, b) \
|
||||||
|
({ \
|
||||||
|
__typeof__(a) _a = (a); \
|
||||||
|
__typeof__(b) _b = (b); \
|
||||||
|
_a < _b ? _a : _b; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define ROUND_UP(x, y) (((x) + (y) - 1) & ~((y) - 1))
|
||||||
|
#define ROUND_DOWN(x, y) ((x) & ~((y) - 1))
|
||||||
|
|
||||||
|
#define VPOKE(type, address) (*((volatile type *)(address)))
|
||||||
|
#define POKE(type, address) (*((type *)(address)))
|
||||||
|
|
||||||
|
#ifndef __SIG_ATOMIC_TYPE__
|
||||||
|
#define __SIG_ATOMIC_TYPE__ int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef __INT8_TYPE__ int8_t;
|
||||||
|
typedef __INT16_TYPE__ int16_t;
|
||||||
|
typedef __INT32_TYPE__ int32_t;
|
||||||
|
typedef __INT64_TYPE__ int64_t;
|
||||||
|
|
||||||
|
typedef __UINT8_TYPE__ uint8_t;
|
||||||
|
typedef __UINT16_TYPE__ uint16_t;
|
||||||
|
typedef __UINT32_TYPE__ uint32_t;
|
||||||
|
typedef __UINT64_TYPE__ uint64_t;
|
||||||
|
|
||||||
|
typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||||
|
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||||
|
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||||
|
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||||
|
|
||||||
|
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||||
|
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||||
|
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||||
|
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
||||||
|
|
||||||
|
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||||
|
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||||
|
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||||
|
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||||
|
|
||||||
|
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||||
|
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||||
|
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||||
|
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||||
|
|
||||||
|
typedef __INTPTR_TYPE__ intptr_t;
|
||||||
|
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||||
|
|
||||||
|
typedef __INTMAX_TYPE__ intmax_t;
|
||||||
|
typedef __UINTMAX_TYPE__ uintmax_t;
|
||||||
|
|
||||||
|
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
#ifndef __cplusplus
|
||||||
|
typedef __WCHAR_TYPE__ wchar_t;
|
||||||
|
#endif
|
||||||
|
typedef __WINT_TYPE__ wint_t;
|
||||||
|
typedef __SIG_ATOMIC_TYPE__ sig_atomic_t;
|
||||||
|
// TODO: ssize_t
|
||||||
|
typedef intptr_t ssize_t;
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
|
typedef int64_t off_t;
|
||||||
|
typedef int64_t off64_t;
|
||||||
|
typedef uint32_t mode_t;
|
||||||
|
typedef uint64_t dev_t;
|
||||||
|
typedef uint64_t ino64_t;
|
||||||
|
typedef uint64_t ino_t;
|
||||||
|
typedef uint32_t nlink_t;
|
||||||
|
typedef int64_t blksize_t;
|
||||||
|
typedef int64_t blkcnt_t;
|
||||||
|
typedef int64_t blkcnt64_t;
|
||||||
|
typedef int64_t time_t;
|
||||||
|
typedef uint32_t uid_t;
|
||||||
|
typedef uint32_t gid_t;
|
||||||
|
typedef int64_t clock_t;
|
||||||
|
typedef int32_t pid_t;
|
||||||
|
#elif defined(__i386__) || defined(__arm__)
|
||||||
|
typedef int32_t off_t;
|
||||||
|
typedef long long off64_t;
|
||||||
|
typedef uint32_t mode_t;
|
||||||
|
typedef int32_t dev_t;
|
||||||
|
typedef int32_t ino64_t;
|
||||||
|
typedef int32_t ino_t;
|
||||||
|
typedef uint32_t nlink_t;
|
||||||
|
typedef int blksize_t;
|
||||||
|
typedef int32_t blkcnt_t;
|
||||||
|
typedef int32_t blkcnt64_t;
|
||||||
|
typedef int32_t time_t;
|
||||||
|
typedef uint32_t uid_t;
|
||||||
|
typedef uint32_t gid_t;
|
||||||
|
typedef long clock_t;
|
||||||
|
typedef int pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
template <typename T>
|
||||||
|
class ptr_t
|
||||||
|
{
|
||||||
|
T ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ptr_t() : ptr(nullptr) {}
|
||||||
|
ptr_t(T p) : ptr(p) {}
|
||||||
|
ptr_t(int p) : ptr((T)(uintptr_t)p) {}
|
||||||
|
ptr_t(const ptr_t<T> &other) : ptr(other.ptr) {}
|
||||||
|
|
||||||
|
operator T() { return ptr; }
|
||||||
|
operator uintptr_t() { return (uintptr_t)ptr; }
|
||||||
|
|
||||||
|
operator bool() { return (void *)(uintptr_t)ptr != nullptr; }
|
||||||
|
|
||||||
|
ptr_t<T> &operator=(const ptr_t<T> &other)
|
||||||
|
{
|
||||||
|
ptr = other.ptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr_t<T> &operator+=(uintptr_t offset)
|
||||||
|
{
|
||||||
|
ptr = (T)((uintptr_t)ptr + offset);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr_t<T> &operator-=(uintptr_t offset)
|
||||||
|
{
|
||||||
|
ptr = (T)((uintptr_t)ptr - offset);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const ptr_t<T> &other) const { return ptr == other.ptr; }
|
||||||
|
bool operator==(auto other) const { return (uintptr_t)ptr == (uintptr_t)other; }
|
||||||
|
|
||||||
|
bool operator!=(const ptr_t<T> &other) const { return ptr != other.ptr; }
|
||||||
|
bool operator!=(auto other) const { return (uintptr_t)ptr != (uintptr_t)other; }
|
||||||
|
|
||||||
|
bool operator>(const ptr_t<T> &other) const { return ptr > other.ptr; }
|
||||||
|
bool operator>(auto other) const { return (uintptr_t)ptr > (uintptr_t)other; }
|
||||||
|
|
||||||
|
bool operator<(const ptr_t<T> &other) const { return ptr < other.ptr; }
|
||||||
|
bool operator<(auto other) const { return (uintptr_t)ptr < (uintptr_t)other; }
|
||||||
|
|
||||||
|
bool operator>=(const ptr_t<T> &other) const { return ptr >= other.ptr; }
|
||||||
|
bool operator>=(auto other) const { return (uintptr_t)ptr >= (uintptr_t)other; }
|
||||||
|
|
||||||
|
bool operator<=(const ptr_t<T> &other) const { return ptr <= other.ptr; }
|
||||||
|
bool operator<=(auto other) const { return (uintptr_t)ptr <= (uintptr_t)other; }
|
||||||
|
|
||||||
|
ptr_t<T> operator+(auto offset) const { return ptr_t<T>((void *)((uintptr_t)ptr + offset)); }
|
||||||
|
ptr_t<T> operator-(auto offset) const { return ptr_t<T>((void *)((uintptr_t)ptr - offset)); }
|
||||||
|
|
||||||
|
T operator->() { return ptr; }
|
||||||
|
T operator*() { return *ptr; }
|
||||||
|
};
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#define INT8_MAX __INT8_MAX__
|
||||||
|
#define INT8_MIN (-INT8_MAX - 1)
|
||||||
|
#define UINT8_MAX __UINT8_MAX__
|
||||||
|
#define INT16_MAX __INT16_MAX__
|
||||||
|
#define INT16_MIN (-INT16_MAX - 1)
|
||||||
|
#define UINT16_MAX __UINT16_MAX__
|
||||||
|
#define INT32_MAX __INT32_MAX__
|
||||||
|
#define INT32_MIN (-INT32_MAX - 1)
|
||||||
|
#define UINT32_MAX __UINT32_MAX__
|
||||||
|
#define INT64_MAX __INT64_MAX__
|
||||||
|
#define INT64_MIN (-INT64_MAX - 1)
|
||||||
|
#define UINT64_MAX __UINT64_MAX__
|
||||||
|
|
||||||
|
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
|
||||||
|
#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
|
||||||
|
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
|
||||||
|
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
|
||||||
|
#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
|
||||||
|
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
|
||||||
|
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
|
||||||
|
#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
|
||||||
|
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
|
||||||
|
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
|
||||||
|
#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
|
||||||
|
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
|
||||||
|
|
||||||
|
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||||
|
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
|
||||||
|
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||||
|
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||||
|
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
|
||||||
|
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||||
|
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||||
|
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
|
||||||
|
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||||
|
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||||
|
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
|
||||||
|
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||||
|
|
||||||
|
#define INTPTR_MAX __INTPTR_MAX__
|
||||||
|
#define INTPTR_MIN (-INTPTR_MAX - 1)
|
||||||
|
#define UINTPTR_MAX __UINTPTR_MAX__
|
||||||
|
|
||||||
|
#define INTMAX_MAX __INTMAX_MAX__
|
||||||
|
#define INTMAX_MIN (-INTMAX_MAX - 1)
|
||||||
|
#define UINTMAX_MAX __UINTMAX_MAX__
|
||||||
|
|
||||||
|
#define PTRDIFF_MAX __PTRDIFF_MAX__
|
||||||
|
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
|
||||||
|
|
||||||
|
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
|
||||||
|
#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
|
||||||
|
|
||||||
|
#define SIZE_MAX __SIZE_MAX__
|
||||||
|
|
||||||
|
#define WCHAR_MAX __WCHAR_MAX__
|
||||||
|
#define WCHAR_MIN __WCHAR_MIN__
|
||||||
|
|
||||||
|
#define WINT_MAX __WINT_MAX__
|
||||||
|
#define WINT_MIN __WINT_MIN__
|
||||||
|
|
||||||
|
#if defined(__amd64__)
|
||||||
|
#define BREAK __asm__ __volatile__("int $0x3" \
|
||||||
|
: \
|
||||||
|
: \
|
||||||
|
: "memory");
|
||||||
|
#elif defined(__i386__)
|
||||||
|
#define BREAK __asm__ __volatile__("int $0x3" \
|
||||||
|
: \
|
||||||
|
: \
|
||||||
|
: "memory");
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#define BREAK __asm__ __volatile__("brk #0" \
|
||||||
|
: \
|
||||||
|
: \
|
||||||
|
: "memory");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __INT48_TYPE__
|
||||||
|
typedef __INT48_TYPE__ int48_t;
|
||||||
|
typedef __UINT48_TYPE__ uint48_t;
|
||||||
|
typedef int48_t int_least48_t;
|
||||||
|
typedef uint48_t uint_least48_t;
|
||||||
|
typedef int48_t int_fast48_t;
|
||||||
|
typedef uint48_t uint_fast48_t;
|
||||||
|
#else // __INT48_TYPE__
|
||||||
|
typedef __INT64_TYPE__ int48_t;
|
||||||
|
typedef __UINT64_TYPE__ uint48_t;
|
||||||
|
typedef int48_t int_least48_t;
|
||||||
|
typedef uint48_t uint_least48_t;
|
||||||
|
typedef int48_t int_fast48_t;
|
||||||
|
typedef uint48_t uint_fast48_t;
|
||||||
|
#endif // __INT48_TYPE__
|
||||||
|
|
||||||
|
#define b4(x) ((x & 0x0F) << 4 | (x & 0xF0) >> 4)
|
||||||
|
#define b8(x) ((x) & 0xFF)
|
||||||
|
#define b16(x) __builtin_bswap16(x)
|
||||||
|
#define b32(x) __builtin_bswap32(x)
|
||||||
|
#define b48(x) (((((x) & 0x0000000000ff) << 40) | \
|
||||||
|
(((x) & 0x00000000ff00) << 24) | \
|
||||||
|
(((x) & 0x000000ff0000) << 8) | \
|
||||||
|
(((x) & 0x0000ff000000) >> 8) | \
|
||||||
|
(((x) & 0x00ff00000000) >> 24) | \
|
||||||
|
(((x) & 0xff0000000000) >> 40)))
|
||||||
|
#define b64(x) __builtin_bswap64(x)
|
||||||
|
|
||||||
|
/* https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html */
|
||||||
|
|
||||||
|
/** No optimization (the default); generates
|
||||||
|
* unoptimized code but has the fastest compilation time.
|
||||||
|
*/
|
||||||
|
#define O0 __attribute__((optimize("O0")))
|
||||||
|
|
||||||
|
/** Moderate optimization;
|
||||||
|
* optimizes reasonably well but does not degrade
|
||||||
|
* compilation time significantly. */
|
||||||
|
#define O1 __attribute__((optimize("O1")))
|
||||||
|
|
||||||
|
/** Full optimization; generates highly
|
||||||
|
* optimized code and has the slowest compilation time.
|
||||||
|
*/
|
||||||
|
#define O2 __attribute__((optimize("O2")))
|
||||||
|
|
||||||
|
/** Full optimization as in -O2;
|
||||||
|
* also uses more aggressive automatic inlining of
|
||||||
|
* subprograms within a unit (Inlining of Subprograms)
|
||||||
|
* and attempts to vectorize loops. */
|
||||||
|
#define O3 __attribute__((optimize("O3")))
|
||||||
|
|
||||||
|
/** Optimize space usage (code and data)
|
||||||
|
* of resulting program.
|
||||||
|
*/
|
||||||
|
#define Os __attribute__((optimize("Os")))
|
||||||
|
|
||||||
|
/** Disregard strict standards compliance.
|
||||||
|
* -Ofast enables all -O3 optimizations.
|
||||||
|
* It also enables optimizations that are not valid for
|
||||||
|
* all standard-compliant programs.
|
||||||
|
*/
|
||||||
|
#define Ofast __attribute__((optimize("Ofast")))
|
||||||
|
|
||||||
|
/** Optimize for size.
|
||||||
|
* -Oz enables all -Os optimizations that do not typically
|
||||||
|
* increase code size.
|
||||||
|
*/
|
||||||
|
#define Oz __attribute__((optimize("Oz")))
|
||||||
|
|
||||||
|
/** Optimize for debugging.
|
||||||
|
* -Og enables optimizations that do not interfere with
|
||||||
|
* debugging.
|
||||||
|
*/
|
||||||
|
#define Og __attribute__((optimize("Og")))
|
||||||
|
|
||||||
|
#define __unused __attribute__((unused))
|
||||||
|
#define __packed __attribute__((packed))
|
||||||
|
#define __naked __attribute__((naked))
|
||||||
|
#define __aligned(x) __attribute__((aligned(x)))
|
||||||
|
#define __section(x) __attribute__((section(x)))
|
||||||
|
#define __noreturn __attribute__((noreturn))
|
||||||
|
#define __weak __attribute__((weak))
|
||||||
|
#define __alias(x) __attribute__((alias(x)))
|
||||||
|
#define __always_inline __attribute__((always_inline))
|
||||||
|
#define __noinline __attribute__((noinline))
|
||||||
|
#define __pure __attribute__((pure))
|
||||||
|
#define __const __attribute__((const))
|
||||||
|
#define __malloc __attribute__((malloc))
|
||||||
|
#define __returns_twice __attribute__((returns_twice))
|
||||||
|
#define __used __attribute__((used))
|
||||||
|
#define __deprecated __attribute__((deprecated))
|
||||||
|
#define __deprecated_msg(x) __attribute__((deprecated(x)))
|
||||||
|
#define __weakref(x) __attribute__((weakref(x)))
|
||||||
|
#define __weakrefalias(x) __attribute__((weakref(#x)))
|
||||||
|
#define __visibility(x) __attribute__((visibility(x)))
|
||||||
|
#define __constructor __attribute__((constructor))
|
||||||
|
#define __destructor __attribute__((destructor))
|
||||||
|
#define __cleanup(x) __attribute__((cleanup(x)))
|
||||||
|
#define __fallthrough __attribute__((fallthrough))
|
||||||
|
#define __nonnull(x) __attribute__((nonnull x))
|
||||||
|
#define __nonnull_all __attribute__((nonnull))
|
||||||
|
#define __returns_nonnull __attribute__((returns_nonnull))
|
||||||
|
#define __sentinel __attribute__((sentinel))
|
||||||
|
#define __sentinel_all __attribute__((sentinel(0)))
|
||||||
|
#define __format(x, y, z) __attribute__((format(x, y, z)))
|
||||||
|
#define __format_arg(x) __attribute__((format_arg(x)))
|
||||||
|
#define __nonnull_params(x) __attribute__((nonnull x))
|
||||||
|
#define __nonnull_all __attribute__((nonnull))
|
||||||
|
#define __warn_unused_result __attribute__((warn_unused_result))
|
||||||
|
#define __no_stack_protector __attribute__((no_stack_protector))
|
||||||
|
#define __no_instrument_function __attribute__((no_instrument_function))
|
||||||
|
#define __no_debug __attribute__((no_debug))
|
||||||
|
#define __target(x) __attribute__((target(x)))
|
||||||
|
#define __min_vector_width(x) __attribute__((min_vector_width(x)))
|
||||||
|
|
||||||
|
// sanitizer
|
||||||
|
#define __no_sanitize(x) __attribute__((no_sanitize(x)))
|
||||||
|
#define __no_sanitize_address __attribute__((no_sanitize_address))
|
||||||
|
#define __no_sanitize_thread __attribute__((no_sanitize_thread))
|
||||||
|
#define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
|
||||||
|
#define __no_sanitize_coverage __attribute__((no_sanitize_coverage))
|
||||||
|
|
||||||
|
#define __synchronize __sync_synchronize()
|
||||||
|
#define __sync __synchronize
|
||||||
|
|
||||||
|
#define __unreachable __builtin_unreachable()
|
||||||
|
|
||||||
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
|
||||||
|
#define NoSecurityAnalysis __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_sanitize_thread
|
||||||
|
#define nsa NoSecurityAnalysis
|
||||||
|
|
||||||
|
#define NIF __no_instrument_function
|
||||||
|
|
||||||
|
#define int3 \
|
||||||
|
__asm__ __volatile__("int3" \
|
||||||
|
: \
|
||||||
|
: \
|
||||||
|
: "memory")
|
||||||
|
|
||||||
|
#define StackPush(stack, type, value) \
|
||||||
|
*((type *)--stack) = value
|
||||||
|
|
||||||
|
#define StackPop(stack, type) \
|
||||||
|
*((type *)stack++)
|
||||||
|
|
||||||
|
#define ReturnLogError(ret, format, ...) \
|
||||||
|
{ \
|
||||||
|
trace(format, ##__VA_ARGS__); \
|
||||||
|
return ret; \
|
||||||
|
} \
|
||||||
|
while (0) \
|
||||||
|
__builtin_unreachable()
|
||||||
|
|
||||||
|
#define AssertReturnError(condition, ret) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (__builtin_expect(!!(!(condition)), 0)) \
|
||||||
|
{ \
|
||||||
|
error("\"%s\" failed!", #condition); \
|
||||||
|
return ret; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif // !__FENNIX_KERNEL_TYPES_H__
|
137
Bootloader/uefi/Makefile
Normal file
137
Bootloader/uefi/Makefile
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
BOOT_FILENAME = BOOTX64.EFI
|
||||||
|
|
||||||
|
GNUEFI_RELEASE_VERSION=3.0.18
|
||||||
|
|
||||||
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||||
|
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
HEADERS := $(sort $(dir $(wildcard ../include/*)))
|
||||||
|
INCLUDE_DIR = -I../include
|
||||||
|
|
||||||
|
define find-sources
|
||||||
|
$(shell find ./ -type f -name '$1' -print0 | xargs -0)
|
||||||
|
endef
|
||||||
|
|
||||||
|
BMP_SOURCES := $(call find-sources,*.bmp)
|
||||||
|
PSF_SOURCES := $(call find-sources,*.psf)
|
||||||
|
S_SOURCES := $(call find-sources,*.S)
|
||||||
|
s_SOURCES := $(call find-sources,*.s)
|
||||||
|
C_SOURCES := $(call find-sources,*.c)
|
||||||
|
CXX_SOURCES := $(call find-sources,*.cpp)
|
||||||
|
|
||||||
|
OBJ = $(BMP_SOURCES:.bmp=.o) $(PSF_SOURCES:.psf=.o) $(s_SOURCES:.s=.o) $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o)
|
||||||
|
|
||||||
|
LDFLAGS = -static -nostdlib -nodefaultlibs -nolibc \
|
||||||
|
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||||
|
-zmax-page-size=0x1000 \
|
||||||
|
-Wl,-Map kernel.map -fno-pic -fno-pie
|
||||||
|
|
||||||
|
# Disable all warnings by adding "-w" in WARNCFLAG and if you want to treat the warnings as errors, add "-Werror"
|
||||||
|
# -Wconversion this may be re-added later
|
||||||
|
WARNCFLAG = -Wall -Wextra \
|
||||||
|
-Wfloat-equal -Wpointer-arith -Wcast-align \
|
||||||
|
-Wredundant-decls -Winit-self -Wswitch-default \
|
||||||
|
-Wstrict-overflow=5 -Wno-error=cpp -Werror \
|
||||||
|
-Wno-unused-parameter -Wno-error=format
|
||||||
|
|
||||||
|
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
||||||
|
|
||||||
|
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||||
|
CFLAGS := \
|
||||||
|
$(INCLUDE_DIR) \
|
||||||
|
-D__kernel__='1' \
|
||||||
|
-DKERNEL_NAME='"$(OSNAME)"' \
|
||||||
|
-DKERNEL_ARCH='"$(OSARCH)"' \
|
||||||
|
-DKERNEL_VERSION='"$(KERNEL_VERSION)"' \
|
||||||
|
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
||||||
|
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' \
|
||||||
|
-fno-pic -fno-pie -fno-builtin
|
||||||
|
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
CFLAGS += -march=core2 -mcmodel=kernel -m64 -mno-red-zone
|
||||||
|
LDFLAGS += -T../linker.ld
|
||||||
|
else ifeq ($(OSARCH), i386)
|
||||||
|
CFLAGS += -march=pentium -m32 -mno-red-zone
|
||||||
|
LDFLAGS += -T../linker.ld
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
CFLAGS += -march=armv7-a -mfloat-abi=softfp -ggdb3
|
||||||
|
LDFLAGS += -T../linker.ld
|
||||||
|
WARNCFLAG += -w
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
CFLAGS += -march=armv9.4-a -mtune=cortex-a72 -mlittle-endian -mcmodel=large
|
||||||
|
LDFLAGS += -T../linker.ld
|
||||||
|
endif # OSARCH
|
||||||
|
|
||||||
|
# -finstrument-functions for __cyg_profile_func_enter & __cyg_profile_func_exit. Used for profiling and debugging.
|
||||||
|
ifeq ($(DEBUG), 1)
|
||||||
|
# CFLAGS += --coverage
|
||||||
|
# CFLAGS += -pg
|
||||||
|
# CFLAGS += -finstrument-functions
|
||||||
|
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage -fsanitize=undefined
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
CFLAGS += -fverbose-asm
|
||||||
|
endif # amd64
|
||||||
|
ifeq ($(OSARCH), arm)
|
||||||
|
CFLAGS += -fstack-check -fverbose-asm
|
||||||
|
endif # arm
|
||||||
|
ifeq ($(OSARCH), aarch64)
|
||||||
|
CFLAGS += -fstack-check -fverbose-asm
|
||||||
|
endif # aarch64
|
||||||
|
LDFLAGS += -ggdb3 -O0
|
||||||
|
ASFLAGS += -g --gstabs+ --gdwarf-5 -D
|
||||||
|
WARNCFLAG += -Wno-unused-function -Wno-maybe-uninitialized -Wno-builtin-declaration-mismatch -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable
|
||||||
|
endif # DEBUG
|
||||||
|
|
||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
build: $(BOOT_FILENAME)
|
||||||
|
|
||||||
|
$(BOOT_FILENAME): $(OBJ)
|
||||||
|
$(info Linking $@)
|
||||||
|
$(LD) -shared -Bsymbolic -L../gnu-efi/x86_64/lib -L../gnu-efi/x86_64/gnuefi -T../gnu-efi/gnuefi/elf_x86_64_efi.lds ../gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o $(OBJ) -o tmp.so -lgnuefi -lefi
|
||||||
|
objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --target efi-app-x86_64 --subsystem=10 tmp.so BOOTX64.EFI
|
||||||
|
rm tmp.so
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) -I../include -fpic -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) -I../include -fpic -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.s
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.psf
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
$(OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), i386)
|
||||||
|
$(OBJCOPY) -O elf32-i386 -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
$(OBJCOPY) -O elf32-littlearm -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
$(OBJCOPY) -O elf64-littleaarch64 -I binary $< $@
|
||||||
|
endif
|
||||||
|
$(NM) $@
|
||||||
|
|
||||||
|
%.o: %.bmp
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
$(OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), i386)
|
||||||
|
$(OBJCOPY) -O elf32-i386 -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), arm)
|
||||||
|
$(OBJCOPY) -O elf32-littlearm -I binary $< $@
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
$(OBJCOPY) -O elf64-littlearch64 -I binary $< $@
|
||||||
|
endif
|
||||||
|
$(NM) $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f kernel.map kernel_dump.map kernel_dump_intel.map $(OBJ) $(STACK_USAGE_OBJ) $(GCNO_OBJ) $(BOOT_FILENAME)
|
27
Bootloader/uefi/main.c
Normal file
27
Bootloader/uefi/main.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Lynx Bootloader.
|
||||||
|
|
||||||
|
Lynx Bootloader 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.
|
||||||
|
|
||||||
|
Lynx Bootloader 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 Lynx Bootloader. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <efi.h>
|
||||||
|
#include <efilib.h>
|
||||||
|
|
||||||
|
EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
||||||
|
{
|
||||||
|
InitializeLib(ImageHandle, SystemTable);
|
||||||
|
SystemTable->BootServices->SetWatchdogTimer(0, 0, 0, NULL);
|
||||||
|
Print(L"Lynx Bootloader © EnderIce2 2025\n");
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
13
Drivers/.editorconfig
Normal file
13
Drivers/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# EditorConfig is awesome: https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
15
Fennix Bootloader.code-workspace
Normal file
15
Fennix Bootloader.code-workspace
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "./Bootloader"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.cwd": "../",
|
||||||
|
"debug.allowBreakpointsEverywhere": true,
|
||||||
|
"git.alwaysSignOff": true,
|
||||||
|
"git.defaultBranchName": "master",
|
||||||
|
"git.openRepositoryInParentFolders": "always",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false
|
||||||
|
}
|
||||||
|
}
|
13
Kernel/.editorconfig
Normal file
13
Kernel/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# EditorConfig is awesome: https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
@ -1,36 +0,0 @@
|
|||||||
/* Based on this tutorial:
|
|
||||||
https://github.com/s-matyukevich/raspberry-pi-os */
|
|
||||||
|
|
||||||
.section ".text.boot", "a"
|
|
||||||
|
|
||||||
.extern _bss_start
|
|
||||||
.extern _bss_end
|
|
||||||
|
|
||||||
.extern arm64Entry
|
|
||||||
memzero:
|
|
||||||
str xzr, [x0], #8
|
|
||||||
subs x1, x1, #8
|
|
||||||
b.gt memzero
|
|
||||||
ret
|
|
||||||
|
|
||||||
.global _start
|
|
||||||
_start:
|
|
||||||
mrs x0, mpidr_el1
|
|
||||||
and x0, x0, #0xFF
|
|
||||||
cbz x0, _start2
|
|
||||||
b CPU_Loop
|
|
||||||
|
|
||||||
_start2:
|
|
||||||
adr x0, _bss_start
|
|
||||||
adr x1, _bss_end
|
|
||||||
sub x1, x1, x0
|
|
||||||
bl memzero
|
|
||||||
mov sp, #0x200000
|
|
||||||
bl arm64Entry
|
|
||||||
|
|
||||||
Halt:
|
|
||||||
wfe
|
|
||||||
b Halt
|
|
||||||
|
|
||||||
CPU_Loop:
|
|
||||||
b CPU_Loop
|
|
49
Kernel/arch/aarch64/bootstrap/raspi/boot.S
Normal file
49
Kernel/arch/aarch64/bootstrap/raspi/boot.S
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section ".bootstrap.boot", "a"
|
||||||
|
|
||||||
|
.extern _kernel_bss_start
|
||||||
|
.extern _kernel_bss_end
|
||||||
|
.extern _kernel_bss_size
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
/* Keep only the main core */
|
||||||
|
mrs x1, mpidr_el1
|
||||||
|
and x1, x1, #3
|
||||||
|
cbz x1, 2f
|
||||||
|
|
||||||
|
/* Halt */
|
||||||
|
1: wfe
|
||||||
|
b 1b
|
||||||
|
|
||||||
|
/* Initialize the stack */
|
||||||
|
2: ldr x1, =_start
|
||||||
|
mov sp, x1
|
||||||
|
|
||||||
|
/* Clear the BSS */
|
||||||
|
ldr x1, =_kernel_bss_start
|
||||||
|
ldr w2, =_kernel_bss_size
|
||||||
|
3: cbz w2, 4f
|
||||||
|
str xzr, [x1], #8
|
||||||
|
sub w2, w2, #1
|
||||||
|
cbnz w2, 3b
|
||||||
|
|
||||||
|
/* Start the kernel */
|
||||||
|
4: bl _aarch64_start
|
||||||
|
b 1b
|
44
Kernel/arch/aarch64/bootstrap/raspi/init.cpp
Normal file
44
Kernel/arch/aarch64/bootstrap/raspi/init.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
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 <cpu.hpp>
|
||||||
|
|
||||||
|
#include "../../../../kernel.h"
|
||||||
|
|
||||||
|
using namespace CPU::aarch64;
|
||||||
|
|
||||||
|
extern "C" __attribute__((section(".bootstrap.text"))) void _aarch64_start(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3)
|
||||||
|
{
|
||||||
|
MIDR_EL1 reg;
|
||||||
|
asmv("mrs %x0, midr_el1" : "=r"(reg.raw));
|
||||||
|
|
||||||
|
switch (reg.PartNum)
|
||||||
|
{
|
||||||
|
case 0xB76: /* Raspberry Pi 1 */
|
||||||
|
case 0xC07: /* Raspberry Pi 2 */
|
||||||
|
default: /* Unknown */
|
||||||
|
CPU::Stop();
|
||||||
|
case 0xD03: /* Raspberry Pi 3 */
|
||||||
|
break;
|
||||||
|
case 0xD08: /* Raspberry Pi 4 */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BootInfo *info = nullptr;
|
||||||
|
Entry(info);
|
||||||
|
}
|
46
Kernel/arch/aarch64/core/uart.cpp
Normal file
46
Kernel/arch/aarch64/core/uart.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 <uart.hpp>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
namespace UART
|
||||||
|
{
|
||||||
|
void Driver::DebugWrite(uint8_t Char)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Driver::DebugRead()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Driver::TTYWrite(uint8_t Char)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Driver::TTYRead()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::Driver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::~Driver() {}
|
||||||
|
}
|
@ -20,70 +20,104 @@ OUTPUT_ARCH(aarch64)
|
|||||||
|
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
||||||
|
PF_R = 0x4;
|
||||||
|
PF_W = 0x2;
|
||||||
|
PF_X = 0x1;
|
||||||
|
|
||||||
|
PHDRS
|
||||||
|
{
|
||||||
|
bootstrap PT_LOAD FLAGS( PF_R | PF_W /*| PF_X*/ );
|
||||||
|
text PT_LOAD FLAGS( PF_R | PF_X );
|
||||||
|
data PT_LOAD FLAGS( PF_R | PF_W );
|
||||||
|
rodata PT_LOAD FLAGS( PF_R );
|
||||||
|
bss PT_LOAD FLAGS( PF_R | PF_W );
|
||||||
|
}
|
||||||
|
|
||||||
|
KERNEL_VMA = 0x80000;
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
. = KERNEL_VMA;
|
||||||
_bootstrap_start = .;
|
_bootstrap_start = .;
|
||||||
.text.boot :
|
.bootstrap : AT(ADDR(.bootstrap) - KERNEL_VMA)
|
||||||
{
|
{
|
||||||
*(.text.boot)
|
*(.bootstrap.boot .bootstrap.boot.*)
|
||||||
. += CONSTANT(MAXPAGESIZE);
|
*(.bootstrap .bootstrap.*)
|
||||||
_bss_start = .;
|
} :bootstrap
|
||||||
*(.text.bss)
|
|
||||||
_bss_end = .;
|
|
||||||
}
|
|
||||||
_bootstrap_end = .;
|
_bootstrap_end = .;
|
||||||
|
|
||||||
_kernel_start = .;
|
_kernel_start = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
_kernel_text_start = .;
|
_kernel_text_start = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
.text :
|
.text ALIGN(CONSTANT(MAXPAGESIZE)) : AT(ADDR(.text) - KERNEL_VMA)
|
||||||
{
|
{
|
||||||
KEEP(*(.text.boot))
|
|
||||||
*(.text .text.*)
|
*(.text .text.*)
|
||||||
}
|
} :text
|
||||||
. = ALIGN(4096);
|
_kernel_text_end = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
_kernel_text_end = .;
|
|
||||||
|
|
||||||
_kernel_data_start = .;
|
_kernel_data_start = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
.data :
|
.data ALIGN(CONSTANT(MAXPAGESIZE)) : AT(ADDR(.data) - KERNEL_VMA)
|
||||||
{
|
{
|
||||||
*(.data .data.*)
|
*(.data .data.*)
|
||||||
}
|
} :data
|
||||||
. = ALIGN(4096);
|
|
||||||
_kernel_data_end = .;
|
|
||||||
|
|
||||||
_kernel_rodata_start = .;
|
.eh_frame : AT(ADDR(.eh_frame) - KERNEL_VMA) ONLY_IF_RW
|
||||||
.rodata :
|
{
|
||||||
|
KEEP (*(.eh_frame .eh_frame.*))
|
||||||
|
} :data
|
||||||
|
|
||||||
|
.gcc_except_table : AT(ADDR(.gcc_except_table) - KERNEL_VMA) ONLY_IF_RW
|
||||||
|
{
|
||||||
|
KEEP (*(.gcc_except_table .gcc_except_table.*))
|
||||||
|
} :data
|
||||||
|
_kernel_data_end = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
|
||||||
|
_kernel_rodata_start = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
.rodata ALIGN(CONSTANT(MAXPAGESIZE)) : AT(ADDR(.rodata) - KERNEL_VMA)
|
||||||
{
|
{
|
||||||
*(.rodata .rodata.*)
|
*(.rodata .rodata.*)
|
||||||
}
|
} :rodata
|
||||||
. = ALIGN(4096);
|
|
||||||
|
|
||||||
.init_array :
|
.init_array ALIGN(CONSTANT(MAXPAGESIZE)) : AT(ADDR(.init_array) - KERNEL_VMA)
|
||||||
{
|
{
|
||||||
PROVIDE_HIDDEN(__init_array_start = .);
|
PROVIDE_HIDDEN(__init_array_start = .);
|
||||||
KEEP(*(.init_array .ctors))
|
KEEP(*(.init_array .ctors))
|
||||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||||
PROVIDE_HIDDEN (__init_array_end = .);
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
}
|
} :rodata
|
||||||
|
|
||||||
.fini_array :
|
.fini_array ALIGN(CONSTANT(MAXPAGESIZE)) : AT(ADDR(.fini_array) - KERNEL_VMA)
|
||||||
{
|
{
|
||||||
PROVIDE_HIDDEN(__fini_array_start = .);
|
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||||
KEEP(*(.fini_array .dtors))
|
KEEP(*(.fini_array .dtors))
|
||||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
}
|
} :rodata
|
||||||
_kernel_rodata_end = .;
|
|
||||||
|
|
||||||
_kernel_bss_start = .;
|
.eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - KERNEL_VMA)
|
||||||
.bss :
|
|
||||||
{
|
{
|
||||||
|
*(.eh_frame_hdr .eh_frame_hdr.*)
|
||||||
|
} :rodata
|
||||||
|
|
||||||
|
.eh_frame : AT(ADDR(.eh_frame) - KERNEL_VMA) ONLY_IF_RO
|
||||||
|
{
|
||||||
|
KEEP (*(.eh_frame .eh_frame.*))
|
||||||
|
} :rodata
|
||||||
|
|
||||||
|
.gcc_except_table : AT(ADDR(.gcc_except_table) - KERNEL_VMA) ONLY_IF_RO
|
||||||
|
{
|
||||||
|
KEEP (*(.gcc_except_table .gcc_except_table.*))
|
||||||
|
} :rodata
|
||||||
|
_kernel_rodata_end = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
|
||||||
|
_kernel_bss_start = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
.bss ALIGN(CONSTANT(MAXPAGESIZE)) : AT(ADDR(.bss) - KERNEL_VMA)
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
*(.bss .bss.*)
|
*(.bss .bss.*)
|
||||||
}
|
} :bss
|
||||||
. = ALIGN(4096);
|
_kernel_bss_end = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
_kernel_bss_end = .;
|
_kernel_bss_size = _kernel_bss_end - _kernel_bss_start;
|
||||||
_kernel_end = .;
|
_kernel_end = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
_bss_size = _kernel_end - _kernel_rodata_end;
|
|
||||||
|
|
||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
|
@ -45,53 +45,40 @@ namespace UART
|
|||||||
{
|
{
|
||||||
if (!DebugAvailable)
|
if (!DebugAvailable)
|
||||||
return;
|
return;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
while ((inb(s_cst(uint16_t, COM1 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
while ((inb(s_cst(uint16_t, COM1 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
||||||
;
|
;
|
||||||
outb(COM1, Char);
|
outb(COM1, Char);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Driver::DebugRead()
|
uint8_t Driver::DebugRead()
|
||||||
{
|
{
|
||||||
if (!DebugAvailable)
|
if (!DebugAvailable)
|
||||||
return 0;
|
return 0;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Driver::TTYWrite(uint8_t Char)
|
void Driver::TTYWrite(uint8_t Char)
|
||||||
{
|
{
|
||||||
if (!TTYAvailable)
|
if (!TTYAvailable)
|
||||||
return;
|
return;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
while ((inb(s_cst(uint16_t, COM4 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
while ((inb(s_cst(uint16_t, COM4 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
||||||
;
|
;
|
||||||
outb(COM4, Char);
|
outb(COM4, Char);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Driver::TTYRead()
|
uint8_t Driver::TTYRead()
|
||||||
{
|
{
|
||||||
if (!TTYAvailable)
|
if (!TTYAvailable)
|
||||||
return 0;
|
return 0;
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Driver::Driver()
|
Driver::Driver()
|
||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
auto initPort = [](uint16_t Port)
|
auto initPort = [](uint16_t Port)
|
||||||
{
|
{
|
||||||
// Initialize the serial port
|
// Initialize the serial port
|
||||||
@ -133,7 +120,6 @@ namespace UART
|
|||||||
initPort(COM4);
|
initPort(COM4);
|
||||||
TTYAvailable = true;
|
TTYAvailable = true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Driver::~Driver() {}
|
Driver::~Driver() {}
|
46
Kernel/arch/arm/core/uart.cpp
Normal file
46
Kernel/arch/arm/core/uart.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 <uart.hpp>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
namespace UART
|
||||||
|
{
|
||||||
|
void Driver::DebugWrite(uint8_t Char)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Driver::DebugRead()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Driver::TTYWrite(uint8_t Char)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Driver::TTYRead()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::Driver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::~Driver() {}
|
||||||
|
}
|
126
Kernel/arch/i386/core/uart.cpp
Normal file
126
Kernel/arch/i386/core/uart.cpp
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
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 <uart.hpp>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
namespace UART
|
||||||
|
{
|
||||||
|
enum SerialPorts
|
||||||
|
{
|
||||||
|
COM1 = 0x3F8,
|
||||||
|
COM2 = 0x2F8,
|
||||||
|
COM3 = 0x3E8,
|
||||||
|
COM4 = 0x2E8,
|
||||||
|
COM5 = 0x5F8,
|
||||||
|
COM6 = 0x4F8,
|
||||||
|
COM7 = 0x5E8,
|
||||||
|
COM8 = 0x4E8
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SERIAL_ENABLE_DLAB 0x80
|
||||||
|
#define SERIAL_RATE_115200_LO 0x01
|
||||||
|
#define SERIAL_RATE_115200_HI 0x00
|
||||||
|
#define SERIAL_RATE_57600_LO 0x02
|
||||||
|
#define SERIAL_RATE_57600_HI 0x00
|
||||||
|
#define SERIAL_RATE_38400_LO 0x03
|
||||||
|
#define SERIAL_RATE_38400_HI 0x00
|
||||||
|
#define SERIAL_BUFFER_EMPTY 0x20
|
||||||
|
|
||||||
|
void Driver::DebugWrite(uint8_t Char)
|
||||||
|
{
|
||||||
|
if (!DebugAvailable)
|
||||||
|
return;
|
||||||
|
while ((inb(s_cst(uint16_t, COM1 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
||||||
|
;
|
||||||
|
outb(COM1, Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Driver::DebugRead()
|
||||||
|
{
|
||||||
|
if (!DebugAvailable)
|
||||||
|
return 0;
|
||||||
|
while ((inb(s_cst(uint16_t, COM1 + 5)) & 1) == 0)
|
||||||
|
;
|
||||||
|
return inb(COM1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Driver::TTYWrite(uint8_t Char)
|
||||||
|
{
|
||||||
|
if (!TTYAvailable)
|
||||||
|
return;
|
||||||
|
while ((inb(s_cst(uint16_t, COM4 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
||||||
|
;
|
||||||
|
outb(COM4, Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Driver::TTYRead()
|
||||||
|
{
|
||||||
|
if (!TTYAvailable)
|
||||||
|
return 0;
|
||||||
|
while ((inb(s_cst(uint16_t, COM4 + 5)) & 1) == 0)
|
||||||
|
;
|
||||||
|
return inb(COM4);
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::Driver()
|
||||||
|
{
|
||||||
|
auto initPort = [](uint16_t Port)
|
||||||
|
{
|
||||||
|
// Initialize the serial port
|
||||||
|
outb(s_cst(uint16_t, Port + 1), 0x00); // Disable all interrupts
|
||||||
|
outb(s_cst(uint16_t, Port + 3), SERIAL_ENABLE_DLAB); // Enable DLAB (set baud rate divisor)
|
||||||
|
outb(s_cst(uint16_t, Port + 0), SERIAL_RATE_115200_LO); // Set divisor to 1 (lo byte) 115200 baud
|
||||||
|
outb(s_cst(uint16_t, Port + 1), SERIAL_RATE_115200_HI); // (hi byte)
|
||||||
|
outb(s_cst(uint16_t, Port + 3), 0x03); // 8 bits, no parity, one stop bit
|
||||||
|
outb(s_cst(uint16_t, Port + 2), 0xC7); // Enable FIFO, clear them, with 14-byte threshold
|
||||||
|
outb(s_cst(uint16_t, Port + 4), 0x0B); // IRQs enabled, RTS/DSR set
|
||||||
|
|
||||||
|
/* FIXME https://wiki.osdev.org/Serial_Ports */
|
||||||
|
// outb(s_cst(uint16_t, Port + 0), 0x1E);
|
||||||
|
// outb(s_cst(uint16_t, Port + 0), 0xAE);
|
||||||
|
// Check if the serial port is faulty.
|
||||||
|
// if (inb(s_cst(uint16_t, Port + 0)) != 0xAE)
|
||||||
|
// {
|
||||||
|
// static int once = 0;
|
||||||
|
// if (!once++)
|
||||||
|
// warn("Serial port %#lx is faulty.", Port);
|
||||||
|
// // serialports[Port] = false; // ignore for now
|
||||||
|
// // return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Set to normal operation mode.
|
||||||
|
outb(s_cst(uint16_t, Port + 4), 0x0F);
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t com = inb(COM1);
|
||||||
|
if (com != 0xFF)
|
||||||
|
{
|
||||||
|
initPort(COM1);
|
||||||
|
DebugAvailable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
com = inb(COM4);
|
||||||
|
if (com != 0xFF)
|
||||||
|
{
|
||||||
|
initPort(COM4);
|
||||||
|
TTYAvailable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::~Driver() {}
|
||||||
|
}
|
@ -179,7 +179,7 @@ namespace CPU
|
|||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("hlt");
|
asmv("hlt");
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
asmv("wfe");
|
asmv("wfi");
|
||||||
#endif
|
#endif
|
||||||
} while (Loop);
|
} while (Loop);
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ namespace CPU
|
|||||||
uint32_t ID : 1;
|
uint32_t ID : 1;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} EFLAGS;
|
} __packed EFLAGS;
|
||||||
|
|
||||||
struct TrapFrame
|
struct TrapFrame
|
||||||
{
|
{
|
||||||
@ -343,7 +343,7 @@ namespace CPU
|
|||||||
EFLAGS eflags; /* Register Flags */
|
EFLAGS eflags; /* Register Flags */
|
||||||
uint32_t esp; /* Stack Pointer */
|
uint32_t esp; /* Stack Pointer */
|
||||||
uint32_t ss; /* Stack Segment */
|
uint32_t ss; /* Stack Segment */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct SchedulerFrame
|
struct SchedulerFrame
|
||||||
{
|
{
|
||||||
@ -366,7 +366,7 @@ namespace CPU
|
|||||||
EFLAGS eflags; /* Register Flags */
|
EFLAGS eflags; /* Register Flags */
|
||||||
uint32_t esp; /* Stack Pointer */
|
uint32_t esp; /* Stack Pointer */
|
||||||
uint32_t ss; /* Stack Segment */
|
uint32_t ss; /* Stack Segment */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct ExceptionFrame
|
struct ExceptionFrame
|
||||||
{
|
{
|
||||||
@ -404,7 +404,7 @@ namespace CPU
|
|||||||
EFLAGS eflags; /* Register Flags */
|
EFLAGS eflags; /* Register Flags */
|
||||||
uint32_t esp; /* Stack Pointer */
|
uint32_t esp; /* Stack Pointer */
|
||||||
uint32_t ss; /* Stack Segment */
|
uint32_t ss; /* Stack Segment */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
typedef union DR6
|
typedef union DR6
|
||||||
{
|
{
|
||||||
@ -432,7 +432,7 @@ namespace CPU
|
|||||||
uint32_t Reserved2 : 15;
|
uint32_t Reserved2 : 15;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} DR6;
|
} __packed DR6;
|
||||||
|
|
||||||
typedef union DR7
|
typedef union DR7
|
||||||
{
|
{
|
||||||
@ -484,7 +484,7 @@ namespace CPU
|
|||||||
uint32_t LEN3 : 2;
|
uint32_t LEN3 : 2;
|
||||||
};
|
};
|
||||||
uint32_t raw;
|
uint32_t raw;
|
||||||
} DR7;
|
} __packed DR7;
|
||||||
|
|
||||||
struct FXState
|
struct FXState
|
||||||
{
|
{
|
||||||
@ -702,7 +702,7 @@ namespace CPU
|
|||||||
uint64_t Reserved3 : 10;
|
uint64_t Reserved3 : 10;
|
||||||
};
|
};
|
||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} RFLAGS;
|
} __packed RFLAGS;
|
||||||
|
|
||||||
struct TrapFrame
|
struct TrapFrame
|
||||||
{
|
{
|
||||||
@ -731,7 +731,7 @@ namespace CPU
|
|||||||
RFLAGS rflags; /* Register Flags */
|
RFLAGS rflags; /* Register Flags */
|
||||||
uint64_t rsp; /* Stack Pointer */
|
uint64_t rsp; /* Stack Pointer */
|
||||||
uint64_t ss; /* Stack Segment */
|
uint64_t ss; /* Stack Segment */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct SchedulerFrame
|
struct SchedulerFrame
|
||||||
{
|
{
|
||||||
@ -763,7 +763,7 @@ namespace CPU
|
|||||||
RFLAGS rflags; /* Register Flags */
|
RFLAGS rflags; /* Register Flags */
|
||||||
uint64_t rsp; /* Stack Pointer */
|
uint64_t rsp; /* Stack Pointer */
|
||||||
uint64_t ss; /* Stack Segment */
|
uint64_t ss; /* Stack Segment */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct ExceptionFrame
|
struct ExceptionFrame
|
||||||
{
|
{
|
||||||
@ -810,7 +810,7 @@ namespace CPU
|
|||||||
RFLAGS rflags; /* Register Flags */
|
RFLAGS rflags; /* Register Flags */
|
||||||
uint64_t rsp; /* Stack Pointer */
|
uint64_t rsp; /* Stack Pointer */
|
||||||
uint64_t ss; /* Stack Segment */
|
uint64_t ss; /* Stack Segment */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
typedef union EFER
|
typedef union EFER
|
||||||
{
|
{
|
||||||
@ -1093,7 +1093,7 @@ namespace CPU
|
|||||||
uint32_t LR; /* Link Register (R14) */
|
uint32_t LR; /* Link Register (R14) */
|
||||||
uint32_t PC; /* Program Counter (R15) */
|
uint32_t PC; /* Program Counter (R15) */
|
||||||
uint32_t CPSR; /* Current Program Status Register */
|
uint32_t CPSR; /* Current Program Status Register */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct SchedulerFrame
|
struct SchedulerFrame
|
||||||
{
|
{
|
||||||
@ -1114,7 +1114,7 @@ namespace CPU
|
|||||||
uint32_t LR; /* Link Register (R14) */
|
uint32_t LR; /* Link Register (R14) */
|
||||||
uint32_t PC; /* Program Counter (R15) */
|
uint32_t PC; /* Program Counter (R15) */
|
||||||
uint32_t CPSR; /* Current Program Status Register */
|
uint32_t CPSR; /* Current Program Status Register */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct ExceptionFrame
|
struct ExceptionFrame
|
||||||
{
|
{
|
||||||
@ -1135,11 +1135,53 @@ namespace CPU
|
|||||||
uint32_t LR; /* Link Register (R14) */
|
uint32_t LR; /* Link Register (R14) */
|
||||||
uint32_t PC; /* Program Counter (R15) */
|
uint32_t PC; /* Program Counter (R15) */
|
||||||
uint32_t CPSR; /* Current Program Status Register */
|
uint32_t CPSR; /* Current Program Status Register */
|
||||||
};
|
} __packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace aarch64
|
namespace aarch64
|
||||||
{
|
{
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint64_t Revision : 4;
|
||||||
|
uint64_t PartNum : 12;
|
||||||
|
uint64_t Architecture : 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0b0001 Armv4.
|
||||||
|
* 0b0010 Armv4T.
|
||||||
|
* 0b0011 Armv5 (obsolete).
|
||||||
|
* 0b0100 Armv5T.
|
||||||
|
* 0b0101 Armv5TE.
|
||||||
|
* 0b0110 Armv5TEJ.
|
||||||
|
* 0b0111 Armv6.
|
||||||
|
* 0b1111 Architectural features are individually identified in the ID_* registers.
|
||||||
|
*/
|
||||||
|
uint64_t Variant : 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0x00 Reserved for software use.
|
||||||
|
* 0x41 Arm Limited.
|
||||||
|
* 0x42 Broadcom Corporation.
|
||||||
|
* 0x43 Cavium Inc.
|
||||||
|
* 0x44 Digital Equipment Corporation.
|
||||||
|
* 0x46 Fujitsu Ltd.
|
||||||
|
* 0x49 Infineon Technologies AG.
|
||||||
|
* 0x4D Motorola or Freescale Semiconductor Inc.
|
||||||
|
* 0x4E NVIDIA Corporation.
|
||||||
|
* 0x50 Applied Micro Circuits Corporation.
|
||||||
|
* 0x51 Qualcomm Inc.
|
||||||
|
* 0x56 Marvell International Ltd.
|
||||||
|
* 0x69 Intel Corporation.
|
||||||
|
* 0xC0 Ampere Computing.
|
||||||
|
*/
|
||||||
|
uint64_t Implementer : 8;
|
||||||
|
uint64_t RES0 : 32;
|
||||||
|
};
|
||||||
|
uint64_t raw;
|
||||||
|
} __packed MIDR_EL1;
|
||||||
|
|
||||||
struct TrapFrame
|
struct TrapFrame
|
||||||
{
|
{
|
||||||
uint64_t x[31];
|
uint64_t x[31];
|
||||||
@ -1148,7 +1190,7 @@ namespace CPU
|
|||||||
uint64_t ESR; /* Exception Syndrome Register */
|
uint64_t ESR; /* Exception Syndrome Register */
|
||||||
uint64_t FAR; /* Fault Address Register */
|
uint64_t FAR; /* Fault Address Register */
|
||||||
uint64_t SPSR; /* Saved Program Status Register */
|
uint64_t SPSR; /* Saved Program Status Register */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct SchedulerFrame
|
struct SchedulerFrame
|
||||||
{
|
{
|
||||||
@ -1158,7 +1200,7 @@ namespace CPU
|
|||||||
uint64_t ESR; /* Exception Syndrome Register */
|
uint64_t ESR; /* Exception Syndrome Register */
|
||||||
uint64_t FAR; /* Fault Address Register */
|
uint64_t FAR; /* Fault Address Register */
|
||||||
uint64_t SPSR; /* Saved Program Status Register */
|
uint64_t SPSR; /* Saved Program Status Register */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct ExceptionFrame
|
struct ExceptionFrame
|
||||||
{
|
{
|
||||||
@ -1168,7 +1210,7 @@ namespace CPU
|
|||||||
uint64_t ESR; /* Exception Syndrome Register */
|
uint64_t ESR; /* Exception Syndrome Register */
|
||||||
uint64_t FAR; /* Fault Address Register */
|
uint64_t FAR; /* Fault Address Register */
|
||||||
uint64_t SPSR; /* Saved Program Status Register */
|
uint64_t SPSR; /* Saved Program Status Register */
|
||||||
};
|
} __packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
|
44
Makefile
44
Makefile
@ -76,9 +76,9 @@ QEMUFLAGS += -M raspi2b \
|
|||||||
-serial stdio \
|
-serial stdio \
|
||||||
-kernel $(OSNAME).img
|
-kernel $(OSNAME).img
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
QEMUFLAGS += -M raspi3b \
|
QEMUFLAGS += -M raspi4b \
|
||||||
-monitor pty \
|
-monitor pty \
|
||||||
-cpu cortex-a57 \
|
-cpu cortex-a72 \
|
||||||
-serial file:serial.log \
|
-serial file:serial.log \
|
||||||
-serial file:COM2.dmp \
|
-serial file:COM2.dmp \
|
||||||
-serial file:COM3.dmp \
|
-serial file:COM3.dmp \
|
||||||
@ -101,13 +101,17 @@ endif
|
|||||||
tools:
|
tools:
|
||||||
make --quiet -C tools all
|
make --quiet -C tools all
|
||||||
|
|
||||||
setup:
|
prepare:
|
||||||
make --quiet -C Kernel prepare
|
make --quiet -C Kernel prepare
|
||||||
|
make --quiet -C Bootloader prepare
|
||||||
make --quiet -C Drivers prepare
|
make --quiet -C Drivers prepare
|
||||||
make --quiet -C Userspace prepare
|
make --quiet -C Userspace prepare
|
||||||
|
|
||||||
|
setup:
|
||||||
|
$(MAKE) prepare
|
||||||
$(MAKE) tools
|
$(MAKE) tools
|
||||||
|
|
||||||
build: build_kernel build_userspace build_drivers build_image
|
build: build_kernel build_bootloader build_userspace build_drivers build_image
|
||||||
|
|
||||||
dump:
|
dump:
|
||||||
make --quiet -C Kernel dump
|
make --quiet -C Kernel dump
|
||||||
@ -123,9 +127,9 @@ ifeq ($(BUILD_KERNEL), 1)
|
|||||||
make -j$(shell nproc) $(MAKE_QUIET_FLAG) -C Kernel build
|
make -j$(shell nproc) $(MAKE_QUIET_FLAG) -C Kernel build
|
||||||
endif
|
endif
|
||||||
|
|
||||||
build_userspace:
|
build_bootloader:
|
||||||
ifeq ($(BUILD_USERSPACE), 1)
|
ifeq ($(BUILD_BOOTLOADER), 1)
|
||||||
make $(MAKE_QUIET_FLAG) -C Userspace build
|
make $(MAKE_QUIET_FLAG) -C Bootloader build
|
||||||
endif
|
endif
|
||||||
|
|
||||||
build_drivers:
|
build_drivers:
|
||||||
@ -133,6 +137,11 @@ ifeq ($(BUILD_DRIVERS), 1)
|
|||||||
make $(MAKE_QUIET_FLAG) -C Drivers build
|
make $(MAKE_QUIET_FLAG) -C Drivers build
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
build_userspace:
|
||||||
|
ifeq ($(BUILD_USERSPACE), 1)
|
||||||
|
make $(MAKE_QUIET_FLAG) -C Userspace build
|
||||||
|
endif
|
||||||
|
|
||||||
build_image:
|
build_image:
|
||||||
mkdir -p iso_tmp_data
|
mkdir -p iso_tmp_data
|
||||||
mkdir -p initrd_tmp_data
|
mkdir -p initrd_tmp_data
|
||||||
@ -171,6 +180,7 @@ ifeq ($(BOOTLOADER), grub)
|
|||||||
endif
|
endif
|
||||||
ifneq ($(filter aarch64 arm,$(OSARCH)),)
|
ifneq ($(filter aarch64 arm,$(OSARCH)),)
|
||||||
$(__CONF_OBJCOPY) Kernel/fennix.elf -O binary $(OSNAME).img
|
$(__CONF_OBJCOPY) Kernel/fennix.elf -O binary $(OSNAME).img
|
||||||
|
# cp Bootloader/boot.bin $(OSNAME).img
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
@ -199,15 +209,23 @@ endif
|
|||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
QEMUHWACCELERATION = -machine q35 -enable-kvm
|
QEMUHWACCELERATION = -machine q35 -enable-kvm
|
||||||
QEMUMEMORY = -m 4G
|
QEMUMEMORY = -m 4G
|
||||||
|
QEMU_DBG_SMP = -smp 1
|
||||||
|
QEMU_DBG_MEMORY = -m 512M
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
QEMUHWACCELERATION = -machine q35 -enable-kvm
|
QEMUHWACCELERATION = -machine q35 -enable-kvm
|
||||||
QEMUMEMORY = -m 4G
|
QEMUMEMORY = -m 4G
|
||||||
|
QEMU_DBG_SMP = -smp 1
|
||||||
|
QEMU_DBG_MEMORY = -m 512M
|
||||||
else ifeq ($(OSARCH), arm)
|
else ifeq ($(OSARCH), arm)
|
||||||
QEMUHWACCELERATION =
|
QEMUHWACCELERATION =
|
||||||
QEMUMEMORY = -m 1G
|
QEMUMEMORY = -m 1G
|
||||||
|
QEMU_DBG_SMP = -smp 1
|
||||||
|
QEMU_DBG_MEMORY = -m 512M
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
QEMUHWACCELERATION =
|
QEMUHWACCELERATION =
|
||||||
QEMUMEMORY = -m 1G
|
QEMUMEMORY = -m 2G
|
||||||
|
QEMU_DBG_SMP = -smp 4
|
||||||
|
QEMU_DBG_MEMORY = -m 2G
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean_logs:
|
clean_logs:
|
||||||
@ -217,10 +235,17 @@ clean_logs:
|
|||||||
mouse.pcap kbd.pcap mousex.pcap kbdx.pcap
|
mouse.pcap kbd.pcap mousex.pcap kbdx.pcap
|
||||||
|
|
||||||
vscode_debug_only: clean_logs
|
vscode_debug_only: clean_logs
|
||||||
|
ifneq ($(filter arm aarch64,$(OSARCH)),)
|
||||||
|
$(QEMU) -S -chardev socket,path=/tmp/gdb-fennix,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 \
|
||||||
|
-d cpu_reset,int,unimp,guest_errors,mmu,fpu \
|
||||||
|
-no-reboot -no-shutdown \
|
||||||
|
$(QEMU_DBG_MEMORY) $(QEMUFLAGS) $(QEMU_DBG_SMP)
|
||||||
|
else
|
||||||
$(QEMU) -S -chardev socket,path=/tmp/gdb-fennix,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 \
|
$(QEMU) -S -chardev socket,path=/tmp/gdb-fennix,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 \
|
||||||
-d cpu_reset,int,unimp,guest_errors,mmu,fpu \
|
-d cpu_reset,int,unimp,guest_errors,mmu,fpu \
|
||||||
-no-reboot -no-shutdown $(QEMU_UEFI_BIOS) \
|
-no-reboot -no-shutdown $(QEMU_UEFI_BIOS) \
|
||||||
-m 512M $(QEMUFLAGS) -smp 1
|
$(QEMU_DBG_MEMORY) $(QEMUFLAGS) $(QEMU_DBG_SMP)
|
||||||
|
endif
|
||||||
|
|
||||||
vscode_debug: build_kernel build_userspace build_drivers build_image vscode_debug_only
|
vscode_debug: build_kernel build_userspace build_drivers build_image vscode_debug_only
|
||||||
|
|
||||||
@ -240,3 +265,4 @@ clean: clean_logs
|
|||||||
make -C Kernel clean
|
make -C Kernel clean
|
||||||
make -C Userspace clean
|
make -C Userspace clean
|
||||||
make -C Drivers clean
|
make -C Drivers clean
|
||||||
|
make -C Bootloader clean
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
> [!CAUTION]
|
> [!CAUTION]
|
||||||
> The project is still in development and is not yet ready for production use.
|
> The project is still in development and is not yet ready for production use.
|
||||||
|
>
|
||||||
> Please use a virtual machine to run the OS.
|
> Please use a virtual machine to run the OS.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
13
Userspace/.editorconfig
Normal file
13
Userspace/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# EditorConfig is awesome: https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
34
config.mk
34
config.mk
@ -8,16 +8,26 @@ OSNAME = Fennix
|
|||||||
# OS architecture, check AVAILABLE_ARCHS for available options.
|
# OS architecture, check AVAILABLE_ARCHS for available options.
|
||||||
OSARCH = amd64
|
OSARCH = amd64
|
||||||
|
|
||||||
|
# This variable specifies the board type.
|
||||||
|
# It is crucial because the ARM booting process differs significantly from x86.
|
||||||
|
#
|
||||||
|
# ! This variable is ignored on x86 !
|
||||||
|
#
|
||||||
|
# Available options are in AVAILABLE_BOARDS.
|
||||||
|
BOARD_TYPE := raspi4
|
||||||
|
|
||||||
# Kernel version.
|
# Kernel version.
|
||||||
KERNEL_VERSION = dev
|
KERNEL_VERSION = dev
|
||||||
|
|
||||||
# Which bootloader to use.
|
# Which bootloader to use.
|
||||||
# Available bootloaders:
|
# Available bootloaders:
|
||||||
|
# - builtin - Built-in
|
||||||
# - grub - GRUB
|
# - grub - GRUB
|
||||||
# - limine - Limine
|
# - limine - Limine
|
||||||
BOOTLOADER = grub
|
BOOTLOADER = grub
|
||||||
|
|
||||||
BUILD_KERNEL = 1
|
BUILD_KERNEL = 1
|
||||||
|
BUILD_BOOTLOADER = 1
|
||||||
BUILD_USERSPACE = 1
|
BUILD_USERSPACE = 1
|
||||||
BUILD_DRIVERS = 1
|
BUILD_DRIVERS = 1
|
||||||
|
|
||||||
@ -35,10 +45,6 @@ COMPILER_PATH := $(CURDIR)/tools/cross
|
|||||||
# Default: $(CURDIR)/tools/cross
|
# Default: $(CURDIR)/tools/cross
|
||||||
__CONF_QEMU_PATH := $(CURDIR)/tools/cross
|
__CONF_QEMU_PATH := $(CURDIR)/tools/cross
|
||||||
|
|
||||||
# Set libc to use. Available options:
|
|
||||||
# - internal - Use the internal libc
|
|
||||||
USE_LIBC = internal
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -56,10 +62,24 @@ USE_LIBC = internal
|
|||||||
# Available architectures. Do not change
|
# Available architectures. Do not change
|
||||||
export AVAILABLE_ARCHS := amd64 i386 arm aarch64
|
export AVAILABLE_ARCHS := amd64 i386 arm aarch64
|
||||||
|
|
||||||
|
# Available board types. Do not change
|
||||||
|
export AVAILABLE_BOARDS := \
|
||||||
|
raspi0 \
|
||||||
|
raspi1 \
|
||||||
|
raspi2 \
|
||||||
|
raspi3 \
|
||||||
|
raspi4
|
||||||
|
|
||||||
ifneq ($(filter $(OSARCH),$(AVAILABLE_ARCHS)),$(OSARCH))
|
ifneq ($(filter $(OSARCH),$(AVAILABLE_ARCHS)),$(OSARCH))
|
||||||
$(error OSARCH=$(OSARCH) is not a supported architecture. Choose one of: $(AVAILABLE_ARCHS))
|
$(error OSARCH=$(OSARCH) is not a supported architecture. Choose one of: $(AVAILABLE_ARCHS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(filter amd64 i386,$(OSARCH)),)
|
||||||
|
ifneq ($(filter $(BOARD_TYPE),$(AVAILABLE_BOARDS)),$(BOARD_TYPE))
|
||||||
|
$(error BOARD_TYPE=$(BOARD_TYPE) is not a supported board type. Choose one of: $(AVAILABLE_BOARDS))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ARCH_MAP := amd64=x86_64 i386=i386 arm=arm aarch64=aarch64
|
ARCH_MAP := amd64=x86_64 i386=i386 arm=arm aarch64=aarch64
|
||||||
COMPILER_ARCH := $(patsubst $(OSARCH)=%,%,$(filter $(OSARCH)=%,$(ARCH_MAP)))
|
COMPILER_ARCH := $(patsubst $(OSARCH)=%,%,$(filter $(OSARCH)=%,$(ARCH_MAP)))
|
||||||
__CONF_QEMU_PATH := $(__CONF_QEMU_PATH)/bin/qemu-system-$(COMPILER_ARCH)
|
__CONF_QEMU_PATH := $(__CONF_QEMU_PATH)/bin/qemu-system-$(COMPILER_ARCH)
|
||||||
@ -78,4 +98,10 @@ export __CONF_GDB := $(TOOLCHAIN_PREFIX)gdb
|
|||||||
export DEBUG
|
export DEBUG
|
||||||
export OSNAME
|
export OSNAME
|
||||||
export OSARCH
|
export OSARCH
|
||||||
|
export BOARD_TYPE
|
||||||
export KERNEL_VERSION
|
export KERNEL_VERSION
|
||||||
|
|
||||||
|
export TOOLCHAIN_AMD64_PREFIX := $(COMPILER_PATH)/bin/x86_64-fennix-
|
||||||
|
export TOOLCHAIN_I386_PREFIX := $(COMPILER_PATH)/bin/i386-fennix-
|
||||||
|
export TOOLCHAIN_ARM_PREFIX := $(COMPILER_PATH)/bin/arm-fennix-
|
||||||
|
export TOOLCHAIN_AARCH64_PREFIX := $(COMPILER_PATH)/bin/aarch64-fennix-
|
||||||
|
12
tools/.gitignore
vendored
Normal file
12
tools/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
*
|
||||||
|
!/acpi
|
||||||
|
!/doxygen
|
||||||
|
!/website
|
||||||
|
!/Makefile
|
||||||
|
!/.gdbinit
|
||||||
|
!/*.c
|
||||||
|
!/*.cpp
|
||||||
|
!/*.cfg
|
||||||
|
!/*.md
|
||||||
|
!/*.patch
|
||||||
|
!/*.gitignore
|
@ -5,6 +5,7 @@ export PATH := $(CROSS_DIR):$(PATH)
|
|||||||
BINUTILS_TAG = binutils-2_43_1
|
BINUTILS_TAG = binutils-2_43_1
|
||||||
GCC_TAG = releases/gcc-14.2.0
|
GCC_TAG = releases/gcc-14.2.0
|
||||||
QEMU_TAG = v9.2.0
|
QEMU_TAG = v9.2.0
|
||||||
|
GRUB_TAG = grub-2.12
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$(error Please specify a target)
|
$(error Please specify a target)
|
||||||
@ -68,6 +69,18 @@ else
|
|||||||
$(info > TOOLS: Operation completed for gcc)
|
$(info > TOOLS: Operation completed for gcc)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
__clone_grub:
|
||||||
|
ifeq ("$(wildcard ./grub)", "")
|
||||||
|
git clone --depth 1 -b $(GRUB_TAG) https://git.savannah.gnu.org/git/grub.git grub
|
||||||
|
else
|
||||||
|
$(info > TOOLS: Reseting grub...)
|
||||||
|
cd grub && \
|
||||||
|
git fetch origin && \
|
||||||
|
git reset --hard $(GRUB_TAG) && \
|
||||||
|
git clean -dfx
|
||||||
|
$(info > TOOLS: Operation completed for grub)
|
||||||
|
endif
|
||||||
|
|
||||||
__patch_cross_binutils: __clone_binutils
|
__patch_cross_binutils: __clone_binutils
|
||||||
$(info > TOOLS: Patching binutils-gcc)
|
$(info > TOOLS: Patching binutils-gcc)
|
||||||
cd binutils-gdb && git apply ../binutils-gdb.patch
|
cd binutils-gdb && git apply ../binutils-gdb.patch
|
||||||
@ -81,18 +94,22 @@ __patch_cross_gcc: __clone_gcc
|
|||||||
$(info > TOOLS: Running autoconf for gcc/libstdc++-v3)
|
$(info > TOOLS: Running autoconf for gcc/libstdc++-v3)
|
||||||
cd gcc/libstdc++-v3 && autoconf
|
cd gcc/libstdc++-v3 && autoconf
|
||||||
|
|
||||||
|
__patch_cross_grub: __clone_grub
|
||||||
|
$(info > TOOLS: Patching grub)
|
||||||
|
cd grub && git apply ../grub.patch
|
||||||
|
|
||||||
__patch_cross_qemu: __clone_qemu
|
__patch_cross_qemu: __clone_qemu
|
||||||
$(info > TOOLS: Patching qemu)
|
$(info > TOOLS: Patching qemu)
|
||||||
cd qemu && git apply ../qemu.patch
|
cd qemu && git apply ../qemu.patch
|
||||||
|
|
||||||
__patch_cross: __patch_cross_binutils __patch_cross_gcc
|
__patch_cross: __patch_cross_binutils __patch_cross_gcc __patch_cross_grub
|
||||||
|
|
||||||
__prep_cross:
|
__prep_cross:
|
||||||
mkdir -p cross
|
mkdir -p cross
|
||||||
mkdir -p binutils-gdb/__build
|
mkdir -p binutils-gdb/__build
|
||||||
mkdir -p gcc/__build
|
mkdir -p gcc/__build
|
||||||
|
|
||||||
__clone_all_no_qemu: __clone_binutils __clone_gcc
|
__clone_all_no_qemu: __clone_grub __clone_binutils __clone_gcc
|
||||||
|
|
||||||
__clone_all: __clone_qemu __clone_all_no_qemu
|
__clone_all: __clone_qemu __clone_all_no_qemu
|
||||||
|
|
||||||
@ -114,6 +131,9 @@ endif
|
|||||||
ifeq ("$(wildcard ./qemu.patch.bk)", "")
|
ifeq ("$(wildcard ./qemu.patch.bk)", "")
|
||||||
mv qemu.patch qemu.patch.bk
|
mv qemu.patch qemu.patch.bk
|
||||||
endif
|
endif
|
||||||
|
ifeq ("$(wildcard ./grub.patch.bk)", "")
|
||||||
|
mv grub.patch grub.patch.bk
|
||||||
|
endif
|
||||||
# binutils-gdb
|
# binutils-gdb
|
||||||
cd binutils-gdb && \
|
cd binutils-gdb && \
|
||||||
git add . && \
|
git add . && \
|
||||||
@ -126,6 +146,10 @@ endif
|
|||||||
cd qemu && \
|
cd qemu && \
|
||||||
git add . && \
|
git add . && \
|
||||||
git diff --cached > ../qemu.patch
|
git diff --cached > ../qemu.patch
|
||||||
|
# grub
|
||||||
|
cd grub && \
|
||||||
|
git add . && \
|
||||||
|
git diff --cached > ../grub.patch
|
||||||
|
|
||||||
do_qemu:
|
do_qemu:
|
||||||
$(MAKE) __patch_cross_qemu
|
$(MAKE) __patch_cross_qemu
|
||||||
@ -139,6 +163,7 @@ do_qemu:
|
|||||||
make --quiet -j$(shell nproc) && make --quiet install
|
make --quiet -j$(shell nproc) && make --quiet install
|
||||||
|
|
||||||
__do_binutils_x86_64:
|
__do_binutils_x86_64:
|
||||||
|
mkdir -p binutils-gdb/__build
|
||||||
cd binutils-gdb/__build && \
|
cd binutils-gdb/__build && \
|
||||||
../configure --target=x86_64-fennix \
|
../configure --target=x86_64-fennix \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
||||||
@ -147,6 +172,7 @@ __do_binutils_x86_64:
|
|||||||
make --quiet install
|
make --quiet install
|
||||||
|
|
||||||
__do_binutils_i386:
|
__do_binutils_i386:
|
||||||
|
mkdir -p binutils-gdb/__build
|
||||||
cd binutils-gdb/__build && \
|
cd binutils-gdb/__build && \
|
||||||
../configure --target=i386-fennix \
|
../configure --target=i386-fennix \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
||||||
@ -155,6 +181,7 @@ __do_binutils_i386:
|
|||||||
make --quiet install
|
make --quiet install
|
||||||
|
|
||||||
__do_binutils_arm:
|
__do_binutils_arm:
|
||||||
|
mkdir -p binutils-gdb/__build
|
||||||
cd binutils-gdb/__build && \
|
cd binutils-gdb/__build && \
|
||||||
../configure --target=arm-fennix \
|
../configure --target=arm-fennix \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
||||||
@ -163,6 +190,7 @@ __do_binutils_arm:
|
|||||||
make --quiet install
|
make --quiet install
|
||||||
|
|
||||||
__do_binutils_aarch64:
|
__do_binutils_aarch64:
|
||||||
|
mkdir -p binutils-gdb/__build
|
||||||
cd binutils-gdb/__build && \
|
cd binutils-gdb/__build && \
|
||||||
../configure --target=aarch64-fennix \
|
../configure --target=aarch64-fennix \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
--prefix="$(CROSS_DIR)" --disable-nls --quiet \
|
||||||
@ -185,6 +213,7 @@ do_binutils:
|
|||||||
$(MAKE) __do_binutils_aarch64
|
$(MAKE) __do_binutils_aarch64
|
||||||
|
|
||||||
__do_gcc_x86_64:
|
__do_gcc_x86_64:
|
||||||
|
mkdir -p gcc/__build
|
||||||
cd gcc/__build && \
|
cd gcc/__build && \
|
||||||
../configure --target=x86_64-fennix --quiet \
|
../configure --target=x86_64-fennix --quiet \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --enable-default-pie \
|
--prefix="$(CROSS_DIR)" --disable-nls --enable-default-pie \
|
||||||
@ -195,6 +224,7 @@ __do_gcc_x86_64:
|
|||||||
make --quiet install-target-libgcc -j$(shell nproc)
|
make --quiet install-target-libgcc -j$(shell nproc)
|
||||||
|
|
||||||
__do_gcc_i386:
|
__do_gcc_i386:
|
||||||
|
mkdir -p gcc/__build
|
||||||
cd gcc/__build && \
|
cd gcc/__build && \
|
||||||
../configure --target=i386-fennix --quiet \
|
../configure --target=i386-fennix --quiet \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --enable-default-pie \
|
--prefix="$(CROSS_DIR)" --disable-nls --enable-default-pie \
|
||||||
@ -205,6 +235,7 @@ __do_gcc_i386:
|
|||||||
make --quiet install-target-libgcc -j$(shell nproc)
|
make --quiet install-target-libgcc -j$(shell nproc)
|
||||||
|
|
||||||
__do_gcc_arm:
|
__do_gcc_arm:
|
||||||
|
mkdir -p gcc/__build
|
||||||
cd gcc/__build && \
|
cd gcc/__build && \
|
||||||
../configure --target=arm-fennix --quiet \
|
../configure --target=arm-fennix --quiet \
|
||||||
--prefix="$(CROSS_DIR)" --disable-nls --enable-default-pie \
|
--prefix="$(CROSS_DIR)" --disable-nls --enable-default-pie \
|
||||||
@ -237,3 +268,53 @@ do_gcc:
|
|||||||
$(MAKE) __do_gcc_arm
|
$(MAKE) __do_gcc_arm
|
||||||
$(MAKE) __reset_gcc
|
$(MAKE) __reset_gcc
|
||||||
$(MAKE) __do_gcc_aarch64
|
$(MAKE) __do_gcc_aarch64
|
||||||
|
|
||||||
|
__do_grub_x86_64:
|
||||||
|
cd grub && ./bootstrap
|
||||||
|
mkdir -p grub/__build
|
||||||
|
cd grub/__build && \
|
||||||
|
../configure --target=x86_64-linux \
|
||||||
|
--disable-nls && \
|
||||||
|
make all -j$(shell nproc) && \
|
||||||
|
make install
|
||||||
|
|
||||||
|
__do_grub_i386:
|
||||||
|
cd grub && ./bootstrap
|
||||||
|
mkdir -p grub/__build
|
||||||
|
cd grub/__build && \
|
||||||
|
../configure --target=i386-linux \
|
||||||
|
--disable-nls && \
|
||||||
|
make all -j$(shell nproc) && \
|
||||||
|
make install
|
||||||
|
|
||||||
|
__do_grub_arm:
|
||||||
|
cd grub && ./bootstrap
|
||||||
|
mkdir -p grub/__build
|
||||||
|
cd grub/__build && \
|
||||||
|
../configure --target=arm-linux \
|
||||||
|
--disable-nls && \
|
||||||
|
make all -j$(shell nproc) && \
|
||||||
|
make install
|
||||||
|
|
||||||
|
__do_grub_aarch64:
|
||||||
|
cd grub && ./bootstrap
|
||||||
|
mkdir -p grub/__build
|
||||||
|
cd grub/__build && \
|
||||||
|
../configure --target=aarch64-linux \
|
||||||
|
--disable-nls && \
|
||||||
|
make all -j$(shell nproc) && \
|
||||||
|
make install
|
||||||
|
|
||||||
|
__reset_grub:
|
||||||
|
$(MAKE) __patch_cross_grub
|
||||||
|
$(MAKE) __prep_cross
|
||||||
|
|
||||||
|
do_grub:
|
||||||
|
$(MAKE) __reset_grub
|
||||||
|
$(MAKE) __do_grub_x86_64
|
||||||
|
$(MAKE) __reset_grub
|
||||||
|
$(MAKE) __do_grub_i386
|
||||||
|
$(MAKE) __reset_grub
|
||||||
|
$(MAKE) __do_grub_arm
|
||||||
|
$(MAKE) __reset_grub
|
||||||
|
$(MAKE) __do_grub_aarch64
|
||||||
|
9
tools/grub.patch
Normal file
9
tools/grub.patch
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
diff --git a/.gitignore b/.gitignore
|
||||||
|
index 2105d87..58fe53f 100644
|
||||||
|
--- a/.gitignore
|
||||||
|
+++ b/.gitignore
|
||||||
|
@@ -281,3 +281,4 @@ widthspec.bin
|
||||||
|
/xfs_test
|
||||||
|
/xzcompress_test
|
||||||
|
/zfs_test
|
||||||
|
+/__build
|
Loading…
x
Reference in New Issue
Block a user