Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Eric-Paul I | a4b246095a | |
Eric-Paul I | ed98984164 | |
Eric-Paul I | 72e1a8ecd0 | |
Eric-Paul I | 3ac01ad142 | |
Eric-Paul I | ddcb64daea | |
Eric-Paul I | 73796b2686 | |
Eric-Paul I | e1978a052d |
|
@ -1,5 +1,4 @@
|
||||||
build
|
build
|
||||||
cmake-build-debug
|
cmake-build-debug
|
||||||
|
.idea
|
||||||
noxos.log
|
noxos.log
|
||||||
ramdisk/shell.elf
|
|
||||||
*.nxkm
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Build instructions
|
||||||
|
**DISCLAIMER: To build this project you need a linux system (WSL could work for windows users, but I haven't tested it)**
|
||||||
|
|
||||||
|
|
||||||
|
First you need to clone the repository:
|
||||||
|
|
||||||
|
`git clone https://codeberg.org/antifallobst/noxos/`
|
||||||
|
|
||||||
|
then there are a few tools required, that need to be installed:
|
||||||
|
* **gcc** - compiler
|
||||||
|
* **ld** - linker
|
||||||
|
* **nasm** - assembler
|
||||||
|
* **cmake** - build system
|
||||||
|
* **xorriso** - ISO creation tools
|
||||||
|
* **qemu** - emulator
|
||||||
|
|
||||||
|
There is a shell script to setup the workspace and compile.
|
||||||
|
Just run it using the following commands:
|
||||||
|
```bash
|
||||||
|
cd noxos
|
||||||
|
./build.sh
|
||||||
|
```
|
||||||
|
If the Bootloader (Limine ([github](https://github.com/limine-bootloader/limine))) isn't downloaded yet, the script will download it.
|
||||||
|
|
||||||
|
The final ISO file will be written to the *build* directory.
|
||||||
|
|
||||||
|
To launch the ISO, run the `run.sh` script.
|
||||||
|
|
||||||
|
# UEFI Emulation
|
||||||
|
To emulate an UEFI system, you need to install the `ovmf` package.
|
||||||
|
Then you can do `./run.sh uefi` to start qemu with uefi instead of bios.
|
||||||
|
|
||||||
|
# Debugging
|
||||||
|
## Logs
|
||||||
|
When running through the script, qemu is configured to write the kernels logs to *STDOUT* and a file called *noxos.log*.
|
||||||
|
## GDB
|
||||||
|
You can connect GDB to qemu.
|
||||||
|
To achieve this, run `./run.sh debug`.
|
||||||
|
QEMU will wait until you connect GDB to it as a 'remote' target on `localhost:1234`.
|
||||||
|
```bash
|
||||||
|
gdb build/cmake/kernel/kernel
|
||||||
|
target remote localhost:1234
|
||||||
|
c
|
||||||
|
```
|
||||||
|
(note, that the last to commands have to be 'executed' in gdb not in your shell)
|
|
@ -0,0 +1,61 @@
|
||||||
|
# Code Style
|
||||||
|
## Naming conventions
|
||||||
|
- **structs** are suffixed with **_T**
|
||||||
|
- **typedefs** are suffixed with **_t**
|
||||||
|
- **enums** are suffixed with **_E**
|
||||||
|
- **global** variables are prefixed with **g_**
|
||||||
|
|
||||||
|
Everything is **snake_case**.
|
||||||
|
|
||||||
|
## Code readability
|
||||||
|
To make the code as readable and self explaining as possible, there are a few patterns that should be used.
|
||||||
|
|
||||||
|
### Avoid abbreviations
|
||||||
|
Give your variables, functions, etc. meaningfull names.
|
||||||
|
The times of 80char wide screens are over, feel free to use that space :D
|
||||||
|
|
||||||
|
Example: `sym_at_idx` -> `get_symbol_at_index`
|
||||||
|
|
||||||
|
But you're not forced to (anything) write out everything.
|
||||||
|
For example the **Interrupt Descriptor Table** is simply referred to as **idt** (this abbreviation is btw standard).
|
||||||
|
|
||||||
|
### Avoid indentation nesting
|
||||||
|
In a perfect codebase, the maximum indention level would be 3.
|
||||||
|
The goal of NoxOS is not to be a perfect codebase, but please avoid huge indention nesting.
|
||||||
|
To achieve this, you can break parts into extra functions and/or use the early return pattern.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```c
|
||||||
|
bool likes_pigs (void* a) {
|
||||||
|
if (a != NULL) {
|
||||||
|
if (a == 0xACAB) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
->
|
||||||
|
```c
|
||||||
|
bool likes_pigs (void* a) {
|
||||||
|
if (a != NULL) { return true; }
|
||||||
|
if (a != 0xACAB) { return true; }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### align declarations
|
||||||
|
|
||||||
|
Please align declarations, definitions, etc like in the example:
|
||||||
|
```c
|
||||||
|
char am_i_a_variable = '?';
|
||||||
|
uint64_t number = 0;
|
||||||
|
bool i_waste_bits = true;
|
||||||
|
```
|
||||||
|
|
||||||
|
### namespaces
|
||||||
|
Unlike C++ C has no namespaces.
|
||||||
|
To achieve the goal of namespaces, please prefix your functions, structs, etc. with the "namespace" they are in.
|
||||||
|
|
||||||
|
Example: `out_byte` -> `io_out_byte`
|
|
@ -0,0 +1,47 @@
|
||||||
|
Welcome :D
|
||||||
|
|
||||||
|
Nice, that you're interested in contributing.
|
||||||
|
|
||||||
|
There are several ways to contribute to NoxOS:
|
||||||
|
- Write code
|
||||||
|
- Maintain Documentation
|
||||||
|
- Typos
|
||||||
|
- Grammar
|
||||||
|
- Is the documentation up to date?
|
||||||
|
- Plan stuff (e.g. syscalls)
|
||||||
|
- open Issues
|
||||||
|
|
||||||
|
# Before Contribution
|
||||||
|
Please read the [Code-Style wiki entry](https://codeberg.org/antifallobst/noxos/wiki/Code-Style) before you start to contribute.
|
||||||
|
|
||||||
|
For workspace setup and build instructions look at [this wiki entry](https://codeberg.org/antifallobst/noxos/wiki/Build-instructions).
|
||||||
|
|
||||||
|
**We don't accept any Assholes! If you're a fascist, racist, or discriminate others for anything, go fuck yourself.**
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
When you contribute code, please [document](https://codeberg.org/antifallobst/noxos/wiki/Kernel-documentation) it.
|
||||||
|
You don't have to (and you also shouldn't) write romans, but a few lines for every in a header exposed function, struct etc. help others (and yourself) understanding how to interact with your code.
|
||||||
|
|
||||||
|
|
||||||
|
## What dafuq is ...?
|
||||||
|
OS development can be quite complicated/confusing. That's Ok.
|
||||||
|
Stuff like Paging can be really weird, if you don't have osdev experience.
|
||||||
|
But there are learning resources and places, where you can ask questions.
|
||||||
|
|
||||||
|
**A small overview about such resources and places:**
|
||||||
|
- The [osdev wiki](https://wiki.osdev.org) is like wikipedia - just for hobby os developers.
|
||||||
|
- The [osdev subreddit](https://reddit.com/r/osdev) is a great place to ask questions and share knowledge
|
||||||
|
- Intel's [developer manual](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html) is a more advanced but kinda precise information source
|
||||||
|
|
||||||
|
Also feel free to join the [NoxOS Matrix space](https://matrix.to/#/#noxos:systemausfall.org),
|
||||||
|
where you can chat with other NoxOS devs and ask questions.
|
||||||
|
**But Stay Respectful, Or We `sudo rm -rf /` Your PC ;)**
|
||||||
|
|
||||||
|
# Where to start?
|
||||||
|
|
||||||
|
Get the codebase and play a bit around with it.
|
||||||
|
Try to understand basic concepts of the codebase, the [documentation](https://codeberg.org/antifallobst/noxos/wiki/Kernel-documentation) will help you.
|
||||||
|
After that you can search the [Issues](https://codeberg.org/antifallobst/noxos/issues) for the `Good First Issue` label,
|
||||||
|
to find easy improvements, etc. that you can try to implement.
|
||||||
|
Another option is to ask in the [Matrix Space](https://matrix.to/#/#noxos:systemausfall.org).
|
|
@ -0,0 +1,11 @@
|
||||||
|
**DISCLAIMER: We don't accept any Assholes! If you're a fascist, racist, or discriminate others for anything, go fuck yourself.** If not, welcome :)
|
||||||
|
|
||||||
|
The wiki on codeberg is probably less frequently updated, than the `.wiki` directory in the codebase.
|
||||||
|
|
||||||
|
Wiki Content:
|
||||||
|
|
||||||
|
* [Contribution guide](https://codeberg.org/antifallobst/noxos/wiki/Contribution-guide)
|
||||||
|
* [Build instructions](https://codeberg.org/antifallobst/noxos/wiki/Build-instructions)
|
||||||
|
* [Code Style](https://codeberg.org/antifallobst/noxos/wiki/Code-Style)
|
||||||
|
* [Kernel Documentation](https://codeberg.org/antifallobst/noxos/wiki/Kernel-documentation)
|
||||||
|
* [Project Roadmap](https://codeberg.org/antifallobst/noxos/wiki/Roadmap)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
||||||
|
# Roadmap
|
||||||
|
- [x] Bootable system
|
||||||
|
- [x] Logger
|
||||||
|
- [X] Page frame manager
|
||||||
|
- [X] Interrupts
|
||||||
|
- [X] Page maps
|
||||||
|
- [X] Heap
|
||||||
|
- [X] Format strings
|
||||||
|
- [X] Graphics Renderer
|
||||||
|
- [X] Text
|
||||||
|
- [X] Double buffering
|
||||||
|
- [X] Buffer requests
|
||||||
|
- [X] Panic Screen
|
||||||
|
- [X] Register dump
|
||||||
|
- [X] Stack tracing
|
||||||
|
- [X] Scheduler
|
||||||
|
- [X] (Kernel) Threads
|
||||||
|
- [X] Ramdisk
|
||||||
|
- [X] USTAR
|
||||||
|
- [X] RAMFS
|
||||||
|
- [X] VFS
|
||||||
|
- [X] ELF loading
|
||||||
|
- [X] Processes
|
||||||
|
- [ ] Keyboard input (ps/2 int)
|
||||||
|
- [ ] Shell
|
||||||
|
- [ ] JSON parser for system config
|
||||||
|
- [ ] FAT32
|
||||||
|
- [ ] Text Editor
|
||||||
|
- [ ] TCC
|
|
@ -1,25 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.00)
|
cmake_minimum_required(VERSION 3.00)
|
||||||
project(kernel)
|
project(NoxOS)
|
||||||
set(C 99)
|
add_subdirectory(kernel)
|
||||||
|
|
||||||
set(CMAKE_NASM_COMPILE_OBJECT "nasm <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
|
|
||||||
|
|
||||||
|
|
||||||
add_executable(kernel)
|
|
||||||
add_library (kernel_asm OBJECT)
|
|
||||||
target_include_directories(kernel PRIVATE inc)
|
|
||||||
file(GLOB_RECURSE kernel_src_c "src/**/*.c")
|
|
||||||
file(GLOB_RECURSE kernel_inc "inc/**/*.h")
|
|
||||||
file(GLOB_RECURSE kernel_src_asm "src/**/*.asm")
|
|
||||||
|
|
||||||
|
|
||||||
target_compile_options(kernel PRIVATE -g -fno-stack-protector -fno-stack-check -mno-red-zone -ffreestanding -m64 -march=x86-64 -mabi=sysv)
|
|
||||||
target_link_options(kernel PRIVATE -nostdlib -static -T "${CMAKE_CURRENT_LIST_DIR}/kernel.ld")
|
|
||||||
|
|
||||||
enable_language(ASM_NASM)
|
|
||||||
set(CAN_USE_ASSEMBLER TRUE)
|
|
||||||
|
|
||||||
target_sources(kernel_asm PRIVATE ${kernel_src_asm})
|
|
||||||
target_sources(kernel PRIVATE ${kernel_src_c} ${kernel_inc} $<TARGET_OBJECTS:kernel_asm>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
||||||
Copyright 2023 the noxos team <antifallobst@systemausfall.org>
|
Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the “Software”), to deal in
|
this software and associated documentation files (the “Software”), to deal in
|
||||||
|
|
64
README.md
64
README.md
|
@ -3,53 +3,39 @@
|
||||||
NoxOS is a small x86 operating system (currently just a kernel).
|
NoxOS is a small x86 operating system (currently just a kernel).
|
||||||
The kernel is booted using the limine boot protocol and is fully documented.
|
The kernel is booted using the limine boot protocol and is fully documented.
|
||||||
|
|
||||||
# Roadmap
|
## Roadmap
|
||||||
|
|
||||||
- [x] Bootable system
|
- [x] Bootable system
|
||||||
- [x] Logger
|
- [x] Logger
|
||||||
- [x] Page frame manager
|
- [X] Page frame manager
|
||||||
- [x] Interrupts
|
- [X] Interrupts
|
||||||
- [x] Page maps
|
- [X] Page maps
|
||||||
- [x] Heap
|
- [X] Heap
|
||||||
- [x] Format strings
|
- [X] Format strings
|
||||||
- [x] Graphics Renderer
|
- [X] Graphics Renderer
|
||||||
- [x] Text
|
- [X] Text
|
||||||
- [x] Double buffering
|
- [X] Double buffering
|
||||||
- [x] Buffer requests
|
- [X] Buffer requests
|
||||||
- [x] Panic Screen
|
- [X] Panic Screen
|
||||||
- [x] Register dump
|
- [X] Register dump
|
||||||
- [x] Stack tracing
|
- [X] Stack tracing
|
||||||
- [x] Scheduler
|
- [X] Scheduler
|
||||||
- [x] Threads
|
- [X] (Kernel) Threads
|
||||||
- [x] Processes
|
- [X] Ramdisk
|
||||||
- [x] Ramdisk
|
- [X] USTAR
|
||||||
- [x] USTAR
|
- [X] RAMFS
|
||||||
- [x] RAMFS
|
- [X] VFS
|
||||||
- [x] VFS
|
- [X] ELF loading
|
||||||
- [x] ELF loading
|
- [X] Processes
|
||||||
- [x] Keyboard input (ps/2 int)
|
- [ ] Keyboard input (ps/2 int)
|
||||||
- [x] JSON parser for system config
|
|
||||||
- [ ] Drivers
|
|
||||||
- [X] Loading / Linking into kernel
|
|
||||||
- [X] Driver Device assignment (PCI / USB / FS)
|
|
||||||
- [ ] API
|
|
||||||
- [ ] Syscalls
|
|
||||||
- [x] Filesystem
|
|
||||||
- [x] Memory
|
|
||||||
- [ ] Processing
|
|
||||||
- [x] Drivers
|
|
||||||
- [X] Kernel
|
|
||||||
- [ ] FAT32 (driver)
|
|
||||||
- [ ] TUI framework
|
|
||||||
- [ ] Shell
|
- [ ] Shell
|
||||||
|
- [ ] JSON parser for system config
|
||||||
|
- [ ] FAT32
|
||||||
- [ ] Text Editor
|
- [ ] Text Editor
|
||||||
- [ ] TCC
|
- [ ] TCC
|
||||||
- [ ] Tetris
|
|
||||||
- [ ] Init System
|
|
||||||
|
|
||||||
## Contribution Welcome :D
|
## Contribution Welcome :D
|
||||||
|
|
||||||
Install instructions, Code Documentation and a Contribution guide can be found [here](https://git.nerdcult.net/noxos/documentation).
|
Install instructions, Code Documentation and a Contribution guide can be found in the [wiki](https://codeberg.org/antifallobst/noxos/wiki/).
|
||||||
|
|
||||||
## Copyright / License (MIT)
|
## Copyright / License (MIT)
|
||||||
Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
90
build.sh
90
build.sh
|
@ -1,6 +1,25 @@
|
||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
# This file is part of noxos and licensed under the MIT open source license
|
# Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
# this software and associated documentation files (the “Software”), to deal in
|
||||||
|
# the Software without restriction, including without limitation the rights to use,
|
||||||
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
# Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
# subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
@ -11,61 +30,16 @@ workspace_setup() {
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
check_toolchain() {
|
|
||||||
echo " --> Checking Toolchain"
|
|
||||||
hash gcc
|
|
||||||
echo " |--> found gcc"
|
|
||||||
hash ld
|
|
||||||
echo " |--> found ld"
|
|
||||||
hash nasm
|
|
||||||
echo " |--> found nasm"
|
|
||||||
hash cmake
|
|
||||||
echo " |--> found cmake"
|
|
||||||
hash xorriso
|
|
||||||
echo " |--> found xorriso"
|
|
||||||
hash qemu-system-x86_64
|
|
||||||
echo " |--> found qemu"
|
|
||||||
|
|
||||||
[ ! -d "/usr/share/ovmf/x64/" ] && echo "OVMF binaries not found!" && exit 255
|
|
||||||
echo " |--> found ovmf"
|
|
||||||
|
|
||||||
echo " --> All checks passed"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
kernel_build() {
|
kernel_build() {
|
||||||
echo " --> Building kernel"
|
echo " --> Building kernel"
|
||||||
cd build/cmake
|
cd build/cmake
|
||||||
cmake -S ../.. -B .
|
cmake ../..
|
||||||
make
|
make
|
||||||
cd ../..
|
cd ../..
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
libnx_build() {
|
|
||||||
cd ../libraries/libnx
|
|
||||||
bash build.sh
|
|
||||||
cd ../../kernel
|
|
||||||
}
|
|
||||||
|
|
||||||
libnxdrv_build() {
|
|
||||||
cd ../libraries/libnxdrv
|
|
||||||
bash build.sh
|
|
||||||
cd ../../kernel
|
|
||||||
|
|
||||||
cd ../drivers/test
|
|
||||||
bash build.sh
|
|
||||||
cd ../../kernel
|
|
||||||
|
|
||||||
mkdir -pv ramdisk/drv/
|
|
||||||
cp ../drivers/build/test.nxkm ramdisk/drv/test.nxkm
|
|
||||||
}
|
|
||||||
|
|
||||||
shell_build() {
|
|
||||||
echo " --> Building shell"
|
|
||||||
# gcc shell.c -o ramdisk/shell.elf -nostdlib -nolibc -fno-stack-protector -I../libraries/libnx/inc/public ../libraries/libnx/build/cmake/libnx.so
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
limine_install() {
|
limine_install() {
|
||||||
echo " --> Installing Limine"
|
echo " --> Installing Limine"
|
||||||
|
@ -91,12 +65,12 @@ generate_image() {
|
||||||
rm -rfv iso
|
rm -rfv iso
|
||||||
mkdir -pv iso
|
mkdir -pv iso
|
||||||
|
|
||||||
cp limine/limine-cd.bin iso/
|
cp limine/limine-cd.bin iso
|
||||||
cp limine/limine-cd-efi.bin iso/
|
cp limine/limine-cd-efi.bin iso
|
||||||
cp limine/limine.sys iso/
|
cp limine/limine.sys iso
|
||||||
cp ../limine.cfg iso/
|
cp ../limine.cfg iso
|
||||||
cp initrd.tar iso/
|
cp initrd.tar iso
|
||||||
cp cmake/kernel iso/kernel.elf
|
cp cmake/kernel/kernel iso/kernel.elf
|
||||||
|
|
||||||
xorriso -as mkisofs -b limine-cd.bin \
|
xorriso -as mkisofs -b limine-cd.bin \
|
||||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||||
|
@ -114,21 +88,11 @@ generate_image() {
|
||||||
|
|
||||||
echo "!=====[ NoxOS build script ]=====!"
|
echo "!=====[ NoxOS build script ]=====!"
|
||||||
|
|
||||||
case $1 in
|
|
||||||
"check")
|
|
||||||
check_toolchain
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
workspace_setup
|
workspace_setup
|
||||||
kernel_build
|
kernel_build
|
||||||
[ ! -d "build/limine" ] && limine_install
|
[ ! -d "build/limine" ] && limine_install
|
||||||
libnx_build
|
|
||||||
libnxdrv_build
|
|
||||||
shell_build
|
|
||||||
generate_initial_ramdisk
|
generate_initial_ramdisk
|
||||||
generate_image
|
generate_image
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "!=====[ Finished ]=====!"
|
echo "!=====[ Finished ]=====!"
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_BOOT_INFO_H
|
|
||||||
#define NOX_BOOT_INFO_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "limine.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct limine_framebuffer_response* framebuffer;
|
|
||||||
struct limine_terminal_response* terminal;
|
|
||||||
struct limine_memmap_response* memory_map;
|
|
||||||
struct limine_file* kernel_file;
|
|
||||||
struct limine_file* ramdisk_file;
|
|
||||||
void* rsdp;
|
|
||||||
} boot_info_T;
|
|
||||||
|
|
||||||
#endif //NOX_BOOT_INFO_H
|
|
|
@ -1,17 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_CONFIG_H
|
|
||||||
#define NOXOS_CONFIG_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool ps2_acpi_validation;
|
|
||||||
bool log_graphical;
|
|
||||||
} sysconfig_T;
|
|
||||||
|
|
||||||
void sysconfig_init();
|
|
||||||
|
|
||||||
extern sysconfig_T* g_sysconfig;
|
|
||||||
|
|
||||||
#endif //NOXOS_CONFIG_H
|
|
|
@ -1,32 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_ACPI_H
|
|
||||||
#define NOX_ACPI_H
|
|
||||||
|
|
||||||
#include "boot/boot_info.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char signature [4];
|
|
||||||
uint32_t length;
|
|
||||||
uint8_t revision;
|
|
||||||
uint8_t checksum;
|
|
||||||
char oem_id [6];
|
|
||||||
char oem_table_id [8];
|
|
||||||
uint32_t oem_revision;
|
|
||||||
uint32_t creator_id;
|
|
||||||
uint32_t creator_revision;
|
|
||||||
} __attribute__((packed)) acpi_sdt_header_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t address_space;
|
|
||||||
uint8_t bit_width;
|
|
||||||
uint8_t bit_offset;
|
|
||||||
uint8_t access_size;
|
|
||||||
uint64_t address;
|
|
||||||
} __attribute__((packed)) acpi_gas_T;
|
|
||||||
|
|
||||||
void acpi_init (boot_info_T* boot_info);
|
|
||||||
acpi_sdt_header_T* acpi_find_table (acpi_sdt_header_T* xsdt, string_t table_id);
|
|
||||||
|
|
||||||
#endif //NOX_ACPI_H
|
|
|
@ -1,68 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_FADT_H
|
|
||||||
#define NOX_FADT_H
|
|
||||||
|
|
||||||
#include "drivers/builtin/acpi/acpi.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
acpi_sdt_header_T header;
|
|
||||||
uint32_t firmware_control;
|
|
||||||
uint32_t dsdt;
|
|
||||||
uint8_t reserved;
|
|
||||||
uint8_t preferred_power_management_profile;
|
|
||||||
uint16_t sci_interrupt;
|
|
||||||
uint32_t smi_command_port;
|
|
||||||
uint8_t apci_enable;
|
|
||||||
uint8_t apci_disable;
|
|
||||||
uint8_t s4_bios_request;
|
|
||||||
uint8_t pstate_control;
|
|
||||||
uint32_t pm1a_event_block;
|
|
||||||
uint32_t pm1b_event_block;
|
|
||||||
uint32_t pm1a_control_block;
|
|
||||||
uint32_t pm1b_control_block;
|
|
||||||
uint32_t pm2_control_block;
|
|
||||||
uint32_t pm_timer_block;
|
|
||||||
uint32_t gpe0_block;
|
|
||||||
uint32_t gpe1_block;
|
|
||||||
uint8_t pm1_event_length;
|
|
||||||
uint8_t pm1_control_length;
|
|
||||||
uint8_t pm2_control_length;
|
|
||||||
uint8_t pm_timer_length;
|
|
||||||
uint8_t gpe0_length;
|
|
||||||
uint8_t gpe1_length;
|
|
||||||
uint8_t gpe1_base;
|
|
||||||
uint8_t c_state_control;
|
|
||||||
uint16_t c2_worst_latency;
|
|
||||||
uint16_t c3_worst_latency;
|
|
||||||
uint16_t flush_size;
|
|
||||||
uint16_t flush_stride;
|
|
||||||
uint8_t duty_offset;
|
|
||||||
uint8_t duty_width;
|
|
||||||
uint8_t day_alarm;
|
|
||||||
uint8_t month_alarm;
|
|
||||||
uint8_t century;
|
|
||||||
uint16_t ia_boot_architecture_flags;
|
|
||||||
uint8_t reserved_2;
|
|
||||||
uint32_t flags;
|
|
||||||
acpi_gas_T reset_register;
|
|
||||||
uint8_t reset_value;
|
|
||||||
uint8_t reserved_3[3];
|
|
||||||
uint64_t x_firmware_control;
|
|
||||||
uint64_t x_dsdt;
|
|
||||||
acpi_gas_T x_pm1a_event_block;
|
|
||||||
acpi_gas_T x_pm1b_event_block;
|
|
||||||
acpi_gas_T x_pm1a_control_block;
|
|
||||||
acpi_gas_T x_pm1b_control_block;
|
|
||||||
acpi_gas_T x_pm2_control_block;
|
|
||||||
acpi_gas_T x_pm_timer_block;
|
|
||||||
acpi_gas_T x_gpe0_block;
|
|
||||||
acpi_gas_T x_gpe1_block;
|
|
||||||
acpi_gas_T sleep_control_register;
|
|
||||||
acpi_gas_T sleep_status_register;
|
|
||||||
uint64_t hypervisor_vendor_identity;
|
|
||||||
} __attribute__((packed)) acpi_fadt_T;
|
|
||||||
|
|
||||||
extern acpi_fadt_T* g_acpi_table_fadt;
|
|
||||||
|
|
||||||
#endif //NOX_FADT_H
|
|
|
@ -1,23 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_MCFG_H
|
|
||||||
#define NOXOS_MCFG_H
|
|
||||||
|
|
||||||
#include "drivers/builtin/acpi/acpi.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
acpi_sdt_header_T header;
|
|
||||||
uint64_t reserved;
|
|
||||||
} __attribute__((packed)) acpi_mcfg_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t base;
|
|
||||||
uint16_t pci_segment_group;
|
|
||||||
uint8_t pci_start_bus;
|
|
||||||
uint8_t pci_end_bus;
|
|
||||||
uint32_t reserved;
|
|
||||||
} __attribute__((packed)) acpi_mcfg_device_config_T;
|
|
||||||
|
|
||||||
extern acpi_mcfg_T* g_acpi_table_mcfg;
|
|
||||||
|
|
||||||
#endif //NOXOS_MCFG_H
|
|
|
@ -1,27 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_RSDP_H
|
|
||||||
#define NOX_RSDP_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char signature [8];
|
|
||||||
uint8_t checksum;
|
|
||||||
char oem_id [6];
|
|
||||||
uint8_t revision;
|
|
||||||
uint32_t rsdt_address;
|
|
||||||
} __attribute__((packed)) rsdp_descriptor_v1_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
rsdp_descriptor_v1_T descriptor_v1;
|
|
||||||
uint32_t length;
|
|
||||||
uint64_t xsdt_address;
|
|
||||||
uint8_t checksum_extended;
|
|
||||||
uint8_t reserved [3];
|
|
||||||
} __attribute__((packed)) rsdp_descriptor_v2_T;
|
|
||||||
|
|
||||||
bool rsdp_descriptor_v1_verify(rsdp_descriptor_v1_T* descriptor);
|
|
||||||
bool rsdp_descriptor_v2_verify(rsdp_descriptor_v2_T* descriptor);
|
|
||||||
|
|
||||||
#endif //NOX_RSDP_H
|
|
|
@ -1,250 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_AHCI_H
|
|
||||||
#define NOXOS_AHCI_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "drivers/builtin/pci.h"
|
|
||||||
#include "drivers/builtin/drive_manager.h"
|
|
||||||
|
|
||||||
#define SATA_SIG_ATA 0x00000101
|
|
||||||
#define SATA_SIG_ATAPI 0xEB140101
|
|
||||||
#define SATA_SIG_SEMB 0xC33C0101
|
|
||||||
#define SATA_SIG_PORT_MULTIPLIER 0x96690101
|
|
||||||
|
|
||||||
#define ATA_DEVICE_BUSY 0x80
|
|
||||||
#define ATA_DEVICE_DRQ 0x08
|
|
||||||
#define ATA_CMD_READ_DMA_EX 0x25
|
|
||||||
#define ATA_CMD_WRITE_DMA_EX 0x35
|
|
||||||
|
|
||||||
#define HBA_PX_IS_TFES (1 << 30)
|
|
||||||
#define HBA_PX_COMMAND_CMD_LIST_RUNNING 0x8000
|
|
||||||
#define HBA_PX_COMMAND_START 0x0001
|
|
||||||
#define HBA_PX_COMMAND_FIS_RECV_ENABLE 0x0010
|
|
||||||
#define HBA_PX_COMMAND_FIS_RECV_RUNNING 0x4000
|
|
||||||
|
|
||||||
#define HBA_PORT_DEVICE_PRESENT 0x03
|
|
||||||
#define HBA_PORT_IPM_ACTIVE 0x01
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
AHCI_DEVICE_NONE,
|
|
||||||
AHCI_DEVICE_SATA,
|
|
||||||
AHCI_DEVICE_SEMB,
|
|
||||||
AHCI_DEVICE_PORT_MULTIPLIER,
|
|
||||||
AHCI_DEVICE_SATAPI,
|
|
||||||
|
|
||||||
AHCI_DEVICE_TYPE_END_OF_ENUM
|
|
||||||
} ahci_device_type_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
AHCI_FIS_REGISTER_HOST_TO_DEVICE = 0x27, // host --> device
|
|
||||||
AHCI_FIS_REGISTER_DEVICE_TO_HOST = 0x34, // host <-- device
|
|
||||||
AHCI_FIS_DMA_ACTIVATE = 0x39, // host <-- device
|
|
||||||
AHCI_FIS_DMA_SETUP = 0x41, // host <--> device
|
|
||||||
AHCI_FIS_DATA = 0x46, // host <--> device
|
|
||||||
AHCI_FIS_BIST = 0x58, // host <--> device
|
|
||||||
AHCI_FIS_PIO_SETUP = 0x5F, // host <-- device
|
|
||||||
AHCI_FIS_DEVICE_BITS = 0xA1 // host <-- device
|
|
||||||
} ahci_fis_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t port_multiplier:4;
|
|
||||||
uint8_t reserved_0:3;
|
|
||||||
uint8_t command_control_select:1;
|
|
||||||
uint8_t command;
|
|
||||||
uint8_t feature_0;
|
|
||||||
uint8_t lba_0;
|
|
||||||
uint8_t lba_1;
|
|
||||||
uint8_t lba_2;
|
|
||||||
uint8_t device;
|
|
||||||
uint8_t lba_3;
|
|
||||||
uint8_t lba_4;
|
|
||||||
uint8_t lba_5;
|
|
||||||
uint8_t feature_1;
|
|
||||||
uint8_t count_low;
|
|
||||||
uint8_t count_high;
|
|
||||||
uint8_t icc;
|
|
||||||
uint8_t control;
|
|
||||||
uint32_t reserved_1;
|
|
||||||
} ahci_fis_register_host_to_device_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t port_multiplier:4;
|
|
||||||
uint8_t reserved_0:2;
|
|
||||||
uint8_t interrupt:1;
|
|
||||||
uint8_t reserved_1:1;
|
|
||||||
uint8_t status;
|
|
||||||
uint8_t error;
|
|
||||||
uint8_t lba_0;
|
|
||||||
uint8_t lba_1;
|
|
||||||
uint8_t lba_2;
|
|
||||||
uint8_t device;
|
|
||||||
uint8_t lba_3;
|
|
||||||
uint8_t lba_4;
|
|
||||||
uint8_t lba_5;
|
|
||||||
uint8_t reserved_2;
|
|
||||||
uint16_t count;
|
|
||||||
uint16_t reserved_3;
|
|
||||||
uint32_t reserved_4;
|
|
||||||
} ahci_fis_register_device_to_host_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t port_multiplier:4;
|
|
||||||
uint8_t reserved_0:4;
|
|
||||||
uint16_t reserved_1;
|
|
||||||
uint32_t data; // this can be followed by more data
|
|
||||||
} ahci_fis_data_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t port_multiplier:4;
|
|
||||||
uint8_t reserved_0:1;
|
|
||||||
uint8_t transfer_direction:1;
|
|
||||||
uint8_t interrupt:1;
|
|
||||||
uint8_t reserved_1:1;
|
|
||||||
uint8_t status;
|
|
||||||
uint8_t error;
|
|
||||||
uint8_t lba_0;
|
|
||||||
uint8_t lba_1;
|
|
||||||
uint8_t lba_2;
|
|
||||||
uint8_t device;
|
|
||||||
uint8_t lba_3;
|
|
||||||
uint8_t lba_4;
|
|
||||||
uint8_t lba_5;
|
|
||||||
uint8_t reserved_2;
|
|
||||||
uint16_t count;
|
|
||||||
uint8_t reserved_3;
|
|
||||||
uint8_t new_status;
|
|
||||||
uint16_t transfer_count;
|
|
||||||
uint16_t reserved_4;
|
|
||||||
} ahci_fis_pio_setup_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t port_multiplier:4;
|
|
||||||
uint8_t reserved_0:1;
|
|
||||||
uint8_t transfer_direction:1;
|
|
||||||
uint8_t interrupt:1;
|
|
||||||
uint8_t auto_activate:1;
|
|
||||||
uint16_t reserved_1;
|
|
||||||
uint64_t dma_buffer_id;
|
|
||||||
uint32_t reserved_2;
|
|
||||||
uint32_t dma_buffer_offset;
|
|
||||||
uint32_t transfer_count;
|
|
||||||
uint32_t reserved_3;
|
|
||||||
} ahci_fis_dma_setup_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t command_list_base;
|
|
||||||
uint32_t command_list_base_upper;
|
|
||||||
uint32_t fis_base_address;
|
|
||||||
uint32_t fis_base_address_upper;
|
|
||||||
uint32_t interrupt_status;
|
|
||||||
uint32_t interrupt_enable;
|
|
||||||
uint32_t command_status;
|
|
||||||
uint32_t reserved_0;
|
|
||||||
uint32_t task_file_data;
|
|
||||||
uint32_t signature;
|
|
||||||
uint32_t sata_status;
|
|
||||||
uint32_t sata_control;
|
|
||||||
uint32_t sata_error;
|
|
||||||
uint32_t sata_active;
|
|
||||||
uint32_t command_issue;
|
|
||||||
uint32_t sata_notification;
|
|
||||||
uint32_t fis_switch_control;
|
|
||||||
uint32_t reserved_1 [11];
|
|
||||||
uint32_t vendor [4];
|
|
||||||
} ahci_hba_port_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t host_capability;
|
|
||||||
uint32_t global_host_control;
|
|
||||||
uint32_t interrupt_status;
|
|
||||||
uint32_t ports_implemented;
|
|
||||||
uint32_t version;
|
|
||||||
uint32_t ccc_control;
|
|
||||||
uint32_t ccc_ports;
|
|
||||||
uint32_t enclosure_management_location;
|
|
||||||
uint32_t enclosure_management_control;
|
|
||||||
uint32_t host_capabilities_extended;
|
|
||||||
uint32_t bios_handoff_control_status;
|
|
||||||
uint8_t reserved_0 [0x74];
|
|
||||||
uint8_t vendor [0x60];
|
|
||||||
ahci_hba_port_T ports [1];
|
|
||||||
} ahci_hba_memory_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t command_fis_length:5;
|
|
||||||
uint8_t atapi:1;
|
|
||||||
uint8_t write:1;
|
|
||||||
uint8_t prefetchable:1;
|
|
||||||
uint8_t reset:1;
|
|
||||||
uint8_t bist:1;
|
|
||||||
uint8_t clear_busy:1;
|
|
||||||
uint8_t reserved_0:1;
|
|
||||||
uint8_t port_multiplier:4;
|
|
||||||
uint16_t prdt_length;
|
|
||||||
uint32_t prdb_count;
|
|
||||||
uint32_t command_table_base_address;
|
|
||||||
uint32_t command_table_base_address_upper;
|
|
||||||
uint32_t reserved_1 [4];
|
|
||||||
} ahci_hba_command_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t data_base_address;
|
|
||||||
uint32_t data_base_address_upper;
|
|
||||||
uint32_t reserved_0;
|
|
||||||
uint32_t byte_count:22;
|
|
||||||
uint32_t reserved_1:9;
|
|
||||||
uint32_t interrupt_on_completion:1;
|
|
||||||
} ahci_hba_prdt_entry_T;
|
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
uint8_t command_fis [64];
|
|
||||||
uint8_t atapi_command [16];
|
|
||||||
uint8_t reserved [48];
|
|
||||||
ahci_hba_prdt_entry_T prdt_entry [];
|
|
||||||
} ahci_hba_command_table_T;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct ahci_controller_T ahci_controller_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
ahci_hba_port_T* hba_port;
|
|
||||||
ahci_device_type_E type;
|
|
||||||
ahci_controller_T* controller;
|
|
||||||
uint8_t id;
|
|
||||||
drive_T* drive;
|
|
||||||
|
|
||||||
void* cmd_list_base;
|
|
||||||
void* fis_base;
|
|
||||||
void* command_tables [32];
|
|
||||||
} ahci_port_T;
|
|
||||||
|
|
||||||
struct ahci_controller_T {
|
|
||||||
ahci_port_T ports [32];
|
|
||||||
int num_ports;
|
|
||||||
pci_device_T* pci_device;
|
|
||||||
ahci_hba_memory_T* abar;
|
|
||||||
};
|
|
||||||
|
|
||||||
ahci_controller_T* ahci_controller_alloc (pci_device_T* pci_device);
|
|
||||||
void ahci_controller_destruct (ahci_controller_T* controller);
|
|
||||||
|
|
||||||
void ahci_port_init (ahci_port_T* port);
|
|
||||||
void ahci_port_init_partitions_mbr (ahci_port_T* port);
|
|
||||||
void ahci_port_init_partitions_gpt (ahci_port_T* port);
|
|
||||||
void ahci_port_destruct (ahci_port_T* port);
|
|
||||||
ahci_device_type_E ahci_port_get_type (ahci_hba_port_T* port);
|
|
||||||
void ahci_port_command_stop (ahci_port_T* port);
|
|
||||||
void ahci_port_command_start (ahci_port_T* port);
|
|
||||||
bool ahci_port_read (ahci_port_T* port, uint64_t sector, uint32_t num_sectors, void* buffer_out);
|
|
||||||
bool ahci_port_write (ahci_port_T* port, uint64_t sector, uint32_t num_sectors, void* buffer_in);
|
|
||||||
|
|
||||||
|
|
||||||
extern string_t g_ahci_device_type_strings[AHCI_DEVICE_TYPE_END_OF_ENUM];
|
|
||||||
|
|
||||||
#endif //NOXOS_AHCI_H
|
|
|
@ -1,72 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_DRIVE_MANAGER_H
|
|
||||||
#define NOXOS_DRIVE_MANAGER_H
|
|
||||||
|
|
||||||
#include "drivers/builtin/fs/vfs.h"
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/bitmap.h"
|
|
||||||
|
|
||||||
#define DRIVE_CHUNK_SIZE 16
|
|
||||||
#define DRIVE_PARTITION_CHUNK_SIZE 16
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
DRIVE_CONTROLLER_AHCI
|
|
||||||
} drive_controller_types_E;
|
|
||||||
|
|
||||||
typedef struct drive_chunk_T drive_chunk_T;
|
|
||||||
typedef struct drive_partition_chunk_T drive_partition_chunk_T;
|
|
||||||
typedef struct drive_partition_T drive_partition_T;
|
|
||||||
typedef struct drive_T drive_T;
|
|
||||||
|
|
||||||
struct drive_partition_T{
|
|
||||||
drive_partition_chunk_T* chunk;
|
|
||||||
uint32_t id_in_chunk;
|
|
||||||
uint32_t id;
|
|
||||||
drive_T* drive;
|
|
||||||
fs_T filesystem;
|
|
||||||
uint32_t start_sector;
|
|
||||||
uint32_t end_sector;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct drive_T {
|
|
||||||
drive_chunk_T* chunk;
|
|
||||||
uint32_t id_in_chunk;
|
|
||||||
uint32_t id;
|
|
||||||
drive_partition_chunk_T* partitions_chunks;
|
|
||||||
drive_controller_types_E controller_type;
|
|
||||||
void* controller;
|
|
||||||
void* device;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct drive_chunk_T {
|
|
||||||
drive_T drives [DRIVE_CHUNK_SIZE];
|
|
||||||
bitmap_T drives_bitmap;
|
|
||||||
uint32_t num_drives;
|
|
||||||
drive_chunk_T* prev;
|
|
||||||
drive_chunk_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct drive_partition_chunk_T {
|
|
||||||
drive_partition_T partitions [DRIVE_PARTITION_CHUNK_SIZE];
|
|
||||||
bitmap_T partitions_bitmap;
|
|
||||||
uint32_t num_partitions;
|
|
||||||
drive_partition_chunk_T* prev;
|
|
||||||
drive_partition_chunk_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
drive_chunk_T* chunks;
|
|
||||||
} drive_manager_T;
|
|
||||||
|
|
||||||
drive_chunk_T* drive_chunk_alloc (drive_chunk_T* prev);
|
|
||||||
drive_partition_chunk_T* drive_partition_chunk_alloc (drive_partition_chunk_T* prev);
|
|
||||||
void drive_partition_chunk_destruct (drive_partition_chunk_T* chunk);
|
|
||||||
|
|
||||||
void drive_manager_init ();
|
|
||||||
drive_T* drive_manager_add_drive (drive_controller_types_E controller_type, void* controller, void* device);
|
|
||||||
void drive_manager_remove_drive (drive_T* drive);
|
|
||||||
drive_partition_T* drive_manager_add_partition (drive_T* drive, uint32_t start_sector, uint32_t end_sector);
|
|
||||||
void drive_manager_remove_partition (drive_partition_T* partition);
|
|
||||||
|
|
||||||
#endif //NOXOS_DRIVE_MANAGER_H
|
|
|
@ -1,23 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_DYNAMIC_H
|
|
||||||
#define NOXOS_DYNAMIC_H
|
|
||||||
|
|
||||||
#include <utils/stdtypes.h>
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ELF_DYNAMIC_TAG_NULL,
|
|
||||||
ELF_DYNAMIC_TAG_NEEDED,
|
|
||||||
ELF_DYNAMIC_TAG_PLT_REL_SIZE,
|
|
||||||
ELF_DYNAMIC_TAG_HASH,
|
|
||||||
ELF_DYNAMIC_TAG_STRTAB,
|
|
||||||
ELF_DYNAMIC_TAG_RELA,
|
|
||||||
ELF_DYNAMIC_TAG_RELA_SIZE
|
|
||||||
} elf_dynamic_tag_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t tag;
|
|
||||||
uint64_t value;
|
|
||||||
} elf_dynamic_T;
|
|
||||||
|
|
||||||
#endif //NOXOS_DYNAMIC_H
|
|
|
@ -1,30 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_ELF_H
|
|
||||||
#define NOX_ELF_H
|
|
||||||
|
|
||||||
#include "drivers/builtin/elf/header.h"
|
|
||||||
#include "drivers/builtin/elf/section.h"
|
|
||||||
#include "drivers/builtin/elf/mapping.h"
|
|
||||||
#include "utils/symbol.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
elf_header_T header;
|
|
||||||
symbol_table_T symbol_table;
|
|
||||||
uint64_t num_mappings;
|
|
||||||
elf_mapping_T* mappings;
|
|
||||||
void* string_table;
|
|
||||||
} elf_executable_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
elf_executable_T* executable;
|
|
||||||
elf_section_T* symbol_table;
|
|
||||||
elf_section_T* section_header_string_table;
|
|
||||||
|
|
||||||
uint8_t* buffer;
|
|
||||||
} elf_executable_temp_T;
|
|
||||||
|
|
||||||
elf_executable_T* elf_executable_create (uint8_t* buffer);
|
|
||||||
void elf_executable_destruct (elf_executable_T* executable);
|
|
||||||
|
|
||||||
#endif //NOX_ELF_H
|
|
|
@ -1,18 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_MAPPING_H
|
|
||||||
#define NOX_MAPPING_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "mm/page_map.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t offset_file;
|
|
||||||
uint64_t offset_virtual;
|
|
||||||
uint64_t length_file;
|
|
||||||
uint64_t length_virtual;
|
|
||||||
} elf_mapping_T;
|
|
||||||
|
|
||||||
void elf_mappings_apply(elf_mapping_T* mappings, uint64_t num_mappings, uint8_t* buffer, void* base, page_map_T* page_map);
|
|
||||||
|
|
||||||
#endif //NOX_MAPPING_H
|
|
|
@ -1,37 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_RELOCATION_H
|
|
||||||
#define NOXOS_RELOCATION_H
|
|
||||||
|
|
||||||
#include <utils/stdtypes.h>
|
|
||||||
#include <drivers/builtin/elf/elf.h>
|
|
||||||
|
|
||||||
#define ELF_RELOCATION_SYMBOL(i) ((i) >> 32)
|
|
||||||
#define ELF_RELOCATION_TYPE(i) ((i) & 0xFFFFFFFFL)
|
|
||||||
#define ELF_RELOCATION_INFO(s,t) (((s) << 32) + ((t) & 0xFFFFFFFFL))
|
|
||||||
|
|
||||||
#define ELF_RELOCATION_X86_64_PC32(s,a,p) (s + a - p)
|
|
||||||
#define ELF_RELOCATION_X86_64_PLT32(l,a,p) (l + a - p)
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ELF_REL_NONE,
|
|
||||||
ELF_REL_64,
|
|
||||||
ELF_REL_PC32,
|
|
||||||
ELF_REL_GOT32,
|
|
||||||
ELF_REL_PLT32,
|
|
||||||
ELF_REL_COPY,
|
|
||||||
ELF_REL_GLOB_DAT,
|
|
||||||
ELF_REL_JUMP_SLOT,
|
|
||||||
ELF_REL_RELATIVE
|
|
||||||
} elf_relocation_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t offset;
|
|
||||||
uint64_t info;
|
|
||||||
int64_t addend;
|
|
||||||
} elf_relocation_a_T;
|
|
||||||
|
|
||||||
//void elf_relocate (elf_executable_T* executable, uint8_t* buffer, void* address);
|
|
||||||
bool elf_relocate_driver(elf_executable_T* executable, uint8_t* buffer, void* load_address);
|
|
||||||
|
|
||||||
#endif //NOXOS_RELOCATION_H
|
|
|
@ -1,41 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_SECTION_H
|
|
||||||
#define NOX_SECTION_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ELF_SECTION_NULL,
|
|
||||||
ELF_SECTION_PROGRAM_DATA,
|
|
||||||
ELF_SECTION_SYMBOL_TABLE,
|
|
||||||
ELF_SECTION_STRING_TABLE,
|
|
||||||
ELF_SECTION_RELOCATION_A,
|
|
||||||
ELF_SECTION_HASH,
|
|
||||||
ELF_SECTION_DYNAMIC,
|
|
||||||
ELF_SECTION_NOTE,
|
|
||||||
ELF_SECTION_NOBITS,
|
|
||||||
ELF_SECTION_REL,
|
|
||||||
ELF_SECTION_SHLIB,
|
|
||||||
ELF_SECTION_DYNAMIC_SYMBOL_TABLE,
|
|
||||||
|
|
||||||
ELF_SECTION_ENUM_END
|
|
||||||
} elf_section_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t name_offset;
|
|
||||||
uint32_t type;
|
|
||||||
uint64_t flags;
|
|
||||||
uint64_t virtual_address;
|
|
||||||
uint64_t offset;
|
|
||||||
uint64_t length;
|
|
||||||
uint32_t link;
|
|
||||||
uint32_t info;
|
|
||||||
uint64_t alignment;
|
|
||||||
uint64_t entry_size;
|
|
||||||
} elf_section_T;
|
|
||||||
|
|
||||||
extern string_t g_elf_section_type_strings[ELF_SECTION_ENUM_END+1];
|
|
||||||
|
|
||||||
#endif //NOX_SECTION_H
|
|
|
@ -1,34 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_SEGMENT_H
|
|
||||||
#define NOX_SEGMENT_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ELF_SEGMENT_NULL,
|
|
||||||
ELF_SEGMENT_LOAD,
|
|
||||||
ELF_SEGMENT_DYNAMIC,
|
|
||||||
ELF_SEGMENT_INTERPRETER,
|
|
||||||
ELF_SEGMENT_NOTE,
|
|
||||||
ELF_SEGMENT_PROGRAM_HEADER_TABLE,
|
|
||||||
ELF_SEGMENT_TLS,
|
|
||||||
|
|
||||||
ELF_SEGMENT_ENUM_END
|
|
||||||
} elf_segment_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t type;
|
|
||||||
uint32_t flags;
|
|
||||||
uint64_t offset;
|
|
||||||
uint64_t address_virtual;
|
|
||||||
uint64_t address_physical;
|
|
||||||
uint64_t length_file;
|
|
||||||
uint64_t length_memory;
|
|
||||||
uint64_t align;
|
|
||||||
} elf_segment_T;
|
|
||||||
|
|
||||||
extern string_t g_elf_segment_type_strings[ELF_SEGMENT_ENUM_END+1];
|
|
||||||
|
|
||||||
#endif //NOX_SEGMENT_H
|
|
|
@ -1,32 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_ELF_SYMBOL_H
|
|
||||||
#define NOX_ELF_SYMBOL_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
#define ELF_SYMBOL_TYPE(info) ((info) & 0xF)
|
|
||||||
|
|
||||||
extern string_t g_elf_symbol_type_strings[7];
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ELF_SYMBOL_NONE,
|
|
||||||
ELF_SYMBOL_OBJECT,
|
|
||||||
ELF_SYMBOL_FUNC,
|
|
||||||
ELF_SYMBOL_SECTION,
|
|
||||||
ELF_SYMBOL_FILE,
|
|
||||||
ELF_SYMBOL_COMMON,
|
|
||||||
ELF_SYMBOL_TLS
|
|
||||||
} elf_symbol_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t name_offset;
|
|
||||||
uint8_t info;
|
|
||||||
uint8_t other;
|
|
||||||
uint16_t related_section_index;
|
|
||||||
uint64_t value;
|
|
||||||
uint64_t length;
|
|
||||||
} elf_symbol_T;
|
|
||||||
|
|
||||||
#endif //NOX_ELF_SYMBOL_H
|
|
|
@ -1,50 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_GPT_H
|
|
||||||
#define NOXOS_GPT_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GPT_PARTITION_GUID_UNUSED,
|
|
||||||
GPT_PARTITION_GUID_UNKNOWN,
|
|
||||||
GPT_PARTITION_GUID_PRIMARY,
|
|
||||||
GPT_PARTITION_GUID_EFI_SYSTEM,
|
|
||||||
|
|
||||||
GPT_PARTITION_GUID_ENUM_END
|
|
||||||
} gpt_partition_type_guids_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t signature [8];
|
|
||||||
uint32_t revision;
|
|
||||||
uint32_t header_size;
|
|
||||||
uint32_t checksum_crc32;
|
|
||||||
uint32_t reserved;
|
|
||||||
uint64_t current_lba;
|
|
||||||
uint64_t backup_lba;
|
|
||||||
uint64_t first_usable_lba;
|
|
||||||
uint64_t last_usable_lba;
|
|
||||||
uint8_t disk_guid [16];
|
|
||||||
uint64_t starting_lba;
|
|
||||||
uint32_t num_partitions;
|
|
||||||
uint32_t partition_entry_size;
|
|
||||||
uint32_t partition_entry_crc32;
|
|
||||||
uint8_t reserved2 [0x1A4];
|
|
||||||
}__attribute__((packed)) gpt_table_header_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t partition_type_guid [16];
|
|
||||||
uint8_t partition_guid [16];
|
|
||||||
uint64_t starting_lba;
|
|
||||||
uint64_t ending_lba;
|
|
||||||
uint64_t attributes;
|
|
||||||
uint16_t name [36]; // UTF-16 encoded
|
|
||||||
}__attribute__((packed)) gpt_partition_entry_T;
|
|
||||||
|
|
||||||
gpt_partition_type_guids_E gpt_get_partition_type (uint8_t guid[16]);
|
|
||||||
string_t gpt_partition_type_to_string(gpt_partition_type_guids_E type);
|
|
||||||
|
|
||||||
extern uint8_t g_gpt_partition_type_guides[GPT_PARTITION_GUID_ENUM_END][16];
|
|
||||||
|
|
||||||
#endif //NOXOS_GPT_H
|
|
|
@ -1,40 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_MBR_H
|
|
||||||
#define NOXOS_MBR_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MBR_PARTITION_TYPE_UNUSED = 0x00,
|
|
||||||
MBR_PARTITION_TYPE_GPT = 0xEE,
|
|
||||||
MBR_PARTITION_TYPE_EXT2 = 0x83,
|
|
||||||
MBR_PARTITION_TYPE_FAT12 = 0x01,
|
|
||||||
MBR_PARTITION_TYPE_FAT16 = 0x04,
|
|
||||||
MBR_PARTITION_TYPE_FAT32_CHS = 0x0B,
|
|
||||||
MBR_PARTITION_TYPE_FAT32_LBA = 0x0C
|
|
||||||
} mbr_partition_types_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t boot_indicator;
|
|
||||||
uint8_t start_head;
|
|
||||||
uint16_t start_sector:6;
|
|
||||||
uint16_t start_cylinder:10;
|
|
||||||
uint8_t partition_type;
|
|
||||||
uint8_t end_head;
|
|
||||||
uint16_t end_sector:6;
|
|
||||||
uint16_t end_cylinder:10;
|
|
||||||
uint32_t start_lba;
|
|
||||||
uint32_t num_sectors;
|
|
||||||
}__attribute__((packed)) mbr_partition_header_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t bootstrap [446];
|
|
||||||
mbr_partition_header_T partitions [4];
|
|
||||||
uint8_t signature [2];
|
|
||||||
} mbr_header_T;
|
|
||||||
|
|
||||||
string_t mbr_partition_type_to_string(mbr_partition_types_E type);
|
|
||||||
|
|
||||||
#endif //NOXOS_MBR_H
|
|
|
@ -1,13 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_RAMFS_H
|
|
||||||
#define NOX_RAMFS_H
|
|
||||||
|
|
||||||
#include "drivers/builtin/fs/vfs.h"
|
|
||||||
|
|
||||||
void ramfs_file_delete (vfs_node_T* node);
|
|
||||||
uint64_t ramfs_file_write (vfs_node_T* node, uint64_t size, uint8_t* buffer_in);
|
|
||||||
uint64_t ramfs_file_read (vfs_node_T* node, uint64_t size, uint8_t* buffer_out);
|
|
||||||
|
|
||||||
|
|
||||||
#endif //NOX_RAMFS_H
|
|
|
@ -1,37 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_USTAR_H
|
|
||||||
#define NOX_USTAR_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
USTAR_FILE,
|
|
||||||
USTAR_LINK_HARD,
|
|
||||||
USTAR_LINK_SYM,
|
|
||||||
USTAR_CHAR_DEVICE,
|
|
||||||
USTAR_BLOCK_DEVICE,
|
|
||||||
USTAR_DIRECTORY,
|
|
||||||
USTAR_PIPE
|
|
||||||
} ustar_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char name [100];
|
|
||||||
uint64_t mode;
|
|
||||||
uint64_t owner_id;
|
|
||||||
uint64_t group_id;
|
|
||||||
char size [12]; // octal based string (don't ask me why, the ustar standard is weird)
|
|
||||||
char last_modification [12]; // unix timestamp (octal)
|
|
||||||
uint64_t checksum;
|
|
||||||
uint8_t type;
|
|
||||||
char name_linked [100];
|
|
||||||
char indicator [6];
|
|
||||||
uint16_t version;
|
|
||||||
char owner_user_name [32];
|
|
||||||
char owner_group_name [32];
|
|
||||||
uint64_t device_major;
|
|
||||||
uint64_t device_minor;
|
|
||||||
char name_prefix [155];
|
|
||||||
}__attribute__((packed)) __attribute__((aligned(512))) ustar_header_T;
|
|
||||||
|
|
||||||
#endif //NOX_USTAR_H
|
|
|
@ -1,34 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_COLOR_H
|
|
||||||
#define NOX_COLOR_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
// Colors from https://gogh-co.github.io/Gogh/
|
|
||||||
typedef enum {
|
|
||||||
COLOR_PAL_GREY_DARK,
|
|
||||||
COLOR_PAL_PINK,
|
|
||||||
COLOR_PAL_GREEN_SIGNAL,
|
|
||||||
COLOR_PAL_ORANGE,
|
|
||||||
COLOR_PAL_BLUE,
|
|
||||||
COLOR_PAL_PURPLE,
|
|
||||||
COLOR_PAL_GREEN,
|
|
||||||
COLOR_PAL_GREY_LIGHT,
|
|
||||||
COLOR_PAL_RED,
|
|
||||||
|
|
||||||
COLOR_PAL_ENUM_END
|
|
||||||
} color_palette_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t alpha;
|
|
||||||
uint8_t red;
|
|
||||||
uint8_t green;
|
|
||||||
uint8_t blue;
|
|
||||||
} color_argb_T;
|
|
||||||
|
|
||||||
extern color_argb_T g_color_palette[COLOR_PAL_ENUM_END];
|
|
||||||
|
|
||||||
color_argb_T color_argb_blend_alpha(color_argb_T background, color_argb_T foreground);
|
|
||||||
|
|
||||||
#endif //NOX_COLOR_H
|
|
|
@ -1,17 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_FONT_H
|
|
||||||
#define NOX_FONT_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t width;
|
|
||||||
uint8_t height;
|
|
||||||
uint8_t glyph_size;
|
|
||||||
uint8_t* buffer;
|
|
||||||
} font_T;
|
|
||||||
|
|
||||||
extern font_T g_font;
|
|
||||||
|
|
||||||
#endif //NOX_FONT_H
|
|
|
@ -1,20 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_FRAMEBUFFER_H
|
|
||||||
#define NOX_FRAMEBUFFER_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void* address;
|
|
||||||
uint64_t width;
|
|
||||||
uint64_t height;
|
|
||||||
uint64_t pitch;
|
|
||||||
uint16_t bits_per_pixel;
|
|
||||||
uint8_t bytes_per_pixel;
|
|
||||||
uint8_t shift_red;
|
|
||||||
uint8_t shift_green;
|
|
||||||
uint8_t shift_blue;
|
|
||||||
} framebuffer_T;
|
|
||||||
|
|
||||||
#endif //NOX_FRAMEBUFFER_H
|
|
|
@ -1,62 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_RENDERER_H
|
|
||||||
#define NOX_RENDERER_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
#include "utils/math.h"
|
|
||||||
#include "drivers/builtin/graphics/color.h"
|
|
||||||
#include "drivers/builtin/graphics/font.h"
|
|
||||||
#include "drivers/builtin/graphics/framebuffer.h"
|
|
||||||
#include "boot/boot_info.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GRAPHICS_BUFFER_STANDARD,
|
|
||||||
GRAPHICS_BUFFER_OVERLAY,
|
|
||||||
|
|
||||||
GRAPHICS_BUFFER_ENUM_MAX
|
|
||||||
} graphics_buffer_layer_E;
|
|
||||||
|
|
||||||
typedef struct graphics_buffer_T graphics_buffer_T;
|
|
||||||
struct graphics_buffer_T {
|
|
||||||
color_argb_T* buffer;
|
|
||||||
uint32_t width;
|
|
||||||
uint32_t height;
|
|
||||||
uint32_t pos_x;
|
|
||||||
uint32_t pos_y;
|
|
||||||
bool blocked;
|
|
||||||
bool render;
|
|
||||||
graphics_buffer_layer_E layer;
|
|
||||||
graphics_buffer_T* prev;
|
|
||||||
graphics_buffer_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
framebuffer_T framebuffer;
|
|
||||||
uint32_t* back_buffer;
|
|
||||||
uint64_t buffer_size;
|
|
||||||
graphics_buffer_T** graphics_buffer_layers;
|
|
||||||
font_T font;
|
|
||||||
bool initialized;
|
|
||||||
bool blocked;
|
|
||||||
} graphics_renderer_T;
|
|
||||||
|
|
||||||
graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer);
|
|
||||||
void graphics_buffer_show (graphics_buffer_T* graphics_buffer);
|
|
||||||
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer);
|
|
||||||
void graphics_buffer_move (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y);
|
|
||||||
void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer);
|
|
||||||
void graphics_buffer_shift_up (graphics_buffer_T* graphics_buffer, uint16_t shift);
|
|
||||||
void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color);
|
|
||||||
color_argb_T graphics_buffer_get_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y);
|
|
||||||
void graphics_buffer_draw_char (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, char chr);
|
|
||||||
position_T graphics_buffer_draw_string (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, string_t string);
|
|
||||||
|
|
||||||
void graphics_renderer_init (boot_info_T* boot_info);
|
|
||||||
void graphics_renderer_update ();
|
|
||||||
graphics_buffer_T* graphics_renderer_get_top_buffer (graphics_buffer_layer_E layer);
|
|
||||||
uint32_t graphics_renderer_get_width ();
|
|
||||||
uint32_t graphics_renderer_get_height ();
|
|
||||||
|
|
||||||
#endif //NOX_RENDERER_H
|
|
|
@ -1,98 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_JSON_H
|
|
||||||
#define NOXOS_JSON_H
|
|
||||||
|
|
||||||
#include "utils/string.h"
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* JSON node schematic
|
|
||||||
*
|
|
||||||
* +-----------+
|
|
||||||
* +----------| Root Node |------------+
|
|
||||||
* | +-----------+ |
|
|
||||||
* | ^ |
|
|
||||||
* | | |
|
|
||||||
* [childs_start] /----[parent]------\ [childs_end]
|
|
||||||
* | / | \ |
|
|
||||||
* v / | \ v
|
|
||||||
* +------+ +------+ +------+
|
|
||||||
* | Node |--[next]->| Node |--[next]->| Node |
|
|
||||||
* | |<-[prev]--| |<-[prev]--| | ---> . . .
|
|
||||||
* +------+ +------+ +------+
|
|
||||||
*
|
|
||||||
* |
|
|
||||||
* v
|
|
||||||
* . . .
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
|
|
||||||
#define JSON_INCREMENT_TOKEN_ID \
|
|
||||||
*token_id += 1; \
|
|
||||||
/* DEBUG("token: %d - %s", *token_id, json->tokens[*token_id].string);*/ \
|
|
||||||
if (*token_id >= json->num_tokens) { \
|
|
||||||
log(LOG_ERROR, "failed to parse json -> unexpected EOF"); \
|
|
||||||
json_node_dump(json->root_node, 0); \
|
|
||||||
return false; \
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
JSON_TOKEN_NUMERIC,
|
|
||||||
JSON_TOKEN_TEXT,
|
|
||||||
JSON_TOKEN_STRING,
|
|
||||||
JSON_TOKEN_SPECIAL
|
|
||||||
} json_token_type_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
JSON_NODE_OBJECT,
|
|
||||||
JSON_NODE_ARRAY,
|
|
||||||
JSON_NODE_STRING,
|
|
||||||
JSON_NODE_NUMBER,
|
|
||||||
JSON_NODE_BOOL,
|
|
||||||
JSON_NODE_NULL
|
|
||||||
} json_node_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
json_token_type_E type;
|
|
||||||
uint64_t value;
|
|
||||||
string_t string;
|
|
||||||
|
|
||||||
uint32_t line;
|
|
||||||
uint32_t column;
|
|
||||||
} json_token_T;
|
|
||||||
|
|
||||||
typedef struct json_node_T json_node_T;
|
|
||||||
struct json_node_T {
|
|
||||||
json_node_type_E type;
|
|
||||||
string_t string;
|
|
||||||
uint64_t value;
|
|
||||||
|
|
||||||
json_node_T* parent;
|
|
||||||
json_node_T* childs_start;
|
|
||||||
json_node_T* childs_end;
|
|
||||||
json_node_T* prev;
|
|
||||||
json_node_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
json_token_T* tokens;
|
|
||||||
uint64_t num_tokens;
|
|
||||||
void* string_buffer;
|
|
||||||
json_node_T* root_node;
|
|
||||||
} json_T;
|
|
||||||
|
|
||||||
json_T* json_from_string (string_t str);
|
|
||||||
void json_destruct (json_T* json);
|
|
||||||
json_node_T* json_node_alloc (json_node_T* parent, json_node_type_E type, json_token_T* token);
|
|
||||||
void json_node_destruct (json_node_T* node);
|
|
||||||
void json_node_dump (json_node_T* node, uint32_t indent);
|
|
||||||
string_t json_node_type_to_string (json_node_type_E type);
|
|
||||||
void json_tokenize (json_T* json, string_t str);
|
|
||||||
bool json_parse (json_T* json);
|
|
||||||
bool json_parse_assignment (json_T* json, uint32_t* token_id, json_node_T* node);
|
|
||||||
bool json_parse_object (json_T* json, uint32_t* token_id, json_node_T* node);
|
|
||||||
bool json_parse_array (json_T* json, uint32_t* token_id, json_node_T* node);
|
|
||||||
|
|
||||||
#endif //NOXOS_JSON_H
|
|
|
@ -1,255 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_PCI_H
|
|
||||||
#define NOXOS_PCI_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_CLASS_UNCLASSIFIED = 0x00,
|
|
||||||
PCI_CLASS_MASS_STORAGE_CONTROLLER = 0x01,
|
|
||||||
PCI_CLASS_NETWORK_CONTROLLER = 0x02,
|
|
||||||
PCI_CLASS_DISPLAY_CONTROLLER = 0x03,
|
|
||||||
PCI_CLASS_MULTIMEDIA_CONTROLLER = 0x04,
|
|
||||||
PCI_CLASS_MEMORY_CONTROLLER = 0x05,
|
|
||||||
PCI_CLASS_BRIDGE = 0x06,
|
|
||||||
PCI_CLASS_SIMPLE_COMMUNICATION_CONTROLLER = 0x07,
|
|
||||||
PCI_CLASS_BASE_SYSTEM_PERIPHERAL = 0x08,
|
|
||||||
PCI_CLASS_INPUT_DEVICE_CONTROLLER = 0x09,
|
|
||||||
PCI_CLASS_DOCKING_STATION = 0x0a,
|
|
||||||
PCI_CLASS_PROCESSOR = 0x0b,
|
|
||||||
PCI_CLASS_SERIAL_BUS_CONTROLLER = 0x0c,
|
|
||||||
PCI_CLASS_WIRELESS_CONTROLLER = 0x0d,
|
|
||||||
PCI_CLASS_INTELLIGENT_CONTROLLER = 0x0e,
|
|
||||||
PCI_CLASS_SATELLITE_COMMUNICATION_CONTROLLER = 0x0f,
|
|
||||||
PCI_CLASS_ENCRYPTION_CONTROLLER = 0x10,
|
|
||||||
PCI_CLASS_SIGNAL_PROCESSING_CONTROLLER = 0x11,
|
|
||||||
PCI_CLASS_PROCESSING_ACCELERATOR = 0x12,
|
|
||||||
PCI_CLASS_NON_ESSENTIAL_INSTRUMENTATION = 0x13,
|
|
||||||
PCI_CLASS_COPROCESSOR = 0x40
|
|
||||||
} pci_class_E;
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_NON_VGA_COMPATIBLE_UNCLASSIFIED_DEVICE = 0x00,
|
|
||||||
PCI_SUBCLASS_VGA_COMPATIBLE_UNCLASSIFIED_DEVICE = 0x01
|
|
||||||
} pci_unclassified_sublasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_SCSI_BUS_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_IDE_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_FLOPPY_DISK_CONTROLLER = 0x02,
|
|
||||||
PCI_SUBCLASS_IPI_BUS_CONTROLLER = 0x03,
|
|
||||||
PCI_SUBCLASS_RAID_CONTROLLER = 0x04,
|
|
||||||
PCI_SUBCLASS_ATA_CONTROLLER = 0x05,
|
|
||||||
PCI_SUBCLASS_SERIAL_ATA_CONTROLLER = 0x06,
|
|
||||||
PCI_SUBCLASS_SERIAL_ATTACHED_SCSI_CONTROLLER = 0x07,
|
|
||||||
PCI_SUBCLASS_NON_VOLATILE_MEMORY_CONTROLLER = 0x08,
|
|
||||||
PCI_SUBCLASS_OTHER_MASS_STORAGE_CONTROLLER = 0x80
|
|
||||||
} pci_mass_storage_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_ETHERNET_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_TOKEN_RING_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_FDDI_CONTROLLER = 0x02,
|
|
||||||
PCI_SUBCLASS_ATM_CONTROLLER = 0x03,
|
|
||||||
PCI_SUBCLASS_ISDN_CONTROLLER = 0x04,
|
|
||||||
PCI_SUBCLASS_WORLDFIP_CONTROLLER = 0x05,
|
|
||||||
PCI_SUBCLASS_PICMG_2_14_MULTI_COMPUTING_CONTROLLER = 0x06,
|
|
||||||
PCI_SUBCLASS_INFINIBAND_NETWORKCONTROLLER = 0x07,
|
|
||||||
PCI_SUBCLASS_FABRIC_CONTROLLER = 0x08,
|
|
||||||
PCI_SUBCLASS_OTHER_NETWORK_CONTROLLER = 0x80
|
|
||||||
} pci_network_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_VGA_COMPATIBLE_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_XGA_COMPATIBLE_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_3D_CONTROLLER_NOT_VGA_COMPATIBLE = 0x02,
|
|
||||||
PCI_SUBCLASS_OTHER_DISPLAY_CONTROLLER = 0x80
|
|
||||||
} pci_display_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_MULTIMEDIA_VIDEO_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_MULTIMEDIA_AUDIO_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_COMPUTER_TELEPHONY_DEVICE = 0x02,
|
|
||||||
PCI_SUBCLASS_AUDIO_DEVICE = 0x03,
|
|
||||||
PCI_SUBCLASS_OTHER_MULTIMEDIA_CONTROLLER = 0x80
|
|
||||||
} pci_multimedia_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_RAM_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_FLASH_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_OTHER_MEMORY_CONTROLLER = 0x80
|
|
||||||
} pci_memory_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_HOST_BRIDGE = 0x00,
|
|
||||||
PCI_SUBCLASS_ISA_BRIDGE = 0x01,
|
|
||||||
PCI_SUBCLASS_EISA_BRIDGE = 0x02,
|
|
||||||
PCI_SUBCLASS_MCA_BRIDGE = 0x03,
|
|
||||||
PCI_SUBCLASS_PCI_TO_PCI_BRIDGE = 0x04,
|
|
||||||
PCI_SUBCLASS_PCMCIA_BRIDGE = 0x05,
|
|
||||||
PCI_SUBCLASS_NUBUS_BRIDGE = 0x06,
|
|
||||||
PCI_SUBCLASS_CARDBUS_BRIDGE = 0x07,
|
|
||||||
PCI_SUBCLASS_RACEWAY_BRIDGE = 0x08,
|
|
||||||
PCI_SUBCLASS_PCI_TO_PCI_BRIDGE_2 = 0x09,
|
|
||||||
PCI_SUBCLASS_INFINIBAND_TO_PCI_HOST_BRIDGE = 0x0a,
|
|
||||||
PCI_SUBCLASS_OTHER_BRIDGE = 0x80
|
|
||||||
} pci_bridge_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_SERIAL_SIMPLE_COMMUNICATION_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_PARALLEL_SIMPLE_COMMUNICATION_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_MULTIPORT_SERIAL_CONTROLLER = 0x02,
|
|
||||||
PCI_SUBCLASS_MODEM = 0x03,
|
|
||||||
PCI_SUBCLASS_IEEE_488_1_2_GPIB_CONTROLLER = 0x04,
|
|
||||||
PCI_SUBCLASS_SMART_CARD_CONTROLLER = 0x05,
|
|
||||||
PCI_SUBCLASS_OTHER_SIMPLE_COMMUNICATION_CONTROLLER = 0x80
|
|
||||||
} pci_simple_communication_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_PIC = 0x00,
|
|
||||||
PCI_SUBCLASS_DMA_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_TIMER = 0x02,
|
|
||||||
PCI_SUBCLASS_RTC_CONTROLLER = 0x03,
|
|
||||||
PCI_SUBCLASS_PCI_HOT_PLUG_CONTROLLER = 0x04,
|
|
||||||
PCI_SUBCLASS_SD_HOST_CONTROLLER = 0x05,
|
|
||||||
PCI_SUBCLASS_IOMMU = 0x06,
|
|
||||||
PCI_SUBCLASS_OTHER_BASE_SYSTEM_PERIPHERAL = 0x80
|
|
||||||
} pci_base_system_peripheral_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_KEYBOARD_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_DIGITIZER_PEN = 0x01,
|
|
||||||
PCI_SUBCLASS_MOUSE_CONTROLLER = 0x02,
|
|
||||||
PCI_SUBCLASS_SCANNER_CONTROLLER = 0x03,
|
|
||||||
PCI_SUBCLASS_GAMEPORT_CONTROLLER = 0x04,
|
|
||||||
PCI_SUBCLASS_OTHER_INPUT_DEVICE_CONTROLLER = 0x80
|
|
||||||
} pci_input_device_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_GENERIC_DOCKING_STATION = 0x00,
|
|
||||||
PCI_SUBCLASS_OTHER_DOCKING_STATION = 0x80
|
|
||||||
} pci_docking_station_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_386_PROCESSOR = 0x00,
|
|
||||||
PCI_SUBCLASS_486_PROCESSOR = 0x01,
|
|
||||||
PCI_SUBCLASS_PENTIUM_PROCESSOR = 0x02,
|
|
||||||
PCI_SUBCLASS_PENTIUM_PRO_PROCESSOR = 0x03,
|
|
||||||
PCI_SUBCLASS_ALPHA_PROCESSOR = 0x10,
|
|
||||||
PCI_SUBCLASS_POWERPC_PROCESSOR = 0x20,
|
|
||||||
PCI_SUBCLASS_MIPS_PROCESSOR = 0x30,
|
|
||||||
PCI_SUBCLASS_COPROCESSOR = 0x40,
|
|
||||||
PCI_SUBCLASS_OTHER_PROCESSOR = 0x80
|
|
||||||
} pci_processor_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_FIREWIRE_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_ACCESS_BUS_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_SSA = 0x02,
|
|
||||||
PCI_SUBCLASS_USB_CONTROLLER = 0x03,
|
|
||||||
PCI_SUBCLASS_FIBRE_CHANNEL = 0x04,
|
|
||||||
PCI_SUBCLASS_SMBUS_CONTROLLER = 0x05,
|
|
||||||
PCI_SUBCLASS_INFINIBAND_SERIAL_BUS_CONTROLLER = 0x06,
|
|
||||||
PCI_SUBCLASS_IPMI_INTERFACE = 0x07,
|
|
||||||
PCI_SUBCLASS_SERCOS_INTERFACE = 0x08,
|
|
||||||
PCI_SUBCLASS_CANBUS_CONTROLLER = 0x09,
|
|
||||||
PCI_SUBCLASS_OTHER_SERIAL_BUS_CONTROLLER = 0x80
|
|
||||||
} pci_serial_bus_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_IRDA_COMPATIBLE_CONTROLLER = 0x00,
|
|
||||||
PCI_SUBCLASS_CONSUMER_IR_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_RF_CONTROLLER = 0x10,
|
|
||||||
PCI_SUBCLASS_BLUETOOTH_CONTROLLER = 0x11,
|
|
||||||
PCI_SUBCLASS_BROADBAND_CONTROLLER = 0x12,
|
|
||||||
PCI_SUBCLASS_ETHERNET_CONTROLLER_802_1A = 0x20,
|
|
||||||
PCI_SUBCLASS_ETHERNET_CONTROLLER_802_1B = 0x21,
|
|
||||||
PCI_SUBCLASS_OTHER_WIRELESS_CONTROLLER = 0x80
|
|
||||||
} pci_wireless_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_I20_INTELLIGENT_CONTROLLER = 0x00
|
|
||||||
} pci_intelligent_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_SATELLITE_TV_CONTROLLER = 0x01,
|
|
||||||
PCI_SUBCLASS_SATELLITE_AUDIO_CONTROLLER = 0x02,
|
|
||||||
PCI_SUBCLASS_SATELLITE_VOICE_CONTROLLER = 0x03,
|
|
||||||
PCI_SUBCLASS_SATELLITE_DATA_CONTROLLER = 0x04
|
|
||||||
} pci_satellite_communication_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_NETWORK_AND_COMPUTING_ENCRYPTION_DECRYPTION = 0x00,
|
|
||||||
PCI_SUBCLASS_ENTERTAINMENT_ENCRYPTION_DECRYPTION = 0x10,
|
|
||||||
PCI_SUBCLASS_OTHER_ENCRYPTION_CONTROLLER = 0x80
|
|
||||||
} pci_encryption_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PCI_SUBCLASS_DPIO_MODULES = 0x00,
|
|
||||||
PCI_SUBCLASS_PERFORMANCE_COUNTERS = 0x01,
|
|
||||||
PCI_SUBCLASS_COMMUNICATION_SYNCHRONIZER = 0x10,
|
|
||||||
PCI_SUBCLASS_SIGNAL_PROCESSING_MANAGEMENT = 0x20,
|
|
||||||
PCI_SUBCLASS_OTHER_SIGNAL_PROCESSING_CONTROLLER = 0x80
|
|
||||||
} pci_signal_processing_controller_subclasses_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t vendor_id;
|
|
||||||
uint16_t device_id;
|
|
||||||
uint16_t command_reg;
|
|
||||||
uint16_t status_reg;
|
|
||||||
uint8_t revision_id;
|
|
||||||
uint8_t progif; // Programming Interface Byte
|
|
||||||
uint8_t subclass;
|
|
||||||
uint8_t main_class;
|
|
||||||
uint8_t cache_line_size;
|
|
||||||
uint8_t latency_timer;
|
|
||||||
uint8_t header_type;
|
|
||||||
uint8_t bist; // Built-in Self-Test
|
|
||||||
} __attribute__((packed)) pci_device_header_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
pci_device_header_T header;
|
|
||||||
uint32_t bar0;
|
|
||||||
uint32_t bar1;
|
|
||||||
uint32_t bar2;
|
|
||||||
uint32_t bar3;
|
|
||||||
uint32_t bar4;
|
|
||||||
uint32_t bar5;
|
|
||||||
uint32_t cardbus_cis_pointer;
|
|
||||||
uint16_t subsystem_vendor_id;
|
|
||||||
uint16_t subsystem_id;
|
|
||||||
uint32_t expansion_rom_base_address;
|
|
||||||
uint8_t capabilities;
|
|
||||||
uint8_t reserved[7];
|
|
||||||
uint8_t interrupt_line;
|
|
||||||
uint8_t interrupt_pin;
|
|
||||||
uint8_t min_grant;
|
|
||||||
uint8_t max_latency;
|
|
||||||
} __attribute__((packed)) pci_header_0_T;
|
|
||||||
|
|
||||||
typedef struct pci_device_T pci_device_T;
|
|
||||||
struct pci_device_T {
|
|
||||||
pci_device_header_T* header;
|
|
||||||
void* specific;
|
|
||||||
pci_device_T* prev;
|
|
||||||
pci_device_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
pci_device_T* devices;
|
|
||||||
} pci_manager_T;
|
|
||||||
|
|
||||||
void pci_init ();
|
|
||||||
|
|
||||||
void pci_manager_add_device (pci_device_header_T* header);
|
|
||||||
void pci_manager_remove_device (pci_device_T* device);
|
|
||||||
pci_device_T* pci_manager_find_device (pci_class_E class, uint8_t subclass, uint8_t progif);
|
|
||||||
void pci_manager_dump_devices ();
|
|
||||||
|
|
||||||
string_t pci_get_subclass_string (pci_class_E class, uint8_t subclass);
|
|
||||||
string_t pci_get_vendor_string (uint16_t vendor_id);
|
|
||||||
|
|
||||||
#endif // NOXOS_PCI_H
|
|
|
@ -1,23 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_CONTROLLER_H
|
|
||||||
#define NOX_CONTROLLER_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
#define PS2_CONTROLLER_DATA_PORT 0x60
|
|
||||||
#define PS2_CONTROLLER_STATUS_PORT 0x64
|
|
||||||
#define PS2_CONTROLLER_COMMAND_PORT 0x64
|
|
||||||
|
|
||||||
#define PS2_CONTROLLER_TIMEOUT 0xFFFFF
|
|
||||||
|
|
||||||
void ps2_controller_init ();
|
|
||||||
uint8_t ps2_controller_command (uint8_t command);
|
|
||||||
uint8_t ps2_controller_command_with_data (uint8_t command, uint8_t data);
|
|
||||||
bool ps2_controller_command_has_response (uint8_t command);
|
|
||||||
bool ps2_controller_wait_until_ready_for_input ();
|
|
||||||
bool ps2_controller_wait_until_ready_for_output ();
|
|
||||||
uint8_t ps2_controller_read_data ();
|
|
||||||
void ps2_controller_write_data (uint8_t data);
|
|
||||||
|
|
||||||
#endif //NOX_CONTROLLER_H
|
|
|
@ -1,39 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_KEYBOARD_H
|
|
||||||
#define NOX_KEYBOARD_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PS2_KEYBOARD_COMMAND_SET_LEDS = 0xED,
|
|
||||||
PS2_KEYBOARD_COMMAND_ECHO = 0xEE,
|
|
||||||
PS2_KEYBOARD_COMMAND_SET_SCANCODE_SET = 0xF0,
|
|
||||||
PS2_KEYBOARD_COMMAND_IDENTIFY = 0xF2,
|
|
||||||
PS2_KEYBOARD_COMMAND_SET_TYPEMATIC = 0xF3,
|
|
||||||
PS2_KEYBOARD_COMMAND_ENABLE_SCAN = 0xF4,
|
|
||||||
PS2_KEYBOARD_COMMAND_DISABLE_SCAN = 0xF5,
|
|
||||||
PS2_KEYBOARD_COMMAND_SET_DEFAULT_PARAMS = 0xF6,
|
|
||||||
PS2_KEYBOARD_COMMAND_RESEND_LAST_BYTE = 0xFE,
|
|
||||||
PS2_KEYBOARD_COMMAND_SELF_TEST = 0xFF
|
|
||||||
} ps2_keyboard_command_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PS2_KEYBOARD_RESPONSE_KEY_DETECTION_ERROR_1 = 0x00,
|
|
||||||
PS2_KEYBOARD_RESPONSE_SELF_TEST_PASSED = 0xAA,
|
|
||||||
PS2_KEYBOARD_RESPONSE_ECHO = 0xEE,
|
|
||||||
PS2_KEYBOARD_RESPONSE_ACKNOWLEDGED = 0xFA,
|
|
||||||
PS2_KEYBOARD_RESPONSE_SELF_TEST_FAILED_1 = 0xFC,
|
|
||||||
PS2_KEYBOARD_RESPONSE_SELF_TEST_FAILED_2 = 0xFD,
|
|
||||||
PS2_KEYBOARD_RESPONSE_RESEND = 0xFE,
|
|
||||||
PS2_KEYBOARD_RESPONSE_KEY_DETECTION_ERROR_2 = 0xFF
|
|
||||||
} ps2_keyboard_response_E;
|
|
||||||
|
|
||||||
uint8_t ps2_keyboard_command (ps2_keyboard_command_E command);
|
|
||||||
void ps2_keyboard_init ();
|
|
||||||
void ps2_keyboard_read ();
|
|
||||||
string_t ps2_keyboard_command_to_string (ps2_keyboard_command_E command);
|
|
||||||
|
|
||||||
#endif //NOX_KEYBOARD_H
|
|
|
@ -1,38 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_SCANCODES_H
|
|
||||||
#define NOX_SCANCODES_H
|
|
||||||
|
|
||||||
#define PS2_SCANCODE_SET_1_ESCAPE 0x01
|
|
||||||
#define PS2_SCANCODE_SET_1_BACKSPACE 0x0E
|
|
||||||
#define PS2_SCANCODE_SET_1_TABULATOR 0x0F
|
|
||||||
#define PS2_SCANCODE_SET_1_RETURN 0x1C
|
|
||||||
#define PS2_SCANCODE_SET_1_SHIFT_LEFT 0x2A
|
|
||||||
#define PS2_SCANCODE_SET_1_SHIFT_RIGHT 0x36
|
|
||||||
#define PS2_SCANCODE_SET_1_ALT_LEFT 0x38
|
|
||||||
#define PS2_SCANCODE_SET_1_SPACE 0x39
|
|
||||||
#define PS2_SCANCODE_SET_1_CAPSLOCK 0x3A
|
|
||||||
#define PS2_SCANCODE_SET_1_NUMLOCK 0x45
|
|
||||||
#define PS2_SCANCODE_SET_1_SCROLLLOCK 0x46
|
|
||||||
#define PS2_SCANCODE_SET_1_F1 0x3B
|
|
||||||
#define PS2_SCANCODE_SET_1_F2 0x3C
|
|
||||||
#define PS2_SCANCODE_SET_1_F3 0x3D
|
|
||||||
#define PS2_SCANCODE_SET_1_F4 0x3E
|
|
||||||
#define PS2_SCANCODE_SET_1_F5 0x3F
|
|
||||||
#define PS2_SCANCODE_SET_1_F6 0x40
|
|
||||||
#define PS2_SCANCODE_SET_1_F7 0x41
|
|
||||||
#define PS2_SCANCODE_SET_1_F8 0x42
|
|
||||||
#define PS2_SCANCODE_SET_1_F9 0x43
|
|
||||||
#define PS2_SCANCODE_SET_1_F10 0x44
|
|
||||||
#define PS2_SCANCODE_SET_1_F11 0x57
|
|
||||||
#define PS2_SCANCODE_SET_1_F12 0x58
|
|
||||||
|
|
||||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_UP 0x48
|
|
||||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_LEFT 0x4B
|
|
||||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_RIGHT 0x4D
|
|
||||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_DOWN 0x50
|
|
||||||
|
|
||||||
#define PS2_SCANCODE_SET_1_RELEASE 0x80
|
|
||||||
#define PS2_SCANCODE_SET_1_MODIFIER 0xE0
|
|
||||||
|
|
||||||
#endif //NOX_SCANCODES_H
|
|
|
@ -1,13 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_PIT_H
|
|
||||||
#define NOX_PIT_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
#define PIT_CHANNEL_0_PORT 0x40
|
|
||||||
#define PIT_DIVISOR 32768 // This gives an interrupt every ~27.46ms
|
|
||||||
|
|
||||||
void pit_set_divisor(uint16_t divisor);
|
|
||||||
|
|
||||||
#endif //NOX_PIT_H
|
|
|
@ -1,25 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_TTY_H
|
|
||||||
#define NOXOS_TTY_H
|
|
||||||
|
|
||||||
#include "drivers/builtin/graphics/renderer.h"
|
|
||||||
#include "utils/stream.h"
|
|
||||||
#include "proc/pipe.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
graphics_buffer_T* graphics_buffer;
|
|
||||||
pipe_T* output;
|
|
||||||
pipe_T input;
|
|
||||||
graphics_buffer_T* cursor_overlay;
|
|
||||||
position_T cursor;
|
|
||||||
color_argb_T color;
|
|
||||||
} tty_T;
|
|
||||||
|
|
||||||
void tty_init ();
|
|
||||||
void tty_update ();
|
|
||||||
uint32_t tty_write (string_t string);
|
|
||||||
|
|
||||||
extern tty_T* g_tty;
|
|
||||||
|
|
||||||
#endif //NOXOS_TTY_H
|
|
|
@ -1,115 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_DRIVER_H
|
|
||||||
#define NOXOS_DRIVER_H
|
|
||||||
|
|
||||||
#include <utils/stdtypes.h>
|
|
||||||
#include <utils/bitmap.h>
|
|
||||||
#include <utils/hashmap.h>
|
|
||||||
#include <drivers/builtin/elf/elf.h>
|
|
||||||
|
|
||||||
#define DRIVER_MANAGER_CHUNK_SIZE 64
|
|
||||||
#define DRIVER_MANAGER_HASHMAP_SIZE 128
|
|
||||||
#define DRIVER_MEMORY_REGION_SIZE 0x100000000 // 4 GB
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
DRIVER_TRANSPORT_PCI,
|
|
||||||
DRIVER_TRANSPORT_USB,
|
|
||||||
DRIVER_TRANSPORT_FS
|
|
||||||
} __attribute__((packed)) driver_transport_protocol_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
|
|
||||||
DRIVER_UNKNOWN = 0x0000,
|
|
||||||
DRIVER_RESERVED = 0x0001,
|
|
||||||
|
|
||||||
// Specific Driver
|
|
||||||
|
|
||||||
DRIVER_MASS_STORAGE = 0x0101,
|
|
||||||
DRIVER_FILESYSTEM = 0x0102,
|
|
||||||
DRIVER_GRAPHICS = 0x0103,
|
|
||||||
DRIVER_AUDIO = 0x0104,
|
|
||||||
|
|
||||||
// Drivers which define the transmission of data but have multiple
|
|
||||||
// intended usages, such as USB for mass storage, input, etc..
|
|
||||||
|
|
||||||
DRIVER_TRANSMISSION = 0x0201,
|
|
||||||
DRIVER_USB_DEVICE = 0x0202,
|
|
||||||
DRIVER_PCI_DEVICE = 0x0203,
|
|
||||||
DRIVER_PCIE_DEVICE = 0x0204,
|
|
||||||
DRIVER_BLUETOOTH = 0x0205,
|
|
||||||
DRIVER_ETHERNET = 0x0206,
|
|
||||||
|
|
||||||
// MISCELLANEOUS
|
|
||||||
|
|
||||||
DRIVER_EMULATION = 0x7fff
|
|
||||||
|
|
||||||
} driver_category_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t vendor_id;
|
|
||||||
uint16_t device_id;
|
|
||||||
} __attribute__((packed)) driver_config_device_id_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool enable_progif;
|
|
||||||
uint8_t class;
|
|
||||||
uint8_t subclass;
|
|
||||||
uint8_t progif;
|
|
||||||
uint16_t num_device_ids;
|
|
||||||
driver_config_device_id_T device_ids[];
|
|
||||||
} __attribute__((packed)) driver_config_pci_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t min_version;
|
|
||||||
uint16_t num_device_ids;
|
|
||||||
driver_config_device_id_T device_ids[];
|
|
||||||
} __attribute__((packed)) driver_config_usb_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t gpt_guid[16];
|
|
||||||
uint8_t mbr_type;
|
|
||||||
} __attribute__((packed)) driver_config_fs_T;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
driver_config_pci_T* pci;
|
|
||||||
driver_config_usb_T* usb;
|
|
||||||
driver_config_fs_T* fs;
|
|
||||||
} conf_U;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t id;
|
|
||||||
void* base;
|
|
||||||
elf_executable_T* executable;
|
|
||||||
} driver_T;
|
|
||||||
|
|
||||||
typedef struct driver_manager_chunk_T driver_manager_chunk_T;
|
|
||||||
struct driver_manager_chunk_T {
|
|
||||||
driver_T drivers [DRIVER_MANAGER_CHUNK_SIZE];
|
|
||||||
bitmap_T drivers_bitmap;
|
|
||||||
|
|
||||||
uint32_t free_slots;
|
|
||||||
|
|
||||||
driver_manager_chunk_T* prev;
|
|
||||||
driver_manager_chunk_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
driver_manager_chunk_T* driver_pool;
|
|
||||||
hashmap_T lookup_table_pci;
|
|
||||||
hashmap_T lookup_table_usb;
|
|
||||||
hashmap_T lookup_table_fs_gpt;
|
|
||||||
hashmap_T lookup_table_fs_mbr;
|
|
||||||
} driver_manager_T;
|
|
||||||
|
|
||||||
void driver_manager_init ();
|
|
||||||
driver_manager_chunk_T* driver_manager_chunk_alloc(driver_manager_chunk_T* prev);
|
|
||||||
driver_T* driver_register (elf_executable_T* executable, uint8_t* buffer);
|
|
||||||
void driver_init (driver_T* driver, driver_transport_protocol_E protocol, conf_U conf);
|
|
||||||
driver_T* driver_lookup_pci_device (uint16_t vendor_id, uint16_t device_id);
|
|
||||||
driver_T* driver_lookup_usb_device (uint16_t vendor_id, uint16_t device_id);
|
|
||||||
driver_T* driver_lookup_fs_gpt (uint8_t guid[16]);
|
|
||||||
driver_T* driver_lookup_fs_mbr (uint8_t type);
|
|
||||||
driver_T* driver_lookup_by_address (void* address);
|
|
||||||
|
|
||||||
#endif //NOXOS_DRIVER_H
|
|
|
@ -1,31 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_HEAP_H
|
|
||||||
#define NOX_HEAP_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
#define HEAP_SEGMENT_MAGIC 0xA1C3A1B2
|
|
||||||
|
|
||||||
typedef struct heap_segment_T heap_segment_T;
|
|
||||||
struct heap_segment_T {
|
|
||||||
uint32_t magic;
|
|
||||||
uint64_t size;
|
|
||||||
bool free;
|
|
||||||
heap_segment_T* next;
|
|
||||||
heap_segment_T* prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void* start;
|
|
||||||
void* end;
|
|
||||||
heap_segment_T* last_segment;
|
|
||||||
} heap_T;
|
|
||||||
|
|
||||||
void heap_init (heap_T* heap, void* base);
|
|
||||||
void* heap_memory_allocate (heap_T* heap, uint64_t size);
|
|
||||||
void heap_memory_free (heap_T* heap, void* address);
|
|
||||||
void heap_dump_segments (heap_T* heap);
|
|
||||||
void heap_destruct (heap_T* heap);
|
|
||||||
|
|
||||||
#endif //NOX_HEAP_H
|
|
|
@ -1,11 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_MEMORY_MAP_H
|
|
||||||
#define NOX_MEMORY_MAP_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "boot/boot_info.h"
|
|
||||||
|
|
||||||
uint64_t memory_map_get_total_memory_size(boot_info_T* boot_info);
|
|
||||||
|
|
||||||
#endif //NOX_MEMORY_MAP_H
|
|
|
@ -1,30 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_PAGE_FRAME_H
|
|
||||||
#define NOX_PAGE_FRAME_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/bitmap.h"
|
|
||||||
#include "boot/boot_info.h"
|
|
||||||
|
|
||||||
#define PFRAME_SIZE 4096 // The size of a page frame
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t free_memory;
|
|
||||||
uint64_t reserved_memory;
|
|
||||||
uint64_t used_memory;
|
|
||||||
uint64_t page_bitmap_index;
|
|
||||||
bitmap_T page_bitmap;
|
|
||||||
bool blocked;
|
|
||||||
} page_frame_manager_T;
|
|
||||||
|
|
||||||
void pframe_manager_init (boot_info_T* boot_info);
|
|
||||||
void pframe_reserve (void* address);
|
|
||||||
void pframe_reserve_multi (void* address, uint32_t n);
|
|
||||||
void pframe_unreserve (void* address);
|
|
||||||
void pframe_unreserve_multi (void* address, uint32_t n);
|
|
||||||
void pframe_free (void* address);
|
|
||||||
void pframe_free_multi (void* address, uint32_t n);
|
|
||||||
void* pframe_request ();
|
|
||||||
|
|
||||||
#endif //NOX_PAGE_FRAME_H
|
|
|
@ -1,28 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_REGION_H
|
|
||||||
#define NOX_REGION_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
#define KERNEL_START_ADDRESS (uint64_t)&_kernel_start
|
|
||||||
#define KERNEL_END_ADDRESS (uint64_t)&_kernel_end
|
|
||||||
|
|
||||||
#define MEM_REGION_THREAD_OFFSET 0x100000000
|
|
||||||
|
|
||||||
#define MEM_REGION_PROCESS 0x0000000000000000
|
|
||||||
#define MEM_REGION_PROCESS_EXEC 0x0000010000000000
|
|
||||||
#define MEM_REGION_PROCESS_THREAD_BASE 0x0000010100000000
|
|
||||||
#define MEM_REGION_PROCESS_USABLE 0x0000080000000000
|
|
||||||
|
|
||||||
#define MEM_REGION_KERNEL 0x0000800000000000
|
|
||||||
#define MEM_REGION_KERNEL_DRIVERS 0xFFFFE80000000000 // size: up to 8 TB
|
|
||||||
#define MEM_REGION_KERNEL_STACK_DUMMY 0xFFFFF00000000000 // size: 4 KB
|
|
||||||
#define MEM_REGION_KERNEL_HEAP 0xFFFFF80000000000 // size: up to 8 TB
|
|
||||||
#define MEM_REGION_KERNEL_THREAD_BASE 0xFFFFFF0000000000 // size: up to 1022 GB
|
|
||||||
#define MEM_REGION_KERNEL_EXEC 0xFFFFFFFF80000000 // size: up to 2 GB
|
|
||||||
|
|
||||||
extern uint64_t _kernel_start;
|
|
||||||
extern uint64_t _kernel_end;
|
|
||||||
|
|
||||||
#endif //NOX_REGION_H
|
|
|
@ -1,16 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_STACK_H
|
|
||||||
#define NOX_STACK_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/symbol.h"
|
|
||||||
|
|
||||||
#include "drivers/builtin/elf/elf.h"
|
|
||||||
|
|
||||||
void stack_dump_call_info (uint64_t rip, symbol_T* symbol);
|
|
||||||
void stack_trace_call_stack (uint64_t rbp);
|
|
||||||
|
|
||||||
extern uint64_t stack_get_caller();
|
|
||||||
|
|
||||||
#endif //NOX_STACK_H
|
|
|
@ -1,45 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_GDT_H
|
|
||||||
#define NOX_GDT_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GDT_SELECTOR_NULL = 0x00,
|
|
||||||
GDT_SELECTOR_KERNEL_CODE = 0x08,
|
|
||||||
GDT_SELECTOR_KERNEL_DATA = 0x10,
|
|
||||||
GDT_SELECTOR_USER_NULL = 0x18,
|
|
||||||
GDT_SELECTOR_USER_CODE = 0x20,
|
|
||||||
GDT_SELECTOR_USER_DATA = 0x28
|
|
||||||
} gdt_selector_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t size;
|
|
||||||
uint64_t offset;
|
|
||||||
}__attribute__((packed)) gdt_descriptor_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t limit0;
|
|
||||||
uint16_t base0;
|
|
||||||
uint8_t base1;
|
|
||||||
uint8_t access;
|
|
||||||
uint8_t limit1_flags;
|
|
||||||
uint8_t base2;
|
|
||||||
}__attribute__((packed)) gdt_entry_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
gdt_entry_T null; // 0x00
|
|
||||||
gdt_entry_T kernel_code; // 0x08
|
|
||||||
gdt_entry_T kernel_data; // 0x10
|
|
||||||
gdt_entry_T user_null; // 0x18
|
|
||||||
gdt_entry_T user_code; // 0x20
|
|
||||||
gdt_entry_T user_data; // 0x28
|
|
||||||
}__attribute__((packed)) __attribute__((aligned(0x1000))) gdt_T;
|
|
||||||
|
|
||||||
extern gdt_T g_default_gdt;
|
|
||||||
|
|
||||||
void gdt_init();
|
|
||||||
|
|
||||||
|
|
||||||
#endif //NOX_GDT_H
|
|
|
@ -1,55 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_SYSCALL_H
|
|
||||||
#define NOX_SYSCALL_H
|
|
||||||
|
|
||||||
#include "platform/cpu.h"
|
|
||||||
#include "utils/status.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SYSCALLS_FILES = 0x00,
|
|
||||||
SYSCALLS_MEMORY = 0x01,
|
|
||||||
SYSCALLS_PROC = 0x02,
|
|
||||||
SYSCALLS_DRIVERS = 0x03,
|
|
||||||
|
|
||||||
SYSCALLS_KERNEL = 0xFF
|
|
||||||
}syscall_group_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SYSCALL_NX_FS_OPEN = 0x0001,
|
|
||||||
SYSCALL_NX_FS_CLOSE = 0x0002,
|
|
||||||
SYSCALL_NX_FS_READ = 0x0003,
|
|
||||||
SYSCALL_NX_FS_WRITE = 0x0004,
|
|
||||||
SYSCALL_NX_FS_DELETE = 0x0005,
|
|
||||||
SYSCALL_NX_FS_LIST = 0x0006,
|
|
||||||
SYSCALL_NX_FS_INFO = 0x0007,
|
|
||||||
|
|
||||||
SYSCALL_NX_MEM_ALLOC = 0x0101,
|
|
||||||
SYSCALL_NX_MEM_FREE = 0x0102,
|
|
||||||
SYSCALL_NX_MEM_LABEL = 0x0103,
|
|
||||||
SYSCALL_NX_MEM_UNLABEL = 0x0104,
|
|
||||||
|
|
||||||
SYSCALL_NX_PROC_CREATE = 0x0201,
|
|
||||||
SYSCALL_NX_PROC_SIGNAL_SEND = 0x0202,
|
|
||||||
SYSCALL_NX_PROC_SIGNAL_SET_HANDLER = 0x0203,
|
|
||||||
SYSCALL_NX_PROC_THREAD_CREATE = 0x0204,
|
|
||||||
SYSCALL_NX_PROC_THREAD_START = 0x0205,
|
|
||||||
SYSCALL_NX_PROC_THREAD_PAUSE = 0x0206,
|
|
||||||
SYSCALL_NX_PROC_THREAD_KILL = 0x0207,
|
|
||||||
|
|
||||||
SYSCALL_NX_DRV_REGISTER = 0x0301,
|
|
||||||
|
|
||||||
SYSCALL_NX_KERNEL_SCHEDULER_START = 0xFF00,
|
|
||||||
SYSCALL_NX_KERNEL_PANIC = 0xFF01
|
|
||||||
} syscall_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SYSCALL_NX_MMAP_FLAG_WRITE,
|
|
||||||
SYSCALL_NX_MMAP_FLAG_NO_EXEC
|
|
||||||
} syscall_nx_mmap_flags_E;
|
|
||||||
|
|
||||||
extern status_E syscall_perform(syscall_E id, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4);
|
|
||||||
|
|
||||||
cpu_state_T* syscall_handle(cpu_state_T* state);
|
|
||||||
|
|
||||||
#endif //NOX_SYSCALL_H
|
|
|
@ -1,46 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_FILE_DESCRIPTOR_H
|
|
||||||
#define NOX_FILE_DESCRIPTOR_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/bitmap.h"
|
|
||||||
#include "drivers/builtin/fs/vfs.h"
|
|
||||||
|
|
||||||
#define FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE 32
|
|
||||||
|
|
||||||
typedef uint32_t file_descriptor_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
FILE_DESCRIPTOR_INVALID,
|
|
||||||
FILE_DESCRIPTOR_STDOUT,
|
|
||||||
FILE_DESCRIPTOR_STDIN,
|
|
||||||
FILE_DESCRIPTOR_STDERR,
|
|
||||||
|
|
||||||
FILE_DESCRIPTORS_ENUM_END
|
|
||||||
} std_file_descriptors_E;
|
|
||||||
|
|
||||||
typedef struct file_descriptor_array_chunk_T file_descriptor_array_chunk_T;
|
|
||||||
struct file_descriptor_array_chunk_T {
|
|
||||||
file_descriptor_array_chunk_T* prev;
|
|
||||||
file_descriptor_array_chunk_T* next;
|
|
||||||
vfs_node_T* lookup [FILE_DESCRIPTOR_ARRAY_CHUNK_SIZE];
|
|
||||||
bitmap_T bitmap;
|
|
||||||
uint32_t amount;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
file_descriptor_array_chunk_T* base_chunk;
|
|
||||||
} file_descriptor_array_T;
|
|
||||||
|
|
||||||
file_descriptor_t file_descriptor_request (file_descriptor_array_T* fd_array, vfs_node_T* node);
|
|
||||||
vfs_node_T* file_descriptor_resolve (file_descriptor_array_T* fd_array, file_descriptor_t fd);
|
|
||||||
void file_descriptor_free (file_descriptor_array_T* fd_array, file_descriptor_t fd);
|
|
||||||
|
|
||||||
file_descriptor_array_T* file_descriptor_array_alloc ();
|
|
||||||
void file_descriptor_array_destruct (file_descriptor_array_T* fd_array);
|
|
||||||
|
|
||||||
file_descriptor_array_chunk_T* file_descriptor_array_chunk_alloc (file_descriptor_array_chunk_T* prev);
|
|
||||||
void file_descriptor_array_chunk_destruct (file_descriptor_array_chunk_T* chunk);
|
|
||||||
|
|
||||||
#endif //NOX_FILE_DESCRIPTOR_H
|
|
|
@ -1,31 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_PIPE_H
|
|
||||||
#define NOXOS_PIPE_H
|
|
||||||
|
|
||||||
#ifndef NOX_PROCESS
|
|
||||||
typedef struct process_T process_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "utils/stream.h"
|
|
||||||
#include "utils/bitmap.h"
|
|
||||||
|
|
||||||
#define PIPE_MAX_SENDERS 8
|
|
||||||
#define PIPE_STD_STREAM_SIZE 0x1000
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
stream_T* stream;
|
|
||||||
process_T* receiver;
|
|
||||||
process_T* senders [PIPE_MAX_SENDERS];
|
|
||||||
bitmap_T senders_bitmap;
|
|
||||||
void (*on_write)();
|
|
||||||
} pipe_T;
|
|
||||||
|
|
||||||
void pipe_init (pipe_T* pipe, process_T* receiver, void (*on_write)());
|
|
||||||
void pipe_destruct (pipe_T* pipe);
|
|
||||||
bool pipe_add_sender (pipe_T* pipe, process_T* sender);
|
|
||||||
void pipe_remove_sender (pipe_T* pipe, process_T* sender);
|
|
||||||
uint64_t pipe_write (pipe_T* pipe, void* buffer_in, uint64_t n);
|
|
||||||
uint64_t pipe_read (pipe_T* pipe, void* buffer_out, uint64_t n);
|
|
||||||
|
|
||||||
#endif //NOXOS_PIPE_H
|
|
|
@ -1,92 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_PROCESS_H
|
|
||||||
#define NOX_PROCESS_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
#include "utils/bitmap.h"
|
|
||||||
#include "proc/file_descriptor.h"
|
|
||||||
#include "proc/pipe.h"
|
|
||||||
#include "mm/page_map.h"
|
|
||||||
#include "drivers/builtin/elf/elf.h"
|
|
||||||
|
|
||||||
#define MAX_THREADS_PER_PROCESS 64
|
|
||||||
#define THREAD_ID_INVALID (-1)
|
|
||||||
|
|
||||||
typedef uint32_t pid_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PROCESS_NONE,
|
|
||||||
PROCESS_KERNEL
|
|
||||||
} processes_standard_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PROCESS_BLOCK_WAIT_PIPE_OUT,
|
|
||||||
PROCESS_BLOCK_WAIT_PIPE_IN,
|
|
||||||
|
|
||||||
PROCESS_BLOCK_ENUM_SIZE
|
|
||||||
} process_blockers_E;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PROCESS_SIGNAL_START, // SIGSTART
|
|
||||||
PROCESS_SIGNAL_PAUSE, // SIGPAUSE
|
|
||||||
PROCESS_SIGNAL_KILL, // SIGKILL
|
|
||||||
PROCESS_SIGNAL_PAGEFAULT, // SIGPAGEFAULT
|
|
||||||
PROCESS_SIGNAL_MATHFAULT, // SIGMATHFAULT
|
|
||||||
} process_signals_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
file_descriptor_t at_parent;
|
|
||||||
file_descriptor_t at_child;
|
|
||||||
}__attribute__((packed)) process_inherit_fd_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t privilege_level;
|
|
||||||
char name[80];
|
|
||||||
file_descriptor_t executable;
|
|
||||||
uint16_t num_inherit_fds;
|
|
||||||
process_inherit_fd_T inherit_fds[];
|
|
||||||
}__attribute__((packed)) process_config_T;
|
|
||||||
|
|
||||||
typedef struct process_T process_T;
|
|
||||||
struct process_T {
|
|
||||||
char name [128];
|
|
||||||
pid_t id;
|
|
||||||
void* chunk;
|
|
||||||
uint32_t chunk_id;
|
|
||||||
|
|
||||||
page_map_T* page_map;
|
|
||||||
elf_executable_T* executable;
|
|
||||||
file_descriptor_array_T* fd_array;
|
|
||||||
|
|
||||||
pipe_T* stdout;
|
|
||||||
pipe_T stdin;
|
|
||||||
pipe_T* stderr;
|
|
||||||
|
|
||||||
bitmap_T waiting;
|
|
||||||
|
|
||||||
uint32_t num_threads;
|
|
||||||
void* threads;
|
|
||||||
bitmap_T thread_ids;
|
|
||||||
|
|
||||||
process_T* parent;
|
|
||||||
process_T* childs;
|
|
||||||
process_T* prev;
|
|
||||||
process_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
void process_kernel_spawn (elf_executable_T* executable);
|
|
||||||
pid_t process_spawn (pid_t parent, string_t name, elf_executable_T* executable, void* buffer);
|
|
||||||
void process_signal (process_T* process, process_signals_E signal);
|
|
||||||
bool process_is_child_of (process_T* process, process_T* parent);
|
|
||||||
int32_t process_get_thread_id (process_T* process);
|
|
||||||
void process_clear_thread_id (process_T* process, uint32_t id);
|
|
||||||
void process_pause_pid (pid_t pid);
|
|
||||||
void process_pause (process_T* process);
|
|
||||||
void process_start_pid (pid_t pid);
|
|
||||||
void process_start (process_T* process);
|
|
||||||
void process_kill_pid (pid_t pid);
|
|
||||||
void process_kill (process_T* process);
|
|
||||||
|
|
||||||
#endif //NOX_PROCESS_H
|
|
|
@ -1,34 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_THREAD_H
|
|
||||||
#define NOX_THREAD_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
#include "platform/cpu.h"
|
|
||||||
#include "proc/process.h"
|
|
||||||
|
|
||||||
typedef struct thread_T thread_T;
|
|
||||||
struct thread_T{
|
|
||||||
cpu_state_T* state;
|
|
||||||
uint64_t cpu_time;
|
|
||||||
void* stack;
|
|
||||||
uint32_t stack_size;
|
|
||||||
process_T* process;
|
|
||||||
|
|
||||||
// Scheduling data
|
|
||||||
thread_T* global_prev;
|
|
||||||
thread_T* global_next;
|
|
||||||
|
|
||||||
thread_T* local_prev;
|
|
||||||
thread_T* local_next;
|
|
||||||
uint32_t local_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
thread_T* thread_spawn (pid_t process, void* function);
|
|
||||||
thread_T* thread_spawn_from_state (pid_t process, cpu_state_T* state);
|
|
||||||
void thread_start (thread_T* thread);
|
|
||||||
void thread_pause (thread_T* thread);
|
|
||||||
void thread_kill (thread_T* thread);
|
|
||||||
|
|
||||||
#endif //NOX_THREAD_H
|
|
|
@ -1,20 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_BITMAP_H
|
|
||||||
#define NOX_BITMAP_H
|
|
||||||
|
|
||||||
#include "stdtypes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t size;
|
|
||||||
uint32_t size_bits;
|
|
||||||
uint8_t* buffer;
|
|
||||||
} bitmap_T;
|
|
||||||
|
|
||||||
bitmap_T bitmap_init_from_buffer (void* buffer, uint32_t size);
|
|
||||||
bitmap_T bitmap_init (uint32_t size);
|
|
||||||
void bitmap_destruct (bitmap_T* bitmap);
|
|
||||||
bool bitmap_set (bitmap_T* bitmap, uint32_t index, bool value);
|
|
||||||
bool bitmap_get (bitmap_T* bitmap, uint32_t index);
|
|
||||||
|
|
||||||
#endif //NOX_BITMAP_H
|
|
|
@ -1,16 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_CORE_H
|
|
||||||
#define NOX_CORE_H
|
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "platform/interrupts.h"
|
|
||||||
|
|
||||||
#define CORE_INTERRUPTABLE_HALT_WHILE(a) while(!g_handling_interrupt && a) { asm("hlt"); }
|
|
||||||
#define CORE_HALT_WHILE(a) while(!g_handling_interrupt && a) { asm("hlt"); }
|
|
||||||
#define CORE_HALT_FOREVER log(LOG_WARNING, "!=====[ HALTING SYSTEM ]=====!"); while(1) { asm("hlt"); }
|
|
||||||
|
|
||||||
#define CORE_INTERRUPTS_ENABLE asm("sti");
|
|
||||||
#define CORE_INTERRUPTS_DISABLE asm("cli");
|
|
||||||
|
|
||||||
#endif //NOX_CORE_H
|
|
|
@ -1,10 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_SHA1_H
|
|
||||||
#define NOXOS_SHA1_H
|
|
||||||
|
|
||||||
#include <utils/stdtypes.h>
|
|
||||||
|
|
||||||
int sha1_hash(uint8_t *digest, const uint8_t* data, uint64_t len_data);
|
|
||||||
|
|
||||||
#endif //NOXOS_SHA1_H
|
|
|
@ -1,28 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOXOS_HASHMAP_H
|
|
||||||
#define NOXOS_HASHMAP_H
|
|
||||||
|
|
||||||
#include <utils/stdtypes.h>
|
|
||||||
|
|
||||||
typedef struct hashmap_entry_T hashmap_entry_T;
|
|
||||||
struct hashmap_entry_T {
|
|
||||||
bool in_use;
|
|
||||||
uint64_t key;
|
|
||||||
void* value;
|
|
||||||
hashmap_entry_T* prev;
|
|
||||||
hashmap_entry_T* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t size;
|
|
||||||
hashmap_entry_T* entries;
|
|
||||||
} hashmap_T;
|
|
||||||
|
|
||||||
hashmap_T hashmap_create (uint64_t size);
|
|
||||||
void hashmap_destruct (hashmap_T* hashmap);
|
|
||||||
void hashmap_insert (hashmap_T* hashmap, uint64_t key, void* value);
|
|
||||||
void hashmap_delete (hashmap_T* hashmap, uint64_t key);
|
|
||||||
void* hashmap_lookup (hashmap_T* hashmap, uint64_t key);
|
|
||||||
|
|
||||||
#endif //NOXOS_HASHMAP_H
|
|
|
@ -1,15 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_IO_H
|
|
||||||
#define NOX_IO_H
|
|
||||||
|
|
||||||
#include "stdtypes.h"
|
|
||||||
|
|
||||||
// sends one byte to a port
|
|
||||||
void io_out_byte (uint16_t port, uint8_t data);
|
|
||||||
uint8_t io_in_byte (uint16_t port);
|
|
||||||
void io_out_word (uint16_t port, uint32_t data);
|
|
||||||
uint32_t io_in_word (uint16_t port);
|
|
||||||
void io_wait ();
|
|
||||||
|
|
||||||
#endif //NOX_IO_H
|
|
|
@ -1,26 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_LOGGER_H
|
|
||||||
#define NOX_LOGGER_H
|
|
||||||
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
#define LOG_PORT 0x3F8
|
|
||||||
|
|
||||||
#define DEBUG(f, args...) log(LOG_DEBUG, "%s:%d -> " f, __FILE_NAME__, __LINE__, ##args)
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
LOG_NONE,
|
|
||||||
LOG_INFO,
|
|
||||||
LOG_DEBUG,
|
|
||||||
LOG_WARNING,
|
|
||||||
LOG_ERROR,
|
|
||||||
|
|
||||||
LOG_ENUM_END
|
|
||||||
} log_level_E;
|
|
||||||
|
|
||||||
// logs a string to qemu's serial port
|
|
||||||
void graphical_log_init ();
|
|
||||||
void log (log_level_E log_level, string_t string, ...);
|
|
||||||
|
|
||||||
#endif //NOX_LOGGER_H
|
|
|
@ -1,23 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_MATH_H
|
|
||||||
#define NOX_MATH_H
|
|
||||||
|
|
||||||
#include "stdtypes.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
||||||
#define MIN(a, b) ((a) > (b) ? (b) : (a))
|
|
||||||
#define CEIL_TO(a, b) ((a) % (b) ? (a) + (b) - ((a) % (b)) : (a))
|
|
||||||
#define FLOOR_TO(a, b) ((a) - ((a) % (b)))
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t x;
|
|
||||||
uint64_t y;
|
|
||||||
} position_T;
|
|
||||||
|
|
||||||
uint64_t pow (uint64_t base, uint64_t exp);
|
|
||||||
uint64_t abs (int64_t n);
|
|
||||||
uint64_t octal_string_to_int (string_t string, uint8_t size);
|
|
||||||
|
|
||||||
#endif //NOX_MATH_H
|
|
|
@ -1,16 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_MEMORY_H
|
|
||||||
#define NOX_MEMORY_H
|
|
||||||
|
|
||||||
#include "stdtypes.h"
|
|
||||||
|
|
||||||
void memory_copy (void* source, void* destination, uint32_t num);
|
|
||||||
void memory_set (void* destination, uint8_t data, uint32_t num);
|
|
||||||
bool memory_compare (void* a, void* b, uint32_t num);
|
|
||||||
void* memory_allocate (uint64_t size);
|
|
||||||
void memory_free (void* address);
|
|
||||||
void memory_allocator_init (void* base);
|
|
||||||
void memory_hexdump (uint8_t* address, uint64_t num);
|
|
||||||
|
|
||||||
#endif //NOX_MEMORY_H
|
|
|
@ -1,11 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_PANIC_H
|
|
||||||
#define NOX_PANIC_H
|
|
||||||
|
|
||||||
#include "platform/cpu.h"
|
|
||||||
#include "utils/string.h"
|
|
||||||
|
|
||||||
void panic(cpu_state_T* state, string_t message);
|
|
||||||
|
|
||||||
#endif //NOX_PANIC_H
|
|
|
@ -1,19 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_STATUS_H
|
|
||||||
#define NOX_STATUS_H
|
|
||||||
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
STATUS_SUCCESS,
|
|
||||||
|
|
||||||
STATUS_PERMISSION_DENIED,
|
|
||||||
STATUS_RESOURCE_NOT_AVAILABLE,
|
|
||||||
STATUS_NOT_SUPPORTED,
|
|
||||||
STATUS_GENERIC_ERROR
|
|
||||||
} status_E;
|
|
||||||
|
|
||||||
extern string_t g_status_code_strings[3];
|
|
||||||
|
|
||||||
#endif //NOX_STATUS_H
|
|
|
@ -1,22 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_STDTYPES_H
|
|
||||||
#define NOX_STDTYPES_H
|
|
||||||
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef signed int int32_t;
|
|
||||||
typedef unsigned long uint64_t;
|
|
||||||
typedef signed long int64_t;
|
|
||||||
|
|
||||||
typedef _Bool bool;
|
|
||||||
|
|
||||||
#define true 1
|
|
||||||
#define false 0
|
|
||||||
|
|
||||||
#define NULL (void*)0
|
|
||||||
|
|
||||||
#endif //NOX_STDTYPES_H
|
|
|
@ -1,20 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_STREAM_H
|
|
||||||
#define NOX_STREAM_H
|
|
||||||
|
|
||||||
#include "utils/stdtypes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t* buffer;
|
|
||||||
uint32_t size;
|
|
||||||
uint32_t pos_sender;
|
|
||||||
uint32_t pos_receiver;
|
|
||||||
} stream_T;
|
|
||||||
|
|
||||||
stream_T* stream_alloc (uint32_t size);
|
|
||||||
void stream_destruct (stream_T* stream);
|
|
||||||
uint32_t stream_write (stream_T* stream, void* buffer_in, uint32_t n);
|
|
||||||
uint32_t stream_read (stream_T* stream, void* buffer_out, uint32_t n);
|
|
||||||
|
|
||||||
#endif //NOX_STREAM_H
|
|
|
@ -1,34 +0,0 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
|
||||||
|
|
||||||
#ifndef NOX_SYMBOLS_H
|
|
||||||
#define NOX_SYMBOLS_H
|
|
||||||
|
|
||||||
#include "utils/string.h"
|
|
||||||
#include "utils/hashmap.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SYMBOL_FUNCTION,
|
|
||||||
SYMBOL_VARIABLE,
|
|
||||||
SYMBOL_UNKNOWN
|
|
||||||
} symbol_type_E;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
string_t name;
|
|
||||||
symbol_type_E type;
|
|
||||||
uint64_t address;
|
|
||||||
} symbol_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
hashmap_T hashmap;
|
|
||||||
uint64_t num_symbols;
|
|
||||||
symbol_T* symbols;
|
|
||||||
uint64_t symbols_index;
|
|
||||||
} symbol_table_T;
|
|
||||||
|
|
||||||
symbol_table_T symbol_table_init (uint64_t num_symbols);
|
|
||||||
void symbol_table_destruct (symbol_table_T* symbol_table);
|
|
||||||
void symbol_table_insert (symbol_table_T* symbol_table, symbol_T symbol);
|
|
||||||
symbol_T* symbol_resolve_from_name (symbol_table_T* symbol_table, string_t name);
|
|
||||||
symbol_T* symbol_resolve_from_rip (symbol_table_T* symbol_table, uint64_t rip);
|
|
||||||
|
|
||||||
#endif //NOX_SYMBOLS_H
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
set(C 99)
|
||||||
|
|
||||||
|
set(CMAKE_NASM_COMPILE_OBJECT "nasm <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(kernel)
|
||||||
|
add_library (kernel_asm OBJECT)
|
||||||
|
target_include_directories(kernel PRIVATE inc)
|
||||||
|
file(GLOB_RECURSE kernel_src_c "**/*.c")
|
||||||
|
file(GLOB_RECURSE kernel_inc "**/*.h")
|
||||||
|
file(GLOB_RECURSE kernel_src_asm "**/*.asm")
|
||||||
|
|
||||||
|
|
||||||
|
target_compile_options(kernel PRIVATE -g -fno-stack-protector -fno-stack-check -mno-red-zone -ffreestanding -m64 -march=x86-64 -mabi=sysv)
|
||||||
|
target_link_options(kernel PRIVATE -nostdlib -static -T "${CMAKE_CURRENT_LIST_DIR}/kernel.ld")
|
||||||
|
|
||||||
|
enable_language(ASM_NASM)
|
||||||
|
set(CAN_USE_ASSEMBLER TRUE)
|
||||||
|
|
||||||
|
target_sources(kernel_asm PRIVATE ${kernel_src_asm})
|
||||||
|
target_sources(kernel PRIVATE ${kernel_src_c} ${kernel_inc} $<TARGET_OBJECTS:kernel_asm>)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_BOOT_INFO_H
|
||||||
|
#define NOX_BOOT_INFO_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "limine.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct limine_framebuffer_response* framebuffer;
|
||||||
|
struct limine_terminal_response* terminal;
|
||||||
|
struct limine_memmap_response* memory_map;
|
||||||
|
struct limine_file* kernel_file;
|
||||||
|
struct limine_file* ramdisk_file;
|
||||||
|
void* rsdp;
|
||||||
|
} boot_info_T;
|
||||||
|
|
||||||
|
#endif //NOX_BOOT_INFO_H
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_ELF_H
|
||||||
|
#define NOX_ELF_H
|
||||||
|
|
||||||
|
#include "drivers/elf/header.h"
|
||||||
|
#include "drivers/elf/section.h"
|
||||||
|
#include "drivers/elf/mapping.h"
|
||||||
|
#include "utils/symbol.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
elf_header_T header;
|
||||||
|
uint64_t num_symbols;
|
||||||
|
symbol_T* symbols;
|
||||||
|
uint64_t num_mappings;
|
||||||
|
elf_mapping_T* mappings;
|
||||||
|
void* string_table;
|
||||||
|
} elf_executable_T;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
elf_executable_T* executable;
|
||||||
|
elf_section_T* symbol_table;
|
||||||
|
elf_section_T* section_header_string_table;
|
||||||
|
|
||||||
|
uint8_t* buffer;
|
||||||
|
} elf_executable_temp_T;
|
||||||
|
|
||||||
|
elf_executable_T* elf_executable_create (uint8_t* buffer);
|
||||||
|
void elf_executable_destruct (elf_executable_T* executable);
|
||||||
|
|
||||||
|
#endif //NOX_ELF_H
|
|
@ -1,4 +1,25 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_ELF_HEADER_H
|
#ifndef NOX_ELF_HEADER_H
|
||||||
#define NOX_ELF_HEADER_H
|
#define NOX_ELF_HEADER_H
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_MAPPING_H
|
||||||
|
#define NOX_MAPPING_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "mm/page_map.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t offset_file;
|
||||||
|
uint64_t offset_virtual;
|
||||||
|
uint64_t length_file;
|
||||||
|
uint64_t length_virtual;
|
||||||
|
} elf_mapping_T;
|
||||||
|
|
||||||
|
void elf_mappings_apply(elf_mapping_T* mappings, uint64_t num_mappings, uint8_t* buffer, void* base, page_map_T* page_map);
|
||||||
|
|
||||||
|
#endif //NOX_MAPPING_H
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_SECTION_H
|
||||||
|
#define NOX_SECTION_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "utils/string.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ELF_SECTION_NULL,
|
||||||
|
ELF_SECTION_PROGRAM_DATA,
|
||||||
|
ELF_SECTION_SYMBOL_TABLE,
|
||||||
|
ELF_SECTION_STRING_TABLE,
|
||||||
|
ELF_SECTION_RELOCATION_A,
|
||||||
|
ELF_SECTION_HASH,
|
||||||
|
ELF_SECTION_DYNAMIC_LINK,
|
||||||
|
ELF_SECTION_NOTE,
|
||||||
|
ELF_SECTION_NOBITS,
|
||||||
|
|
||||||
|
ELF_SECTION_ENUM_END
|
||||||
|
} elf_section_type_E;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t name_offset;
|
||||||
|
uint32_t type;
|
||||||
|
uint64_t flags;
|
||||||
|
uint64_t virtual_address;
|
||||||
|
uint64_t offset;
|
||||||
|
uint64_t length;
|
||||||
|
uint32_t link;
|
||||||
|
uint32_t info;
|
||||||
|
uint64_t alignment;
|
||||||
|
uint64_t entry_size;
|
||||||
|
} elf_section_T;
|
||||||
|
|
||||||
|
extern string_t g_elf_section_type_strings[ELF_SECTION_ENUM_END+1];
|
||||||
|
|
||||||
|
#endif //NOX_SECTION_H
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_SEGMENT_H
|
||||||
|
#define NOX_SEGMENT_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "utils/string.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ELF_SEGMENT_NULL,
|
||||||
|
ELF_SEGMENT_LOAD,
|
||||||
|
ELF_SEGMENT_DYNAMIC,
|
||||||
|
ELF_SEGMENT_INTERPRETER,
|
||||||
|
ELF_SEGMENT_NOTE,
|
||||||
|
ELF_SEGMENT_PROGRAM_HEADER_TABLE,
|
||||||
|
ELF_SEGMENT_TLS,
|
||||||
|
|
||||||
|
ELF_SEGMENT_ENUM_END
|
||||||
|
} elf_segment_type_E;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t type;
|
||||||
|
uint32_t flags;
|
||||||
|
uint64_t offset;
|
||||||
|
uint64_t address_virtual;
|
||||||
|
uint64_t address_physical;
|
||||||
|
uint64_t length_file;
|
||||||
|
uint64_t length_memory;
|
||||||
|
uint64_t align;
|
||||||
|
} elf_segment_T;
|
||||||
|
|
||||||
|
extern string_t g_elf_segment_type_strings[ELF_SEGMENT_ENUM_END+1];
|
||||||
|
|
||||||
|
#endif //NOX_SEGMENT_H
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_ELF_SYMBOL_H
|
||||||
|
#define NOX_ELF_SYMBOL_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "utils/string.h"
|
||||||
|
|
||||||
|
#define ELF_SYMBOL_TYPE(info) ((info) & 0xF)
|
||||||
|
|
||||||
|
extern string_t g_elf_symbol_type_strings[7];
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ELF_SYMBOL_NONE,
|
||||||
|
ELF_SYMBOL_OBJECT,
|
||||||
|
ELF_SYMBOL_FUNC,
|
||||||
|
ELF_SYMBOL_SECTION,
|
||||||
|
ELF_SYMBOL_FILE,
|
||||||
|
ELF_SYMBOL_COMMON,
|
||||||
|
ELF_SYMBOL_TLS
|
||||||
|
} elf_symbol_type_E;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t name_offset;
|
||||||
|
uint8_t info;
|
||||||
|
uint8_t other;
|
||||||
|
uint16_t related_section_index;
|
||||||
|
uint64_t value;
|
||||||
|
uint64_t length;
|
||||||
|
} elf_symbol_T;
|
||||||
|
|
||||||
|
#endif //NOX_ELF_SYMBOL_H
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_RAMFS_H
|
||||||
|
#define NOX_RAMFS_H
|
||||||
|
|
||||||
|
#include "drivers/fs/vfs.h"
|
||||||
|
|
||||||
|
void ramfs_file_delete (vfs_node_T* node);
|
||||||
|
void ramfs_file_write (vfs_node_T* node, uint64_t size, uint8_t* buffer_in);
|
||||||
|
void ramfs_file_read (vfs_node_T* node, uint64_t size, uint8_t* buffer_out);
|
||||||
|
|
||||||
|
|
||||||
|
#endif //NOX_RAMFS_H
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_USTAR_H
|
||||||
|
#define NOX_USTAR_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
USTAR_FILE,
|
||||||
|
USTAR_LINK_HARD,
|
||||||
|
USTAR_LINK_SYM,
|
||||||
|
USTAR_CHAR_DEVICE,
|
||||||
|
USTAR_BLOCK_DEVICE,
|
||||||
|
USTAR_DIRECTORY,
|
||||||
|
USTAR_PIPE
|
||||||
|
} ustar_type_E;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name [100];
|
||||||
|
uint64_t mode;
|
||||||
|
uint64_t owner_id;
|
||||||
|
uint64_t group_id;
|
||||||
|
char size [12]; // octal based string (don't ask me why, the ustar standard is weird)
|
||||||
|
char last_modification [12]; // unix timestamp (octal)
|
||||||
|
uint64_t checksum;
|
||||||
|
uint8_t type;
|
||||||
|
char name_linked [100];
|
||||||
|
char indicator [6];
|
||||||
|
uint16_t version;
|
||||||
|
char owner_user_name [32];
|
||||||
|
char owner_group_name [32];
|
||||||
|
uint64_t device_major;
|
||||||
|
uint64_t device_minor;
|
||||||
|
char name_prefix [155];
|
||||||
|
}__attribute__((packed)) __attribute__((aligned(512))) ustar_header_T;
|
||||||
|
|
||||||
|
#endif //NOX_USTAR_H
|
|
@ -1,4 +1,25 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_VFS_H
|
#ifndef NOX_VFS_H
|
||||||
#define NOX_VFS_H
|
#define NOX_VFS_H
|
||||||
|
@ -59,14 +80,13 @@ void vfs_node_cache_destruct (vfs_node_cache_T* node_cache);
|
||||||
|
|
||||||
vfs_node_T* vfs_node_create (vfs_node_T* parent, string_t name, vfs_node_type_E type, void* specific);
|
vfs_node_T* vfs_node_create (vfs_node_T* parent, string_t name, vfs_node_type_E type, void* specific);
|
||||||
void vfs_node_destruct (vfs_node_T* node);
|
void vfs_node_destruct (vfs_node_T* node);
|
||||||
void vfs_node_delete (vfs_node_T* node);
|
|
||||||
void vfs_node_dump_info (vfs_node_T* node, uint64_t indent);
|
void vfs_node_dump_info (vfs_node_T* node, uint64_t indent);
|
||||||
vfs_node_T* vfs_node_resolve_child (vfs_node_T* node, string_t child_name);
|
vfs_node_T* vfs_node_resolve_child (vfs_node_T* node, string_t child_name);
|
||||||
|
|
||||||
vfs_node_T* vfs_file_create (fs_T* filesystem, string_t path);
|
vfs_node_T* vfs_file_create (fs_T* filesystem, string_t path);
|
||||||
void vfs_file_delete (vfs_node_T* file);
|
void vfs_file_delete (vfs_node_T* file);
|
||||||
uint64_t vfs_file_write (vfs_node_T* file, uint64_t position, uint64_t size, uint8_t* buffer_in);
|
void vfs_file_write (vfs_node_T* file, uint64_t position, uint64_t size, uint8_t* buffer_in);
|
||||||
uint64_t vfs_file_read (vfs_node_T* file, uint64_t position, uint64_t size, uint8_t* buffer_out);
|
void vfs_file_read (vfs_node_T* file, uint64_t position, uint64_t size, uint8_t* buffer_out);
|
||||||
|
|
||||||
vfs_node_T* vfs_directory_create (fs_T* filesystem, string_t path);
|
vfs_node_T* vfs_directory_create (fs_T* filesystem, string_t path);
|
||||||
void vfs_directory_delete (vfs_node_T* directory);
|
void vfs_directory_delete (vfs_node_T* directory);
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#ifndef NOX_GRAPHICS_COMMAND_QUEUE_H
|
||||||
|
#define NOX_GRAPHICS_COMMAND_QUEUE_H
|
||||||
|
|
||||||
|
#include <utils/math.h>
|
||||||
|
#include <utils/memory.h>
|
||||||
|
#include <utils/stdtypes.h>
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#ifndef NOX_GRAPHICS_DEFAULT_IMPLEMENTATION_H
|
||||||
|
#define NOX_GRAPHICS_DEFAULT_IMPLEMENTATION_H
|
||||||
|
|
||||||
|
#include <utils/math.h>
|
||||||
|
#include <utils/memory.h>
|
||||||
|
#include <utils/stdtypes.h>
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
#ifndef NOX_GRAPHICS_DRIVER_H
|
||||||
|
#define NOX_GRAPHICS_DRIVER_H
|
||||||
|
|
||||||
|
#include <boot/boot_info.h>
|
||||||
|
|
||||||
|
#include <utils/math.h>
|
||||||
|
#include <utils/memory.h>
|
||||||
|
#include <utils/stdtypes.h>
|
||||||
|
|
||||||
|
#include <drivers/gfx/pixelbuffer.h>
|
||||||
|
|
||||||
|
typedef struct framebuffer_t {
|
||||||
|
|
||||||
|
uint32_t pixel_width;
|
||||||
|
uint32_t pixel_height;
|
||||||
|
uint8_t pixel_stride;
|
||||||
|
|
||||||
|
void *memory_mapping;
|
||||||
|
pixelbuffer_T *root_pixelbuffer;
|
||||||
|
|
||||||
|
} framebuffer_T;
|
||||||
|
|
||||||
|
typedef struct graphics_driver_t {
|
||||||
|
|
||||||
|
uint32_t num_framebuffers;
|
||||||
|
framebuffer_T *framebuffers;
|
||||||
|
|
||||||
|
} graphics_driver_T;
|
||||||
|
|
||||||
|
graphics_driver_T * create_graphics_driver_from_boot_info(boot_info_T *boot_info);
|
||||||
|
void delete_graphics_driver(graphics_driver_T *driver);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
|
||||||
|
#ifndef NOX_PIXELBUFFER_H
|
||||||
|
#define NOX_PIXELBUFFER_H
|
||||||
|
|
||||||
|
#include <utils/math.h>
|
||||||
|
#include <utils/memory.h>
|
||||||
|
#include <utils/stdtypes.h>
|
||||||
|
#include <drivers/gfx/utility.h>
|
||||||
|
|
||||||
|
typedef struct pixelbuffer_t pixelbuffer_T;
|
||||||
|
|
||||||
|
struct pixelbuffer_t {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Other relevant state
|
||||||
|
//
|
||||||
|
|
||||||
|
pixelbuffer_T *parent;
|
||||||
|
// root_pixelbuffer: The first pixelbuffer for a screen, it represents the whole screen
|
||||||
|
// from a drawing perspective. In the root pixelbuffers themselves, this is NULL.
|
||||||
|
pixelbuffer_T *root_pixelbuffer;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dimensions of the pixelbuffers' area
|
||||||
|
//
|
||||||
|
|
||||||
|
uint32_t relative_start_x;
|
||||||
|
uint32_t relative_start_y;
|
||||||
|
uint32_t absolute_start_x;
|
||||||
|
uint32_t absolute_start_y;
|
||||||
|
uint32_t pixel_width;
|
||||||
|
uint32_t pixel_height;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Information necessary for drawing
|
||||||
|
//
|
||||||
|
|
||||||
|
// pixel_stride: The distance between pixels in 'mapped_region', in bytes.
|
||||||
|
uint8_t pixel_stride;
|
||||||
|
void *memory_mapping;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
pixelbuffer_T * create_pixelbuffer (pixelbuffer_T *parent);
|
||||||
|
void delete_pixelbuffer (pixelbuffer_T *pixelbuffer);
|
||||||
|
|
||||||
|
void graphics_set_pixel (pixelbuffer_T *pixelbuffer,
|
||||||
|
uint32_t relative_x, uint32_t relative_y, pixel_T pixel);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#ifndef NOX_GRAPHICS_STRINGIFY_ENUMS_H
|
||||||
|
#define NOX_GRAPHICS_STRINGIFY_ENUMS_H
|
||||||
|
|
||||||
|
#include <utils/math.h>
|
||||||
|
#include <utils/memory.h>
|
||||||
|
#include <utils/stdtypes.h>
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
#ifndef NOX_GRAPHICS_UTILITY_H
|
||||||
|
#define NOX_GRAPHICS_UTILITY_H
|
||||||
|
|
||||||
|
#include <utils/math.h>
|
||||||
|
#include <utils/memory.h>
|
||||||
|
#include <utils/stdtypes.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint16_t red;
|
||||||
|
uint16_t green;
|
||||||
|
uint16_t blue;
|
||||||
|
uint16_t alpha;
|
||||||
|
|
||||||
|
} pixel_T;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_PIT_H
|
||||||
|
#define NOX_PIT_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
|
||||||
|
#define PIT_CHANNEL_0_PORT 0x40
|
||||||
|
#define PIT_DIVISOR 32768 // This gives an interrupt every ~27.46ms
|
||||||
|
|
||||||
|
void pit_set_divisor(uint16_t divisor);
|
||||||
|
|
||||||
|
#endif //NOX_PIT_H
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_HEAP_H
|
||||||
|
#define NOX_HEAP_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
|
||||||
|
#define HEAP_SEGMENT_MAGIC 0xA1C3A1B2
|
||||||
|
|
||||||
|
typedef struct heap_segment_T heap_segment_T;
|
||||||
|
struct heap_segment_T {
|
||||||
|
uint32_t magic;
|
||||||
|
uint64_t size;
|
||||||
|
bool free;
|
||||||
|
heap_segment_T* next;
|
||||||
|
heap_segment_T* prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void* start;
|
||||||
|
void* end;
|
||||||
|
heap_segment_T* last_segment;
|
||||||
|
} heap_T;
|
||||||
|
|
||||||
|
void heap_init (heap_T* heap, void* base);
|
||||||
|
void* heap_memory_allocate (heap_T* heap, uint64_t size);
|
||||||
|
void heap_memory_free (heap_T* heap, void* address);
|
||||||
|
void heap_dump_segments (heap_T* heap);
|
||||||
|
void heap_destruct (heap_T* heap);
|
||||||
|
|
||||||
|
#endif //NOX_HEAP_H
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_MEMORY_MAP_H
|
||||||
|
#define NOX_MEMORY_MAP_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "boot/boot_info.h"
|
||||||
|
|
||||||
|
uint64_t memory_map_get_total_memory_size(boot_info_T* boot_info);
|
||||||
|
|
||||||
|
#endif //NOX_MEMORY_MAP_H
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_PAGE_FRAME_H
|
||||||
|
#define NOX_PAGE_FRAME_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "utils/bitmap.h"
|
||||||
|
#include "boot/boot_info.h"
|
||||||
|
|
||||||
|
#define PFRAME_SIZE 4096 // The size of a page frame
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t free_memory;
|
||||||
|
uint64_t reserved_memory;
|
||||||
|
uint64_t used_memory;
|
||||||
|
uint64_t page_bitmap_index;
|
||||||
|
bitmap_T page_bitmap;
|
||||||
|
bool blocked;
|
||||||
|
} page_frame_manager_T;
|
||||||
|
|
||||||
|
void pframe_manager_init (boot_info_T* boot_info);
|
||||||
|
void pframe_reserve (void* address);
|
||||||
|
void pframe_reserve_multi (void* address, uint32_t n);
|
||||||
|
void pframe_unreserve (void* address);
|
||||||
|
void pframe_unreserve_multi (void* address, uint32_t n);
|
||||||
|
void pframe_free (void* address);
|
||||||
|
void pframe_free_multi (void* address, uint32_t n);
|
||||||
|
void* pframe_request ();
|
||||||
|
|
||||||
|
#endif //NOX_PAGE_FRAME_H
|
|
@ -1,4 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_PAGE_MAP_H
|
#ifndef NOX_PAGE_MAP_H
|
||||||
#define NOX_PAGE_MAP_H
|
#define NOX_PAGE_MAP_H
|
||||||
|
@ -31,7 +52,6 @@ extern page_map_T* page_map_fetch_current ();
|
||||||
extern void page_map_load (page_map_T* page_map);
|
extern void page_map_load (page_map_T* page_map);
|
||||||
void page_map_map_memory (page_map_T* page_map, void* virtual_address, void* physical_address, uint64_t flags);
|
void page_map_map_memory (page_map_T* page_map, void* virtual_address, void* physical_address, uint64_t flags);
|
||||||
void page_map_unmap_memory (page_map_T* page_map, void* virtual_address);
|
void page_map_unmap_memory (page_map_T* page_map, void* virtual_address);
|
||||||
bool page_map_check_memory (page_map_T* page_map, void* virtual_address);
|
|
||||||
void* page_map_get_physical_address (page_map_T* page_map, void* virtual_address);
|
void* page_map_get_physical_address (page_map_T* page_map, void* virtual_address);
|
||||||
void page_map_destruct (page_map_T* page_map);
|
void page_map_destruct (page_map_T* page_map);
|
||||||
void page_map_dump_info (page_map_T* page_map);
|
void page_map_dump_info (page_map_T* page_map);
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_REGION_H
|
||||||
|
#define NOX_REGION_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
|
||||||
|
#define KERNEL_START_ADDRESS (uint64_t)&_kernel_start
|
||||||
|
#define KERNEL_END_ADDRESS (uint64_t)&_kernel_end
|
||||||
|
|
||||||
|
#define MEM_REGION_THREAD_OFFSET 0x100000000
|
||||||
|
|
||||||
|
#define MEM_REGION_PROCESS 0x0000000000000000
|
||||||
|
#define MEM_REGION_PROCESS_EXEC 0x0000010000000000
|
||||||
|
#define MEM_REGION_PROCESS_THREAD_BASE 0x0000010100000000
|
||||||
|
|
||||||
|
#define MEM_REGION_KERNEL 0xFFFF800000000000
|
||||||
|
#define MEM_REGION_KERNEL_STACK_DUMMY 0xFFFFF00000000000 // size 0x4000
|
||||||
|
#define MEM_REGION_KERNEL_HEAP 0xFFFFF80000000000
|
||||||
|
#define MEM_REGION_KERNEL_THREAD_BASE 0xFFFFFF0000000000
|
||||||
|
#define MEM_REGION_KERNEL_EXEC 0xFFFFFFFF80000000
|
||||||
|
|
||||||
|
extern uint64_t _kernel_start;
|
||||||
|
extern uint64_t _kernel_end;
|
||||||
|
|
||||||
|
#endif //NOX_REGION_H
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_STACK_H
|
||||||
|
#define NOX_STACK_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "utils/symbol.h"
|
||||||
|
|
||||||
|
#include "drivers/elf/elf.h"
|
||||||
|
|
||||||
|
void stack_dump_call_info (uint64_t rip, symbol_T* symbol);
|
||||||
|
void stack_trace_call_stack (uint64_t rbp);
|
||||||
|
|
||||||
|
#endif //NOX_STACK_H
|
|
@ -1,4 +1,25 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_CPU_H
|
#ifndef NOX_CPU_H
|
||||||
#define NOX_CPU_H
|
#define NOX_CPU_H
|
|
@ -1,4 +1,25 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_EXCEPTIONS_H
|
#ifndef NOX_EXCEPTIONS_H
|
||||||
#define NOX_EXCEPTIONS_H
|
#define NOX_EXCEPTIONS_H
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_GDT_H
|
||||||
|
#define NOX_GDT_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GDT_SELECTOR_NULL = 0x00,
|
||||||
|
GDT_SELECTOR_KERNEL_CODE = 0x08,
|
||||||
|
GDT_SELECTOR_KERNEL_DATA = 0x10,
|
||||||
|
GDT_SELECTOR_USER_NULL = 0x18,
|
||||||
|
GDT_SELECTOR_USER_CODE = 0x20,
|
||||||
|
GDT_SELECTOR_USER_DATA = 0x28
|
||||||
|
} gdt_selector_E;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t size;
|
||||||
|
uint64_t offset;
|
||||||
|
}__attribute__((packed)) gdt_descriptor_T;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t limit0;
|
||||||
|
uint16_t base0;
|
||||||
|
uint8_t base1;
|
||||||
|
uint8_t access;
|
||||||
|
uint8_t limit1_flags;
|
||||||
|
uint8_t base2;
|
||||||
|
}__attribute__((packed)) gdt_entry_T;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
gdt_entry_T null; // 0x00
|
||||||
|
gdt_entry_T kernel_code; // 0x08
|
||||||
|
gdt_entry_T kernel_data; // 0x10
|
||||||
|
gdt_entry_T user_null; // 0x18
|
||||||
|
gdt_entry_T user_code; // 0x20
|
||||||
|
gdt_entry_T user_data; // 0x28
|
||||||
|
}__attribute__((packed)) __attribute__((aligned(0x1000))) gdt_T;
|
||||||
|
|
||||||
|
extern gdt_T g_default_gdt;
|
||||||
|
|
||||||
|
void gdt_init();
|
||||||
|
|
||||||
|
|
||||||
|
#endif //NOX_GDT_H
|
|
@ -1,4 +1,25 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_INTERRUPTS_H
|
#ifndef NOX_INTERRUPTS_H
|
||||||
#define NOX_INTERRUPTS_H
|
#define NOX_INTERRUPTS_H
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_SYSCALL_H
|
||||||
|
#define NOX_SYSCALL_H
|
||||||
|
|
||||||
|
#include "platform/cpu.h"
|
||||||
|
#include "utils/status.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SYSCALLS_FILES = 0x00,
|
||||||
|
SYSCALLS_MEMORY = 0x01,
|
||||||
|
SYSCALLS_PROC = 0x02,
|
||||||
|
SYSCALLS_RUNTIME_LINKER = 0x02,
|
||||||
|
SYSCALLS_COMPATABILITY = 0x02,
|
||||||
|
|
||||||
|
SYSCALLS_KERNEL = 0xFF
|
||||||
|
}syscall_group_E;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SYSCALL_FILES_OPEN = 0x0101,
|
||||||
|
SYSCALL_FILES_CLOSE = 0x0102,
|
||||||
|
SYSCALL_FILES_READ = 0x0103,
|
||||||
|
SYSCALL_FILES_WRITE = 0x0104,
|
||||||
|
SYSCALL_FILES_DELETE = 0x0105,
|
||||||
|
SYSCALL_FILES_LIST = 0x0106,
|
||||||
|
SYSCALL_FILES_FOLLOW = 0x0107, // Warning: nx_follow will probably be kicked out of the ABI
|
||||||
|
SYSCALL_FILES_INFO = 0x0108,
|
||||||
|
|
||||||
|
SYSCALL_MEMORY_ALLOC = 0x0201,
|
||||||
|
SYSCALL_MEMORY_FREE = 0x0202,
|
||||||
|
SYSCALL_MEMORY_LABEL = 0x0203,
|
||||||
|
SYSCALL_MEMORY_RANGE = 0x0204,
|
||||||
|
SYSCALL_MEMORY_ACCESS = 0x0205,
|
||||||
|
|
||||||
|
SYSCALL_PROCESS_CREATE = 0x0301,
|
||||||
|
SYSCALL_PROCESS_ENVFILE = 0x0302,
|
||||||
|
SYSCALL_PROCESS_START = 0x0303,
|
||||||
|
SYSCALL_PROCESS_SIGNAL = 0x0304,
|
||||||
|
|
||||||
|
SYSCALL_RUNTIME_LINKER_OPEN = 0x0401,
|
||||||
|
SYSCALL_RUNTIME_LINKER_CLOSE = 0x0402,
|
||||||
|
SYSCALL_RUNTIME_LINKER_LOAD_SYMBOL = 0x0403,
|
||||||
|
SYSCALL_RUNTIME_LINKER_STATUS = 0x0404,
|
||||||
|
SYSCALL_RUNTIME_LINKER_STANDARD_MOD = 0x0405,
|
||||||
|
|
||||||
|
SYSCALL_COMPATABILITY_ABI_TYPE = 0x0501,
|
||||||
|
SYSCALL_COMPATABILITY_ABI_VERSION = 0x0502,
|
||||||
|
SYSCALL_COMPATABILITY_ACTION = 0x0503,
|
||||||
|
|
||||||
|
SYSCALL_KERNEL_SCHEDULER_START = 0xFF00,
|
||||||
|
SYSCALL_KERNEL_PANIC = 0xFF01
|
||||||
|
} syscall_E;
|
||||||
|
|
||||||
|
extern status_E syscall_perform(syscall_E id, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4);
|
||||||
|
|
||||||
|
cpu_state_T* syscall_handle(cpu_state_T* state);
|
||||||
|
|
||||||
|
#endif //NOX_SYSCALL_H
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_PROCESS_H
|
||||||
|
#define NOX_PROCESS_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "utils/string.h"
|
||||||
|
#include "utils/bitmap.h"
|
||||||
|
#include "mm/page_map.h"
|
||||||
|
#include "drivers/elf/elf.h"
|
||||||
|
|
||||||
|
#define MAX_THREADS_PER_PROCESS 64
|
||||||
|
#define THREAD_ID_INVALID (-1)
|
||||||
|
|
||||||
|
typedef uint32_t pid_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PROCESS_NONE,
|
||||||
|
PROCESS_KERNEL
|
||||||
|
} processes_standard_E;
|
||||||
|
|
||||||
|
typedef struct process_T process_T;
|
||||||
|
struct process_T {
|
||||||
|
char name [128];
|
||||||
|
pid_t id;
|
||||||
|
void* chunk;
|
||||||
|
uint32_t chunk_id;
|
||||||
|
|
||||||
|
page_map_T* page_map;
|
||||||
|
elf_executable_T* executable;
|
||||||
|
|
||||||
|
uint32_t num_threads;
|
||||||
|
void* threads;
|
||||||
|
bitmap_T thread_ids;
|
||||||
|
|
||||||
|
process_T* parent;
|
||||||
|
process_T* childs;
|
||||||
|
process_T* prev;
|
||||||
|
process_T* next;
|
||||||
|
};
|
||||||
|
|
||||||
|
void process_kernel_spawn (elf_executable_T* executable);
|
||||||
|
pid_t process_spawn (pid_t parent, string_t name, elf_executable_T* executable, void* buffer);
|
||||||
|
int32_t process_get_thread_id (process_T* process);
|
||||||
|
void process_clear_thread_id (process_T* process, uint32_t id);
|
||||||
|
void process_kill_pid (pid_t pid);
|
||||||
|
void process_kill (process_T* process);
|
||||||
|
|
||||||
|
#endif //NOX_PROCESS_H
|
|
@ -1,4 +1,25 @@
|
||||||
// This file is part of noxos and licensed under the MIT open source license
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOX_SCHEDULER_H
|
#ifndef NOX_SCHEDULER_H
|
||||||
#define NOX_SCHEDULER_H
|
#define NOX_SCHEDULER_H
|
||||||
|
@ -42,8 +63,6 @@ void scheduler_start_thread (thread_T* thread);
|
||||||
void scheduler_kill_thread (thread_T* thread);
|
void scheduler_kill_thread (thread_T* thread);
|
||||||
|
|
||||||
pid_t scheduler_register_process (process_T* process);
|
pid_t scheduler_register_process (process_T* process);
|
||||||
void scheduler_pause_process (process_T* process);
|
|
||||||
void scheduler_start_process (process_T* process);
|
|
||||||
void scheduler_kill_process (process_T* process);
|
void scheduler_kill_process (process_T* process);
|
||||||
process_T* scheduler_get_process (pid_t pid);
|
process_T* scheduler_get_process (pid_t pid);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the “Software”), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||||
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NOX_THREAD_H
|
||||||
|
#define NOX_THREAD_H
|
||||||
|
|
||||||
|
#include "utils/stdtypes.h"
|
||||||
|
#include "platform/cpu.h"
|
||||||
|
#include "proc/process.h"
|
||||||
|
|
||||||
|
typedef struct thread_T thread_T;
|
||||||
|
struct thread_T{
|
||||||
|
cpu_state_T* state;
|
||||||
|
uint64_t cpu_time;
|
||||||
|
void* stack;
|
||||||
|
uint32_t stack_size;
|
||||||
|
process_T* process;
|
||||||
|
|
||||||
|
// Scheduling data
|
||||||
|
thread_T* global_prev;
|
||||||
|
thread_T* global_next;
|
||||||
|
|
||||||
|
thread_T* local_prev;
|
||||||
|
thread_T* local_next;
|
||||||
|
uint32_t local_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
thread_T* thread_spawn (pid_t process, void* function);
|
||||||
|
thread_T* thread_spawn_from_state (pid_t process, cpu_state_T* state);
|
||||||
|
void thread_start (thread_T* thread);
|
||||||
|
void thread_pause (thread_T* thread);
|
||||||
|
void thread_kill (thread_T* thread);
|
||||||
|
|
||||||
|
#endif //NOX_THREAD_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue