87 Commits

Author SHA1 Message Date
fbe9fbfbd1 kernel: add arm architecture support
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 5m35s
Build OS / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Has been cancelled
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Build OS / Build amd64 (push) Has been cancelled
Build OS / Build i386 (push) Has been cancelled
Build OS / Build aarch64 (push) Has been cancelled
Build OS / Build arm (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-10 18:55:34 +02:00
e6933acfb0 kernel: add aarch64 architecture support
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-10 17:26:26 +02:00
07abdd9f6c workflows: move obsolete CodeQL and documentation workflows to makefile.yml
Some checks failed
Build OS / Build Cross-Compiler & Toolchain (push) Successful in 2h54m6s
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 3m8s
Build OS / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Failing after 2m37s
Build OS / Build amd64 (push) Failing after 14m7s
Build OS / Build i386 (push) Failing after 13m9s
Build OS / Build aarch64 (push) Failing after 5m33s
Build OS / Build arm (push) Failing after 5m29s
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-08 17:11:46 +02:00
9cb66f395b workflows: add ARM build support
Some checks failed
Build OS / Build amd64 (push) Blocked by required conditions
Build OS / Build i386 (push) Blocked by required conditions
Build OS / Build aarch64 (push) Blocked by required conditions
Build OS / Build arm (push) Blocked by required conditions
Deploy Documentation / Deploy Documentation to GitHub Pages (push) Failing after 5m4s
CodeQL Advanced / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Failing after 4m42s
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-08 12:02:12 +02:00
eb602e12c2 toolchain: update architecture support and improve toolchain configuration
Added arm and aarch64 support
tools/Makefile has been refactored

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-08 11:59:30 +02:00
61b1e95629 kernel: Fix boot on i386
Some checks failed
CodeQL Advanced / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Has been cancelled
Deploy Documentation / Deploy Documentation to GitHub Pages (push) Has been cancelled
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Build OS / Build amd64 (push) Has been cancelled
Build OS / Build i386 (push) Has been cancelled
Build OS / Build aarch64 (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-07 17:58:51 +02:00
2bb997597e refactor: Fix build on i386
Some checks failed
CodeQL Advanced / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Has been cancelled
Deploy Documentation / Deploy Documentation to GitHub Pages (push) Has been cancelled
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Build OS / Build amd64 (push) Has been cancelled
Build OS / Build i386 (push) Has been cancelled
Build OS / Build aarch64 (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-07 17:49:37 +02:00
463d16f8bc refactor: streamline source file discovery in Makefile and update OSARCH handling in config.mk
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-07 13:45:59 +02:00
6cf3c62c83 chore: remove SonarCloud workflow configuration
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 21:44:56 +02:00
3a85a5586f Merge branch 'master' of https://github.com/EnderIce2/Fennix
Some checks failed
Deploy Documentation / Deploy Documentation to GitHub Pages (push) Failing after 3m36s
SonarCloud analysis / Analysis (push) Failing after 6m26s
Build OS / Build Cross-Compiler & Toolchain (push) Successful in 1h10m12s
Build OS / Build amd64 (push) Failing after 16m17s
Build OS / Build i386 (push) Failing after 7m21s
Build OS / Build aarch64 (push) Has been cancelled
CodeQL Advanced / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Failing after 2m53s
2025-01-04 21:35:38 +02:00
363200d443 Create sonarcloud.yml 2025-01-04 21:27:02 +02:00
d4001003a3 chore: add LICENSE file for rpmalloc
[skip ci]

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 21:05:06 +02:00
8bfed94ba9 chore: upgrade actions/checkout, actions/cache, and actions/upload-artifact to v4
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 21:01:06 +02:00
04edfd46bb chore: rename workflow from 'Build OS' to 'Deploy Documentation'
[skip ci]

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:35:57 +02:00
082f2fb6f2 kernel: Fix release compilation on amd64
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:34:57 +02:00
94cdd71e1e chore: migrate documentation deployment to a new workflow
[skip ci]

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:30:14 +02:00
c22c079628 chore: todo
Some checks failed
Build OS / Build amd64 (push) Blocked by required conditions
Build OS / Build i386 (push) Blocked by required conditions
Build OS / Build aarch64 (push) Blocked by required conditions
CodeQL Advanced / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Failing after 3m8s
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 1m52s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 1h9m55s
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:26:08 +02:00
6024a2347b chore: Add CodeQL advanced analysis workflow
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:23:34 +02:00
c723a5f82d chore: Allow aarch64 build job
[skip ci]

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:19:10 +02:00
a6d2d51870 chore: Remove CodeQL analysis steps from makefile.yml workflow
[skip ci]

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 20:03:08 +02:00
fb186f6615 chore: Remove Flawfinder analysis steps from makefile.yml workflow
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 19:55:35 +02:00
0160fa3c72 chore: Update flawfinder scan minimum level from 4 to 5 in makefile.yml
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 19:47:21 +02:00
d77d6892a0 chore: Enhance makefile.yml to recheck and install specific versions of automake and autoconf
Some checks failed
Build OS / Build i386 (push) Blocked by required conditions
Build OS / Build aarch64 (push) Blocked by required conditions
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 1m32s
Build OS / Build Cross-Compiler & Toolchain (push) Successful in 1h8m49s
Build OS / Flawfinder (push) Failing after 3m17s
Build OS / Analyze with CodeQL (cpp) (push) Failing after 3m27s
Build OS / Build amd64 (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:59:04 +02:00
2b1ec40dc3 chore: Add automake installation to makefile.yml workflow
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:49:43 +02:00
a1fa698bc3 chore: Update autoconf installation command to use dpkg with force option
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:46:40 +02:00
4c0cb59aa7 chore: Remove autoconf purge step and adjust installation method for autoconf
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 1m46s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 13m37s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
Build OS / Flawfinder (push) Failing after 2m29s
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:37:32 +02:00
f015ff606f chore: Update makefile.yml to install automake alongside autoconf
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 2m2s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 1m16s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
Build OS / Flawfinder (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:33:52 +02:00
df0c17b50f chore: Update autoconf workflow to also purge and install automake
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:30:46 +02:00
9a9ee7e571 chore: Update autoconf installation method in workflow to use Debian package
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:26:24 +02:00
e7e248bc3a chore: Fix typo in package installation command in makefile.yml
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 1m30s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 38s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
Build OS / Flawfinder (push) Failing after 2m52s
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:17:21 +02:00
bbc6212cfa chore: Enhance GCC installation workflow with autoconf recheck and libtool addition
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:15:58 +02:00
170922e1be chore: Purge autoconf before installing GCC dependencies in workflow
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:07:18 +02:00
100927547d chore: Update GCC dependencies in GitHub Actions workflow
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 18:03:09 +02:00
073f582752 website: Rewrite the website
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 2m45s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 14m7s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
Build OS / Flawfinder (push) Failing after 6m46s
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 08:09:57 +02:00
edd13c30c5 chore: Update markdown files
Added CODE_OF_CONDUCT.md
Added CONTRIBUTING.md
Moved CREDITS.md
Moved LICENSES.md
Added SECURITY.md
Added STYLE_GUIDE.md

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 07:52:29 +02:00
6dae34debd userspace: Rewrite everything
Everything.

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:27:54 +02:00
dea36a0228 chore: Update makefiles and doxygen
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:26:55 +02:00
8dd3179aaa chore: Delete tailprofiler.sh and tailserial.sh scripts
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:14:47 +02:00
0699d7962d docker: Remove .dockerignore, Dockerfile, and compose.yaml
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:14:20 +02:00
e4403cdbd6 vscode: Update configuration files
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:13:31 +02:00
5632c7cb10 drivers: Update syscalls.h
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:07:12 +02:00
efb3a80ffd signal: Remove redundant static assertions for signal flags
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 06:03:17 +02:00
5d3bb391a4 syscalls: Add syscall_clockid_t and fix enum names
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 04:35:02 +02:00
b3f304f2c5 linker: Remove .note section from discard list
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 04:20:27 +02:00
e23e793574 syscalls: Add signal_action_flags_t structure
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-04 04:19:31 +02:00
522158913f kernel: Add .note section
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-03 21:51:17 +02:00
12a768a592 chore: Update workflows
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-29 22:43:20 +02:00
9ea2f4266e chore: Add patch for qemu
Removed patch "Replace GDB exit calls with proper shutdown" so when we stop debugging in vscode, the qemu process is automatically killed.

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-28 08:49:12 +02:00
eb7c13dd45 drivers: Update syscalls.h
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 05:45:06 +02:00
8f04f8a374 kernel/idt: Keep #PF handling always enabled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 05:44:26 +02:00
1695418dcb kernel/syscalls: Implement sys_tell & sys_seek
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 03:20:27 +02:00
b208862de2 kernel/syscalls: Add conversion for syscall macros
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 03:06:54 +02:00
a8481d4260 kernel/syscalls: Fix doxygen documentation
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 02:48:50 +02:00
c84757af48 kernel/syscalls: Add macros for syscalls
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 02:37:02 +02:00
80afbedf39 kernel/syscalls: Implement sys_kill syscall
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 02:23:30 +02:00
911caf7203 kernel/signals: Update headers for syscalls.h changes
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-26 02:23:12 +02:00
95a8d6fb6f kernel/idt: Fix ExceptionHandlerStub setting fs & gs to 0
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-25 04:49:01 +02:00
b471645743 kernel/syscalls: Implement sys_prctl syscall
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-25 04:47:26 +02:00
cc6ec04814 kernel/stack: Fix stack guard expansion
Kernel didn't mapped the pages correctly

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-24 03:54:13 +02:00
1dbee4660e drivers: Update include headers
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-23 03:55:39 +02:00
81af8a48cb kernel/uart: Refactor code
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-23 03:52:26 +02:00
0807ea5a9a chore: Update TODO.md
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:11:42 +02:00
79d267631a kernel/syscalls: Add experimental native system calls
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:11:01 +02:00
cbd671292d kernel/fs: Implement usr_pread/pwrite in FDT
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:09:30 +02:00
37c3ee8e99 kernel: Update syscall header
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:07:34 +02:00
7d85dd5dd8 kernel: Update interface headers
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:03:27 +02:00
17abdcaf1e kernel: Update elf.h
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:02:09 +02:00
f038f6110e chore: Update vscode config
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 04:01:33 +02:00
3798ec0f58 kernel: Add COM5-8 checks
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-20 03:58:31 +02:00
fe5e4e3eec chore: Update makefiles
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2024-12-11 05:52:22 +02:00
6f17b29963 kernel/elf: Update ELFObject()
Why did I wrote that?

The interpreter wants argv[0] to be the path of the program to be loaded.

Signed-off-by: EnderIce2 <enderice2@users.noreply.github.com>
2024-12-11 04:50:42 +02:00
8b026175bb chore: Update makefiles
https://stackoverflow.com/a/17845120/9352057
Signed-off-by: EnderIce2 <enderice2@users.noreply.github.com>
2024-12-11 04:48:16 +02:00
828dab1875 chore: Update driver makefiles 2024-11-29 05:05:49 +02:00
7948d0c6e5 chore: Update makefiles & macros 2024-11-29 04:24:27 +02:00
ce3cf8162a chore: Update codebase
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 53s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 17m52s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
2024-11-28 04:47:30 +02:00
640b902045 chore: Update vscode workspace files
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Has been cancelled
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Build OS / Analyze with CodeQL (cpp) (push) Has been cancelled
Build OS / Build amd64 (push) Has been cancelled
Build OS / Build i386 (push) Has been cancelled
Build OS / Build aarch64 (push) Has been cancelled
2024-11-27 01:56:37 +02:00
0dbdacb8df chore: General cleanup 2024-11-27 01:19:24 +02:00
220238eff8 chore: Revert last change
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 13s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 9s
Build OS / Build GNU-EFI (push) Failing after 5s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
2024-11-26 04:13:34 +02:00
360afdbc9c chore: Remove sudo & change "apt-get" to "apt"
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 18s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 10s
Build OS / Build GNU-EFI (push) Failing after 11s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
2024-11-26 04:03:57 +02:00
f34a222bf1 chore: TODO: Fix workflows
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Waiting to run
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 20s
Build OS / Build GNU-EFI (push) Failing after 3s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
Awesome...
2024-11-26 03:46:43 +02:00
1b1d3e68fd chore: Fix workflow error 2024-11-26 03:42:12 +02:00
f11c00a4e3 chore: (Again) Fix workflow error
Too bad that there's no way of testing a workflow.
2024-11-26 03:37:31 +02:00
ae07b07964 chore: Fix workflow error "this file was generated for autoconf 2.69" 2024-11-26 03:32:40 +02:00
23853cbb15 chore: Add experimental docker build 2024-11-26 03:27:25 +02:00
00a37325f6 chore: Fix build process 2024-11-26 03:27:08 +02:00
ce4ebaf6c5 Remove submodule
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 1m14s
Build OS / Build Cross-Compiler & Toolchain (push) Failing after 1m2s
Build OS / Build GNU-EFI (push) Failing after 7s
Build OS / Analyze with CodeQL (cpp) (push) Has been skipped
Build OS / Build amd64 (push) Has been skipped
Build OS / Build i386 (push) Has been skipped
Build OS / Build aarch64 (push) Has been skipped
2024-11-20 05:49:33 +02:00
5806c4feaf Update .gitmodules 2024-11-20 05:47:19 +02:00
454 changed files with 29694 additions and 26790 deletions

2
.github/FUNDING.yml vendored
View File

@ -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

View File

@ -7,17 +7,160 @@ on:
branches: [ master ] branches: [ master ]
jobs: jobs:
buildcompiler:
name: Build Cross-Compiler & Toolchain
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache cross Folder
id: cache-cross
uses: actions/cache@v4
with:
path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Update System
if: steps.cache-cross.outputs.cache-hit != 'true'
run: sudo apt update
- name: Install GCC Dependencies
if: steps.cache-cross.outputs.cache-hit != 'true'
run: sudo apt -y install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo libzstd-dev libisl-dev m4 automake gettext gperf dejagnu guile-3.0 guile-3.0-dev expect tcl autogen tex-common sphinx-common git ssh diffutils patch autoconf2.69 libtool wget dpkg
- name: Check autoconf
if: steps.cache-cross.outputs.cache-hit != 'true'
run: |
if [ "$(autoconf --version | head -n 1 | awk '{print $NF}')" != "2.69" ]; then
echo "Autoconf version is not 2.69, performing additional steps..."
wget https://launchpad.net/ubuntu/+archive/primary/+files/autoconf_2.69-11.1_all.deb
sudo dpkg --force-all -i ./autoconf_2.69-11.1_all.deb
fi
- name: Check automake
if: steps.cache-cross.outputs.cache-hit != 'true'
run: |
if [ "$(automake --version | head -n 1 | awk '{print $NF}')" != "1.15.1" ]; then
echo "Automake version is not 1.15.1, performing additional steps..."
wget https://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz
tar -xzf automake-1.15.1.tar.gz
cd automake-1.15.1
./configure
make
sudo make install
fi
- name: Clone All
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools __clone_all_no_qemu
- name: Compile Binutils
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools do_binutils
- name: Compile GCC
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools do_gcc
- name: Clean Up
if: steps.cache-cross.outputs.cache-hit != 'true'
run: |
cd tools
rm -rf binutils-gdb gcc
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
needs: [buildcompiler]
permissions:
security-events: write
packages: read
actions: read
contents: read
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: manual
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for cache
id: check-cache
run: |
if [ -z "${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}" ]; then
echo "No cache found, cancelling job."
exit 1
fi
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 0
- name: Install Packages
run: |
sudo apt update
sudo apt -y install rustc xorriso mtools genisoimage ovmf nasm doxygen make gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo
make --quiet -C tools do_limine
make --quiet -C Drivers prepare
make --quiet -C Userspace prepare
make --quiet -C Kernel prepare
- name: Cache cross
id: cache-cross
uses: actions/cache@v4
with:
path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Build OS
run: |
make build_userspace
make build_drivers
make build_kernel
make build_userspace
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
deploydoc: deploydoc:
name: Deploy Documentation to GitHub Pages name: Deploy Documentation to GitHub Pages
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Update System
run: sudo apt update
- name: Install Doxygen - name: Install Doxygen
run: sudo apt-get install doxygen make -y run: sudo apt -y install doxygen make
- name: Generate Documentation - name: Generate Documentation
run: make doxygen run: make doxygen
@ -30,310 +173,199 @@ jobs:
with: with:
folder: doxygen-doc folder: doxygen-doc
buildcompiler:
name: Build Cross-Compiler & Toolchain
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache cross Folder compile_amd64:
id: cache-cross
uses: actions/cache@v3
with:
path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Update System
if: steps.cache-cross.outputs.cache-hit != 'true'
run: sudo apt-get update
- name: Install GCC Dependencies
if: steps.cache-cross.outputs.cache-hit != 'true'
run: sudo apt 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 -y
- name: Clone All
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools __clone_all_no_qemu
- name: Compile Binutils amd64
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools do_binutils_64
- name: Compile Binutils i386
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools do_binutils_32
- name: Compile GCC amd64
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools do_gcc_64
- name: Compile GCC i386
if: steps.cache-cross.outputs.cache-hit != 'true'
run: make --quiet -C tools do_gcc_32
- name: Clean Up
if: steps.cache-cross.outputs.cache-hit != 'true'
run: |
cd tools
rm -rf binutils-gdb gcc build-binutils64 build-gcc64 build-binutils32 build-gcc32
compilegnuefi:
name: Build GNU-EFI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache gnu-efi Folder
id: cache-gnuefi
uses: actions/cache@v3
with:
path: Lynx/gnu-efi
key: ${{ runner.os }}-gnuefi-${{ hashFiles('Lynx/Makefile') }}
- name: Update System
if: steps.cache-gnuefi.outputs.cache-hit != 'true'
run: sudo apt-get update
- name: Install MinGW compiler
if: steps.cache-gnuefi.outputs.cache-hit != 'true'
run: sudo apt-get install make gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y
- name: Get GNU-EFI source code and compile it
if: steps.cache-gnuefi.outputs.cache-hit != 'true'
run: make --quiet -C Lynx prepare
analyze:
name: Analyze with CodeQL
runs-on: ubuntu-latest
needs: [buildcompiler, compilegnuefi]
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Install Packages
run: |
sudo apt-get update
sudo apt-get install rustc xorriso mtools genisoimage ovmf nasm doxygen make gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo -y
make --quiet -C tools do_limine
make --quiet -C Drivers prepare
make --quiet -C Userspace prepare
make --quiet -C Lynx prepare
make --quiet -C Kernel prepare
- name: Cache cross
id: cache-cross
uses: actions/cache@v3
with:
path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Cache gnuefi
id: cache-gnuefi
uses: actions/cache@v3
with:
path: Lynx/gnu-efi
key: ${{ runner.os }}-gnuefi-${{ hashFiles('Lynx/Makefile') }}
- name: Build OS
run: |
make build_lynx
make build_userspace
make build_drivers
make build_kernel
make build_userspace
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
compile64:
name: Build amd64 name: Build amd64
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [buildcompiler, compilegnuefi] needs: [buildcompiler]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Update & Install Required Packages - name: Update & Install Required Packages
run: | run: |
sudo apt-get update sudo apt update
sudo apt-get install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y sudo apt install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y
make --quiet -C tools do_limine make --quiet -C tools do_limine
make --quiet -C Drivers prepare make --quiet -C Drivers prepare
make --quiet -C Userspace prepare make --quiet -C Userspace prepare
make --quiet -C Lynx prepare
make --quiet -C Kernel prepare make --quiet -C Kernel prepare
- name: Cache cross Folder - name: Cache cross Folder
id: cache-cross id: cache-cross
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: tools/cross path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }} key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Cache gnu-efi Folder - name: Configure config.mk
id: cache-gnuefi run: sed -i 's/.*OSARCH = .*/OSARCH = amd64/' ./config.mk && cat config.mk | grep OSARCH
uses: actions/cache@v3
with:
path: Lynx/gnu-efi
key: ${{ runner.os }}-gnuefi-${{ hashFiles('Lynx/Makefile') }}
- name: Configure Makefile.conf
run: sed -i 's/.*OSARCH = .*/OSARCH = amd64/' ./Makefile.conf && cat Makefile.conf | 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
- name: Upload Artifact (Fennix-debug.iso) - name: Upload Artifact (Fennix-debug.iso)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: Fennix-amd64-debug name: Fennix-amd64-debug
path: Fennix-debug.iso path: Fennix-debug.iso
- name: Upload Artifact (Fennix-release.iso) - name: Upload Artifact (Fennix-release.iso)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: Fennix-amd64-release name: Fennix-amd64-release
path: Fennix-release.iso path: Fennix-release.iso
compile32: compile_i386:
name: Build i386 name: Build i386
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [buildcompiler, compilegnuefi] needs: [buildcompiler]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Update & Install Required Packages - name: Update & Install Required Packages
run: | run: |
sudo apt-get update sudo apt update
sudo apt-get install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y sudo apt install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y
make --quiet -C tools do_limine make --quiet -C tools do_limine
make --quiet -C Drivers prepare make --quiet -C Drivers prepare
make --quiet -C Userspace prepare make --quiet -C Userspace prepare
make --quiet -C Lynx prepare
make --quiet -C Kernel prepare make --quiet -C Kernel prepare
- name: Cache cross Folder - name: Cache cross Folder
id: cache-cross id: cache-cross
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: tools/cross path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }} key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Cache gnu-efi Folder - name: Configure config.mk
id: cache-gnuefi run: sed -i 's/.*OSARCH = .*/OSARCH = i386/' ./config.mk && cat config.mk | grep OSARCH
uses: actions/cache@v3
with:
path: Lynx/gnu-efi
key: ${{ runner.os }}-gnuefi-${{ hashFiles('Lynx/Makefile') }}
- name: Configure Makefile.conf
run: sed -i 's/.*OSARCH = .*/OSARCH = i386/' ./Makefile.conf && cat Makefile.conf | 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
- name: Upload Artifact (Fennix-debug.iso) - name: Upload Artifact (Fennix-debug.iso)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: Fennix-i386-debug name: Fennix-i386-debug
path: Fennix-debug.iso path: Fennix-debug.iso
- name: Upload Artifact (Fennix-release.iso) - name: Upload Artifact (Fennix-release.iso)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: Fennix-i386-release name: Fennix-i386-release
path: Fennix-release.iso path: Fennix-release.iso
compilearm64: compile_aarch64:
if: ${{ false }} # Disabled until we can get it to work
name: Build aarch64 name: Build aarch64
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [buildcompiler, compilegnuefi] needs: [buildcompiler]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Update & Install Required Packages - name: Update & Install Required Packages
run: | run: |
sudo apt-get update sudo apt update
sudo apt-get install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y sudo apt install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y
make --quiet -C tools do_limine make --quiet -C tools do_limine
make --quiet -C Drivers prepare make --quiet -C Drivers prepare
make --quiet -C Userspace prepare make --quiet -C Userspace prepare
make --quiet -C Lynx prepare
make --quiet -C Kernel prepare make --quiet -C Kernel prepare
- name: Cache cross Folder - name: Cache cross Folder
id: cache-cross id: cache-cross
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: tools/cross path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }} key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Cache gnu-efi Folder - name: Configure config.mk
id: cache-gnuefi run: sed -i 's/.*OSARCH = .*/OSARCH = aarch64/' ./config.mk && cat config.mk | grep OSARCH
uses: actions/cache@v3
with:
path: Lynx/gnu-efi
key: ${{ runner.os }}-gnuefi-${{ hashFiles('Lynx/Makefile') }}
- name: Configure Makefile.conf
run: sed -i 's/.*OSARCH = .*/OSARCH = aarch64/' ./Makefile.conf && cat Makefile.conf | 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
- name: Upload Artifact (Fennix-debug.iso) - name: Upload Artifact (Fennix-debug.iso)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: Fennix-aarch64-debug name: Fennix-aarch64-debug
path: Fennix-debug.iso path: Fennix-debug.iso
- name: Upload Artifact (Fennix-release.iso) - name: Upload Artifact (Fennix-release.iso)
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: Fennix-aarch64-release name: Fennix-aarch64-release
path: Fennix-release.iso path: Fennix-release.iso
compile_arm:
name: Build arm
runs-on: ubuntu-latest
needs: [buildcompiler]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Update & Install Required Packages
run: |
sudo apt update
sudo apt install rustc xorriso mtools genisoimage ovmf nasm doxygen make meson gcc-10 g++-10 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 mingw-w64 -y
make --quiet -C tools do_limine
make --quiet -C Drivers prepare
make --quiet -C Userspace prepare
make --quiet -C Kernel prepare
- name: Cache cross Folder
id: cache-cross
uses: actions/cache@v4
with:
path: tools/cross
key: ${{ runner.os }}-cross-${{ hashFiles('tools/Makefile') }}
- name: Configure config.mk
run: sed -i 's/.*OSARCH = .*/OSARCH = arm/' ./config.mk && cat config.mk | grep OSARCH
- name: Compile Debug and Release ISO
run: |
make build
mv Fennix.iso Fennix-debug.iso
make clean
sed -i 's/.*DEBUG = .*/DEBUG = 0/' ./config.mk && cat config.mk | grep DEBUG
make build
mv Fennix.iso Fennix-release.iso
- name: Upload Artifact (Fennix-debug.iso)
uses: actions/upload-artifact@v4
with:
name: Fennix-arm-debug
path: Fennix-debug.iso
- name: Upload Artifact (Fennix-release.iso)
uses: actions/upload-artifact@v4
with:
name: Fennix-arm-release
path: Fennix-release.iso

