Initial import

This commit is contained in:
Jozef Nagy 2025-01-20 21:52:47 +01:00
commit 94aad4b8e1
Signed by untrusted user who does not match committer: crz
GPG key ID: 459A4811CEAC7068
77 changed files with 4414 additions and 0 deletions

1
.github/CODEOWNERS vendored Normal file
View file

@ -0,0 +1 @@
* @schkwve

2
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1,2 @@
github: schkwve

37
.github/ISSUE_TEMPLATE/01_BUG_REPORT.md vendored Normal file
View file

@ -0,0 +1,37 @@
---
name: Bug Report
about: Create a report to help AurixOS to improve
title: "bug: "
labels: "bug"
assignees: ""
---
# Bug Report
**AurixOS version:**
<!-- Please specify commit or tag version. -->
**Current behavior:**
<!-- Describe how the bug manifests. -->
**Expected behavior:**
<!-- Describe what you expect the behavior to be without the bug. -->
**Steps to reproduce:**
<!-- Explain the steps required to duplicate the issue, especially if you are able to provide a sample application. -->
**Related code:**
<!-- If you are able to illustrate the bug or feature request with an example, please provide it here. -->
```
insert short code snippets here
```
**Other information:**
<!-- List any other information that is relevant to your issue. Related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->

View file

@ -0,0 +1,35 @@
---
name: Feature Request
about: Suggest an idea for this project
title: "feat: "
labels: "enhancement"
assignees: ""
---
# Feature Request
**Describe the Feature Request**
<!-- A clear and concise description of what the feature request is. Please include if your feature request is related to a problem. -->
**Describe Preferred Solution**
<!-- A clear and concise description of what you want to happen. -->
**Describe Alternatives**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
**Related Code**
<!-- If you are able to illustrate the bug or feature request with an example, please provide it here. -->
**Additional Context**
<!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to add, use case, Stack Overflow links, forum links, screenshots, OS if applicable, etc. -->
**If the feature request is approved, would you be willing to submit a PR?**
_(Help can be provided if you need assistance submitting a PR)_
- [ ] Yes
- [ ] No

View file

@ -0,0 +1,7 @@
---
name: Codebase improvement
about: Provide your feedback for the existing codebase. Suggest a better solution for algorithms, development tools, etc.
title: "dev: "
labels: "enhancement"
assignees: ""
---

View file

@ -0,0 +1,9 @@
---
name: Support Question
about: Question on how to use this project
title: "support: "
labels: "question"
assignees: ""
---
# Support Question

2
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,2 @@
---
blank_issues_enabled: false

40
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,40 @@
<!--- Please provide a general summary of your changes in the title above -->
## Pull Request type
<!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. -->
Please check the type of change your PR introduces:
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
Issue Number: N/A
## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by this PR. -->
-
-
-
## Does this introduce a breaking change?
- [ ] Yes
- [ ] No
<!-- If this does introduce a breaking change, please describe the impact and migration path for existing applications below. -->
## Other information
<!-- Any other information that is important to this PR, such as screenshots of how the component looks before and after the change. -->

14
.gitignore vendored Normal file
View file

@ -0,0 +1,14 @@
build/
release/
sysroot/
ovmf/
.vscode/
.ccls-cache/
.DS_Store
Brewfile.lock.json
*.o
*.d
*.iso
*.img
*.log

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "boot/platform/uefi/libefi"]
path = boot/platform/uefi/libefi
url = https://github.com/aurixos/efi

36
Brewfile Normal file
View file

@ -0,0 +1,36 @@
####
# COMMON PACKAGES
##
# These packages are required for building and running AurixOS
# regardless of the target architecture.
###
brew "git"
brew "make"
brew "gptfdisk"
brew "xorriso"
brew "qemu"
brew "zig"
brew "util-linux" if OS.mac?
brew "gsed" if OS.mac?
####
# x86_64-SPECIFIC PACKAGES
##
# These packages are required for building and running AurixOS
# ONLY for the x86_64 architecture.
###
brew "x86_64-elf-binutils"
brew "x86_64-elf-gcc"
brew "nasm"
####
# aarch64-SPECIFIC PACKAGES
##
# These packages are required for building and running AurixOS
# ONLY for the aarch64 architecture.
###
brew "aarch64-elf-binutils"
brew "aarch64-elf-gcc"

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024-2025, Jozef Nagy
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.

113
Makefile Normal file
View file

@ -0,0 +1,113 @@
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
export ARCH ?= x86_64
export PLATFORM ?= generic-pc
export ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export BUILD_DIR ?= $(ROOT_DIR)/build
export SYSROOT_DIR ?= $(ROOT_DIR)/sysroot
export RELEASE_DIR ?= $(ROOT_DIR)/release
export GITREV := $(shell git rev-parse --short HEAD)
NOUEFI ?= y
LIVECD := $(RELEASE_DIR)/aurix-$(GITREV)-livecd_$(ARCH)-$(PLATFORM).iso
LIVEHDD := $(RELEASE_DIR)/aurix-$(GITREV)-livehdd_$(ARCH)-$(PLATFORM).img
LIVESD := $(RELEASE_DIR)/aurix-$(GITREV)-livesd_$(ARCH)-$(PLATFORM).img
QEMU_FLAGS := -m 2G -smp 4 -serial stdio
.PHONY: boot
boot:
@printf ">>> Building bootloader...\n"
ifneq (,$(filter $(ARCH),i686 x86_64))
@$(MAKE) -C boot PLATFORM=pc-bios
else
@$(MAKE) -C boot
endif
ifneq (,$(filter $(ARCH),i686 x86_64 arm32 aarch64))
ifeq ($(NOUEFI),n)
@$(MAKE) -C boot PLATFORM=uefi
endif
endif
.PHONY: kernel
kernel:
@printf ">>> Building kernel...\n"
@$(MAKE) -C kernel
.PHONY: install
install: boot kernel
@printf ">>> Building sysroot...\n"
@mkdir -p $(SYSROOT_DIR)
ifneq (,$(filter $(ARCH),i686 x86_64))
@$(MAKE) -C boot install PLATFORM=pc-bios
else
@$(MAKE) -C boot install
endif
ifneq (,$(filter $(ARCH),i686 x86_64 arm32 aarch64))
ifeq ($(NOUEFI),n)
@$(MAKE) -C boot install PLATFORM=uefi
endif
endif
@$(MAKE) -C kernel install
ovmf:
@printf ">>> Downloading OVMF images...\n"
@utils/download-ovmf.sh
.PHONY: livecd
livecd: install
@printf ">>> Generating Live CD..."
@mkdir -p $(RELEASE_DIR)
@utils/arch/$(ARCH)/generate-iso.sh $(LIVECD)
.PHONY: livehdd
livehdd: install
@printf ">>> Generating Live HDD..."
@mkdir -p $(RELEASE_DIR)
@utils/arch/$(ARCH)/generate-hdd.sh $(LIVEHDD)
.PHONY: livesd
livesd: install
@$(error SD Card Generation is not supported yet!)
@printf ">>> Generating Live SD Card..."
@mkdir -p $(RELEASE_DIR)
@utils/arch/$(ARCH)/generate-sd.sh $(LIVESD)
.PHONY: run
run: livecd
@printf ">>> Running QEMU...\n"
@qemu-system-$(ARCH) $(QEMU_FLAGS) $(QEMU_MACHINE_FLAGS) -cdrom $(LIVECD)
.PHONY: run-uefi
run-uefi: livecd ovmf
@printf ">>> Running QEMU (UEFI)...\n"
@qemu-system-$(ARCH) $(QEMU_FLAGS) $(QEMU_MACHINE_FLAGS) -bios ovmf/ovmf-$(ARCH).fd -cdrom $(LIVECD)
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR) $(SYSROOT_DIR)
.PHONY: distclean
distclean:
@rm -rf $(BUILD_DIR) $(SYSROOT_DIR) $(RELEASE_DIR) ovmf/

135
README.md Normal file
View file

