mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 23:44:31 +00:00
Compare commits
41 Commits
ce3cf8162a
...
073f582752
Author | SHA1 | Date | |
---|---|---|---|
073f582752 | |||
edd13c30c5 | |||
6dae34debd | |||
dea36a0228 | |||
8dd3179aaa | |||
0699d7962d | |||
e4403cdbd6 | |||
5632c7cb10 | |||
efb3a80ffd | |||
5d3bb391a4 | |||
b3f304f2c5 | |||
e23e793574 | |||
522158913f | |||
12a768a592 | |||
9ea2f4266e | |||
eb7c13dd45 | |||
8f04f8a374 | |||
1695418dcb | |||
b208862de2 | |||
a8481d4260 | |||
c84757af48 | |||
80afbedf39 | |||
911caf7203 | |||
95a8d6fb6f | |||
b471645743 | |||
cc6ec04814 | |||
1dbee4660e | |||
81af8a48cb | |||
0807ea5a9a | |||
79d267631a | |||
cbd671292d | |||
37c3ee8e99 | |||
7d85dd5dd8 | |||
17abdcaf1e | |||
f038f6110e | |||
3798ec0f58 | |||
fe5e4e3eec | |||
|
6f17b29963 | ||
|
8b026175bb | ||
|
828dab1875 | ||
|
7948d0c6e5 |
@ -1,34 +0,0 @@
|
|||||||
# Include any files or directories that you don't want to be copied to your
|
|
||||||
# container here (e.g., local build artifacts, temporary files, etc.).
|
|
||||||
#
|
|
||||||
# For more help, visit the .dockerignore file reference guide at
|
|
||||||
# https://docs.docker.com/go/build-context-dockerignore/
|
|
||||||
|
|
||||||
**/.DS_Store
|
|
||||||
**/__pycache__
|
|
||||||
**/.venv
|
|
||||||
**/.classpath
|
|
||||||
**/.dockerignore
|
|
||||||
**/.env
|
|
||||||
**/.git
|
|
||||||
**/.gitignore
|
|
||||||
**/.project
|
|
||||||
**/.settings
|
|
||||||
**/.toolstarget
|
|
||||||
**/.vs
|
|
||||||
**/.vscode
|
|
||||||
**/*.*proj.user
|
|
||||||
**/*.dbmdl
|
|
||||||
**/*.jfm
|
|
||||||
**/bin
|
|
||||||
**/charts
|
|
||||||
**/docker-compose*
|
|
||||||
**/compose.y*ml
|
|
||||||
**/Dockerfile*
|
|
||||||
**/node_modules
|
|
||||||
**/npm-debug.log
|
|
||||||
**/obj
|
|
||||||
**/secrets.dev.yaml
|
|
||||||
**/values.dev.yaml
|
|
||||||
LICENSE
|
|
||||||
README.md
|
|
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@ -3,7 +3,7 @@
|
|||||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
patreon: # Replace with a single Patreon username
|
patreon: # Replace with a single Patreon username
|
||||||
open_collective: # Replace with a single Open Collective username
|
open_collective: # Replace with a single Open Collective username
|
||||||
ko_fi: EnderIce2 # Replace with a single Ko-fi username
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
liberapay: # Replace with a single Liberapay username
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
55
.github/workflows/makefile.yml
vendored
55
.github/workflows/makefile.yml
vendored
@ -9,13 +9,16 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploydoc:
|
deploydoc:
|
||||||
name: Deploy Documentation to GitHub Pages
|
name: Deploy Documentation to GitHub Pages
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Update System
|
||||||
|
run: sudo apt update
|
||||||
|
|
||||||
- name: Install Doxygen
|
- name: Install Doxygen
|
||||||
run: sudo apt -y install doxygen make
|
run: sudo apt -y install doxygen make
|
||||||
|
|
||||||
@ -32,7 +35,7 @@ jobs:
|
|||||||
|
|
||||||
buildcompiler:
|
buildcompiler:
|
||||||
name: Build Cross-Compiler & Toolchain
|
name: Build Cross-Compiler & Toolchain
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@ -73,7 +76,7 @@ jobs:
|
|||||||
|
|
||||||
analyze:
|
analyze:
|
||||||
name: Analyze with CodeQL
|
name: Analyze with CodeQL
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
needs: [buildcompiler]
|
needs: [buildcompiler]
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
actions: read
|
||||||
@ -122,9 +125,31 @@ jobs:
|
|||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|
||||||
|
flawfinder:
|
||||||
|
name: Flawfinder
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: flawfinder_scan
|
||||||
|
uses: david-a-wheeler/flawfinder@2.0.19
|
||||||
|
with:
|
||||||
|
arguments: '--sarif ./ --minlevel 4'
|
||||||
|
output: 'flawfinder_results.sarif'
|
||||||
|
|
||||||
|
- name: Upload analysis results to GitHub Security tab
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
||||||
|
|
||||||
compile64:
|
compile64:
|
||||||
name: Build amd64
|
name: Build amd64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
needs: [buildcompiler]
|
needs: [buildcompiler]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -147,15 +172,15 @@ jobs:
|
|||||||
path: tools/cross
|
path: tools/cross
|
||||||
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
|
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
|
||||||
|
|
||||||
- name: Configure Makefile.conf
|
- name: Configure config.mk
|
||||||
run: sed -i 's/.*OSARCH = .*/OSARCH = amd64/' ./Makefile.conf && cat Makefile.conf | grep OSARCH
|
run: sed -i 's/.*OSARCH = .*/OSARCH = amd64/' ./config.mk && cat config.mk | grep OSARCH
|
||||||
|
|
||||||
- name: Compile Debug and Release ISO
|
- name: Compile Debug and Release ISO
|
||||||
run: |
|
run: |
|
||||||
make build
|
make build
|
||||||
mv Fennix.iso Fennix-debug.iso
|
mv Fennix.iso Fennix-debug.iso
|
||||||
make clean
|
make clean
|
||||||
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./Makefile.conf && cat Makefile.conf | grep DEBUG
|
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
|
||||||
make build
|
make build
|
||||||
mv Fennix.iso Fennix-release.iso
|
mv Fennix.iso Fennix-release.iso
|
||||||
|
|
||||||
@ -173,7 +198,7 @@ jobs:
|
|||||||
|
|
||||||
compile32:
|
compile32:
|
||||||
name: Build i386
|
name: Build i386
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
needs: [buildcompiler]
|
needs: [buildcompiler]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -196,15 +221,15 @@ jobs:
|
|||||||
path: tools/cross
|
path: tools/cross
|
||||||
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
|
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
|
||||||
|
|
||||||
- name: Configure Makefile.conf
|
- name: Configure config.mk
|
||||||
run: sed -i 's/.*OSARCH = .*/OSARCH = i386/' ./Makefile.conf && cat Makefile.conf | grep OSARCH
|
run: sed -i 's/.*OSARCH = .*/OSARCH = i386/' ./config.mk && cat config.mk | grep OSARCH
|
||||||
|
|
||||||
- name: Compile Debug and Release ISO
|
- name: Compile Debug and Release ISO
|
||||||
run: |
|
run: |
|
||||||
make build
|
make build
|
||||||
mv Fennix.iso Fennix-debug.iso
|
mv Fennix.iso Fennix-debug.iso
|
||||||
make clean
|
make clean
|
||||||
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./Makefile.conf && cat Makefile.conf | grep DEBUG
|
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
|
||||||
make build
|
make build
|
||||||
mv Fennix.iso Fennix-release.iso
|
mv Fennix.iso Fennix-release.iso
|
||||||
|
|
||||||
@ -223,7 +248,7 @@ jobs:
|
|||||||
compilearm64:
|
compilearm64:
|
||||||
if: ${{ false }} # Disabled until we can get it to work
|
if: ${{ false }} # Disabled until we can get it to work
|
||||||
name: Build aarch64
|
name: Build aarch64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
needs: [buildcompiler]
|
needs: [buildcompiler]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -246,15 +271,15 @@ jobs:
|
|||||||
path: tools/cross
|
path: tools/cross
|
||||||
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
|
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
|
||||||
|
|
||||||
- name: Configure Makefile.conf
|
- name: Configure config.mk
|
||||||
run: sed -i 's/.*OSARCH = .*/OSARCH = aarch64/' ./Makefile.conf && cat Makefile.conf | grep OSARCH
|
run: sed -i 's/.*OSARCH = .*/OSARCH = aarch64/' ./config.mk && cat config.mk | grep OSARCH
|
||||||
|
|
||||||
- name: Compile Debug and Release ISO
|
- name: Compile Debug and Release ISO
|
||||||
run: |
|
run: |
|
||||||
make build
|
make build
|
||||||
mv Fennix.iso Fennix-debug.iso
|
mv Fennix.iso Fennix-debug.iso
|
||||||
make clean
|
make clean
|
||||||
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./Makefile.conf && cat Makefile.conf | grep DEBUG
|
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
|
||||||
make build
|
make build
|
||||||
mv Fennix.iso Fennix-release.iso
|
mv Fennix.iso Fennix-release.iso
|
||||||
|
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,7 +6,6 @@ tools/*
|
|||||||
!tools/ExtMemDbg
|
!tools/ExtMemDbg
|
||||||
!tools/stage2_eltorito
|
!tools/stage2_eltorito
|
||||||
!tools/*.md
|
!tools/*.md
|
||||||
!tools/*.css
|
|
||||||
!tools/README.md
|
!tools/README.md
|
||||||
!tools/website
|
!tools/website
|
||||||
!tools/Makefile
|
!tools/Makefile
|
||||||
@ -15,6 +14,8 @@ tools/*
|
|||||||
!tools/*.cpp
|
!tools/*.cpp
|
||||||
!tools/*.cfg
|
!tools/*.cfg
|
||||||
!tools/acpi
|
!tools/acpi
|
||||||
|
!tools/doxygen
|
||||||
|
!tools/.gdbinit
|
||||||
doxygen-doc
|
doxygen-doc
|
||||||
initrd.tar
|
initrd.tar
|
||||||
.dccache
|
.dccache
|
||||||
|
@ -87,11 +87,11 @@ build64:
|
|||||||
- make --quiet -C Userspace prepare
|
- make --quiet -C Userspace prepare
|
||||||
- make --quiet -C Lynx prepare
|
- make --quiet -C Lynx prepare
|
||||||
- make --quiet -C Kernel prepare
|
- make --quiet -C Kernel prepare
|
||||||
- sed -i 's/.*OSARCH = .*/OSARCH = amd64/' ./Makefile.conf && cat Makefile.conf | grep OSARCH
|
- sed -i 's/.*OSARCH = .*/OSARCH = amd64/' ./config.mk && cat config.mk | grep OSARCH
|
||||||
- make build
|
- make build
|
||||||
- mv Fennix.iso Fennix-debug.iso
|
- mv Fennix.iso Fennix-debug.iso
|
||||||
- make clean
|
- make clean
|
||||||
- sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./Makefile.conf && cat Makefile.conf | grep DEBUG
|
- sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
|
||||||
- make build
|
- make build
|
||||||
- mv Fennix.iso Fennix-release.iso
|
- mv Fennix.iso Fennix-release.iso
|
||||||
artifacts:
|
artifacts:
|
||||||
@ -111,11 +111,11 @@ build32:
|
|||||||
- make --quiet -C Userspace prepare
|
- make --quiet -C Userspace prepare
|
||||||
- make --quiet -C Lynx prepare
|
- make --quiet -C Lynx prepare
|
||||||
- make --quiet -C Kernel prepare
|
- make --quiet -C Kernel prepare
|
||||||
- sed -i 's/.*OSARCH = .*/OSARCH = i386/' ./Makefile.conf && cat Makefile.conf | grep OSARCH
|
- sed -i 's/.*OSARCH = .*/OSARCH = i386/' ./config.mk && cat config.mk | grep OSARCH
|
||||||
- make build
|
- make build
|
||||||
- mv Fennix.iso Fennix-debug.iso
|
- mv Fennix.iso Fennix-debug.iso
|
||||||
- make clean
|
- make clean
|
||||||
- sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./Makefile.conf && cat Makefile.conf | grep DEBUG
|
- sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
|
||||||
- make build
|
- make build
|
||||||
- mv Fennix.iso Fennix-release.iso
|
- mv Fennix.iso Fennix-release.iso
|
||||||
artifacts:
|
artifacts:
|
||||||
@ -134,11 +134,11 @@ buildarm64:
|
|||||||
- make --quiet -C Userspace prepare
|
- make --quiet -C Userspace prepare
|
||||||
- make --quiet -C Lynx prepare
|
- make --quiet -C Lynx prepare
|
||||||
- make --quiet -C Kernel prepare
|
- make --quiet -C Kernel prepare
|
||||||
- sed -i 's/.*OSARCH = .*/OSARCH = arm64/' ./Makefile.conf && cat Makefile.conf | grep OSARCH
|
- sed -i 's/.*OSARCH = .*/OSARCH = arm64/' ./config.mk && cat config.mk | grep OSARCH
|
||||||
- make build
|
- make build
|
||||||
- mv Fennix.iso Fennix-debug.iso
|
- mv Fennix.iso Fennix-debug.iso
|
||||||
- make clean
|
- make clean
|
||||||
- sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./Makefile.conf && cat Makefile.conf | grep DEBUG
|
- sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
|
||||||
- make build
|
- make build
|
||||||
- mv Fennix.iso Fennix-release.iso
|
- mv Fennix.iso Fennix-release.iso
|
||||||
artifacts:
|
artifacts:
|
||||||
|
20
.vscode/c_boilerplates.code-snippets
vendored
20
.vscode/c_boilerplates.code-snippets
vendored
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"Fennix Kernel Header": {
|
|
||||||
"scope": "c",
|
|
||||||
"prefix": [
|
|
||||||
"head",
|
|
||||||
],
|
|
||||||
"body": [
|
|
||||||
"#ifndef __FENNIX_KERNEL_${2:header}_H__",
|
|
||||||
"#define __FENNIX_KERNEL_${2:header}_H__",
|
|
||||||
"",
|
|
||||||
"#include <types.h>",
|
|
||||||
"",
|
|
||||||
"$0",
|
|
||||||
"",
|
|
||||||
"#endif // !__FENNIX_KERNEL_${2:header}_H__",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"description": "Create kernel header."
|
|
||||||
}
|
|
||||||
}
|
|
69
.vscode/launch.json
vendored
Normal file
69
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch QEMU & debug the kernel",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"args": [],
|
||||||
|
"targetArchitecture": "x64",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerServerAddress": "/tmp/gdb-fennix",
|
||||||
|
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
||||||
|
"miDebuggerArgs": "",
|
||||||
|
"externalConsole": false,
|
||||||
|
"additionalSOLibSearchPath": "${workspaceFolder}",
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"customLaunchSetupCommands": [
|
||||||
|
// {
|
||||||
|
// "text": "target remote localhost:1234",
|
||||||
|
// "description": "Connect to QEMU remote debugger"
|
||||||
|
// }
|
||||||
|
],
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "set breakpoint pending on",
|
||||||
|
"description": "Make breakpoint pending on future shared library load."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "file ${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
|
"description": "Load binary"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
||||||
|
"description": "Load /bin/utest",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "source ${workspaceFolder}/../tools/.gdbinit"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "launch-qemu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "gdb",
|
||||||
|
"request": "attach",
|
||||||
|
"name": "Launch QEMU & attach to gdbserver",
|
||||||
|
"executable": "${workspaceFolder}/../Kernel/fennix.elf",
|
||||||
|
"target": "/tmp/gdb-fennix",
|
||||||
|
"remote": true,
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"valuesFormatting": "parseText",
|
||||||
|
"gdbpath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
||||||
|
"autorun": [
|
||||||
|
"set auto-load safe-path ${workspaceFolder}",
|
||||||
|
"source ${workspaceFolder}/../tools/.gdbinit",
|
||||||
|
],
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"printCalls": false,
|
||||||
|
"preLaunchTask": "launch-qemu"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,16 +11,10 @@
|
|||||||
"editor.cursorSmoothCaretAnimation": "on",
|
"editor.cursorSmoothCaretAnimation": "on",
|
||||||
"files.watcherExclude": {
|
"files.watcherExclude": {
|
||||||
"**/tools/binutils-gdb/**": true,
|
"**/tools/binutils-gdb/**": true,
|
||||||
"**/tools/build-binutilsamd64/**": true,
|
|
||||||
"**/tools/build-binutilsarm64/**": true,
|
|
||||||
"**/tools/build-binutilsi386/**": true,
|
|
||||||
"**/tools/build-gccamd64/**": true,
|
|
||||||
"**/tools/build-gccarm64/**": true,
|
|
||||||
"**/tools/build-gcci386/**": true,
|
|
||||||
"**/tools/cross/**": true,
|
|
||||||
"**/tools/gcc/**": true,
|
"**/tools/gcc/**": true,
|
||||||
"**/tools/limine/**": true,
|
"**/tools/limine/**": true,
|
||||||
"**/tools/qemu/**": true,
|
"**/tools/qemu/**": true,
|
||||||
|
"**/tools/cross/**": true,
|
||||||
"**/doxygen-doc/**": true,
|
"**/doxygen-doc/**": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
28
.vscode/tasks.json
vendored
Normal file
28
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "launch-qemu",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make -C ../ build && make -C ../ vscode_debug_only",
|
||||||
|
"isBackground": true,
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "shared"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"shell": {
|
||||||
|
"executable": "bash",
|
||||||
|
"args": [
|
||||||
|
"-c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
128
CODE_OF_CONDUCT.md
Normal file
128
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or
|
||||||
|
advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email
|
||||||
|
address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
enderice2@protonmail.com.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.0, available at
|
||||||
|
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
https://www.contributor-covenant.org/faq. Translations are available at
|
||||||
|
https://www.contributor-covenant.org/translations.
|
70
CONTRIBUTING.md
Normal file
70
CONTRIBUTING.md
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# Contributing to Fennix
|
||||||
|
|
||||||
|
We welcome contributions to Fennix! Whether you are reporting a bug, suggesting a feature, or submitting a pull request, we’re excited to collaborate with you.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
- [How to Contribute](#how-to-contribute)
|
||||||
|
- [Code of Conduct](#code-of-conduct)
|
||||||
|
- [Getting Started](#getting-started)
|
||||||
|
- [Pull Request Guidelines](#pull-request-guidelines)
|
||||||
|
- [Reporting Issues](#reporting-issues)
|
||||||
|
- [Style Guide](#style-guide)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## How to Contribute
|
||||||
|
|
||||||
|
1. **Check existing issues or discussions** to see if your idea has already been mentioned or if someone is already working on it.
|
||||||
|
2. If you’re new to the project, consider contributing to [good first issues](https://github.com/EnderIce2/Fennix/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
|
||||||
|
3. Fork the repository and create a new branch for your changes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). Be respectful and inclusive while interacting with the community.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
1. Fork this repository and clone your fork.
|
||||||
|
2. Set up your development environment according to the [README.md](README.md) or any other setup guide provided.
|
||||||
|
3. Ensure all tests pass before submitting changes. Add tests for new features where applicable.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Pull Request Guidelines
|
||||||
|
|
||||||
|
1. Keep pull requests focused on a single issue or feature.
|
||||||
|
2. Write clear, descriptive commit messages.
|
||||||
|
3. Ensure all tests pass before submitting your PR.
|
||||||
|
4. Include a detailed description of your changes and reference any relevant issue numbers.
|
||||||
|
5. Be open to feedback and revise your pull request if requested.
|
||||||
|
6. Mark your pull request as a draft if it’s still a work in progress.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Reporting Issues
|
||||||
|
|
||||||
|
1. Check if the issue has already been reported.
|
||||||
|
2. Include a clear and descriptive title.
|
||||||
|
3. Provide detailed steps to reproduce the problem (if applicable).
|
||||||
|
4. Mention your environment details (e.g., OS, version, etc.).
|
||||||
|
5. Attach screenshots or logs if they help explain the issue.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Style Guide
|
||||||
|
|
||||||
|
Follow the coding style used in the repository to ensure consistency. Adhere to:
|
||||||
|
- Use CamelCase for all names.
|
||||||
|
- Start function and global declaration names with an uppercase letter.
|
||||||
|
- Start local variable names with a lowercase letter.
|
||||||
|
- Maintain consistent formatting and commenting guidelines.
|
||||||
|
|
||||||
|
Refer to the [style guide document](STYLE_GUIDE.md) if available.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Thank you for contributing! Your effort makes Fennix better for everyone. If you have any questions, feel free to reach out by opening an issue or joining our discussions.
|
43
Dockerfile
43
Dockerfile
@ -1,43 +0,0 @@
|
|||||||
FROM ubuntu:22.04 AS base
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
WORKDIR /fennix
|
|
||||||
ADD . /fennix
|
|
||||||
|
|
||||||
RUN apt -y update
|
|
||||||
RUN apt -y install \
|
|
||||||
build-essential \
|
|
||||||
bison \
|
|
||||||
flex \
|
|
||||||
libgmp3-dev \
|
|
||||||
libmpc-dev \
|
|
||||||
libmpfr-dev \
|
|
||||||
texinfo \
|
|
||||||
libzstd-dev \
|
|
||||||
libisl-dev \
|
|
||||||
autoconf \
|
|
||||||
m4 \
|
|
||||||
automake \
|
|
||||||
gettext \
|
|
||||||
gperf \
|
|
||||||
dejagnu \
|
|
||||||
guile-3.0 \
|
|
||||||
guile-3.0-dev \
|
|
||||||
expect \
|
|
||||||
tcl \
|
|
||||||
autogen \
|
|
||||||
tex-common \
|
|
||||||
sphinx-common \
|
|
||||||
git \
|
|
||||||
ssh \
|
|
||||||
diffutils \
|
|
||||||
patch
|
|
||||||
|
|
||||||
RUN apt clean && rm -rf /var/lib/apt/lists
|
|
||||||
|
|
||||||
RUN make -C tools __clone_all_no_qemu
|
|
||||||
RUN make --quiet -C tools do_binutils
|
|
||||||
RUN make --quiet -C tools do_gcc
|
|
||||||
RUN cd tools && rm -rf binutils-gdb gcc
|
|
||||||
|
|
||||||
RUN make build
|
|
42
Doxyfile
42
Doxyfile
@ -44,14 +44,14 @@ PROJECT_NUMBER = 1.0.0
|
|||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
# quick idea about the purpose of the project. Keep the description short.
|
# quick idea about the purpose of the project. Keep the description short.
|
||||||
|
|
||||||
PROJECT_BRIEF = "Opeating System from scratch made in C and C++"
|
PROJECT_BRIEF = "Full Documentation"
|
||||||
|
|
||||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||||
# in the documentation. The maximum height of the logo should not exceed 55
|
# in the documentation. The maximum height of the logo should not exceed 55
|
||||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||||
# the logo to the output directory.
|
# the logo to the output directory.
|
||||||
|
|
||||||
PROJECT_LOGO =
|
PROJECT_LOGO = tools/doxygen/favicon.ico
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||||
# into which the generated documentation will be written. If a relative path is
|
# into which the generated documentation will be written. If a relative path is
|
||||||
@ -246,7 +246,7 @@ INHERIT_DOCS = YES
|
|||||||
# of the file/class/namespace that contains it.
|
# of the file/class/namespace that contains it.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
SEPARATE_MEMBER_PAGES = YES
|
SEPARATE_MEMBER_PAGES = NO
|
||||||
|
|
||||||
# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
|
# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
|
||||||
# uses this value to replace tabs by spaces in code fragments.
|
# uses this value to replace tabs by spaces in code fragments.
|
||||||
@ -424,7 +424,7 @@ SUBGROUPING = YES
|
|||||||
# SEPARATE_MEMBER_PAGES.
|
# SEPARATE_MEMBER_PAGES.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
INLINE_GROUPED_CLASSES = YES
|
INLINE_GROUPED_CLASSES = NO
|
||||||
|
|
||||||
# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
|
# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
|
||||||
# with only public data fields or simple typedef fields will be shown inline in
|
# with only public data fields or simple typedef fields will be shown inline in
|
||||||
@ -614,7 +614,7 @@ HIDE_COMPOUND_REFERENCE= NO
|
|||||||
# the files that are included by a file in the documentation of that file.
|
# the files that are included by a file in the documentation of that file.
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
||||||
SHOW_INCLUDE_FILES = YES
|
SHOW_INCLUDE_FILES = NO
|
||||||
|
|
||||||
# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
|
# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
|
||||||
# grouped member an include statement to the documentation, telling the reader
|
# grouped member an include statement to the documentation, telling the reader
|
||||||
@ -794,7 +794,7 @@ CITE_BIB_FILES =
|
|||||||
# messages are off.
|
# messages are off.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
QUIET = NO
|
QUIET = YES
|
||||||
|
|
||||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||||
# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
|
# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
|
||||||
@ -864,7 +864,14 @@ WARN_LOGFILE =
|
|||||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = Kernel Userspace Drivers tools/doxymds/main.md
|
INPUT = tools/doxygen/index.md \
|
||||||
|
tools/doxygen/api.md \
|
||||||
|
tools/doxygen/develop.md \
|
||||||
|
README \
|
||||||
|
Userspace/README.md \
|
||||||
|
Drivers/README.md \
|
||||||
|
Kernel/README.md \
|
||||||
|
Kernel/include/interface
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
@ -955,7 +962,7 @@ RECURSIVE = YES
|
|||||||
# Note that relative paths are relative to the directory from which doxygen is
|
# Note that relative paths are relative to the directory from which doxygen is
|
||||||
# run.
|
# run.
|
||||||
|
|
||||||
EXCLUDE = .vscode tools
|
EXCLUDE = .vscode .github
|
||||||
|
|
||||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||||
@ -1064,7 +1071,7 @@ FILTER_SOURCE_PATTERNS =
|
|||||||
# (index.html). This can be useful if you have a project on for instance GitHub
|
# (index.html). This can be useful if you have a project on for instance GitHub
|
||||||
# and want to reuse the introduction page also for the doxygen output.
|
# and want to reuse the introduction page also for the doxygen output.
|
||||||
|
|
||||||
USE_MDFILE_AS_MAINPAGE = tools/doxymds/main.md
|
USE_MDFILE_AS_MAINPAGE = tools/doxygen/index.md
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options related to source browsing
|
# Configuration options related to source browsing
|
||||||
@ -1224,7 +1231,7 @@ GENERATE_HTML = YES
|
|||||||
# The default directory is: html.
|
# The default directory is: html.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_OUTPUT = doxygen-doc/fulldoc
|
HTML_OUTPUT = doxygen-doc/docs
|
||||||
|
|
||||||
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
|
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
|
||||||
# generated HTML page (for example: .htm, .php, .asp).
|
# generated HTML page (for example: .htm, .php, .asp).
|
||||||
@ -1251,7 +1258,7 @@ HTML_FILE_EXTENSION = .html
|
|||||||
# of the possible markers and block names see the documentation.
|
# of the possible markers and block names see the documentation.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_HEADER =
|
HTML_HEADER = tools/doxygen/header.html
|
||||||
|
|
||||||
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
||||||
# generated HTML page. If the tag is left blank doxygen will generate a standard
|
# generated HTML page. If the tag is left blank doxygen will generate a standard
|
||||||
@ -1286,7 +1293,8 @@ HTML_STYLESHEET =
|
|||||||
# list). For an example see the documentation.
|
# list). For an example see the documentation.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_EXTRA_STYLESHEET = tools/doxygen-awesome.css tools/custom.css
|
HTML_EXTRA_STYLESHEET = tools/doxygen/theme/doxygen-awesome.css \
|
||||||
|
tools/doxygen/custom.css
|
||||||
|
|
||||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||||
# other source files which should be copied to the HTML output directory. Note
|
# other source files which should be copied to the HTML output directory. Note
|
||||||
@ -1296,7 +1304,11 @@ HTML_EXTRA_STYLESHEET = tools/doxygen-awesome.css tools/custom.css
|
|||||||
# files will be copied as-is; there are no commands or markers available.
|
# files will be copied as-is; there are no commands or markers available.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_EXTRA_FILES =
|
HTML_EXTRA_FILES = tools/doxygen/theme/doxygen-awesome-darkmode-toggle.js \
|
||||||
|
tools/doxygen/theme/doxygen-awesome-fragment-copy-button.js \
|
||||||
|
tools/doxygen/theme/doxygen-awesome-paragraph-link.js \
|
||||||
|
tools/doxygen/theme/doxygen-awesome-interactive-toc.js \
|
||||||
|
tools/doxygen/theme/doxygen-awesome-tabs.js
|
||||||
|
|
||||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||||
# will adjust the colors in the style sheet and background images according to
|
# will adjust the colors in the style sheet and background images according to
|
||||||
@ -1335,7 +1347,7 @@ HTML_COLORSTYLE_GAMMA = 80
|
|||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_TIMESTAMP = NO
|
HTML_TIMESTAMP = YES
|
||||||
|
|
||||||
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
||||||
# documentation will contain a main index with vertical navigation menus that
|
# documentation will contain a main index with vertical navigation menus that
|
||||||
@ -2071,7 +2083,7 @@ MAN_OUTPUT = man
|
|||||||
# The default value is: .3.
|
# The default value is: .3.
|
||||||
# This tag requires that the tag GENERATE_MAN is set to YES.
|
# This tag requires that the tag GENERATE_MAN is set to YES.
|
||||||
|
|
||||||
MAN_EXTENSION = .3
|
MAN_EXTENSION = .2
|
||||||
|
|
||||||
# The MAN_SUBDIR tag determines the name of the directory created within
|
# The MAN_SUBDIR tag determines the name of the directory created within
|
||||||
# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
|
# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
|
||||||
|
2
Drivers/.vscode/c_cpp_properties.json
vendored
2
Drivers/.vscode/c_cpp_properties.json
vendored
@ -12,7 +12,6 @@
|
|||||||
"KERNEL_VERSION=\"1.0\"",
|
"KERNEL_VERSION=\"1.0\"",
|
||||||
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
||||||
"GIT_COMMIT_SHORT=\"0000000\"",
|
"GIT_COMMIT_SHORT=\"0000000\"",
|
||||||
"a64",
|
|
||||||
"DEBUG=\"1\""
|
"DEBUG=\"1\""
|
||||||
],
|
],
|
||||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
|
||||||
@ -69,7 +68,6 @@
|
|||||||
"KERNEL_VERSION=\"1.0\"",
|
"KERNEL_VERSION=\"1.0\"",
|
||||||
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
|
||||||
"GIT_COMMIT_SHORT=\"0000000\"",
|
"GIT_COMMIT_SHORT=\"0000000\"",
|
||||||
"a32",
|
|
||||||
"DEBUG=\"1\""
|
"DEBUG=\"1\""
|
||||||
],
|
],
|
||||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-elf-gcc",
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-elf-gcc",
|
||||||
|
1
Drivers/.vscode/launch.json
vendored
Symbolic link
1
Drivers/.vscode/launch.json
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../.vscode/launch.json
|
1
Drivers/.vscode/tasks.json
vendored
Symbolic link
1
Drivers/.vscode/tasks.json
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../.vscode/tasks.json
|
2659
Drivers/Doxyfile
2659
Drivers/Doxyfile
File diff suppressed because it is too large
Load Diff
@ -1,29 +0,0 @@
|
|||||||
BSD 3-Clause License
|
|
||||||
|
|
||||||
Copyright (c) 2024, EnderIce2
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
3. Neither the name of the copyright holder nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,3 +1,48 @@
|
|||||||
|
default:
|
||||||
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
|
export CC := $(__CONF_CC)
|
||||||
|
export CXX := $(__CONF_CXX)
|
||||||
|
export LD := $(__CONF_LD)
|
||||||
|
export AS := $(__CONF_AS)
|
||||||
|
export OBJDUMP := $(__CONF_OBJDUMP)
|
||||||
|
|
||||||
|
export OUTPUT_DIR := $(CURDIR)/out/
|
||||||
|
export INCLUDE_DIR := $(CURDIR)/include
|
||||||
|
|
||||||
|
DRIVER_LDFLAGS = -nostdlib -nodefaultlibs -nolibc -zmax-page-size=0x1000 \
|
||||||
|
-Wl,-Map file.map -fvisibility=hidden -Wl,--dynamic-linker=/boot/fennix.elf
|
||||||
|
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
DRIVER_CFLAGS = -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
|
-msoft-float -fno-builtin
|
||||||
|
|
||||||
|
else ifeq ($(OSARCH), i386)
|
||||||
|
DRIVER_CFLAGS = -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
|
-march=i386 -pipe -msoft-float -fno-builtin
|
||||||
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
DRIVER_CFLAGS = -pipe -fno-builtin -fPIC
|
||||||
|
endif
|
||||||
|
|
||||||
|
DRIVER_CFLAGS += -I$(CURDIR)/include
|
||||||
|
|
||||||
|
ifeq ($(DEBUG), 1)
|
||||||
|
DRIVER_CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
|
||||||
|
ifeq ($(OSARCH), amd64)
|
||||||
|
DRIVER_CFLAGS += -fverbose-asm
|
||||||
|
endif
|
||||||
|
ifneq ($(OSARCH), aarch64)
|
||||||
|
DRIVER_CFLAGS += -fstack-check
|
||||||
|
endif
|
||||||
|
DRIVER_LDFLAGS += -ggdb3 -O0
|
||||||
|
endif
|
||||||
|
|
||||||
|
export DRIVER_LDFLAGS
|
||||||
|
export DRIVER_CFLAGS
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cp -rf ../Kernel/include/interface/* include/
|
cp -rf ../Kernel/include/interface/* include/
|
||||||
mkdir -p out
|
mkdir -p out
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
build:
|
MAKE_TARGETS := build clean
|
||||||
make -C ac97 build
|
DIRECTORIES := $(sort $(dir $(wildcard ./*/)))
|
||||||
make -C hda build
|
|
||||||
|
|
||||||
clean:
|
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES)
|
||||||
make -C ac97 clean
|
|
||||||
make -C hda clean
|
$(MAKE_TARGETS): $(DIRECTORIES)
|
||||||
|
|
||||||
|
$(DIRECTORIES):
|
||||||
|
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = ac97.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = hda.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
|
||||||
LD = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ld
|
|
||||||
AS = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)as
|
|
||||||
OBJDUMP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)objdump
|
|
||||||
|
|
||||||
DRIVER_LDFLAGS := -nostdlib -nodefaultlibs -nolibc -zmax-page-size=0x1000 \
|
|
||||||
-Wl,-Map file.map -fvisibility=hidden -Wl,--dynamic-linker=/boot/fennix.elf
|
|
||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
|
||||||
|
|
||||||
DRIVER_CFLAGS := -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
|
||||||
-msoft-float -fno-builtin
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i386)
|
|
||||||
|
|
||||||
DRIVER_CFLAGS := -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
|
||||||
-march=i386 -pipe -msoft-float -fno-builtin
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
|
||||||
|
|
||||||
DRIVER_CFLAGS += -pipe -fno-builtin -fPIC
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
DRIVER_CFLAGS += -I../../include
|
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
|
||||||
DRIVER_CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
|
|
||||||
ifeq ($(OSARCH), amd64)
|
|
||||||
DRIVER_CFLAGS += -fverbose-asm
|
|
||||||
endif
|
|
||||||
ifneq ($(OSARCH), aarch64)
|
|
||||||
DRIVER_CFLAGS += -fstack-check
|
|
||||||
endif
|
|
||||||
DRIVER_LDFLAGS += -ggdb3 -O0
|
|
||||||
endif
|
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
|
||||||
|
|
||||||
%.o: %.c $(HEADERS)
|
|
||||||
$(info Compiling $<)
|
|
||||||
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
|
||||||
|
|
||||||
%.o: %.cpp $(HEADERS)
|
|
||||||
$(info Compiling $<)
|
|
||||||
$(CPP) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
|
||||||
|
|
||||||
%.o: %.S
|
|
||||||
$(info Compiling $<)
|
|
||||||
$(AS) -o $@ $<
|
|
@ -1,5 +1,9 @@
|
|||||||
build:
|
MAKE_TARGETS := build clean
|
||||||
make -C fat build
|
DIRECTORIES := $(sort $(dir $(wildcard ./*/)))
|
||||||
|
|
||||||
clean:
|
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES)
|
||||||
make -C fat clean
|
|
||||||
|
$(MAKE_TARGETS): $(DIRECTORIES)
|
||||||
|
|
||||||
|
$(DIRECTORIES):
|
||||||
|
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = fat.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of Fennix Drivers.
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
Fennix Drivers is free software: you can redistribute it and/or
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation, either version 3 of
|
published by the Free Software Foundation, either version 3 of
|
||||||
the License, or (at your option) any later version.
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
Fennix Drivers is distributed in the hope that it will be useful,
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Fennix Drivers. If not, see <https://www.gnu.org/licenses/>.
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __FENNIX_API_AIP_H__
|
#ifndef __FENNIX_API_AIP_H__
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __FENNIX_KERNEL_ERRNO_H__
|
#ifndef __FENNIX_API_ERRNO_H__
|
||||||
#define __FENNIX_KERNEL_ERRNO_H__
|
#define __FENNIX_API_ERRNO_H__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The documentation for these error codes are from:
|
* The documentation for these error codes are from:
|
||||||
@ -416,8 +416,8 @@ typedef enum
|
|||||||
* Not a directory. A component of the specified pathname exists, but
|
* Not a directory. A component of the specified pathname exists, but
|
||||||
* it is not a directory, when a directory was expected; or an
|
* it is not a directory, when a directory was expected; or an
|
||||||
* attempt was made to create a non-directory file, and the specified
|
* attempt was made to create a non-directory file, and the specified
|
||||||
* pathname contains at least one non- <slash> character and ends
|
* pathname contains at least one non- \<slash\> character and ends
|
||||||
* with one or more trailing <slash> characters.
|
* with one or more trailing \<slash\> characters.
|
||||||
*/
|
*/
|
||||||
ENOTDIR = 57,
|
ENOTDIR = 57,
|
||||||
|
|
||||||
@ -588,17 +588,18 @@ typedef enum
|
|||||||
__ERRNO_MAX
|
__ERRNO_MAX
|
||||||
} KernelErrors;
|
} KernelErrors;
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
EXTERNC int *__errno_location(void) __attribute__((const));
|
|
||||||
#define errno (*__errno_location())
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int *__errno_location(void) __attribute__((const));
|
||||||
char *strerror(int errnum);
|
char *strerror(int errnum);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !__FENNIX_KERNEL_ERRNO_H__
|
#define errno (*__errno_location())
|
||||||
|
|
||||||
|
#endif // !__FENNIX_API_ERRNO_H__
|
||||||
|
@ -348,6 +348,7 @@ struct SuperBlockOperations
|
|||||||
* Write all pending changes to the disk.
|
* Write all pending changes to the disk.
|
||||||
*
|
*
|
||||||
* @param Info Inode to synchronize. If NULL, synchronize all inodes.
|
* @param Info Inode to synchronize. If NULL, synchronize all inodes.
|
||||||
|
* @param Node Inode to synchronize.
|
||||||
*
|
*
|
||||||
* @return Zero on success, otherwise an error code.
|
* @return Zero on success, otherwise an error code.
|
||||||
*/
|
*/
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of Fennix Drivers.
|
This file is part of Fennix Kernel.
|
||||||
|
|
||||||
Fennix Drivers is free software: you can redistribute it and/or
|
Fennix Kernel is free software: you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation, either version 3 of
|
published by the Free Software Foundation, either version 3 of
|
||||||
the License, or (at your option) any later version.
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
Fennix Drivers is distributed in the hope that it will be useful,
|
Fennix Kernel is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Fennix Drivers. If not, see <https://www.gnu.org/licenses/>.
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __FENNIX_API_PCI_H__
|
#ifndef __FENNIX_API_PCI_H__
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,9 @@
|
|||||||
build:
|
MAKE_TARGETS := build clean
|
||||||
make -C aip build
|
DIRECTORIES := $(sort $(dir $(wildcard ./*/)))
|
||||||
|
|
||||||
clean:
|
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES)
|
||||||
make -C aip clean
|
|
||||||
|
$(MAKE_TARGETS): $(DIRECTORIES)
|
||||||
|
|
||||||
|
$(DIRECTORIES):
|
||||||
|
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = aip.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,21 +1,14 @@
|
|||||||
# Config file
|
|
||||||
include ../../Makefile.conf
|
|
||||||
|
|
||||||
FILENAME = libkernel.so
|
FILENAME = libkernel.so
|
||||||
|
|
||||||
CC = ../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
default:
|
||||||
CPP = ../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
$(error Do not run this Makefile directly!)
|
||||||
LD = ../../$(COMPILER_PATH)/$(COMPILER_ARCH)ld
|
|
||||||
AS = ../../$(COMPILER_PATH)/$(COMPILER_ARCH)as
|
|
||||||
AR = ../../$(COMPILER_PATH)/$(COMPILER_ARCH)ar
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./crt/*")
|
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./crt/*")
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./crt/*")
|
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./crt/*")
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./crt/*")
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./crt/*")
|
||||||
HEADERS = $(sort $(dir $(wildcard ../include/*)))
|
HEADERS = $(sort $(dir $(wildcard $(INCLUDE_DIR)/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
INCLUDE_DIR = ../include
|
|
||||||
|
|
||||||
LDFLAGS := -fPIC -fPIE -pie -nostdlib -nodefaultlibs -nolibc \
|
LDFLAGS := -fPIC -fPIE -pie -nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 -Wl,-Map libkernel.map -shared
|
-zmax-page-size=0x1000 -Wl,-Map libkernel.map -shared
|
||||||
@ -43,7 +36,7 @@ CFLAGS += -pipe -fno-builtin -fPIC
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CRT_CFLAGS := -fPIC -fPIE -pie -mno-red-zone -std=c++20 -I../include
|
CRT_CFLAGS := -fPIC -fPIE -pie -mno-red-zone -std=c++20 -I$(INCLUDE_DIR)
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
|
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
|
||||||
@ -60,12 +53,12 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
$(CPP) $(CRT_CFLAGS) -c crt/crt0.cpp -o dcrt0.o
|
$(CXX) $(CRT_CFLAGS) -c crt/crt0.cpp -o dcrt0.o
|
||||||
mv dcrt0.o ../out/dcrt0.o
|
mv dcrt0.o $(OUTPUT_DIR)dcrt0.o
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(LDFLAGS) $(OBJ) -o ../out/$(FILENAME)
|
$(CC) $(LDFLAGS) $(OBJ) -o $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
%.o: %.c $(HEADERS)
|
%.o: %.c $(HEADERS)
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
@ -73,7 +66,7 @@ $(FILENAME): $(OBJ)
|
|||||||
|
|
||||||
%.o: %.cpp $(HEADERS)
|
%.o: %.cpp $(HEADERS)
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
$(CPP) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@
|
$(CXX) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
build:
|
MAKE_TARGETS := build clean
|
||||||
make -C example build
|
DIRECTORIES := $(sort $(dir $(wildcard ./*/)))
|
||||||
make -C vmware build
|
|
||||||
|
|
||||||
clean:
|
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES)
|
||||||
make -C example clean
|
|
||||||
make -C vmware clean
|
$(MAKE_TARGETS): $(DIRECTORIES)
|
||||||
|
|
||||||
|
$(DIRECTORIES):
|
||||||
|
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = example.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -66,15 +66,14 @@ int DriverProbe()
|
|||||||
* This function is to test if the driver is compatible
|
* This function is to test if the driver is compatible
|
||||||
* with the hardware.
|
* with the hardware.
|
||||||
* Example: Like if there is a PCI device that the driver
|
* Example: Like if there is a PCI device that the driver
|
||||||
* is for, or a CPU feature that etc.
|
* is for, or a CPU feature etc.
|
||||||
*
|
*
|
||||||
* Return 0 if the driver is compatible with the hardware.
|
* Return 0 if the driver is compatible with the hardware.
|
||||||
* Otherwise, return a value that is not 0.
|
|
||||||
*
|
*
|
||||||
* Note: In this function you cannot use variables that
|
* Note: In this function you cannot use variables that
|
||||||
* have constructors or destructors. Before DriverEntry,
|
* have constructors or destructors. Before DriverEntry,
|
||||||
* the constructors are called and after DriverFinalize,
|
* the constructors are called and after DriverFinalize,
|
||||||
* the destructors are called.
|
* the destructors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = vmware.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
build:
|
MAKE_TARGETS := build clean
|
||||||
make -C e1000 build
|
DIRECTORIES := $(sort $(dir $(wildcard ./*/)))
|
||||||
make -C rtl8139 build
|
|
||||||
|
|
||||||
clean:
|
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES)
|
||||||
make -C e1000 clean
|
|
||||||
make -C rtl8139 clean
|
$(MAKE_TARGETS): $(DIRECTORIES)
|
||||||
|
|
||||||
|
$(DIRECTORIES):
|
||||||
|
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = e1000.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = rtl8139.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = ahci.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
# Config files
|
default:
|
||||||
include ../../../Makefile.conf
|
$(error Do not run this Makefile directly!)
|
||||||
include ../../config.mk
|
|
||||||
|
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
S_SOURCES = $(shell find ./ -type f -name '*.S')
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
C_SOURCES = $(shell find ./ -type f -name '*.c')
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
|
||||||
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(S_SOURCES:.S=.o)
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
|
||||||
FILENAME = ata.drv
|
FILENAME = $(notdir $(shell pwd)).drv
|
||||||
|
|
||||||
build: $(FILENAME)
|
build: $(FILENAME)
|
||||||
mv $(FILENAME) ../../out/$(FILENAME)
|
mv $(FILENAME) $(OUTPUT_DIR)$(FILENAME)
|
||||||
|
|
||||||
$(FILENAME): $(OBJ)
|
$(FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(DRIVER_LDFLAGS) $(OBJ) ../../out/dcrt0.o -L../../out -lkernel -o $@
|
$(CC) $(DRIVER_LDFLAGS) $(OBJ) $(OUTPUT_DIR)dcrt0.o -L$(OUTPUT_DIR) -lkernel -o $@
|
||||||
|
|
||||||
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CC) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp $(HEADERS)
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(CXX) $(DRIVER_CFLAGS) $(WARNCFLAG) -std=c++20 -fno-exceptions -fno-rtti -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(info Compiling $<)
|
||||||
|
$(AS) -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
rm -f file.map $(OBJ) $(STACK_USAGE_OBJ)
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"terminal.integrated.cwd": "../",
|
"terminal.integrated.cwd": "../",
|
||||||
"debug.allowBreakpointsEverywhere": true
|
"debug.allowBreakpointsEverywhere": true,
|
||||||
|
"git.alwaysSignOff": true,
|
||||||
|
"git.defaultBranchName": "master",
|
||||||
|
"git.openRepositoryInParentFolders": "always",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,10 @@
|
|||||||
"editor.cursorBlinking": "blink",
|
"editor.cursorBlinking": "blink",
|
||||||
"editor.cursorSmoothCaretAnimation": "on",
|
"editor.cursorSmoothCaretAnimation": "on",
|
||||||
"editor.cursorStyle": "line",
|
"editor.cursorStyle": "line",
|
||||||
"editor.cursorWidth": 2
|
"editor.cursorWidth": 2,
|
||||||
|
"git.alwaysSignOff": true,
|
||||||
|
"git.defaultBranchName": "master",
|
||||||
|
"git.openRepositoryInParentFolders": "always",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,10 @@
|
|||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"terminal.integrated.cwd": "../",
|
"terminal.integrated.cwd": "../",
|
||||||
"debug.allowBreakpointsEverywhere": true
|
"debug.allowBreakpointsEverywhere": true,
|
||||||
|
"git.alwaysSignOff": true,
|
||||||
|
"git.defaultBranchName": "master",
|
||||||
|
"git.openRepositoryInParentFolders": "always",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false
|
||||||
}
|
}
|
||||||
}
|
}
|
14
Fennix Website.code-workspace
Normal file
14
Fennix Website.code-workspace
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "./tools/website"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"debug.allowBreakpointsEverywhere": true,
|
||||||
|
"git.alwaysSignOff": true,
|
||||||
|
"git.defaultBranchName": "master",
|
||||||
|
"git.openRepositoryInParentFolders": "always",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"debug.allowBreakpointsEverywhere": true
|
"debug.allowBreakpointsEverywhere": true,
|
||||||
|
"git.alwaysSignOff": true,
|
||||||
|
"git.defaultBranchName": "master",
|
||||||
|
"git.openRepositoryInParentFolders": "always",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false
|
||||||
}
|
}
|
||||||
}
|
}
|
36
Kernel/.github/workflows/flawfinder.yml
vendored
36
Kernel/.github/workflows/flawfinder.yml
vendored
@ -1,36 +0,0 @@
|
|||||||
# This workflow uses actions that are not certified by GitHub.
|
|
||||||
# They are provided by a third-party and are governed by
|
|
||||||
# separate terms of service, privacy policy, and support
|
|
||||||
# documentation.
|
|
||||||
|
|
||||||
name: flawfinder
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "master" ]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [ "master" ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
flawfinder:
|
|
||||||
name: Flawfinder
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: flawfinder_scan
|
|
||||||
uses: david-a-wheeler/flawfinder@8e4a779ad59dbfaee5da586aa9210853b701959c
|
|
||||||
with:
|
|
||||||
arguments: '--sarif ./'
|
|
||||||
output: 'flawfinder_results.sarif'
|
|
||||||
|
|
||||||
- name: Upload analysis results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v2
|
|
||||||
with:
|
|
||||||
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
|
5
Kernel/.vscode/c_boilerplates.code-snippets
vendored
5
Kernel/.vscode/c_boilerplates.code-snippets
vendored
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Fennix Kernel C++ Header": {
|
"Fennix Kernel C++ Header": {
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"scope": "c,cpp",
|
||||||
"prefix": [
|
"prefix": [
|
||||||
"head",
|
"head",
|
||||||
],
|
],
|
||||||
@ -31,6 +33,8 @@
|
|||||||
"description": "Create kernel header."
|
"description": "Create kernel header."
|
||||||
},
|
},
|
||||||
"Fennix Kernel C Header": {
|
"Fennix Kernel C Header": {
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"scope": "c,cpp",
|
||||||
"prefix": [
|
"prefix": [
|
||||||
"headc",
|
"headc",
|
||||||
],
|
],
|
||||||
@ -74,6 +78,7 @@
|
|||||||
"description": "Create kernel documentation brief."
|
"description": "Create kernel documentation brief."
|
||||||
},
|
},
|
||||||
"License": {
|
"License": {
|
||||||
|
"isFileTemplate": true,
|
||||||
"prefix": [
|
"prefix": [
|
||||||
"license",
|
"license",
|
||||||
],
|
],
|
||||||
|
5
Kernel/.vscode/c_cpp_properties.json
vendored
5
Kernel/.vscode/c_cpp_properties.json
vendored
@ -10,8 +10,6 @@
|
|||||||
"${workspaceFolder}/arch/amd64/include"
|
"${workspaceFolder}/arch/amd64/include"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"a64",
|
|
||||||
"a86",
|
|
||||||
"DEBUG=\"1\""
|
"DEBUG=\"1\""
|
||||||
],
|
],
|
||||||
"forcedInclude": [
|
"forcedInclude": [
|
||||||
@ -82,8 +80,6 @@
|
|||||||
"${workspaceFolder}/.vscode/preinclude.h"
|
"${workspaceFolder}/.vscode/preinclude.h"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"a32",
|
|
||||||
"a86",
|
|
||||||
"DEBUG=\"1\""
|
"DEBUG=\"1\""
|
||||||
],
|
],
|
||||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-fennix-gcc",
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-fennix-gcc",
|
||||||
@ -154,7 +150,6 @@
|
|||||||
"${workspaceFolder}/.vscode/preinclude.h"
|
"${workspaceFolder}/.vscode/preinclude.h"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"aa64",
|
|
||||||
"DEBUG=\"1\""
|
"DEBUG=\"1\""
|
||||||
],
|
],
|
||||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gcc",
|
"compilerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gcc",
|
||||||
|
14
Kernel/.vscode/extensions.json
vendored
14
Kernel/.vscode/extensions.json
vendored
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"jeff-hykin.better-cpp-syntax",
|
|
||||||
"aaron-bond.better-comments",
|
|
||||||
"ms-vscode.cpptools",
|
|
||||||
"maziac.hex-hover-converter",
|
|
||||||
"zixuanwang.linkerscript",
|
|
||||||
"webfreak.debug",
|
|
||||||
"ibm.output-colorizer",
|
|
||||||
"wayou.vscode-todo-highlight",
|
|
||||||
"gruntfuggly.todo-tree",
|
|
||||||
"maziac.asm-code-lens"
|
|
||||||
]
|
|
||||||
}
|
|
175
Kernel/.vscode/launch.json
vendored
175
Kernel/.vscode/launch.json
vendored
@ -1,175 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Launch QEMU and debug the kernel",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/fennix.elf",
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"args": [],
|
|
||||||
"targetArchitecture": "x64",
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
|
||||||
"miDebuggerArgs": "",
|
|
||||||
"externalConsole": false,
|
|
||||||
"additionalSOLibSearchPath": "${workspaceFolder}",
|
|
||||||
"customLaunchSetupCommands": [
|
|
||||||
{
|
|
||||||
"text": "target remote localhost:1234",
|
|
||||||
"description": "Connect to QEMU remote debugger"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "set breakpoint pending on",
|
|
||||||
"description": "Make breakpoint pending on future shared library load."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "file ${workspaceFolder}/fennix.elf",
|
|
||||||
"description": "Load binary."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "source ${workspaceFolder}/.gdbinit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"preLaunchTask": "launch-qemu"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Attach to a running VM instance",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/fennix.elf",
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"args": [],
|
|
||||||
"targetArchitecture": "x64",
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
|
||||||
"miDebuggerArgs": "",
|
|
||||||
"externalConsole": false,
|
|
||||||
"additionalSOLibSearchPath": "${workspaceFolder}",
|
|
||||||
"customLaunchSetupCommands": [
|
|
||||||
{
|
|
||||||
"text": "target remote localhost:1234",
|
|
||||||
"description": "Connect to QEMU remote debugger"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "set breakpoint pending on",
|
|
||||||
"description": "Make breakpoint pending on future shared library load."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "file ${workspaceFolder}/fennix.elf",
|
|
||||||
"description": "Load binary."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "source ${workspaceFolder}/.gdbinit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Attach to VM w/utest",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/fennix.elf",
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"args": [],
|
|
||||||
"targetArchitecture": "x64",
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
|
||||||
"miDebuggerArgs": "",
|
|
||||||
"externalConsole": false,
|
|
||||||
"additionalSOLibSearchPath": "${workspaceFolder}",
|
|
||||||
"customLaunchSetupCommands": [
|
|
||||||
{
|
|
||||||
"text": "target remote localhost:1234",
|
|
||||||
"description": "Connect to QEMU remote debugger"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "set breakpoint pending on",
|
|
||||||
"description": "Make breakpoint pending on future shared library load."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "file ${workspaceFolder}/fennix.elf",
|
|
||||||
"description": "Load binary."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
|
|
||||||
"description": "Load /bin/utest.",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "source ${workspaceFolder}/.gdbinit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"preLaunchTask": "launch-qemu",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Attach to VM w/utest_linux",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/fennix.elf",
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"args": [],
|
|
||||||
"targetArchitecture": "x64",
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gdb",
|
|
||||||
"miDebuggerArgs": "",
|
|
||||||
"externalConsole": false,
|
|
||||||
"additionalSOLibSearchPath": "${workspaceFolder}",
|
|
||||||
"customLaunchSetupCommands": [
|
|
||||||
{
|
|
||||||
"text": "target remote localhost:1234",
|
|
||||||
"description": "Connect to QEMU remote debugger"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "set breakpoint pending on",
|
|
||||||
"description": "Make breakpoint pending on future shared library load."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "file ${workspaceFolder}/fennix.elf",
|
|
||||||
"description": "Load binary."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "set debug-file-directory /usr/lib/debug",
|
|
||||||
"description": "Set debug-file-directory to /usr/lib/debug.",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest_linux",
|
|
||||||
"description": "Load /bin/utest_linux.",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "source ${workspaceFolder}/.gdbinit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"preLaunchTask": "launch-qemu",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
1
Kernel/.vscode/launch.json
vendored
Symbolic link
1
Kernel/.vscode/launch.json
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../.vscode/launch.json
|
26
Kernel/.vscode/tasks.json
vendored
26
Kernel/.vscode/tasks.json
vendored
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "launch-qemu",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "make -j$(shell nproc) build && make -C ../ build_image && make -C ../ vscode_debug_only",
|
|
||||||
"isBackground": true,
|
|
||||||
"problemMatcher": [],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "always",
|
|
||||||
"panel": "shared"
|
|
||||||
},
|
|
||||||
"options": {
|
|
||||||
"shell": {
|
|
||||||
"executable": "bash",
|
|
||||||
"args": ["-c"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
1
Kernel/.vscode/tasks.json
vendored
Symbolic link
1
Kernel/.vscode/tasks.json
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../.vscode/tasks.json
|
2659
Kernel/Doxyfile
2659
Kernel/Doxyfile
File diff suppressed because it is too large
Load Diff
@ -1,54 +0,0 @@
|
|||||||
# Licenses in the project
|
|
||||||
|
|
||||||
This project uses code from other projects, each with its own licenses.
|
|
||||||
Below are the licenses associated with these components.
|
|
||||||
Make sure to read and comply with these licenses before using or redistributing this software.
|
|
||||||
|
|
||||||
## printf
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT)
|
|
||||||
- **Location:** [library/printf.c](library/printf.c) [include/printf.h](include/printf.h)
|
|
||||||
|
|
||||||
## stb_image
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT) and Public Domain
|
|
||||||
- **Location:** [include/stb/image.h](include/stb/image.h)
|
|
||||||
|
|
||||||
## stb_image_resize
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT) and Public Domain
|
|
||||||
- **Location:** [include/stb/image_resize.h](include/stb/image_resize.h)
|
|
||||||
|
|
||||||
## cargs
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT)
|
|
||||||
- **Location:** [library/cargs.c](library/cargs.c) [include/cargs.h](include/cargs.h)
|
|
||||||
|
|
||||||
## cwalk
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT)
|
|
||||||
- **Location:** [library/cwalk.c](library/cwalk.c) [include/cwalk.h](include/cwalk.h)
|
|
||||||
|
|
||||||
## Tamsyn Font (v1.11)
|
|
||||||
|
|
||||||
- **License:** Unknown
|
|
||||||
- **Location:** [files/tamsyn-font-1.11/LICENSE](files/tamsyn-font-1.11/LICENSE)
|
|
||||||
|
|
||||||
## liballoc
|
|
||||||
|
|
||||||
- **License:** Public Domain
|
|
||||||
- **Location:** [https://raw.githubusercontent.com/blanham/liballoc/master/LICENSE](https://raw.githubusercontent.com/blanham/liballoc/master/LICENSE)
|
|
||||||
|
|
||||||
## rpmalloc
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT) and Public Domain
|
|
||||||
- **Location:** [https://raw.githubusercontent.com/mjansson/rpmalloc/develop/LICENSE](https://raw.githubusercontent.com/mjansson/rpmalloc/develop/LICENSE)
|
|
||||||
|
|
||||||
## ini.h
|
|
||||||
|
|
||||||
- **License:** The MIT License (MIT) and Public Domain
|
|
||||||
- **Location:** [include/ini.h](include/ini.h)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Please refer to the respective license files for the full text of each license.
|
|
145
Kernel/Makefile
145
Kernel/Makefile
@ -1,54 +1,38 @@
|
|||||||
# Config file
|
|
||||||
include ../Makefile.conf
|
|
||||||
|
|
||||||
KERNEL_FILENAME = fennix.elf
|
KERNEL_FILENAME = fennix.elf
|
||||||
|
|
||||||
CC = ../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
|
||||||
CPP = ../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
|
||||||
LD = ../$(COMPILER_PATH)/$(COMPILER_ARCH)ld
|
|
||||||
AS = ../$(COMPILER_PATH)/$(COMPILER_ARCH)as
|
|
||||||
NM = ../$(COMPILER_PATH)/$(COMPILER_ARCH)nm
|
|
||||||
OBJCOPY = ../$(COMPILER_PATH)/$(COMPILER_ARCH)objcopy
|
|
||||||
OBJDUMP = ../$(COMPILER_PATH)/$(COMPILER_ARCH)objdump
|
|
||||||
GDB = ../$(COMPILER_PATH)/$(COMPILER_ARCH)gdb
|
|
||||||
|
|
||||||
RUST_TARGET_PATH = arch/$(OSARCH)/rust-target.json
|
|
||||||
|
|
||||||
GIT_COMMIT = $(shell git rev-parse HEAD)
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||||
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
|
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
HEADERS = $(sort $(dir $(wildcard ./include/*))) $(sort $(dir $(wildcard ./include_std/*)))
|
HEADERS := $(sort $(dir $(wildcard ./include/*))) $(sort $(dir $(wildcard ./include_std/*)))
|
||||||
INCLUDE_DIR = -I./include -I./include_std
|
INCLUDE_DIR = -I./include -I./include_std
|
||||||
|
|
||||||
BMP_SOURCES = $(shell find ./ -type f -name '*.bmp')
|
BMP_SOURCES := $(shell find ./ -type f -name '*.bmp')
|
||||||
PSF_SOURCES = $(shell find ./ -type f -name '*.psf')
|
PSF_SOURCES := $(shell find ./ -type f -name '*.psf')
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
S_SOURCES := $(shell find ./ -type f -name '*.S' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
||||||
s_SOURCES = $(shell find ./ -type f -name '*.s' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
s_SOURCES := $(shell find ./ -type f -name '*.s' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
C_SOURCES := $(shell find ./ -type f -name '*.c' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
CXX_SOURCES := $(shell find ./ -type f -name '*.cpp' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
||||||
HEADERS += $(sort $(dir $(wildcard ./arch/amd64/include/*)))
|
|
||||||
INCLUDE_DIR += -I./arch/amd64/include
|
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
S_SOURCES := $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||||
s_SOURCES = $(shell find ./ -type f -name '*.s' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
s_SOURCES := $(shell find ./ -type f -name '*.s' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
C_SOURCES := $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
CXX_SOURCES := $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||||
HEADERS += $(sort $(dir $(wildcard ./arch/i386/include/*)))
|
|
||||||
INCLUDE_DIR += -I./arch/i386/include
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
S_SOURCES := $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
||||||
s_SOURCES = $(shell find ./ -type f -name '*.s' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
s_SOURCES := $(shell find ./ -type f -name '*.s' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
||||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
C_SOURCES := $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
||||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
CXX_SOURCES := $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
||||||
HEADERS += $(sort $(dir $(wildcard ./arch/aarch64/include/*)))
|
endif # OSARCH
|
||||||
INCLUDE_DIR += -I./arch/aarch64/include
|
|
||||||
endif
|
|
||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(s_SOURCES:.s=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
|
||||||
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CPP_SOURCES:.cpp=.su)
|
|
||||||
GCNO_OBJ = $(C_SOURCES:.c=.gcno) $(CPP_SOURCES:.cpp=.gcno)
|
|
||||||
|
|
||||||
LDFLAGS := -Wl,-Map kernel.map -static -nostdlib -nodefaultlibs -nolibc
|
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)
|
||||||
|
STACK_USAGE_OBJ = $(C_SOURCES:.c=.su) $(CXX_SOURCES:.cpp=.su)
|
||||||
|
GCNO_OBJ = $(C_SOURCES:.c=.gcno) $(CXX_SOURCES:.cpp=.gcno)
|
||||||
|
|
||||||
|
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"
|
# 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
|
# -Wconversion this may be re-added later
|
||||||
@ -58,6 +42,8 @@ WARNCFLAG = -Wall -Wextra \
|
|||||||
-Wstrict-overflow=5 -Wno-error=cpp -Werror \
|
-Wstrict-overflow=5 -Wno-error=cpp -Werror \
|
||||||
-Wno-unused-parameter
|
-Wno-unused-parameter
|
||||||
|
|
||||||
|
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
||||||
|
|
||||||
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||||
CFLAGS := \
|
CFLAGS := \
|
||||||
$(INCLUDE_DIR) \
|
$(INCLUDE_DIR) \
|
||||||
@ -66,40 +52,19 @@ CFLAGS := \
|
|||||||
-DKERNEL_ARCH='"$(OSARCH)"' \
|
-DKERNEL_ARCH='"$(OSARCH)"' \
|
||||||
-DKERNEL_VERSION='"$(KERNEL_VERSION)"' \
|
-DKERNEL_VERSION='"$(KERNEL_VERSION)"' \
|
||||||
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
||||||
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
|
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' \
|
||||||
|
-fno-pic -fno-pie -mno-red-zone -fno-builtin
|
||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
CFLAGS += -march=core2 -mcmodel=kernel -m64
|
||||||
CFLAGS += -fno-pic -fno-pie -mno-red-zone -march=core2 \
|
LDFLAGS += -Tarch/amd64/linker.ld
|
||||||
-mcmodel=kernel -fno-builtin -Da64 -Da86 -m64
|
|
||||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld \
|
|
||||||
-fno-pic -fno-pie \
|
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
|
||||||
-zmax-page-size=0x1000 \
|
|
||||||
-Wl,-Map kernel.map
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
|
CFLAGS += -march=pentium -m32
|
||||||
CFLAGS += -fno-pic -fno-pie -mno-red-zone -march=pentium \
|
LDFLAGS += -Tarch/i386/linker.ld
|
||||||
-fno-builtin -Da32 -Da86 -m32
|
|
||||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
|
||||||
LDFLAGS += -Tarch/i386/linker.ld \
|
|
||||||
-fno-pic -fno-pie \
|
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
|
||||||
-zmax-page-size=0x1000 \
|
|
||||||
-Wl,-Map kernel.map
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
CFLAGS +=
|
||||||
CFLAGS += -fno-builtin -Wstack-protector -Daa64 -fPIC -mno-outline-atomics
|
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||||
CFLAG_STACK_PROTECTOR := -fstack-protector-all
|
endif # OSARCH
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld -fPIC -pie \
|
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
|
||||||
-zmax-page-size=0x1000 \
|
|
||||||
-Wl,-Map kernel.map
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
# -finstrument-functions for __cyg_profile_func_enter & __cyg_profile_func_exit. Used for profiling and debugging.
|
# -finstrument-functions for __cyg_profile_func_enter & __cyg_profile_func_exit. Used for profiling and debugging.
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
@ -109,17 +74,17 @@ ifeq ($(DEBUG), 1)
|
|||||||
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage -fsanitize=undefined
|
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage -fsanitize=undefined
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
CFLAGS += -fverbose-asm
|
CFLAGS += -fverbose-asm
|
||||||
endif
|
endif # amd64
|
||||||
ifneq ($(OSARCH), aarch64)
|
ifneq ($(OSARCH), aarch64)
|
||||||
CFLAGS += -fstack-check
|
CFLAGS += -fstack-check
|
||||||
endif
|
endif # aarch64
|
||||||
LDFLAGS += -ggdb3 -O0
|
LDFLAGS += -ggdb3 -O0
|
||||||
ASFLAGS += -g --gstabs+ --gdwarf-5 -D
|
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
|
WARNCFLAG += -Wno-unused-function -Wno-maybe-uninitialized -Wno-builtin-declaration-mismatch -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable
|
||||||
endif
|
endif # DEBUG
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$(error Please specify a target)
|
$(error Do not run this Makefile directly!)
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
$(info Nothing to prepare)
|
$(info Nothing to prepare)
|
||||||
@ -131,51 +96,51 @@ ifeq (,$(wildcard $(KERNEL_FILENAME)))
|
|||||||
$(error $(KERNEL_FILENAME) does not exist)
|
$(error $(KERNEL_FILENAME) does not exist)
|
||||||
endif
|
endif
|
||||||
$(info Dumping $(KERNEL_FILENAME) in AT T syntax...)
|
$(info Dumping $(KERNEL_FILENAME) in AT T syntax...)
|
||||||
$(OBJDUMP) -D -g -s -d $(KERNEL_FILENAME) > kernel_dump.map
|
$(__CONF_OBJDUMP) -D -g -s -d $(KERNEL_FILENAME) > kernel_dump.map
|
||||||
$(info Dumping $(KERNEL_FILENAME) in Intel syntax...)
|
$(info Dumping $(KERNEL_FILENAME) in Intel syntax...)
|
||||||
$(OBJDUMP) -M intel -D -g -s -d $(KERNEL_FILENAME) > kernel_dump_intel.map
|
$(__CONF_OBJDUMP) -M intel -D -g -s -d $(KERNEL_FILENAME) > kernel_dump_intel.map
|
||||||
|
|
||||||
$(KERNEL_FILENAME): $(OBJ)
|
$(KERNEL_FILENAME): $(OBJ)
|
||||||
$(info Linking $@)
|
$(info Linking $@)
|
||||||
$(CC) $(LDFLAGS) $(OBJ) -o $@
|
$(__CONF_CC) $(LDFLAGS) $(OBJ) -o $@
|
||||||
# $(CC) $(LDFLAGS) $(OBJ) -mno-red-zone -lgcc -o $@
|
# $(__CONF_CC) $(LDFLAGS) $(OBJ) -mno-red-zone -lgcc -o $@
|
||||||
|
|
||||||
%.o: %.c $(HEADERS)
|
%.o: %.c $(HEADERS)
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
$(CC) $(CFLAGS) $(CFLAG_STACK_PROTECTOR) $(WARNCFLAG) -std=c17 -c $< -o $@
|
$(__CONF_CC) $(CFLAGS) $(CFLAG_STACK_PROTECTOR) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||||
|
|
||||||
# https://gcc.gnu.org/projects/cxx-status.html
|
# https://gcc.gnu.org/projects/cxx-status.html
|
||||||
%.o: %.cpp $(HEADERS)
|
%.o: %.cpp $(HEADERS)
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
$(CPP) $(CFLAGS) -fcoroutines $(CFLAG_STACK_PROTECTOR) $(WARNCFLAG) -std=c++20 -c $< -o $@ -fno-rtti
|
$(__CONF_CXX) $(CFLAGS) -fcoroutines $(CFLAG_STACK_PROTECTOR) $(WARNCFLAG) -std=c++20 -c $< -o $@ -fno-rtti
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
$(AS) $(ASFLAGS) -c $< -o $@
|
$(__CONF_AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
%.o: %.s
|
%.o: %.s
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
$(AS) $(ASFLAGS) -c $< -o $@
|
$(__CONF_AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
%.o: %.psf
|
%.o: %.psf
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
$(OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
$(OBJCOPY) -O elf32-i386 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf32-i386 -I binary $< $@
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
$(OBJCOPY) -O elf64-littleaarch64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-littleaarch64 -I binary $< $@
|
||||||
endif
|
endif
|
||||||
$(NM) $@
|
$(__CONF_NM) $@
|
||||||
|
|
||||||
%.o: %.bmp
|
%.o: %.bmp
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
$(OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-x86-64 -I binary $< $@
|
||||||
else ifeq ($(OSARCH), i386)
|
else ifeq ($(OSARCH), i386)
|
||||||
$(OBJCOPY) -O elf32-i386 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf32-i386 -I binary $< $@
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
$(OBJCOPY) -O elf64-littlearch64 -I binary $< $@
|
$(__CONF_OBJCOPY) -O elf64-littlearch64 -I binary $< $@
|
||||||
endif
|
endif
|
||||||
$(NM) $@
|
$(__CONF_NM) $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f kernel.map kernel_dump.map kernel_dump_intel.map $(OBJ) $(STACK_USAGE_OBJ) $(GCNO_OBJ) $(KERNEL_FILENAME)
|
rm -f kernel.map kernel_dump.map kernel_dump_intel.map $(OBJ) $(STACK_USAGE_OBJ) $(GCNO_OBJ) $(KERNEL_FILENAME)
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
- [ ] Fix std::string.
|
- [ ] Fix std::string.
|
||||||
- [x] Rewrite PS/2 drivers.
|
- [x] Rewrite PS/2 drivers.
|
||||||
- [ ] Improve signal handling.
|
- [ ] Improve signal handling.
|
||||||
|
- [ ] Handle empty initrd.
|
||||||
|
- [ ] Fix CoW.
|
||||||
|
|
||||||
- [ ] Improve the way the kernel crashes.
|
- [ ] Improve the way the kernel crashes.
|
||||||
- Add panic() function.
|
- Add panic() function.
|
||||||
|
@ -85,6 +85,5 @@ SECTIONS
|
|||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
*(.comment*)
|
*(.comment*)
|
||||||
*(.note*)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,10 +139,14 @@ namespace InterruptDescriptorTable
|
|||||||
"pushq %r14\n"
|
"pushq %r14\n"
|
||||||
"pushq %r15\n"
|
"pushq %r15\n"
|
||||||
|
|
||||||
"movq %ds, %rax\n pushq %rax\n"
|
// "movq %ds, %rax\n pushq %rax\n"
|
||||||
"movq %es, %rax\n pushq %rax\n"
|
// "movq %es, %rax\n pushq %rax\n"
|
||||||
"movq %fs, %rax\n pushq %rax\n"
|
// "movq %fs, %rax\n pushq %rax\n"
|
||||||
"movq %gs, %rax\n pushq %rax\n"
|
// "movq %gs, %rax\n pushq %rax\n"
|
||||||
|
"pushq %rax\n"
|
||||||
|
"pushq %rax\n"
|
||||||
|
"pushq %rax\n"
|
||||||
|
"pushq %rax\n"
|
||||||
|
|
||||||
"movq %dr7, %rax\n pushq %rax\n"
|
"movq %dr7, %rax\n pushq %rax\n"
|
||||||
"movq %dr6, %rax\n pushq %rax\n"
|
"movq %dr6, %rax\n pushq %rax\n"
|
||||||
@ -173,10 +177,14 @@ namespace InterruptDescriptorTable
|
|||||||
"popq %rax\n movq %rax, %dr6\n"
|
"popq %rax\n movq %rax, %dr6\n"
|
||||||
"popq %rax\n movq %rax, %dr7\n"
|
"popq %rax\n movq %rax, %dr7\n"
|
||||||
|
|
||||||
"popq %rax\n movq %rax, %gs\n"
|
"popq %rax\n"
|
||||||
"popq %rax\n movq %rax, %fs\n"
|
"popq %rax\n"
|
||||||
"popq %rax\n movq %rax, %es\n"
|
"popq %rax\n"
|
||||||
"popq %rax\n movq %rax, %ds\n"
|
"popq %rax\n"
|
||||||
|
// "popq %rax\n movq %rax, %gs\n"
|
||||||
|
// "popq %rax\n movq %rax, %fs\n"
|
||||||
|
// "popq %rax\n movq %rax, %es\n"
|
||||||
|
// "popq %rax\n movq %rax, %ds\n"
|
||||||
|
|
||||||
"popq %r15\n"
|
"popq %r15\n"
|
||||||
"popq %r14\n"
|
"popq %r14\n"
|
||||||
@ -273,13 +281,13 @@ namespace InterruptDescriptorTable
|
|||||||
/* TODO: Add advanced check so we won't update the cr3 when not needed */
|
/* TODO: Add advanced check so we won't update the cr3 when not needed */
|
||||||
|
|
||||||
"movq %cr3, %rax\n pushq %rax\n" /* Push opt */
|
"movq %cr3, %rax\n pushq %rax\n" /* Push opt */
|
||||||
"pushq %rax\n" /* Push ppt */
|
"pushq %rax\n" /* Push ppt */
|
||||||
|
|
||||||
"movq %rsp, %rdi\n"
|
"movq %rsp, %rdi\n"
|
||||||
"call SchedulerInterruptHandler\n"
|
"call SchedulerInterruptHandler\n"
|
||||||
|
|
||||||
"popq %rax\n movq %rax, %cr3\n" /* Restore to ppt */
|
"popq %rax\n movq %rax, %cr3\n" /* Restore to ppt */
|
||||||
"popq %rax\n" /* Pop opt */
|
"popq %rax\n" /* Pop opt */
|
||||||
|
|
||||||
"popq %r15\n"
|
"popq %r15\n"
|
||||||
"popq %r14\n"
|
"popq %r14\n"
|
||||||
@ -660,7 +668,7 @@ namespace InterruptDescriptorTable
|
|||||||
SetEntry(0xb, InterruptHandler_0xb, IST1, INTERRUPT_GATE_64BIT, RING0, (!DebuggerIsAttached), GDT_KERNEL_CODE);
|
SetEntry(0xb, InterruptHandler_0xb, IST1, INTERRUPT_GATE_64BIT, RING0, (!DebuggerIsAttached), GDT_KERNEL_CODE);
|
||||||
SetEntry(0xc, InterruptHandler_0xc, IST3, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
SetEntry(0xc, InterruptHandler_0xc, IST3, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
||||||
SetEntry(0xd, InterruptHandler_0xd, IST3, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
SetEntry(0xd, InterruptHandler_0xd, IST3, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
||||||
SetEntry(0xe, InterruptHandler_0xe, IST3, INTERRUPT_GATE_64BIT, RING0, EnableISRs /* FIXME: CoW? */, GDT_KERNEL_CODE);
|
SetEntry(0xe, InterruptHandler_0xe, IST3, INTERRUPT_GATE_64BIT, RING0, true /* FIXME: CoW? */, GDT_KERNEL_CODE);
|
||||||
SetEntry(0xf, InterruptHandler_0xf, IST1, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
SetEntry(0xf, InterruptHandler_0xf, IST1, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
||||||
SetEntry(0x10, InterruptHandler_0x10, IST1, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
SetEntry(0x10, InterruptHandler_0x10, IST1, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
||||||
SetEntry(0x11, InterruptHandler_0x11, IST1, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
SetEntry(0x11, InterruptHandler_0x11, IST1, INTERRUPT_GATE_64BIT, RING0, EnableISRs, GDT_KERNEL_CODE);
|
||||||
|
@ -124,6 +124,5 @@ SECTIONS
|
|||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
*(.comment*)
|
*(.comment*)
|
||||||
*(.note*)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,5 @@ SECTIONS
|
|||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
*(.comment*)
|
*(.comment*)
|
||||||
*(.note*)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
|
|
||||||
#include "../kernel.h"
|
#include "../kernel.h"
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
using namespace CPU::x64;
|
using namespace CPU::x64;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
using namespace CPU::x32;
|
using namespace CPU::x32;
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace CPU
|
namespace CPU
|
||||||
@ -40,19 +40,19 @@ namespace CPU
|
|||||||
static char Vendor[13] = {0};
|
static char Vendor[13] = {0};
|
||||||
if (Vendor[0] != 0)
|
if (Vendor[0] != 0)
|
||||||
return Vendor;
|
return Vendor;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
x64::cpuid(0x0, &eax, &ebx, &ecx, &edx);
|
x64::cpuid(0x0, &eax, &ebx, &ecx, &edx);
|
||||||
memcpy(Vendor + 0, &ebx, 4);
|
memcpy(Vendor + 0, &ebx, 4);
|
||||||
memcpy(Vendor + 4, &edx, 4);
|
memcpy(Vendor + 4, &edx, 4);
|
||||||
memcpy(Vendor + 8, &ecx, 4);
|
memcpy(Vendor + 8, &ecx, 4);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
x32::cpuid(0x0, &eax, &ebx, &ecx, &edx);
|
x32::cpuid(0x0, &eax, &ebx, &ecx, &edx);
|
||||||
memcpy(Vendor + 0, &ebx, 4);
|
memcpy(Vendor + 0, &ebx, 4);
|
||||||
memcpy(Vendor + 4, &edx, 4);
|
memcpy(Vendor + 4, &edx, 4);
|
||||||
memcpy(Vendor + 8, &ecx, 4);
|
memcpy(Vendor + 8, &ecx, 4);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#error "Not implemented"
|
#error "Not implemented"
|
||||||
#endif
|
#endif
|
||||||
return Vendor;
|
return Vendor;
|
||||||
@ -63,7 +63,7 @@ namespace CPU
|
|||||||
static char Name[49] = {0};
|
static char Name[49] = {0};
|
||||||
if (Name[0] != 0)
|
if (Name[0] != 0)
|
||||||
return Name;
|
return Name;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
x64::cpuid(0x80000002, &eax, &ebx, &ecx, &edx);
|
x64::cpuid(0x80000002, &eax, &ebx, &ecx, &edx);
|
||||||
memcpy(Name + 0, &eax, 4);
|
memcpy(Name + 0, &eax, 4);
|
||||||
@ -80,7 +80,7 @@ namespace CPU
|
|||||||
memcpy(Name + 36, &ebx, 4);
|
memcpy(Name + 36, &ebx, 4);
|
||||||
memcpy(Name + 40, &ecx, 4);
|
memcpy(Name + 40, &ecx, 4);
|
||||||
memcpy(Name + 44, &edx, 4);
|
memcpy(Name + 44, &edx, 4);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
x32::cpuid(0x80000002, &eax, &ebx, &ecx, &edx);
|
x32::cpuid(0x80000002, &eax, &ebx, &ecx, &edx);
|
||||||
memcpy(Name + 0, &eax, 4);
|
memcpy(Name + 0, &eax, 4);
|
||||||
@ -97,7 +97,7 @@ namespace CPU
|
|||||||
memcpy(Name + 36, &ebx, 4);
|
memcpy(Name + 36, &ebx, 4);
|
||||||
memcpy(Name + 40, &ecx, 4);
|
memcpy(Name + 40, &ecx, 4);
|
||||||
memcpy(Name + 44, &edx, 4);
|
memcpy(Name + 44, &edx, 4);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#error "Not implemented"
|
#error "Not implemented"
|
||||||
#endif
|
#endif
|
||||||
return Name;
|
return Name;
|
||||||
@ -108,7 +108,7 @@ namespace CPU
|
|||||||
static char Hypervisor[13] = {0};
|
static char Hypervisor[13] = {0};
|
||||||
if (Hypervisor[0] != 0)
|
if (Hypervisor[0] != 0)
|
||||||
return Hypervisor;
|
return Hypervisor;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
x64::cpuid(0x1, &eax, &ebx, &ecx, &edx);
|
x64::cpuid(0x1, &eax, &ebx, &ecx, &edx);
|
||||||
if (!(ecx & (1 << 31))) /* Intel & AMD are the same */
|
if (!(ecx & (1 << 31))) /* Intel & AMD are the same */
|
||||||
@ -124,7 +124,7 @@ namespace CPU
|
|||||||
memcpy(Hypervisor + 0, &ebx, 4);
|
memcpy(Hypervisor + 0, &ebx, 4);
|
||||||
memcpy(Hypervisor + 4, &ecx, 4);
|
memcpy(Hypervisor + 4, &ecx, 4);
|
||||||
memcpy(Hypervisor + 8, &edx, 4);
|
memcpy(Hypervisor + 8, &edx, 4);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
x32::cpuid(0x1, &eax, &ebx, &ecx, &edx);
|
x32::cpuid(0x1, &eax, &ebx, &ecx, &edx);
|
||||||
if (!(ecx & (1 << 31))) /* Intel & AMD are the same */
|
if (!(ecx & (1 << 31))) /* Intel & AMD are the same */
|
||||||
@ -140,7 +140,7 @@ namespace CPU
|
|||||||
memcpy(Hypervisor + 0, &ebx, 4);
|
memcpy(Hypervisor + 0, &ebx, 4);
|
||||||
memcpy(Hypervisor + 4, &ecx, 4);
|
memcpy(Hypervisor + 4, &ecx, 4);
|
||||||
memcpy(Hypervisor + 8, &edx, 4);
|
memcpy(Hypervisor + 8, &edx, 4);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#error "Not implemented"
|
#error "Not implemented"
|
||||||
#endif
|
#endif
|
||||||
return Hypervisor;
|
return Hypervisor;
|
||||||
@ -153,17 +153,17 @@ namespace CPU
|
|||||||
case Check:
|
case Check:
|
||||||
{
|
{
|
||||||
uintptr_t Flags;
|
uintptr_t Flags;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
asmv("pushfq");
|
asmv("pushfq");
|
||||||
asmv("popq %0"
|
asmv("popq %0"
|
||||||
: "=r"(Flags));
|
: "=r"(Flags));
|
||||||
return Flags & (1 << 9);
|
return Flags & (1 << 9);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
asmv("pushfl");
|
asmv("pushfl");
|
||||||
asmv("popl %0"
|
asmv("popl %0"
|
||||||
: "=r"(Flags));
|
: "=r"(Flags));
|
||||||
return Flags & (1 << 9);
|
return Flags & (1 << 9);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("mrs %0, cpsr"
|
asmv("mrs %0, cpsr"
|
||||||
: "=r"(Flags));
|
: "=r"(Flags));
|
||||||
return Flags & (1 << 7);
|
return Flags & (1 << 7);
|
||||||
@ -171,18 +171,18 @@ namespace CPU
|
|||||||
}
|
}
|
||||||
case Enable:
|
case Enable:
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("sti");
|
asmv("sti");
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("cpsie i");
|
asmv("cpsie i");
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case Disable:
|
case Disable:
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("cli");
|
asmv("cli");
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("cpsid i");
|
asmv("cpsid i");
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@ -197,7 +197,7 @@ namespace CPU
|
|||||||
void *PageTable(void *PT)
|
void *PageTable(void *PT)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
asmv("movq %%cr3, %0"
|
asmv("movq %%cr3, %0"
|
||||||
: "=r"(ret));
|
: "=r"(ret));
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ namespace CPU
|
|||||||
: "r"(PT)
|
: "r"(PT)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
asmv("movl %%cr3, %0"
|
asmv("movl %%cr3, %0"
|
||||||
: "=r"(ret));
|
: "=r"(ret));
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ namespace CPU
|
|||||||
: "r"(PT)
|
: "r"(PT)
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("mrs %0, ttbr0_el1"
|
asmv("mrs %0, ttbr0_el1"
|
||||||
: "=r"(ret));
|
: "=r"(ret));
|
||||||
|
|
||||||
@ -392,13 +392,13 @@ namespace CPU
|
|||||||
{
|
{
|
||||||
// TODO: Get the counter from the x2APIC or any other timer that is available. (TSC is not available on all CPUs)
|
// TODO: Get the counter from the x2APIC or any other timer that is available. (TSC is not available on all CPUs)
|
||||||
uint64_t Counter;
|
uint64_t Counter;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint32_t eax, edx;
|
uint32_t eax, edx;
|
||||||
asmv("rdtsc"
|
asmv("rdtsc"
|
||||||
: "=a"(eax),
|
: "=a"(eax),
|
||||||
"=d"(edx));
|
"=d"(edx));
|
||||||
Counter = ((uint64_t)eax) | (((uint64_t)edx) << 32);
|
Counter = ((uint64_t)eax) | (((uint64_t)edx) << 32);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("mrs %0, cntvct_el0"
|
asmv("mrs %0, cntvct_el0"
|
||||||
: "=r"(Counter));
|
: "=r"(Counter));
|
||||||
#endif
|
#endif
|
||||||
@ -413,7 +413,7 @@ namespace CPU
|
|||||||
#warning "TODO: Proper SIMD support"
|
#warning "TODO: Proper SIMD support"
|
||||||
return SIMD_NONE;
|
return SIMD_NONE;
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
static uint64_t SIMDType = SIMD_NONE;
|
static uint64_t SIMDType = SIMD_NONE;
|
||||||
|
|
||||||
if (likely(SIMDType != SIMD_NONE))
|
if (likely(SIMDType != SIMD_NONE))
|
||||||
@ -495,7 +495,7 @@ namespace CPU
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug("No SIMD support.");
|
debug("No SIMD support.");
|
||||||
#endif // a64 || a32
|
#endif // __amd64__ || __i386__
|
||||||
return SIMD_NONE;
|
return SIMD_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +504,7 @@ namespace CPU
|
|||||||
if (unlikely(!SSEEnabled))
|
if (unlikely(!SSEEnabled))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
|
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
|
||||||
{
|
{
|
||||||
CPU::x86::AMD::CPUID0x00000001 cpuid;
|
CPU::x86::AMD::CPUID0x00000001 cpuid;
|
||||||
@ -545,7 +545,7 @@ namespace CPU
|
|||||||
else if (Type == SIMD_SSE)
|
else if (Type == SIMD_SSE)
|
||||||
return cpuid.EDX.SSE;
|
return cpuid.EDX.SSE;
|
||||||
}
|
}
|
||||||
#endif // a64 || a32
|
#endif // __amd64__ || __i386__
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,48 +27,9 @@ NewLock(DebuggerLock);
|
|||||||
|
|
||||||
extern bool serialports[8];
|
extern bool serialports[8];
|
||||||
|
|
||||||
EXTERNC NIF void uart_wrapper(char c, void *unused)
|
EXTERNC NIF void uart_wrapper(char c, void *)
|
||||||
{
|
{
|
||||||
static int once = 0;
|
uart.DebugWrite(c);
|
||||||
if (unlikely(!once++))
|
|
||||||
{
|
|
||||||
uint8_t com = inb(0x3F8);
|
|
||||||
if (com != 0xFF)
|
|
||||||
{
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 1), 0x00); // Disable all interrupts
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 3), 0x80); // Enable DLAB (set baud rate divisor)
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 0), 0x1); // Set divisor to 1 (lo byte) 115200 baud
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 1), 0x0); // (hi byte)
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 3), 0x03); // 8 bits, no parity, one stop bit
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 2), 0xC7); // Enable FIFO, clear them, with 14-byte threshold
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 4), 0x0B); // IRQs enabled, RTS/DSR set
|
|
||||||
|
|
||||||
/* FIXME https://wiki.osdev.org/Serial_Ports */
|
|
||||||
// outb(s_cst(uint16_t, 0x3F8 + 0), 0x1E);
|
|
||||||
// outb(s_cst(uint16_t, 0x3F8 + 0), 0xAE);
|
|
||||||
// Check if the serial port is faulty.
|
|
||||||
// if (inb(s_cst(uint16_t, 0x3F8 + 0)) != 0xAE)
|
|
||||||
// {
|
|
||||||
// static int once = 0;
|
|
||||||
// if (!once++)
|
|
||||||
// warn("Serial port %#llx is faulty.", 0x3F8);
|
|
||||||
// // serialports[0x3F8] = false; // ignore for now
|
|
||||||
// // return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Set to normal operation mode.
|
|
||||||
outb(s_cst(uint16_t, 0x3F8 + 4), 0x0F);
|
|
||||||
serialports[0] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (likely(serialports[0]))
|
|
||||||
{
|
|
||||||
while ((inb(s_cst(uint16_t, 0x3F8 + 5)) & 0x20) == 0)
|
|
||||||
;
|
|
||||||
outb(0x3F8, c);
|
|
||||||
}
|
|
||||||
UNUSED(unused);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline NIF bool WritePrefix(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, va_list args)
|
static inline NIF bool WritePrefix(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, va_list args)
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
#include <smp.hpp>
|
#include <smp.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../arch/amd64/cpu/apic.hpp"
|
#include "../arch/amd64/cpu/apic.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#include "../arch/i386/cpu/apic.hpp"
|
#include "../arch/i386/cpu/apic.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "../kernel.h"
|
#include "../kernel.h"
|
||||||
|
@ -23,15 +23,15 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../arch/amd64/cpu/apic.hpp"
|
#include "../arch/amd64/cpu/apic.hpp"
|
||||||
#include "../arch/amd64/cpu/gdt.hpp"
|
#include "../arch/amd64/cpu/gdt.hpp"
|
||||||
#include "../arch/amd64/cpu/idt.hpp"
|
#include "../arch/amd64/cpu/idt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#include "../arch/i386/cpu/apic.hpp"
|
#include "../arch/i386/cpu/apic.hpp"
|
||||||
#include "../arch/i386/cpu/gdt.hpp"
|
#include "../arch/i386/cpu/gdt.hpp"
|
||||||
#include "../arch/i386/cpu/idt.hpp"
|
#include "../arch/i386/cpu/idt.hpp"
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../kernel.h"
|
#include "../kernel.h"
|
||||||
@ -106,15 +106,15 @@ namespace Interrupts
|
|||||||
std::atomic_uint SortEvents = SORT_START / SORT_DIVIDER;
|
std::atomic_uint SortEvents = SORT_START / SORT_DIVIDER;
|
||||||
constexpr uint32_t SORT_ITR = (SORT_START * 100) / SORT_DIVIDER;
|
constexpr uint32_t SORT_ITR = (SORT_START * 100) / SORT_DIVIDER;
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
/* APIC::APIC */ void *apic[MAX_CPU] = {nullptr};
|
/* APIC::APIC */ void *apic[MAX_CPU] = {nullptr};
|
||||||
/* APIC::Timer */ void *apicTimer[MAX_CPU] = {nullptr};
|
/* APIC::Timer */ void *apicTimer[MAX_CPU] = {nullptr};
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Initialize(int Core)
|
void Initialize(int Core)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
GlobalDescriptorTable::Init(Core);
|
GlobalDescriptorTable::Init(Core);
|
||||||
InterruptDescriptorTable::Init(Core);
|
InterruptDescriptorTable::Init(Core);
|
||||||
CPUData *CoreData = GetCPU(Core);
|
CPUData *CoreData = GetCPU(Core);
|
||||||
@ -133,7 +133,7 @@ namespace Interrupts
|
|||||||
debug("Stack for core %d is %#lx (Address: %#lx)",
|
debug("Stack for core %d is %#lx (Address: %#lx)",
|
||||||
Core, CoreData->Stack, CoreData->Stack - STACK_SIZE);
|
Core, CoreData->Stack, CoreData->Stack - STACK_SIZE);
|
||||||
InitializeSystemCalls();
|
InitializeSystemCalls();
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
GlobalDescriptorTable::Init(Core);
|
GlobalDescriptorTable::Init(Core);
|
||||||
InterruptDescriptorTable::Init(Core);
|
InterruptDescriptorTable::Init(Core);
|
||||||
CPUData *CoreData = GetCPU(Core);
|
CPUData *CoreData = GetCPU(Core);
|
||||||
@ -151,14 +151,14 @@ namespace Interrupts
|
|||||||
}
|
}
|
||||||
debug("Stack for core %d is %#lx (Address: %#lx)",
|
debug("Stack for core %d is %#lx (Address: %#lx)",
|
||||||
Core, CoreData->Stack, CoreData->Stack - STACK_SIZE);
|
Core, CoreData->Stack, CoreData->Stack - STACK_SIZE);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
warn("aarch64 is not supported yet");
|
warn("aarch64 is not supported yet");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Enable(int Core)
|
void Enable(int Core)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (((ACPI::MADT *)PowerManager->GetMADT())->LAPICAddress != nullptr)
|
if (((ACPI::MADT *)PowerManager->GetMADT())->LAPICAddress != nullptr)
|
||||||
{
|
{
|
||||||
// TODO: This function is called by SMP too. Do not initialize timers that doesn't support multiple cores.
|
// TODO: This function is called by SMP too. Do not initialize timers that doesn't support multiple cores.
|
||||||
@ -171,7 +171,7 @@ namespace Interrupts
|
|||||||
error("LAPIC not found");
|
error("LAPIC not found");
|
||||||
// TODO: PIC
|
// TODO: PIC
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
warn("aarch64 is not supported yet");
|
warn("aarch64 is not supported yet");
|
||||||
#endif
|
#endif
|
||||||
CPU::Interrupts(CPU::Enable);
|
CPU::Interrupts(CPU::Enable);
|
||||||
@ -180,14 +180,14 @@ namespace Interrupts
|
|||||||
void InitializeTimer(int Core)
|
void InitializeTimer(int Core)
|
||||||
{
|
{
|
||||||
// TODO: This function is called by SMP too. Do not initialize timers that doesn't support multiple cores.
|
// TODO: This function is called by SMP too. Do not initialize timers that doesn't support multiple cores.
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (apic[Core] != nullptr)
|
if (apic[Core] != nullptr)
|
||||||
apicTimer[Core] = new APIC::Timer((APIC::APIC *)apic[Core]);
|
apicTimer[Core] = new APIC::Timer((APIC::APIC *)apic[Core]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fixme("apic not found");
|
fixme("apic not found");
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
warn("aarch64 is not supported yet");
|
warn("aarch64 is not supported yet");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -333,12 +333,12 @@ namespace Interrupts
|
|||||||
public:
|
public:
|
||||||
AutoSwitchPageTable()
|
AutoSwitchPageTable()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %%cr3, %0" : "=r"(Original));
|
asmv("mov %%cr3, %0" : "=r"(Original));
|
||||||
#endif
|
#endif
|
||||||
if (likely(Original == KernelPageTable))
|
if (likely(Original == KernelPageTable))
|
||||||
return;
|
return;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %0, %%cr3" : : "r"(KernelPageTable));
|
asmv("mov %0, %%cr3" : : "r"(KernelPageTable));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ namespace Interrupts
|
|||||||
{
|
{
|
||||||
if (likely(Original == KernelPageTable))
|
if (likely(Original == KernelPageTable))
|
||||||
return;
|
return;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %0, %%cr3" : : "r"(Original));
|
asmv("mov %0, %%cr3" : : "r"(Original));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ namespace Interrupts
|
|||||||
while (it != RegisteredEvents.end())
|
while (it != RegisteredEvents.end())
|
||||||
{
|
{
|
||||||
int iEvNum = it->IRQ;
|
int iEvNum = it->IRQ;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
iEvNum += CPU::x86::IRQ0;
|
iEvNum += CPU::x86::IRQ0;
|
||||||
#endif
|
#endif
|
||||||
if (iEvNum == s_cst(int, Frame->InterruptNumber))
|
if (iEvNum == s_cst(int, Frame->InterruptNumber))
|
||||||
@ -402,7 +402,7 @@ namespace Interrupts
|
|||||||
{
|
{
|
||||||
KernelPageTable->Update();
|
KernelPageTable->Update();
|
||||||
CPU::SchedulerFrame *Frame = (CPU::SchedulerFrame *)Data;
|
CPU::SchedulerFrame *Frame = (CPU::SchedulerFrame *)Data;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
assert(Frame->InterruptNumber == CPU::x86::IRQ16);
|
assert(Frame->InterruptNumber == CPU::x86::IRQ16);
|
||||||
#else
|
#else
|
||||||
assert(Frame->InterruptNumber == 16);
|
assert(Frame->InterruptNumber == 16);
|
||||||
|
@ -75,7 +75,7 @@ namespace Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (bInfo.RSDP)
|
if (bInfo.RSDP)
|
||||||
{
|
{
|
||||||
RSDPStart = (uintptr_t)bInfo.RSDP;
|
RSDPStart = (uintptr_t)bInfo.RSDP;
|
||||||
@ -101,7 +101,7 @@ namespace Memory
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint64_t i = 0; i < bInfo.Memory.Entries; i++)
|
for (uint64_t i = 0; i < bInfo.Memory.Entries; i++)
|
||||||
|
@ -121,7 +121,7 @@ namespace Xalloc
|
|||||||
{
|
{
|
||||||
if (this->SMAPUsed)
|
if (this->SMAPUsed)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asm volatile("stac" ::
|
asm volatile("stac" ::
|
||||||
: "cc");
|
: "cc");
|
||||||
#endif
|
#endif
|
||||||
@ -132,7 +132,7 @@ namespace Xalloc
|
|||||||
{
|
{
|
||||||
if (this->SMAPUsed)
|
if (this->SMAPUsed)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asm volatile("clac" ::
|
asm volatile("clac" ::
|
||||||
: "cc");
|
: "cc");
|
||||||
#endif
|
#endif
|
||||||
|
10
Kernel/core/memory/heap_allocators/liballoc_1_1/LICENSE
Normal file
10
Kernel/core/memory/heap_allocators/liballoc_1_1/LICENSE
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
This code is released into the public domain. Use this code at your own
|
||||||
|
risk. Feel free to use it for whatever purpose you want. I take no responsibilty or
|
||||||
|
whatever if anything goes wrong. Use it at your own risk.
|
||||||
|
|
||||||
|
If you have any fixes or patches, please email me.
|
||||||
|
|
||||||
|
Durand Miller <clutter@djm.co.za>
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ NIF void tracepagetable(PageTable *pt)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 512; i++)
|
for (int i = 0; i < 512; i++)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
if (pt->Entries[i].Present)
|
if (pt->Entries[i].Present)
|
||||||
debug("Entry %03d: %x %x %x %x %x %x %x %p-%#llx", i,
|
debug("Entry %03d: %x %x %x %x %x %x %x %p-%#llx", i,
|
||||||
pt->Entries[i].Present, pt->Entries[i].ReadWrite,
|
pt->Entries[i].Present, pt->Entries[i].ReadWrite,
|
||||||
@ -64,8 +64,8 @@ NIF void tracepagetable(PageTable *pt)
|
|||||||
pt->Entries[i].CacheDisable, pt->Entries[i].Accessed,
|
pt->Entries[i].CacheDisable, pt->Entries[i].Accessed,
|
||||||
pt->Entries[i].ExecuteDisable, pt->Entries[i].Address << 12,
|
pt->Entries[i].ExecuteDisable, pt->Entries[i].Address << 12,
|
||||||
pt->Entries[i]);
|
pt->Entries[i]);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,15 +257,15 @@ NIF void CreatePageTable(PageTable *pt)
|
|||||||
|
|
||||||
if (PSESupport)
|
if (PSESupport)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
CPU::x64::CR4 cr4 = CPU::x64::readcr4();
|
CPU::x64::CR4 cr4 = CPU::x64::readcr4();
|
||||||
cr4.PSE = 1;
|
cr4.PSE = 1;
|
||||||
CPU::x64::writecr4(cr4);
|
CPU::x64::writecr4(cr4);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
CPU::x32::CR4 cr4 = CPU::x32::readcr4();
|
CPU::x32::CR4 cr4 = CPU::x32::readcr4();
|
||||||
cr4.PSE = 1;
|
cr4.PSE = 1;
|
||||||
CPU::x32::writecr4(cr4);
|
CPU::x32::writecr4(cr4);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
trace("PSE Support Enabled");
|
trace("PSE Support Enabled");
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ NIF void CreatePageTable(PageTable *pt)
|
|||||||
NIF void InitializeMemoryManagement()
|
NIF void InitializeMemoryManagement()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#ifndef a32
|
#ifndef __i386__
|
||||||
for (uint64_t i = 0; i < bInfo.Memory.Entries; i++)
|
for (uint64_t i = 0; i < bInfo.Memory.Entries; i++)
|
||||||
{
|
{
|
||||||
uintptr_t Base = r_cst(uintptr_t, bInfo.Memory.Entry[i].BaseAddress);
|
uintptr_t Base = r_cst(uintptr_t, bInfo.Memory.Entry[i].BaseAddress);
|
||||||
@ -333,7 +333,7 @@ NIF void InitializeMemoryManagement()
|
|||||||
End,
|
End,
|
||||||
Type);
|
Type);
|
||||||
}
|
}
|
||||||
#endif // a32
|
#endif // __i386__
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
trace("Initializing Physical Memory Manager");
|
trace("Initializing Physical Memory Manager");
|
||||||
// KernelAllocator = Physical(); <- Already called in the constructor
|
// KernelAllocator = Physical(); <- Already called in the constructor
|
||||||
|
@ -9,9 +9,9 @@ namespace Memory
|
|||||||
{
|
{
|
||||||
void PageTable::Update()
|
void PageTable::Update()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %0, %%cr3" ::"r"(this));
|
asmv("mov %0, %%cr3" ::"r"(this));
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("msr ttbr0_el1, %0" ::"r"(this));
|
asmv("msr ttbr0_el1, %0" ::"r"(this));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ namespace Memory
|
|||||||
memcpy(NewTable, this, sizeof(PageTable));
|
memcpy(NewTable, this, sizeof(PageTable));
|
||||||
|
|
||||||
debug("Forking page table %#lx to %#lx", this, NewTable);
|
debug("Forking page table %#lx to %#lx", this, NewTable);
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
for (size_t i = 0; i < sizeof(Entries) / sizeof(Entries[0]); i++)
|
for (size_t i = 0; i < sizeof(Entries) / sizeof(Entries[0]); i++)
|
||||||
{
|
{
|
||||||
PageMapLevel4 *PML4 = &Entries[i];
|
PageMapLevel4 *PML4 = &Entries[i];
|
||||||
|
@ -22,7 +22,7 @@ namespace Memory
|
|||||||
Virtual::PageMapIndexer::PageMapIndexer(uintptr_t VirtualAddress)
|
Virtual::PageMapIndexer::PageMapIndexer(uintptr_t VirtualAddress)
|
||||||
{
|
{
|
||||||
uintptr_t Address = VirtualAddress;
|
uintptr_t Address = VirtualAddress;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
Address >>= 12;
|
Address >>= 12;
|
||||||
this->PTEIndex = Address & 0x1FF;
|
this->PTEIndex = Address & 0x1FF;
|
||||||
Address >>= 9;
|
Address >>= 9;
|
||||||
@ -31,12 +31,12 @@ namespace Memory
|
|||||||
this->PDPTEIndex = Address & 0x1FF;
|
this->PDPTEIndex = Address & 0x1FF;
|
||||||
Address >>= 9;
|
Address >>= 9;
|
||||||
this->PMLIndex = Address & 0x1FF;
|
this->PMLIndex = Address & 0x1FF;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
Address >>= 12;
|
Address >>= 12;
|
||||||
this->PTEIndex = Address & 0x3FF;
|
this->PTEIndex = Address & 0x3FF;
|
||||||
Address >>= 10;
|
Address >>= 10;
|
||||||
this->PDEIndex = Address & 0x3FF;
|
this->PDEIndex = Address & 0x3FF;
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (VirtualAddress > PAGE_SIZE)
|
if (VirtualAddress > PAGE_SIZE)
|
||||||
@ -44,7 +44,7 @@ namespace Memory
|
|||||||
assert(
|
assert(
|
||||||
this->PTEIndex != 0 ||
|
this->PTEIndex != 0 ||
|
||||||
this->PDEIndex != 0
|
this->PDEIndex != 0
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
|| this->PDPTEIndex != 0 ||
|
|| this->PDPTEIndex != 0 ||
|
||||||
this->PMLIndex != 0
|
this->PMLIndex != 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,10 +90,10 @@ namespace Memory
|
|||||||
Elf_Sym *Symbols = nullptr;
|
Elf_Sym *Symbols = nullptr;
|
||||||
uint8_t *StringAddress = nullptr;
|
uint8_t *StringAddress = nullptr;
|
||||||
|
|
||||||
#if defined(a64) || defined(aa64)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
Elf64_Xword SymbolSize = 0;
|
Elf64_Xword SymbolSize = 0;
|
||||||
Elf64_Xword StringSize = 0;
|
Elf64_Xword StringSize = 0;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
Elf32_Word SymbolSize = 0;
|
Elf32_Word SymbolSize = 0;
|
||||||
Elf32_Word StringSize = 0;
|
Elf32_Word StringSize = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -149,7 +149,7 @@ namespace Memory
|
|||||||
TO_PAGES(bInfo.Modules[i].Size));
|
TO_PAGES(bInfo.Modules[i].Size));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (bInfo.RSDP)
|
if (bInfo.RSDP)
|
||||||
{
|
{
|
||||||
debug("Reserving RSDT region %#lx-%#lx...", bInfo.RSDP,
|
debug("Reserving RSDT region %#lx-%#lx...", bInfo.RSDP,
|
||||||
@ -201,7 +201,7 @@ namespace Memory
|
|||||||
this->ReservePages(SDTHdr, TO_PAGES(SDTHdr->Length));
|
this->ReservePages(SDTHdr, TO_PAGES(SDTHdr->Length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,7 @@ namespace Memory
|
|||||||
if (!this->UserMode)
|
if (!this->UserMode)
|
||||||
assert(!"Kernel mode stack expansion not implemented");
|
assert(!"Kernel mode stack expansion not implemented");
|
||||||
|
|
||||||
if (FaultAddress < USER_STACK_END ||
|
if (FaultAddress < USER_STACK_END || FaultAddress > USER_STACK_BASE)
|
||||||
FaultAddress > USER_STACK_BASE)
|
|
||||||
{
|
{
|
||||||
info("Fault address %#lx is not in range of stack %#lx - %#lx",
|
info("Fault address %#lx is not in range of stack %#lx - %#lx",
|
||||||
FaultAddress, USER_STACK_END, USER_STACK_BASE);
|
FaultAddress, USER_STACK_END, USER_STACK_BASE);
|
||||||
@ -39,16 +38,16 @@ namespace Memory
|
|||||||
size_t stackPages = TO_PAGES(diff);
|
size_t stackPages = TO_PAGES(diff);
|
||||||
stackPages = stackPages < 1 ? 1 : stackPages;
|
stackPages = stackPages < 1 ? 1 : stackPages;
|
||||||
|
|
||||||
debug("roundFA: %#lx, sb: %#lx, diff: %#lx, stackPages: %d",
|
debug("roundFA: %#lx, StackBottom: %#lx, diff: %#lx, stackPages: %d",
|
||||||
roundFA, this->StackBottom, diff, stackPages);
|
roundFA, this->StackBottom, diff, stackPages);
|
||||||
|
|
||||||
void *AllocatedStack = vma->RequestPages(stackPages);
|
void *pPage = vma->RequestPages(stackPages);
|
||||||
debug("AllocatedStack: %#lx", AllocatedStack);
|
debug("pPage: %#lx", pPage);
|
||||||
|
|
||||||
for (size_t i = 0; i < stackPages; i++)
|
for (size_t i = 1; i < stackPages + 1; i++)
|
||||||
{
|
{
|
||||||
void *vAddress = (void *)((uintptr_t)this->StackBottom - (i * PAGE_SIZE));
|
void *vAddress = (void *)((uintptr_t)this->StackBottom - (i * PAGE_SIZE));
|
||||||
void *pAddress = (void *)((uintptr_t)AllocatedStack + (i * PAGE_SIZE));
|
void *pAddress = (void *)((uintptr_t)pPage + (i * PAGE_SIZE));
|
||||||
|
|
||||||
vma->Map(vAddress, pAddress, PAGE_SIZE, PTFlag::RW | PTFlag::US);
|
vma->Map(vAddress, pAddress, PAGE_SIZE, PTFlag::RW | PTFlag::US);
|
||||||
AllocatedPages ap = {
|
AllocatedPages ap = {
|
||||||
@ -56,11 +55,11 @@ namespace Memory
|
|||||||
.VirtualAddress = vAddress,
|
.VirtualAddress = vAddress,
|
||||||
};
|
};
|
||||||
AllocatedPagesList.push_back(ap);
|
AllocatedPagesList.push_back(ap);
|
||||||
debug("Mapped %#lx to %#lx", pAddress, vAddress);
|
debug("Mapped p:%#lx to v:%#lx", pAddress, vAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->StackBottom = (void *)((uintptr_t)this->StackBottom - (stackPages * PAGE_SIZE));
|
this->StackBottom = (void *)((uintptr_t)this->StackBottom - (stackPages * PAGE_SIZE));
|
||||||
this->Size += stackPages * PAGE_SIZE;
|
this->CurrentSize += stackPages * PAGE_SIZE;
|
||||||
debug("Stack expanded to %#lx", this->StackBottom);
|
debug("Stack expanded to %#lx", this->StackBottom);
|
||||||
this->Expanded = true;
|
this->Expanded = true;
|
||||||
return true;
|
return true;
|
||||||
@ -76,7 +75,7 @@ namespace Memory
|
|||||||
this->StackTop = Parent->StackTop;
|
this->StackTop = Parent->StackTop;
|
||||||
this->StackPhysicalBottom = Parent->StackPhysicalBottom;
|
this->StackPhysicalBottom = Parent->StackPhysicalBottom;
|
||||||
this->StackPhysicalTop = Parent->StackPhysicalTop;
|
this->StackPhysicalTop = Parent->StackPhysicalTop;
|
||||||
this->Size = Parent->Size;
|
this->CurrentSize = Parent->CurrentSize;
|
||||||
this->Expanded = Parent->Expanded;
|
this->Expanded = Parent->Expanded;
|
||||||
|
|
||||||
std::list<AllocatedPages> ParentAllocatedPages = Parent->GetAllocatedPages();
|
std::list<AllocatedPages> ParentAllocatedPages = Parent->GetAllocatedPages();
|
||||||
@ -103,19 +102,19 @@ namespace Memory
|
|||||||
|
|
||||||
if (this->UserMode)
|
if (this->UserMode)
|
||||||
{
|
{
|
||||||
void *AllocatedStack = vma->RequestPages(TO_PAGES(USER_STACK_SIZE));
|
void *pPage = vma->RequestPages(TO_PAGES(USER_STACK_SIZE));
|
||||||
|
debug("pPage: %#lx", pPage);
|
||||||
|
|
||||||
this->StackBottom = (void *)USER_STACK_BASE;
|
this->StackBottom = (void *)USER_STACK_BASE;
|
||||||
this->StackTop = (void *)(USER_STACK_BASE + USER_STACK_SIZE);
|
this->StackTop = (void *)(USER_STACK_BASE + USER_STACK_SIZE);
|
||||||
this->StackPhysicalBottom = AllocatedStack;
|
this->StackPhysicalBottom = pPage;
|
||||||
this->StackPhysicalTop = (void *)((uintptr_t)AllocatedStack + USER_STACK_SIZE);
|
this->StackPhysicalTop = (void *)((uintptr_t)pPage + USER_STACK_SIZE);
|
||||||
this->Size = USER_STACK_SIZE;
|
this->CurrentSize = USER_STACK_SIZE;
|
||||||
|
|
||||||
debug("AllocatedStack: %#lx", AllocatedStack);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < TO_PAGES(USER_STACK_SIZE); i++)
|
for (size_t i = 0; i < TO_PAGES(USER_STACK_SIZE); i++)
|
||||||
{
|
{
|
||||||
void *vAddress = (void *)(USER_STACK_BASE + (i * PAGE_SIZE));
|
void *vAddress = (void *)(USER_STACK_BASE + (i * PAGE_SIZE));
|
||||||
void *pAddress = (void *)((uintptr_t)AllocatedStack + (i * PAGE_SIZE));
|
void *pAddress = (void *)((uintptr_t)pPage + (i * PAGE_SIZE));
|
||||||
vma->Map(vAddress, pAddress, PAGE_SIZE, PTFlag::RW | PTFlag::US);
|
vma->Map(vAddress, pAddress, PAGE_SIZE, PTFlag::RW | PTFlag::US);
|
||||||
|
|
||||||
AllocatedPages ap = {
|
AllocatedPages ap = {
|
||||||
@ -123,7 +122,7 @@ namespace Memory
|
|||||||
.VirtualAddress = vAddress,
|
.VirtualAddress = vAddress,
|
||||||
};
|
};
|
||||||
AllocatedPagesList.push_back(ap);
|
AllocatedPagesList.push_back(ap);
|
||||||
debug("Mapped %#lx to %#lx", pAddress, vAddress);
|
debug("Mapped p:%#lx to v:%#lx", pAddress, vAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -133,7 +132,7 @@ namespace Memory
|
|||||||
this->StackTop = (void *)((uintptr_t)this->StackBottom + LARGE_STACK_SIZE);
|
this->StackTop = (void *)((uintptr_t)this->StackBottom + LARGE_STACK_SIZE);
|
||||||
this->StackPhysicalBottom = sa.PhysicalAddress;
|
this->StackPhysicalBottom = sa.PhysicalAddress;
|
||||||
this->StackPhysicalTop = (void *)((uintptr_t)this->StackPhysicalBottom + LARGE_STACK_SIZE);
|
this->StackPhysicalTop = (void *)((uintptr_t)this->StackPhysicalBottom + LARGE_STACK_SIZE);
|
||||||
this->Size = LARGE_STACK_SIZE;
|
this->CurrentSize = LARGE_STACK_SIZE;
|
||||||
|
|
||||||
debug("StackBottom: %#lx", this->StackBottom);
|
debug("StackBottom: %#lx", this->StackBottom);
|
||||||
|
|
||||||
|
@ -241,9 +241,9 @@ namespace Memory
|
|||||||
pte->CopyOnWrite = false;
|
pte->CopyOnWrite = false;
|
||||||
debug("PFA %#lx is CoW (pt %#lx, flags %#lx)",
|
debug("PFA %#lx is CoW (pt %#lx, flags %#lx)",
|
||||||
PFA, this->Table, pte->raw);
|
PFA, this->Table, pte->raw);
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
CPU::x64::invlpg((void *)PFA);
|
CPU::x64::invlpg((void *)PFA);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
CPU::x32::invlpg((void *)PFA);
|
CPU::x32::invlpg((void *)PFA);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@ -303,7 +303,7 @@ namespace Memory
|
|||||||
void *AddressToMap = (void *)((uintptr_t)ap.Address + (i * PAGE_SIZE));
|
void *AddressToMap = (void *)((uintptr_t)ap.Address + (i * PAGE_SIZE));
|
||||||
void *RealAddress = (void *)((uintptr_t)Address + (i * PAGE_SIZE));
|
void *RealAddress = (void *)((uintptr_t)Address + (i * PAGE_SIZE));
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
PageTableEntry *pte = vmm.GetPTE(AddressToMap);
|
PageTableEntry *pte = vmm.GetPTE(AddressToMap);
|
||||||
uintptr_t Flags = 0;
|
uintptr_t Flags = 0;
|
||||||
Flags |= pte->Present ? (uintptr_t)PTFlag::P : 0;
|
Flags |= pte->Present ? (uintptr_t)PTFlag::P : 0;
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../arch/amd64/cpu/gdt.hpp"
|
#include "../../arch/amd64/cpu/gdt.hpp"
|
||||||
#include "../arch/amd64/cpu/apic.hpp"
|
#include "../arch/amd64/cpu/apic.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#include "../../arch/i386/cpu/gdt.hpp"
|
#include "../../arch/i386/cpu/gdt.hpp"
|
||||||
#include "../arch/i386/cpu/apic.hpp"
|
#include "../arch/i386/cpu/apic.hpp"
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../kernel.h"
|
#include "../../kernel.h"
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../arch/amd64/cpu/gdt.hpp"
|
#include "../../arch/amd64/cpu/gdt.hpp"
|
||||||
#include "../arch/amd64/cpu/apic.hpp"
|
#include "../arch/amd64/cpu/apic.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#include "../../arch/i386/cpu/gdt.hpp"
|
#include "../../arch/i386/cpu/gdt.hpp"
|
||||||
#include "../arch/i386/cpu/apic.hpp"
|
#include "../arch/i386/cpu/apic.hpp"
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../kernel.h"
|
#include "../../kernel.h"
|
||||||
@ -100,7 +100,7 @@ nsa void HaltAllCores()
|
|||||||
if (SMP::CPUCores <= 1)
|
if (SMP::CPUCores <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (Interrupts::apic[0] == nullptr)
|
if (Interrupts::apic[0] == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ nsa void HaltAllCores()
|
|||||||
((APIC::APIC *)Interrupts::apic[i])->ICR(icr);
|
((APIC::APIC *)Interrupts::apic[i])->ICR(icr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint("\x1b[0m-----------------------------------------------\n");
|
ExPrint("\x1b[0m-----------------------------------------------\n");
|
||||||
ExPrint("\x1b[30;41mUnrecoverable exception %#lx on CPU %d\n",
|
ExPrint("\x1b[30;41mUnrecoverable exception %#lx on CPU %d\n",
|
||||||
Frame->InterruptNumber, core->ID);
|
Frame->InterruptNumber, core->ID);
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
||||||
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
||||||
ExPrint("DR0=%#lx DR1=%#lx DR2=%#lx DR3=%#lx DR6=%#lx DR7=%#lx\n",
|
ExPrint("DR0=%#lx DR1=%#lx DR2=%#lx DR3=%#lx DR6=%#lx DR7=%#lx\n",
|
||||||
@ -195,29 +195,29 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint("GS=%#lx FS=%#lx ES=%#lx DS=%#lx SS=%#lx CS=%#lx\n",
|
ExPrint("GS=%#lx FS=%#lx ES=%#lx DS=%#lx SS=%#lx CS=%#lx\n",
|
||||||
Frame->gs, Frame->fs, Frame->es, Frame->ds, Frame->ss, Frame->cs);
|
Frame->gs, Frame->fs, Frame->es, Frame->ds, Frame->ss, Frame->cs);
|
||||||
#endif
|
#endif
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
ExPrint("R8=%#lx R9=%#lx R10=%#lx R11=%#lx R12=%#lx R13=%#lx R14=%#lx R15=%#lx\n",
|
ExPrint("R8=%#lx R9=%#lx R10=%#lx R11=%#lx R12=%#lx R13=%#lx R14=%#lx R15=%#lx\n",
|
||||||
Frame->r8, Frame->r9, Frame->r10, Frame->r11, Frame->r12, Frame->r13,
|
Frame->r8, Frame->r9, Frame->r10, Frame->r11, Frame->r12, Frame->r13,
|
||||||
Frame->r14, Frame->r15);
|
Frame->r14, Frame->r15);
|
||||||
#endif
|
#endif
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("AX=%#lx BX=%#lx CX=%#lx DX=%#lx SI=%#lx DI=%#lx BP=%#lx SP=%#lx\n",
|
ExPrint("AX=%#lx BX=%#lx CX=%#lx DX=%#lx SI=%#lx DI=%#lx BP=%#lx SP=%#lx\n",
|
||||||
|
|
||||||
#ifdef a64
|
#ifdef __amd64__
|
||||||
Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx, Frame->rsi, Frame->rdi,
|
Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx, Frame->rsi, Frame->rdi,
|
||||||
Frame->rbp, Frame->rsp);
|
Frame->rbp, Frame->rsp);
|
||||||
#else
|
#else
|
||||||
Frame->eax, Frame->ebx, Frame->ecx, Frame->edx, Frame->esi, Frame->edi,
|
Frame->eax, Frame->ebx, Frame->ecx, Frame->edx, Frame->esi, Frame->edi,
|
||||||
Frame->ebp, Frame->esp);
|
Frame->ebp, Frame->esp);
|
||||||
#endif /* a64 */
|
#endif /* __amd64__ */
|
||||||
|
|
||||||
ExPrint("IP=%#lx FL=%#lx INT=%#lx ERR=%#lx\n",
|
ExPrint("IP=%#lx FL=%#lx INT=%#lx ERR=%#lx\n",
|
||||||
|
|
||||||
#ifdef a64
|
#ifdef __amd64__
|
||||||
Frame->rip, Frame->rflags.raw,
|
Frame->rip, Frame->rflags.raw,
|
||||||
#else
|
#else
|
||||||
Frame->eip, Frame->eflags.raw,
|
Frame->eip, Frame->eflags.raw,
|
||||||
#endif /* a64 */
|
#endif /* __amd64__ */
|
||||||
Frame->InterruptNumber, Frame->ErrorCode);
|
Frame->InterruptNumber, Frame->ErrorCode);
|
||||||
#endif /* a86 */
|
#endif /* a86 */
|
||||||
|
|
||||||
@ -233,14 +233,14 @@ nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint("\x1b[0m-----------------------------------------------\n");
|
ExPrint("\x1b[0m-----------------------------------------------\n");
|
||||||
ExPrint("Exception inside exception: %#lx at %#lx\n",
|
ExPrint("Exception inside exception: %#lx at %#lx\n",
|
||||||
Frame->InterruptNumber,
|
Frame->InterruptNumber,
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
Frame->rip);
|
Frame->rip);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
Frame->eip);
|
Frame->eip);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
Frame->pc);
|
Frame->pc);
|
||||||
#endif
|
#endif
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
||||||
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
||||||
ExPrint("DR0=%#lx DR1=%#lx DR2=%#lx DR3=%#lx DR6=%#lx DR7=%#lx\n",
|
ExPrint("DR0=%#lx DR1=%#lx DR2=%#lx DR3=%#lx DR6=%#lx DR7=%#lx\n",
|
||||||
@ -248,29 +248,29 @@ nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint("GS=%#lx FS=%#lx ES=%#lx DS=%#lx SS=%#lx CS=%#lx\n",
|
ExPrint("GS=%#lx FS=%#lx ES=%#lx DS=%#lx SS=%#lx CS=%#lx\n",
|
||||||
Frame->gs, Frame->fs, Frame->es, Frame->ds, Frame->ss, Frame->cs);
|
Frame->gs, Frame->fs, Frame->es, Frame->ds, Frame->ss, Frame->cs);
|
||||||
#endif
|
#endif
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
ExPrint("R8=%#lx R9=%#lx R10=%#lx R11=%#lx R12=%#lx R13=%#lx R14=%#lx R15=%#lx\n",
|
ExPrint("R8=%#lx R9=%#lx R10=%#lx R11=%#lx R12=%#lx R13=%#lx R14=%#lx R15=%#lx\n",
|
||||||
Frame->r8, Frame->r9, Frame->r10, Frame->r11, Frame->r12, Frame->r13,
|
Frame->r8, Frame->r9, Frame->r10, Frame->r11, Frame->r12, Frame->r13,
|
||||||
Frame->r14, Frame->r15);
|
Frame->r14, Frame->r15);
|
||||||
#endif
|
#endif
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("AX=%#lx BX=%#lx CX=%#lx DX=%#lx SI=%#lx DI=%#lx BP=%#lx SP=%#lx\n",
|
ExPrint("AX=%#lx BX=%#lx CX=%#lx DX=%#lx SI=%#lx DI=%#lx BP=%#lx SP=%#lx\n",
|
||||||
|
|
||||||
#ifdef a64
|
#ifdef __amd64__
|
||||||
Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx, Frame->rsi, Frame->rdi,
|
Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx, Frame->rsi, Frame->rdi,
|
||||||
Frame->rbp, Frame->rsp);
|
Frame->rbp, Frame->rsp);
|
||||||
#else
|
#else
|
||||||
Frame->eax, Frame->ebx, Frame->ecx, Frame->edx, Frame->esi, Frame->edi,
|
Frame->eax, Frame->ebx, Frame->ecx, Frame->edx, Frame->esi, Frame->edi,
|
||||||
Frame->ebp, Frame->esp);
|
Frame->ebp, Frame->esp);
|
||||||
#endif /* a64 */
|
#endif /* __amd64__ */
|
||||||
|
|
||||||
ExPrint("IP=%#lx FL=%#lx INT=%#lx ERR=%#lx\n",
|
ExPrint("IP=%#lx FL=%#lx INT=%#lx ERR=%#lx\n",
|
||||||
|
|
||||||
#ifdef a64
|
#ifdef __amd64__
|
||||||
Frame->rip, Frame->rflags.raw,
|
Frame->rip, Frame->rflags.raw,
|
||||||
#else
|
#else
|
||||||
Frame->eip, Frame->eflags.raw,
|
Frame->eip, Frame->eflags.raw,
|
||||||
#endif /* a64 */
|
#endif /* __amd64__ */
|
||||||
Frame->InterruptNumber, Frame->ErrorCode);
|
Frame->InterruptNumber, Frame->ErrorCode);
|
||||||
#endif /* a86 */
|
#endif /* a86 */
|
||||||
Display->UpdateBuffer();
|
Display->UpdateBuffer();
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../../arch/amd64/cpu/gdt.hpp"
|
#include "../../../arch/amd64/cpu/gdt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../../kernel.h"
|
#include "../../../kernel.h"
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../../arch/amd64/cpu/gdt.hpp"
|
#include "../../../arch/amd64/cpu/gdt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../../kernel.h"
|
#include "../../../kernel.h"
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../../arch/amd64/cpu/gdt.hpp"
|
#include "../../../arch/amd64/cpu/gdt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../../kernel.h"
|
#include "../../../kernel.h"
|
||||||
@ -107,7 +107,7 @@ nsa static inline int GetLetterFromScanCode(uint8_t ScanCode)
|
|||||||
|
|
||||||
nsa void CrashPS2KeyboardDriver::PS2Wait(bool Output)
|
nsa void CrashPS2KeyboardDriver::PS2Wait(bool Output)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
TimeoutCallNumber++;
|
TimeoutCallNumber++;
|
||||||
int timeout = 100000;
|
int timeout = 100000;
|
||||||
PS2_STATUSES status = {.Raw = inb(PS2_STATUS)};
|
PS2_STATUSES status = {.Raw = inb(PS2_STATUS)};
|
||||||
@ -153,7 +153,7 @@ nsa CrashPS2KeyboardDriver::CrashPS2KeyboardDriver() : Interrupts::Handler(1) /*
|
|||||||
|
|
||||||
/* Dots will be printed at the bottom of the screen as a progress bar. */
|
/* Dots will be printed at the bottom of the screen as a progress bar. */
|
||||||
ExPrint("\x1b[%d;%dH", (Display->GetWidth / CrashFontRenderer.CurrentFont->GetInfo().Width) - 2, 0);
|
ExPrint("\x1b[%d;%dH", (Display->GetWidth / CrashFontRenderer.CurrentFont->GetInfo().Width) - 2, 0);
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
|
|
||||||
/* Disable port 1 & 2 */
|
/* Disable port 1 & 2 */
|
||||||
{
|
{
|
||||||
@ -355,14 +355,14 @@ nsa CrashPS2KeyboardDriver::CrashPS2KeyboardDriver() : Interrupts::Handler(1) /*
|
|||||||
|
|
||||||
ExPrint(".");
|
ExPrint(".");
|
||||||
|
|
||||||
#endif // defined(a86)
|
#endif // defined(__amd64__) || defined(__i386__)
|
||||||
|
|
||||||
CPU::Interrupts(CPU::Enable);
|
CPU::Interrupts(CPU::Enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa void CrashPS2KeyboardDriver::OnInterruptReceived(CPU::TrapFrame *)
|
nsa void CrashPS2KeyboardDriver::OnInterruptReceived(CPU::TrapFrame *)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint8_t scanCode = inb(PS2_DATA);
|
uint8_t scanCode = inb(PS2_DATA);
|
||||||
|
|
||||||
if (scanCode == KEY_D_TAB ||
|
if (scanCode == KEY_D_TAB ||
|
||||||
@ -412,5 +412,5 @@ nsa void CrashPS2KeyboardDriver::OnInterruptReceived(CPU::TrapFrame *)
|
|||||||
}
|
}
|
||||||
Display->UpdateBuffer(); /* Update as we type. */
|
Display->UpdateBuffer(); /* Update as we type. */
|
||||||
}
|
}
|
||||||
#endif // a64 || a32
|
#endif // __amd64__ || __i386__
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../../arch/amd64/cpu/gdt.hpp"
|
#include "../../../arch/amd64/cpu/gdt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../../kernel.h"
|
#include "../../../kernel.h"
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../../arch/amd64/cpu/gdt.hpp"
|
#include "../../../arch/amd64/cpu/gdt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../../kernel.h"
|
#include "../../../kernel.h"
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../arch/amd64/cpu/gdt.hpp"
|
#include "../../arch/amd64/cpu/gdt.hpp"
|
||||||
#include "../arch/amd64/cpu/apic.hpp"
|
#include "../arch/amd64/cpu/apic.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#include "../../arch/i386/cpu/gdt.hpp"
|
#include "../../arch/i386/cpu/gdt.hpp"
|
||||||
#include "../arch/i386/cpu/apic.hpp"
|
#include "../arch/i386/cpu/apic.hpp"
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../kernel.h"
|
#include "../../kernel.h"
|
||||||
@ -143,11 +143,11 @@ nsa const char *ExGetKSymbol(CPU::ExceptionFrame *Frame)
|
|||||||
Frame->rip > (uintptr_t)&_kernel_end)
|
Frame->rip > (uintptr_t)&_kernel_end)
|
||||||
return "<OUTSIDE KERNEL>";
|
return "<OUTSIDE KERNEL>";
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
return ExGetKSymbolByAddress(Frame->rip);
|
return ExGetKSymbolByAddress(Frame->rip);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
return ExGetKSymbolByAddress(Frame->eip);
|
return ExGetKSymbolByAddress(Frame->eip);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
return ExGetKSymbolByAddress(Frame->pc);
|
return ExGetKSymbolByAddress(Frame->pc);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -299,23 +299,23 @@ nsa void DisplayMainScreen(CPU::ExceptionFrame *Frame)
|
|||||||
ExPrint("\nWe're sorry, but the system has encountered a critical error and needs to restart.\n");
|
ExPrint("\nWe're sorry, but the system has encountered a critical error and needs to restart.\n");
|
||||||
|
|
||||||
ExPrint("\nError: %s (%s 0x%x)\n",
|
ExPrint("\nError: %s (%s 0x%x)\n",
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
x86Exceptions[Frame->InterruptNumber].Name,
|
x86Exceptions[Frame->InterruptNumber].Name,
|
||||||
x86Exceptions[Frame->InterruptNumber].Mnemonic,
|
x86Exceptions[Frame->InterruptNumber].Mnemonic,
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#error "AA64 not implemented"
|
#error "AA64 not implemented"
|
||||||
#endif
|
#endif
|
||||||
Frame->InterruptNumber);
|
Frame->InterruptNumber);
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ExPrint("Cause: %s\n", x86Exceptions[Frame->InterruptNumber].Cause);
|
ExPrint("Cause: %s\n", x86Exceptions[Frame->InterruptNumber].Cause);
|
||||||
#endif
|
#endif
|
||||||
ExPrint("Exception occurred in function %s (%#lx)\n",
|
ExPrint("Exception occurred in function %s (%#lx)\n",
|
||||||
ExGetKSymbol(Frame),
|
ExGetKSymbol(Frame),
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
Frame->rip);
|
Frame->rip);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
Frame->eip);
|
Frame->eip);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
Frame->pc);
|
Frame->pc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -431,9 +431,9 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
|||||||
{
|
{
|
||||||
Memory::Virtual vmm;
|
Memory::Virtual vmm;
|
||||||
struct StackFrame *sf;
|
struct StackFrame *sf;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
sf = (struct StackFrame *)Frame->rbp;
|
sf = (struct StackFrame *)Frame->rbp;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
sf = (struct StackFrame *)Frame->ebp;
|
sf = (struct StackFrame *)Frame->ebp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -455,11 +455,11 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
|||||||
/* FIXME: Get symbol offset more efficiently */
|
/* FIXME: Get symbol offset more efficiently */
|
||||||
|
|
||||||
uintptr_t fIP;
|
uintptr_t fIP;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
fIP = Frame->rip;
|
fIP = Frame->rip;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
fIP = Frame->eip;
|
fIP = Frame->eip;
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
fIP = Frame->pc;
|
fIP = Frame->pc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
#include <smp.hpp>
|
#include <smp.hpp>
|
||||||
#include <cpu.hpp>
|
#include <cpu.hpp>
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
#include "../../arch/amd64/cpu/gdt.hpp"
|
#include "../../arch/amd64/cpu/gdt.hpp"
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../kernel.h"
|
#include "../../kernel.h"
|
||||||
@ -32,26 +32,26 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsa void dbgPrint(CPU::ExceptionFrame *Frame)
|
nsa void dbgPrint(CPU::ExceptionFrame *Frame)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
debug("FS=%#lx GS=%#lx SS=%#lx CS=%#lx DS=%#lx", Frame->fs, Frame->gs, Frame->ss, Frame->cs, Frame->ds);
|
debug("FS=%#lx GS=%#lx SS=%#lx CS=%#lx DS=%#lx", Frame->fs, Frame->gs, Frame->ss, Frame->cs, Frame->ds);
|
||||||
debug("R8=%#lx R9=%#lx R10=%#lx R11=%#lx", Frame->r8, Frame->r9, Frame->r10, Frame->r11);
|
debug("R8=%#lx R9=%#lx R10=%#lx R11=%#lx", Frame->r8, Frame->r9, Frame->r10, Frame->r11);
|
||||||
debug("R12=%#lx R13=%#lx R14=%#lx R15=%#lx", Frame->r12, Frame->r13, Frame->r14, Frame->r15);
|
debug("R12=%#lx R13=%#lx R14=%#lx R15=%#lx", Frame->r12, Frame->r13, Frame->r14, Frame->r15);
|
||||||
debug("RAX=%#lx RBX=%#lx RCX=%#lx RDX=%#lx", Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx);
|
debug("RAX=%#lx RBX=%#lx RCX=%#lx RDX=%#lx", Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx);
|
||||||
debug("RSI=%#lx RDI=%#lx RBP=%#lx RSP=%#lx", Frame->rsi, Frame->rdi, Frame->rbp, Frame->rsp);
|
debug("RSI=%#lx RDI=%#lx RBP=%#lx RSP=%#lx", Frame->rsi, Frame->rdi, Frame->rbp, Frame->rsp);
|
||||||
debug("RIP=%#lx RFL=%#lx INT=%#lx ERR=%#lx", Frame->rip, Frame->rflags.raw, Frame->InterruptNumber, Frame->ErrorCode);
|
debug("RIP=%#lx RFL=%#lx INT=%#lx ERR=%#lx", Frame->rip, Frame->rflags.raw, Frame->InterruptNumber, Frame->ErrorCode);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
debug("FS=%#x GS=%#x CS=%#x DS=%#x", Frame->fs, Frame->gs, Frame->cs, Frame->ds);
|
debug("FS=%#x GS=%#x CS=%#x DS=%#x", Frame->fs, Frame->gs, Frame->cs, Frame->ds);
|
||||||
debug("EAX=%#x EBX=%#x ECX=%#x EDX=%#x", Frame->eax, Frame->ebx, Frame->ecx, Frame->edx);
|
debug("EAX=%#x EBX=%#x ECX=%#x EDX=%#x", Frame->eax, Frame->ebx, Frame->ecx, Frame->edx);
|
||||||
debug("ESI=%#x EDI=%#x EBP=%#x ESP=%#x", Frame->esi, Frame->edi, Frame->ebp, Frame->esp);
|
debug("ESI=%#x EDI=%#x EBP=%#x ESP=%#x", Frame->esi, Frame->edi, Frame->ebp, Frame->esp);
|
||||||
debug("EIP=%#x EFL=%#x INT=%#x ERR=%#x", Frame->eip, Frame->eflags.raw, Frame->InterruptNumber, Frame->ErrorCode);
|
debug("EIP=%#x EFL=%#x INT=%#x ERR=%#x", Frame->eip, Frame->eflags.raw, Frame->InterruptNumber, Frame->ErrorCode);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
debug("CR2=%#lx CR3=%#lx", Frame->cr2, Frame->cr3);
|
debug("CR2=%#lx CR3=%#lx", Frame->cr2, Frame->cr3);
|
||||||
#endif // defined(a86)
|
#endif // defined(__amd64__) || defined(__i386__)
|
||||||
|
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
debug("RFL: CF:%s PF:%s AF:%s ZF:%s SF:%s TF:%s IF:%s DF:%s OF:%s IOPL:%s NT:%s RF:%s VM:%s AC:%s VIF:%s VIP:%s ID:%s AlwaysOne:%d R0:%#x R1:%#x R2:%#x R3:%#x",
|
debug("RFL: CF:%s PF:%s AF:%s ZF:%s SF:%s TF:%s IF:%s DF:%s OF:%s IOPL:%s NT:%s RF:%s VM:%s AC:%s VIF:%s VIP:%s ID:%s AlwaysOne:%d R0:%#x R1:%#x R2:%#x R3:%#x",
|
||||||
Frame->rflags.CF ? "True " : "False", Frame->rflags.PF ? "True " : "False", Frame->rflags.AF ? "True " : "False", Frame->rflags.ZF ? "True " : "False",
|
Frame->rflags.CF ? "True " : "False", Frame->rflags.PF ? "True " : "False", Frame->rflags.AF ? "True " : "False", Frame->rflags.ZF ? "True " : "False",
|
||||||
Frame->rflags.SF ? "True " : "False", Frame->rflags.TF ? "True " : "False", Frame->rflags.IF ? "True " : "False", Frame->rflags.DF ? "True " : "False",
|
Frame->rflags.SF ? "True " : "False", Frame->rflags.TF ? "True " : "False", Frame->rflags.IF ? "True " : "False", Frame->rflags.DF ? "True " : "False",
|
||||||
@ -59,7 +59,7 @@ nsa void dbgPrint(CPU::ExceptionFrame *Frame)
|
|||||||
Frame->rflags.VM ? "True " : "False", Frame->rflags.AC ? "True " : "False", Frame->rflags.VIF ? "True " : "False", Frame->rflags.VIP ? "True " : "False",
|
Frame->rflags.VM ? "True " : "False", Frame->rflags.AC ? "True " : "False", Frame->rflags.VIF ? "True " : "False", Frame->rflags.VIP ? "True " : "False",
|
||||||
Frame->rflags.ID ? "True " : "False", Frame->rflags.AlwaysOne,
|
Frame->rflags.ID ? "True " : "False", Frame->rflags.AlwaysOne,
|
||||||
Frame->rflags.Reserved0, Frame->rflags.Reserved1, Frame->rflags.Reserved2, Frame->rflags.Reserved3);
|
Frame->rflags.Reserved0, Frame->rflags.Reserved1, Frame->rflags.Reserved2, Frame->rflags.Reserved3);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
debug("EFL: CF:%s PF:%s AF:%s ZF:%s SF:%s TF:%s IF:%s DF:%s OF:%s IOPL:%s NT:%s RF:%s VM:%s AC:%s VIF:%s VIP:%s ID:%s AlwaysOne:%d R0:%#x R1:%#x R2:%#x",
|
debug("EFL: CF:%s PF:%s AF:%s ZF:%s SF:%s TF:%s IF:%s DF:%s OF:%s IOPL:%s NT:%s RF:%s VM:%s AC:%s VIF:%s VIP:%s ID:%s AlwaysOne:%d R0:%#x R1:%#x R2:%#x",
|
||||||
Frame->eflags.CF ? "True " : "False", Frame->eflags.PF ? "True " : "False", Frame->eflags.AF ? "True " : "False", Frame->eflags.ZF ? "True " : "False",
|
Frame->eflags.CF ? "True " : "False", Frame->eflags.PF ? "True " : "False", Frame->eflags.AF ? "True " : "False", Frame->eflags.ZF ? "True " : "False",
|
||||||
Frame->eflags.SF ? "True " : "False", Frame->eflags.TF ? "True " : "False", Frame->eflags.IF ? "True " : "False", Frame->eflags.DF ? "True " : "False",
|
Frame->eflags.SF ? "True " : "False", Frame->eflags.TF ? "True " : "False", Frame->eflags.IF ? "True " : "False", Frame->eflags.DF ? "True " : "False",
|
||||||
@ -67,7 +67,7 @@ nsa void dbgPrint(CPU::ExceptionFrame *Frame)
|
|||||||
Frame->eflags.VM ? "True " : "False", Frame->eflags.AC ? "True " : "False", Frame->eflags.VIF ? "True " : "False", Frame->eflags.VIP ? "True " : "False",
|
Frame->eflags.VM ? "True " : "False", Frame->eflags.AC ? "True " : "False", Frame->eflags.VIF ? "True " : "False", Frame->eflags.VIP ? "True " : "False",
|
||||||
Frame->eflags.ID ? "True " : "False", Frame->eflags.AlwaysOne,
|
Frame->eflags.ID ? "True " : "False", Frame->eflags.AlwaysOne,
|
||||||
Frame->eflags.Reserved0, Frame->eflags.Reserved1, Frame->eflags.Reserved2);
|
Frame->eflags.Reserved0, Frame->eflags.Reserved1, Frame->eflags.Reserved2);
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1100,7 +1100,7 @@ namespace PCI
|
|||||||
|
|
||||||
Manager::Manager()
|
Manager::Manager()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (!PowerManager->GetACPI())
|
if (!PowerManager->GetACPI())
|
||||||
{
|
{
|
||||||
error("ACPI not found");
|
error("ACPI not found");
|
||||||
@ -1127,7 +1127,7 @@ namespace PCI
|
|||||||
for (uint32_t Bus = NewDeviceConfig->StartBus; Bus < NewDeviceConfig->EndBus; Bus++)
|
for (uint32_t Bus = NewDeviceConfig->StartBus; Bus < NewDeviceConfig->EndBus; Bus++)
|
||||||
EnumerateBus(NewDeviceConfig->BaseAddress, Bus, dev);
|
EnumerateBus(NewDeviceConfig->BaseAddress, Bus, dev);
|
||||||
}
|
}
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
error("PCI not implemented on aarch64");
|
error("PCI not implemented on aarch64");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace Random
|
|||||||
|
|
||||||
uint16_t rand16()
|
uint16_t rand16()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (RDRANDFlag)
|
if (RDRANDFlag)
|
||||||
{
|
{
|
||||||
uint16_t RDRANDValue = 0;
|
uint16_t RDRANDValue = 0;
|
||||||
@ -80,7 +80,7 @@ namespace Random
|
|||||||
|
|
||||||
uint32_t rand32()
|
uint32_t rand32()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (RDRANDFlag)
|
if (RDRANDFlag)
|
||||||
{
|
{
|
||||||
uint32_t RDRANDValue = 0;
|
uint32_t RDRANDValue = 0;
|
||||||
@ -97,7 +97,7 @@ namespace Random
|
|||||||
|
|
||||||
uint64_t rand64()
|
uint64_t rand64()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
if (RDRANDFlag)
|
if (RDRANDFlag)
|
||||||
{
|
{
|
||||||
uintptr_t RDRANDValue = 0;
|
uintptr_t RDRANDValue = 0;
|
||||||
|
@ -60,13 +60,13 @@ EXTERNC __noreturn __no_stack_protector void __stack_chk_fail(void)
|
|||||||
CPU::PageTable(KernelPageTable);
|
CPU::PageTable(KernelPageTable);
|
||||||
|
|
||||||
void *Stack = nullptr;
|
void *Stack = nullptr;
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
asmv("movq %%rsp, %0"
|
asmv("movq %%rsp, %0"
|
||||||
: "=r"(Stack));
|
: "=r"(Stack));
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
asmv("movl %%esp, %0"
|
asmv("movl %%esp, %0"
|
||||||
: "=r"(Stack));
|
: "=r"(Stack));
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
asmv("mov %%sp, %0"
|
asmv("mov %%sp, %0"
|
||||||
: "=r"(Stack));
|
: "=r"(Stack));
|
||||||
#endif
|
#endif
|
||||||
|
@ -101,10 +101,10 @@ namespace SymbolResolver
|
|||||||
Elf_Sym *Symbols = nullptr;
|
Elf_Sym *Symbols = nullptr;
|
||||||
uint8_t *StringAddress = nullptr;
|
uint8_t *StringAddress = nullptr;
|
||||||
|
|
||||||
#if defined(a64) || defined(aa64)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
Elf64_Xword SymbolSize = 0;
|
Elf64_Xword SymbolSize = 0;
|
||||||
// Elf64_Xword StringSize = 0;
|
// Elf64_Xword StringSize = 0;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
Elf32_Word SymbolSize = 0;
|
Elf32_Word SymbolSize = 0;
|
||||||
// Elf32_Word StringSize = 0;
|
// Elf32_Word StringSize = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -218,9 +218,9 @@ namespace SymbolResolver
|
|||||||
}
|
}
|
||||||
debug("Solving symbols for address: %#llx", ImageAddress);
|
debug("Solving symbols for address: %#llx", ImageAddress);
|
||||||
|
|
||||||
#if defined(a64) || defined(aa64)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
Elf64_Ehdr *Header = (Elf64_Ehdr *)ImageAddress;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
Elf32_Ehdr *Header = (Elf32_Ehdr *)ImageAddress;
|
||||||
#endif
|
#endif
|
||||||
if (Header->e_ident[0] != 0x7F &&
|
if (Header->e_ident[0] != 0x7F &&
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
AutoSwitchPageTable()
|
AutoSwitchPageTable()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %%cr3, %0"
|
asmv("mov %%cr3, %0"
|
||||||
: "=r"(Original));
|
: "=r"(Original));
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
{
|
{
|
||||||
debug("- %#lx %s(%d)", Original,
|
debug("- %#lx %s(%d)", Original,
|
||||||
thisProcess->Name, thisProcess->ID);
|
thisProcess->Name, thisProcess->ID);
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
asmv("mov %0, %%cr3"
|
asmv("mov %0, %%cr3"
|
||||||
:
|
:
|
||||||
: "r"(Original));
|
: "r"(Original));
|
@ -28,12 +28,12 @@ namespace Time
|
|||||||
{
|
{
|
||||||
bool HighPrecisionEventTimer::Sleep(size_t Duration, Units Unit)
|
bool HighPrecisionEventTimer::Sleep(size_t Duration, Units Unit)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
uint64_t Target = mminq(&hpet->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
uint64_t Target = mminq(&hpet->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
||||||
while (mminq(&hpet->MainCounterValue) < Target)
|
while (mminq(&hpet->MainCounterValue) < Target)
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
return true;
|
return true;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
uint64_t Target = mminl(&hpet->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
uint64_t Target = mminl(&hpet->MainCounterValue) + (Duration * ConvertUnit(Unit)) / clk;
|
||||||
while (mminl(&hpet->MainCounterValue) < Target)
|
while (mminl(&hpet->MainCounterValue) < Target)
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
@ -44,25 +44,25 @@ namespace Time
|
|||||||
|
|
||||||
uint64_t HighPrecisionEventTimer::GetCounter()
|
uint64_t HighPrecisionEventTimer::GetCounter()
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
return mminq(&hpet->MainCounterValue);
|
return mminq(&hpet->MainCounterValue);
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
return mminl(&hpet->MainCounterValue);
|
return mminl(&hpet->MainCounterValue);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HighPrecisionEventTimer::CalculateTarget(uint64_t Target, Units Unit)
|
uint64_t HighPrecisionEventTimer::CalculateTarget(uint64_t Target, Units Unit)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
return mminq(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
return mminq(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
return mminl(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
return mminl(&hpet->MainCounterValue) + (Target * ConvertUnit(Unit)) / clk;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HighPrecisionEventTimer::GetNanosecondsSinceClassCreation()
|
uint64_t HighPrecisionEventTimer::GetNanosecondsSinceClassCreation()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint64_t Subtraction = this->GetCounter() - this->ClassCreationTime;
|
uint64_t Subtraction = this->GetCounter() - this->ClassCreationTime;
|
||||||
if (Subtraction <= 0 || this->clk <= 0)
|
if (Subtraction <= 0 || this->clk <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -74,7 +74,7 @@ namespace Time
|
|||||||
|
|
||||||
HighPrecisionEventTimer::HighPrecisionEventTimer(void *hpet)
|
HighPrecisionEventTimer::HighPrecisionEventTimer(void *hpet)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
ACPI::ACPI::HPETHeader *HPET_HDR = (ACPI::ACPI::HPETHeader *)hpet;
|
ACPI::ACPI::HPETHeader *HPET_HDR = (ACPI::ACPI::HPETHeader *)hpet;
|
||||||
Memory::Virtual vmm;
|
Memory::Virtual vmm;
|
||||||
vmm.Map((void *)HPET_HDR->Address.Address,
|
vmm.Map((void *)HPET_HDR->Address.Address,
|
||||||
@ -86,7 +86,7 @@ namespace Time
|
|||||||
(void *)HPET_HDR->Address.Address);
|
(void *)HPET_HDR->Address.Address);
|
||||||
clk = s_cst(uint32_t, (uint64_t)this->hpet->GeneralCapabilities >> 32);
|
clk = s_cst(uint32_t, (uint64_t)this->hpet->GeneralCapabilities >> 32);
|
||||||
KPrint("HPET clock is %u Hz", clk);
|
KPrint("HPET clock is %u Hz", clk);
|
||||||
#ifdef a64
|
#ifdef __amd64__
|
||||||
mmoutq(&this->hpet->GeneralConfiguration, 0);
|
mmoutq(&this->hpet->GeneralConfiguration, 0);
|
||||||
mmoutq(&this->hpet->MainCounterValue, 0);
|
mmoutq(&this->hpet->MainCounterValue, 0);
|
||||||
mmoutq(&this->hpet->GeneralConfiguration, 1);
|
mmoutq(&this->hpet->GeneralConfiguration, 1);
|
||||||
|
@ -24,7 +24,7 @@ namespace Time
|
|||||||
Clock ReadClock()
|
Clock ReadClock()
|
||||||
{
|
{
|
||||||
Clock tm;
|
Clock tm;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint32_t t = 0;
|
uint32_t t = 0;
|
||||||
outb(0x70, 0x00);
|
outb(0x70, 0x00);
|
||||||
t = inb(0x71);
|
t = inb(0x71);
|
||||||
@ -45,7 +45,7 @@ namespace Time
|
|||||||
t = inb(0x71);
|
t = inb(0x71);
|
||||||
tm.Year = ((t & 0x0F) + ((t >> 4) * 10));
|
tm.Year = ((t & 0x0F) + ((t >> 4) * 10));
|
||||||
tm.Counter = 0;
|
tm.Counter = 0;
|
||||||
#elif defined(aa64)
|
#elif defined(__aarch64__)
|
||||||
tm.Year = 0;
|
tm.Year = 0;
|
||||||
tm.Month = 0;
|
tm.Month = 0;
|
||||||
tm.Day = 0;
|
tm.Day = 0;
|
||||||
|
@ -145,7 +145,7 @@ namespace Time
|
|||||||
|
|
||||||
void time::FindTimers(void *acpi)
|
void time::FindTimers(void *acpi)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
/* TODO: RTC check */
|
/* TODO: RTC check */
|
||||||
/* TODO: PIT check */
|
/* TODO: PIT check */
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace Time
|
|||||||
{
|
{
|
||||||
bool TimeStampCounter::Sleep(size_t Duration, Units Unit)
|
bool TimeStampCounter::Sleep(size_t Duration, Units Unit)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint64_t Target = this->GetCounter() + (Duration * ConvertUnit(Unit)) / this->clk;
|
uint64_t Target = this->GetCounter() + (Duration * ConvertUnit(Unit)) / this->clk;
|
||||||
while (this->GetCounter() < Target)
|
while (this->GetCounter() < Target)
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
@ -38,28 +38,28 @@ namespace Time
|
|||||||
|
|
||||||
uint64_t TimeStampCounter::GetCounter()
|
uint64_t TimeStampCounter::GetCounter()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
return CPU::Counter();
|
return CPU::Counter();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t TimeStampCounter::CalculateTarget(uint64_t Target, Units Unit)
|
uint64_t TimeStampCounter::CalculateTarget(uint64_t Target, Units Unit)
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
return uint64_t((this->GetCounter() + (Target * ConvertUnit(Unit))) / this->clk);
|
return uint64_t((this->GetCounter() + (Target * ConvertUnit(Unit))) / this->clk);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t TimeStampCounter::GetNanosecondsSinceClassCreation()
|
uint64_t TimeStampCounter::GetNanosecondsSinceClassCreation()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
return uint64_t((this->GetCounter() - this->ClassCreationTime) / this->clk);
|
return uint64_t((this->GetCounter() - this->ClassCreationTime) / this->clk);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeStampCounter::TimeStampCounter()
|
TimeStampCounter::TimeStampCounter()
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
stub; // FIXME: This is not a good way to measure the clock speed
|
stub; // FIXME: This is not a good way to measure the clock speed
|
||||||
uint64_t Start = CPU::Counter();
|
uint64_t Start = CPU::Counter();
|
||||||
TimeManager->Sleep(1, Units::Milliseconds);
|
TimeManager->Sleep(1, Units::Milliseconds);
|
||||||
|
@ -16,33 +16,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <uart.hpp>
|
#include <uart.hpp>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
#include <debug.h>
|
namespace UART
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
bool serialports[8] = {false, false, false, false, false, false, false, false};
|
|
||||||
std::vector<UniversalAsynchronousReceiverTransmitter::Events *> RegisteredEvents;
|
|
||||||
|
|
||||||
#if defined(a86)
|
|
||||||
NIF __always_inline inline uint8_t NoProfiler_inportb(uint16_t Port)
|
|
||||||
{
|
{
|
||||||
uint8_t Result;
|
enum SerialPorts
|
||||||
asm("in %%dx, %%al"
|
{
|
||||||
: "=a"(Result)
|
COM1 = 0x3F8,
|
||||||
: "d"(Port));
|
COM2 = 0x2F8,
|
||||||
return Result;
|
COM3 = 0x3E8,
|
||||||
}
|
COM4 = 0x2E8,
|
||||||
|
COM5 = 0x5F8,
|
||||||
|
COM6 = 0x4F8,
|
||||||
|
COM7 = 0x5E8,
|
||||||
|
COM8 = 0x4E8
|
||||||
|
};
|
||||||
|
|
||||||
NIF __always_inline inline void NoProfiler_outportb(uint16_t Port, uint8_t Data)
|
|
||||||
{
|
|
||||||
asmv("out %%al, %%dx"
|
|
||||||
:
|
|
||||||
: "a"(Data), "d"(Port));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace UniversalAsynchronousReceiverTransmitter
|
|
||||||
{
|
|
||||||
#define SERIAL_ENABLE_DLAB 0x80
|
#define SERIAL_ENABLE_DLAB 0x80
|
||||||
#define SERIAL_RATE_115200_LO 0x01
|
#define SERIAL_RATE_115200_LO 0x01
|
||||||
#define SERIAL_RATE_115200_HI 0x00
|
#define SERIAL_RATE_115200_HI 0x00
|
||||||
@ -52,137 +41,96 @@ namespace UniversalAsynchronousReceiverTransmitter
|
|||||||
#define SERIAL_RATE_38400_HI 0x00
|
#define SERIAL_RATE_38400_HI 0x00
|
||||||
#define SERIAL_BUFFER_EMPTY 0x20
|
#define SERIAL_BUFFER_EMPTY 0x20
|
||||||
|
|
||||||
/* TODO: Serial Port implementation needs reword. https://wiki.osdev.org/Serial_Ports */
|
void Driver::DebugWrite(uint8_t Char)
|
||||||
|
|
||||||
nsa NIF UART::UART(SerialPorts Port)
|
|
||||||
{
|
{
|
||||||
#if defined(a86)
|
if (!DebugAvailable)
|
||||||
if (Port == COMNULL)
|
|
||||||
return;
|
return;
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
uint8_t com = NoProfiler_inportb(Port);
|
while ((inb(s_cst(uint16_t, COM1 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
||||||
if (com == 0xFF)
|
|
||||||
{
|
|
||||||
error("Serial port %#lx is not available.", Port);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->Port = Port;
|
|
||||||
int PortNumber = 0;
|
|
||||||
|
|
||||||
switch (Port)
|
|
||||||
{
|
|
||||||
case COM1:
|
|
||||||
PortNumber = 0;
|
|
||||||
break;
|
|
||||||
case COM2:
|
|
||||||
PortNumber = 1;
|
|
||||||
break;
|
|
||||||
case COM3:
|
|
||||||
PortNumber = 2;
|
|
||||||
break;
|
|
||||||
case COM4:
|
|
||||||
PortNumber = 3;
|
|
||||||
break;
|
|
||||||
case COM5:
|
|
||||||
PortNumber = 4;
|
|
||||||
break;
|
|
||||||
case COM6:
|
|
||||||
PortNumber = 5;
|
|
||||||
break;
|
|
||||||
case COM7:
|
|
||||||
PortNumber = 6;
|
|
||||||
break;
|
|
||||||
case COM8:
|
|
||||||
PortNumber = 7;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serialports[PortNumber])
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Initialize the serial port
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 1), 0x00); // Disable all interrupts
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 3), SERIAL_ENABLE_DLAB); // Enable DLAB (set baud rate divisor)
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 0), SERIAL_RATE_115200_LO); // Set divisor to 1 (lo byte) 115200 baud
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 1), SERIAL_RATE_115200_HI); // (hi byte)
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 3), 0x03); // 8 bits, no parity, one stop bit
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 2), 0xC7); // Enable FIFO, clear them, with 14-byte threshold
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 4), 0x0B); // IRQs enabled, RTS/DSR set
|
|
||||||
|
|
||||||
/* FIXME https://wiki.osdev.org/Serial_Ports */
|
|
||||||
// NoProfiler_outportb(s_cst(uint16_t, Port + 0), 0x1E);
|
|
||||||
// NoProfiler_outportb(s_cst(uint16_t, Port + 0), 0xAE);
|
|
||||||
// Check if the serial port is faulty.
|
|
||||||
// if (NoProfiler_inportb(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.
|
|
||||||
NoProfiler_outportb(s_cst(uint16_t, Port + 4), 0x0F);
|
|
||||||
serialports[PortNumber] = true;
|
|
||||||
this->IsAvailable = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
nsa NIF UART::~UART() {}
|
|
||||||
|
|
||||||
nsa NIF void UART::Write(uint8_t Char)
|
|
||||||
{
|
|
||||||
if (!this->IsAvailable)
|
|
||||||
return;
|
|
||||||
#if defined(a86)
|
|
||||||
while ((NoProfiler_inportb(s_cst(uint16_t, Port + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
|
||||||
;
|
;
|
||||||
NoProfiler_outportb(Port, Char);
|
outb(COM1, Char);
|
||||||
#endif
|
#endif
|
||||||
foreach (auto e in RegisteredEvents)
|
|
||||||
if (e->GetRegisteredPort() == Port || e->GetRegisteredPort() == COMNULL)
|
|
||||||
e->OnSent(Char);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF uint8_t UART::Read()
|
uint8_t Driver::DebugRead()
|
||||||
{
|
{
|
||||||
if (!this->IsAvailable)
|
if (!DebugAvailable)
|
||||||
return 0;
|
return 0;
|
||||||
#if defined(a86)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
while ((NoProfiler_inportb(s_cst(uint16_t, Port + 5)) & 1) == 0)
|
while ((inb(s_cst(uint16_t, COM1 + 5)) & 1) == 0)
|
||||||
;
|
;
|
||||||
return NoProfiler_inportb(Port);
|
return inb(COM1);
|
||||||
#endif
|
#endif
|
||||||
foreach (auto e in RegisteredEvents)
|
|
||||||
{
|
|
||||||
if (e->GetRegisteredPort() == Port || e->GetRegisteredPort() == COMNULL)
|
|
||||||
{
|
|
||||||
#if defined(a86)
|
|
||||||
e->OnReceived(NoProfiler_inportb(Port));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF Events::Events(SerialPorts Port)
|
void Driver::TTYWrite(uint8_t Char)
|
||||||
{
|
{
|
||||||
this->Port = Port;
|
if (!TTYAvailable)
|
||||||
RegisteredEvents.push_back(this);
|
return;
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
|
while ((inb(s_cst(uint16_t, COM4 + 5)) & SERIAL_BUFFER_EMPTY) == 0)
|
||||||
|
;
|
||||||
|
outb(COM4, Char);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF Events::~Events()
|
uint8_t Driver::TTYRead()
|
||||||
{
|
{
|
||||||
forItr(itr, RegisteredEvents)
|
if (!TTYAvailable)
|
||||||
{
|
return 0;
|
||||||
if (*itr == this)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
{
|
while ((inb(s_cst(uint16_t, COM4 + 5)) & 1) == 0)
|
||||||
RegisteredEvents.erase(itr);
|
;
|
||||||
return;
|
return inb(COM4);
|
||||||
}
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Driver::Driver()
|
||||||
|
{
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver::~Driver() {}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace Execute
|
|||||||
uint64_t EntryPoint,
|
uint64_t EntryPoint,
|
||||||
uint64_t BaseAddress)
|
uint64_t BaseAddress)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
char *aux_platform = (char *)vma->RequestPages(1, true); /* TODO: 4KiB is too much for this */
|
char *aux_platform = (char *)vma->RequestPages(1, true); /* TODO: 4KiB is too much for this */
|
||||||
strcpy(aux_platform, "x86_64");
|
strcpy(aux_platform, "x86_64");
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ namespace Execute
|
|||||||
|
|
||||||
void ELFObject::LoadExec_x86_64(FileNode *fd, PCB *TargetProcess)
|
void ELFObject::LoadExec_x86_64(FileNode *fd, PCB *TargetProcess)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
||||||
foreach (auto Interp in PhdrINTERP)
|
foreach (auto Interp in PhdrINTERP)
|
||||||
{
|
{
|
||||||
@ -318,7 +318,7 @@ namespace Execute
|
|||||||
|
|
||||||
void ELFObject::LoadDyn_x86_64(FileNode *fd, PCB *TargetProcess)
|
void ELFObject::LoadDyn_x86_64(FileNode *fd, PCB *TargetProcess)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
||||||
foreach (auto Interp in PhdrINTERP)
|
foreach (auto Interp in PhdrINTERP)
|
||||||
{
|
{
|
||||||
@ -811,36 +811,15 @@ namespace Execute
|
|||||||
Elf32_Ehdr ELFHeader{};
|
Elf32_Ehdr ELFHeader{};
|
||||||
fd->Read(&ELFHeader, sizeof(Elf32_Ehdr), 0);
|
fd->Read(&ELFHeader, sizeof(Elf32_Ehdr), 0);
|
||||||
|
|
||||||
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
|
||||||
const char *ElfInterpPath = nullptr;
|
|
||||||
if (!PhdrINTERP.empty() && ELFHeader.e_type == ET_DYN)
|
|
||||||
{
|
|
||||||
ElfInterpPath = new char[256];
|
|
||||||
fd->Read(ElfInterpPath, 256, PhdrINTERP.front().p_offset);
|
|
||||||
debug("Interpreter: %s", ElfInterpPath);
|
|
||||||
argc++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ELFargv = new const char *[argc + 2];
|
// ELFargv = new const char *[argc + 2];
|
||||||
size_t argv_size = argc + 2 * sizeof(char *);
|
size_t argv_size = argc + 2 * sizeof(char *);
|
||||||
ELFargv = (const char **)TargetProcess->vma->RequestPages(TO_PAGES(argv_size));
|
ELFargv = (const char **)TargetProcess->vma->RequestPages(TO_PAGES(argv_size));
|
||||||
|
|
||||||
int interAdd = 0;
|
for (int i = 0; i < argc; i++)
|
||||||
if (ElfInterpPath)
|
|
||||||
{
|
{
|
||||||
size_t interp_size = strlen(ElfInterpPath) + 1;
|
size_t arg_size = strlen(argv[i]) + 1;
|
||||||
ELFargv[0] = (const char *)TargetProcess->vma->RequestPages(TO_PAGES(interp_size));
|
|
||||||
strcpy((char *)ELFargv[0], ElfInterpPath);
|
|
||||||
delete[] ElfInterpPath;
|
|
||||||
interAdd++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = interAdd; i < argc; i++)
|
|
||||||
{
|
|
||||||
assert(argv[i - interAdd] != nullptr);
|
|
||||||
size_t arg_size = strlen(argv[i - interAdd]) + 1;
|
|
||||||
ELFargv[i] = (const char *)TargetProcess->vma->RequestPages(TO_PAGES(arg_size));
|
ELFargv[i] = (const char *)TargetProcess->vma->RequestPages(TO_PAGES(arg_size));
|
||||||
strcpy((char *)ELFargv[i], argv[i - interAdd]);
|
strcpy((char *)ELFargv[i], argv[i]);
|
||||||
}
|
}
|
||||||
ELFargv[argc] = nullptr;
|
ELFargv[argc] = nullptr;
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ namespace Execute
|
|||||||
|
|
||||||
Elf64_Sym ELFLookupSymbol(FileNode *fd, std::string Name)
|
Elf64_Sym ELFLookupSymbol(FileNode *fd, std::string Name)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
Elf64_Ehdr Header{};
|
Elf64_Ehdr Header{};
|
||||||
fd->Read(&Header, sizeof(Elf64_Ehdr), 0);
|
fd->Read(&Header, sizeof(Elf64_Ehdr), 0);
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ namespace Execute
|
|||||||
|
|
||||||
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index)
|
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
if (Table == SHN_UNDEF || Index == SHN_UNDEF)
|
if (Table == SHN_UNDEF || Index == SHN_UNDEF)
|
||||||
return 0;
|
return 0;
|
||||||
Elf64_Shdr *SymbolTable = GetELFSection(Header, Table);
|
Elf64_Shdr *SymbolTable = GetELFSection(Header, Table);
|
||||||
@ -186,7 +186,7 @@ namespace Execute
|
|||||||
Elf64_Shdr *Target = GetELFSection(Header, Symbol->st_shndx);
|
Elf64_Shdr *Target = GetELFSection(Header, Symbol->st_shndx);
|
||||||
return (uintptr_t)Header + Symbol->st_value + Target->sh_offset;
|
return (uintptr_t)Header + Symbol->st_value + Target->sh_offset;
|
||||||
}
|
}
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
return 0xdead;
|
return 0xdead;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace Execute
|
|||||||
const char *Name,
|
const char *Name,
|
||||||
Tasking::PCB *Process)
|
Tasking::PCB *Process)
|
||||||
{
|
{
|
||||||
#if defined(a64)
|
#if defined(__amd64__)
|
||||||
UNUSED(Name);
|
UNUSED(Name);
|
||||||
debug("Relocatable");
|
debug("Relocatable");
|
||||||
/* TODO: I have to fully implement this, but for now I will leave it as it is now. */
|
/* TODO: I have to fully implement this, but for now I will leave it as it is now. */
|
||||||
@ -95,7 +95,7 @@ namespace Execute
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace Execute
|
|||||||
std::vector<Elf64_Dyn> ELFGetDynamicTag_x86_64(FileNode *fd,
|
std::vector<Elf64_Dyn> ELFGetDynamicTag_x86_64(FileNode *fd,
|
||||||
DynamicArrayTags Tag)
|
DynamicArrayTags Tag)
|
||||||
{
|
{
|
||||||
#if defined(a64) || defined(aa64)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
std::vector<Elf64_Dyn> Ret;
|
std::vector<Elf64_Dyn> Ret;
|
||||||
|
|
||||||
Elf64_Ehdr ELFHeader{};
|
Elf64_Ehdr ELFHeader{};
|
||||||
@ -55,7 +55,7 @@ namespace Execute
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
#elif defined(a32)
|
#elif defined(__i386__)
|
||||||
return {};
|
return {};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user