7
.gitignore vendored
View File

@ -6,14 +6,16 @@ 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
!tools/*.c !tools/*.c
!tools/*.patch
!tools/*.cpp !tools/*.cpp
!tools/*.cfg !tools/*.cfg
!tools/SSDT1.dat !tools/acpi
!tools/doxygen
!tools/.gdbinit
doxygen-doc doxygen-doc
initrd.tar initrd.tar
.dccache .dccache
@ -28,3 +30,4 @@ initrd.tar
*.so *.so
*.o *.o
*.dmp *.dmp
*.pcap

View File

@ -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:

View File

@ -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
View 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"
},
]
}

10
.vscode/settings.json vendored
View File

@ -1,5 +1,5 @@
{ {
"C_Cpp.errorSquiggles": "Enabled", "C_Cpp.errorSquiggles": "enabled",
"C_Cpp.autocompleteAddParentheses": true, "C_Cpp.autocompleteAddParentheses": true,
"C_Cpp.codeAnalysis.clangTidy.enabled": true, "C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.clang_format_style": "Visual Studio", "C_Cpp.clang_format_style": "Visual Studio",
@ -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
View 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
View 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
View 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, were 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 youre 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 its 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.

View File

@ -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 Lynx 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

View File

@ -1,120 +1,137 @@
{ {
"configurations": [ "configurations": [
{ {
"name": "Fennix x64 (Linux, GCC, debug)", "name": "Fennix x64 (Linux, GCC, debug)",
"includePath": [ "includePath": [
"${workspaceFolder}/include", "${workspaceFolder}/include",
"${workspaceFolder}/include/**" "${workspaceFolder}/include/**"
], ],
"defines": [ "defines": [
"__debug_vscode__", "__debug_vscode__",
"KERNEL_NAME=\"Fennix\"", "KERNEL_NAME=\"Fennix\"",
"KERNEL_VERSION=\"1.0\"", "KERNEL_VERSION=\"1.0\"",
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"", "GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
"GIT_COMMIT_SHORT=\"0000000\"", "GIT_COMMIT_SHORT=\"0000000\"",
"a64", "DEBUG=\"1\""
"DEBUG=\"1\"" ],
], "compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc", "cStandard": "c17",
"cStandard": "c17", "cppStandard": "c++20",
"cppStandard": "c++20", "intelliSenseMode": "gcc-x64",
"intelliSenseMode": "gcc-x64", "configurationProvider": "ms-vscode.makefile-tools",
"configurationProvider": "ms-vscode.makefile-tools", "compilerArgs": [
"compilerArgs": [ // Compiler flags
// Compiler flags "-fPIC",
"-fPIC", "-fPIE",
"-fPIE", "-pie",
"-pie", "-mno-80387",
"-mno-80387", "-mno-mmx",
"-mno-mmx", "-mno-3dnow",
"-mno-3dnow", "-mno-red-zone",
"-mno-red-zone", "-mno-sse",
"-mno-sse", "-mno-sse2",
"-mno-sse2", "-march=x86-64",
"-march=x86-64", "-pipe",
"-pipe", "-ffunction-sections",
"-ffunction-sections", "-msoft-float",
"-msoft-float", "-fno-builtin",
"-fno-builtin", // C++ flags
"-fexceptions",
// C++ flags // Linker flags
"-fexceptions", "-fPIC",
"-fPIE",
// Linker flags "-pie",
"-fPIC", "-Wl,-eDriverEntry",
"-fPIE", "-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment",
"-pie", "-nostdlib",
"-Wl,-eDriverEntry", "-nodefaultlibs",
"-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment", "-nolibc",
"-nostdlib", "-zmax-page-size=0x1000",
"-nodefaultlibs", "-static",
"-nolibc", // VSCode flags
"-zmax-page-size=0x1000", "-ffreestanding",
"-static", "-nostdinc",
"-nostdinc++"
// VSCode flags ]
"-ffreestanding", },
"-nostdinc", {
"-nostdinc++" "name": "Fennix x32 (Linux, GCC, debug)",
] "includePath": [
}, "${workspaceFolder}/include/**"
{ ],
"name": "Fennix x32 (Linux, GCC, debug)", "defines": [
"includePath": [ "__debug_vscode__",
"${workspaceFolder}/include/**" "KERNEL_NAME=\"Fennix\"",
], "KERNEL_VERSION=\"1.0\"",
"defines": [ "GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
"__debug_vscode__", "GIT_COMMIT_SHORT=\"0000000\"",
"KERNEL_NAME=\"Fennix\"", "DEBUG=\"1\""
"KERNEL_VERSION=\"1.0\"", ],
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"", "compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-elf-gcc",
"GIT_COMMIT_SHORT=\"0000000\"", "cStandard": "c17",
"a32", "cppStandard": "c++20",
"DEBUG=\"1\"" "intelliSenseMode": "gcc-x86",
], "configurationProvider": "ms-vscode.makefile-tools",
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-elf-gcc", "compilerArgs": [
"cStandard": "c17", // Compiler flags
"cppStandard": "c++20", "-fPIC",
"intelliSenseMode": "gcc-x86", "-fPIE",
"configurationProvider": "ms-vscode.makefile-tools", "-pie",
"compilerArgs": [ "-mno-80387",
// Compiler flags "-mno-mmx",
"-fPIC", "-mno-3dnow",
"-fPIE", "-mno-red-zone",
"-pie", "-mno-sse",
"-mno-80387", "-mno-sse2",
"-mno-mmx", "-march=i386",
"-mno-3dnow", "-pipe",
"-mno-red-zone", "-ffunction-sections",
"-mno-sse", "-msoft-float",
"-mno-sse2", "-fno-builtin",
"-march=i386", // C++ flags
"-pipe", "-fexceptions",
"-ffunction-sections", // Linker flags
"-msoft-float", "-fPIC",
"-fno-builtin", "-fPIE",
"-pie",
// C++ flags "-Wl,-eDriverEntry",
"-fexceptions", "-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment",
"-nostdlib",
// Linker flags "-nodefaultlibs",
"-fPIC", "-nolibc",
"-fPIE", "-zmax-page-size=0x1000",
"-pie", "-static",
"-Wl,-eDriverEntry", // VSCode flags
"-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment", "-ffreestanding",
"-nostdlib", "-nostdinc",
"-nodefaultlibs", "-nostdinc++"
"-nolibc", ]
"-zmax-page-size=0x1000", },
"-static", {
"name": "Fennix Aarch64 (Linux, GCC, debug)",
// VSCode flags "includePath": [
"-ffreestanding", "${workspaceFolder}/include",
"-nostdinc", "${workspaceFolder}/include/**"
"-nostdinc++" ],
] "defines": [
} "__debug_vscode__",
], "KERNEL_NAME=\"Fennix\"",
"version": 4 "KERNEL_VERSION=\"1.0\"",
"GIT_COMMIT=\"0000000000000000000000000000000000000000\"",
"GIT_COMMIT_SHORT=\"0000000\"",
"DEBUG=\"1\""
],
"compilerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-arm64",
"configurationProvider": "ms-vscode.makefile-tools",
"compilerArgs": [
"-ffreestanding",
"-nostdinc",
"-nostdinc++"
]
}
],
"version": 4
} }

1
Drivers/.vscode/launch.json vendored Symbolic link
View File

@ -0,0 +1 @@
../../.vscode/launch.json

1
Drivers/.vscode/tasks.json vendored Symbolic link
View File

@ -0,0 +1 @@
../../.vscode/tasks.json

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2022, 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.

View File

@ -1,13 +1,60 @@
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
make -C library build make -C library build
ifneq ($(filter amd64 i386,$(OSARCH)),)
make -C audio build make -C audio build
make -C input build make -C input build
make -C misc build make -C misc build
make -C network build make -C network build
make -C storage build make -C storage build
make -C filesystem build make -C filesystem build
endif
prepare: prepare:
$(info Nothing to prepare) $(info Nothing to prepare)
@ -15,9 +62,11 @@ prepare:
clean: clean:
rm -rf out rm -rf out
make -C library clean make -C library clean
ifneq ($(filter amd64 i386,$(OSARCH)),)
make -C audio clean make -C audio clean
make -C input clean make -C input clean
make -C misc clean make -C misc clean
make -C network clean make -C network clean
make -C storage clean make -C storage clean
make -C filesystem clean make -C filesystem clean
endif

View File

@ -1,11 +1 @@
# Drivers # Drivers
Drivers for [Fennix](https://github.com/Fennix-Project/Fennix).
---
Use `Fennix` repo to build the operating system.
```bash
git clone --recurse-submodules https://github.com/Fennix-Project/Fennix.git
```

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 $@ $<

View File

@ -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)

View File

@ -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)

View File

@ -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__

View File

@ -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__

View File

@ -146,10 +146,10 @@ static_assert(sizeof(blkcnt_t) == 8, "blkcnt_t must be 64 bits");
#else #else
static_assert(sizeof(dev_t) == 4, "dev_t must be 32 bits"); static_assert(sizeof(dev_t) == 4, "dev_t must be 32 bits");
static_assert(sizeof(ino_t) == 4, "ino_t must be 32 bits"); static_assert(sizeof(ino_t) == 4, "ino_t must be 32 bits");
static_assert(sizeof(mode_t) == 2, "mode_t must be 16 bits"); static_assert(sizeof(mode_t) == 4, "mode_t must be 32 bits");
static_assert(sizeof(nlink_t) == 2, "nlink_t must be 16 bits"); static_assert(sizeof(nlink_t) == 4, "nlink_t must be 32 bits");
static_assert(sizeof(uid_t) == 2, "uid_t must be 16 bits"); static_assert(sizeof(uid_t) == 4, "uid_t must be 32 bits");
static_assert(sizeof(gid_t) == 2, "gid_t must be 16 bits"); static_assert(sizeof(gid_t) == 4, "gid_t must be 32 bits");
static_assert(sizeof(off_t) == 4, "off_t must be 32 bits"); static_assert(sizeof(off_t) == 4, "off_t must be 32 bits");
static_assert(sizeof(time_t) == 4, "time_t must be 32 bits"); static_assert(sizeof(time_t) == 4, "time_t must be 32 bits");
static_assert(sizeof(blksize_t) == 4, "blksize_t must be 32 bits"); static_assert(sizeof(blksize_t) == 4, "blksize_t must be 32 bits");
@ -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.
*/ */