@ -0,0 +1,135 @@
<h1 align="center">
<a href="https://github.com/aurixos/os">
<img src="docs/images/logo.png" alt="Logo" width="100" height="100">
</a>
</h1>
<div align="center">
AurixOS
<br />
<br />
<a href="https://github.com/aurixos/os/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+">Report a Bug</a>
·
<a href="https://github.com/aurixos/os/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feat%3A+">Request a Feature</a>
.
<a href="https://github.com/aurixos/os/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+">Ask a Question</a>
</div>
<br />
<div align="center">
[![Project license](https://img.shields.io/github/license/aurixos/os.svg?style=flat-square)](LICENSE)
[![Discord Chat](https://img.shields.io/discord/1234051470182055988)](https://discord.com/invite/hgbZ6wFP4n)
</div>
<details open="open">
<summary>Table of Contents</summary>
- [About](#about)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Building](#building)
- [Running](#running)
- [Support](#support)
- [Contributing](#contributing)
- [Authors & contributors](#authors--contributors)
- [Security](#security)
- [License](#license)
- [Acknowledgements](#acknowledgements)
</details>
---
## About
AurixOS is a general-purpose operating system, meant to take security, performance and usability to the next level.
<!--
<details>
<summary>Screenshots</summary>
<br>
| Title |
| :---------------------------------------------------------------: |
| <img src="docs/images/screenshot.png" title="Title" width="100%"> |
</details>
-->
## Getting Started
Latest official releases of AurixOS are available for download [here](https://github.com/aurixos/os/releases).
### Prerequisites
If you have [Homebrew](https://brew.sh) installed, simply run `brew bundle` to install **all** required build dependencies (incl. packages to build AurixOS for every supported architecture).
Alternatively, read the [Brewfile](Brewfile) in the root of this repository and install the required (and optional) packages manually.
### Building
To build AurixOS, simply run `make` in the root directory of this repository.
To change the build target, run `make ARCH=arch PLATFORM=platform`, where `arch` is the target architecture, and `platform` is the target platform (Default is set to `x86_64`/`generic-pc`).
#### Possible/planned targets:
##### i686 / x86_64
- `generic-pc`
##### arm32 (not available yet)
- `raspi2`
##### aarch64
- `raspi3` (not available yet)
- `raspi4` (limited support)
- `raspi5` (not available yet)
> [!NOTE]
> On x86(_64) architectures, a UEFI bootloader will be automatically built and packaged together together with a legacy stub. On arm32 and aarch64, invoke Make with `NOUEFI=n` modifier to create a UEFI-capable image.
Inputting an invalid architecture/platform combination will result in an error.
Building AurixOS images is also supported with Make recipes:
- `livecd` builds a CD-ROM image (.iso)
- `livehdd` builds a HDD image (.img)
- `livesd` builds an SD Card image (.img)
Please note that not all bootable images can be created for all platforms (eg. `rpi4` only supports creating an SD Card image). Any attempt at creating an unsupported image will result in an error.
All generated images reside in the `release/` directory and follow this naming scheme:
`aurixos-live[MEDIA]-[GIT_REV]_[ARCH]-[PLATFORM].iso`
`make help` shows you all available build options
## Running
To run AurixOS on QEMU, run `make run` (optionally, append `ARCH=arch PLATFORM=platform` if you're building/running AurixOS on an architecture other than x86_64).
Alternatively, you can boot AurixOS on a physical machine by running `dd if=release/<usb-image>.img of=/dev/<target USB drive> bs=1M` and booting off of this USB drive.
## Support
If you have any questions, feel free to open a [GitHub issue](https://github.com/aurixos/os/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+).
Alternatively, you can visit us:
- on our [Discord server](https://discord.com/invite/hgbZ6wFP4n)
- on #aurixos at [irc.libera.chat](https://libera.chat/) ([Kiwi IRC](https://kiwiirc.com/client/irc.libera.chat/?&theme=cli#aurixos))
## Contributing
First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are **greatly appreciated**.
Please read [our contribution guidelines](docs/CONTRIBUTING.md), and thank you for being involved!
## Authors & contributors
For a full list of all authors and contributors, see [the contributors page](https://github.com/aurixos/os/contributors).
## Security
AurixOS follows good practices of security, but 100% security cannot be assured.
AurixOS is provided **"as is"** without any **warranty**. Use at your own risk.
_For more information and to report security issues, please refer to our [security documentation](docs/SECURITY.md)._
## License
This project is licensed under the **MIT license**.
See [LICENSE](LICENSE) for more information.

49
boot/Makefile Normal file
View file

@ -0,0 +1,49 @@
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
.DEFAULT_GOAL := all
export INCLUDE_DIRS := $(BOOT_ROOT)/include
export BUILD_DIR ?= build
export SYSROOT_DIR ?= sysroot
export ASFLAGS :=
export CFLAGS := -D__$(ARCH) -D_AXBOOT -ffreestanding -fno-stack-protector -fno-stack-check -MMD -MP
export LDFLAGS := -nostdlib
export BOOT_ROOT := $(ROOT_DIR)/boot
ifeq ($(DEBUG),yes)
CFLAGS += -O0 -g3
else
CFLAGS += -O2
endif
.PHONY: all
all:
@$(MAKE) -C platform/$(PLATFORM) all
.PHONY: install
install:
@$(MAKE) -C platform/$(PLATFORM) install
.PHONY: clean
clean:
@$(MAKE) -C platform/$(PLATFORM) clean

View file

@ -0,0 +1,69 @@
/*********************************************************************************/
/* Module Name: boot.S */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
.section ".text.boot"
.global _start
_start:
//
// hello, am i on the main core?
//
mrs x1, mpidr_el1
and x1, x1, #3
cbz x1, 2f
//
// no? alright then, sorry for interrupting. *leaves*
//
1:
wfe
b 1b
//
// ok cool now execute this huge pile of horrible code
// thanks :>
//
2:
//
// let the stack live below our code
//
ldr x1, =_start
mov sp, x1
//
// no junk allowed in .bss!
//
ldr x1, =__bss_start
ldr w2, =__bss_size
3: cbz w2, 4f
str xzr, [x1], #8
sub w2, w2, #1
cbnz w2, 3b
4:
bl menu_main
//
// crazy? i was crazy once.
// they locked me in a room. a rubber room. a rubber room with rats.
// and rats make me crazy.
// (bootloader returned, just halt the whole thing)
//
b 1b

View file

@ -0,0 +1,57 @@
/*********************************************************************************/
/* Module Name: linker.ld */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
SECTIONS
{
. = 0x80000;
.text : {
*(.text .text.*)
*(.gnu.linkonce.t*)
}
.rodata : {
*(.rodata .rodata.*)
*(.gnu.linkonce.r*)
}
PROVIDE(_data = .);
.data : {
*(.data .data.*)
*(.gnu.linkonce.d*)
}
.bss (NOLOAD) : {
. = ALIGN(16);
__bss_start = .;
*(.bss .bss.*)
*(COMMON)
__bss_end = .;
}
_end = .;
/DISCARD/ : {
*(.comment)
*(.gnu*)
*(.note*)
*(.eh_frame*)
}
}
/*__bss_size = (__bss_end - __bss_start) >> 3;*/

View file

View file

@ -0,0 +1,80 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Module Name: boot-cd.asm ;;
;; Project: AurixOS ;;
;; ;;
;; Copyright (c) 2024-2025 Jozef Nagy ;;
;; ;;
;; This source is subject to the MIT License. ;;
;; See License.txt in the root of this repository. ;;
;; All other rights reserved. ;;
;; ;;
;; 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. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[bits 16]
[org 0x7c00]
jmp 0x0000:AxBootEntry
times 8-($-$$) db 0
bi_PrimaryVolumeDescriptor dd 0
bi_BootFileLocation dd 0
bi_BootFileLength dd 0
bi_Checksum dd 0
bi_Reserved times 40 db 0
;;
;; BIOS bootloader on i686 is just a placeholder
;; incase it ever becomes a thing... for now it just
;; notifies the user that you can't boot AurixOS
;; without UEFI on i686.
;;
%include "arch/strings.inc"
AxBootEntry:
;;
;; Set 80x50 text mode and clear the screen
;;
mov ax, 0x03
int 0x10
xor bx, bx
mov ax, 0x1112
int 0x10
mov ah, 0
int 0x10
;;
;; Display an error message and halt
;;
mov si, sErrorUnbootable
call PrintString
mov si, sPressToReboot
call PrintString
jmp AxBootHalt
PrintString:
lodsb
or al, al
jz .done
mov ah, 0x0e
mov bx, 0x0007
int 0x10
jmp PrintString
.done:
ret
AxBootHalt:
cli
hlt
jmp AxBootHalt
times 510-($-$$) db 0
dw 0xaa55

View file

@ -0,0 +1,72 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Module Name: boot-hdd.asm ;;
;; Project: AurixOS ;;
;; ;;
;; Copyright (c) 2024-2025 Jozef Nagy ;;
;; ;;
;; This source is subject to the MIT License. ;;
;; See License.txt in the root of this repository. ;;
;; All other rights reserved. ;;
;; ;;
;; 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. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[bits 16]
[org 0x7c00]
jmp 0x0000:AxBootEntry
;;
;; BIOS bootloader on i686 is just a placeholder
;; incase it ever becomes a thing... for now it just
;; notifies the user that you can't boot AurixOS
;; without UEFI on i686.
;;
%include "arch/strings.inc"
AxBootEntry:
;;
;; Set 80x50 text mode and clear the screen
;;
mov ax, 0x03
int 0x10
xor bx, bx
mov ax, 0x1112
int 0x10
mov ah, 0
int 0x10
;;
;; Display an error message and halt
;;
mov si, sErrorUnbootable
call PrintString
mov si, sPressToReboot
call PrintString
jmp AxBootHalt
PrintString:
lodsb
or al, al
jz .done
mov ah, 0x0e
mov bx, 0x0007
int 0x10
jmp PrintString
.done:
ret
AxBootHalt:
cli
hlt
jmp AxBootHalt
times 510-($-$$) db 0
dw 0xaa55

View file

@ -0,0 +1,21 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Module Name: strings.inc ;;
;; Project: AurixOS ;;
;; ;;
;; Copyright (c) 2024-2025 Jozef Nagy ;;
;; ;;
;; This source is subject to the MIT License. ;;
;; See License.txt in the root of this repository. ;;
;; All other rights reserved. ;;
;; ;;
;; 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. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sErrorUnbootable: db 0x0d, 0x0a, 0x0d, 0x0a, "Error: AurixOS can only be booted via UEFI on i686!", 0x0d, 0x0a, 0
sPressToReboot: db "Press Ctrl+Alt+Del to reboot", 0

View file

View file

@ -0,0 +1,35 @@
/*********************************************************************************/
/* Module Name: gdt.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <arch/cpu/gdt.h>
#include <arch/mm/paging.h>
#include <stdint.h>
void gdt_set_entry(struct gdt_descriptor *entry, uint32_t base, uint32_t limit, uint8_t access,
uint8_t flags)
{
entry->limit_low = (limit >> 8) & 0xffff;
entry->base_low = (base >> 8) & 0xffff;
entry->base_mid = (base >> 16) & 0xff;
entry->access = access;
entry->limit_high = (limit >> 16) & 0xf;
entry->flags = flags;
entry->base_high = (base >> 24) & 0xff;
}

View file

@ -0,0 +1,60 @@
/*********************************************************************************/
/* Module Name: serial.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <debug/serial.h>
#include <arch/cpu/cpu.h>
#include <stdint.h>
#define COM1 0x3f8
static int is_tx_empty(void)
{
return inb(COM1 + 5) & 0x20;
}
void serial_init(void)
{
// TODO: Initialize all COM ports
outb(COM1 + 1, 0x00);
outb(COM1 + 3, 0x80);
outb(COM1, 0x03);
outb(COM1 + 1, 0x00);
outb(COM1 + 3, 0x03);
outb(COM1 + 2, 0xC7);
outb(COM1 + 4, 0x0B);
outb(COM1 + 4, 0x0F);
}
void serial_send(char c)
{
while (is_tx_empty() == 0);
outb(COM1, c);
}
void serial_sendstr(char *s)
{
while (*s != '\0') {
if (*s == '\r') {
s++;
continue;
}
serial_send(*s++);
}
}

View file

@ -0,0 +1,79 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Module Name: boot-cd.asm ;;
;; Project: AurixOS ;;
;; ;;
;; Copyright (c) 2024-2025 Jozef Nagy ;;
;; ;;
;; This source is subject to the MIT License. ;;
;; See License.txt in the root of this repository. ;;
;; All other rights reserved. ;;
;; ;;
;; 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. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[bits 16]
[org 0x7c00]
jmp 0x0000:AxBootEntry
times 8-($-$$) db 0
bi_PrimaryVolumeDescriptor dd 0
bi_BootFileLocation dd 0
bi_BootFileLength dd 0
bi_Checksum dd 0
bi_Reserved times 40 db 0
;;
;; BIOS bootloader on x86_64 is just a placeholder
;; incase it ever becomes a thing... for now it just
;; notifies the user that you can't boot AurixOS
;; without UEFI on x86_64.
;;
%include "strings.inc"
AxBootEntry:
;;
;; Set 80x50 text mode and clear the screen
;;
mov ax, 0x03
int 0x10
xor bx, bx
mov ax, 0x1112
int 0x10
mov ah, 0
int 0x10
;;
;; Display an error message and halt
;;
mov si, sErrorUnbootable
call PrintString
mov si, sPressToReboot
call PrintString
jmp AxBootHalt
PrintString:
lodsb
or al, al
jz .done
mov ah, 0x0e
mov bx, 0x0007
int 0x10
jmp PrintString
.done:
ret
AxBootHalt:
hlt
jmp AxBootHalt
times 510-($-$$) db 0
dw 0xaa55

View file

@ -0,0 +1,71 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Module Name: boot-hdd.asm ;;
;; Project: AurixOS ;;
;; ;;
;; Copyright (c) 2024-2025 Jozef Nagy ;;
;; ;;
;; This source is subject to the MIT License. ;;
;; See License.txt in the root of this repository. ;;
;; All other rights reserved. ;;
;; ;;
;; 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. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[bits 16]
[org 0x7c00]
jmp 0x0000:AxBootEntry
;;
;; BIOS bootloader on x86_64 is just a placeholder
;; incase it ever becomes a thing... for now it just
;; notifies the user that you can't boot AurixOS
;; without UEFI on x86_64.
;;
%include "strings.inc"
AxBootEntry:
;;
;; Set 80x50 text mode and clear the screen
;;
mov ax, 0x03
int 0x10
xor bx, bx
mov ax, 0x1112
int 0x10
mov ah, 0
int 0x10
;;
;; Display an error message and halt
;;
mov si, sErrorUnbootable
call PrintString
mov si, sPressToReboot
call PrintString
jmp AxBootHalt
PrintString:
lodsb
or al, al
jz .done
mov ah, 0x0e
mov bx, 0x0007
int 0x10
jmp PrintString
.done:
ret
AxBootHalt:
hlt
jmp AxBootHalt
times 510-($-$$) db 0
dw 0xaa55

View file

@ -0,0 +1,21 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Module Name: strings.inc ;;
;; Project: AurixOS ;;
;; ;;
;; Copyright (c) 2024-2025 Jozef Nagy ;;
;; ;;
;; This source is subject to the MIT License. ;;
;; See License.txt in the root of this repository. ;;
;; All other rights reserved. ;;
;; ;;
;; 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. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sErrorUnbootable: db 0x0d, 0x0a, 0x0d, 0x0a, "Error: AurixOS can only be booted via UEFI on x86_64!", 0x0d, 0x0a, 0
sPressToReboot: db "Press Ctrl+Alt+Del to reboot", 0

View file

12
boot/base/axboot.cfg Normal file
View file

@ -0,0 +1,12 @@
; This is a comment
entry "AurixOS" {
PROTOCOL="aurix"
IMAGE_PATH="boot:///System/axkrnl.sys"
}
;; UEFI only
entry "Windows" {
PROTOCOL="chainload"
IMAGE_PATH="boot:///EFI/Microsoft/bootmgfw.efi"
}

View file

@ -0,0 +1,78 @@
/*********************************************************************************/
/* Module Name: config.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <config/config.h>
#include <firmware/file.h>
#include <lib/string.h>
#include <print.h>
#include <axboot.h>
#include <stdint.h>
#include <stddef.h>
char *config_paths[] = {
"\\axboot.cfg",
"\\System\\axboot.cfg",
"\\EFI\\axboot.cfg",
"\\EFI\\BOOT\\axboot.cfg",
};
void config_init(void)
{
FILE *config_file;
char *config_buffer;
int filesize;
for (size_t i = 0; i < ARRAY_LENGTH(config_paths); i++) {
config_file = fw_file_open(NULL, config_paths[i]);
if (config_file != NULL) {
break;
}
}
if (config_file == NULL) {
//print("No configuration file found! Please refer to the AxBoot documentation.\n");
//print("Entering console...\n\n");
//console();
}
filesize = fw_file_size(config_file);
config_buffer = malloc(filesize);
if (config_buffer == NULL) {
log("Entering console...\r\n\r\n");
//console();
}
fw_file_read(config_file, filesize, config_buffer);
// TODO: parse configuration file
free(config_buffer);
/*
if (config_errors != 0 || config_get_menu_root() == NULL) {
//print("\nConfiguration invalid!\n");
//print("Please correct your config file.\n");
//print("Entering console...\n\n");
//console();
}
*/
fw_file_close(config_file);
}

128
boot/common/lib/string.c Normal file
View file

@ -0,0 +1,128 @@
/*********************************************************************************/
/* Module Name: string.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <lib/string.h>
#include <stdint.h>
#include <stddef.h>
size_t mbstowcs(wchar_t *dest, const char **src, size_t len)
{
char *lsrc = (char *)*src;
size_t count = len;
if (dest == NULL) {
return 0;
}
while (count) {
if ((*dest = *lsrc) == 0) {
lsrc = NULL;
break;
}
if (*dest >= 0x80) {
return -1;
}
lsrc++;
dest++;
count--;
}
return len - count;
}
size_t strlen(const char *str)
{
size_t count = 0;
if (str == NULL) {
return 0;
}
do {
count++;
} while (str[count] != '\0');
return count;
}
char *strcpy(char *dest, const char *src)
{
if (dest == NULL || src == NULL) {
return NULL;
}
char *pdest = dest;
while (*src != '\0') {
*dest = *src;
dest++;
src++;
}
*dest = '\0';
return pdest;
}
void *memset(void *dest, int val, size_t len)
{
unsigned char *ptr = dest;
while (len-- > 0) {
*ptr++ = (unsigned char)val;
}
return dest;
}
void *memcpy(void *dest, void *src, size_t len)
{
char *d = (char *)dest;
const char *s = (const char *)src;
while (len-- > 0) {
*d++ = *s++;
}
return dest;
}
int memcmp(const void *a, const void *b, size_t len)
{
unsigned char *ap = (unsigned char *)a;
unsigned char *bp = (unsigned char *)b;
int ret = 0;
if (a == b) {
return 0;
}
while (len > 0) {
if (*ap != *bp) {
ret = (*ap > *bp) ? 1 : -1;
break;
}
len--;
ap++;
bp++;
}
return ret;
}

64
boot/common/print.c Normal file
View file

@ -0,0 +1,64 @@
/*********************************************************************************/
/* Module Name: print.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#define NANOPRINTF_IMPLEMENTATION
#define NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS 1
#define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 1
#define NANOPRINTF_USE_FLOAT_FORMAT_SPECIFIERS 1
#define NANOPRINTF_USE_LARGE_FORMAT_SPECIFIERS 1
#define NANOPRINTF_USE_BINARY_FORMAT_SPECIFIERS 0
#define NANOPRINTF_USE_WRITEBACK_FORMAT_SPECIFIERS 0
#include <nanoprintf.h>
#include <debug/serial.h>
#include <print.h>
#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
int32_t _fltused = 0;
int32_t __eqdf2 = 0;
int32_t __ltdf2 = 0;
void log(const char *fmt, ...)
{
va_list args;
char buf[4096];
va_start(args, fmt);
npf_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
//printstr(buf);
}
void debug(const char *fmt, ...)
{
va_list args;
char buf[4096];
va_start(args, fmt);
npf_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
//serial_sendstr(buf);
}

View file

@ -0,0 +1,38 @@
/*********************************************************************************/
/* Module Name: paging.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _MM_PAGING_H
#define _MM_PAGING_H
#include <firmware/memmap.h>
#include <stddef.h>
#include <stdint.h>
#define PAGE_SIZE 0x1000
int paging_init(struct memory_map_info *memmap);
void paging_identity_map(uint64_t addr);
void paging_map(uint64_t phys, uint64_t virt);
void paging_unmap(uint64_t virt);
void *paging_allocate(size_t np);
#endif /* _MM_PAGING_H */

View file

View file

View file

View file

@ -0,0 +1,116 @@
/*********************************************************************************/
/* Module Name: cpu.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _ARCH_CPU_CPU_H
#define _ARCH_CPU_CPU_H
#include <stdint.h>
////
// Utilities
///
static inline void cpu_disable_interrupts(void)
{
__asm__ volatile("cli" ::: "memory");
}
static inline uint64_t read_cr0()
{
uint64_t val;
__asm__ volatile("mov %%cr0, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr2()
{
uint64_t val;
__asm__ volatile("mov %%cr2, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr3()
{
uint64_t val;
__asm__ volatile("mov %%cr3, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr4()
{
uint64_t val;
__asm__ volatile("mov %%cr4, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr8()
{
uint64_t val;
__asm__ volatile("mov %%cr8, %0"
: "=r"(val));
return val;
}
static inline void write_cr0(uint64_t val)
{
__asm__ volatile("mov %0, %%cr0"
:: "r"(val));
}
static inline void write_cr2(uint64_t val)
{
__asm__ volatile("mov %0, %%cr2"
:: "r"(val));
}
static inline void write_cr3(uint64_t val)
{
__asm__ volatile("mov %0, %%cr3"
:: "r"(val) : "memory");
}
static inline void write_cr4(uint64_t val)
{
__asm__ volatile("mov %0, %%cr4"
:: "r"(val));
}
static inline void write_cr8(uint64_t val)
{
__asm__ volatile("mov %0, %%cr8"
:: "r"(val));
}
static inline uint8_t inb(uint16_t port)
{
uint8_t ret;
__asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port) : "memory");
return ret;
}
static inline void outb(uint16_t port, uint8_t val)
{
__asm__ volatile("outb %b0, %w1" :: "a"(val), "Nd"(port) : "memory");
}
#endif /* _ARCH_CPU_CPU_H */

View file

@ -0,0 +1,67 @@
/*********************************************************************************/
/* Module Name: gdt.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _ARCH_CPU_GDT_H
#define _ARCH_CPU_GDT_H
#include <stdint.h>
struct gdt_descriptor {
uint16_t limit_low;
uint16_t base_low;
uint8_t base_mid;
uint8_t access;
uint8_t limit_high : 4;
uint8_t flags : 4;
uint8_t base_high;
} __attribute__((packed));
struct tss_descriptor {
struct gdt_descriptor gdt;
uint32_t base_high;
uint32_t reserved;
} __attribute__((packed));
struct tss {
uint32_t reserved;
uint32_t rsp0[2];
uint32_t rsp1[2];
uint32_t rsp2[2];
uint32_t reserved0[2];
uint32_t ist0[2];
uint32_t ist1[2];
uint32_t ist2[2];
uint32_t ist3[2];
uint32_t ist4[2];
uint32_t ist5[2];
uint32_t ist6[2];
uint32_t ist7[2];
uint32_t reserved1[4];
uint16_t iomap_base;
} __attribute__((packed));
struct gdtr {
uint16_t limit;
uint64_t base;
} __attribute__((packed));
void gdt_set_entry(struct gdt_descriptor *entry, uint32_t base, uint32_t limit, uint8_t access,
uint8_t flags);
#endif /* _ARCH_CPU_GDT_H */

View file

@ -0,0 +1,29 @@
/*********************************************************************************/
/* Module Name: paging.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _MM_PAGING_H
#define _MM_PAGING_H
#include <firmware/memmap.h>
#include <stdint.h>
#define PAGE_SIZE 0x1000
#endif /* _MM_PAGING_H */

View file

32
boot/include/axboot.h Normal file
View file

@ -0,0 +1,32 @@
/*********************************************************************************/
/* Module Name: axboot.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _AXBOOT_H
#define _AXBOOT_H
#include <utils.h>
#define BOOTLOADER_NAME_STR "AxBoot"
#define BOOTLOADER_VERSION_STR "0.1"
#ifndef UNREACHABLE
#define UNREACHABLE()
#endif
#endif /* _AXBOOT_H */

1137
boot/include/nanoprintf.h Normal file

File diff suppressed because it is too large Load diff

32
boot/include/print.h Normal file
View file

@ -0,0 +1,32 @@
/*********************************************************************************/
/* Module Name: print.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _PRINT_H
#define _PRINT_H
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
void log(const char *fmt, ...);
void debug(const char *fmt, ...);
void printstr(const char *str);
#endif /* _PRINT_H */

28
boot/include/utils.h Normal file
View file

@ -0,0 +1,28 @@
/*********************************************************************************/
/* Module Name: utils.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _UTILS_H
#define _UTILS_H
#define ARRAY_LENGTH(x) ((sizeof(x)) / (sizeof((x[0]))))
#define ROUND_DOWN(x, a) (((x)) & (~((a) - 1)))
#define ROUND_UP(x, a) ((((x)) + (a) - 1) & (~((a) - 1)))
#endif /* _UTILS_H */

View file

@ -0,0 +1,64 @@
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
ARCH_COMMON := x86
INCLUDE_DIRS += include/arch/$(ARCH)
BOOT_AS := nasm
BOOT_CC := $(ARCH)-elf-gcc
BOOT_LD := $(ARCH)-elf-ld
BOOT_ASFLAGS := $(ASFLAGS) \
$(foreach d, $(INCLUDE_DIRS), -I$d)
BOOT_CFLAGS := $(CFLAGS) \
-mno-red-zone \
-mno-stack-arg-probe
BOOT_LDFLAGS := $(LDFLAGS)
$(shell find . -type d \( -name arch -o -name platform \) -prune -name '*.c')
BOOT_ASFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH) -type d -name arch/$(ARCH)/uefi -prune -name '*.S')
BOOT_CFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH) -type d -name arch/$(ARCH)/uefi -prune -name '*.c')
BOOT_OBJ := $(BOOT_CFILES:%.c=$(BUILD_DIR)/boot/boot/%.c.o) \
$(BOOT_ASFILES:%.S=$(BUILD_DIR)/boot/boot/%.S.o) \
$(COMMON_CFILES:common/%.c=$(BUILD_DIR)/boot/boot/common/%.c.o)
# stage 1 bootloader
STAGE1_HDD := $(BUILD_DIR)/boot/pc-bios/stage1-hdd.bin
STAGE1_CD := $(BUILD_DIR)/boot/pc-bios/stage1-cd.bin
STAGE1 := $(STAGE1_HDD) $(STAGE1_CD)
.PHONY: all
all: $(STAGE1)
.PHONY: install
install:
@:
# stage 1
$(STAGE1_HDD): $(BOOT_ROOT)/arch/$(ARCH)/stage1/boot-hdd.asm
@mkdir -p $(@D)
@printf " AS\tboot/arch/$(ARCH)/stage1/stage1-hdd.bin\n"
@nasm -fbin -I$(BOOT_ROOT)/arch/$(ARCH)/stage1 $< -o $@
$(STAGE1_CD): $(BOOT_ROOT)/arch/$(ARCH)/stage1/boot-cd.asm
@mkdir -p $(@D)
@printf " AS\tboot/arch/$(ARCH)/stage1/stage1-cd.bin\n"
@nasm -fbin -I$(BOOT_ROOT)/arch/$(ARCH)/stage1 $< -o $@

View file

@ -0,0 +1,85 @@
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
BOOTFILE := $(BUILD_DIR)/boot/raspi4/axboot.elf
INCLUDE_DIRS += $(BOOT_ROOT)/include \
$(BOOT_ROOT)/include/arch/$(ARCH) \
$(BOOT_ROOT)/include/platform/$(PLATFORM)
BOOT_AS := $(ARCH)-elf-gcc
BOOT_CC := $(ARCH)-elf-gcc
BOOT_LD := $(ARCH)-elf-ld
BOOT_ASFLAGS := $(ASFLAGS) \
$(foreach d, $(INCLUDE_DIRS), -I$d)
BOOT_CFLAGS := $(CFLAGS) \
$(foreach d, $(INCLUDE_DIRS), -I$d)
BOOT_LDFLAGS := $(LDFLAGS)
COMMON_CFILES := $(shell find $(BOOT_ROOT)/common -name '*.c')
COMMON_ARCH_CFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH)/common -name '*.c')
COMMON_ARCH_ASFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH)/common -name '*.S')
PLATFORM_CFILES := $(shell find $(BOOT_ROOT)/platform/$(PLATFORM) -name '*.c')
PLATFORM_ASFILES := $(shell find $(BOOT_ROOT)/platform/$(PLATFORM) -name '*.S')
BOOT_OBJ := $(COMMON_CFILES:$(BOOT_ROOT)/common/%.c=$(BUILD_DIR)/boot/raspi4/common/%.c.o) \
$(COMMON_ARCH_CFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.c=$(BUILD_DIR)/boot/raspi4/arch/%.c.o) \
$(COMMON_ARCH_ASFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.S=$(BUILD_DIR)/boot/raspi4/arch/%.S.o) \
$(PLATFORM_CFILES:$(BOOT_ROOT)/platform/$(PLATFORM)/%.c=$(BUILD_DIR)/boot/raspi4/%.c.o) \
$(PLATFORM_ASFILES:$(BOOT_ROOT)/platform/$(PLATFORM)/%.S=$(BUILD_DIR)/boot/raspi4/%.S.o)
.PHONY: all
all: $(BOOTFILE)
@:
.PHONY: install
install: all
@mkdir -p $(SYSROOT_DIR)
@printf " INSTALL\t/kernel.elf\n"
@cp $(BOOTFILE) $(SYSROOT_DIR)/kernel.elf
$(BOOTFILE): $(BOOT_OBJ)
@mkdir -p $(@D)
@printf " LD\t$(notdir $@)\n"
@$(BOOT_LD) $(BOOT_LDFLAGS) $^ -o $@
-include $(wildcard $(BUILD_DIR)/boot/*.d)
$(BUILD_DIR)/boot/raspi4/%.c.o: $(BOOT_ROOT)/platform/$(PLATFORM)/%.c
@mkdir -p $(@D)
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(BOOT_CC) $(BOOT_CFLAGS) -c $< -o $@
$(BUILD_DIR)/boot/raspi4/common/%.c.o: $(BOOT_ROOT)/common/%.c
@mkdir -p $(@D)
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(BOOT_CC) $(BOOT_CFLAGS) -c $< -o $@
$(BUILD_DIR)/boot/raspi4/arch/%.c.o: $(BOOT_ROOT)/arch/$(ARCH)/common/%.c
@mkdir -p $(@D)
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(BOOT_CC) $(BOOT_CFLAGS) -c $< -o $@
$(BUILD_DIR)/boot/raspi4/arch/%.S.o: $(BOOT_ROOT)/arch/$(ARCH)/common/%.S
@mkdir -p $(@D)
@printf " AS\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(BOOT_AS) $(BOOT_ASFLAGS) -c $< -o $@

116
boot/platform/uefi/Makefile Normal file
View file

@ -0,0 +1,116 @@
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
ifeq ($(ARCH),x86_64)
UEFISUF := X64
else ifeq ($(ARCH),i686)
UEFISUF := IA32
else ifeq ($(ARCH),arm)
UEFISUF := ARM
else ifeq ($(ARCH),aarch64)
UEFISUF := AA64
else ifeq ($(ARCH),riscv64)
UEFISUF := RISCV64
else
$(error Architecture not supported!)
endif
UEFI_BOOTFILE := $(BUILD_DIR)/boot/uefi/BOOT$(UEFISUF).EFI
INCLUDE_DIRS += $(BOOT_ROOT)/include \
$(BOOT_ROOT)/include/arch/$(ARCH) \
$(BOOT_ROOT)/include/arch/$(ARCH)/uefi \
$(BOOT_ROOT)/include/platform/$(PLATFORM) \
$(BOOT_ROOT)/platform/uefi/libefi
UEFI_AS := $(ARCH)-w64-mingw32-as
UEFI_CC := clang
UEFI_LD := clang
UEFI_ASFLAGS := $(ASFLAGS) \
-DAXBOOT_UEFI=1 \
$(foreach d, $(INCLUDE_DIRS), -I$d)
UEFI_CFLAGS := $(CFLAGS) \
-DAXBOOT_UEFI=1 \
$(foreach d, $(INCLUDE_DIRS), -I$d) \
-target $(ARCH)-unknown-windows \
-fshort-wchar \
-mno-red-zone \
-mno-stack-arg-probe
ifneq (,$(filter $(ARCH),i686 x86_64))
UEFI_CFLAGS += -mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2
endif
UEFI_LDFLAGS := $(LDFLAGS) \
-target $(ARCH)-unknown-windows \
-fuse-ld=lld-link \
-Wl,-subsystem:efi_application \
-Wl,-entry:uefi_entry
COMMON_CFILES := $(shell find $(BOOT_ROOT)/common -name '*.c')
COMMON_ARCH_CFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH)/common -name '*.c')
COMMON_ARCH_ASFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH)/common -name '*.S')
UEFI_CFILES := $(shell find $(BOOT_ROOT)/platform/uefi -name '*.c') $(shell find $(BOOT_ROOT)/arch/$(ARCH)/uefi -name '*.c')
UEFI_ASFILES := $(shell find $(BOOT_ROOT)/platform/uefi -name '*.S') $(shell find $(BOOT_ROOT)/arch/$(ARCH)/uefi -name '*.S')
UEFI_OBJ := $(UEFI_CFILES:$(BOOT_ROOT)/platform/uefi/%.c=$(BUILD_DIR)/boot/uefi/%.c.o) \
$(UEFI_ASFILES:$(BOOT_ROOT)/platform/uefi/%.S=$(BUILD_DIR)/boot/uefi/%.S.o) \
$(COMMON_CFILES:$(BOOT_ROOT)/common/%.c=$(BUILD_DIR)/boot/uefi/common/%.c.o) \
$(COMMON_ARCH_CFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.c=$(BUILD_DIR)/boot/uefi/arch/%.c.o) \
$(COMMON_ARCH_ASFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.asm=$(BUILD_DIR)/boot/uefi/arch/%.asm.o)
.PHONY: all
all: $(UEFI_BOOTFILE)
.PHONY: install
install:
@mkdir -p $(SYSROOT_DIR)/EFI/BOOT
@printf " INSTALL\t/EFI/BOOT/BOOT$(UEFISUF).EFI\n"
@cp $(UEFI_BOOTFILE) $(SYSROOT_DIR)/EFI/BOOT/
$(UEFI_BOOTFILE): $(UEFI_OBJ)
@mkdir -p $(@D)
@printf " LD\t$(notdir $@)\n"
@$(UEFI_LD) $(UEFI_LDFLAGS) $^ -o $@
-include $(wildcard $(BUILD_DIR)/boot/*.d)
$(BUILD_DIR)/boot/uefi/%.c.o: $(BOOT_ROOT)/platform/uefi/%.c
@mkdir -p $(@D)
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(UEFI_CC) $(UEFI_CFLAGS) -c $< -o $@
$(BUILD_DIR)/boot/uefi/common/%.c.o: $(BOOT_ROOT)/common/%.c
@mkdir -p $(@D)
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(UEFI_CC) $(UEFI_CFLAGS) -c $< -o $@
$(BUILD_DIR)/boot/uefi/arch/%.c.o: $(BOOT_ROOT)/arch/$(ARCH)/common/%.c
@mkdir -p $(@D)
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(UEFI_CC) $(UEFI_CFLAGS) -c $< -o $@
$(BUILD_DIR)/boot/uefi/arch/%.asm.o: $(BOOT_ROOT)/arch/$(ARCH)/common/%.asm
@mkdir -p $(@D)
@printf " AS\t$(subst $(ROOT_DIR)/,,$<)\n"
@$(UEFI_AS) $(UEFI_ASFLAGS) -c $< -o $@

View file

@ -0,0 +1,46 @@
/*********************************************************************************/
/* Module Name: entry.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <efi.h>
#include <efilib.h>
#include <print.h>
#include <stddef.h>
EFI_STATUS uefi_entry(EFI_HANDLE ImageHandle,
EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
gImageHandle = ImageHandle;
gSystemTable = SystemTable;
// clear the screen
gSystemTable->ConOut->ClearScreen(gSystemTable->ConOut);
// disable UEFI watchdog
Status = gSystemTable->BootServices->SetWatchdogTimer(0, 0, 0, NULL);
if (EFI_ERROR(Status)) {
debug("Couldn't disable UEFI watchdog!\n");
}
while(1);
return EFI_SUCCESS;
}

@ -0,0 +1 @@
Subproject commit 00ed5f5d53641d48024d8a1346edef07d1d79421

View file

@ -0,0 +1,31 @@
/*********************************************************************************/
/* Module Name: print.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <firmware/firmware.h>
#include <lib/string.h>
#include <efi.h>
#include <efilib.h>
void printstr(const char *str)
{
CHAR16 wstr[4096];
mbstowcs(wstr, &str, strlen(str));
wstr[strlen(str)] = '\0';
gSystemTable->ConOut->OutputString(gSystemTable->ConOut, wstr);
}

45
docs/CODE_OF_CONDUCT.md Normal file
View file

@ -0,0 +1,45 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer using any of the [private contact addresses](https://github.com/aurixos/os#support). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
For answers to common questions about this code of conduct, see <https://www.contributor-covenant.org/faq>

46
docs/CONTRIBUTING.md Normal file
View file

@ -0,0 +1,46 @@
# Contributing
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
## Development environment setup
To set up a development environment, follow these steps:
1. Clone the repo
```sh
git clone https://github.com/aurixos/os
```
2. Install all required packages
```sh
brew bundle
```
If you don't have Homebrew installed, or don't want to download all optional packages, look at the [Brewfile](../Brewfile) and install all packages manually.
## Issues and feature requests
You've found a bug in the source code, a mistake in the documentation or maybe you'd like a new feature? You can help us by [submitting an issue on GitHub](https://github.com/aurixos/os/issues). Before you create an issue, make sure to search the issue archive -- your issue may have already been addressed!
Please try to create bug reports that are:
- _Reproducible._ Include steps to reproduce the problem.
- _Specific._ Include as much detail as possible: which version, what environment, etc.
- _Unique._ Do not duplicate existing opened issues.
- _Scoped to a Single Bug._ One bug per report.
**Even better: Submit a pull request with a fix or new feature!**
### How to submit a Pull Request
1. Search our repository for open or closed
[Pull Requests](https://github.com/aurixos/os/pulls)
that relate to your submission. You don't want to duplicate effort.
2. Fork the project
3. Create your feature branch (`git checkout -b feat/amazing_feature`)
4. Commit your changes (`git commit -m 'feat: add amazing_feature'`) AurixOS uses [conventional commits](https://www.conventionalcommits.org), so please follow the specification in your commit messages.
5. Push to the branch (`git push origin feat/amazing_feature`)
6. [Open a Pull Request](https://github.com/aurixos/os/compare?expand=1)

16
docs/SECURITY.md Normal file
View file

@ -0,0 +1,16 @@
# Security Policy
## Reporting a Vulnerability
If there are any vulnerabilities in **AurixOS**, don't hesitate to _report them_.
1. Contact [schkwve@gmail.com](mailto:schkwve@gmail.com).
2. Describe the vulnerability.
If you have a fix, that is most welcome -- please attach or summarize it in your message!
3. We will evaluate the vulnerability and, if necessary, release a fix or mitigating steps to address it. We will contact you to let you know the outcome, and will credit you in the report.
Please **do not disclose the vulnerability publicly** until a fix is released!
4. Once we have either a) published a fix, or b) declined to address the vulnerability for whatever reason, you are free to publicly disclose it.

117
docs/boot/BOOTPROTOCOL.md Normal file
View file

@ -0,0 +1,117 @@
# Aurix Boot Protocol (revision 0.2)
The Aurix Boot Protocol presents a simple and minimal protocol for booting the AurixOS kernel.
> [!NOTE]
> This document is still a work in progress and may contain incomplete information.
## Machine state
- All general purpose registers are zeroed out
- Interrupts are disabled
- Framebuffer is set to the best available video mode (graphics mode if available)
### Architecture-specific
#### x86_64
- Write Protection bit in CR0 is disabled
- GDT is set up as follows:
| Name | Base | Limit | Flags |
| :--------------------- | :----: | :----------: | :--------: |
| NULL Descriptor | `0x00` | `0x0000` | `0x00` |
| 32-bit Code Descriptor | `0x00` | `0xFFFFFFFF` | Read only |
| 32-bit Data Descriptor | `0x00` | `0xFFFFFFFF` | Read/Write |
| 64-bit Code Descriptor | `0x00` | `0x0000` | Read only |
| 64-bit Data Descriptor | `0x00` | `0x0000` | Read/Write |
## Paging
- ~~If available, 5-level paging is set up (see [Kernel Parameters](#kernel-parameters))~~ 5-level paging is not yet supported in AxBoot
- The memory map is identity mapped
- Kernel is mapped to the higher half if desired
## Kernel parameters
The bootloader passes `abp_boot_info` structure as a parameter to the kernel.
A non-zero value in `lvl5_paging` indicates that 5-level paging has been set up and is available.
```c
struct abp_boot_info {
// General
char *bootloader_name;
char *bootloader_version;
char *protocol_version;
// ACPI and SMBIOS
struct acpi_info acpi;
struct smbios_info smbios;
// Memory
struct memory_map *memmap;
int lvl5_paging;
// Framebuffer
struct framebuffer_info framebuffer;
};
```
## ACPI and SMBIOS
These structures contain pointers to the Root System Description Pointer (ACPI) and System Management BIOS Entry Point (SMBIOS).
If `is_valid` is set to a non-zero value, the pointer is guaranteed to be valid.
Otherwise, the pointer is set to NULL and should not be used.
```c
struct acpi_info {
uint8_t is_valid;
void *rsdp;
};
```
```c
struct smbios_info {
uint8_t is_valid;
void *entry_point;
};
```
## Memory map
The memory map is a singly linked list containing the physical address of the entry, its length and type, as well as a pointer to the next entry.
Entries are guaranteed to not overlap with each other, and sorted by base address from low to high.
```c
#define ABP_MEMORY_RESERVED 0xf0
#define ABP_MEMORY_USABLE 0xf1
#define ABP_MEMORY_BOOTLOADER_RECLAIMABLE 0xf2
#define ABP_MEMORY_MMIO 0xf3
#define ABP_MEMORY_ACPI_NVS 0xf4
#define ABP_MEMORY_ACPI_RECLAIMABLE 0xf5
#define ABP_MEMORY_KERNEL 0xf7
#define ABP_MEMORY_NOT_USABLE 0xff
struct memory_map {
uint64_t base;
uint64_t length;
uint64_t type;
struct memory_map *next;
};
```
## Framebuffer
```c
struct framebuffer_info {
void *addr;
uint32_t width;
uint32_t height;
uint16_t bpp;
};
```

51
docs/boot/CONFIG.md Normal file
View file

@ -0,0 +1,51 @@
# Soapine configuration
To work and do what you told it to do, Soapine uses a configuration file.
## Location
Soapine will search for the configuration in:
* `(boot partition)\soapine.cfg`
* `(boot partition)\soapine\soapine.cfg`
* `(boot partition)\EFI\BOOT\soapine.cfg`
* `(boot partition)\EFI\soapine.cfg`
If Soapine finds the config file, he parses it and jump to his usual menu. Else, Soapine will display a stop screen saying that you need to fix your configuration
## Accepted value types
* String literal (`"Hello, World!"`)
* Decimal (`2`)
* Hexadecimal (`0x2`)
* Hexadecimal color (`#FFFFFF`)
* Boolean (`true/false`)
## Declarations
Declarations are values that components of Soapine will search for:
If you declare `VERBOSE` with a value of true, Soapine will itself put in verbose mode.
You can do a declaration by writing the name + an equal sign + the value (using the accepted value types), that will make `NAME=VALUE`.
If an unused declaration is provided (for example `FORCE_SOAPINE_TO_LIKE_ME=true`), Soapine will simply ignore it, but it will still be present.
Here are some example declarations:
* `MENU_BRANDING="Raphaël's Custom Soapine!!"` (string literal)
* `MENU_HEADERBAR_BG=#FFFFFF` (Hexadecimal color)
* `MENU_HEADERBAR_MARGIN=1` (decimal)
* `VERBOSE=true` (boolean)
* `LOAD_ADDRESS=0x1000` (hexadecimal)
## Menu entries
Menu entries allow you to show an operating system (that can be loaded with the supported protocols!) on the menu.
They are declared like that:
```c
menu_entry "Project Jupiter" {
};
```
*(yes i decided to give a C-like syntax to it)*
You can put a small number of declarations inside the menu entries. (PROTOCOL, IMAGE_PATH, CMDLINE, RESOLUTION) (Providing the `PROTOCOL` and `IMAGE_PATH` declarations is required for Soapine to boot your OS!)
## Supported declarations
None for now (we just got the config parser working!)
At least, you can still define entries!

10
docs/boot/PHILOSOPHY.md Normal file
View file

@ -0,0 +1,10 @@
# Soapine's philosophy
Soapine is meant to be lightweight, while being useful to everyone:
* Ship the bootloader with multiple features (even the weirdest features)
* Ability to extend the bootloader with ELF extensions: If you wanna write an extension to support PE loading, ***DO IT***.
Soapine is also meant to be customizable:
* You can modify each bit of the bootloader: If you wanna center the headerbar text, you ***CAN***
* You can change the default values in Soapine's source code.

BIN
docs/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

135
kernel/Makefile Normal file
View file

@ -0,0 +1,135 @@
###################################################################################
## Module Name: Makefile ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
.DEFAULT_GOAL := all
INCLUDE_DIRS := include
BUILD_DIR ?= build
SYSROOT_DIR ?= sysroot
KERNEL_FILE := $(BUILD_DIR)/axkrnl
INCLUDE_DIRS := include \
include/arch/$(ARCH) \
include/platform/$(PLATFORM)
DEFINES := __$(ARCH)__
KERNEL_AS := $(ARCH)-elf-gcc
KERNEL_CC := $(ARCH)-elf-gcc
KERNEL_LD := $(ARCH)-elf-ld
KERNEL_OBJCOPY := $(ARCH)-elf-objcopy
KERNEL_ASFLAGS := $(foreach d, $(INCLUDE_DIRS), -I$d) \
$(foreach d, $(DEFINES), -D$d)
KERNEL_CFLAGS := $(foreach d, $(INCLUDE_DIRS), -I$d) \
$(foreach d, $(DEFINES), -D$d) \
-D__$(ARCH) \
-std=c99 \
-ffreestanding \
-fno-omit-frame-pointer \
-fno-stack-protector \
-fno-stack-check \
-fno-pie \
-MMD \
-MP
KERNEL_LDFLAGS := -Tarch/$(ARCH)/linker.ld \
-nostdlib \
-static \
-no-pie
ifeq ($(DEBUG),yes)
KERNEL_CFLAGS += -g3
else
KERNEL_CFLAGS += -O2
endif
KERNEL_CFILES := $(shell find . -type d \( -name arch -o -name platform \) -prune -name '*.c')
KERNEL_ASFILES := $(shell find . -type d \( -name arch -o -name platform \) -prune -name '*.S')
KERNEL_ARCH_CFILES := $(shell find arch/$(ARCH) -name '*.c')
KERNEL_ARCH_ASFILES := $(shell find arch/$(ARCH) -name '*.S')
KERNEL_PLATFORM_CFILES := $(shell find platform/$(PLATFORM) -name '*.c')
KERNEL_PLATFORM_ASFILES := $(shell find platform/$(PLATFORM) -name '*.S')
KERNEL_OBJ := $(KERNEL_CFILES:%.c=$(BUILD_DIR)/kernel/%.c.o) \
$(KERNEL_ASFILES:%.S=$(BUILD_DIR)/kernel/%.S.o) \
$(KERNEL_ARCH_CFILES:arch/$(ARCH)/%.c=$(BUILD_DIR)/kernel/arch/%.c.o) \
$(KERNEL_ARCH_ASFILES:arch/$(ARCH)/%.S=$(BUILD_DIR)/kernel/arch/%.S.o) \
$(KERNEL_PLATFORM_CFILES:platform/$(PLATFORM)/%.c=$(BUILD_DIR)/kernel/platform/%.c.o) \
$(KERNEL_PLATFORM_ASFILES:platform/$(PLATFORM)/%.S=$(BUILD_DIR)/kernel/platform/%.S.o)
-include arch/$(ARCH)/config.mk
-include $(wildcard $(BUILD_DIR)/kernel/*.d)
$(KERNEL_FILE): $(KERNEL_OBJ)
@mkdir -p $(@D)
@printf " LD\t$(notdir $@)\n"
@$(KERNEL_LD) $(KERNEL_LDFLAGS) $^ -o $@
ifeq ($(DEBUG),yes)
@printf " OBJCOPY axkrnl.sym\n"
@$(KERNEL_OBJCOPY) --only-keep-debug $@ $(BUILD_DIR)/axkrnl.sym
@$(KERNEL_OBJCOPY) --strip-debug --strip-unneeded $@
endif
$(BUILD_DIR)/kernel/%.c.o: %.c
@mkdir -p $(@D)
@printf " CC\t$<\n"
@$(KERNEL_CC) $(KERNEL_CFLAGS) -c $< -o $@
$(BUILD_DIR)/kernel/arch/%.c.o: arch/$(ARCH)/%.c
@mkdir -p $(@D)
@printf " CC\t$<\n"
@$(KERNEL_CC) $(KERNEL_CFLAGS) -c $< -o $@
$(BUILD_DIR)/kernel/arch/%.S.o: arch/$(ARCH)/%.S
@mkdir -p $(@D)
@printf " AS\t$<\n"
@$(KERNEL_AS) $(KERNEL_ASFLAGS) -c $< -o $@
$(BUILD_DIR)/kernel/platform/%.c.o: platform/$(PLATFORM)/%.c
@mkdir -p $(@D)
@printf " CC\t$<\n"
@$(KERNEL_CC) $(KERNEL_CFLAGS) -c $< -o $@
$(BUILD_DIR)/kernel/platform/%.S.o: platform/$(PLATFORM)/%.S
@mkdir -p $(@D)
@printf " AS\t$<\n"
@$(KERNEL_AS) $(KERNEL_ASFLAGS) -c $< -o $@
.PHONY: all
all: kernel
.PHONY: kernel
kernel: $(KERNEL_FILE)
.PHONY: install
install: install-kernel
.PHONY: install-kernel
install-kernel: kernel
@mkdir -p $(SYSROOT_DIR)/System
@printf " INSTALL\t/System/$(notdir $(KERNEL_FILE))\n"
@cp $(KERNEL_FILE) $(SYSROOT_DIR)/System
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR) $(SYSROOT_DIR)

View file

@ -0,0 +1,23 @@
###################################################################################
## Module Name: config.mk ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
KERNEL_CFLAGS +=
KERNEL_LDFLAGS += -nostdlib \
--no-dynamic-linker

View file

@ -0,0 +1,60 @@
/*********************************************************************************/
/* Module Name: linker.ld */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
/* This is just a copied linker from the bootloader. */
/* Not cool. But it's good enough... for now. */
SECTIONS
{
. = 0x80000;
.text : {
*(.text .text.*)
*(.gnu.linkonce.t*)
}
.rodata : {
*(.rodata .rodata.*)
*(.gnu.linkonce.r*)
}
PROVIDE(_data = .);
.data : {
*(.data .data.*)
*(.gnu.linkonce.d*)
}
.bss (NOLOAD) : {
. = ALIGN(16);
__bss_start = .;
*(.bss .bss.*)
*(COMMON)
__bss_end = .;
}
_end = .;
/DISCARD/ : {
*(.comment)
*(.gnu*)
*(.note*)
*(.eh_frame*)
}
}
/*__bss_size = (__bss_end - __bss_start) >> 3;*/

View file

@ -0,0 +1,33 @@
###################################################################################
## Module Name: config.mk ##
## Project: AurixOS ##
## ##
## Copyright (c) 2024-2025 Jozef Nagy ##
## ##
## This source is subject to the MIT License. ##
## See License.txt in the root of this repository. ##
## All other rights reserved. ##
## ##
## 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. ##
###################################################################################
KERNEL_CFLAGS += -m64 \
-march=x86-64 \
-mabi=sysv \
-mno-red-zone \
-mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2
KERNEL_LDFLAGS += -nostdlib \
--no-dynamic-linker \
-z max-page-size=0x1000 \
-z text \
-melf_x86_64

View file

@ -0,0 +1,78 @@
/*********************************************************************************/
/* Module Name: linker.ld */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
PHDRS
{
text PT_LOAD FLAGS((1 << 0) | (1 << 2));
rodata PT_LOAD FLAGS(1 << 2);
data PT_LOAD FLAGS((1 << 1) | (1 << 2));
dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2));
}
SECTIONS
{
/* AxBoot remaps this to 0xffffffff80000000 for us */
. = 0x1000;
_linker_start_text = .;
.text : {
*(.text .text.*)
} :text
_linker_end_text = .;
. = ALIGN(CONSTANT(MAXPAGESIZE));
_linker_start_rodata = .;
.rodata : {
*(.rodata .rodata.*)
} :rodata
_linker_end_rodata = .;
. = ALIGN(CONSTANT(MAXPAGESIZE));
_linker_start_data = .;
.data : {
*(.data .data.*)
} :data
.dynamic : {
*(.dynamic)
} :data :dynamic
.bss : {
*(COMMON)
*(.bss .bss.*)
} :data
_linker_end_data = .;
/DISCARD/ : {
*(.eh_frame)
*(.note .note.*)
}
}

View file

@ -0,0 +1,23 @@
/*********************************************************************************/
/* Module Name: cpu.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _ARCH_CPU_CPU_H
#define _ARCH_CPU_CPU_H
#endif /* _ARCH_CPU_CPU_H */

View file

@ -0,0 +1,116 @@
/*********************************************************************************/
/* Module Name: cpu.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _ARCH_CPU_CPU_H
#define _ARCH_CPU_CPU_H
#include <stdint.h>
////
// Utilities
///
static inline void cpu_disable_interrupts(void)
{
__asm__ volatile("cli" ::: "memory");
}
static inline uint64_t read_cr0()
{
uint64_t val;
__asm__ volatile("mov %%cr0, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr2()
{
uint64_t val;
__asm__ volatile("mov %%cr2, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr3()
{
uint64_t val;
__asm__ volatile("mov %%cr3, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr4()
{
uint64_t val;
__asm__ volatile("mov %%cr4, %0"
: "=r"(val));
return val;
}
static inline uint64_t read_cr8()
{
uint64_t val;
__asm__ volatile("mov %%cr8, %0"
: "=r"(val));
return val;
}
static inline void write_cr0(uint64_t val)
{
__asm__ volatile("mov %0, %%cr0"
:: "r"(val));
}
static inline void write_cr2(uint64_t val)
{
__asm__ volatile("mov %0, %%cr2"
:: "r"(val));
}
static inline void write_cr3(uint64_t val)
{
__asm__ volatile("mov %0, %%cr3"
:: "r"(val) : "memory");
}
static inline void write_cr4(uint64_t val)
{
__asm__ volatile("mov %0, %%cr4"
:: "r"(val));
}
static inline void write_cr8(uint64_t val)
{
__asm__ volatile("mov %0, %%cr8"
:: "r"(val));
}
static inline uint8_t inb(uint16_t port)
{
uint8_t ret;
__asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port) : "memory");
return ret;
}
static inline void outb(uint16_t port, uint8_t val)
{
__asm__ volatile("outb %b0, %w1" :: "a"(val), "Nd"(port) : "memory");
}
#endif /* _ARCH_CPU_CPU_H */

View file

@ -0,0 +1,30 @@
/*********************************************************************************/
/* Module Name: uart.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _DEBUG_SERIAL_H
#define _DEBUG_SERIAL_H
#include <platform/debug/uart.h>
void serial_init(void);
void serial_send(char c);
void serial_sendstr(char *s);
#endif /* _DEBUG_SERIAL_H */

View file

@ -0,0 +1,32 @@
/*********************************************************************************/
/* Module Name: serial.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _MACHINE_DEBUG_SERIAL_H
#define _MACHINE_DEBUG_SERIAL_H
#define COM1 0x3f8
#define COM2 0x2f8
#define COM3 0x3e8
#define COM4 0x2e8
#define COM5 0x5f8
#define COM6 0x4f8
#define COM7 0x5e8
#define COM8 0x4e8
#endif /* _MACHINE_DEBUG_SERIAL_H */

View file

@ -0,0 +1,23 @@
/*********************************************************************************/
/* Module Name: serial.h */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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 _MACHINE_DEBUG_SERIAL_H
#define _MACHINE_DEBUG_SERIAL_H
#endif /* _MACHINE_DEBUG_SERIAL_H */

34
kernel/kinit.c Normal file
View file

@ -0,0 +1,34 @@
/*********************************************************************************/
/* Module Name: kinit.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <debug/uart.h>
void _start(void)
{
serial_init();
serial_sendstr("Hello from AurixOS!\n");
for (;;) {
#ifdef __x86_64__
__asm__ volatile("cli;hlt");
#elif __aarch64__
__asm__ volatile("wfe");
#endif
}
}

View file

@ -0,0 +1,63 @@
/*********************************************************************************/
/* Module Name: uart.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <arch/cpu/cpu.h>
#include <debug/uart.h>
#include <stdint.h>
static uint8_t is_tx_empty(void)
{
return inb(COM1 + 5) & 0x20;
}
static uint8_t received(void)
{
return inb(COM1 + 5) & 1;
}
void serial_init(void)
{
// TODO: Initialize all COM ports
outb(COM1 + 1, 0x00);
outb(COM1 + 3, 0x80);
outb(COM1, 0x03);
outb(COM1 + 1, 0x00);
outb(COM1 + 3, 0x03);
outb(COM1 + 2, 0xC7);
outb(COM1 + 4, 0x0B);
outb(COM1 + 4, 0x0F);
}
void serial_send(char c)
{
while (is_tx_empty() == 0);
outb(COM1, c);
}
void serial_sendstr(char *s)
{
while (*s != '\0') {
if (*s == '\r') {
s++;
continue;
}
serial_send(*s++);
}
}

View file

@ -0,0 +1,34 @@
/*********************************************************************************/
/* Module Name: uart.c */
/* Project: AurixOS */
/* */
/* Copyright (c) 2024-2025 Jozef Nagy */
/* */
/* This source is subject to the MIT License. */
/* See License.txt in the root of this repository. */
/* All other rights reserved. */
/* */
/* 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. */
/*********************************************************************************/
#include <debug/uart.h>
#include <stdint.h>
void serial_init(void)
{
}
void serial_send(char c)
{
}
void serial_sendstr(char *s)
{
}

1
machine/i686/qemu.mk Normal file
View file

@ -0,0 +1 @@
QEMU_MACHINE_FLAGS := -M q35

1
machine/x86_64/qemu.mk Normal file
View file

@ -0,0 +1 @@
QEMU_MACHINE_FLAGS := -M q35

85
utils/arch/i686/generate-hdd.sh Executable file
View file

@ -0,0 +1,85 @@
#!/bin/bash
if [[ -z $1 ]]; then
printf "Please don't invoke this script manually. Run \`make release_hdd\` instead.\n"
exit 1
fi
sysroot_size=$(du -hsm kernel | cut -f 1)
disk_name=$1
disk_size=$(($sysroot_size + $efi_partition_size + 2))
unamestr=$(uname)
# Check if we're running on a supported host
if ! [[ "$unamestr" =~ ^('Linux'|'Darwin') ]]; then
printf " failed. (unsupported host)\n"
exit 128
fi
# create a disk image
dd if=/dev/zero of="$disk_name" bs=1M count="$disk_size" >/dev/null 2>&1
# create a partition table
fdisk "$disk_name" >/dev/null 2>&1 << EOF
g
n p
1
+$efi_partition_size\M
t 1
1
n p
2
t 2
11
w
EOF
tempmountdir=$(mktemp -d 2>/dev/null)
# mount disk
if [ "$unamestr" = 'Linux' ]; then
echo "Linux HDD Generation not implemented yet"
rm -r $tempmountdir
exit 200
elif [ "$unamestr" = 'Darwin' ]; then
loopback=$(hdiutil attach -nomount $disk_name)
loopback=$(echo $loopback | cut -f1 -d" ")
loopback_efi="$loopback"s1
fi
# format EFI partition
mkfs.vfat -F32 -n "EFI" "$loopback_efi" >/dev/null 2>&1
# mount EFI partition
if [ "$unamestr" = 'Darwin' ]; then
diskutil mount -mountPoint "$tempmountdir" "$loopback_efi" >/dev/null 2>&1
else
mount "$loopback_efi" "$tempmountdir"
fi
# Copy system root to the newly created image
cp -r "$ROOT_DIR"/sysroot/* "$tempmountdir"
# unmount all partitions
if [ "$unamestr" = 'Linux' ]; then
echo "Linux HDD Generation not implemented yet"
rm -r $tempmountdir
exit 200
elif [ "$unamestr" = 'Darwin' ]; then
diskutil unmount "$tempmountdir" >/dev/null 2>&1
hdiutil detach "$loopback" >/dev/null 2>&1
fi
rm -r "$tempmountdir"
# Install legacy BIOS placeholder to the new image
dd if="$BUILD_DIR/boot/boot/bootsect-hdd.bin" of="$disk_name" conv=notrunc bs=446 count=1 >/dev/null 2>&1
dd if="$BUILD_DIR/boot/boot/bootsect-hdd.bin" of="$disk_name" conv=notrunc bs=1 count=2 skip=510 seek=510 >/dev/null 2>&1
printf " done.\n"

39
utils/arch/i686/generate-iso.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
if [[ -z $1 ]]; then
printf "Please don't invoke this script manually. Run \`make livecd\` instead.\n"
exit 1
fi
disk_name=$1
uefi_image=$BUILD_DIR/uefi.img
tempmountdir=$(mktemp -d 2>/dev/null)
# Create UEFI image
dd if=/dev/zero of=$uefi_image bs=1k count=1440 >/dev/null 2>&1
mformat -i $uefi_image -f 1440 :: >/dev/null 2>&1
mmd -i $uefi_image ::/EFI >/dev/null 2>&1
mmd -i $uefi_image ::/EFI/BOOT >/dev/null 2>&1
mcopy -i $uefi_image $SYSROOT_DIR/EFI/BOOT/BOOTIA32.EFI ::/EFI/BOOT >/dev/null 2>&1
## !FIXME: Huge hack! Make a filesystem.
mmd -i $uefi_image ::/System >/dev/null 2>&1
mcopy -i $uefi_image $SYSROOT_DIR/System/axkrnl ::/System >/dev/null 2>&1
# Create directory structure
mkdir -p $tempmountdir/boot
cp $uefi_image $tempmountdir/boot/uefi.bin
cp $BUILD_DIR/boot/boot/bootsect-cd.bin $tempmountdir/boot/bootcd.bin
cp -r $ROOT_DIR/sysroot/* $tempmountdir/
# Create ISO
xorriso -as mkisofs -b boot/bootcd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot boot/uefi.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
$tempmountdir -o $1 >/dev/null 2>&1
rm -rf $tempmountdir
printf " done.\n"

View file

@ -0,0 +1,87 @@
#!/bin/bash
if [[ -z $1 ]]; then
printf "Please don't invoke this script manually. Run \`make release_hdd\` instead.\n"
exit 1
fi
#sysroot_size=$(du -hsm kernel | cut -f 1)
sysroot_size=16
efi_partition_size=32
disk_name=$1
disk_size=$(($sysroot_size + $efi_partition_size + 2))
unamestr=$(uname)
# Check if we're running on a supported host
if ! [[ "$unamestr" =~ ^('Linux'|'Darwin') ]]; then
printf " failed. (unsupported host)\n"
exit 128
fi
# create a disk image
dd if=/dev/zero of="$disk_name" bs=1M count="$disk_size" >/dev/null 2>&1
# create a partition table
fdisk "$disk_name" >/dev/null 2>&1 << EOF
g
n p
1
+$efi_partition_size\M
t 1
1
n p
2
t 2
11
w
EOF
tempmountdir=$(mktemp -d 2>/dev/null)
# mount disk
if [ "$unamestr" = 'Linux' ]; then
echo "Linux HDD Generation not implemented yet"
rm -r $tempmountdir
exit 200
elif [ "$unamestr" = 'Darwin' ]; then
loopback=$(hdiutil attach -nomount $disk_name)
loopback=$(echo $loopback | cut -f1 -d" ")
loopback_efi="$loopback"s1
fi
# format EFI partition
mkfs.vfat -F32 -n "EFI" "$loopback_efi" >/dev/null 2>&1
# mount EFI partition
if [ "$unamestr" = 'Darwin' ]; then
diskutil mount -mountPoint "$tempmountdir" "$loopback_efi" >/dev/null 2>&1
else
mount "$loopback_efi" "$tempmountdir"
fi
# Copy system root to the newly created image
cp -r "$ROOT_DIR"/sysroot/* "$tempmountdir"
# unmount all partitions
if [ "$unamestr" = 'Linux' ]; then
echo "Linux HDD Generation not implemented yet"
rm -r $tempmountdir
exit 200
elif [ "$unamestr" = 'Darwin' ]; then
diskutil unmount "$tempmountdir" >/dev/null 2>&1
hdiutil detach "$loopback" >/dev/null 2>&1
fi
rm -r "$tempmountdir"
# Install legacy BIOS placeholder to the new image
dd if="$BUILD_DIR/boot/pc-bios/stage1-hdd.bin" of="$disk_name" conv=notrunc bs=446 count=1 >/dev/null 2>&1
dd if="$BUILD_DIR/boot/pc-bios/stage1-hdd.bin" of="$disk_name" conv=notrunc bs=1 count=2 skip=510 seek=510 >/dev/null 2>&1
printf " done.\n"

View file

@ -0,0 +1,39 @@
#!/bin/bash
if [[ -z $1 ]]; then
printf "Please don't invoke this script manually. Run \`make livecd\` instead.\n"
exit 1
fi
disk_name=$1
uefi_image=$BUILD_DIR/uefi.img
tempmountdir=$(mktemp -d 2>/dev/null)
# Create UEFI image
dd if=/dev/zero of=$uefi_image bs=1k count=1440 >/dev/null 2>&1
mformat -i $uefi_image -f 1440 :: >/dev/null 2>&1
mmd -i $uefi_image ::/EFI >/dev/null 2>&1
mmd -i $uefi_image ::/EFI/BOOT >/dev/null 2>&1
mcopy -i $uefi_image $SYSROOT_DIR/EFI/BOOT/BOOTX64.EFI ::/EFI/BOOT >/dev/null 2>&1
## !FIXME: Huge hack! Make a filesystem.
mmd -i $uefi_image ::/System >/dev/null 2>&1
mcopy -i $uefi_image $SYSROOT_DIR/System/axkrnl ::/System >/dev/null 2>&1
# Create directory structure
mkdir -p $tempmountdir/boot
cp $uefi_image $tempmountdir/boot/uefi.bin
cp $BUILD_DIR/boot/pc-bios/stage1-cd.bin $tempmountdir/boot/bootcd.bin
cp -r $ROOT_DIR/sysroot/* $tempmountdir/
# Create ISO
xorriso -as mkisofs -b boot/bootcd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot boot/uefi.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
$tempmountdir -o $1 >/dev/null 2>&1
rm -rf $tempmountdir
printf " done.\n"

20
utils/download-ovmf.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
check_command() {
if ! command -v "$1" &> /dev/null; then
echo "[!] '$1' could not be found!"
exit 1
fi
}
# Make sure we have curl
check_command curl
mkdir -p ovmf
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF.fd -o ovmf/ovmf-x86_64.fd >/dev/null 2>&1
curl https://retrage.github.io/edk2-nightly/bin/RELEASEIA32_OVMF.fd -o ovmf/ovmf-i686.fd >/dev/null 2>&1
curl https://retrage.github.io/edk2-nightly/bin/RELEASEAARCH64_QEMU_EFI.fd -o ovmf/ovmf-aarch64.fd >/dev/null 2>&1
curl https://retrage.github.io/edk2-nightly/bin/RELEASERISCV64_VIRT_CODE.fd -o ovmf/ovmf-riscv64.fd >/dev/null 2>&1
printf " done.\n"