├── libkstructures ├── .gitignore ├── arch │ ├── i386 │ │ └── make.config │ ├── x86_64 │ │ └── make.config │ └── aarch64 │ │ └── make.config ├── structures.pc ├── make.config ├── include │ └── structs │ │ ├── node.h │ │ └── ini.h └── Makefile.linux ├── userspace ├── lib │ ├── .gitignore │ ├── pthread │ │ ├── dummy.c │ │ └── lib.conf │ ├── ansi │ │ └── lib.conf │ ├── keyboard │ │ └── lib.conf │ ├── version │ │ └── lib.conf │ ├── ethereal │ │ ├── lib.conf │ │ ├── reboot.c │ │ ├── shared.c │ │ ├── pthread.c │ │ └── driver.c │ ├── graphics │ │ ├── lib.conf │ │ └── blend.c │ ├── widget │ │ ├── lib.conf │ │ └── geometry.c │ ├── celestial │ │ └── lib.conf │ ├── make.config │ ├── include │ │ ├── ethereal │ │ │ ├── celestial │ │ │ │ └── types.h │ │ │ ├── toast.h │ │ │ ├── widget.h │ │ │ ├── reboot.h │ │ │ ├── version.h │ │ │ ├── widget │ │ │ │ ├── event.h │ │ │ │ ├── button.h │ │ │ │ ├── label.h │ │ │ │ ├── frame.h │ │ │ │ └── input.h │ │ │ ├── celestial.h │ │ │ └── shared.h │ │ └── graphics │ │ │ ├── util.h │ │ │ └── color.h │ └── Makefile ├── init │ └── app.conf ├── dhcpcli │ └── app.conf ├── getty │ └── app.conf ├── login │ └── app.conf ├── plasma │ └── app.conf ├── terminal │ └── app.conf ├── colorwave │ ├── app.conf │ └── colorwave.c ├── desktop │ ├── app.conf │ └── widget.h ├── memvisualize │ └── app.conf ├── termemu │ ├── app.conf │ └── terminal.h ├── etherealver │ └── app.conf ├── font-viewer │ └── app.conf ├── wmtest │ └── app.conf ├── celestial │ ├── app.conf │ ├── kbd.h │ ├── event.h │ ├── event.c │ ├── mouse.h │ ├── socket.h │ └── kbd.c ├── essence │ ├── app.conf │ ├── input.c │ └── commands.c ├── flanterm │ └── app.conf ├── show-dialog │ └── app.conf ├── login-gui │ └── app.conf ├── toast-server │ └── app.conf ├── miniutils │ ├── README.txt │ ├── tty.c │ ├── echo.c │ ├── clear.c │ ├── hibernate.c │ ├── reboot.c │ ├── poweroff.c │ ├── users.c │ ├── whoami.c │ ├── poweroff-dialog.c │ ├── ethereal-version.c │ ├── touch.c │ ├── Makefile │ ├── readlink.c │ ├── dns-resolve.c │ ├── date.c │ ├── kill.c │ └── ps.c ├── tray │ ├── make.config │ ├── network │ │ └── network.c │ └── Makefile ├── make.config └── Makefile ├── external ├── freetype │ ├── .gitignore │ ├── Makefile │ ├── make.config │ ├── freetype.patch │ └── build.sh ├── README.txt ├── acpica │ ├── README.txt │ └── make.config ├── plutosvg │ ├── Makefile │ └── make.config ├── LICENSE.Astral └── Makefile ├── base ├── sysroot │ ├── etc │ │ ├── resolv.conf │ │ ├── init.d │ │ │ ├── 02_hostname.sh │ │ │ └── 01_welcome.sh │ │ ├── desktop.ini │ │ ├── localtime │ │ ├── desktop.d │ │ │ ├── 01-terminal.ent │ │ │ ├── 04-plasma.ent │ │ │ ├── 99-poweroff.ent │ │ │ ├── 03-color-wave.ent │ │ │ └── 02-about-ethereal.ent │ │ ├── ethereal-version │ │ ├── passwd │ │ └── hosts │ ├── usr │ │ ├── share │ │ │ ├── DejaVuSans.ttf │ │ │ ├── ter-112n.psf │ │ │ ├── EtherealLogo.bmp │ │ │ ├── cursors │ │ │ │ ├── text.bmp │ │ │ │ └── default.bmp │ │ │ ├── terminfo │ │ │ │ ├── v │ │ │ │ │ └── vt220 │ │ │ │ └── x │ │ │ │ │ └── xterm-256color │ │ │ ├── DejaVuSansMono.ttf │ │ │ ├── icons │ │ │ │ ├── 16 │ │ │ │ │ └── Ethereal.bmp │ │ │ │ └── 24 │ │ │ │ │ ├── power.bmp │ │ │ │ │ ├── Ethereal.bmp │ │ │ │ │ ├── Terminal.bmp │ │ │ │ │ └── Application.bmp │ │ │ ├── mercury │ │ │ │ ├── close.bmp │ │ │ │ ├── maximize.bmp │ │ │ │ ├── minimize.bmp │ │ │ │ ├── close-hover.bmp │ │ │ │ ├── maximize-hover.bmp │ │ │ │ └── minimize-hover.bmp │ │ │ ├── wallpapers │ │ │ │ ├── lines.bmp │ │ │ │ └── EtherealWallpaper1.bmp │ │ │ ├── DejaVuSansMono-Bold.ttf │ │ │ ├── EtherealStartButton.bmp │ │ │ └── UbuntuMono-Regular.ttf │ │ └── bin │ │ │ └── x86_64-ethereal-pkg-config │ └── boot │ │ └── conf.ini ├── initrd │ └── test.txt └── Makefile ├── libc ├── .gitignore ├── README.txt ├── ethereal_cross.txt ├── make.config └── Makefile ├── drivers ├── .gitignore ├── arch │ ├── i386.config │ ├── aarch64.config │ └── x86_64.config ├── example │ ├── driver.conf │ ├── main.c │ └── Makefile ├── fs │ ├── fat │ │ ├── driver.conf │ │ └── Makefile │ ├── ext2 │ │ ├── driver.conf │ │ └── Makefile │ └── make.config ├── misc │ ├── ps2 │ │ ├── driver.conf │ │ └── Makefile │ └── make.config ├── net │ ├── rtl8169 │ │ ├── driver.conf │ │ └── Makefile │ ├── e1000 │ │ ├── driver.conf │ │ └── Makefile │ ├── rtl8139 │ │ ├── driver.conf │ │ └── Makefile │ └── make.config ├── sound │ ├── ac97 │ │ ├── driver.conf │ │ └── Makefile │ └── make.config ├── storage │ ├── ahci │ │ ├── driver.conf │ │ └── Makefile │ ├── ide │ │ ├── driver.conf │ │ ├── main.c │ │ └── Makefile │ ├── nvme │ │ ├── driver.conf │ │ └── Makefile │ └── make.config ├── usb │ ├── uhci │ │ ├── driver.conf │ │ └── Makefile │ ├── xhci │ │ ├── driver.conf │ │ ├── Makefile │ │ └── xhci.c │ ├── usbhub │ │ ├── driver.conf.old │ │ └── Makefile │ ├── ehci │ │ ├── driver.conf │ │ └── Makefile │ └── make.config ├── graphics │ └── make.config ├── make_main.config ├── make.config └── Makefile ├── conf ├── theme │ ├── Ethereal.png │ ├── select_c.png │ ├── select_e.png │ ├── select_w.png │ ├── slider_c.png │ ├── slider_n.png │ ├── slider_s.png │ ├── boot_menu_c.png │ ├── boot_menu_e.png │ ├── boot_menu_n.png │ ├── boot_menu_ne.png │ ├── boot_menu_nw.png │ ├── boot_menu_s.png │ ├── boot_menu_se.png │ ├── boot_menu_sw.png │ ├── boot_menu_w.png │ ├── terminus-12.pf2 │ ├── terminus-14.pf2 │ ├── terminus-16.pf2 │ ├── terminus-18.pf2 │ ├── terminal_box_c.png │ ├── terminal_box_e.png │ ├── terminal_box_n.png │ ├── terminal_box_s.png │ ├── terminal_box_w.png │ ├── terminal_box_ne.png │ ├── terminal_box_nw.png │ ├── terminal_box_se.png │ ├── terminal_box_sw.png │ └── README └── build │ ├── aarch64.mk │ ├── i386.mk │ └── x86_64.mk ├── .gitmodules ├── .gitignore ├── hexahedron ├── include │ └── kernel │ │ ├── fs │ │ ├── log.h │ │ ├── console.h │ │ ├── null.h │ │ ├── ramdev.h │ │ └── pipe.h │ │ ├── drivers │ │ ├── x86 │ │ │ ├── early_log.h │ │ │ ├── acpica.h │ │ │ ├── clock.h │ │ │ └── pit.h │ │ ├── usb │ │ │ ├── status.h │ │ │ └── hid │ │ │ │ ├── mouse.h │ │ │ │ └── keyboard.h │ │ ├── grubvid.h │ │ ├── nicdev.h │ │ ├── net │ │ │ └── udp.h │ │ └── sound │ │ │ └── audio.h │ │ ├── kernel.h │ │ ├── gfx │ │ ├── gfx.h │ │ └── video.h │ │ ├── misc │ │ ├── args.h │ │ └── ksym.h │ │ ├── task │ │ ├── futex.h │ │ └── timer.h │ │ ├── config.h │ │ ├── arch │ │ └── x86_64 │ │ │ └── registers.h │ │ └── mm │ │ └── alloc.h ├── klib │ ├── stdlib │ │ ├── abs.c │ │ ├── assert.c │ │ └── malloc.c │ ├── string │ │ ├── select.c │ │ ├── memset.c │ │ ├── strlen.c │ │ ├── memcpy_fast.S │ │ ├── strdup.c │ │ ├── rand.c │ │ ├── memcpy.c │ │ ├── strstr.c │ │ ├── memcmp.c │ │ ├── memchr.c │ │ ├── strcat.c │ │ ├── strchr.c │ │ ├── strcpy.c │ │ ├── strcmp.c │ │ ├── ctype.c │ │ ├── strtok.c │ │ └── strto.c │ └── time │ │ └── time.c ├── arch │ └── x86_64 │ │ ├── make.config │ │ ├── misc.S │ │ └── signal.S ├── make.config ├── misc │ └── stack.c ├── drivers │ ├── README.txt │ ├── net │ │ └── loopback.c │ └── x86 │ │ └── early_log.c ├── fs │ ├── random.c │ └── console.c └── debug │ └── debugger.c ├── .github └── workflows │ ├── i386.old │ └── x86_64.yml ├── make.config ├── .vscode ├── launch.json └── tasks.json └── LICENSE /libkstructures/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ -------------------------------------------------------------------------------- /userspace/lib/.gitignore: -------------------------------------------------------------------------------- 1 | flanterm -------------------------------------------------------------------------------- /external/freetype/.gitignore: -------------------------------------------------------------------------------- 1 | freetype-2.4.9* -------------------------------------------------------------------------------- /base/sysroot/etc/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 8.8.8.8 -------------------------------------------------------------------------------- /libc/.gitignore: -------------------------------------------------------------------------------- 1 | linux-6.16 2 | linux-6.16.tar.xz -------------------------------------------------------------------------------- /base/initrd/test.txt: -------------------------------------------------------------------------------- 1 | Test file for the initial ramdisk -------------------------------------------------------------------------------- /drivers/.gitignore: -------------------------------------------------------------------------------- 1 | */*.sys 2 | */*.o 3 | usb/xhci_old/ -------------------------------------------------------------------------------- /userspace/init/app.conf: -------------------------------------------------------------------------------- 1 | NAME = init 2 | INSTALL_DIR = /usr/bin/ -------------------------------------------------------------------------------- /drivers/arch/i386.config: -------------------------------------------------------------------------------- 1 | # i386 config file for Makefile 2 | 3 | -------------------------------------------------------------------------------- /userspace/dhcpcli/app.conf: -------------------------------------------------------------------------------- 1 | NAME = dhcpcli 2 | INSTALL_DIR = /usr/bin/ -------------------------------------------------------------------------------- /base/sysroot/etc/init.d/02_hostname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | hostname "ethereal" -------------------------------------------------------------------------------- /userspace/lib/pthread/dummy.c: -------------------------------------------------------------------------------- 1 | /* libpthread is already integrated into the libc */ -------------------------------------------------------------------------------- /libkstructures/arch/i386/make.config: -------------------------------------------------------------------------------- 1 | # i386 architecture Makefile for libkstructures 2 | -------------------------------------------------------------------------------- /userspace/getty/app.conf: -------------------------------------------------------------------------------- 1 | NAME = getty 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = version -------------------------------------------------------------------------------- /userspace/login/app.conf: -------------------------------------------------------------------------------- 1 | NAME = login 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = version -------------------------------------------------------------------------------- /base/sysroot/etc/desktop.ini: -------------------------------------------------------------------------------- 1 | [wallpaper] 2 | file=/usr/share/wallpapers/EtherealWallpaper1.bmp -------------------------------------------------------------------------------- /base/sysroot/etc/init.d/01_welcome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Execute whatarewe 4 | whatarewe -------------------------------------------------------------------------------- /libkstructures/arch/x86_64/make.config: -------------------------------------------------------------------------------- 1 | # x86_64 architecture Makefile for libkstructures 2 | -------------------------------------------------------------------------------- /userspace/plasma/app.conf: -------------------------------------------------------------------------------- 1 | NAME = plasma 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = celestial -------------------------------------------------------------------------------- /userspace/terminal/app.conf: -------------------------------------------------------------------------------- 1 | NAME = terminal 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard -------------------------------------------------------------------------------- /drivers/arch/aarch64.config: -------------------------------------------------------------------------------- 1 | # aarch64 config file for Makefile 2 | 3 | CFLAGS += -mcmodel=large -------------------------------------------------------------------------------- /libkstructures/arch/aarch64/make.config: -------------------------------------------------------------------------------- 1 | # aarch64 architecture Makefile for libkstructures 2 | -------------------------------------------------------------------------------- /userspace/colorwave/app.conf: -------------------------------------------------------------------------------- 1 | NAME = colorwave 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = celestial -------------------------------------------------------------------------------- /conf/theme/Ethereal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/Ethereal.png -------------------------------------------------------------------------------- /conf/theme/select_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/select_c.png -------------------------------------------------------------------------------- /conf/theme/select_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/select_e.png -------------------------------------------------------------------------------- /conf/theme/select_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/select_w.png -------------------------------------------------------------------------------- /conf/theme/slider_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/slider_c.png -------------------------------------------------------------------------------- /conf/theme/slider_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/slider_n.png -------------------------------------------------------------------------------- /conf/theme/slider_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/slider_s.png -------------------------------------------------------------------------------- /libc/README.txt: -------------------------------------------------------------------------------- 1 | A copy of linux-6.16 is provided to enable the usage of linux kernel headers in mlibc -------------------------------------------------------------------------------- /userspace/desktop/app.conf: -------------------------------------------------------------------------------- 1 | NAME = desktop 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = celestial, version -------------------------------------------------------------------------------- /userspace/lib/ansi/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = ansi 2 | VERSION = 1.1.1 3 | DESCRIPTION = "ANSI parser library" 4 | -------------------------------------------------------------------------------- /userspace/memvisualize/app.conf: -------------------------------------------------------------------------------- 1 | NAME = memvisualize 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = celestial -------------------------------------------------------------------------------- /base/sysroot/etc/localtime: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/etc/localtime -------------------------------------------------------------------------------- /conf/theme/boot_menu_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_c.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_e.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_n.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_ne.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_ne.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_nw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_nw.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_s.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_se.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_sw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_sw.png -------------------------------------------------------------------------------- /conf/theme/boot_menu_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/boot_menu_w.png -------------------------------------------------------------------------------- /conf/theme/terminus-12.pf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminus-12.pf2 -------------------------------------------------------------------------------- /conf/theme/terminus-14.pf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminus-14.pf2 -------------------------------------------------------------------------------- /conf/theme/terminus-16.pf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminus-16.pf2 -------------------------------------------------------------------------------- /conf/theme/terminus-18.pf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminus-18.pf2 -------------------------------------------------------------------------------- /userspace/lib/keyboard/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = keyboard 2 | VERSION = 1.1.0 3 | DESCRIPTION = "Keyboard library" 4 | -------------------------------------------------------------------------------- /userspace/lib/version/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = version 2 | DESCRIPTION = Stupid version library 3 | VERSION = 1.0.0 -------------------------------------------------------------------------------- /userspace/termemu/app.conf: -------------------------------------------------------------------------------- 1 | NAME = termemu 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard, celestial, ansi -------------------------------------------------------------------------------- /conf/theme/terminal_box_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_c.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_e.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_n.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_s.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_w.png -------------------------------------------------------------------------------- /userspace/etherealver/app.conf: -------------------------------------------------------------------------------- 1 | NAME = etherealver 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = celestial, version -------------------------------------------------------------------------------- /userspace/font-viewer/app.conf: -------------------------------------------------------------------------------- 1 | NAME = font-viewer 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard, celestial -------------------------------------------------------------------------------- /userspace/wmtest/app.conf: -------------------------------------------------------------------------------- 1 | NAME = wmtest 2 | INSTALL_DIR = /usr/bin/ 3 | 4 | DEPENDS = widget, keyboard, celestial -------------------------------------------------------------------------------- /conf/theme/terminal_box_ne.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_ne.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_nw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_nw.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_se.png -------------------------------------------------------------------------------- /conf/theme/terminal_box_sw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/conf/theme/terminal_box_sw.png -------------------------------------------------------------------------------- /drivers/example/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "example_driver.sys" 2 | ENVIRONMENT = ANY 3 | PRIORITY = IGNORE 4 | ARCH = ANY -------------------------------------------------------------------------------- /drivers/fs/fat/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "fat.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/misc/ps2/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "ps2.sys" 2 | ENVIRONMENT = ANY 3 | PRIORITY = IGNORE 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/net/rtl8169/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "net_rtl8169.sys" 2 | ENVIRONMENT = ANY 3 | PRIORITY = IGNORE 4 | ARCH = ANY -------------------------------------------------------------------------------- /userspace/celestial/app.conf: -------------------------------------------------------------------------------- 1 | NAME = celestial 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = graphics, ethereal, structures -------------------------------------------------------------------------------- /userspace/essence/app.conf: -------------------------------------------------------------------------------- 1 | NAME = essence 2 | INSTALL_DIR = /usr/bin/ 3 | SYMLINKS = /bin/sh 4 | DEPENDS = structures -------------------------------------------------------------------------------- /userspace/flanterm/app.conf: -------------------------------------------------------------------------------- 1 | NAME = flanterm 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard, celestial, flanterm -------------------------------------------------------------------------------- /userspace/lib/ethereal/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = ethereal 2 | VERSION = 1.1.0 3 | DESCRIPTION = "Generic Ethereal library" 4 | -------------------------------------------------------------------------------- /userspace/show-dialog/app.conf: -------------------------------------------------------------------------------- 1 | NAME = show-dialog 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard, widget, celestial -------------------------------------------------------------------------------- /drivers/arch/x86_64.config: -------------------------------------------------------------------------------- 1 | # x86_64 config file for Makefile 2 | 3 | CFLAGS += -mcmodel=large -mno-mmx -mno-sse -mno-sse2 -------------------------------------------------------------------------------- /drivers/fs/ext2/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "ext2.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/sound/ac97/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "ac97.sys" 2 | ENVIRONMENT = ANY 3 | PRIORITY = IGNORE 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /userspace/lib/pthread/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = pthread 2 | VERSION = 1.0.0 3 | DESCRIPTION = "Stub pthread library" 4 | NO_SHARED -------------------------------------------------------------------------------- /userspace/login-gui/app.conf: -------------------------------------------------------------------------------- 1 | NAME = login-gui 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard, celestial, version, widget -------------------------------------------------------------------------------- /userspace/toast-server/app.conf: -------------------------------------------------------------------------------- 1 | NAME = toast-server 2 | INSTALL_DIR = /usr/bin/ 3 | DEPENDS = keyboard, widget, celestial -------------------------------------------------------------------------------- /base/sysroot/usr/share/DejaVuSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/DejaVuSans.ttf -------------------------------------------------------------------------------- /base/sysroot/usr/share/ter-112n.psf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/ter-112n.psf -------------------------------------------------------------------------------- /drivers/net/e1000/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "net_e1000.sys" 2 | ENVIRONMENT = ANY 3 | PRIORITY = IGNORE 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/storage/ahci/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "ahci.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/storage/ide/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "ide_ata.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/storage/nvme/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "nvme.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/usb/uhci/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "usb_uhci.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/usb/xhci/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "usb_xhci.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /base/sysroot/etc/desktop.d/01-terminal.ent: -------------------------------------------------------------------------------- 1 | [Desktop] 2 | Name=Terminal 3 | Icon=/usr/share/icons/24/Terminal.bmp 4 | Exec="termemu" -------------------------------------------------------------------------------- /base/sysroot/etc/desktop.d/04-plasma.ent: -------------------------------------------------------------------------------- 1 | [Desktop] 2 | Name="Plasma" 3 | Icon=/usr/share/icons/24/Application.bmp 4 | Exec="plasma" -------------------------------------------------------------------------------- /base/sysroot/etc/ethereal-version: -------------------------------------------------------------------------------- 1 | NAME=Ethereal 2 | CODENAME=Mountainside 3 | VERSION_MAJOR=1 4 | VERSION_MINOR=2 5 | VERSION_LOWER=0 -------------------------------------------------------------------------------- /base/sysroot/usr/share/EtherealLogo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/EtherealLogo.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/cursors/text.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/cursors/text.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/terminfo/v/vt220: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/terminfo/v/vt220 -------------------------------------------------------------------------------- /drivers/net/rtl8139/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "net_rtl8139.sys" 2 | ENVIRONMENT = ANY 3 | PRIORITY = IGNORE 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /drivers/usb/usbhub/driver.conf.old: -------------------------------------------------------------------------------- 1 | FILENAME = "usb_hub.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 -------------------------------------------------------------------------------- /base/sysroot/etc/desktop.d/99-poweroff.ent: -------------------------------------------------------------------------------- 1 | [Desktop] 2 | Name=Power Off 3 | Icon=/usr/share/icons/24/power.bmp 4 | Exec="poweroff-dialog" -------------------------------------------------------------------------------- /base/sysroot/etc/passwd: -------------------------------------------------------------------------------- 1 | root:x:0:0:Administrator:/root/:/usr/bin/essence 2 | user:x:1000:1000:Ethereal User:/home/user:/usr/bin/essence -------------------------------------------------------------------------------- /base/sysroot/usr/share/DejaVuSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/DejaVuSansMono.ttf -------------------------------------------------------------------------------- /base/sysroot/usr/share/cursors/default.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/cursors/default.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/icons/24/power.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/icons/24/power.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/mercury/close.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/mercury/close.bmp -------------------------------------------------------------------------------- /base/sysroot/etc/desktop.d/03-color-wave.ent: -------------------------------------------------------------------------------- 1 | [Desktop] 2 | Name="Color Wave" 3 | Icon=/usr/share/icons/24/Application.bmp 4 | Exec="colorwave" -------------------------------------------------------------------------------- /base/sysroot/usr/share/icons/16/Ethereal.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/icons/16/Ethereal.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/icons/24/Ethereal.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/icons/24/Ethereal.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/icons/24/Terminal.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/icons/24/Terminal.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/mercury/maximize.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/mercury/maximize.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/mercury/minimize.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/mercury/minimize.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/wallpapers/lines.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/wallpapers/lines.bmp -------------------------------------------------------------------------------- /base/sysroot/etc/desktop.d/02-about-ethereal.ent: -------------------------------------------------------------------------------- 1 | [Desktop] 2 | Name="About Ethereal" 3 | Icon=/usr/share/icons/24/Ethereal.bmp 4 | Exec="etherealver" -------------------------------------------------------------------------------- /base/sysroot/usr/share/DejaVuSansMono-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/DejaVuSansMono-Bold.ttf -------------------------------------------------------------------------------- /base/sysroot/usr/share/EtherealStartButton.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/EtherealStartButton.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/UbuntuMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/UbuntuMono-Regular.ttf -------------------------------------------------------------------------------- /base/sysroot/usr/share/icons/24/Application.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/icons/24/Application.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/mercury/close-hover.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/mercury/close-hover.bmp -------------------------------------------------------------------------------- /external/README.txt: -------------------------------------------------------------------------------- 1 | External resources will be placed here. See each subdirectory for instructions on installing the required resources if needed. -------------------------------------------------------------------------------- /userspace/lib/graphics/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = graphics 2 | VERSION = 1.1.0 3 | DESCRIPTION = "Ethereal graphics library" 4 | DEPENDS_ON = freetype2 5 | -------------------------------------------------------------------------------- /userspace/lib/widget/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = widget 2 | VERSION = 1.0.0 3 | DESCRIPTION = "Widget library" 4 | DEPENDS_ON = celestial, graphics, keyboard -------------------------------------------------------------------------------- /base/sysroot/etc/hosts: -------------------------------------------------------------------------------- 1 | # Static table lookup for hostnames. 2 | # See hosts(5) for details. 3 | 127.0.0.1 localhost 4 | ::1 localhost -------------------------------------------------------------------------------- /base/sysroot/usr/share/mercury/maximize-hover.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/mercury/maximize-hover.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/mercury/minimize-hover.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/mercury/minimize-hover.bmp -------------------------------------------------------------------------------- /base/sysroot/usr/share/terminfo/x/xterm-256color: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/terminfo/x/xterm-256color -------------------------------------------------------------------------------- /base/sysroot/boot/conf.ini: -------------------------------------------------------------------------------- 1 | [boot] 2 | kernel_font=/device/initrd/usr/share/ter-112n.psf 3 | symmap=/device/initrd/boot/hexahedron-kernel-symmap.map 4 | 5 | -------------------------------------------------------------------------------- /drivers/usb/ehci/driver.conf: -------------------------------------------------------------------------------- 1 | FILENAME = "usb_ehci.sys" 2 | ENVIRONMENT = NORMAL 3 | PRIORITY = WARN 4 | ARCH = I386 OR X86_64 5 | LOAD_BEFORE = usb_uhci.sys -------------------------------------------------------------------------------- /userspace/lib/celestial/lib.conf: -------------------------------------------------------------------------------- 1 | NAME = celestial 2 | VERSION = 1.2.0 3 | DESCRIPTION = "Window server library" 4 | DEPENDS_ON = graphics,structures,ethereal -------------------------------------------------------------------------------- /base/sysroot/usr/share/wallpapers/EtherealWallpaper1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sasdallas/Ethereal/HEAD/base/sysroot/usr/share/wallpapers/EtherealWallpaper1.bmp -------------------------------------------------------------------------------- /userspace/miniutils/README.txt: -------------------------------------------------------------------------------- 1 | miniutils: A set of small coreutils equivalents (+ more for Ethereal) 2 | ===================================================================== 3 | -------------------------------------------------------------------------------- /conf/build/aarch64.mk: -------------------------------------------------------------------------------- 1 | # aarch64 build configuration for Hexahedron/Polyhedron/any aarch64-based project 2 | # YOU MAY EDIT THIS 3 | 4 | # ACPICA settings 5 | USE_ACPICA = 0 6 | CFLAGS += -mcmodel=large -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libc/mlibc"] 2 | path = libc/mlibc 3 | url = https://github.com/sasdallas/mlibc 4 | [submodule "external/plutosvg/plutosvg"] 5 | path = external/plutosvg/plutosvg 6 | url = https://github.com/sammycage/plutosvg 7 | -------------------------------------------------------------------------------- /drivers/fs/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /drivers/net/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /drivers/usb/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /external/freetype/Makefile: -------------------------------------------------------------------------------- 1 | # freetype makefile 2 | include ./make.config 3 | 4 | install: 5 | chmod +x ./build.sh 6 | bash -c "./build.sh $(HOSTARCH) $(DESTDIR)" 7 | 8 | install-headers: 9 | 10 | clean: 11 | -rm -rf build-freetype -------------------------------------------------------------------------------- /drivers/graphics/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /drivers/misc/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /drivers/sound/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /drivers/storage/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /userspace/lib/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /userspace/tray/make.config: -------------------------------------------------------------------------------- 1 | # Taken from https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile 2 | mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 | 4 | include $(mkfile_path)/../make.config -------------------------------------------------------------------------------- /base/sysroot/usr/bin/x86_64-ethereal-pkg-config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export PKG_CONFIG_SYSROOT_DIR=$SYSROOT 3 | export PKG_CONFIG_LIBDIR=$PKG_CONFIG_SYSROOT_DIR/usr/lib/pkgconfig 4 | export PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR 5 | exec pkg-config --static "$@" 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build-output/ 2 | external/acpica/acpica-src/ 3 | external/freetype/build-freetype/ 4 | external/freetype/freetype-2.4.9/ 5 | ser_output.txt 6 | ser_output2.txt 7 | .gdb_history 8 | *.img 9 | drivers/test 10 | drivers/test/* 11 | **/generated_build_rules.mk -------------------------------------------------------------------------------- /conf/theme/README: -------------------------------------------------------------------------------- 1 | Ethereal's cobbled together GRUB theme is sourced from: 2 | 3 | - The default Starfield GRUB theme (COPYING.CC-BY-SA-3.0) 4 | - The Particle Circle GRUB theme (Particle-Circle.LICENSE): https://github.com/yeyushengfan258/Particle-circle-grub-theme/blob/main/LICENSE -------------------------------------------------------------------------------- /libkstructures/structures.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr 2 | exec_prefix=${prefix} 3 | libdir=/usr/lib 4 | includedir=/usr/include 5 | 6 | Name: structures 7 | Description: "Generic structures library" 8 | Requires: 9 | Requires.private: 10 | Version: 1.1.0 11 | Libs: -L${libdir} -lstructures 12 | Libs.private: 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /conf/build/i386.mk: -------------------------------------------------------------------------------- 1 | # i386 build configuration for Hexahedron/Polyhedron/any I386-based project 2 | # YOU MAY EDIT THIS 3 | 4 | # ACPICA settings 5 | USE_ACPICA = 1 6 | 7 | ifeq ($(USE_ACPICA), 1) 8 | CFLAGS += -DACPICA_ENABLED 9 | endif 10 | 11 | # !!!: HACK 12 | CFLAGS += -I$(PROJECT_ROOT)/build-output/sysroot/usr/include/freetype2/ -------------------------------------------------------------------------------- /libc/ethereal_cross.txt: -------------------------------------------------------------------------------- 1 | [host_machine] 2 | system = 'ethereal' 3 | cpu_family = 'x86_64' 4 | cpu = 'x86_64' 5 | endian = 'little' 6 | [binaries] 7 | c = 'x86_64-ethereal-gcc' 8 | cpp = 'x86_64-ethereal-g++' 9 | ar = 'x86_64-ethereal-ar' 10 | strip = 'x86_64-ethereal-strip' 11 | ld = 'x86_64-ethereal-ld' 12 | pkgconfig = 'x86_64-ethereal-pkg-config' -------------------------------------------------------------------------------- /conf/build/x86_64.mk: -------------------------------------------------------------------------------- 1 | # x86_64 build configuration for Hexahedron/Polyhedron/any x86_64-based project 2 | # YOU MAY EDIT THIS 3 | 4 | # ACPICA settings 5 | USE_ACPICA = 1 6 | 7 | ifeq ($(USE_ACPICA), 1) 8 | CFLAGS += -DACPICA_ENABLED 9 | endif 10 | 11 | # Add additional x86_64 CFLAGS 12 | CFLAGS += -mcmodel=large -fstrict-volatile-bitfields 13 | 14 | # !!!: HACK FOR FREETYPE 15 | CFLAGS += -I$(PROJECT_ROOT)/build-output/sysroot/usr/include/freetype2/ -------------------------------------------------------------------------------- /hexahedron/include/kernel/fs/log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/fs/log.h 3 | * @brief Log device 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_FS_LOG_H 15 | #define KERNEL_FS_LOG_H 16 | 17 | #endif -------------------------------------------------------------------------------- /hexahedron/klib/stdlib/abs.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/stdlib/abs.c 3 | * @brief abs 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | int abs(int j) { 17 | return (j < 0) ? -(j) : j; 18 | } -------------------------------------------------------------------------------- /libkstructures/make.config: -------------------------------------------------------------------------------- 1 | include ../make.config 2 | 3 | CFLAGS?=-O2 -g 4 | CPPFLAGS?= 5 | LDFLAGS?= 6 | LIBS?= 7 | 8 | DESTDIR?= 9 | PREFIX?=/usr 10 | EXEC_PREFIX?=$(PREFIX) 11 | BOOT_OUTPUT?=/boot 12 | INCLUDE_DIR?=$(PREFIX)/include 13 | LIBDIR?=$(EXEC_PREFIX)/lib 14 | 15 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 16 | 17 | CFLAGS := $(CFLAGS) -ffreestanding -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-parameter 18 | CPPFLAGS := $(CPPFLAGS) 19 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) 20 | LIBS := $(LIBS) -lgcc -------------------------------------------------------------------------------- /external/acpica/README.txt: -------------------------------------------------------------------------------- 1 | ACPICA 2 | ================================================= 3 | 4 | Please extract the ACPICA sources to "external/acpica/acpica-src". 5 | Requested version: 20240927 6 | Link: https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/download.html 7 | 8 | 9 | ----------- LICENSING ----------- 10 | 11 | I could not find any licensing for the Intel-specific license they are stated to use. 12 | Please check: https://www.intel.com/content/www/us/en/developer/articles/license/acpica-licensing.html -------------------------------------------------------------------------------- /hexahedron/include/kernel/fs/console.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/fs/console.h 3 | * @brief /device/console 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_FS_CONSOLE_H 15 | #define KERNEL_FS_CONSOLE_H 16 | 17 | 18 | #endif -------------------------------------------------------------------------------- /external/plutosvg/Makefile: -------------------------------------------------------------------------------- 1 | include ./make.config 2 | 3 | OBJ_DIR = $(OBJ_OUTPUT_DIRECTORY)/plutosvg 4 | 5 | BASE_DIR = $(shell pwd) 6 | PLUTOSVG_DIR = $(BASE_DIR)/plutosvg/ 7 | 8 | make_dirs: 9 | -mkdir $(OBJ_DIR) 10 | 11 | install-headers: make_dirs 12 | 13 | install: 14 | set -e; \ 15 | cd $(OBJ_DIR); \ 16 | LDFLAGS="" CFLAGS="" meson setup --cross-file=$(PROJECT_ROOT)/libc/ethereal_cross.txt -Dprefix=$(PREFIX) $(PLUTOSVG_DIR); \ 17 | DESTDIR=$(DESTDIR) ninja install; \ 18 | cd $(BASE_DIR) 19 | 20 | clean: 21 | -rm -rf $(OBJ_DIR) 22 | -------------------------------------------------------------------------------- /userspace/miniutils/tty.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/tty.c 3 | * @brief tty 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | int main(int argc, char *argv[]) { 18 | printf("%s\n", ptsname(1)); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /drivers/make_main.config: -------------------------------------------------------------------------------- 1 | include ../make.config 2 | 3 | CFLAGS?=-O2 -g 4 | CPPFLAGS?= 5 | LDFLAGS?= 6 | LIBS?= 7 | 8 | DESTDIR?= 9 | PREFIX?=/usr 10 | EXEC_PREFIX?=$(PREFIX) 11 | BOOT_OUTPUT?=/boot 12 | INCLUDE_DIR?=$(PREFIX)/include 13 | LIBDIR?=$(EXEC_PREFIX)/lib 14 | 15 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 16 | 17 | CFLAGS := $(CFLAGS) -ffreestanding -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-function -D__KERNEL_DRIVER__ 18 | CPPFLAGS := $(CPPFLAGS) 19 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) -L$(DESTDIR)$(LIBDIR) 20 | LIBS := $(LIBS) -nostdlib -------------------------------------------------------------------------------- /userspace/miniutils/echo.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/echo.c 3 | * @brief echo 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | int main(int argc, char *argv[]) { 17 | for (int i = 1; i < argc; i++) { 18 | printf("%s ", argv[i]); 19 | } 20 | 21 | putchar('\n'); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /external/freetype/make.config: -------------------------------------------------------------------------------- 1 | include ../../make.config 2 | 3 | CFLAGS?=-O2 -g 4 | CPPFLAGS?= 5 | LDFLAGS?= 6 | LIBS?= 7 | 8 | DESTDIR?= 9 | PREFIX?=/usr 10 | EXEC_PREFIX?=$(PREFIX) 11 | BOOT_OUTPUT?=/boot 12 | INCLUDE_DIR?=$(PREFIX)/include 13 | LIBDIR?=$(EXEC_PREFIX)/lib 14 | 15 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 16 | 17 | CFLAGS := $(CFLAGS) -D__KERNEL__ -ffreestanding -I $(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 18 | CPPFLAGS := $(CPPFLAGS) -D__KERNEL__ -ffreestanding -I $(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 19 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) 20 | LIBS := $(LIBS) -lgcc -------------------------------------------------------------------------------- /external/plutosvg/make.config: -------------------------------------------------------------------------------- 1 | include ../../make.config 2 | 3 | CFLAGS?=-O2 -g 4 | CPPFLAGS?= 5 | LDFLAGS?= 6 | LIBS?= 7 | 8 | DESTDIR?= 9 | PREFIX?=/usr 10 | EXEC_PREFIX?=$(PREFIX) 11 | BOOT_OUTPUT?=/boot 12 | INCLUDE_DIR?=$(PREFIX)/include 13 | LIBDIR?=$(EXEC_PREFIX)/lib 14 | 15 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 16 | 17 | CFLAGS := $(CFLAGS) -D__KERNEL__ -ffreestanding -I $(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 18 | CPPFLAGS := $(CPPFLAGS) -D__KERNEL__ -ffreestanding -I $(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 19 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) 20 | LIBS := $(LIBS) -lgcc -------------------------------------------------------------------------------- /hexahedron/arch/x86_64/make.config: -------------------------------------------------------------------------------- 1 | # x86_64 build configuration 2 | 3 | # Add source directories 4 | SOURCE_DIRECTORIES += arch/x86_64 drivers/x86/ 5 | 6 | # Specify the linker file 7 | ARCH_LINK_LD := arch/x86_64/linker.ld 8 | 9 | CFLAGS += -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mfsgsbase -mgeneral-regs-only -z max-page-size=0x1000 -fno-omit-frame-pointer -Wno-unused-local-typedefs -mcmodel=large -fstack-protector 10 | LDFLAGS += -z max-page-size=0x1000 11 | 12 | # Add extra stuff if needed 13 | ifeq ($(USE_ACPICA), 1) 14 | CFLAGS += -I$(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 15 | LIBS += -lacpica 16 | endif 17 | -------------------------------------------------------------------------------- /libc/make.config: -------------------------------------------------------------------------------- 1 | CFLAGS?=-O2 -g 2 | CPPFLAGS?= 3 | LDFLAGS?= 4 | LIBS?= 5 | 6 | DESTDIR?= 7 | PREFIX?=/usr 8 | EXEC_PREFIX?=$(PREFIX) 9 | BOOT_OUTPUT?=/boot 10 | INCLUDE_DIR?=$(PREFIX)/include 11 | LIBDIR?=$(EXEC_PREFIX)/lib 12 | BINARY_DIR?=$(PREFIX)/bin 13 | 14 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 15 | 16 | CFLAGS := $(CFLAGS) -ffreestanding -Wall -Wextra -Werror -Wno-format -Wno-unused-parameter -Wno-unused-function -Wno-unused-local-typedefs -Iinclude 17 | CPPFLAGS := $(CPPFLAGS) 18 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) -L$(DESTDIR)$(LIBDIR) -lc -lm 19 | LIBS := $(LIBS) -nostdlib 20 | 21 | -------------------------------------------------------------------------------- /external/acpica/make.config: -------------------------------------------------------------------------------- 1 | include ../../make.config 2 | 3 | CFLAGS := $(patsubst %-g, %, $(CFLAGS)) 4 | CPPFLAGS?= 5 | LDFLAGS?= 6 | LIBS?= 7 | 8 | DESTDIR?= 9 | PREFIX?=/usr 10 | EXEC_PREFIX?=$(PREFIX) 11 | BOOT_OUTPUT?=/boot 12 | INCLUDE_DIR?=$(PREFIX)/include 13 | LIBDIR?=$(EXEC_PREFIX)/lib 14 | 15 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 16 | 17 | CFLAGS := $(CFLAGS) -D__KERNEL__ -ffreestanding -I $(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 18 | CPPFLAGS := $(CPPFLAGS) -D__KERNEL__ -ffreestanding -I $(DESTDIR)$(INCLUDE_DIRECTORY)/acpica/ 19 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) 20 | LIBS := $(LIBS) -lgcc -------------------------------------------------------------------------------- /hexahedron/klib/string/select.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @brief Code taken from mlibc 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void __FD_CLR(int fd, fd_set *set) { 10 | assert(fd < FD_SETSIZE); 11 | set->fds_bits[fd / 8] &= ~(1 << (fd % 8)); 12 | } 13 | int __FD_ISSET(int fd, fd_set *set) { 14 | assert(fd < FD_SETSIZE); 15 | return set->fds_bits[fd / 8] & (1 << (fd % 8)); 16 | } 17 | void __FD_SET(int fd, fd_set *set) { 18 | assert(fd < FD_SETSIZE); 19 | set->fds_bits[fd / 8] |= 1 << (fd % 8); 20 | } 21 | void __FD_ZERO(fd_set *set) { 22 | memset(set->fds_bits, 0, sizeof(fd_set)); 23 | } -------------------------------------------------------------------------------- /userspace/miniutils/clear.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/clear.c 3 | * @brief clear program, which uses the ANSI escape sequence \033[2J 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | int main(int argc, char *argv[]) { 17 | // TODO: Make this part of the terminal? 18 | printf("\033[2J"); 19 | fflush(stdout); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/memset.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/memset.c 3 | * @brief memset 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | void *memset(void *s, int ch, size_t n) { 17 | unsigned char *p = (unsigned char*)s; 18 | for (unsigned i = 0; i < n; i++) p[i] = ch; 19 | return s; 20 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/strlen.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strlen.c 3 | * @brief strlen 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | size_t strlen(const char *s) { 17 | char *p = (char*)s; // Avoiding GCC complaining 18 | size_t ret = 0; 19 | while (*p) { p++; ret++; } 20 | return ret; 21 | } -------------------------------------------------------------------------------- /hexahedron/make.config: -------------------------------------------------------------------------------- 1 | include ../make.config 2 | 3 | CFLAGS?=-O2 -g 4 | CPPFLAGS?= 5 | LDFLAGS?= 6 | LIBS?= 7 | 8 | DESTDIR?= 9 | PREFIX?=/usr 10 | EXEC_PREFIX?=$(PREFIX) 11 | BOOT_OUTPUT?=/boot 12 | INCLUDE_DIR?=$(PREFIX)/include 13 | LIBDIR?=$(EXEC_PREFIX)/lib 14 | 15 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 16 | 17 | CFLAGS := $(CFLAGS) -ffreestanding -Wall -Wextra -Werror -Wno-unused-parameter -Wno-restrict -Wno-format -Wno-unused-function -Wno-unused-local-typedefs -D__LIBK -Iinclude 18 | CPPFLAGS := $(CPPFLAGS) 19 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) -L$(DESTDIR)$(LIBDIR) 20 | LIBS := $(LIBS) -nostdlib 21 | 22 | -------------------------------------------------------------------------------- /.github/workflows/i386.old: -------------------------------------------------------------------------------- 1 | on: [push, workflow_dispatch] 2 | name: i386 ISO image 3 | jobs: 4 | build-iso: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Clone reduceOS repository 8 | uses: actions/checkout@v2 9 | - name: Download Docker image 10 | run: docker pull techdude17/reduceos-docker:i386 11 | - name: Build OS 12 | run: docker run -v ${GITHUB_WORKSPACE}:/opt/reduceOS -t techdude17/reduceos-docker:i386 /opt/build/build.sh 13 | - name: Upload artifact 14 | uses: actions/upload-artifact@v4 15 | with: 16 | name: iso 17 | path: build-output/hexahedron.iso -------------------------------------------------------------------------------- /external/freetype/freetype.patch: -------------------------------------------------------------------------------- 1 | diff -rupN original/builds/unix/config.sub new/builds/unix/config.sub 2 | --- original/builds/unix/config.sub 2012-03-08 15:09:13.000000000 -0500 3 | +++ new/builds/unix/config.sub 2012-05-17 11:40:42.308339450 -0400 4 | @@ -1343,6 +1343,7 @@ case $os in 5 | | -sym* | -kopensolaris* \ 6 | | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 7 | | -aos* | -aros* \ 8 | + | -ethereal* \ 9 | | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ 10 | | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 11 | | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ -------------------------------------------------------------------------------- /hexahedron/klib/string/memcpy_fast.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/memcpy_fast.S 3 | * @brief memcpy implementation 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifdef __ARCH_X86_64__ 15 | 16 | .global memcpy 17 | memcpy: 18 | movq %rdi, %rax 19 | movq %rdx, %rcx 20 | movq %rdi, %rdx 21 | rep movsb 22 | movq %rdx, %rax 23 | ret 24 | 25 | #endif -------------------------------------------------------------------------------- /hexahedron/klib/string/strdup.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strdup.c 3 | * @brief strdup 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | char *strdup(const char *s) { 18 | size_t len = strlen(s); 19 | char *rep = malloc(len+1); 20 | memcpy(rep, s, len); 21 | rep[len] = 0; 22 | return rep; 23 | } -------------------------------------------------------------------------------- /make.config: -------------------------------------------------------------------------------- 1 | CWD := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))) 2 | PROJECT_ROOT = $(CWD) 3 | BUILDSCRIPTS_ROOT = $(CWD)/buildscripts 4 | 5 | DEFAULT_HOST != $(BUILDSCRIPTS_ROOT)/build-arch.sh 6 | HOST ?= DEFAULT_HOST 7 | HOSTARCH != $(BUILDSCRIPTS_ROOT)/target-triplet-to-arch.sh $(DEFAULT_HOST) 8 | 9 | BUILD_ARCH ?= $(shell $(BUILDSCRIPTS_ROOT)/target-triplet-to-arch.sh $(shell $(BUILDSCRIPTS_ROOT)/build-arch.sh)) 10 | 11 | TARGET = $(call lc,$(KERNEL_BUILD_CONF)) 12 | 13 | ifeq ($(KERNEL_BUILD_CONF), DEBUG) 14 | CFLAGS += -g 15 | endif 16 | 17 | # Include the architecture configuration. 18 | include $(PROJECT_ROOT)/conf/build/$(HOSTARCH).mk -------------------------------------------------------------------------------- /base/Makefile: -------------------------------------------------------------------------------- 1 | # Base makefile 2 | include ../make.config 3 | 4 | # Target disabled 5 | all: 6 | @echo "=== TARGET DISABLED ===" 7 | @echo "Please use make install" 8 | 9 | 10 | # Cosmetic 11 | PRINT_HEADER: 12 | @echo 13 | @echo 14 | @echo "[ Creating base, please wait... ]" 15 | @echo 16 | @echo 17 | 18 | 19 | install: 20 | @echo "Ignored" 21 | 22 | install-headers: 23 | -mkdir -pv $(SYSROOT) 24 | -mkdir -pv $(INITRD) 25 | -cp -rp initrd/* $(INITRD)/ 26 | -cp -rp sysroot/* $(SYSROOT)/ 27 | 28 | -mkdir $(SYSROOT)/kernel 29 | -mkdir $(SYSROOT)/tmp 30 | -mkdir $(SYSROOT)/device 31 | -mkdir $(SYSROOT)/comm 32 | 33 | clean: 34 | -rm -rf $(INITRD)/ 35 | -rm -rf $(SYSROOT)/ -------------------------------------------------------------------------------- /userspace/lib/ethereal/reboot.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib//ethereal/reboot.c 3 | * @brief Ethereal reboot API 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | DEFINE_SYSCALL1(reboot, SYS_REBOOT, int); 19 | 20 | int ethereal_reboot(int operation) { 21 | __sets_errno(__syscall_reboot(operation)); 22 | } -------------------------------------------------------------------------------- /userspace/miniutils/hibernate.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/hibernate.c 3 | * @brief Hibernate 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | ethereal_reboot(REBOOT_TYPE_HIBERNATE); 21 | fprintf(stderr, "poweroff: Failed to power off: %s\n", strerror(errno)); 22 | return 1; 23 | } -------------------------------------------------------------------------------- /userspace/miniutils/reboot.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/reboot.c 3 | * @brief Reboot utility 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | ethereal_reboot(REBOOT_TYPE_DEFAULT); 21 | fprintf(stderr, "poweroff: Failed to power off: %s\n", strerror(errno)); 22 | return 1; 23 | } -------------------------------------------------------------------------------- /hexahedron/include/kernel/fs/null.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/fs/null.h 3 | * @brief Null/zero device (/device/null and /device/zero) 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_FS_NULL_H 15 | #define KERNEL_FS_NULL_H 16 | 17 | /**** DEFINITIONS ****/ 18 | 19 | #define NULLDEV_MOUNT_PATH "/device/null" 20 | #define ZERODEV_MOUNT_PATH "/device/zero" 21 | 22 | #endif -------------------------------------------------------------------------------- /userspace/celestial/kbd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/celestial/kbd.h 3 | * @brief kbd.h 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _CELESTIAL_WM_KBD_H 15 | #define _CELESTIAL_WM_KBD_H 16 | 17 | /**** FUNCTIONS ****/ 18 | 19 | /** 20 | * @brief Initialize keyboard device 21 | */ 22 | void kbd_init(); 23 | 24 | /** 25 | * @brief Update keyboard device 26 | */ 27 | void kbd_update(); 28 | 29 | #endif -------------------------------------------------------------------------------- /userspace/miniutils/poweroff.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/poweroff.c 3 | * @brief poweroff utility 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | int main(int argc, char *argv[]) { 20 | ethereal_reboot(REBOOT_TYPE_POWEROFF); 21 | fprintf(stderr, "poweroff: Failed to power off: %s\n", strerror(errno)); 22 | return 1; 23 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/rand.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/rand.c 3 | * @brief rand 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | static unsigned long __rand_next = 0; 15 | 16 | void srand(unsigned int seed) { 17 | __rand_next = seed; 18 | } 19 | 20 | int rand() { 21 | // Assuming RAND_MAX is 32767 22 | __rand_next = __rand_next * 1103515245 + 12345; 23 | return (unsigned int)(__rand_next / 65536) % 32768; 24 | } -------------------------------------------------------------------------------- /hexahedron/klib/stdlib/assert.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/stdlib/assert.c 3 | * @brief assert 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | void __assert_fail(const char *stmt, const char *file, int line, const char *function) { 17 | kernel_panic_extended(ASSERTION_FAILED, "klib", "*** Assertion (%s:%i) in function %s failed: %s\n", file, line, function, stmt); 18 | __builtin_unreachable(); 19 | } -------------------------------------------------------------------------------- /userspace/miniutils/users.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/users.c 3 | * @brief Lists users in the system 4 | * 5 | * @note This lists actual users 6 | * 7 | * @copyright 8 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 9 | * It is released under the terms of the BSD 3-clause license. 10 | * Please see the LICENSE file in the main repository for more details. 11 | * 12 | * Copyright (C) 2025 Samuel Stuart 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | int main(int argc, char *argv[]) { 19 | struct passwd *p = getpwent(); 20 | 21 | while (p) { 22 | printf("%s\n", p->pw_name); 23 | p = getpwent(); 24 | } 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /userspace/miniutils/whoami.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/whoami.c 3 | * @brief whoami 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | int main(int argc, char *argv[]) { 19 | struct passwd *pw = getpwuid(geteuid()); 20 | 21 | if (pw) { 22 | printf("%s\n", pw->pw_name); 23 | } else { 24 | printf("unknown\n"); 25 | } 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/celestial/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/celestial/types.h 3 | * @brief Celestial types (win_pos_t) 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _CELESTIAL_TYPES_H 15 | #define _CELESTIAL_TYPES_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /**** TYPES ****/ 24 | 25 | typedef size_t win_pos_t; 26 | typedef pid_t wid_t; 27 | 28 | #endif -------------------------------------------------------------------------------- /hexahedron/klib/string/memcpy.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/memcpy.c 3 | * @brief memcpy 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | #ifndef __ARCH_X86_64__ 17 | 18 | void *memcpy(void *dest, const void *src, size_t n) { 19 | unsigned char *d = (unsigned char*)dest; 20 | const unsigned char *s = (const unsigned char*)src; 21 | for (unsigned i = 0; i < n; i++) *d++ = *s++; 22 | return dest; 23 | } 24 | 25 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/toast.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/toast.h 3 | * @brief Ethereal toast daemon 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _TOAST_H 15 | #define _TOAST_H 16 | 17 | /**** DEFINITIONS ****/ 18 | 19 | #define TOAST_FLAG_NO_ICON 0x1 20 | 21 | /**** TYPES ****/ 22 | 23 | typedef struct toast { 24 | unsigned char flags; 25 | char icon[64]; 26 | char title[128]; 27 | char description[128]; 28 | } toast_t; 29 | 30 | 31 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/x86/early_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/x86/early_log.h 3 | * @brief Early log device 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_X86_EARLY_LOG_H 15 | #define DRIVERS_X86_EARLY_LOG_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** FUNCTIONS ****/ 22 | 23 | /** 24 | * @brief Initialize the early log 25 | */ 26 | void earlylog_init(); 27 | 28 | #endif -------------------------------------------------------------------------------- /userspace/make.config: -------------------------------------------------------------------------------- 1 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 2 | root_userspace_dir := $(dir $(mkfile_path)) 3 | 4 | include $(root_userspace_dir)/../make.config 5 | 6 | CFLAGS?=-O2 -g 7 | CPPFLAGS?= 8 | LDFLAGS?= 9 | LIBS?= 10 | 11 | DESTDIR?= 12 | PREFIX?=/usr 13 | EXEC_PREFIX?=$(PREFIX) 14 | BOOT_OUTPUT?=/boot 15 | INCLUDE_DIR?=$(PREFIX)/include 16 | LIBDIR?=$(EXEC_PREFIX)/lib 17 | BINARY_DIR?=$(PREFIX)/bin 18 | 19 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 20 | 21 | CFLAGS := $(CFLAGS) -ffreestanding -Wall -Wextra -Werror -Wno-format -Wno-unused-parameter -Wno-unused-function -Wno-unused-local-typedefs -Iinclude 22 | CPPFLAGS := $(CPPFLAGS) 23 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) -L$(DESTDIR)$(LIBDIR) -lc -lm 24 | LIBS := $(LIBS) -nostdlib 25 | 26 | -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/widget.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/widget.h 3 | * @brief Ethereal widgets library 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _WIDGET_H 15 | #define _WIDGET_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/graphics/util.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/graphics/util.h 3 | * @brief Utility graphical functions 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _GRAPHICS_UTIL_H 15 | #define _GRAPHICS_UTIL_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** INLINE FUNCTIONS ****/ 22 | 23 | static inline int gfx_clamp(int val, int low, int high) { 24 | if (val < low) return low; 25 | if (val > high) return high; 26 | return val; 27 | } 28 | 29 | 30 | #endif -------------------------------------------------------------------------------- /drivers/make.config: -------------------------------------------------------------------------------- 1 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 2 | root_driver_dir := $(dir $(mkfile_path)) 3 | 4 | include $(root_driver_dir)/../make.config 5 | 6 | CFLAGS?=-O2 -g 7 | CPPFLAGS?= 8 | LDFLAGS?= 9 | LIBS?= 10 | 11 | DESTDIR?= 12 | PREFIX?=/usr 13 | EXEC_PREFIX?=$(PREFIX) 14 | BOOT_OUTPUT?=/boot 15 | INCLUDE_DIR?=$(PREFIX)/include 16 | LIBDIR?=$(EXEC_PREFIX)/lib 17 | 18 | LIBDIRS = $(dir $(shell $(CC) -print-libgcc-file-name)) 19 | 20 | CFLAGS := $(CFLAGS) -ffreestanding -O2 -Wall -Wextra -Werror -fno-pie -g -static -pedantic -Wno-unused-parameter -Wno-unused-function -D__KERNEL_DRIVER__ 21 | CPPFLAGS := $(CPPFLAGS) 22 | LDFLAGS := $(LDFLAGS) -L$(LIBDIRS) -L$(DESTDIR)$(LIBDIR) -r 23 | LIBS := $(LIBS) -nostdlib -lgcc 24 | 25 | include $(root_driver_dir)/arch/$(BUILD_ARCH).config -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/reboot.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/reboot.h 3 | * @brief Reboot 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _SYS_ETHEREAL_REBOOT_H 15 | #define _SYS_ETHEREAL_REBOOT_H 16 | 17 | /**** DEFINITIONS ****/ 18 | 19 | #define REBOOT_TYPE_DEFAULT 0 20 | #define REBOOT_TYPE_POWEROFF 1 21 | #define REBOOT_TYPE_HIBERNATE 2 22 | 23 | /**** FUNCTIONS ****/ 24 | 25 | int ethereal_reboot(int operation); 26 | 27 | #endif -------------------------------------------------------------------------------- /userspace/miniutils/poweroff-dialog.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/poweroff-dialog.c 3 | * @brief Power off with dialog 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | int main(int argc, char *argv[]) { 20 | int y = system("/usr/bin/show-dialog --question --icon=/usr/share/icons/24/power.bmp --title=\"Power off\" --text=\"Do you want to power off?\""); 21 | 22 | if (y) { 23 | return 0; 24 | } 25 | 26 | 27 | system("poweroff"); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /userspace/miniutils/ethereal-version.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/ethereal-version.c 3 | * @brief Get Ethereal version 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | int main(int argc, char *argv[]) { 18 | const ethereal_version_t *ver = ethereal_getVersion(); 19 | 20 | printf("%s v%d.%d.%d (codename %s)\n", ver->name, ver->version_major, ver->version_minor, ver->version_lower, ver->codename); 21 | printf("Ethereal is licensed under the BSD-3 clause license.\n"); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /hexahedron/klib/stdlib/malloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/stdlib/malloc.c 3 | * @brief malloc + friends (thunks to kmalloc) 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | void *malloc(size_t size) { 18 | return kmalloc(size); 19 | } 20 | 21 | void free(void *p) { 22 | return kfree(p); 23 | } 24 | 25 | void *calloc(size_t n, size_t size) { 26 | return kcalloc(n, size); 27 | } 28 | 29 | void *realloc(void *p, size_t size) { 30 | return krealloc(p, size); 31 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/strstr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strstr.c 3 | * @brief strstr 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | char* strstr(const char* haystack, const char* needle) { 18 | size_t l = strlen(needle); 19 | if (l == 0) return (char*)haystack; 20 | 21 | for (size_t i = 0; haystack[i]; i++) { 22 | if (strncmp(haystack + i, needle, l) == 0) { 23 | return ((char*)haystack + i); 24 | } 25 | } 26 | 27 | return NULL; 28 | } -------------------------------------------------------------------------------- /hexahedron/misc/stack.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/misc/stack.c 3 | * @brief Stack smashing protector 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #if UINT32_MAX == UINTPTR_MAX 20 | #define STACK_CHK_GUARD 0xe2dee396 21 | #else 22 | #define STACK_CHK_GUARD 0x595e9fbd94fda766 23 | #endif 24 | 25 | uintptr_t __stack_chk_guard = STACK_CHK_GUARD; 26 | 27 | void __stack_chk_fail(void) { 28 | kernel_panic(STACK_SMASHING_DETECTED, "stack-protector"); 29 | } -------------------------------------------------------------------------------- /external/freetype/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $1 = arch 3 | # $2 = sysroot 4 | 5 | set -e 6 | 7 | if [[ -d build-freetype ]]; then 8 | echo Assuming Freetype is up to date 9 | exit 0 10 | fi 11 | 12 | # Download freetype 13 | if [ ! -f freetype-2.4.9.tar.bz2 ]; then 14 | wget https://sourceforge.net/projects/freetype/files/freetype2/2.4.9/freetype-2.4.9.tar.bz2 15 | fi 16 | 17 | tar -xf freetype-2.4.9.tar.bz2 18 | # rm freetype-2.4.9.tar.bz2 19 | 20 | # Patch freetype 21 | cd freetype-2.4.9 22 | patch -p1 < ../freetype.patch 23 | cd .. 24 | 25 | 26 | # Build freetype 27 | mkdir build-freetype || true 28 | cd build-freetype 29 | rm -rf * || true 30 | chmod +x ../freetype-2.4.9/configure 31 | ../freetype-2.4.9/configure --host=$1-ethereal --prefix=/usr --build=x86_64-linux-gnu --without-zlib 32 | make -j4 33 | make DESTDIR=$2 install 34 | cd .. -------------------------------------------------------------------------------- /hexahedron/klib/string/memcmp.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/memcmp.c 3 | * @brief memcmp 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | int memcmp(const void *s1, const void *s2, size_t n) { 17 | unsigned char *p1 = (unsigned char *)s1; 18 | unsigned char *p2 = (unsigned char *)s2; 19 | size_t r = n; 20 | 21 | while (r) { 22 | if (*p1 != *p2) { 23 | return (*p1 - *p2); 24 | } 25 | 26 | p1++; 27 | p2++; 28 | r--; 29 | } 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /hexahedron/include/kernel/fs/ramdev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/fs/ramdev.h 3 | * @brief RAM device header 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_FS_RAMDEV_H 15 | #define KERNEL_FS_RAMDEV_H 16 | 17 | /**** INCLUDES ****/ 18 | 19 | #include 20 | #include 21 | 22 | /**** FUNCTIONS ****/ 23 | 24 | /** 25 | * @brief Mount RAM device 26 | * @param addr Virtual memory to use 27 | * @param size The size of the ramdev 28 | */ 29 | fs_node_t *ramdev_mount(uintptr_t addr, uintptr_t size); 30 | 31 | #endif -------------------------------------------------------------------------------- /hexahedron/klib/string/memchr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/memchr.c 3 | * @brief memchr 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | void *memchr(const void *s, int ch, size_t n) { 17 | unsigned char *p = (unsigned char*)s; 18 | for (unsigned i = 0; i < n; i++) if (p[i] == ch) return &p[i]; 19 | return NULL; 20 | } 21 | 22 | void *memchrr(const void *s, int ch, size_t n) { 23 | unsigned char *p = (unsigned char*)s; 24 | for (unsigned i = n; i > 0; i--) if (p[i] == ch) return &p[i]; 25 | return NULL; 26 | } -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/usb/status.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/usb/status.h 3 | * @brief USB status codes 4 | * 5 | * @todo Why does this need its own header? 6 | * 7 | * 8 | * @copyright 9 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 10 | * It is released under the terms of the BSD 3-clause license. 11 | * Please see the LICENSE file in the main repository for more details. 12 | * 13 | * Copyright (C) 2024 Samuel Stuart 14 | */ 15 | 16 | #ifndef DRIVERS_USB_STATUS_H 17 | #define DRIVERS_USB_STATUS_H 18 | 19 | /**** TYPES ****/ 20 | 21 | /** 22 | * @brief Response codes 23 | * 24 | * This is an enum so you know which devices return a different status code. 25 | */ 26 | typedef enum USB_STATUS { 27 | USB_SUCCESS = 0, 28 | USB_FAILURE = 1, 29 | } USB_STATUS; 30 | 31 | #endif -------------------------------------------------------------------------------- /libkstructures/include/structs/node.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libkstructures/include/structs/node.h 3 | * @brief Node structure 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef STRUCTS_NODE_H 15 | #define STRUCTS_NODE_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** TYPES ****/ 21 | 22 | // Node structure 23 | typedef struct _node { 24 | struct _node *next; // Next node 25 | struct _node *prev; // Previous node 26 | void *value; // Value of this node 27 | void *owner; // Owner of this node 28 | } node_t; 29 | 30 | #endif -------------------------------------------------------------------------------- /hexahedron/klib/string/strcat.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strcat.c 3 | * @brief strcat 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | char *strcat(char *dst, const char *src) { 17 | size_t s_len = strlen(src); 18 | *(((unsigned char*)memcpy(dst + strlen(dst), src, s_len)) + s_len) = 0; 19 | return dst; 20 | } 21 | 22 | char *strncat (char *dst, const char *src, size_t n) { 23 | size_t s_len = strlen(src); 24 | if (s_len > n) s_len = n; 25 | *(((unsigned char*)memcpy(dst + strlen(dst), src, s_len)) + s_len) = 0; 26 | return dst; 27 | } -------------------------------------------------------------------------------- /userspace/celestial/event.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/celestial/event.h 3 | * @brief Event system 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _CELESTIAL_WM_EVENT_H 15 | #define _CELESTIAL_WM_EVENT_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include "window.h" 21 | 22 | /**** FUNCTIONS ****/ 23 | 24 | /** 25 | * @brief Send an event to a specific window 26 | * @param win The window to send the event to 27 | * @param event The event type to send 28 | * @returns 0 on success 29 | */ 30 | int event_send(wm_window_t *win, void *event); 31 | 32 | #endif -------------------------------------------------------------------------------- /userspace/miniutils/touch.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/touch.c 3 | * @brief touch 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | if (argc < 2) { 22 | printf("usage: touch \n"); 23 | return 1; 24 | } 25 | 26 | long f = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644); 27 | 28 | if (f < 0) { 29 | printf("touch: %s: %s\n", argv[1], strerror(errno)); 30 | return 1; 31 | } 32 | 33 | close(f); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /hexahedron/klib/time/time.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/time/time.c 3 | * @brief time 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | int gettimeofday(struct timeval *tp, void *tzp) { return clock_gettimeofday(tp, tzp); } 18 | int settimeofday(struct timeval *tp, void *tzp) { return clock_settimeofday(tp, tzp); } 19 | 20 | time_t time(time_t *tloc) { 21 | struct timeval tv; 22 | gettimeofday(&tv, NULL); 23 | if (tloc) *tloc = tv.tv_sec; 24 | return tv.tv_sec; 25 | } 26 | 27 | unsigned long long now() { return (uint64_t)time(NULL); } -------------------------------------------------------------------------------- /hexahedron/include/kernel/kernel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/kernel.h 3 | * @brief Main kernel header file 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_KERNEL_H 15 | #define KERNEL_KERNEL_H 16 | 17 | 18 | /**** VARIABLES ****/ 19 | 20 | /* Set when the kernel is beginning to shutdown */ 21 | extern int kernel_shutdown; 22 | 23 | /**** FUNCTIONS ****/ 24 | 25 | /** 26 | * @brief Main kernel function - start of generic routines 27 | */ 28 | void kmain(); 29 | 30 | /** 31 | * @brief Kernel prepare for new power state 32 | */ 33 | void kernel_prepareForPowerState(int state); 34 | 35 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/version.h 3 | * @brief Ethereal version API (/etc/ethereal-version) 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _VERSION_H 15 | #define _VERSION_H 16 | 17 | 18 | /**** TYPES ****/ 19 | 20 | typedef struct ethereal_version { 21 | char *name; 22 | char *codename; 23 | int version_major; 24 | int version_minor; 25 | int version_lower; 26 | } ethereal_version_t; 27 | 28 | /**** FUNCTIONS ****/ 29 | 30 | /** 31 | * @brief Retrieve Ethereal version 32 | * @returns NULL on failure 33 | */ 34 | const ethereal_version_t *ethereal_getVersion(); 35 | 36 | #endif -------------------------------------------------------------------------------- /drivers/example/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drivers/example/main.c 3 | * @brief Example driver for Hexahedron 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | int driver_init(int argc, char **argv) { 20 | dprintf(DEBUG, "Example driver loaded!\n"); 21 | 22 | return 0; 23 | } 24 | 25 | int driver_deinit() { 26 | return 0; 27 | } 28 | 29 | struct driver_metadata driver_metadata = { 30 | .name = "Example Driver", 31 | .author = "Samuel Stuart", 32 | .init = driver_init, 33 | .deinit = driver_deinit 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /hexahedron/klib/string/strchr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strchr.c 3 | * @brief strchr 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | /* mlibc does not have definition */ 17 | extern void *memchrr(const void *s, int ch, size_t n); 18 | 19 | char *strchr(const char *s, int c) { 20 | return memchr(s, c, strlen(s)); 21 | } 22 | 23 | char *strrchr(const char *s, int c) { 24 | return memchrr(s, c, strlen(s)); 25 | } 26 | 27 | char *strchrnul(const char *s, int c) { 28 | size_t l = strlen(s); 29 | char *p = memchr(s, c, l); 30 | if (!p) return (char*)s + l; 31 | return p; 32 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/strcpy.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strcpy.c 3 | * @brief strcpy and strncpy 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | 17 | char *strcpy(char *dst, const char *src) { 18 | size_t l = strlen(src); 19 | char *p = memcpy(dst, src, l); 20 | *(p + l) = 0; 21 | return p; 22 | } 23 | 24 | char *strncpy(char *dst, const char *src, size_t dsize) { 25 | size_t src_len = strlen(src); 26 | size_t len = (src_len > dsize) ? dsize : src_len; 27 | size_t pad_amnt = (src_len > dsize) ? 0 : dsize-src_len; 28 | return memset(memcpy(dst, src, len)+len, 0, pad_amnt); 29 | } 30 | -------------------------------------------------------------------------------- /hexahedron/klib/string/strcmp.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strcmp.c 3 | * @brief strcmp and strncmp 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | int strcmp(const char *s1, const char *s2) { 18 | while (*s1 && *s2) { 19 | if (*s1 != *s2) break; 20 | s1++; s2++; 21 | } 22 | 23 | return *s1 - *s2; 24 | } 25 | 26 | int strncmp(const char *s1, const char *s2, size_t n) { 27 | while (n && *s1 && (*s1 == *s2)) { 28 | s1++; 29 | s2++; 30 | n--; 31 | } 32 | 33 | if (n == 0) { 34 | return 0; 35 | } 36 | 37 | return *s1 - *s2; 38 | } -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/grubvid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/grubvid.h 3 | * @brief GRUB video driver 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_GRUBVID_H 15 | #define DRIVERS_GRUBVID_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** FUNCTIONS ****/ 22 | 23 | /** 24 | * @brief Initialize the GRUB video driver 25 | * @param parameters Generic parameters containing the LFB driver. 26 | * @returns NULL on failure to initialize, else a video driver structure 27 | */ 28 | video_driver_t *grubvid_initialize(generic_parameters_t *parameters); 29 | 30 | 31 | 32 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/usb/hid/mouse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/usb/hid/mouse.h 3 | * @brief Generic HID mouse driver 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_USB_HID_MOUSE_H 15 | #define DRIVERS_USB_HID_MOUSE_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** DEFINITIONS ****/ 21 | 22 | #define HID_ 23 | 24 | /**** TYPES ****/ 25 | 26 | typedef struct USBHidMouseState { 27 | uint32_t rel_x; 28 | uint32_t rel_y; 29 | uint8_t buttons; 30 | } USBHidMouseState_t; 31 | 32 | /**** FUNCTIONS ****/ 33 | 34 | /** 35 | * @brief Initialize generic HID mouse driver 36 | */ 37 | void usb_mouseInit(); 38 | 39 | #endif -------------------------------------------------------------------------------- /userspace/celestial/event.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/celestial/event.c 3 | * @brief Event logic 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include "celestial.h" 15 | 16 | /** 17 | * @brief Send an event to a specific window 18 | * @param win The window to send the event to 19 | * @param event The event type to send 20 | * @returns 0 on success 21 | */ 22 | int event_send(wm_window_t *win, void *event) { 23 | // Check to make sure the event is subscribed to 24 | celestial_event_header_t *hdr = (celestial_event_header_t*)event; 25 | CELESTIAL_DEBUG("event: Send event %d\n", hdr->type); 26 | if (!((win->events & hdr->type) == hdr->type)) return 0; // Not subscribed 27 | return socket_send(win->sock, hdr->size, event); 28 | } 29 | -------------------------------------------------------------------------------- /userspace/miniutils/Makefile: -------------------------------------------------------------------------------- 1 | # Userspace Makefile 2 | # NOTE: YOU CAN MODIFY THIS IF YOU WANT TO ADD ADDITIONAL TARGETS - SEE BOTTOM OF FILE 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_userspace_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OBJ_DIR = $(OBJ_OUTPUT_DIRECTORY)/userspace/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OUTPUTS = $(patsubst %.c, $(OBJ_DIR)/%, $(C_SRCS)) 18 | 19 | # Additional libc 20 | LDFLAGS += -lversion -lethereal -lstructures 21 | 22 | MAKE_OUTPUT: 23 | -@mkdir -p $(OBJ_DIR) 24 | -@mkdir -p $(INITRD)/bin/ 25 | 26 | $(OBJ_DIR)/%: %.c Makefile 27 | $(CC) $(CFLAGS) -c $< -o $@.o 28 | $(CC) $@.o $(LDFLAGS) -o $@ 29 | cp -r $@ $(DESTDIR)$(BINARY_DIR) 30 | cp -r $@ $(INITRD)/bin 31 | 32 | install: MAKE_OUTPUT $(C_OUTPUTS) 33 | 34 | clean: 35 | -rm -rf $(OBJ_DIR) 36 | 37 | -------------------------------------------------------------------------------- /userspace/lib/ethereal/shared.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/ethereal/shared.c 3 | * @brief Ethereal shared memory API 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | DEFINE_SYSCALL2(shared_new, SYS_SHARED_NEW, size_t, int); 19 | DEFINE_SYSCALL1(shared_key, SYS_SHARED_KEY, int); 20 | DEFINE_SYSCALL1(shared_open, SYS_SHARED_OPEN, key_t); 21 | 22 | int shared_new(size_t size, int flags) { 23 | __sets_errno(__syscall_shared_new(size, flags)); 24 | } 25 | 26 | key_t shared_key(int fd) { 27 | __sets_errno(__syscall_shared_key(fd)); 28 | } 29 | 30 | int shared_open(key_t key) { 31 | __sets_errno(__syscall_shared_open(key)); 32 | } -------------------------------------------------------------------------------- /userspace/miniutils/readlink.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/readlink.c 3 | * @brief readlink 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | int main(int argc, char *argv[]) { 19 | if (argc < 2) { 20 | fprintf(stderr, "readlink: missing operand\n"); 21 | fprintf(stderr, "Try \'readlink --help\' for more information.\n"); 22 | return 1; 23 | } 24 | 25 | // TODO: flush this out 26 | char *p = argv[1]; 27 | 28 | char buffer[256]; 29 | ssize_t bytesread = readlink(p, buffer, 255); 30 | 31 | if (bytesread < 0) { 32 | return 1; 33 | } 34 | 35 | buffer[bytesread] = 0; 36 | 37 | printf("%s\n", buffer); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /.github/workflows/x86_64.yml: -------------------------------------------------------------------------------- 1 | on: [push, workflow_dispatch] 2 | name: x86_64 ISO image 3 | jobs: 4 | build-iso: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Clone reduceOS repository 8 | uses: actions/checkout@v2 9 | - name: Download Docker image 10 | run: docker pull techdude17/ethereal-docker:x86_64 11 | - name: Build OS 12 | run: docker run -v ${GITHUB_WORKSPACE}:/opt/Ethereal -t techdude17/ethereal-docker:x86_64 /opt/build/build.sh 13 | - name: Upload artifact 14 | uses: actions/upload-artifact@v4 15 | with: 16 | name: iso 17 | path: build-output/hexahedron.iso 18 | - name: Upload kernel 19 | uses: actions/upload-artifact@v4 20 | with: 21 | name: kernel 22 | path: build-output/sysroot/boot/hexahedron-kernel.elf 23 | - name: Upload initrd 24 | uses: actions/upload-artifact@v4 25 | with: 26 | name: initrd 27 | path: build-output/sysroot/boot/initrd.tar.img 28 | -------------------------------------------------------------------------------- /hexahedron/drivers/README.txt: -------------------------------------------------------------------------------- 1 | -=-=-=-=-= HEXAHEDRON INTERNAL DRIVER STRUCTURE =-=-=-=-=- 2 | 3 | Hexahedron follows a unique internal driver structure. There are two main types of drivers: 4 | - generic drivers 5 | - machine-specific drivers 6 | 7 | == GENERIC DRIVERS == 8 | 9 | Generic drivers provide a management system for common parts of hardware. 10 | For example, a generic driver such as the "drive.c" driver will take into place VFS mounting of the drive and handling errors. 11 | 12 | == MACHINE-SPECIFIC DRIVERS == 13 | 14 | It's another way of saying architecture-specific, however since x86 is largely compatible with 15 | drivers, I didn't want that. 16 | 17 | These drivers are not prefixed into one folder. They have their machine-type as a folder (e.g. x86/ drivers are x86 and x86_64-specific) 18 | 19 | These drivers are still being worked out how they need to be read and initialized. 20 | Another layer of abstraction is a possibility, but I was thinking some sort of init method list in the config, if that wasn't too clunky. 21 | 22 | -------------------------------------------------------------------------------- /userspace/miniutils/dns-resolve.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/dns-resolve.c 3 | * @brief dns-resolve 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | int main(int argc, char *argv[]) { 19 | if (argc < 2) { 20 | printf("usage: dns-resolve \n"); 21 | return 1; 22 | } 23 | 24 | struct hostent *ent = gethostbyname(argv[1]); 25 | if (!ent) { 26 | printf("dns-resolve: %s: not found by DNS\n", argv[1]); 27 | return 1; 28 | } 29 | 30 | int i = 0; 31 | while (ent->h_addr_list[i] != NULL) { 32 | struct in_addr *in = (struct in_addr*)ent->h_addr_list[i]; 33 | printf("%s\n", inet_ntoa(*in)); 34 | i++; 35 | } 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /hexahedron/include/kernel/gfx/gfx.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/gfx/gfx.h 3 | * @brief Minimal graphics routines 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_GFX_GFX_H 15 | #define KERNEL_GFX_GFX_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** FUNCTIONS ****/ 22 | 23 | /** 24 | * @brief Draw a line 25 | * @param x1 First X 26 | * @param y1 First Y 27 | * @param x2 Second X 28 | * @param y2 Second Y 29 | * @param color The color of the line 30 | */ 31 | void gfx_drawLine(int x1, int y1, int x2, int y2, color_t color); 32 | 33 | /** 34 | * @brief Draw the Hexahedron logo 35 | * @param color The logo color 36 | */ 37 | void gfx_drawLogo(color_t color); 38 | 39 | #endif -------------------------------------------------------------------------------- /hexahedron/klib/string/ctype.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/ctype.c 3 | * @brief ctypes 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | int tolower(int ch) { return (isupper(ch)) ? (ch + 0x20) : ch; } 17 | int toupper(int ch) { return (islower(ch)) ? (ch - 0x20) : ch; } 18 | int islower(int ch) { return ((ch >= 'a') && (ch <= 'z')); } 19 | int isupper(int ch) { return ((ch >= 'A') && (ch <= 'Z')); } 20 | int isdigit(int ch) { return ((ch >= '0') && (ch <= '9')); } 21 | int isxdigit(int ch) { return isdigit(ch) || ((ch >= 'a') && (ch <= 'f')) || ((ch >= 'A') && (ch <= 'F')); } 22 | int isprint(int ch) { return ((ch >= 0x20) && (ch <= 0x7F)); } 23 | int isspace(int ch) { return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\v'); } -------------------------------------------------------------------------------- /userspace/desktop/widget.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/desktop/widget.h 3 | * @brief Desktop widget 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _DESKTOP_WIDGET_H 15 | #define _DESKTOP_WIDGET_H 16 | 17 | /**** FUNCTIONS ****/ 18 | 19 | /** 20 | * @brief Load default widgets 21 | */ 22 | void widgets_load(); 23 | 24 | /** 25 | * @brief Update widgets 26 | */ 27 | void widgets_update(); 28 | 29 | /** 30 | * @brief Handle mouse movement 31 | */ 32 | void widget_mouseMovement(unsigned x, unsigned y); 33 | 34 | /** 35 | * @brief Handle mouse exit 36 | */ 37 | void widget_mouseExit(); 38 | 39 | /** 40 | * @brief Handle mouse click 41 | */ 42 | void widget_mouseClick(unsigned x, unsigned y); 43 | 44 | /** 45 | * @brief Handle mouse release 46 | */ 47 | void widget_mouseRelease(unsigned x, unsigned y); 48 | 49 | #endif -------------------------------------------------------------------------------- /userspace/celestial/mouse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/celestial/mouse.h 3 | * @brief Mouse 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _CELESTIAL_WM_MOUSE_H 15 | #define _CELESTIAL_WM_MOUSE_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** DEFINITIONS ****/ 21 | 22 | #define CELESTIAL_DEFAULT_MOUSE_CURSOR "/usr/share/cursor.bmp" 23 | 24 | /**** FUNCTIONS ****/ 25 | 26 | /** 27 | * @brief Initialize the mouse system 28 | * @returns 0 on success 29 | */ 30 | int mouse_init(); 31 | 32 | /** 33 | * @brief Update the mouse (non-blocking) 34 | */ 35 | int mouse_update(); 36 | 37 | /** 38 | * @brief Render the mouse 39 | */ 40 | void mouse_render(); 41 | 42 | /** 43 | * @brief Change mouse sprite 44 | * @param target The target sprite to change to 45 | */ 46 | void mouse_change(int target); 47 | 48 | #endif -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "gdb", 6 | "request": "attach", 7 | "name": "Attach to gdbserver", 8 | "executable": "./build-output/sysroot/boot/hexahedron-kernel-symbols.sym", 9 | "target": ":1234", 10 | "remote": true, 11 | "cwd": "${workspaceRoot}", 12 | "valuesFormatting": "parseText", 13 | 14 | "preLaunchTask": "Build and Run All" 15 | }, 16 | 17 | { 18 | "name": "C/C++ Runner: Debug Session", 19 | "type": "cppdbg", 20 | "request": "launch", 21 | "args": [], 22 | "stopAtEntry": false, 23 | "externalConsole": false, 24 | "cwd": "/home/samuel/Desktop/reduceOS", 25 | "program": "/home/samuel/Desktop/reduceOS/build/Debug/outDebug", 26 | "MIMode": "gdb", 27 | "miDebuggerPath": "gdb", 28 | "setupCommands": [ 29 | { 30 | "description": "Enable pretty-printing for gdb", 31 | "text": "-enable-pretty-printing", 32 | "ignoreFailures": true 33 | } 34 | ] 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /libkstructures/Makefile.linux: -------------------------------------------------------------------------------- 1 | OUT_OBJ_LIBC = obj 2 | 3 | SOURCE_DIRECTORIES_LIBC = list tree json hashmap ini gzip 4 | OUTPUT_DIRECTORIES_LIBC = $(addprefix $(OUT_OBJ_LIBC)/,$(SOURCE_DIRECTORIES_LIBC)) 5 | LIBC_C_SOURCES = $(shell find $(SOURCE_DIRECTORIES_LIBC) -maxdepth 1 -name "*.c") 6 | LIBC_C_OBJECTS = $(patsubst %.c, $(OUT_OBJ_LIBC)/%.o, $(LIBC_C_SOURCES)) 7 | 8 | PREFIX ?= /usr/ 9 | 10 | CFLAGS += -Iinclude/ 11 | 12 | .PHONY: all 13 | all: mkdirs $(OBJ_OUTPUT_DIRECTORY)/libethereal_structures.a 14 | 15 | mkdirs: 16 | -mkdir $(OUT_OBJ_LIBC) 17 | -mkdir $(OUTPUT_DIRECTORIES_LIBC) 18 | 19 | $(OUT_OBJ_LIBC)/%.o: %.c Makefile 20 | $(CC) $(CFLAGS) -D__LIBCSTRUCTURES -c $< -o $@ 21 | 22 | 23 | $(OBJ_OUTPUT_DIRECTORY)/libethereal_structures.a: 24 | $(CC) -shared $(LIBC_C_OBJECTS) -o $(OUT_OBJ_LIBC)/libethereal_structures.so 25 | $(AR) rcs $(OUT_OBJ_LIBC)/libethereal_structures.a $(LIBC_C_OBJECTS) 26 | 27 | install: 28 | cp -r include/structs $(DESTDIR)$(PREFIX)include/ 29 | cp $(OUT_OBJ_LIBC)/libethereal_structures.a $(DESTDIR)$(PREFIX)lib/ 30 | cp $(OUT_OBJ_LIBC)/libethereal_structures.so $(DESTDIR)$(PREFIX)lib/ 31 | -------------------------------------------------------------------------------- /external/LICENSE.Astral: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Mathewnd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /hexahedron/include/kernel/misc/args.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/misc/args.h 3 | * @brief Kernel arguments handler 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_MISC_ARGS_H 15 | #define KERNEL_MISC_ARGS_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** FUNCTIONS ****/ 21 | 22 | /** 23 | * @brief Initialize the argument parser 24 | * @param args A string pointing to the arguments 25 | */ 26 | void kargs_init(char *args); 27 | 28 | /** 29 | * @brief Get the argument value for a key 30 | * @param arg The argument to get the value for 31 | * @returns NULL on not found or the value 32 | */ 33 | char *kargs_get(char *arg); 34 | 35 | /** 36 | * @brief Returns whether the arguments list has an argument 37 | * @param arg The argument to check for 38 | */ 39 | int kargs_has(char *arg); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /userspace/lib/Makefile: -------------------------------------------------------------------------------- 1 | # Userspace libraries Makefile for Hexahedron 2 | include ./make.config 3 | 4 | # List of libraries to compile 5 | LIBS = ethereal graphics celestial keyboard ansi pthread widget version 6 | 7 | LIBS_TARGETS_INSTALL := $(patsubst %, install-%, $(LIBS)) 8 | LIBS_TARGETS_CLEAN := $(patsubst %, clean-%, $(LIBS)) 9 | 10 | # Target disabled 11 | all: 12 | @echo "=== TARGET DISABLED ===" 13 | @echo "Please use make install" 14 | 15 | 16 | install-%: 17 | $(MAKE) -C $(subst $e-,/,$(patsubst install-%, %, $@)) install 18 | 19 | clean-%: 20 | $(MAKE) -C $(subst $e-,/,$(patsubst clean-%, %, $@)) clean 21 | 22 | # Create build directories 23 | MAKE_DIRS: 24 | -@mkdir -pv $(DESTDIR)$(BINARY_DIR) 25 | -@mkdir -pv $(OBJ_OUTPUT_DIRECTORY)/userspace/lib/ 26 | 27 | # Cosmetic 28 | PRINT_HEADER: 29 | @echo 30 | @echo 31 | @echo "[ Building userspace libraries, please wait... ]" 32 | @echo 33 | @echo 34 | 35 | install: PRINT_HEADER MAKE_DIRS $(LIBS_TARGETS_INSTALL) 36 | clean: $(LIBS_TARGETS_CLEAN) 37 | 38 | install-headers: 39 | @-mkdir -pv $(DESTDIR)$(INCLUDE_DIRECTORY) 40 | @-cp -R --preserve=timestamps include/. $(DESTDIR)$(INCLUDE_DIRECTORY)/ -------------------------------------------------------------------------------- /hexahedron/fs/random.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/fs/random.c 3 | * @brief /device/random 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | 21 | static ssize_t random_read(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { 22 | size_t s = 0; 23 | 24 | while (s < size) { 25 | // Read from buffer 26 | buffer[s] = rand() % 0xFF; 27 | s++; 28 | } 29 | 30 | return size; 31 | } 32 | 33 | 34 | /** 35 | * @brief Mount random device 36 | */ 37 | int random_mount() { 38 | fs_node_t *n = fs_node(); 39 | strcpy(n->name, "random"); 40 | n->mask = 0666; 41 | n->uid = n->gid = 0; 42 | n->flags = VFS_CHARDEVICE; 43 | n->read = random_read; 44 | 45 | vfs_mount(n, "/device/random"); 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Build All", 6 | "type": "shell", 7 | "command": "", 8 | "args": [ 9 | "make", 10 | "--directory=${workspaceFolder}", 11 | "all" 12 | ], 13 | "group": { 14 | "kind": "build", 15 | "isDefault": true 16 | }, 17 | "presentation": { 18 | "reveal": "always", 19 | }, 20 | "problemMatcher": "$gcc" 21 | }, 22 | { 23 | "label": "Build and Run All", 24 | "type": "shell", 25 | "dependsOn": [ 26 | "Build All" 27 | ], 28 | "command": "", 29 | "args": [ 30 | "qemu-system-x86_64", 31 | "-cdrom", 32 | "build-output/hexahedron.iso", 33 | "-serial", 34 | "stdio", 35 | "-s" 36 | ], 37 | "isBackground": true, 38 | "problemMatcher": [ 39 | { 40 | "pattern": [ 41 | { 42 | "regexp": ".", 43 | "file": 1, 44 | "line": 1, 45 | "column": 1, 46 | "message": 1 47 | } 48 | ], 49 | "background": { 50 | "activeOnStart": true, 51 | "beginsPattern": { "regexp": "." }, 52 | "endsPattern": { "regexp": "^.*$" } 53 | } 54 | } 55 | ] 56 | } 57 | ] 58 | } -------------------------------------------------------------------------------- /libc/Makefile: -------------------------------------------------------------------------------- 1 | # mlibc Makefile integration 2 | 3 | include ./make.config 4 | 5 | OBJ_DIR = $(OBJ_OUTPUT_DIRECTORY)/mlibc 6 | OBJ_DIR2 = $(OBJ_OUTPUT_DIRECTORY)/mlibc_headers 7 | LIBC_DIR=$(shell pwd) 8 | MLIBC_DIR = $(LIBC_DIR)/mlibc 9 | 10 | $(info $(MLIBC_DIR)) 11 | 12 | make_dirs: 13 | -mkdir $(OBJ_DIR) 14 | -mkdir $(OBJ_DIR2) 15 | 16 | install-headers: make_dirs 17 | # Install mlibc headers 18 | if ! [ -d mlibc ]; then \ 19 | echo -e "\n\nYou forgot to run git submodule init and git submodule update\n\n"; \ 20 | exit 1; \ 21 | fi 22 | 23 | cd $(OBJ_DIR2); \ 24 | meson setup --cross-file=$(LIBC_DIR)/ethereal_cross.txt -Dheaders_only=true -Dprefix=$(PREFIX) -Ddefault_library=both -Dlinux_kernel_headers=$(DESTDIR)/usr/include/ $(MLIBC_DIR); \ 25 | ninja install; \ 26 | cd $(LIBC_DIR); 27 | 28 | install: 29 | # Install mlibc 30 | set -e; \ 31 | cd $(OBJ_DIR); \ 32 | LDFLAGS="" CFLAGS="" meson setup --cross-file=$(LIBC_DIR)/ethereal_cross.txt -Dheaders_only=false -Dprefix=$(PREFIX) -Ddefault_library=both -Dlinux_kernel_headers=$(DESTDIR)/usr/include/ --reconfigure $(MLIBC_DIR); \ 33 | ninja install; \ 34 | cd $(LIBC_DIR) 35 | 36 | clean: 37 | -rm -rf $(OBJ_DIR) 38 | -rm -rf linux-6.16 -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/widget/event.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/widget/event.h 3 | * @brief Widget event system 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _WIDGET_EVENT_H 15 | #define _WIDGET_EVENT_H 16 | 17 | /**** INCLUDES ****/ 18 | 19 | #include 20 | #include 21 | 22 | /**** TYPES ****/ 23 | 24 | struct widget; 25 | 26 | typedef struct widget_event_state { 27 | struct widget *frame; // Parent frame of this event state 28 | struct widget *held_widget; // The currently held widget 29 | struct widget *last_clicked; // Last clicked widget 30 | keyboard_t *keyboard; // Keyboard 31 | } widget_event_state_t; 32 | 33 | /**** FUNCTIONS ****/ 34 | 35 | /** 36 | * @brief Initialize events on a frame 37 | * @param frame The frame to init events on 38 | */ 39 | void widget_initEvents(struct widget *frame); 40 | 41 | #endif -------------------------------------------------------------------------------- /drivers/storage/ide/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drivers/ide/main.c 3 | * @brief Main driver logic of the IDE driver 4 | * 5 | * Just a forwarder to @c ata.c 6 | * 7 | * @copyright 8 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 9 | * It is released under the terms of the BSD 3-clause license. 10 | * Please see the LICENSE file in the main repository for more details. 11 | * 12 | * Copyright (C) 2024 Samuel Stuart 13 | */ 14 | 15 | #include "ata.h" 16 | #include 17 | 18 | int ide_initialize(int argc, char **argv) { 19 | // Initialize and load the main sections of the IDE ATA driver 20 | int status = ata_initialize(); 21 | 22 | if (!status) { 23 | return DRIVER_STATUS_SUCCESS; 24 | } else if (status == -ENODEV) { 25 | return DRIVER_STATUS_NO_DEVICE; 26 | } else if (status == -ENOTSUP) { 27 | return DRIVER_STATUS_UNSUPPORTED; 28 | } 29 | 30 | return DRIVER_STATUS_ERROR; 31 | } 32 | 33 | int ide_deinit() { 34 | return 0; 35 | } 36 | 37 | struct driver_metadata driver_metadata = { 38 | .name = "IDE ATA/ATAPI Driver", 39 | .author = "Samuel Stuart", 40 | .init = ide_initialize, 41 | .deinit = ide_deinit 42 | }; -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/nicdev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/nicdev.h 3 | * @brief NIC device ioctls 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_NICDEV_H 15 | #define DRIVERS_NICDEV_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** TYPES ****/ 22 | 23 | typedef struct nic_info { 24 | char nic_name[256]; // NIC name (hehe, "nickname") 25 | uint8_t nic_mac[6]; // NIC MAC address 26 | size_t nic_mtu; // NIC MTU 27 | in_addr_t nic_ipv4_addr; // NIC IPv4 address 28 | in_addr_t nic_ipv4_subnet; // NIC IPv4 subnet 29 | in_addr_t nic_ipv4_gateway; // NIC IPv4 gateway 30 | } nic_info_t; 31 | 32 | /**** DEFINITIONS ****/ 33 | #define IO_NIC_GET_INFO 0x4001 // Get NIC information 34 | #define IO_NIC_SET_INFO 0x4002 // Set NIC information 35 | 36 | #endif -------------------------------------------------------------------------------- /userspace/lib/graphics/blend.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/graphics/blend.c 3 | * @brief Alpha blend support 4 | * 5 | * 6 | * @copyright 7 | * This file is part of ToaruOS and is released under the terms 8 | * of the NCSA / University of Illinois License - see LICENSE.md 9 | * Copyright (C) 2011-2021 K. Lange 10 | */ 11 | 12 | #include 13 | 14 | /** 15 | * @brief Alpha blend two colors together 16 | * @param top The topmost color 17 | * @param bottom The bottom color 18 | */ 19 | inline gfx_color_t gfx_alphaBlend(gfx_color_t top, gfx_color_t bottom) { 20 | // TODO: Rewrite without stolen code... 21 | if (GFX_RGB_A(bottom) == 0) return top; 22 | if (GFX_RGB_A(top) == 255) return top; 23 | if (GFX_RGB_A(top) == 0) return bottom; 24 | uint8_t a = GFX_RGB_A(top); 25 | uint16_t t = 0xFF ^ a; 26 | uint8_t d_r = GFX_RGB_R(top) + (((uint32_t)(GFX_RGB_R(bottom) * t + 0x80) * 0x101) >> 16UL); 27 | uint8_t d_g = GFX_RGB_G(top) + (((uint32_t)(GFX_RGB_G(bottom) * t + 0x80) * 0x101) >> 16UL); 28 | uint8_t d_b = GFX_RGB_B(top) + (((uint32_t)(GFX_RGB_B(bottom) * t + 0x80) * 0x101) >> 16UL); 29 | uint8_t d_a = GFX_RGB_A(top) + (((uint32_t)(GFX_RGB_A(bottom) * t + 0x80) * 0x101) >> 16UL); 30 | return GFX_RGBA(d_r, d_g, d_b, d_a); 31 | } -------------------------------------------------------------------------------- /userspace/miniutils/date.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) { 9 | time_t t; 10 | char buffer[256]; 11 | 12 | // Get the current time 13 | t = time(NULL); 14 | if (t == -1) { 15 | perror("time"); 16 | return EXIT_FAILURE; 17 | } 18 | 19 | // Convert to local time 20 | struct tm *local_tm_info = localtime(&t); 21 | if (local_tm_info == NULL) { 22 | perror("localtime"); 23 | return EXIT_FAILURE; 24 | } 25 | 26 | // Check if a format is provided 27 | if (argc > 1) { 28 | if (strftime(buffer, sizeof(buffer), argv[1], local_tm_info) == 0) { 29 | printf("date: strftime: %s\n", strerror(errno)); 30 | return EXIT_FAILURE; 31 | } 32 | } else { 33 | // Default format 34 | if (strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Z %Y", local_tm_info) == 0) { 35 | printf("date: strftime: %s\n", strerror(errno)); 36 | return EXIT_FAILURE; 37 | } 38 | } 39 | 40 | // Print the formatted date 41 | printf("%s\n", buffer); 42 | return EXIT_SUCCESS; 43 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/strtok.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strtok.c 3 | * @brief strtok 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | 16 | #define HAS_DELIM(ch) (!!memchr(delim, ch, delim_len)) 17 | 18 | char *strtok_r(char *str, const char *delim, char **saveptr) { 19 | if (!str) str = *saveptr; 20 | if (!(*str)) return NULL; 21 | size_t delim_len = strlen(delim); 22 | 23 | // Skip leading delimiters 24 | while (*str && HAS_DELIM(*str)) str++; 25 | if (!(*str)) return NULL; 26 | 27 | // Find the next delimiter 28 | char *start = str; 29 | while (*str && !HAS_DELIM(*str)) str++; 30 | 31 | if (*str) { 32 | *str = '\0'; // Null-terminate the token 33 | str++; 34 | } 35 | *saveptr = str; 36 | 37 | return start; 38 | } 39 | 40 | static char *__strtok_save = NULL; 41 | 42 | char *strtok(char *str, const char *delim) { 43 | return strtok_r(str, delim, &__strtok_save); 44 | } -------------------------------------------------------------------------------- /userspace/tray/network/network.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/tray/network/network.c 3 | * @brief Network tray icon 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | sprite_t *icon_sprite = NULL; 20 | 21 | int network_init(desktop_tray_widget_t *widget) { 22 | fprintf(stderr, "Network widget coming up\n"); 23 | 24 | icon_sprite = gfx_createSprite(0,0); 25 | gfx_loadSprite(icon_sprite, fopen("/usr/share/icons/24/Ethereal.bmp", "r")); 26 | widget->width = icon_sprite->width + 2; 27 | widget->height = icon_sprite->height; 28 | 29 | return 0; 30 | } 31 | 32 | int network_drawIcon(desktop_tray_widget_t *widget) { 33 | gfx_renderSprite(widget->ctx, icon_sprite, 1, 0); 34 | gfx_render(widget->ctx); 35 | 36 | return 0; 37 | } 38 | 39 | desktop_tray_widget_data_t this_widget = { 40 | .name = "Network Widget", 41 | .init = network_init, 42 | .icon = network_drawIcon, 43 | }; -------------------------------------------------------------------------------- /hexahedron/arch/x86_64/misc.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/arch/x86_64/util.S 3 | * @brief Minor utility code 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | .set CR0_NE, 1 << 5 15 | .set CR0_TS, 1 << 3 16 | .set CR0_EM, 1 << 2 17 | .set CR0_MP, 1 << 1 18 | .set CR4_OSFXSR, 1 << 9 19 | .set CR4_OSXMMEXCPT, 1 << 10 20 | 21 | // Reference for SSE/FPU code: https://wiki.osdev.org/SSE and https://wiki.osdev.org/FPU 22 | // x86_64 requires a minimum level of SSE support so we can ensure it 23 | 24 | .global arch_enable_sse 25 | arch_enable_sse: 26 | // Despite the function name we will begin with FPU init 27 | mov %cr0, %rdx 28 | and $(~(CR0_TS | CR0_EM)), %rdx 29 | mov %rdx, %cr0 30 | fninit 31 | 32 | // Now we can do SSE initialization 33 | mov %cr0, %rax 34 | and $(~(CR0_EM)), %rax 35 | or $(CR0_MP), %rax 36 | mov %rax, %cr0 37 | mov %cr4, %rax 38 | or $(CR4_OSFXSR | CR4_OSXMMEXCPT), %rax 39 | mov %rax, %cr4 40 | 41 | // SSE enabled successfully 42 | ret -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/net/udp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/net/udp.h 3 | * @brief User Datagram Protocol 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_NET_UDP_H 15 | #define DRIVERS_NET_UDP_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** TYPES ****/ 22 | 23 | typedef struct udp_packet { 24 | uint16_t src_port; // Source port 25 | uint16_t dest_port; // Destination port 26 | uint16_t length; // Length 27 | uint16_t checksum; // Checksum 28 | uint8_t data[]; // UDP data 29 | } __attribute__((packed)) udp_packet_t; 30 | 31 | typedef struct udp_sock { 32 | uint16_t port; // Port bound to this socket 33 | } udp_sock_t; 34 | 35 | /**** FUNCTIONS ****/ 36 | 37 | /** 38 | * @brief Handle a UDP packet 39 | */ 40 | int udp_handle(fs_node_t *nic, void *frame, size_t size); 41 | 42 | #endif -------------------------------------------------------------------------------- /userspace/essence/input.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/essence/input.c 3 | * @brief Essence input system 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include "essence.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define CSR_SHOW() { putchar('\030'); fflush(stdout); } 22 | #define CSR_HIDE() { printf("\b"); fflush(stdout); } 23 | #define PUTCHAR_FLUSH(c) { putchar(c); fflush(stdout); } 24 | 25 | 26 | #define DEFAULT_BUFSIZE 128 27 | 28 | /** 29 | * @brief Get a fully processed line of input 30 | */ 31 | char *essence_getInput() { 32 | struct termios tios; 33 | tcgetattr(STDOUT_FILENO, &tios); 34 | tios.c_iflag |= ICRNL; 35 | tcsetattr(STDOUT_FILENO, TCSANOW, &tios); 36 | 37 | size_t bufsz = DEFAULT_BUFSIZE; 38 | char *buffer = malloc(bufsz); 39 | memset(buffer, 0, bufsz); 40 | 41 | // Read from buffer 42 | ssize_t r = 0; 43 | while ((r = read(STDIN_FILENO, buffer, BUFSIZ)) <= 0); 44 | buffer[r-1] = 0; 45 | 46 | return buffer; 47 | } -------------------------------------------------------------------------------- /userspace/essence/commands.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/essence/commands.c 3 | * @brief Basic Essence commands 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include "essence.h" 15 | #include 16 | #include 17 | #include 18 | 19 | extern char **environ; 20 | 21 | int cd(int argc, char *argv[]) { 22 | char *cd_path = getenv("HOME"); 23 | if (argc > 1) cd_path = argv[1]; 24 | if (!cd_path) cd_path = "/"; 25 | 26 | chdir(cd_path); 27 | return 0; 28 | } 29 | 30 | int env(int argc, char *argv[]) { 31 | char **envp = environ; 32 | while (*envp) { 33 | printf("%s\n", *envp); 34 | envp++; 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | int export(int argc, char *argv[]) { 41 | if (argc == 1) return env(argc, argv); 42 | putenv(argv[1]); 43 | return 0; 44 | } 45 | 46 | int exit_cmd(int argc, char *argv[]) { 47 | exit(0); 48 | __builtin_unreachable(); 49 | } 50 | 51 | int unset(int argc, char *argv[]) { 52 | if (argc < 2) return 0; 53 | unsetenv(argv[1]); 54 | return 0; 55 | } -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/widget/button.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/widget/button.h 3 | * @brief Button widget 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _WIDGET_BUTTON_H 15 | #define _WIDGET_BUTTON_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** DEFINITIONS ****/ 21 | 22 | #define BUTTON_DISABLED 0 23 | #define BUTTON_ENABLED 1 24 | 25 | /**** TYPES ****/ 26 | 27 | typedef struct widget_button { 28 | char *text; // Text on the button 29 | gfx_color_t color; // Button color 30 | uint8_t enabled; // Button enabled or disabled 31 | } widget_button_t; 32 | 33 | /**** FUNCTIONS ****/ 34 | 35 | /** 36 | * @brief Create a new button widget 37 | * @param frame The frame to put the button into 38 | * @param text The text of the button 39 | * @param color The primary color of the button 40 | * @param state The state of the button, @c BUTTON_ENABLED 41 | */ 42 | widget_t *button_create(widget_t *frame, char *text, gfx_color_t color, int state); 43 | 44 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/task/futex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/task/futex.h 3 | * @brief Futex implementation 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_TASK_FUTEX_H 15 | #define KERNEL_TASK_FUTEX_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /**** DEFINITIONS ****/ 24 | 25 | /**** TYPES ****/ 26 | 27 | typedef struct futex { 28 | sleep_queue_t *queue; // Sleep queue 29 | 30 | } futex_t; 31 | 32 | /**** FUNCTIONS ****/ 33 | 34 | /** 35 | * @brief Wait on a futex 36 | * @param pointer Pointer to the futex variable 37 | * @param value The vaue to look for 38 | * @param time Time to wait on 39 | */ 40 | int futex_wait(int *pointer, int val, const struct timespec *time); 41 | 42 | /** 43 | * @brief Wake up a futex 44 | * @param pointer Pointer to the futex 45 | */ 46 | int futex_wakeup(int *pointer); 47 | 48 | /** 49 | * @brief Initialize futexes 50 | */ 51 | void futex_init(); 52 | 53 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/sound/audio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/sound/audio.h 3 | * @brief Audio types 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_SOUND_AUDIO_H 15 | #define DRIVERS_SOUND_AUDIO_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** DEFINITIONS ****/ 21 | 22 | /* Encoding of audio */ 23 | #define SOUND_FORMAT_S16PCM 1 // Signed 16-bit PCM 24 | #define SOUND_FORMAT_S24PCM 2 // Signed 24-bit PCM 25 | #define SOUND_FORMAT_S32PCM 3 // Signed 32-bit PCM 26 | #define SOUND_FORMAT_U8PCM 4 // Unsigned 8-bit PCM 27 | 28 | /* Hz */ 29 | #define SOUND_RATE_8000HZ 8000 30 | #define SOUND_RATE_11025HZ 11025 31 | #define SOUND_RATE_16000HZ 16000 32 | #define SOUND_RATE_22050HZ 22050 33 | #define SOUND_RATE_32000HZ 32000 34 | #define SOUND_RATE_44100HZ 44100 35 | #define SOUND_RATE_48000HZ 48000 36 | #define SOUND_RATE_88200HZ 88200 37 | #define SOUND_RATE_96000HZ 96000 38 | 39 | #endif -------------------------------------------------------------------------------- /drivers/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/fs/ext2/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/fs/fat/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/misc/ps2/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/usb/ehci/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/usb/uhci/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/usb/xhci/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /hexahedron/include/kernel/gfx/video.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/gfx/video.h 3 | * @brief Video interface 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_GFX_VIDEO_H 15 | #define KERNEL_GFX_VIDEO_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** DEFINITIONS ****/ 21 | 22 | /* ioctl() calls */ 23 | #define IO_VIDEO_GET_INFO 0x3000 // Get video mode information 24 | #define IO_VIDEO_SET_INFO 0x3001 // Set video mode information 25 | #define IO_VIDEO_GET_FRAMEBUFFER 0x3002 // Get framebuffer call 26 | #define IO_VIDEO_FLUSH_FRAMEBUFFER 0x3004 // Flush the framebuffer, as the kernel implements double buffering 27 | 28 | /**** TYPES ****/ 29 | 30 | /** 31 | * @brief Returned video information structure 32 | */ 33 | typedef struct video_info { 34 | uintptr_t screen_width; // Width 35 | uintptr_t screen_height; // Height 36 | uintptr_t screen_pitch; // Pitch 37 | uintptr_t screen_bpp; // BPP 38 | int graphics; // Old 39 | } video_info_t; 40 | 41 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/misc/ksym.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/misc/ksym.h 3 | * @brief Kernel symbol loader 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_MISC_KSYM_H 15 | #define KERNEL_MISC_KSYM_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** TYPES ****/ 22 | 23 | 24 | /**** FUNCTIONS ****/ 25 | 26 | /** 27 | * @brief Initialize the kernel symbol map 28 | * @param file The symbol map file 29 | * @returns Number of symbols loaded or error code 30 | */ 31 | int ksym_load(fs_node_t *file); 32 | 33 | /** 34 | * @brief Resolve a symbol name to a symbol address 35 | * @param name The name of the symbol to resolve 36 | * @returns The address or NULL 37 | */ 38 | uintptr_t ksym_resolve(char *symname); 39 | 40 | /** 41 | * @brief Resolve an address to the best matching symbol 42 | * @param address The address of the symbol 43 | * @param name Output name of the symbol 44 | * @returns The address of the symbol 45 | */ 46 | uintptr_t ksym_find_best_symbol(uintptr_t address, char **name); 47 | 48 | #endif -------------------------------------------------------------------------------- /drivers/net/e1000/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/net/rtl8139/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/net/rtl8169/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/sound/ac97/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/storage/ahci/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/storage/ide/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/storage/nvme/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /drivers/usb/usbhub/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron Makefile for any driver 2 | # Just drop this into your driver system, it will handle everything 3 | 4 | include ../make.config 5 | 6 | # Working directory 7 | WORKING_DIR = $(shell pwd) 8 | 9 | # Get the actual directory (e.g. storage/ahci) 10 | ACTUAL_DIR = $(patsubst $(root_driver_dir)%,%,$(WORKING_DIR)) 11 | 12 | # Output directory 13 | OUTPUT_DIR = $(OBJ_OUTPUT_DIRECTORY)/drivers/$(ACTUAL_DIR) 14 | 15 | # Source files 16 | C_SRCS = $(shell find . -name "*.c" -printf '%f ') 17 | C_OBJS = $(patsubst %.c, $(OUTPUT_DIR)/%.o, $(C_SRCS)) 18 | 19 | # Output file (.SYS file) 20 | OUTPUT_FILE = $(shell $(PYTHON) $(PROJECT_ROOT)/buildscripts/get_driveroutput.py) 21 | 22 | PRINT_HEADER: 23 | @echo "-- Building driver \"$(OUTPUT_FILE)\"..." 24 | 25 | MAKE_OUTPUT: 26 | -mkdir -p $(OUTPUT_DIR) 27 | 28 | # C compilation 29 | $(OUTPUT_DIR)/%.o: %.c 30 | $(CC) $(CFLAGS) -c $< -o $@ -I$(DESTDIR)$(INCLUDE_DIR) 31 | 32 | ./$(OUTPUT_FILE): $(C_OBJS) 33 | $(LD) $(LDFLAGS) -o $(OUTPUT_FILE) $(C_OBJS) 34 | 35 | 36 | install: PRINT_HEADER MAKE_OUTPUT ./$(OUTPUT_FILE) 37 | cp -r $(OUTPUT_FILE) $(DESTDIR)$(BOOT_OUTPUT)/drivers 38 | cp -r $(OUTPUT_FILE) $(INITRD)/drivers/ 39 | rm ./$(OUTPUT_FILE) 40 | 41 | clean: 42 | -rm ./$(OUTPUT_FILE) 43 | -rm -rf $(OUTPUT_DIR) 44 | -rm $(INITRD)/drivers/$(OUTPUT_FILE) 45 | -rm $(DESTDIR)$(BOOT_OUTPUT)/drivers/$(OUTPUT_FILE) -------------------------------------------------------------------------------- /userspace/Makefile: -------------------------------------------------------------------------------- 1 | # Userspace Makefile for Hexahedron 2 | include ./make.config 3 | 4 | # List of apps to compile 5 | APPS = init miniutils essence dhcpcli celestial wmtest terminal termemu desktop etherealver font-viewer show-dialog tray 6 | APPS += toast-server colorwave plasma memvisualize login-gui getty login 7 | 8 | APPS_TARGETS_INSTALL := $(patsubst %, install?%, $(APPS)) 9 | APPS_TARGETS_CLEAN := $(patsubst %, clean?%, $(APPS)) 10 | 11 | USERSPACE_LIB_DIRECTORY = lib 12 | 13 | # Target disabled 14 | all: 15 | @echo "=== TARGET DISABLED ===" 16 | @echo "Please use make install" 17 | 18 | install-lib: 19 | $(MAKE) -C $(USERSPACE_LIB_DIRECTORY) install 20 | 21 | clean-lib: 22 | $(MAKE) -C $(USERSPACE_LIB_DIRECTORY) clean 23 | 24 | install?%: 25 | $(MAKE) -C $(subst $e?,/,$(patsubst install?%, %, $@)) install 26 | 27 | clean?%: 28 | $(MAKE) -C $(subst $e?,/,$(patsubst clean?%, %, $@)) clean 29 | 30 | # Create build directories 31 | MAKE_DIRS: 32 | -@mkdir -pv $(DESTDIR)$(BINARY_DIR) 33 | -@mkdir -pv $(OBJ_OUTPUT_DIRECTORY)/userspace 34 | 35 | # Cosmetic 36 | PRINT_HEADER: 37 | @echo 38 | @echo 39 | @echo "[ Building userspace applications, please wait... ]" 40 | @echo 41 | @echo 42 | 43 | install: PRINT_HEADER MAKE_DIRS install-lib $(APPS_TARGETS_INSTALL) 44 | 45 | install-headers: 46 | make -C $(USERSPACE_LIB_DIRECTORY) install-headers 47 | 48 | clean: clean-lib $(APPS_TARGETS_CLEAN) -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/x86/acpica.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/x86/acpica.h 3 | * @brief ACPICA kernel interface header 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifdef ACPICA_ENABLED 15 | 16 | #ifndef DRIVERS_X86_ACPICA_H 17 | #define DRIVERS_X86_ACPICA_H 18 | 19 | /**** INCLUDES ****/ 20 | #include 21 | #include 22 | 23 | /* Architecture-specific includes */ 24 | #if defined(__ARCH_I386__) 25 | #include 26 | #elif defined(__ARCH_X86_64__) 27 | #include 28 | #else 29 | #error "Unsupported architecture - do not compile this file" 30 | #endif 31 | 32 | 33 | /**** FUNCTIONS ****/ 34 | 35 | /** 36 | * @brief Initialize ACPICA 37 | */ 38 | int ACPICA_Initialize(); 39 | 40 | /** 41 | * @brief Get SMP information from MADT 42 | * @returns A pointer to the SMP information object, or NULL if there was an error. 43 | */ 44 | smp_info_t *ACPICA_GetSMPInfo(); 45 | 46 | /** 47 | * @brief Print the ACPICA namespace to serial (for debug) 48 | */ 49 | void ACPICA_PrintNamespace(); 50 | 51 | #endif 52 | 53 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/celestial.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/celestial.h 3 | * @brief Celestial header file 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _CELESTIAL_H 15 | #define _CELESTIAL_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /**** TYPES ****/ 24 | 25 | typedef struct celestial_info { 26 | size_t screen_width; // Screen width 27 | size_t screen_height; // Screen height 28 | } celestial_info_t; 29 | 30 | /**** FUNCTIONS ****/ 31 | 32 | /** 33 | * @brief Main loop for a Celestial window 34 | * 35 | * You are not required to enter this. This is if you have async threads running and don't want to care. 36 | * Most likely, you want @c celestial_poll that will handle updates on your window. 37 | */ 38 | void celestial_mainLoop(); 39 | 40 | /** 41 | * @brief Get Celestial window server information 42 | * @returns Celestial server information 43 | */ 44 | celestial_info_t *celestial_getServerInformation(); 45 | 46 | #endif -------------------------------------------------------------------------------- /userspace/tray/Makefile: -------------------------------------------------------------------------------- 1 | # Userspace tray Makefile for Hexahedron 2 | include ./make.config 3 | 4 | # List of tray widgets to compile 5 | WIDGETS = clock network 6 | 7 | WIDGETS_TARGETS_INSTALL := $(patsubst %, install-%, $(WIDGETS)) 8 | WIDGETS_TARGETS_CLEAN := $(patsubst %, clean-%, $(WIDGETS)) 9 | WIDGETS_DEST_DIR := $(DESTDIR)$(LIBDIR)/widgets/ 10 | 11 | # Target disabled 12 | all: 13 | @echo "=== TARGET DISABLED ===" 14 | @echo "Please use make install" 15 | 16 | 17 | # !!!: HACK to remove -MD 18 | REMOVE_MD: 19 | -rm $(WIDGETS_DEST_DIR)/*.d 20 | 21 | install-%: 22 | $(CC) -shared -fPIC -I$(DESTDIR)/usr/include/freetype2 -I$(DESTDIR)/usr/include/ $(wildcard $(subst $e-,/,$(patsubst install-%,%,$@))/*.c) -o $(WIDGETS_DEST_DIR)/$(subst $e-,/,$(patsubst install-%,%,$@)).so -lwidget -lkeyboard -lcelestial -lstructures -lgraphics -lfreetype -lethereal 23 | 24 | clean-%: 25 | -rm $(WIDGETS_DEST_DIR)/$(subst $e-,/,$(patsubst clean-%,%,$@)).so 26 | 27 | # Create build directories 28 | MAKE_DIRS: 29 | -@mkdir -pv $(WIDGETS_DEST_DIR) 30 | 31 | # Cosmetic 32 | PRINT_HEADER: 33 | @echo 34 | @echo 35 | @echo "[ Building userspace tray widgets, please wait... ]" 36 | 37 | install: PRINT_HEADER MAKE_DIRS $(WIDGETS_TARGETS_INSTALL) REMOVE_MD 38 | clean: $(WIDGETS_TARGETS_CLEAN) 39 | 40 | install-headers: 41 | @-mkdir -pv $(DESTDIR)$(INCLUDE_DIRECTORY) 42 | @-cp -R --preserve=timestamps include/. $(DESTDIR)$(INCLUDE_DIRECTORY)/ -------------------------------------------------------------------------------- /hexahedron/include/kernel/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/config.h 3 | * @brief Kernel configuration header 4 | * 5 | * @note THIS FILE DOES NOT CONTAIN CONFIGURATION DATA. SEE CONFIG.C 6 | * 7 | * @copyright 8 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 9 | * It is released under the terms of the BSD 3-clause license. 10 | * Please see the LICENSE file in the main repository for more details. 11 | * 12 | * Copyright (C) 2024 Samuel Stuart 13 | */ 14 | 15 | #ifndef KERNEL_CONFIG_H 16 | #define KERNEL_CONFIG_H 17 | 18 | 19 | /* This just exposes things exposed in config.c, which is remade every build. */ 20 | extern const char *__kernel_version_format; 21 | extern const char *__kernel_version_codename; 22 | extern const char *__kernel_build_date, *__kernel_build_time; 23 | extern const char *__kernel_build_configuration; 24 | extern const char *__kernel_architecture; 25 | extern const char *__kernel_compiler; 26 | extern const char *__kernel_ascii_art_formatted; 27 | 28 | 29 | // Versioning information 30 | extern const int __kernel_version_major; 31 | extern const int __kernel_version_minor; 32 | extern const int __kernel_version_lower; 33 | 34 | // Debug settings 35 | extern const int __debug_output_com_port, __debug_output_baud_rate; 36 | extern const int __debugger_com_port, __debugger_baud_rate, __debugger_enabled, __debugger_wait_time; 37 | 38 | 39 | 40 | #endif -------------------------------------------------------------------------------- /external/Makefile: -------------------------------------------------------------------------------- 1 | include ../make.config 2 | 3 | ifeq ($(HOSTARCH), i386) 4 | # Required for I386 5 | PROJECTS := freetype plutosvg 6 | 7 | # ACPICA 8 | ifeq ($(USE_ACPICA), 1) 9 | PROJECTS += acpica 10 | endif 11 | 12 | else ifeq ($(HOSTARCH), x86_64) 13 | # Required for x86_64 14 | PROJECTS := freetype plutosvg 15 | 16 | # ACPICA 17 | ifeq ($(USE_ACPICA), 1) 18 | PROJECTS += acpica 19 | endif 20 | 21 | else ifeq ($(HOSTARCH), aarch64) 22 | # Required for aarch64 23 | # Freetype cannot be built 24 | PROJECTS := 25 | 26 | else 27 | PROJECTS := 28 | endif 29 | 30 | 31 | 32 | 33 | # i love make i love make cmake is bad i love make i love make 34 | PROJECTS_HEADERS := $(addsuffix /installheaders, $(PROJECTS)) 35 | PROJECTS_INSTALL := $(addsuffix /install, $(PROJECTS)) 36 | PROJECTS_CLEAN := $(addsuffix /clean, $(PROJECTS)) 37 | 38 | # Target disabled 39 | all: 40 | @echo "=== TARGET DISABLED ===" 41 | @echo "Please use make install" 42 | 43 | $(PROJECTS_HEADERS): 44 | make -C $(dir $@) install-headers 45 | 46 | $(PROJECTS_INSTALL): 47 | make -C $(dir $@) install 48 | 49 | $(PROJECTS_CLEAN): 50 | make -C $(dir $@) clean 51 | 52 | # Because I could care less each external project should at least have an 53 | # install-headers dummy target. Suck it. 54 | install-headers: $(PROJECTS_HEADERS) 55 | @echo "[EXTERNAL] Finished headers: $(PROJECTS)" 56 | install: $(PROJECTS_INSTALL) 57 | @echo "[EXTERNAL] Finished compiling: $(PROJECTS)" 58 | clean: $(PROJECTS_CLEAN) -------------------------------------------------------------------------------- /userspace/termemu/terminal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/termemu/terminal.h 3 | * @brief terminal.h 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _TERMINAL_H 15 | #define _TERMINAL_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** DEFINITIONS ****/ 22 | 23 | /* Cell width and height */ 24 | #define CELL_WIDTH 8 25 | #define CELL_HEIGHT 17 26 | 27 | /* Cell foreground/background */ 28 | #define CELL_FG_UNHIGHLIGHTED GFX_RGB(255, 255, 255) 29 | #define CELL_FG_HIGHLIGHTED GFX_RGB(0, 0, 0) 30 | #define CELL_BG_UNHIGHLIGHTED GFX_RGB(0, 0, 0) 31 | #define CELL_BG_HIGHLIGHTED GFX_RGB(255, 255, 255) 32 | 33 | /**** TYPES ****/ 34 | 35 | typedef struct term_cell { 36 | char ch; // The character in the cell 37 | uint8_t highlighted; // Cell is highlighted 38 | gfx_color_t fg; // Foreground 39 | gfx_color_t bg; // Background 40 | uint8_t bold; // Cell is bold 41 | } term_cell_t; 42 | 43 | /**** MACROS ****/ 44 | 45 | #define HIGHLIGHT(cell) { cell->highlighted = 1; } 46 | #define UNHIGHLIGHT(cell) { cell->highlighted = 0; } 47 | 48 | #endif -------------------------------------------------------------------------------- /hexahedron/debug/debugger.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/debug/debugger.c 3 | * @brief Provides the main interface of the Hexahedron debugger. 4 | * 5 | * The debugger and the kernel communicate via JSON objects. 6 | * On startup, the kernel will wait for a hello packet from the debugger, then start 7 | * communication from there. 8 | * 9 | * Packets are constructed like so: 10 | * - Newline 11 | * - Initial @c PACKET_START byte 12 | * - Length of the packets (int) 13 | * - JSON string 14 | * - Final @c PACKET_END byte 15 | * - Newline 16 | * 17 | * The JSON itself isn't very important (you can provide your own JSON 18 | * fields) - the main important thing is the pointer to the packet's structure. 19 | * 20 | * @copyright 21 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 22 | * It is released under the terms of the BSD 3-clause license. 23 | * Please see the LICENSE file in the main repository for more details. 24 | * 25 | * Copyright (C) 2024 Samuel Stuart 26 | */ 27 | 28 | 29 | #include 30 | 31 | /** 32 | * @brief Initialize the debugger. This will wait for a hello packet if configured. 33 | * @param port The serial port to use 34 | * @returns 1 on a debugger connecting, 0 on a debugger not connecting, and anything below zero is a bad input. 35 | */ 36 | int debugger_initialize(serial_port_t *port) { 37 | // The debugger was removed in Hexahedron 2.0.0 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /hexahedron/include/kernel/arch/x86_64/registers.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/arch/x86_64/registers.h 3 | * @brief Registers structure for x86_64 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_ARCH_X86_64_REGISTERS_H 15 | #define KERNEL_ARCH_X86_64_REGISTERS_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /***** TYPES ****/ 21 | 22 | // Descriptor (e.g. gdtr, idtr) 23 | typedef struct _descriptor { 24 | uint16_t limit; 25 | uint64_t base; 26 | } __attribute__((packed)) descriptor_t; 27 | 28 | // Registers structure 29 | typedef struct _registers { 30 | uint16_t ds; 31 | 32 | uint64_t r8, r9, r10, r11, r12, r13, r14, r15; 33 | uint64_t rbp, rdi, rsi, rdx, rcx, rbx, rax; 34 | 35 | // Pushed by the wrapper 36 | uintptr_t int_no; 37 | uintptr_t err_code; 38 | 39 | // Pushed by the CPU 40 | uintptr_t rip, cs, rflags, rsp, ss; 41 | } __attribute__((packed)) registers_t; 42 | 43 | // Extended registers 44 | typedef struct _extended_registers { 45 | uint64_t cr0; 46 | uint64_t cr2; 47 | uint64_t cr3; 48 | uint64_t cr4; 49 | descriptor_t gdtr; 50 | descriptor_t idtr; 51 | } __attribute__((packed)) extended_registers_t; 52 | 53 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/widget/label.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/widget/label.h 3 | * @brief Label widget 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _WIDGET_LABEL_H 15 | #define _WIDGET_LABEL_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** DEFINITIONS ****/ 22 | 23 | #define LABEL_DEFAULT_FONT "/usr/share/DejaVuSans.ttf" 24 | #define LABEL_DEFAULT_COLOR GFX_RGB(0, 0, 0) 25 | 26 | /**** TYPES ****/ 27 | 28 | typedef struct widget_label { 29 | char *text; // Text of the label 30 | gfx_color_t color; // Label color 31 | size_t font_size; // Font size of the label 32 | } widget_label_t; 33 | 34 | /**** FUNCTIONS ****/ 35 | 36 | /** 37 | * @brief Create a new label object 38 | * @param frame The frame to place the label under 39 | * @param text The text to use for the label 40 | * @param size The size of font to use for the label 41 | */ 42 | widget_t *label_create(widget_t *frame, char *text, size_t size); 43 | 44 | /** 45 | * @brief Set the text on a label 46 | * @param label The label 47 | * @param text The text 48 | */ 49 | void label_setText(widget_t *label, char *text); 50 | 51 | #endif -------------------------------------------------------------------------------- /userspace/miniutils/kill.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/kill.c 3 | * @brief kill 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | void usage() { 21 | printf("Usage: kill [OPTIONS] \n"); 22 | printf("Forcibly terminate a process.\n"); 23 | exit(EXIT_SUCCESS); 24 | } 25 | 26 | void version() { 27 | printf("kill (Ethereal miniutils) 1.00\n"); 28 | printf("Copyright (C) 2025 The Ethereal Development Team\n"); 29 | exit(EXIT_SUCCESS); 30 | } 31 | 32 | int main(int argc, char *argv[]) { 33 | if (argc < 2) { 34 | usage(); 35 | } 36 | 37 | if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { 38 | version(); 39 | } 40 | 41 | if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { 42 | usage(); 43 | } 44 | 45 | // TODO: Other signal support 46 | 47 | // TODO: Burn this 48 | char *pid_str = argv[1]; 49 | pid_t pid = strtol(pid_str, NULL, 10); 50 | if (pid || *(argv[1]) == '0') { 51 | if (kill(pid, SIGTERM) < 0) { 52 | printf("kill: %d: %s\n", pid, strerror(errno)); 53 | return 1; 54 | } 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /hexahedron/drivers/net/loopback.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/drivers/net/loopback.c 3 | * @brief Loopback interface 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /** 19 | * @brief Loopback write 20 | */ 21 | ssize_t loopback_write(fs_node_t *node, off_t offset, size_t size, uint8_t *buffer) { 22 | // Loop right back atcha 23 | NIC(node)->stats.rx_bytes += size; 24 | NIC(node)->stats.rx_packets++; 25 | NIC(node)->stats.tx_bytes += size; 26 | NIC(node)->stats.tx_packets++; 27 | ethernet_handle((ethernet_packet_t*)buffer, node, size); 28 | return size; 29 | } 30 | 31 | /** 32 | * @brief Install the loopback device 33 | */ 34 | static int loopback_install() { 35 | uint8_t mac[6] = {00, 00, 00, 00, 00, 00}; 36 | fs_node_t *nic_node = nic_create("loopback interface", mac, NIC_TYPE_ETHERNET, NULL); 37 | 38 | NIC(nic_node)->ipv4_address = inet_addr("127.0.0.1"); 39 | NIC(nic_node)->ipv4_subnet = inet_addr("255.0.0.0"); 40 | NIC(nic_node)->mtu = 1500; 41 | 42 | nic_node->write = loopback_write; 43 | return nic_register(nic_node, "lo"); 44 | } 45 | 46 | NET_INIT_ROUTINE(loopback, INIT_FLAG_DEFAULT, loopback_install); -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/usb/hid/keyboard.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/usb/hid/keyboard.h 3 | * @brief Generic HID keyboard driver 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_USB_HID_KEYBOARD_H 15 | #define DRIVERS_USB_HID_KEYBOARD_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** TYPES ****/ 21 | 22 | typedef struct USBHidKeyboardState { 23 | uint8_t last_keyboard_state[8]; 24 | uint8_t current_keyboard_state[8]; 25 | uint8_t idx; 26 | uint8_t last_modifiers; 27 | uint8_t modifiers; 28 | } USBHidKeyboardState_t; 29 | 30 | /**** DEFINITIONS ****/ 31 | 32 | #define HID_KEYBOARD_USAGE_PAGE 0x1 33 | #define HID_KEYBOARD_USAGE_ID 0x6 34 | 35 | #define HID_KEYBOARD_MODIFIER_LCTRL 0 36 | #define HID_KEYBOARD_MODIFIER_LSHIFT 1 37 | #define HID_KEYBOARD_MODIFIER_LALT 2 38 | #define HID_KEYBOARD_MODIFIER_LSUPER 3 39 | #define HID_KEYBOARD_MODIFIER_RCTRL 4 40 | #define HID_KEYBOARD_MODIFIER_RSHIFT 5 41 | #define HID_KEYBOARD_MODIFIER_RALT 6 42 | #define HID_KEYBOARD_MODIFIER_RSUPER 7 43 | 44 | 45 | /**** FUNCTIONS ****/ 46 | 47 | /** 48 | * @brief Initialize generic USB HID keyboard driver 49 | */ 50 | void usb_keyboardInit(); 51 | 52 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/task/timer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/task/timer.h 3 | * @brief timer.h 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_TASK_TIMER_H 15 | #define KERNEL_TASK_TIMER_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | 22 | /**** TYPES ****/ 23 | 24 | struct process; 25 | 26 | typedef struct process_timer { 27 | int which; // The type of timer we are 28 | struct timeval reset_value; // Reset value for the timer 29 | struct timeval value; // Current value of the timer 30 | struct process *process; // Process which has the timer 31 | 32 | unsigned long expire_seconds; // Expire seconds 33 | unsigned long expire_subseconds; // Expire subseconds 34 | } process_timer_t; 35 | 36 | 37 | /**** FUNCTIONS ****/ 38 | 39 | /** 40 | * @brief Set and queue a timer for a process 41 | * @param process The process to queue the timer for 42 | * @param which The type of timer to queue 43 | * @param value The new value of the timer 44 | * @returns 0 on success 45 | */ 46 | int timer_set(struct process *process, int which, struct itimerval *value); 47 | 48 | #endif -------------------------------------------------------------------------------- /hexahedron/fs/console.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/fs/console.c 3 | * @brief Framebuffer console driver (/device/console) 4 | * 5 | * This provides a mini text device for shell mode. 6 | * 7 | * 8 | * @copyright 9 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 10 | * It is released under the terms of the BSD 3-clause license. 11 | * Please see the LICENSE file in the main repository for more details. 12 | * 13 | * Copyright (C) 2025 Samuel Stuart 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /** 26 | * @brief Write method for console 27 | */ 28 | ssize_t console_write(fs_node_t *node, off_t off, size_t size, uint8_t *buffer) { 29 | if (!size) return 0; 30 | 31 | extern int video_ks; 32 | for (size_t i = 0; i < size; i++) { 33 | if (!video_ks) terminal_putchar(buffer[i]); 34 | else debug_print(NULL, buffer[i]); 35 | } 36 | 37 | return size; 38 | } 39 | 40 | /** 41 | * @brief Mount the console device 42 | */ 43 | static int console_mount() { 44 | fs_node_t *condev = fs_node(); 45 | strncpy(condev->name, "console", 256); 46 | condev->flags = VFS_CHARDEVICE; 47 | condev->mask = 0777; 48 | condev->write = console_write; 49 | vfs_mount(condev, "/device/console"); 50 | return 0; 51 | } 52 | 53 | FS_INIT_ROUTINE(console, INIT_FLAG_DEFAULT, console_mount); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2024, Samuel Stuart 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/shared.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/shared.h 3 | * @brief Ethereal shared memory API (because POSIX's is trash) 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _SYS_ETHEREAL_SHARED_H 15 | #define _SYS_ETHEREAL_SHARED_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** DEFINITIONS ****/ 22 | 23 | #define SHARED_DEFAULT 0x0 // Default shared memory 24 | 25 | /**** TYPES ****/ 26 | 27 | typedef int key_t; 28 | 29 | /**** FUNCTIONS ****/ 30 | 31 | /** 32 | * @brief Create a new object of shared memory 33 | * @param size The size of the shared memory 34 | * @param flags Flags to use when creating the shared memory 35 | * @returns A file descriptor that you can @c mmap in 36 | */ 37 | int shared_new(size_t size, int flags); 38 | 39 | /** 40 | * @brief Get the key of a shared memory object 41 | * @param fd The file descriptor of the shared memory object 42 | * @returns The key on success or -1 on failure 43 | */ 44 | key_t shared_key(int fd); 45 | 46 | /** 47 | * @brief Open a shared memory object by its key 48 | * @param key The key to use to open the shared memory object 49 | * @returns A nonzero file descriptor on success or -1 50 | */ 51 | int shared_open(key_t key); 52 | 53 | #endif -------------------------------------------------------------------------------- /userspace/miniutils/ps.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/miniutils/ps.c 3 | * @brief ps 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | char buffer[128]; 20 | 21 | char *get_process_name(char *proc_dir_name) { 22 | char name[512]; 23 | snprintf(name, 512, "/kernel/processes/%s/info", proc_dir_name); 24 | 25 | FILE *f = fopen(name, "r"); 26 | memset(buffer, 0, 128); 27 | fread(buffer, 128, 1, f); 28 | buffer[strlen(buffer)-1] = 0; 29 | fclose(f); 30 | 31 | char *procname = strchr(buffer, ':'); 32 | char *nl = strchr(procname, '\n'); 33 | *nl = 0; 34 | 35 | if (!*(procname)) return "(error getting name)"; 36 | procname++; 37 | return procname; 38 | } 39 | 40 | 41 | int main(int argc, char *argv[]) { 42 | DIR *dirp = opendir("/kernel/processes"); 43 | 44 | printf("PID\t\t\tNAME\n"); 45 | 46 | struct dirent *ent = readdir(dirp); 47 | while (ent) { 48 | if (isdigit(ent->d_name[0]) || (ent->d_name[0] == '-' && isdigit(ent->d_name[1]))) { 49 | // Get process name 50 | printf("%s \t\t\t%s\n", ent->d_name, get_process_name(ent->d_name)); 51 | } 52 | 53 | ent = readdir(dirp); 54 | 55 | } 56 | 57 | // closedir(dirp); 58 | return 0; 59 | } -------------------------------------------------------------------------------- /hexahedron/klib/string/strto.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/klib/string/strto.c 3 | * @brief strto 4 | * @ref https://cplusplus.com/reference/cstdlib/strtol/ 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #define __strto_common_macro(ret_type) ({ \ 18 | char *str = (char*)s; \ 19 | while (*str == ' ') str++; \ 20 | int sign = (*str == '-') ? -1 : 1; \ 21 | if (*str == '-' || *str == '+') str++; \ 22 | if (base == 16 && *str == '0') { if (*(str+1) == 'x') str += 2; } \ 23 | ret_type ret = 0; \ 24 | while (*str && ((isdigit(*str)) || (base > 10 && tolower(*str) >= 'a' && tolower(*str) <= ('a'+(base-10))))) { \ 25 | ret *= base; \ 26 | if ((*str >= '0' && *str <= '9')) ret += (*str - '0'); \ 27 | else ret += (tolower(*str) - 'a' + 10); \ 28 | str++; \ 29 | }; \ 30 | if (endptr) *endptr = str; \ 31 | return ret*sign; \ 32 | }) 33 | 34 | long int strtol(const char *s, char **endptr, int base) { __strto_common_macro(long); } 35 | unsigned long int strtoul(const char *s, char **endptr, int base) { __strto_common_macro(unsigned long); } 36 | unsigned long long int strtoull(const char *s, char **endptr, int base) { __strto_common_macro(unsigned long long); } 37 | int atoi(const char *nptr) { return strtol(nptr, NULL, 10); } -------------------------------------------------------------------------------- /libkstructures/include/structs/ini.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libkstructures/include/structs/ini.h 3 | * @brief INI file parsing 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef STRUCTS_INI_H 15 | #define STRUCTS_INI_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /**** TYPES ****/ 24 | 25 | /** 26 | * @brief INI file 27 | */ 28 | typedef struct ini { 29 | hashmap_t *sections; 30 | } ini_t; 31 | 32 | /**** FUNCTIONS ****/ 33 | 34 | /** 35 | * @brief Load INI file 36 | * @param filename The file to load 37 | * @returns New INI object 38 | */ 39 | ini_t *ini_load(char *filename); 40 | 41 | /** 42 | * @brief Get values from section 43 | * @param ini The INI file 44 | * @param section The section to get 45 | * @returns Hashmap of entries 46 | */ 47 | hashmap_t *ini_getSectionValues(ini_t *ini, char *section); 48 | 49 | /** 50 | * @brief Get value from section 51 | * @param ini The INI file 52 | * @param section The section to get from 53 | * @param key The key to look for 54 | * @returns Value 55 | */ 56 | char *ini_get(ini_t *ini, char *section, char *key); 57 | 58 | /** 59 | * @brief Destroy INI object 60 | * @param ini The INI object to destroy 61 | */ 62 | void ini_destroy(ini_t *ini); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /hexahedron/include/kernel/fs/pipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/fs/pipe.h 3 | * @brief Ethereal pipe implementation 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_FS_PIPE_H 15 | #define KERNEL_FS_PIPE_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /**** TYPES ****/ 24 | 25 | typedef struct fs_pipe { 26 | fs_node_t *read; // Reader pipe 27 | fs_node_t *write; // Writer pipe 28 | circbuf_t *buf; // Pipe buffer 29 | uint8_t closed_read; // Read closed 30 | uint8_t closed_write; // Write closed 31 | } fs_pipe_t; 32 | 33 | /**** FUNCTIONS ****/ 34 | 35 | /** 36 | * @brief Create a new pipe set for a process 37 | * @param process The process to create the pipes on 38 | * @param fildes The file descriptor array to fill with pipes 39 | * @returns Error code 40 | */ 41 | int pipe_create(process_t *process, int fildes[2]); 42 | 43 | /** 44 | * @brief Create a pipe set for usage 45 | * @returns Pipe object 46 | */ 47 | fs_pipe_t *pipe_createPipe(); 48 | 49 | /** 50 | * @brief Returns the amount of content available to read 51 | * @param pipe One end of a pipe 52 | */ 53 | size_t pipe_remainingRead(fs_node_t *pipe); 54 | 55 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/mm/alloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/mm/alloc.h 3 | * @brief Allocator 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef KERNEL_MM_ALLOC_H 15 | #define KERNEL_MM_ALLOC_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** MACROS ****/ 22 | #define kzalloc(a) ({ void *p = kmalloc(a); memset(p, 0, a); p; }) 23 | 24 | /**** DEFINITIONS ****/ 25 | #define KMA_DEFAULT 0x0 26 | #define KMA_FAST 0x1 // Only use slab fastpath. CANNOT BE USED FOR LARGE ALLOCATIONS. 27 | 28 | /**** TYPES ****/ 29 | typedef uint32_t kma_flags_t; 30 | 31 | /**** FUNCTIONS ****/ 32 | __attribute__((malloc)) void *kmalloc_flags(size_t size, kma_flags_t kmaflags); 33 | __attribute__((malloc)) void *kmalloc(size_t size); 34 | __attribute__((malloc)) void *krealloc(void *ptr, size_t size); 35 | __attribute__((malloc)) void *kcalloc(size_t nobj, size_t size); 36 | void kfree(void *ptr); 37 | 38 | /** 39 | * @brief Get allocator bytes in use (cache) 40 | */ 41 | size_t alloc_used(); 42 | 43 | /** 44 | * @brief Print allocator statistics 45 | */ 46 | void alloc_stats(); 47 | 48 | /** 49 | * @brief Initialize allocator 50 | */ 51 | void alloc_init(); 52 | 53 | /** 54 | * @brief Post-SMP allocator init 55 | */ 56 | void alloc_postSMPInit(); 57 | 58 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/widget/frame.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/widget/frame.h 3 | * @brief Main frame widget of ethereal 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _WIDGET_FRAME_H 15 | #define _WIDGET_FRAME_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /**** DEFINITIONS ****/ 24 | 25 | #define FRAME_DEFAULT 0x0 26 | #define FRAME_NO_BG 0x1 // Don't draw background, so you can render other things 27 | 28 | /**** TYPES ****/ 29 | 30 | typedef struct widget_frame { 31 | window_t *window; // The window (if this is a root frame) 32 | gfx_color_t bg_color; // Background color 33 | widget_event_state_t *event; // Widget event state 34 | int flags; 35 | } widget_frame_t; 36 | 37 | /**** FUNCTIONS ****/ 38 | 39 | /** 40 | * @brief Create a new frame window based off of the root window 41 | * @param window The Celestial window to create the frame on 42 | * @param flags Creation flags 43 | */ 44 | widget_t *frame_createRoot(window_t *window, int flags); 45 | 46 | /** 47 | * @brief Get context for frame 48 | * @param frame The frame to get graphics context for 49 | */ 50 | gfx_context_t *frame_getContext(widget_t *w); 51 | 52 | #endif -------------------------------------------------------------------------------- /userspace/lib/widget/geometry.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/widget/geometry.c 3 | * @brief Widget geometry manager 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /** 19 | * @brief Render widget to X and Y coordinates 20 | * @param widget The widget to render 21 | * @param x The X coordinate in the window to render 22 | * @param y The Y coordinate in the window to render 23 | * @returns 0 on success, -1 on failure (errno set) 24 | */ 25 | int widget_renderAtCoordinates(struct widget *widget, int32_t x, int32_t y) { 26 | if (widget->geometry) { 27 | free(widget->geometry); 28 | } 29 | 30 | widget_geometry_xy_t *geometry = malloc(sizeof(widget_geometry_xy_t)); 31 | geometry->type = GEOMETRY_TYPE_XY; 32 | geometry->x = x; 33 | geometry->y = y; 34 | 35 | widget->geometry = (widget_geometry_t*)geometry; 36 | return 0; 37 | } 38 | 39 | /** 40 | * @brief Get the coordinates of a specific widget 41 | * @param widget The widget to get coords of 42 | * @param x_out Out X 43 | * @param y_out Out Y 44 | */ 45 | void widget_getCoordinates(widget_t *widget, int *x_out, int *y_out) { 46 | assert(widget->geometry->type == GEOMETRY_TYPE_XY); // TODO 47 | 48 | *x_out = ((widget_geometry_xy_t*)widget->geometry)->x; 49 | *y_out = ((widget_geometry_xy_t*)widget->geometry)->y; 50 | } -------------------------------------------------------------------------------- /userspace/celestial/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/celestial/socket.h 3 | * @brief Celestial socket handler 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _CELESTIAL_WM_SOCKET_H 15 | #define _CELESTIAL_WM_SOCKET_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | #include 21 | 22 | /**** DEFINITIONS ****/ 23 | 24 | #define CELESTIAL_SOCKET_NAME "/comm/wndsrv" 25 | 26 | /**** FUNCTIONS ****/ 27 | 28 | /** 29 | * @brief Create and bind the window server socket 30 | */ 31 | void socket_init(); 32 | 33 | /** 34 | * @brief Handle any new socket accepts 35 | * @note This is non-blocking, call and just do whatever afterwards 36 | */ 37 | void socket_accept(); 38 | 39 | /** 40 | * @brief New data available on a socket 41 | * @param sock The socket with data available 42 | */ 43 | void socket_handle(int sock); 44 | 45 | /** 46 | * @brief Send a response to a socket 47 | * @param sock The socket to send to 48 | * @param resp The response to send 49 | * @returns 0 on success 50 | */ 51 | int socket_sendResponse(int sock, void *resp); 52 | 53 | /** 54 | * @brief Send a packet to a socket 55 | * @param sock The socket to send the packet to 56 | * @param size The size of the packet 57 | * @param packet The packet to send 58 | * @returns 0 on success 59 | */ 60 | int socket_send(int sock, size_t size, void *packet); 61 | 62 | #endif -------------------------------------------------------------------------------- /userspace/lib/ethereal/pthread.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/ethereal/pthread.c 3 | * @brief Ethereal pthread API 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | DEFINE_SYSCALL4(create_thread, SYS_CREATE_THREAD, uintptr_t, uintptr_t, void *, void *); 20 | DEFINE_SYSCALL0(gettid, SYS_GETTID); 21 | DEFINE_SYSCALL1(settls, SYS_SETTLS, uintptr_t); 22 | DEFINE_SYSCALL1(exit_thread, SYS_EXIT_THREAD, void *); 23 | DEFINE_SYSCALL2(join_thread, SYS_JOIN_THREAD, pid_t, void **); 24 | DEFINE_SYSCALL2(kill_thread, SYS_KILL_THREAD, pid_t, int); 25 | 26 | pid_t ethereal_createThread(uintptr_t stack, uintptr_t tls, void *(*func)(void *), void *arg) { 27 | __sets_errno(__syscall_create_thread(stack, tls, func, arg)); 28 | } 29 | 30 | pid_t ethereal_gettid() { 31 | return __syscall_gettid(); 32 | } 33 | 34 | int ethereal_settls(uintptr_t tls) { 35 | __sets_errno(__syscall_settls(tls)); 36 | } 37 | 38 | __attribute__((noreturn)) void ethereal_exitThread(void *retval) { 39 | __syscall_exit_thread(retval); 40 | __builtin_unreachable(); 41 | } 42 | 43 | int ethereal_joinThread(pid_t tid, void **retval) { 44 | __sets_errno(__syscall_join_thread(tid, retval)); 45 | } 46 | 47 | int ethereal_killThread(pid_t tid, int sig) { 48 | __sets_errno(__syscall_kill_thread(tid, sig)); 49 | } -------------------------------------------------------------------------------- /hexahedron/drivers/x86/early_log.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/drivers/x86/early_log.c 3 | * @brief Early log device 4 | * 5 | * Pre-serial initialization 6 | * 7 | * 8 | * @copyright 9 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 10 | * It is released under the terms of the BSD 3-clause license. 11 | * Please see the LICENSE file in the main repository for more details. 12 | * 13 | * Copyright (C) 2025 Samuel Stuart 14 | */ 15 | 16 | #include 17 | 18 | typedef enum { 19 | SERIAL_COM1, 20 | SERIAL_COM2, 21 | SERIAL_COM3, 22 | PORT_E9, 23 | } ELOG_DEVICE; 24 | 25 | /* SELECTED DEVICE */ 26 | const int __early_log_device = SERIAL_COM1; 27 | 28 | /* Log port */ 29 | static uint16_t __early_log_port = 0x0; 30 | 31 | 32 | /** 33 | * @brief Early log write method 34 | */ 35 | static int earlylog_write(void *user, char ch) { 36 | outportb(__early_log_port, ch); 37 | return 0; 38 | } 39 | 40 | /** 41 | * @brief Initialize early log 42 | */ 43 | void earlylog_init() { 44 | switch (__early_log_device) { 45 | case SERIAL_COM1: 46 | __early_log_port = 0x3f8; 47 | outportb(0x3f8+3, 0x03); 48 | break; 49 | case SERIAL_COM2: 50 | __early_log_port = 0x2f8; 51 | outportb(0x2f8+3, 0x03); 52 | break; 53 | case SERIAL_COM3: 54 | __early_log_port = 0x3e8; 55 | outportb(0x3e8+3, 0x03); 56 | break; 57 | case PORT_E9: 58 | __early_log_port = 0xe9; 59 | break; // 0xE9 needs no init 60 | } 61 | 62 | debug_setOutput(earlylog_write); 63 | } -------------------------------------------------------------------------------- /drivers/usb/xhci/xhci.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drivers/usb/xhci/xhci.c 3 | * @brief xHCI controller driver 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include "xhci.h" 15 | #include 16 | #include 17 | 18 | /** 19 | * @brief PCI scan method for xHCI 20 | */ 21 | int xhci_scan(pci_device_t *dev, void *data) { 22 | if (pci_readConfigOffset(dev->bus, dev->slot, dev->function, PCI_PROGIF_OFFSET, 1) == 0x30) { 23 | // xHCI controller found 24 | return xhci_initController(dev); 25 | } 26 | 27 | return 0; 28 | } 29 | 30 | /** 31 | * @brief Driver init method 32 | */ 33 | int driver_init(int argc, char **argv) { 34 | // Do a scan 35 | pci_scan_parameters_t params = { 36 | .class_code = 0x0C, 37 | .subclass_code = 0x03, 38 | .id_list = NULL 39 | }; 40 | 41 | if (pci_scanDevice(xhci_scan, ¶ms, NULL)) { 42 | return DRIVER_STATUS_ERROR; 43 | } 44 | 45 | if (xhci_controller_count) { 46 | return DRIVER_STATUS_SUCCESS; 47 | } else { 48 | return DRIVER_STATUS_NO_DEVICE; 49 | } 50 | } 51 | 52 | /** 53 | * @brief Driver deinit method 54 | */ 55 | int driver_deinit() { 56 | return 0; 57 | } 58 | 59 | struct driver_metadata driver_metadata = { 60 | .name = "xHCI Driver", 61 | .author = "Samuel Stuart", 62 | .init = driver_init, 63 | .deinit = driver_deinit 64 | }; -------------------------------------------------------------------------------- /userspace/lib/include/graphics/color.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/graphics/color.h 3 | * @brief Graphics color 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _GRAPHICS_COLOR_H 15 | #define _GRAPHICS_COLOR_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** TYPES ****/ 21 | 22 | typedef uint32_t gfx_color_t; 23 | 24 | /**** MACROS ****/ 25 | 26 | /* Color manipulation */ 27 | #define GFX_RGB_A(color) (((color) & 0xFF000000) / 0x1000000) 28 | #define GFX_RGB_R(color) (((color) & 0x00FF0000) / 0x10000) 29 | #define GFX_RGB_G(color) (((color) & 0x0000FF00) / 0x100) 30 | #define GFX_RGB_B(color) (((color) & 0x000000FF)) 31 | #define GFX_RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) 32 | #define GFX_RGB(r, g, b) GFX_RGBA(r, g, b, 255) 33 | #define GFX_EXTRACT_RGBA(color, out_r, out_g, out_b, out_a) ({ *(out_r) = GFX_RGB_R(color); *(out_g) = GFX_RGB_G(color); *(out_b) = GFX_RGB_B(color); *(out_a) = GFX_RGB_A(color); }) 34 | 35 | /* https://learn.microsoft.com/en-us/windows/apps/develop/win2d/premultiplied-alpha */ 36 | #define __gfx_premultiply_add_alpha_channel(color, channel, new_alpha_vector) (uint8_t)(((((uint16_t)(GFX_RGB_##channel (color)) * (new_alpha_vector) + 128) * 257) >> 16) & 0xFF) 37 | #define __gfx_premultiply(color) (GFX_RGBA((GFX_RGB_R(color) * GFX_RGB_A(color) / 255), (GFX_RGB_G(color) * GFX_RGB_A(color) / 255), (GFX_RGB_B(color) * GFX_RGB_A(color) / 255), GFX_RGB_A(color))) 38 | 39 | #endif -------------------------------------------------------------------------------- /userspace/lib/include/ethereal/widget/input.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/include/ethereal/widget/input.h 3 | * @brief Input textbox 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #ifndef _WIDGET_INPUT_H 15 | #define _WIDGET_INPUT_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** DEFINITIONS ****/ 22 | 23 | #define INPUT_TYPE_DEFAULT 0 24 | #define INPUT_TYPE_PASSWORD 1 25 | 26 | /**** TYPES ****/ 27 | typedef void (*input_newline_handler_t)(widget_t *, void *); 28 | 29 | typedef struct widget_input { 30 | int type; 31 | unsigned int idx; 32 | char *buffer; 33 | char *placeholder; 34 | bool focused; 35 | bool csr_state; 36 | uint64_t last_csr_update; 37 | 38 | // on ENTER 39 | input_newline_handler_t nl; 40 | void *nl_ctx; 41 | } widget_input_t; 42 | 43 | 44 | /**** FUNCTIONS ****/ 45 | 46 | /** 47 | * @brief Create a text input box 48 | * @param frame The frame to create the input box on 49 | * @param type Type of textbox 50 | * @param placeholder Optional placeholder 51 | */ 52 | widget_t *input_create(widget_t *frame, int type, char *placeholder, size_t width, size_t height); 53 | 54 | /** 55 | * @brief Register newline handler 56 | * @param input Input box 57 | * @param handler Handler 58 | * @param context Context 59 | */ 60 | void input_onNewline(widget_t *input, input_newline_handler_t handler, void *context); 61 | 62 | #endif -------------------------------------------------------------------------------- /userspace/colorwave/colorwave.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/colorwave/colorwave.c 3 | * @brief Test for celestial 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define FREQ .05 23 | #define PHASE1 00 24 | #define PHASE2 02 25 | #define PHASE3 04 26 | #define CENTER 128 27 | 28 | gfx_color_t color_gradient(int i, double t) { 29 | uint32_t r = sin(FREQ * i + (PHASE1) + t) * 127 + 128; 30 | uint32_t g = sin(FREQ * i + (PHASE2) + t) * 127 + 128; 31 | uint32_t b = sin(FREQ * i + (PHASE3) + t) * 127 + 128; 32 | 33 | return GFX_RGB(r, g, b); 34 | } 35 | 36 | int main(int argc, char *argv[]) { 37 | wid_t wid = celestial_createWindow(CELESTIAL_WINDOW_FLAG_EXIT_ON_CLOSE, 300, 300); 38 | window_t *win = celestial_getWindow(wid); 39 | celestial_setTitle(win, "Color Wave"); 40 | 41 | double t = 0.0; 42 | 43 | while (celestial_running()) { 44 | for (uint32_t y = 0; y < 150; y++) { 45 | celestial_poll(); 46 | gfx_drawRectangleFilled(celestial_getGraphicsContext(win), &GFX_RECT(0, y*2, 300, 2), color_gradient(y, t)); 47 | } 48 | 49 | gfx_render(celestial_getGraphicsContext(win)); 50 | celestial_flip(win); 51 | usleep(16000); 52 | t += 0.05; 53 | } 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/x86/clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/arch/i386/clock.h 3 | * @brief I386 clock header 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_X86_CLOCK_H 15 | #define DRIVERS_X86_CLOCK_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | #include 20 | 21 | /**** DEFINITIONS ****/ 22 | 23 | #define CMOS_ADDRESS 0x70 // CMOS I/O address 24 | #define CMOS_DATA 0x71 // CMOS data address 25 | 26 | /**** TYPES ****/ 27 | enum { 28 | CMOS_SECOND = 0, 29 | CMOS_MINUTE = 2, 30 | CMOS_HOUR = 4, 31 | CMOS_DAY = 7, 32 | CMOS_MONTH = 8, 33 | CMOS_YEAR = 9 34 | }; 35 | 36 | 37 | /**** MACROS ****/ 38 | #define from_bcd(n) ((n / 16) * 10 + (n & 0xF)) // who the hell thought it would be a good idea to make CMOS use BCD 39 | // BCD is terrible 40 | 41 | /**** FUNCTIONS ****/ 42 | 43 | /** 44 | * @brief Initialize the CMOS-based clock driver. 45 | */ 46 | void clock_initialize(); 47 | 48 | /** 49 | * @brief Read the current CPU timestamp counter. 50 | */ 51 | uint64_t clock_readTSC(); 52 | 53 | /** 54 | * @brief Get the TSC speed 55 | */ 56 | size_t clock_getTSCSpeed(); 57 | 58 | /** 59 | * @brief Gets the tick count (CPU timestamp counter / TSC speed) 60 | * 61 | * You should probably use this in timers with clock_update(clock_readTicks()) 62 | */ 63 | uint64_t clock_readTicks(); 64 | 65 | #endif -------------------------------------------------------------------------------- /hexahedron/include/kernel/drivers/x86/pit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/include/kernel/drivers/x86/pit.h 3 | * @brief PIT header 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is apart of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2024 Samuel Stuart 12 | */ 13 | 14 | #ifndef DRIVERS_X86_PIT_H 15 | #define DRIVERS_X86_PIT_H 16 | 17 | /**** INCLUDES ****/ 18 | #include 19 | 20 | /**** DEFINITIONS ****/ 21 | 22 | #define PIT_CHANNEL_A 0x40 // Main timer channel. Generates IRQ0 23 | #define PIT_CHANNEL_B 0x41 // No longer usable 24 | #define PIT_CHANNEL_C 0x42 // PC speaker 25 | #define PIT_MODE 0x43 // Mode/command register 26 | 27 | #define PIT_IRQ 0 // Channel A IRQ 28 | #define PIT_SCALE 1193180 // 1.193180 MHz (round up of PIT 1.193182 MHz) 29 | 30 | // Only bitmasks we need 31 | #define PIT_RATE_GENERATOR 0x04 // 0 1 0 - Mode 2 32 | #define PIT_LOBYTE_HIBYTE 0x30 // Access mode 33 | 34 | 35 | 36 | /**** FUNCTIONS ****/ 37 | 38 | /** 39 | * @brief Change the PIT timer phase. 40 | * @warning Don't touch unless you know what you're doing. 41 | */ 42 | void pit_setTimerPhase(long hz); 43 | 44 | /** 45 | * @brief Initialize PIT 46 | */ 47 | void pit_initialize(); 48 | 49 | /** 50 | * @brief Sleep function 51 | */ 52 | void pit_sleep(uint64_t ms); 53 | 54 | /** 55 | * @brief Change the PIT state. 56 | * 57 | * This is used when the LAPIC timer is initialized, to allow the PIT to still operate as a timer without scheduling 58 | */ 59 | void pit_setState(int enabled); 60 | 61 | 62 | #endif -------------------------------------------------------------------------------- /drivers/Makefile: -------------------------------------------------------------------------------- 1 | # Hexahedron drivers makefile 2 | # NOTE: YOU DO NOT NEED TO MODIFY THIS! 3 | 4 | include ./make_main.config 5 | 6 | # Source directories 7 | # MODDIR_TARGETS_xxx should contain the targets (e.g. install-storage-ahci), and then we can substitute the "-" for "/" in MODDIRS 8 | MODDIRS_RAW := $(shell $(PYTHON) $(BUILDSCRIPTS_ROOT)/get_driver_directories.py $(BUILD_ARCH)) 9 | MODDIR_TARGETS_INSTALL := $(patsubst %, install-%, $(MODDIRS_RAW)) 10 | MODDIR_TARGETS_CLEAN := $(patsubst %, clean-%, $(MODDIRS_RAW)) 11 | MODDIRS := $(subst $e-,/,$(MODDIRS_RAW)) # such weird naming... 12 | 13 | # GNU Make does not exit on a $(shell ...) failure 14 | # Better have Make >4.2! 15 | $(if $(filter-out 0,$(.SHELLSTATUS)),$(error Failed to get driver list - nonzero exit code)) 16 | 17 | all: TARGET_DISABLED 18 | 19 | TARGET_DISABLED: 20 | @echo "!! THIS TARGET IS DISABLED !!" 21 | @echo "Please use make install." 22 | 23 | 24 | install-%: 25 | $(MAKE) -C $(subst $e-,/,$(patsubst install-%, %, $@)) install 26 | 27 | clean-%: 28 | $(MAKE) -C $(subst $e-,/,$(patsubst clean-%, %, $@)) clean 29 | 30 | # Create build directories 31 | MAKE_DIRS: 32 | -@mkdir -pv $(DESTDIR)$(BOOT_OUTPUT)/drivers 33 | -@mkdir -pv $(INITRD)/drivers 34 | -@mkdir -pv $(OBJ_OUTPUT_DIRECTORY)/drivers 35 | 36 | # Cosmetic 37 | PRINT_HEADER: 38 | @echo 39 | @echo 40 | @echo "[ Building drivers, please wait... ]" 41 | @echo 42 | @echo 43 | 44 | 45 | # Install/clean targets 46 | 47 | install: PRINT_HEADER MAKE_DIRS $(MODDIR_TARGETS_INSTALL) 48 | $(PYTHON) $(BUILDSCRIPTS_ROOT)/create_driver_data.py $(MODDIRS) 49 | cp driver_conf.json $(INITRD)/drivers/ 50 | cp driver_conf.json $(DESTDIR)$(BOOT_OUTPUT)/drivers/ 51 | rm driver_conf.json 52 | 53 | clean: $(MODDIR_TARGETS_CLEAN) -------------------------------------------------------------------------------- /userspace/celestial/kbd.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/celestial/kbd.c 3 | * @brief Keyboard 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include "celestial.h" 15 | #include 16 | #include 17 | #include 18 | 19 | int __celestial_keyboard_fd = -1; 20 | 21 | /** 22 | * @brief Initialize keyboard device 23 | */ 24 | void kbd_init() { 25 | __celestial_keyboard_fd = open("/device/keyboard", O_RDONLY); 26 | if (__celestial_keyboard_fd < 0) { 27 | CELESTIAL_PERROR("open"); 28 | celestial_fatal(); 29 | } 30 | } 31 | 32 | /** 33 | * @brief Update keyboard device 34 | */ 35 | void kbd_update() { 36 | key_event_t ev; 37 | ssize_t r = read(__celestial_keyboard_fd, &ev, sizeof(key_event_t)); 38 | 39 | while (r > 0) { 40 | if (WM_FOCUSED_WINDOW) { 41 | celestial_event_key_t key = { 42 | .magic = CELESTIAL_MAGIC_EVENT, 43 | .size = sizeof(celestial_event_key_t), 44 | .type = CELESTIAL_EVENT_KEY_EVENT, 45 | .wid = WM_FOCUSED_WINDOW->id, 46 | .ev = ev, 47 | }; 48 | 49 | event_send(WM_FOCUSED_WINDOW, &key); 50 | } 51 | 52 | r = read(__celestial_keyboard_fd, &ev, sizeof(key_event_t)); 53 | } 54 | 55 | if (r < 0) { 56 | CELESTIAL_PERROR("read"); 57 | CELESTIAL_ERR("keyboard: Error while getting event\n"); 58 | celestial_fatal(); 59 | } 60 | } -------------------------------------------------------------------------------- /hexahedron/arch/x86_64/signal.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hexahedron/arch/x86_64/signal.S 3 | * @brief Signal trampoline 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | /* This code will be copied by the process launcher into the VAS */ 15 | .section .userspace 16 | 17 | .global arch_signal_trampoline 18 | arch_signal_trampoline: 19 | pushq %rax 20 | pushq %rbx 21 | pushq %rcx 22 | pushq %rdx 23 | pushq %rdi 24 | pushq %rsi 25 | pushq %rbp 26 | pushq %r8 27 | pushq %r9 28 | pushq %r10 29 | pushq %r11 30 | pushq %r12 31 | pushq %r13 32 | pushq %r14 33 | pushq %r15 34 | 35 | // On the stack we have: 36 | // 1. The signal handler 37 | // 2. The signal number 38 | // 3. The userspace return address 39 | movq 120(%rsp), %rdi // Signal handler 40 | movq 128(%rsp), %rax // Signal number 41 | 42 | // Align the stack 43 | movq %rsp, %rbp 44 | and $0xFFFFFFFFFFFFFFF0, %rsp 45 | 46 | // Save FPU registers 47 | subq $512, %rsp 48 | fxsave64 (%rsp) 49 | 50 | // Leap of faith! 51 | call *%rax 52 | 53 | fxrstor64 (%rsp) 54 | addq $512, %rsp 55 | 56 | // We're back, restore. 57 | movq %rbp, %rsp 58 | popq %r15 59 | popq %r14 60 | popq %r13 61 | popq %r12 62 | popq %r11 63 | popq %r10 64 | popq %r9 65 | popq %r8 66 | popq %rbp 67 | popq %rsi 68 | popq %rdi 69 | popq %rdx 70 | popq %rcx 71 | popq %rbx 72 | popq %rax 73 | 74 | // Update RSP 75 | addq $16, %rsp 76 | popfq 77 | 78 | ret -------------------------------------------------------------------------------- /userspace/lib/ethereal/driver.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userspace/lib/ethereal/driver.c 3 | * @brief Ethereal driver system 4 | * 5 | * 6 | * @copyright 7 | * This file is part of the Hexahedron kernel, which is part of the Ethereal Operating System. 8 | * It is released under the terms of the BSD 3-clause license. 9 | * Please see the LICENSE file in the main repository for more details. 10 | * 11 | * Copyright (C) 2025 Samuel Stuart 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #define SYSCALL3(name, num, p1_type, p2_type, p3_type) \ 21 | __syscall_prefix __syscall_##name(p1_type p1, p2_type p2, p3_type p3) { \ 22 | long __return_value = num;\ 23 | asm volatile (SYSCALL_INSTRUCTION \ 24 | : "=a"(__return_value) \ 25 | : "a"(__return_value), "D"((long)(p1)), "S"((long)(p2)), "d"((long)(p3)) : SYSCALL_CLOBBERS); \ 26 | return __return_value; \ 27 | } 28 | 29 | SYSCALL3(load_driver, SYS_LOAD_DRIVER, char*, int, char**); 30 | DEFINE_SYSCALL1(unload_driver, SYS_UNLOAD_DRIVER, pid_t); 31 | DEFINE_SYSCALL2(get_driver, SYS_GET_DRIVER, pid_t, ethereal_driver_t*); 32 | 33 | pid_t ethereal_loadDriver(char *filename, int priority, char **argv) { 34 | __sets_errno(__syscall_load_driver(filename, priority, argv)); 35 | } 36 | 37 | int ethereal_unloadDriver(pid_t id) { 38 | __sets_errno(__syscall_unload_driver(id)); 39 | } 40 | 41 | ethereal_driver_t *ethereal_getDriver(pid_t id) { 42 | ethereal_driver_t *driver = malloc(sizeof(ethereal_driver_t)); 43 | memset(driver, 0, sizeof(ethereal_driver_t)); 44 | 45 | long r = __syscall_get_driver(id, driver); 46 | 47 | if (r < 0) { 48 | errno = -r; 49 | return NULL; 50 | } 51 | 52 | return driver; 53 | } --------------------------------------------------------------------------------