View File

@ -75,7 +75,7 @@ extern "C"
: "dN"(Port), "a"(Data)); : "dN"(Port), "a"(Data));
} }
static inline uint8_t mmioin8(uint64_t Address) static inline uint8_t mmioin8(uintptr_t Address)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
@ -85,7 +85,7 @@ extern "C"
return Result; return Result;
} }
static inline uint16_t mmioin16(uint64_t Address) static inline uint16_t mmioin16(uintptr_t Address)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
@ -95,7 +95,7 @@ extern "C"
return Result; return Result;
} }
static inline uint32_t mmioin32(uint64_t Address) static inline uint32_t mmioin32(uintptr_t Address)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
@ -105,17 +105,17 @@ extern "C"
return Result; return Result;
} }
static inline uint64_t mmioin64(uint64_t Address) static inline uintptr_t mmioin64(uintptr_t Address)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
uint64_t Result = *(volatile uint64_t *)Address; uintptr_t Result = *(volatile uintptr_t *)Address;
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
return Result; return Result;
} }
static inline void mmioout8(uint64_t Address, uint8_t Data) static inline void mmioout8(uintptr_t Address, uint8_t Data)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
@ -124,7 +124,7 @@ extern "C"
: "memory"); : "memory");
} }
static inline void mmioout16(uint64_t Address, uint16_t Data) static inline void mmioout16(uintptr_t Address, uint16_t Data)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
@ -133,7 +133,7 @@ extern "C"
: "memory"); : "memory");
} }
static inline void mmioout32(uint64_t Address, uint32_t Data) static inline void mmioout32(uintptr_t Address, uint32_t Data)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
@ -142,11 +142,11 @@ extern "C"
: "memory"); : "memory");
} }
static inline void mmioout64(uint64_t Address, uint64_t Data) static inline void mmioout64(uintptr_t Address, uintptr_t Data)
{ {
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
*(volatile uint64_t *)Address = Data; *(volatile uintptr_t *)Address = Data;
__asm__ volatile("" :: __asm__ volatile("" ::
: "memory"); : "memory");
} }
@ -175,10 +175,10 @@ extern "C"
: "memory"); : "memory");
} }
static inline void mmoutq(void *Address, uint64_t Value) static inline void mmoutq(void *Address, uintptr_t Value)
{ {
__asm__ volatile("mov %1, %0" __asm__ volatile("mov %1, %0"
: "=m"((*(uint64_t *)(Address))) : "=m"((*(uintptr_t *)(Address)))
: "r"(Value) : "r"(Value)
: "memory"); : "memory");
} }
@ -213,12 +213,12 @@ extern "C"
return Result; return Result;
} }
static inline uint64_t mminq(void *Address) static inline uintptr_t mminq(void *Address)
{ {
uint64_t Result; uintptr_t Result;
__asm__ volatile("mov %1, %0" __asm__ volatile("mov %1, %0"
: "=r"(Result) : "=r"(Result)
: "m"((*(uint64_t *)(Address))) : "m"((*(uintptr_t *)(Address)))
: "memory"); : "memory");
return Result; return Result;
} }

View File

@ -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

View File

@ -71,7 +71,7 @@ typedef uint32_t uid_t;
typedef uint32_t gid_t; typedef uint32_t gid_t;
typedef int64_t clock_t; typedef int64_t clock_t;
typedef int32_t pid_t; typedef int32_t pid_t;
#elif defined(__LP32__) #else
typedef int32_t off_t; typedef int32_t off_t;
typedef long long off64_t; typedef long long off64_t;
typedef __INT32_TYPE__ mode_t; typedef __INT32_TYPE__ mode_t;

View File

@ -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)

View File

@ -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)

View File

@ -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,15 @@ 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 -std=c++20 -I$(INCLUDE_DIR)
ifeq ($(OSARCH), amd64)
CRT_CFLAGS += -mno-red-zone
else ifeq ($(OSARCH), i386)
CRT_CFLAGS += -mno-red-zone
else ifeq ($(OSARCH), aarch64)
CRT_CFLAGS +=
endif
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fstack-usage
@ -60,12 +61,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 +74,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 $<)

View File

@ -73,7 +73,11 @@ DefineFunction(void, KernelPrint, const char *format, ...)
{ {
__builtin_va_list args; __builtin_va_list args;
__builtin_va_start(args, format); __builtin_va_start(args, format);
#if defined(__amd64__) || defined(__i386__)
__KernelPrint(DriverID, (long)format, (long)args); __KernelPrint(DriverID, (long)format, (long)args);
#elif defined(__aarch64__)
__KernelPrint(DriverID, (long)format, (long)__builtin_va_arg(args, void *));
#endif
__builtin_va_end(args); __builtin_va_end(args);
} }
@ -81,7 +85,11 @@ DefineFunction(void, KernelLog, const char *format, ...)
{ {
__builtin_va_list args; __builtin_va_list args;
__builtin_va_start(args, format); __builtin_va_start(args, format);
#if defined(__amd64__) || defined(__i386__)
__KernelLog(DriverID, (long)format, (long)args); __KernelLog(DriverID, (long)format, (long)args);
#elif defined(__aarch64__)
__KernelLog(DriverID, (long)format, (long)__builtin_va_arg(args, void *));
#endif
__builtin_va_end(args); __builtin_va_end(args);
} }

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -107,6 +107,8 @@ typedef struct
#define MESSAGE_RECV_PAYLOAD ToMsg(MSG_RECVPAYLOAD) #define MESSAGE_RECV_PAYLOAD ToMsg(MSG_RECVPAYLOAD)
#define MESSAGE_RECV_STATUS ToMsg(MSG_RECVSTATUS) #define MESSAGE_RECV_STATUS ToMsg(MSG_RECVSTATUS)
#if defined(__amd64__)
#define VM_PORT(cmd, in_ebx, isi, idi, \ #define VM_PORT(cmd, in_ebx, isi, idi, \
flags, magic, \ flags, magic, \
ax, bx, cx, dx, si, di) \ ax, bx, cx, dx, si, di) \
@ -169,6 +171,23 @@ typedef struct
"D"(idi), \ "D"(idi), \
"r"(bp) : "memory", "cc") "r"(bp) : "memory", "cc")
#elif defined(__i386__)
#define VM_PORT(cmd, in_ebx, isi, idi, \
flags, magic, \
ax, bx, cx, dx, si, di)
#define VM_PORT_HB_OUT(cmd, in_ecx, isi, idi, \
flags, \
magic, bp, ax, \
bx, cx, dx, si, di)
#define VM_PORT_HB_IN(cmd, in_ecx, isi, idi, \
flags, magic, bp, \
ax, bx, cx, dx, si, di)
#endif
/* TODO: /* TODO:
- use vmcall or vmmcall instead of "out" and "in" if available - use vmcall or vmmcall instead of "out" and "in" if available
*/ */

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -5,108 +5,11 @@
} }
], ],
"settings": { "settings": {
"terminal.integrated.cwd": "../",
"debug.allowBreakpointsEverywhere": true, "debug.allowBreakpointsEverywhere": true,
"cSpell.words": [ "git.alwaysSignOff": true,
"ABAR", "git.defaultBranchName": "master",
"ABSPOINTER", "git.openRepositoryInParentFolders": "always",
"AHCI", "C_Cpp.autoAddFileAssociations": false
"BIST",
"Cardbus",
"CFIEN",
"cmdret",
"cmpb",
"driverinfo",
"ECTRL",
"EEPROM",
"Fennix",
"GETVERSION",
"HBAPRDT",
"IFCS",
"inportb",
"inportl",
"inportw",
"INTX",
"KAPI",
"LEDS",
"LPBK",
"LSTA",
"mminb",
"mminl",
"mminq",
"mminw",
"mmioin",
"mmioout",
"mmoutb",
"mmoutl",
"mmoutw",
"NABM",
"NABMB",
"NABMBOFF",
"outportb",
"outportl",
"outportw",
"PCIBAR",
"PCMOUT",
"PCNET",
"PCTRL",
"PMCF",
"PORTHB",
"PRDT",
"Prefetchable",
"RCTL",
"RCTRL",
"RDMTS",
"RDTR",
"rpci",
"RSRPD",
"RTCL",
"RTLC",
"RTLIB",
"RTLIL",
"RTLIW",
"RTLOB",
"RTLOL",
"RTLOW",
"RXDCTL",
"RXDESCHEAD",
"RXDESCHI",
"RXDESCLEN",
"RXDESCLO",
"RXDESCTAIL",
"Sata",
"SATAPI",
"SECRC",
"SEMB",
"SWXOFF",
"tclo",
"TCTL",
"TCTRL",
"TFES",
"TIPG",
"TSAD",
"TSTA",
"TXDESCHEAD",
"TXDESCHI",
"TXDESCLEN",
"TXDESCLO",
"TXDESCTAIL",
"TYPEMATIC",
"ubit",
"Virtio",
"Wmissing"
],
"files.associations": {
"*.su": "tsv",
"driver.h": "c",
"base.h": "c",
"types.h": "c",
"syscall.h": "c",
"aip.h": "c",
"input.h": "c",
"errno.h": "c",
"io.h": "c",
"rtl8139.hpp": "c",
"net.h": "c"
}
} }
} }

View File

@ -5,513 +5,8 @@
} }
], ],
"settings": { "settings": {
"terminal.integrated.cwd": "../",
"debug.allowBreakpointsEverywhere": true, "debug.allowBreakpointsEverywhere": true,
"files.associations": {
"*.su": "tsv",
"thread": "cpp",
"bitset": "cpp",
"initializer_list": "cpp",
"semaphore": "cpp",
"memory": "cpp",
"limits": "cpp",
"climits": "cpp",
"iterator": "cpp",
"ranges": "cpp",
"cassert": "cpp",
"concepts": "cpp",
"cctype": "cpp",
"tuple": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"coroutine": "cpp",
"static_vector": "cpp",
"string_view": "cpp",
"compare": "cpp",
"limine.h": "c",
"types.h": "c",
"binfo.h": "c",
"liballoc_1_1.h": "c",
"cstring": "cpp",
"cargs.h": "c",
"memory.hpp": "c",
"convert.h": "c",
"limits.h": "c",
"assert.h": "c",
"cwalk.h": "c",
"md5.h": "c",
"stdint.h": "c",
"debug.h": "c",
"ubsan.h": "c",
"kernel.h": "c",
"filesystem.hpp": "c",
"vector.hpp": "c",
"string.hpp": "c",
"nc.hpp": "c",
"vector": "c",
"task.hpp": "c",
"recovery.hpp": "c",
"symbols.hpp": "c",
"cstddef": "cpp",
"atomic.hpp": "c",
"atomic": "cpp",
"syscalls.h": "c",
"cmath": "cpp",
"typeinfo": "c",
"exception": "cpp",
"errno.h": "c",
"float.h": "c",
"mutex": "cpp",
"type_trails": "cpp",
"utility": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"stdio.h": "c",
"string": "cpp",
"list": "cpp",
"stdexcept": "cpp",
"unistd.h": "c",
"unordered_map": "cpp",
"sched.h": "c",
"mman.h": "c",
"string.h": "c",
"macro.hpp": "c",
"stddef.h": "c",
"cfloat": "c",
"type_traits": "cpp",
"stdlib.h": "c",
"new": "cpp",
"ostream": "cpp",
"iostream": "cpp",
"istream": "cpp",
"ios": "cpp",
"locale": "cpp",
"unwind.h": "c",
"memory.h": "c",
"physical.hpp": "c",
"swap_pt.hpp": "c",
"brk.hpp": "c",
"bitmap.hpp": "c",
"lock.hpp": "c",
"virtual.hpp": "c",
"table.hpp": "c",
"vma.hpp": "c",
"abi.h": "c",
"kstack.hpp": "c",
"stack.hpp": "c",
"optional": "cpp"
},
"cSpell.words": [
"AABBCC",
"AAFF",
"AAFFAA",
"ABAR",
"ABIVERSION",
"ABSPOINTER",
"ACPI",
"ACPINVS",
"addralign",
"AEFF",
"AFAFAF",
"AHBA",
"AHCI",
"ALTLBA",
"APERF",
"apic",
"APICID",
"archaux",
"AROS",
"ARRAYSZ",
"auxv",
"BABABA",
"BADRAM",
"BGRT",
"bimi",
"binfo",
"biosdev",
"BIST",
"BITALG",
"BLOCKDEV",
"BLOCKDEVICE",
"BNDCFGS",
"bochs",
"bootanim",
"bootdev",
"Bootloader",
"brontobyte",
"CACACA",
"calloc",
"Cardbus",
"CCCCCCCPU",
"CHARDEV",
"CHARDEVICE",
"charsize",
"clac",
"CLOUDABI",
"CMCI",
"CMOS",
"cntvct",
"COMNULL",
"copydoc",
"cpudata",
"CPUID",
"crashdata",
"CSTAR",
"CTLS",
"cutlim",
"DADADA",
"daif",
"daifclr",
"daifset",
"DAPI",
"DBGP",
"DEBUGCTL",
"defragment",
"dfdesc",
"dialup",
"Didx",
"DLAB",
"Drivermemcpy",
"Drivermemset",
"Driversprintf",
"drvdir",
"DRVER",
"DSDT",
"DUID",
"dynstr",
"dynsym",
"EBDA",
"edid",
"EEPROM",
"EFER",
"Ehdr",
"ehsize",
"EISA",
"ELFABI",
"ELFCLASS",
"ELFDATA",
"ELFMAG",
"ELFOSABI",
"EMMINTRIN",
"endregion",
"Ensoniq",
"EVTSEL",
"EXECFN",
"exobyte",
"EXTD",
"FADT",
"FAFAFA",
"FAFAFAI",
"Fargc",
"Fargv",
"fcreat",
"fctprintf",
"Femto",
"FENIXOS",
"FENNIX",
"FFAA",
"FFAAAA",
"FFSMBIOS",
"FFXSR",
"filestatus",
"FMAPS",
"fonthdr",
"Framebuffer",
"FSGSBASE",
"fsmi",
"fxrstor",
"fxsave",
"Gamepad",
"Gameport",
"geopbyte",
"GETVERSION",
"GFNI",
"haddpd",
"headersize",
"HIPROC",
"HPET",
"hwaddress",
"ICRHI",
"ICRLO",
"IDIV",
"idtd",
"IFHLNK",
"infloop",
"inportb",
"inportl",
"inportw",
"INTFASTX",
"INTLEASTX",
"INTX",
"invlpg",
"ioapic",
"ioapicirq",
"IOCTLFS",
"IPCID",
"IRET",
"iretq",
"isdelim",
"ishld",
"ishst",
"itimerspec",
"itrfb",
"JMPREL",
"KAPI",
"KAPIPCI",
"kcalloc",
"kcon",
"kdentry",
"kdirent",
"kernelctl",
"kfree",
"klog",
"kmalloc",
"kproc",
"krealloc",
"kthrd",
"lapic",
"lfanew",
"LFLR",
"lgdt",
"liballoc",
"LIBLIST",
"lidt",
"limine",
"LMSLE",
"LOPROC",
"lsacpi",
"LSTAR",
"MADT",
"MADTIO",
"malloc",
"MCFG",
"memdbg",
"memmap",
"memsz",
"MEMTEST",
"mfence",
"MIDR",
"mminb",
"mminl",
"mminq",
"mminw",
"mmioin",
"mmioout",
"mmoutb",
"mmoutl",
"mmoutq",
"mmoutw",
"modbg",
"Modulememcpy",
"Modulememset",
"Modulesprintf",
"movaps",
"movddup",
"movdqa",
"movdqu",
"movntdq",
"movntdqa",
"movw",
"MPERF",
"MSRID",
"MTRR",
"MTRRCAP",
"multiboot",
"MWAIT",
"newfstatat",
"NIDENT",
"NOBITS",
"nullfd",
"nullptr",
"objptr",
"OEMID",
"Ofast",
"okstat",
"oldfd",
"OPENVOS",
"OPTMZ",
"OSABI",
"OSFXSR",
"OSXMMEXCPT",
"OSXSAVE",
"Outof",
"outportb",
"outportl",
"outportw",
"PAGESZ",
"palignr",
"PCIDE",
"pcmpistri",
"PCNET",
"PDBR",
"PDPTE",
"PEBS",
"PERFEVTSEL",
"PEXIT",
"PFLA",
"Phdrs",
"pheader",
"PHENT",
"phentsize",
"phnum",
"phoff",
"PHYSBASE",
"PHYSMASK",
"Pico",
"PINBASED",
"Pipefd",
"PKRU",
"PLTGOT",
"PLTREL",
"PLTRELSZ",
"POPCNT",
"PORTHB",
"powerline",
"Prefetchable",
"PREINIT",
"PROCBASED",
"PROGBITS",
"PTMX",
"ptys",
"pushfl",
"pushfq",
"Raphson",
"RARP",
"RBSTART",
"rdmsr",
"RDRAND",
"rdseed",
"rdtsc",
"readcr",
"readxcr",
"realloc",
"Realtek",
"RELAENT",
"RELASZ",
"RELSZ",
"Rodata",
"RPCI",
"rpmalloc",
"RRGGBB",
"RSDP",
"RSDT",
"RTIT",
"SATA",
"schedbg",
"SERCOS",
"serialports",
"sfence",
"sgdt",
"SGXLEPUBKEYHASH",
"Shdr",
"Sheader",
"shentsize",
"shnum",
"shoff",
"showbuf",
"shstrndx",
"shstrtab",
"sidt",
"SIGCOMP",
"sigsetsize",
"SIVR",
"SMAP",
"SMBASE",
"SMBIOSBIOS",
"SMEP",
"SMRR",
"SMXE",
"SNTP",
"SRAT",
"SSDT",
"sspt",
"SSSE",
"stac",
"strdbg",
"STRSZ",
"SVME",
"swapgs",
"Symbios",
"SYMENT",
"SYSENTER",
"sysret",
"sysretq",
"Tamsyn",
"targp",
"TCCR",
"TCLO",
"TCPA",
"TDCR",
"TEXIT",
"TEXTREL",
"Thrd",
"TICR",
"tlbi",
"Touchpad",
"tracepagetable",
"tskdbg",
"ttbr",
"uarch",
"uartmemdmp",
"ubsan",
"UINTFASTX",
"UINTLEASTX",
"UINTX",
"ultoa",
"UMIP",
"UMWAIT",
"UNMAP",
"Unmaskable",
"Unreserving",
"unseek",
"Unswap",
"unsynchronized",
"UPDT",
"UPID",
"uroot",
"UTID",
"VAES",
"VBMI",
"vectorize",
"vfctprintf",
"vfsdbg",
"Vidx",
"Virtio",
"VMCS",
"VMFUNC",
"vmouse",
"VMXE",
"VNNI",
"VNNIW",
"VPCLMULQDQ",
"VPID",
"VPOKE",
"VPOPCNTDQ",
"WAET",
"weakrefalias",
"Wignored",
"Wmissing",
"writecr",
"writexcr",
"wrmsr",
"WWVB",
"WWVH",
"Xalloc",
"xallocv",
"Xclac",
"xgetbv",
"Xmemcpy",
"Xmemset",
"XSDT",
"Xsize",
"XSLC",
"XSLF",
"XSLM",
"XSLR",
"Xstac",
"Xuintptr",
"yottabyte",
"zettabyte"
],
"editor.tabCompletion": "on", "editor.tabCompletion": "on",
"diffEditor.codeLens": true, "diffEditor.codeLens": true,
"editor.quickSuggestionsDelay": 100, "editor.quickSuggestionsDelay": 100,
@ -527,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
} }
} }

View File

@ -1,22 +0,0 @@
{
"folders": [
{
"path": "./Lynx"
}
],
"settings": {
"debug.allowBreakpointsEverywhere": true,
"files.associations": {
"*.su": "tsv",
"limine.h": "c"
},
"cSpell.words": [
"Bootloader",
"COMNULL",
"CPUID",
"FENNIX",
"JMPREL",
"UBSAN"
]
}
}

View File

@ -5,67 +5,11 @@
} }
], ],
"settings": { "settings": {
"terminal.integrated.cwd": "../",
"debug.allowBreakpointsEverywhere": true, "debug.allowBreakpointsEverywhere": true,
"files.associations": { "git.alwaysSignOff": true,
"*.su": "tsv", "git.defaultBranchName": "master",
"thread": "cpp", "git.openRepositoryInParentFolders": "always",
"bitset": "cpp", "C_Cpp.autoAddFileAssociations": false
"initializer_list": "cpp",
"fex.hpp": "c",
"types.h": "c",
"dlfcn.h": "c",
"aux.h": "c",
"stddef.h": "c",
"stdio.h": "c",
"syscalls.h": "c",
"syslib.h": "c",
"sysfile.h": "c",
"ipc.h": "c",
"sysbase.h": "c",
"inttypes.h": "c",
"doomkeys.h": "c",
"doomgeneric.h": "c",
"elf.h": "c",
"init.h": "c",
"unused_code": "cpp",
"liballoc_1_1.h": "c",
"errno.h": "c",
"stdlib.h": "c",
"stdarg.h": "c",
"printf.h": "c",
"ctype.h": "c",
"unistd.h": "c",
"stat.h": "c",
"wait.h": "c",
"base.h": "c",
"ld.h": "c",
"syscall.h": "c",
"stdint.h": "c",
"setjmp.h": "c",
"limits.h": "c",
"fcntl.h": "c",
"pty.h": "c",
"string.h": "c",
"time.h": "c",
"reboot.h": "c",
"*.in": "c",
"signal.h": "c",
"alltypes.h": "c",
"pr44328.C": "cpp"
},
"cSpell.words": [
"auxv",
"cmpq",
"FENNIX",
"JMPREL",
"Krnl",
"liballoc",
"libinit",
"oldpath",
"preinit",
"Shdr",
"vfctprintf",
"WAITSTATUS"
]
} }
} }

View 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
}
}

View File

@ -6,30 +6,9 @@
], ],
"settings": { "settings": {
"debug.allowBreakpointsEverywhere": true, "debug.allowBreakpointsEverywhere": true,
"files.associations": { "git.alwaysSignOff": true,
"*.su": "tsv", "git.defaultBranchName": "master",
"thread": "cpp", "git.openRepositoryInParentFolders": "always",
"bitset": "cpp", "C_Cpp.autoAddFileAssociations": false
"initializer_list": "cpp",
"semaphore": "cpp",
"memory": "cpp",
"limits": "cpp",
"climits": "cpp",
"iterator": "cpp",
"ranges": "cpp",
"cassert": "cpp",
"concepts": "cpp",
"cctype": "cpp",
"tuple": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"coroutine": "cpp",
"static_vector": "cpp",
"string_view": "cpp",
"compare": "cpp",
"ostream": "cpp",
"unordered_map": "cpp",
"vector": "cpp"
}
} }
} }

View File

@ -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

View File

@ -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",
], ],

View File

@ -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",
@ -141,6 +137,33 @@
"-nostdinc++" "-nostdinc++"
] ]
}, },
{
"name": "Fennix Arm (Linux, GCC, debug)",
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/include/**",
"${workspaceFolder}/include_std",
"${workspaceFolder}/include_std/**",
"${workspaceFolder}/arch/aarch64/include"
],
"forcedInclude": [
"${workspaceFolder}/.vscode/preinclude.h"
],
"defines": [
"DEBUG=\"1\""
],
"compilerPath": "${workspaceFolder}/../tools/cross/bin/arm-fennix-gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-arm",
"configurationProvider": "ms-vscode.makefile-tools",
"compilerArgs": [
// VSCode flags
"-ffreestanding",
"-nostdinc",
"-nostdinc++"
]
},
{ {
"name": "Fennix Aarch64 (Linux, GCC, debug)", "name": "Fennix Aarch64 (Linux, GCC, debug)",
"includePath": [ "includePath": [
@ -154,7 +177,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",
@ -163,38 +185,6 @@
"intelliSenseMode": "linux-gcc-arm64", "intelliSenseMode": "linux-gcc-arm64",
"configurationProvider": "ms-vscode.makefile-tools", "configurationProvider": "ms-vscode.makefile-tools",
"compilerArgs": [ "compilerArgs": [
// Compiler flags
"-pipe",
"-fno-builtin",
"-msoft-float",
"-fPIC",
"-Wstack-protector",
"-fcoroutines",
// Warnings
"-Wall",
"-Wextra",
"-Wfloat-equal",
"-Wpointer-arith",
"-Wcast-align",
"-Wredundant-decls",
"-Winit-self",
"-Wswitch-default",
"-Wstrict-overflow=5",
"-Wconversion",
// C++ flags
"-fno-rtti",
"-fno-exceptions",
// Linker flags
"-T${workspaceFolder}/arch/aarch64/linker.ld",
"-fPIC",
// Debug flags
"-ggdb3",
"-O0",
"-fdiagnostics-color=always",
"-fverbose-asm",
"-fstack-usage",
"-fstack-check",
"-fsanitize=undefined",
// VSCode flags // VSCode flags
"-ffreestanding", "-ffreestanding",
"-nostdinc", "-nostdinc",

View File

@ -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"
]
}

View File

@ -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
View File

@ -0,0 +1 @@
../../.vscode/launch.json

View File

@ -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
View File

@ -0,0 +1 @@
../../.vscode/tasks.json

File diff suppressed because it is too large Load Diff

View File

@ -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.

View File

@ -1,54 +1,30 @@
# 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') define find-sources
PSF_SOURCES = $(shell find ./ -type f -name '*.psf') $(shell find ./ -type f -name '$1' $(shell echo $(foreach arch,$(filter-out $(OSARCH),$(AVAILABLE_ARCHS)), -not -path \"./arch/$(arch)/*\")) -print0 | xargs -0)
ifeq ($(OSARCH), amd64) endef
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/*")
CPP_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)
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/*")
CPP_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)
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/*")
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
HEADERS += $(sort $(dir $(wildcard ./arch/aarch64/include/*)))
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 BMP_SOURCES := $(call find-sources,*.bmp)
PSF_SOURCES := $(call find-sources,*.psf)
S_SOURCES := $(call find-sources,*.S)
s_SOURCES := $(call find-sources,*.s)
C_SOURCES := $(call find-sources,*.c)
CXX_SOURCES := $(call find-sources,*.cpp)
OBJ = $(BMP_SOURCES:.bmp=.o) $(PSF_SOURCES:.psf=.o) $(s_SOURCES:.s=.o) $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o)
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
@ -56,7 +32,9 @@ WARNCFLAG = -Wall -Wextra \
-Wfloat-equal -Wpointer-arith -Wcast-align \ -Wfloat-equal -Wpointer-arith -Wcast-align \
-Wredundant-decls -Winit-self -Wswitch-default \ -Wredundant-decls -Winit-self -Wswitch-default \
-Wstrict-overflow=5 -Wno-error=cpp -Werror \ -Wstrict-overflow=5 -Wno-error=cpp -Werror \
-Wno-unused-parameter -Wno-unused-parameter -Wno-error=format
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 := \
@ -66,40 +44,23 @@ 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 -fno-builtin
ifeq ($(OSARCH), amd64) ifeq ($(OSARCH), amd64)
CFLAGS += -march=core2 -mcmodel=kernel -m64 -mno-red-zone
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 -mno-red-zone
CFLAGS += -fno-pic -fno-pie -mno-red-zone -march=pentium \ LDFLAGS += -Tarch/i386/linker.ld
-fno-builtin -Da32 -Da86 -m32 else ifeq ($(OSARCH), arm)
CFLAG_STACK_PROTECTOR := -fstack-protector-all CFLAGS += -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16
LDFLAGS += -Tarch/i386/linker.ld \ LDFLAGS += -Tarch/arm/linker.ld
-fno-pic -fno-pie \ WARNCFLAG += -w
-Wl,-static,--no-dynamic-linker,-ztext \
-zmax-page-size=0x1000 \
-Wl,-Map kernel.map
else ifeq ($(OSARCH), aarch64) else ifeq ($(OSARCH), aarch64)
CFLAGS += -march=armv9.4-a -mtune=cortex-a72 -mlittle-endian -mcmodel=large
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 +70,20 @@ 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) ifeq ($(OSARCH), arm)
CFLAGS += -fstack-check CFLAGS += -fstack-check -fverbose-asm
endif endif # arm
ifeq ($(OSARCH), aarch64)
CFLAGS += -fstack-check -fverbose-asm
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 +95,55 @@ 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), arm)
$(__CONF_OBJCOPY) -O elf32-littlearm -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), arm)
$(__CONF_OBJCOPY) -O elf32-littlearm -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)

View File

@ -1,11 +1,3 @@
# Kernel # Kernel
The core of the operating system. The core of the operating system.
---
Use `Fennix` repo to build the operating system.
```bash
git clone --recurse-submodules https://github.com/Fennix-Project/Fennix.git
```

View File

@ -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.

View File

@ -0,0 +1,46 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <display.hpp>
#include <bitmap.hpp>
#include <convert.h>
#include <printf.h>
#include <lock.hpp>
#include <rand.hpp>
#include <uart.hpp>
#include <debug.h>
#include <smp.hpp>
#include <cpu.hpp>
#include <io.h>
#if defined(__amd64__)
#include "../../arch/amd64/cpu/gdt.hpp"
#include "../arch/amd64/cpu/apic.hpp"
#elif defined(__i386__)
#include "../../arch/i386/cpu/gdt.hpp"
#include "../arch/i386/cpu/apic.hpp"
#elif defined(__aarch64__)
#endif
#include "../../../../kernel.h"
extern void ExPrint(const char *Format, ...);
arch nsa void DisplayDetailsScreen(CPU::ExceptionFrame *Frame)
{
ExPrint("\nException Frame:\n");
}

View File

@ -85,6 +85,5 @@ SECTIONS
/DISCARD/ : /DISCARD/ :
{ {
*(.comment*) *(.comment*)
*(.note*)
} }
} }

View File

@ -0,0 +1,97 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include "acpi.hpp"
#include <memory.hpp>
#include <debug.h>
#include "../../kernel.h"
namespace ACPI
{
MADT::MADT(ACPI::MADTHeader *madt)
{
trace("Initializing MADT");
if (!madt)
{
error("MADT is NULL");
return;
}
CPUCores = 0;
LAPICAddress = (LAPIC *)(uintptr_t)madt->LocalControllerAddress;
for (uint8_t *ptr = (uint8_t *)(madt->Entries);
(uintptr_t)(ptr) < (uintptr_t)(madt) + madt->Header.Length;
ptr += *(ptr + 1))
{
switch (*(ptr))
{
case 0:
{
if (ptr[4] & 1)
{
lapic.push_back((LocalAPIC *)ptr);
KPrint("Local APIC %d (APIC %d) found.", lapic.back()->ACPIProcessorId, lapic.back()->APICId);
CPUCores++;
}
break;
}
case 1:
{
ioapic.push_back((MADTIOApic *)ptr);
KPrint("I/O APIC %d (Address %#lx) found.", ioapic.back()->APICID, ioapic.back()->Address);
Memory::Virtual(KernelPageTable).Map((void *)(uintptr_t)ioapic.back()->Address, (void *)(uintptr_t)ioapic.back()->Address, Memory::PTFlag::RW | Memory::PTFlag::PCD); // Make sure that the address is mapped.
break;
}
case 2:
{
iso.push_back((MADTIso *)ptr);
KPrint("ISO (IRQ:%#lx, BUS:%#lx, GSI:%#lx, %s/%s) found.",
iso.back()->IRQSource, iso.back()->BuSSource, iso.back()->GSI,
iso.back()->Flags & 0x00000004 ? "Active High" : "Active Low",
iso.back()->Flags & 0x00000100 ? "Edge Triggered" : "Level Triggered");
break;
}
case 4:
{
nmi.push_back((MADTNmi *)ptr);
KPrint("NMI %#lx (lint:%#lx) found.", nmi.back()->processor, nmi.back()->lint);
break;
}
case 5:
{
LAPICAddress = (LAPIC *)ptr;
KPrint("APIC found at %#lx", LAPICAddress);
break;
}
default:
{
KPrint("Unknown MADT entry %#lx", *(ptr));
break;
}
}
Memory::Virtual(KernelPageTable).Map((void *)LAPICAddress, (void *)LAPICAddress, Memory::PTFlag::RW | Memory::PTFlag::PCD); // I should map more than one page?
}
CPUCores--; // We start at 0 (BSP) and end at 11 (APs), so we have 12 cores.
KPrint("Total CPU cores: %d", CPUCores + 1);
}
MADT::~MADT()
{
}
}

View File

@ -24,17 +24,46 @@ namespace Memory
{ {
bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type) bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type)
{ {
#warning "aarch64 not implemented"
return 0;
} }
void *Virtual::GetPhysical(void *VirtualAddress) void *Virtual::GetPhysical(void *VirtualAddress)
{ {
#warning "aarch64 not implemented"
return nullptr;
}
Virtual::MapType Virtual::GetMapType(void *VirtualAddress)
{
#warning "aarch64 not implemented"
return MapType::NoMapType;
}
PageDirectoryEntry *Virtual::GetPDE(void *VirtualAddress, MapType Type)
{
#warning "aarch64 not implemented"
return nullptr;
}
PageTableEntry *Virtual::GetPTE(void *VirtualAddress, MapType Type)
{
#warning "aarch64 not implemented"
return nullptr;
} }
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type) void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
{ {
#warning "aarch64 not implemented"
} }
void Virtual::Unmap(void *VirtualAddress, MapType Type) void Virtual::Unmap(void *VirtualAddress, MapType Type)
{ {
#warning "aarch64 not implemented"
}
void Virtual::Remap(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
{
#warning "aarch64 not implemented"
} }
} }

View File

@ -19,9 +19,8 @@
#include <cpu.hpp> #include <cpu.hpp>
extern "C" __naked __used __no_stack_protector void SystemCallHandlerStub() extern "C" __used __no_stack_protector void SystemCallHandlerStub()
{ {
} }
extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs); extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs);

View File

@ -0,0 +1,38 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <signal.hpp>
#include <dumper.hpp>
#include <task.hpp>
#include <errno.h>
/* subsystem/linux/syscall.cpp */
extern int ConvertSignalToLinux(signal_t sig);
namespace Tasking
{
bool Signal::HandleSignal(CPU::SchedulerFrame *tf, void *thread)
{
#warning "aarch64 not implemented"
return false;
}
void Signal::RestoreHandleSignal(SyscallsFrame *sf, void *thread)
{
#warning "aarch64 not implemented"
}
}

View File

@ -0,0 +1,28 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
.global _sig_native_trampoline_start
_sig_native_trampoline_start:
.global _sig_native_trampoline_end
_sig_native_trampoline_end:
.global _sig_linux_trampoline_start
_sig_linux_trampoline_start:
.global _sig_linux_trampoline_end
_sig_linux_trampoline_end:

View File

@ -0,0 +1,134 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <display.hpp>
#include <bitmap.hpp>
#include <convert.h>
#include <printf.h>
#include <lock.hpp>
#include <rand.hpp>
#include <uart.hpp>
#include <debug.h>
#include <smp.hpp>
#include <cpu.hpp>
#include <io.h>
#include "../../cpu/gdt.hpp"
#include "../../cpu/apic.hpp"
#include "../../../../kernel.h"
extern void ExPrint(const char *Format, ...);
static const char *x86PageFaultDescriptions[9] = {
"Supervisor tried to read a non-present page entry\n",
"Supervisor tried to read a page and caused a protection fault\n",
"Supervisor tried to write to a non-present page entry\n",
"Supervisor tried to write a page and caused a protection fault\n",
"User tried to read a non-present page entry\n",
"User tried to read a page and caused a protection fault\n",
"User tried to write to a non-present page entry\n",
"User tried to write a page and caused a protection fault\n",
"One or more page directory entries contain reserved bits which are set to 1.\n"};
arch nsa void DisplayDetailsScreen(CPU::ExceptionFrame *Frame)
{
ExPrint("\nException Frame:\n");
ExPrint(" General Purpose Registers:\n");
ExPrint(" RAX: %#lx RBX: %#lx RCX: %#lx RDX: %#lx\n",
Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx);
ExPrint(" RSI: %#lx RDI: %#lx R8: %#lx R9: %#lx\n",
Frame->rsi, Frame->rdi, Frame->r8, Frame->r9);
ExPrint(" R10: %#lx R11: %#lx R12: %#lx R13: %#lx\n",
Frame->r10, Frame->r11, Frame->r12, Frame->r13);
ExPrint(" R14: %#lx R15: %#lx\n", Frame->r14, Frame->r15);
ExPrint(" Control Registers:\n");
ExPrint(" CR0: %#lx CR2: %#lx CR3: %#lx CR4: %#lx\n",
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4);
ExPrint(" CR8: %#lx\n", Frame->cr8);
ExPrint(" Segment Registers:\n");
ExPrint(" CS: %#lx SS: %#lx DS: %#lx ES: %#lx FS: %#lx GS: %#lx\n",
Frame->cs, Frame->ss, Frame->ds, Frame->es, Frame->fs, Frame->gs);
ExPrint(" Debug Registers:\n");
ExPrint(" DR0: %#lx DR1: %#lx DR2: %#lx DR3: %#lx\n",
Frame->dr0, Frame->dr1, Frame->dr2, Frame->dr3);
ExPrint(" DR6: %#lx DR7: %#lx\n", Frame->dr6, Frame->dr7);
ExPrint(" Other:\n");
ExPrint(" INT: %#lx ERR: %#lx RIP: %#lx RFLAGS: %#lx\n",
Frame->InterruptNumber, Frame->ErrorCode,
Frame->rip, Frame->rflags.raw);
ExPrint(" RSP: %#lx RBP: %#lx\n",
Frame->rsp, Frame->rbp);
ExPrint("Exception Details:\n");
switch (Frame->InterruptNumber)
{
case CPU::x86::PageFault:
{
CPU::x64::PageFaultErrorCode pfCode = {.raw = (uint32_t)Frame->ErrorCode};
ExPrint("PFEC: P:%d W:%d U:%d R:%d I:%d PK:%d SS:%d SGX:%d\n",
pfCode.P, pfCode.W, pfCode.U, pfCode.R,
pfCode.I, pfCode.PK, pfCode.SS, pfCode.SGX);
{
Memory::Virtual vmm((Memory::PageTable *)Frame->cr3);
if (vmm.GetMapType((void *)Frame->cr2) != Memory::Virtual::FourKiB)
ExPrint("Can't display page %#lx\n", Frame->cr2);
else
{
Memory::PageTableEntry *pte = vmm.GetPTE((void *)Frame->cr2);
ExPrint("Page %#lx: P:%d W:%d U:%d G:%d CoW:%d KRsv:%d NX:%d\n",
ALIGN_DOWN(Frame->cr2, 0x1000), pte->Present, pte->ReadWrite,
pte->UserSupervisor, pte->Global, pte->CopyOnWrite,
pte->KernelReserve, pte->ExecuteDisable);
}
}
ExPrint("%s", x86PageFaultDescriptions[Frame->ErrorCode & 0b111]);
if (Frame->ErrorCode & 0x8)
ExPrint("%s", x86PageFaultDescriptions[8]);
break;
}
case CPU::x86::StackSegmentFault:
case CPU::x86::GeneralProtectionFault:
{
CPU::x64::SelectorErrorCode sCode = {.raw = Frame->ErrorCode};
ExPrint("Kernel performed an illegal operation.\n");
ExPrint("External: %d\n", sCode.External);
ExPrint("Table: %d\n", sCode.Table);
ExPrint("Index: %#x\n", sCode.Idx);
break;
}
default:
ExPrint("No additional information available for this exception.\n");
break;
}
if (!TaskManager)
return;
CPUData *core = GetCurrentCPU();
Tasking::PCB *proc = core->CurrentProcess.load();
Tasking::TCB *thread = core->CurrentThread.load();
ExPrint("Exception in %s process %s(%d) thread %s(%d)\n",
proc->Security.ExecutionMode == Tasking::User ? "user" : "kernel",
proc->Name, proc->ID,
thread->Name, thread->ID);
}

View File

@ -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);

View File

@ -61,7 +61,7 @@ nsa CPUData *GetCurrentCPU()
Memory::SwapPT(KernelPageTable, thisPageTable); Memory::SwapPT(KernelPageTable, thisPageTable);
if (apic->x2APIC) if (apic->x2APIC)
CoreID = int(CPU::x64::rdmsr(CPU::x64::MSR_X2APIC_APICID)); CoreID = int(CPU::x86::rdmsr(CPU::x86::MSR_X2APIC_APICID));
else else
CoreID = apic->Read(APIC::APIC_ID) >> 24; CoreID = apic->Read(APIC::APIC_ID) >> 24;
} }
@ -151,7 +151,7 @@ namespace SMP
debug("Initializing CPU %d", lapic->APICId); debug("Initializing CPU %d", lapic->APICId);
uint8_t APIC_ID = 0; uint8_t APIC_ID = 0;
if (apic->x2APIC) if (apic->x2APIC)
APIC_ID = uint8_t(CPU::x64::rdmsr(CPU::x64::MSR_X2APIC_APICID)); APIC_ID = uint8_t(CPU::x86::rdmsr(CPU::x86::MSR_X2APIC_APICID));
else else
APIC_ID = uint8_t(apic->Read(APIC::APIC_ID) >> 24); APIC_ID = uint8_t(apic->Read(APIC::APIC_ID) >> 24);

View File

@ -124,6 +124,5 @@ SECTIONS
/DISCARD/ : /DISCARD/ :
{ {
*(.comment*) *(.comment*)
*(.note*)
} }
} }

View File

@ -22,7 +22,7 @@
namespace Memory namespace Memory
{ {
bool Virtual::Check(void *VirtualAddress, PTFlag Flag) bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type)
{ {
uintptr_t Address = (uintptr_t)VirtualAddress; uintptr_t Address = (uintptr_t)VirtualAddress;
Address &= 0xFFFFFFFFFFFFF000; Address &= 0xFFFFFFFFFFFFF000;

View File

@ -92,8 +92,8 @@ extern "C" __naked __used __no_stack_protector __aligned(16) void SystemCallHand
void InitializeSystemCalls() void InitializeSystemCalls()
{ {
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | 1); CPU::x86::wrmsr(CPU::x86::MSR_EFER, CPU::x86::rdmsr(CPU::x86::MSR_EFER) | 1);
wrmsr(MSR_STAR, ((uint64_t)(GDT_KERNEL_CODE) << 32) | ((uint64_t)(GDT_KERNEL_DATA | 3) << 48)); CPU::x86::wrmsr(CPU::x86::MSR_STAR, ((uint64_t)(GDT_KERNEL_CODE) << 32) | ((uint64_t)(GDT_KERNEL_DATA | 3) << 48));
wrmsr(MSR_LSTAR, (uint64_t)SystemCallHandlerStub); CPU::x86::wrmsr(CPU::x86::MSR_LSTAR, (uint64_t)SystemCallHandlerStub);
wrmsr(MSR_SYSCALL_MASK, (uint64_t)(1 << 9)); CPU::x86::wrmsr(CPU::x86::MSR_SYSCALL_MASK, (uint64_t)(1 << 9));
} }

View File

@ -0,0 +1,172 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <signal.hpp>
#include <dumper.hpp>
#include <task.hpp>
#include <errno.h>
#include "../cpu/gdt.hpp"
/* subsystem/linux/syscall.cpp */
extern int ConvertSignalToLinux(signal_t sig);
namespace Tasking
{
bool Signal::HandleSignal(CPU::SchedulerFrame *tf, void *thread)
{
/* We don't want to do this in kernel mode */
if (tf->cs != GDT_USER_CODE)
return false;
if (Queue.empty())
return false;
debug("We have %d signals to handle", Queue.size());
SmartLock(SignalLock);
SignalInfo sigI = GetAvailableSignal(thread);
if (sigI.sig == SIGNULL)
return false;
uintptr_t _p_rsp = ((PCB *)ctx)->PageTable->Get(tf->rsp);
uint64_t paRsp = _p_rsp;
paRsp &= ~0xF; /* Align */
paRsp -= 128; /* Red zone */
/* Calculate the virtual rsp */
uintptr_t _v_rsp = tf->rsp;
_v_rsp &= ~0xF; /* Align */
_v_rsp -= 128; /* Red zone */
uint64_t *vRsp = (uint64_t *)(_v_rsp - sizeof(StackInfo));
vRsp--; /* Alignment */
vRsp--; /* Handler Address */
assert(!((uintptr_t)vRsp & 0xF));
/* Add the stack info */
StackInfo si{};
CPU::x86::fxsave(&si.fx);
si.tf = *tf;
si.GSBase = CPU::x86::rdmsr(CPU::x86::MSR_GS_BASE);
si.FSBase = CPU::x86::rdmsr(CPU::x86::MSR_FS_BASE);
si.ShadowGSBase = CPU::x86::rdmsr(CPU::x86::MSR_SHADOW_GS_BASE);
si.SignalMask = ((TCB *)thread)->Signals.Mask.to_ulong();
si.Compatibility = ((PCB *)ctx)->Info.Compatibility;
debug("gs: %#lx fs: %#lx shadow: %#lx",
si.GSBase, si.FSBase, si.ShadowGSBase);
/* Copy the stack info */
uint64_t *pRsp = (uint64_t *)(paRsp - sizeof(StackInfo));
memcpy(pRsp, &si, sizeof(StackInfo));
/* Set the handler address */
pRsp--; /* Alignment */
pRsp--;
*pRsp = uint64_t(sa[sigI.sig].sa_handler.Handler);
assert(!((uintptr_t)pRsp & 0xF));
int cSig = LinuxSig() ? ConvertSignalToLinux((signal_t)sigI.sig) : sigI.sig;
#ifdef DEBUG
DumpData("Stack Data", (void *)pRsp,
paRsp - uint64_t(pRsp));
debug("initial stack tf->rsp: %#lx after: %#lx",
tf->rsp, uint64_t(vRsp));
debug("sig: %d -> %d", sigI.sig, cSig);
#endif
tf->rsp = uint64_t(vRsp);
tf->rip = uint64_t(TrampAddr);
/* void func(int signo); */
/* void func(int signo, siginfo_t *info, void *context); */
tf->rdi = cSig;
if (sa[sigI.sig].Flags & SA_SIGINFO)
{
fixme("SA_SIGINFO not implemented");
siginfo_t *info = 0;
void *context = 0;
tf->rsi = uint64_t(info);
tf->rdx = uint64_t(context);
tf->rcx = 0;
tf->r8 = 0;
tf->r9 = 0;
}
else
{
tf->rsi = 0;
tf->rdx = 0;
tf->rcx = 0;
tf->r8 = 0;
tf->r9 = 0;
}
((TCB *)thread)->Signals.Mask = sa[sigI.sig].Mask;
assert(TrampAddr != nullptr);
return true;
}
void Signal::RestoreHandleSignal(SyscallsFrame *sf, void *thread)
{
debug("Restoring signal handler");
SmartLock(SignalLock);
gsTCB *gs = (gsTCB *)CPU::x86::rdmsr(CPU::x86::MSR_GS_BASE);
uint64_t *sp = (uint64_t *)((PCB *)ctx)->PageTable->Get(gs->TempStack);
sp++; /* Alignment */
sp++; /* Handler Address */
assert(!((uintptr_t)sp & 0xF));
StackInfo *si = (StackInfo *)sp;
assert(si != nullptr);
sf->r15 = si->tf.r15;
sf->r14 = si->tf.r14;
sf->r13 = si->tf.r13;
sf->r12 = si->tf.r12;
sf->r11 = si->tf.r11;
sf->r10 = si->tf.r10;
sf->r9 = si->tf.r9;
sf->r8 = si->tf.r8;
sf->bp = si->tf.rbp;
sf->di = si->tf.rdi;
sf->si = si->tf.rsi;
sf->dx = si->tf.rdx;
sf->cx = si->tf.rcx;
sf->bx = si->tf.rbx;
sf->ax = si->tf.rax;
sf->Flags = si->tf.rflags.raw;
sf->ReturnAddress = si->tf.rip;
gs->TempStack = (void *)si->tf.rsp;
((TCB *)thread)->Signals.Mask = si->SignalMask;
CPU::x86::fxrstor(&si->fx);
CPU::x86::wrmsr(CPU::x86::MSR_GS_BASE, si->ShadowGSBase);
CPU::x86::wrmsr(CPU::x86::MSR_FS_BASE, si->FSBase);
CPU::x86::wrmsr(CPU::x86::MSR_SHADOW_GS_BASE, si->GSBase);
debug("gs: %#lx fs: %#lx shadow: %#lx",
si->GSBase, si->FSBase, si->ShadowGSBase);
// ((PCB *)ctx)->GetContext()->Yield();
// __builtin_unreachable();
/* Return because we will restore at sysretq */
}
}

40
Kernel/arch/arm/aeabi.c Normal file
View File

@ -0,0 +1,40 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
unsigned __aeabi_uidiv(unsigned a, unsigned b) { return a / b; }
unsigned __aeabi_idiv(unsigned a, unsigned b) { return a / b; }
unsigned __aeabi_l2d(unsigned a) { return a; }
unsigned __aeabi_d2lz(unsigned a) { return a; }
unsigned __aeabi_ldivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
unsigned __aeabi_uldivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
unsigned __aeabi_uidivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
unsigned __aeabi_idivmod(unsigned a, unsigned b, unsigned *r) { *r = a % b; return a / b; }
unsigned __aeabi_unwind_cpp_pr1(void) { return 0; }
unsigned __aeabi_atexit(void) { return 0; }
unsigned __cxa_end_cleanup(void) { return 0; }
unsigned __aeabi_unwind_cpp_pr0(void) { return 0; }

View File

@ -0,0 +1,18 @@
/* Based on this tutorial:
https://github.com/s-matyukevich/raspberry-pi-os */
.section ".text.boot", "a"
.extern _bss_start
.extern _bss_end
.global _start
_start:
b CPU_Loop
Halt:
wfe
b Halt
CPU_Loop:
b CPU_Loop

View File

@ -0,0 +1,46 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <display.hpp>
#include <bitmap.hpp>
#include <convert.h>
#include <printf.h>
#include <lock.hpp>
#include <rand.hpp>
#include <uart.hpp>
#include <debug.h>
#include <smp.hpp>
#include <cpu.hpp>
#include <io.h>
#if defined(__amd64__)
#include "../../arch/amd64/cpu/gdt.hpp"
#include "../arch/amd64/cpu/apic.hpp"
#elif defined(__i386__)
#include "../../arch/i386/cpu/gdt.hpp"
#include "../arch/i386/cpu/apic.hpp"
#elif defined(__aarch64__)
#endif
#include "../../../../kernel.h"
extern void ExPrint(const char *Format, ...);
arch nsa void DisplayDetailsScreen(CPU::ExceptionFrame *Frame)
{
ExPrint("\nException Frame:\n");
}

View File

@ -0,0 +1,59 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <smp.hpp>
#include <ints.hpp>
#include <memory.hpp>
#include <cpu.hpp>
#include "../../../kernel.h"
volatile bool CPUEnabled = false;
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
static __aligned(0x1000) CPUData CPUs[MAX_CPU] = {0};
CPUData *GetCPU(uint64_t id) { return &CPUs[id]; }
CPUData *GetCurrentCPU()
{
uint64_t ret = 0;
if (!CPUs[ret].IsActive)
{
error("CPU %d is not active!", ret);
return &CPUs[0];
}
if (CPUs[ret].Checksum != CPU_DATA_CHECKSUM)
{
error("CPU %d data is corrupted!", ret);
return &CPUs[0];
}
return &CPUs[ret];
}
namespace SMP
{
int CPUCores = 0;
void Initialize(void *madt)
{
fixme("SMP::Initialize() is not implemented!");
}
}

27
Kernel/arch/arm/entry.cpp Normal file
View File

@ -0,0 +1,27 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <types.h>
#include <debug.h>
#include <cpu.hpp>
EXTERNC void arm64Entry(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3)
{
trace("Hello, World!");
CPU::Halt(true);
}

89
Kernel/arch/arm/linker.ld Normal file
View File

@ -0,0 +1,89 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
ENTRY(_start)
SECTIONS
{
_bootstrap_start = .;
.text.boot :
{
*(.text.boot)
. += CONSTANT(MAXPAGESIZE);
_bss_start = .;
*(.text.bss)
_bss_end = .;
}
_bootstrap_end = .;
_kernel_start = .;
_kernel_text_start = .;
.text :
{
KEEP(*(.text.boot))
*(.text .text.*)
}
. = ALIGN(4096);
_kernel_text_end = .;
_kernel_data_start = .;
.data :
{
*(.data .data.*)
}
. = ALIGN(4096);
_kernel_data_end = .;
_kernel_rodata_start = .;
.rodata :
{
*(.rodata .rodata.*)
}
. = ALIGN(4096);
.init_array :
{
PROVIDE_HIDDEN(__init_array_start = .);
KEEP(*(.init_array .ctors))
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN(__fini_array_start = .);
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP(*(.fini_array .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
_kernel_rodata_end = .;
_kernel_bss_start = .;
.bss :
{
*(.bss .bss.*)
}
. = ALIGN(4096);
_kernel_bss_end = .;
_kernel_end = .;
_bss_size = _kernel_end - _kernel_rodata_end;
/DISCARD/ :
{
*(.comment*)
}
}

97
Kernel/arch/arm/madt.cpp Normal file
View File

@ -0,0 +1,97 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include "acpi.hpp"
#include <memory.hpp>
#include <debug.h>
#include "../../kernel.h"
namespace ACPI
{
MADT::MADT(ACPI::MADTHeader *madt)
{
trace("Initializing MADT");
if (!madt)
{
error("MADT is NULL");
return;
}
CPUCores = 0;
LAPICAddress = (LAPIC *)(uintptr_t)madt->LocalControllerAddress;
for (uint8_t *ptr = (uint8_t *)(madt->Entries);
(uintptr_t)(ptr) < (uintptr_t)(madt) + madt->Header.Length;
ptr += *(ptr + 1))
{
switch (*(ptr))
{
case 0:
{
if (ptr[4] & 1)
{
lapic.push_back((LocalAPIC *)ptr);
KPrint("Local APIC %d (APIC %d) found.", lapic.back()->ACPIProcessorId, lapic.back()->APICId);
CPUCores++;
}
break;
}
case 1:
{
ioapic.push_back((MADTIOApic *)ptr);
KPrint("I/O APIC %d (Address %#lx) found.", ioapic.back()->APICID, ioapic.back()->Address);
Memory::Virtual(KernelPageTable).Map((void *)(uintptr_t)ioapic.back()->Address, (void *)(uintptr_t)ioapic.back()->Address, Memory::PTFlag::RW | Memory::PTFlag::PCD); // Make sure that the address is mapped.
break;
}
case 2:
{
iso.push_back((MADTIso *)ptr);
KPrint("ISO (IRQ:%#lx, BUS:%#lx, GSI:%#lx, %s/%s) found.",
iso.back()->IRQSource, iso.back()->BuSSource, iso.back()->GSI,
iso.back()->Flags & 0x00000004 ? "Active High" : "Active Low",
iso.back()->Flags & 0x00000100 ? "Edge Triggered" : "Level Triggered");
break;
}
case 4:
{
nmi.push_back((MADTNmi *)ptr);
KPrint("NMI %#lx (lint:%#lx) found.", nmi.back()->processor, nmi.back()->lint);
break;
}
case 5:
{
LAPICAddress = (LAPIC *)ptr;
KPrint("APIC found at %#lx", LAPICAddress);
break;
}
default:
{
KPrint("Unknown MADT entry %#lx", *(ptr));
break;
}
}
Memory::Virtual(KernelPageTable).Map((void *)LAPICAddress, (void *)LAPICAddress, Memory::PTFlag::RW | Memory::PTFlag::PCD); // I should map more than one page?
}
CPUCores--; // We start at 0 (BSP) and end at 11 (APs), so we have 12 cores.
KPrint("Total CPU cores: %d", CPUCores + 1);
}
MADT::~MADT()
{
}
}

View File

@ -0,0 +1,69 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <memory.hpp>
#include <convert.h>
#include <debug.h>
namespace Memory
{
bool Virtual::Check(void *VirtualAddress, PTFlag Flag, MapType Type)
{
#warning "arm not implemented"
return 0;
}
void *Virtual::GetPhysical(void *VirtualAddress)
{
#warning "arm not implemented"
return nullptr;
}
Virtual::MapType Virtual::GetMapType(void *VirtualAddress)
{
#warning "arm not implemented"
return MapType::NoMapType;
}
PageDirectoryEntry *Virtual::GetPDE(void *VirtualAddress, MapType Type)
{
#warning "arm not implemented"
return nullptr;
}
PageTableEntry *Virtual::GetPTE(void *VirtualAddress, MapType Type)
{
#warning "arm not implemented"
return nullptr;
}
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
{
#warning "arm not implemented"
}
void Virtual::Unmap(void *VirtualAddress, MapType Type)
{
#warning "arm not implemented"
}
void Virtual::Remap(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
{
#warning "arm not implemented"
}
}

View File

@ -0,0 +1,30 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <syscalls.hpp>
#include <cpu.hpp>
extern "C" __used __no_stack_protector void SystemCallHandlerStub()
{
}
extern "C" uint64_t SystemCallsHandler(SyscallsFrame *regs);
void InitializeSystemCalls()
{
}

View File

@ -0,0 +1,38 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <signal.hpp>
#include <dumper.hpp>
#include <task.hpp>
#include <errno.h>
/* subsystem/linux/syscall.cpp */
extern int ConvertSignalToLinux(signal_t sig);
namespace Tasking
{
bool Signal::HandleSignal(CPU::SchedulerFrame *tf, void *thread)
{
#warning "arm not implemented"
return false;
}
void Signal::RestoreHandleSignal(SyscallsFrame *sf, void *thread)
{
#warning "arm not implemented"
}
}

View File

@ -0,0 +1,28 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
.global _sig_native_trampoline_start
_sig_native_trampoline_start:
.global _sig_native_trampoline_end
_sig_native_trampoline_end:
.global _sig_linux_trampoline_start
_sig_linux_trampoline_start:
.global _sig_linux_trampoline_end
_sig_linux_trampoline_end:

View File

@ -15,13 +15,24 @@
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>. along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/ */
.intel_syntax noprefix
.code32 .code32
.extern Multiboot_start
.section .multiboot, "a" .section .multiboot, "a"
.align 4 .align 4
MULTIBOOT_HEADER: MULTIBOOT_HEADER:
.long 0x1BADB002 .long 0x1BADB002
.long 1 << 0 | 1 << 1 .long 0x1 | 0x2 | 0x4
.long -(0x1BADB002 + (1 << 0 | 1 << 1)) .long -(0x1BADB002 + (0x1 | 0x2 | 0x4))
/* KLUDGE */
.long 0
.long 0
.long 0
.long 0
.long 0
/* VIDEO MODE */
.long 0
.long 0
.long 0
.long 0

View File

@ -15,8 +15,6 @@
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>. along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/ */
.intel_syntax noprefix
.code32 .code32
.extern Multiboot_start .extern Multiboot_start
@ -91,3 +89,4 @@ EndTag_Start:
.long EndTag_End - EndTag_Start .long EndTag_End - EndTag_Start
EndTag_End: EndTag_End:
MULTIBOOT2_HEADER_END: MULTIBOOT2_HEADER_END:
nop

View File

@ -0,0 +1,131 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <display.hpp>
#include <bitmap.hpp>
#include <convert.h>
#include <printf.h>
#include <lock.hpp>
#include <rand.hpp>
#include <uart.hpp>
#include <debug.h>
#include <smp.hpp>
#include <cpu.hpp>
#include <io.h>
#include "../../cpu/gdt.hpp"
#include "../../cpu/apic.hpp"
#include "../../../../kernel.h"
extern void ExPrint(const char *Format, ...);
static const char *x86PageFaultDescriptions[9] = {
"Supervisor tried to read a non-present page entry\n",
"Supervisor tried to read a page and caused a protection fault\n",
"Supervisor tried to write to a non-present page entry\n",
"Supervisor tried to write a page and caused a protection fault\n",
"User tried to read a non-present page entry\n",
"User tried to read a page and caused a protection fault\n",
"User tried to write to a non-present page entry\n",
"User tried to write a page and caused a protection fault\n",
"One or more page directory entries contain reserved bits which are set to 1.\n"};
arch nsa void DisplayDetailsScreen(CPU::ExceptionFrame *Frame)
{
ExPrint("\nException Frame:\n");
ExPrint(" General Purpose Registers:\n");
ExPrint(" EAX: %#lx EBX: %#lx ECX: %#lx EDX: %#lx\n",
Frame->eax, Frame->ebx, Frame->ecx, Frame->edx);
ExPrint(" ESI: %#lx EDI: %#lx\n",
Frame->esi, Frame->edi);
ExPrint(" Control Registers:\n");
ExPrint(" CR0: %#lx CR2: %#lx CR3: %#lx CR4: %#lx\n",
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4);
ExPrint(" CR8: %#lx\n", Frame->cr8);
ExPrint(" Segment Registers:\n");
ExPrint(" CS: %#lx SS: %#lx DS: %#lx ES: %#lx FS: %#lx GS: %#lx\n",
Frame->cs, Frame->ss, Frame->ds, Frame->es, Frame->fs, Frame->gs);
ExPrint(" Debug Registers:\n");
ExPrint(" DR0: %#lx DR1: %#lx DR2: %#lx DR3: %#lx\n",
Frame->dr0, Frame->dr1, Frame->dr2, Frame->dr3);
ExPrint(" DR6: %#lx DR7: %#lx\n", Frame->dr6, Frame->dr7);
ExPrint(" Other:\n");
ExPrint(" INT: %#lx ERR: %#lx EIP: %#lx RFLAGS: %#lx\n",
Frame->InterruptNumber, Frame->ErrorCode,
Frame->eip, Frame->eflags.raw);
ExPrint(" RSP: %#lx RBP: %#lx\n",
Frame->esp, Frame->ebp);
ExPrint("Exception Details:\n");
switch (Frame->InterruptNumber)
{
case CPU::x86::PageFault:
{
CPU::x64::PageFaultErrorCode pfCode = {.raw = (uint32_t)Frame->ErrorCode};
ExPrint("PFEC: P:%d W:%d U:%d R:%d I:%d PK:%d SS:%d SGX:%d\n",
pfCode.P, pfCode.W, pfCode.U, pfCode.R,
pfCode.I, pfCode.PK, pfCode.SS, pfCode.SGX);
{
Memory::Virtual vmm((Memory::PageTable *)Frame->cr3);
if (vmm.GetMapType((void *)Frame->cr2) != Memory::Virtual::FourKiB)
ExPrint("Can't display page %#lx\n", Frame->cr2);
else
{
Memory::PageTableEntry *pte = vmm.GetPTE((void *)Frame->cr2);
ExPrint("Page %#lx: P:%d W:%d U:%d G:%d CoW:%d KRsv:%d\n",
ALIGN_DOWN(Frame->cr2, 0x1000), pte->Present, pte->ReadWrite,
pte->UserSupervisor, pte->Global, pte->CopyOnWrite,
pte->KernelReserve);
}
}
ExPrint("%s", x86PageFaultDescriptions[Frame->ErrorCode & 0b111]);
if (Frame->ErrorCode & 0x8)
ExPrint("%s", x86PageFaultDescriptions[8]);
break;
}
case CPU::x86::StackSegmentFault:
case CPU::x86::GeneralProtectionFault:
{
CPU::x64::SelectorErrorCode sCode = {.raw = Frame->ErrorCode};
ExPrint("Kernel performed an illegal operation.\n");
ExPrint("External: %d\n", sCode.External);
ExPrint("Table: %d\n", sCode.Table);
ExPrint("Index: %#x\n", sCode.Idx);
break;
}
default:
ExPrint("No additional information available for this exception.\n");
break;
}
if (!TaskManager)
return;
CPUData *core = GetCurrentCPU();
Tasking::PCB *proc = core->CurrentProcess.load();
Tasking::TCB *thread = core->CurrentThread.load();
ExPrint("Exception in %s process %s(%d) thread %s(%d)\n",
proc->Security.ExecutionMode == Tasking::User ? "user" : "kernel",
proc->Name, proc->ID,
thread->Name, thread->ID);
}

View File

@ -55,7 +55,7 @@ nsa CPUData *GetCurrentCPU()
if (CPUEnabled.load(std::memory_order_acquire) == true) if (CPUEnabled.load(std::memory_order_acquire) == true)
{ {
if (apic->x2APIC) if (apic->x2APIC)
CoreID = int(CPU::x32::rdmsr(CPU::x32::MSR_X2APIC_APICID)); CoreID = int(CPU::x86::rdmsr(CPU::x86::MSR_X2APIC_APICID));
else else
CoreID = apic->Read(APIC::APIC_ID) >> 24; CoreID = apic->Read(APIC::APIC_ID) >> 24;
} }

View File

@ -124,6 +124,5 @@ SECTIONS
/DISCARD/ : /DISCARD/ :
{ {
*(.comment*) *(.comment*)
*(.note*)
} }
} }

View File

@ -29,7 +29,7 @@ namespace Memory
Address &= 0xFFFFF000; Address &= 0xFFFFF000;
PageMapIndexer Index = PageMapIndexer(Address); PageMapIndexer Index = PageMapIndexer(Address);
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
PageTableEntryPtr *PTE = nullptr; PageTableEntryPtr *PTE = nullptr;
if ((PDE->raw & Flag) > 0) if ((PDE->raw & Flag) > 0)
@ -54,7 +54,7 @@ namespace Memory
Address &= 0xFFFFF000; Address &= 0xFFFFF000;
PageMapIndexer Index = PageMapIndexer(Address); PageMapIndexer Index = PageMapIndexer(Address);
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
PageTableEntryPtr *PTE = nullptr; PageTableEntryPtr *PTE = nullptr;
if (PDE->Present) if (PDE->Present)
@ -80,7 +80,7 @@ namespace Memory
PageMapIndexer Index = PageMapIndexer(Address); PageMapIndexer Index = PageMapIndexer(Address);
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
PageTableEntryPtr *PTE = nullptr; PageTableEntryPtr *PTE = nullptr;
if (PDE->Present) if (PDE->Present)
@ -104,7 +104,7 @@ namespace Memory
Address &= 0xFFFFF000; Address &= 0xFFFFF000;
PageMapIndexer Index = PageMapIndexer(Address); PageMapIndexer Index = PageMapIndexer(Address);
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
if (PDE->Present) if (PDE->Present)
return PDE; return PDE;
return nullptr; return nullptr;
@ -116,7 +116,7 @@ namespace Memory
Address &= 0xFFFFF000; Address &= 0xFFFFF000;
PageMapIndexer Index = PageMapIndexer(Address); PageMapIndexer Index = PageMapIndexer(Address);
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
if (!PDE->Present) if (!PDE->Present)
return nullptr; return nullptr;
@ -130,7 +130,7 @@ namespace Memory
void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type) void Virtual::Map(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
{ {
SmartLock(this->MemoryLock); SmartLock(this->MemoryLock);
if (unlikely(!this->Table)) if (unlikely(!this->pTable))
{ {
error("No page table"); error("No page table");
return; return;
@ -142,7 +142,7 @@ namespace Memory
// Clear any flags that are not 1 << 0 (Present) - 1 << 5 (Accessed) because rest are for page table entries only // Clear any flags that are not 1 << 0 (Present) - 1 << 5 (Accessed) because rest are for page table entries only
uint64_t DirectoryFlags = Flags & 0x3F; uint64_t DirectoryFlags = Flags & 0x3F;
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
if (Type == MapType::FourMiB) if (Type == MapType::FourMiB)
{ {
PDE->raw |= (uintptr_t)Flags; PDE->raw |= (uintptr_t)Flags;
@ -191,14 +191,14 @@ namespace Memory
void Virtual::Unmap(void *VirtualAddress, MapType Type) void Virtual::Unmap(void *VirtualAddress, MapType Type)
{ {
SmartLock(this->MemoryLock); SmartLock(this->MemoryLock);
if (!this->Table) if (!this->pTable)
{ {
error("No page table"); error("No page table");
return; return;
} }
PageMapIndexer Index = PageMapIndexer((uintptr_t)VirtualAddress); PageMapIndexer Index = PageMapIndexer((uintptr_t)VirtualAddress);
PageDirectoryEntry *PDE = &this->Table->Entries[Index.PDEIndex]; PageDirectoryEntry *PDE = &this->pTable->Entries[Index.PDEIndex];
if (!PDE->Present) if (!PDE->Present)
{ {
warn("Page %#lx not present", PDE->GetAddress()); warn("Page %#lx not present", PDE->GetAddress());
@ -223,4 +223,18 @@ namespace Memory
PTEPtr->Entries[Index.PTEIndex] = PTE; PTEPtr->Entries[Index.PTEIndex] = PTE;
CPU::x32::invlpg(VirtualAddress); CPU::x32::invlpg(VirtualAddress);
} }
void Virtual::Remap(void *VirtualAddress, void *PhysicalAddress, uint64_t Flags, MapType Type)
{
SmartLock(this->MemoryLock);
if (unlikely(!this->pTable))
{
error("No page table");
return;
}
#warning "Remap is not properly implemented"
this->Unmap(VirtualAddress, Type);
this->Map(VirtualAddress, PhysicalAddress, Flags, Type);
}
} }

View File

@ -0,0 +1,160 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <signal.hpp>
#include <dumper.hpp>
#include <task.hpp>
#include <errno.h>
#include "../cpu/gdt.hpp"
/* subsystem/linux/syscall.cpp */
extern int ConvertSignalToLinux(signal_t sig);
namespace Tasking
{
bool Signal::HandleSignal(CPU::SchedulerFrame *tf, void *thread)
{
/* We don't want to do this in kernel mode */
if (tf->cs != GDT_USER_CODE)
return false;
if (Queue.empty())
return false;
debug("We have %d signals to handle", Queue.size());
SmartLock(SignalLock);
SignalInfo sigI = GetAvailableSignal(thread);
if (sigI.sig == SIGNULL)
return false;
uintptr_t _p_esp = ((PCB *)ctx)->PageTable->Get(tf->esp);
uint64_t paEsp = _p_esp;
paEsp &= ~0xF; /* Align */
paEsp -= 128; /* Red zone */
/* Calculate the virtual rsp */
uintptr_t _v_esp = tf->esp;
_v_esp &= ~0xF; /* Align */
_v_esp -= 128; /* Red zone */
uint64_t *vEsp = (uint64_t *)(_v_esp - sizeof(StackInfo));
vEsp--; /* Alignment */
vEsp--; /* Handler Address */
assert(!((uintptr_t)vEsp & 0xF));
/* Add the stack info */
StackInfo si{};
CPU::x86::fxsave(&si.fx);
si.tf = *tf;
si.GSBase = CPU::x86::rdmsr(CPU::x86::MSR_GS_BASE);
si.FSBase = CPU::x86::rdmsr(CPU::x86::MSR_FS_BASE);
si.ShadowGSBase = CPU::x86::rdmsr(CPU::x86::MSR_SHADOW_GS_BASE);
si.SignalMask = ((TCB *)thread)->Signals.Mask.to_ulong();
si.Compatibility = ((PCB *)ctx)->Info.Compatibility;
debug("gs: %#lx fs: %#lx shadow: %#lx",
si.GSBase, si.FSBase, si.ShadowGSBase);
/* Copy the stack info */
uint64_t *pEsp = (uint64_t *)(paEsp - sizeof(StackInfo));
memcpy(pEsp, &si, sizeof(StackInfo));
/* Set the handler address */
pEsp--; /* Alignment */
pEsp--;
*pEsp = uint64_t(sa[sigI.sig].sa_handler.Handler);
assert(!((uintptr_t)pEsp & 0xF));
int cSig = LinuxSig() ? ConvertSignalToLinux((signal_t)sigI.sig) : sigI.sig;
#ifdef DEBUG
DumpData("Stack Data", (void *)pEsp,
paEsp - uint64_t(pEsp));
debug("initial stack tf->rsp: %#lx after: %#lx",
tf->esp, uint64_t(vEsp));
debug("sig: %d -> %d", sigI.sig, cSig);
#endif
tf->esp = uint64_t(vEsp);
tf->eip = uint64_t(TrampAddr);
/* void func(int signo); */
/* void func(int signo, siginfo_t *info, void *context); */
tf->edi = cSig;
if (sa[sigI.sig].Flags & SA_SIGINFO)
{
fixme("SA_SIGINFO not implemented");
siginfo_t *info = 0;
void *context = 0;
tf->eax = uint64_t(info);
tf->edx = uint64_t(context);
tf->ecx = 0;
}
else
{
tf->eax = 0;
tf->edx = 0;
tf->ecx = 0;
}
((TCB *)thread)->Signals.Mask = sa[sigI.sig].Mask;
assert(TrampAddr != nullptr);
return true;
}
void Signal::RestoreHandleSignal(SyscallsFrame *sf, void *thread)
{
debug("Restoring signal handler");
SmartLock(SignalLock);
gsTCB *gs = (gsTCB *)CPU::x86::rdmsr(CPU::x86::MSR_GS_BASE);
uint64_t *sp = (uint64_t *)((PCB *)ctx)->PageTable->Get(gs->TempStack);
sp++; /* Alignment */
sp++; /* Handler Address */
assert(!((uintptr_t)sp & 0xF));
StackInfo *si = (StackInfo *)sp;
assert(si != nullptr);
sf->bp = si->tf.ebp;
sf->di = si->tf.edi;
sf->si = si->tf.esi;
sf->dx = si->tf.edx;
sf->cx = si->tf.ecx;
sf->bx = si->tf.ebx;
sf->ax = si->tf.eax;
sf->Flags = si->tf.eflags.raw;
sf->ReturnAddress = si->tf.eip;
gs->TempStack = (void *)si->tf.esp;
((TCB *)thread)->Signals.Mask = si->SignalMask;
CPU::x86::fxrstor(&si->fx);
CPU::x86::wrmsr(CPU::x86::MSR_GS_BASE, si->ShadowGSBase);
CPU::x86::wrmsr(CPU::x86::MSR_FS_BASE, si->FSBase);
CPU::x86::wrmsr(CPU::x86::MSR_SHADOW_GS_BASE, si->GSBase);
debug("gs: %#lx fs: %#lx shadow: %#lx",
si->GSBase, si->FSBase, si->ShadowGSBase);
// ((PCB *)ctx)->GetContext()->Yield();
// __builtin_unreachable();
/* Return because we will restore at sysretq */
}
}

View File

@ -0,0 +1,38 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
.code64
.global _sig_native_trampoline_start
_sig_native_trampoline_start:
int $0x3
.global _sig_native_trampoline_end
_sig_native_trampoline_end:
.global _sig_linux_trampoline_start
_sig_linux_trampoline_start:
movq %rsp, %rbp
movq (%rbp), %rax
call *%rax
mov %rbp, %rsp
/* rt_sigreturn = 15 */
movq $15, %rax
syscall
.global _sig_linux_trampoline_end
_sig_linux_trampoline_end:

View File

@ -194,10 +194,14 @@ namespace ACPI
if (FADT) if (FADT)
{ {
#if defined(__amd64__) || defined(__i386__)
outb(s_cst(uint16_t, FADT->SMI_CommandPort), FADT->AcpiEnable); outb(s_cst(uint16_t, FADT->SMI_CommandPort), FADT->AcpiEnable);
/* TODO: Sleep for ~5 seconds before polling PM1a CB? */ /* TODO: Sleep for ~5 seconds before polling PM1a CB? */
while (!(inw(s_cst(uint16_t, FADT->PM1aControlBlock)) & 1)) while (!(inw(s_cst(uint16_t, FADT->PM1aControlBlock)) & 1))
CPU::Pause(); CPU::Pause();
#elif defined(__aarch64__)
warn("aarch64 is not supported yet");
#endif
} }
} }

Some files were not shown because too many files have changed in this diff Show More