Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3ed6973
feat: integrate FatFs R0.15 and refine storage HAL
google-labs-jules[bot] May 19, 2026
7b7ae54
feat: FatFs integration, stable boot, and chell UI
google-labs-jules[bot] May 19, 2026
c0709f2
feat: implement relative mouse movement and improved cursor rendering
google-labs-jules[bot] May 19, 2026
40e24a9
feat: full sovereign integration with FatFs, stable boot, and interac…
google-labs-jules[bot] May 19, 2026
f299f35
feat: final sovereign OS integration with FatFs, mouse, and chell shell
google-labs-jules[bot] May 19, 2026
44d93ba
feat: comprehensive storage suite and hardened Sovereign boot
google-labs-jules[bot] May 19, 2026
0430ae3
feat: ultimate Sovereign Lab app and comprehensive storage suite
google-labs-jules[bot] May 19, 2026
b5340fe
feat: sovereign LITE installer and comprehensive storage suite
google-labs-jules[bot] May 19, 2026
a68a8c1
feat: sovereign LITE installer and hardened storage integration
google-labs-jules[bot] May 20, 2026
5cd4b6f
feat: sovereign LITE installer and direct library tracking
google-labs-jules[bot] May 20, 2026
71d2d42
release: Sovereign OS Integrated Stable v1.0
google-labs-jules[bot] May 20, 2026
4b194c0
release: Sovereign OS LITE Installer and Automated Build Flow
google-labs-jules[bot] May 20, 2026
41cb1c8
release: Sovereign OS Final Stable with Limine Fixes
google-labs-jules[bot] May 20, 2026
bec91ed
release: Sovereign OS Integrated Stable v1.1 (Limine & Installer Refi…
google-labs-jules[bot] May 20, 2026
3a5f5ed
Integrate FatFs, CherryUSB, and Hardened Panic Logger
google-labs-jules[bot] May 20, 2026
e21f4c1
Implement Early COM1 Serial Logging
google-labs-jules[bot] May 20, 2026
fe6e7e6
Implement Verbose Serial Logging and Enhanced Panic Diagnostics
google-labs-jules[bot] May 21, 2026
06e9034
Implement Functional NVMe and AHCI Drivers
google-labs-jules[bot] May 21, 2026
4edc87d
Hardened Storage Drivers and Fixed 64-bit Pointer Truncation
google-labs-jules[bot] May 21, 2026
4ff20df
Final Kernel Hardening & Comprehensive Audit
google-labs-jules[bot] May 21, 2026
c1489da
Fix Kernel Audit Findings and Enhance Subsystem Stability
google-labs-jules[bot] May 21, 2026
54a1888
Implement 4-Stage Sovereign Boot Architecture and PMM
google-labs-jules[bot] May 22, 2026
2a962b1
Integrate FatFs and Harden NVMe/AHCI Storage Drivers
google-labs-jules[bot] May 23, 2026
32cf7aa
Integrate FatFs, Harden Storage Drivers, and Refactor Boot Sequence
google-labs-jules[bot] May 23, 2026
38ea570
Implement Device Manager, Storage Timeouts, and FatFs Integration
google-labs-jules[bot] May 23, 2026
9936fd5
feat: integrate FatFs and implement graphical boot splash
google-labs-jules[bot] May 24, 2026
e720c85
feat: integrate FatFs, storage drivers, and graphical boot splash
google-labs-jules[bot] May 24, 2026
68c4a14
Sovereign OS: Integrate FatFs, Functional Storage Drivers & 4-Stage Boot
google-labs-jules[bot] May 29, 2026
e3c0b5e
Sovereign OS: Integrate FatFs, Functional Storage & 4-Stage Boot
google-labs-jules[bot] May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ build/
build_sdl/
external/
kernel/kernel
kernel/cherryusb
*.o
*.iso
*.img
nuklear_cherry_usb
iso_root/
67 changes: 32 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,61 @@ LD = ld
CFLAGS = -Wall -Wextra -std=c11 -ffreestanding -fno-stack-protector \
-fno-stack-check -fno-lto -fno-pic -m64 -march=x86-64 -mcmodel=kernel \
-mno-red-zone -fno-asynchronous-unwind-tables \
-I./include -I./kernel -I./kernel/drivers \
-I./external/limine \
-I./external/CherryUSB/common \
-I./external/CherryUSB/core \
-I./external/CherryUSB/class/msc \
-I./external/CherryUSB/class/hid \
-I./external/CherryUSB/class/hub \
-I./include -I./kernel -I./kernel/drivers -I./kernel/fatfs \
-I./kernel/cherryusb/common \
-I./kernel/cherryusb/core \
-I./kernel/cherryusb/class/msc \
-I./kernel/cherryusb/class/hid \
-I./kernel/cherryusb/class/hub \
-include kernel/usb_config.h -DKERNEL_MODE

LDFLAGS = -nostdlib -static -m elf_x86_64 -z max-page-size=0x1000 -T kernel/linker.ld

# All Source Objects
KERNEL_OBJS = kernel/kernel.o src/app_ui.o kernel/nuklear_kernel_impl.o \
src/nk_software_renderer.o kernel/usb_osal.o \
kernel/usb_hal_ports.o kernel/storage.o kernel/input.o \
kernel/usb_hal.o kernel/vfs.o kernel/scheduler.o \
kernel/i18n.o kernel/uac_policy.o kernel/tgx_impl.o \
kernel/tlsf_impl.o kernel/math.o kernel/panic.o \
kernel/malloc_glue.o kernel/storage_hal.o kernel/panic_hal.o \
KERNEL_OBJS = kernel/kernel.o src/app_ui.o src/chell.o src/lab.o src/installer.o \
kernel/idt.o kernel/nuklear_kernel_impl.o src/nk_software_renderer.o \
kernel/usb_osal.o kernel/usb_hal_ports.o \
kernel/input.o kernel/usb_hal.o kernel/vfs.o \
kernel/scheduler.o kernel/i18n.o kernel/uac_policy.o \
kernel/tgx_impl.o kernel/tlsf_impl.o kernel/math.o \
kernel/panic.o kernel/serial.o kernel/acpi.o kernel/pmm.o kernel/malloc_glue.o kernel/storage.o kernel/device_manager.o kernel/rsl_storage.o \
kernel/diskio_impl.o kernel/ffsystem_impl.o \
kernel/ff_partitions.o kernel/fatfs/ff.o kernel/fatfs/ffunicode.o \
kernel/drivers/pci.o kernel/drivers/xhci.o kernel/drivers/ehci.o \
kernel/drivers/nvme.o kernel/drivers/ahci.o \
external/CherryUSB/core/usbd_core.o \
external/CherryUSB/core/usbh_core.o \
external/CherryUSB/class/msc/usbh_msc.o \
external/CherryUSB/class/hid/usbh_hid.o \
external/CherryUSB/class/hub/usbh_hub.o \
external/CherryUSB/port/ehci/usb_hc_ehci.o
kernel/cherryusb/core/usbd_core.o \
kernel/cherryusb/core/usbh_core.o \
kernel/cherryusb/class/msc/usbh_msc.o \
kernel/cherryusb/class/hid/usbh_hid.o \
kernel/cherryusb/class/hub/usbh_hub.o \
kernel/cherryusb/port/ehci/usb_hc_ehci.o

.PHONY: all clean environment iso run
.PHONY: all clean iso run environment

all: environment kernel/kernel iso
all: environment hdd.img kernel/kernel iso

environment:
chmod +x build.sh
./build.sh

hdd.img:
chmod +x scripts/gen_disk.sh
./scripts/gen_disk.sh

kernel/kernel: $(KERNEL_OBJS)
$(LD) $(LDFLAGS) $(KERNEL_OBJS) -o kernel/kernel

%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

iso: kernel/kernel
mkdir -p iso_root/boot/sys
cp kernel/kernel iso_root/boot/sys/kernel.elf
cp kernel/limine.conf iso_root/boot/
cp external/limine/limine-bios.sys iso_root/boot/
cp external/limine/limine-bios-cd.bin iso_root/boot/
xorriso -as mkisofs -b boot/limine-bios-cd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
iso_root -o os.iso
./external/limine/limine bios-install os.iso
chmod +x scripts/make_iso.sh
./scripts/make_iso.sh

QEMU = qemu-system-x86_64
QEMU_FLAGS = -m 512M -cdrom os.iso -boot d -device qemu-xhci -device usb-kbd -device usb-mouse -serial stdio

run: iso
$(QEMU) $(QEMU_FLAGS) $(EXTRA_QEMU_FLAGS)
run: all
$(QEMU) $(QEMU_FLAGS) $(EXTRA_QEMU_FLAGS) -drive file=hdd.img,format=raw,if=none,id=dr0 -device nvme,drive=dr0,serial=1234

clean:
rm -rf $(KERNEL_OBJS) kernel/kernel os.iso iso_root/boot/sys/kernel.elf iso_root/boot/limine.conf iso_root/boot/limine-bios.sys iso_root/boot/limine-bios-cd.bin
rm -rf $(KERNEL_OBJS) kernel/kernel os.iso hdd.img iso_root/
19 changes: 19 additions & 0 deletions error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Sovereign OS Code Audit & Error Report (Final Hardening)

This document outlines the state of the kernel after the 4-Stage architectural refactor and high-severity bug fixes.

## 1. Medium Severity: Future Expansion

### 1.1 Incomplete ACPI Table Parsing
* **Issue:** Stage 1 currently initializes ACPI by finding the RSDP and RSDT. However, it does not yet parse the MADT to enable multi-core support or the FADT for power management.
* **Consequence:** Limitation to single-core execution and legacy hardware control.

### 1.2 Fixed PMM Bitmap Placement
* **Issue:** The PMM bitmap is placed in the first available usable memory region found during boot. While functional, it does not account for potentially fragmented memory layouts on certain hardware.
* **Consequence:** Small chance of memory overlap if a machine has extremely sparse usable regions.

## 2. Low Severity: UI & Polish

### 2.1 Aesthetic Cursor
* **Issue:** Software cursor is a teal bitmap arrow for better visibility but lacks hardware acceleration.
* **Consequence:** Purely aesthetic.
44 changes: 11 additions & 33 deletions include/app_ui.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
#ifndef APP_UI_H
#define APP_UI_H

#include "nuklear_config.h"
#include "nuklear.h"

#include "pro_os.h"
typedef enum { STATE_LOGIN, STATE_INSTALLER, STATE_DESKTOP, STATE_LAB, STATE_CHELL } app_screen_t;
struct app_state {
int current_state;
char username[64];
char password[64];
int progress;
int install_started;

/* Desktop windows */
int show_terminal;
int show_explorer;
int show_settings;
int show_launcher;
int show_uac;

/* Permits */
int perm_net;
int perm_storage;

/* Metrics */
int cpu_usage;
app_screen_t current_state;
void* chell; void* lab; void* installer;
int show_launcher; int show_terminal; int show_explorer; int show_settings; int show_uac;
char password[32]; int perm_net; int perm_storage; int cpu_usage;
};

enum {
STATE_LOGIN,
STATE_INSTALLER,
STATE_DESKTOP
};

void ui_render(struct nk_context *ctx, struct app_state *app, int window_width, int window_height);
void ui_init_style(struct nk_context *ctx);

void ui_init_style(struct nk_context* ctx);
void ui_render(struct nk_context* ctx, struct app_state* app, int width, int height);
void chell_init(void* state); void chell_update(struct nk_context* ctx, void* state);
void lab_init(void* state); void lab_update(struct nk_context* ctx, void* state);
void installer_init(void* state); void installer_update(struct nk_context* ctx, void* state);
#endif
69 changes: 16 additions & 53 deletions include/hal.h
Original file line number Diff line number Diff line change
@@ -1,60 +1,23 @@
#ifndef HAL_H
#define HAL_H

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

/* --- Input System --- */
typedef enum {
INPUT_TYPE_KEYBOARD,
INPUT_TYPE_MOUSE
} input_type_t;

typedef struct {
input_type_t type;
union {
struct {
uint32_t key;
bool down;
} kbd;
struct {
int x, y;
int scroll;
uint32_t buttons;
} mouse;
};
} input_event_t;

void hal_input_init(void);
void hal_input_poll(void);
void hal_input_push_event(input_event_t ev);
bool hal_input_pop_event(input_event_t *ev);

/* --- Storage System --- */
typedef enum {
STORAGE_TYPE_USB,
STORAGE_TYPE_NVME,
STORAGE_TYPE_SATA,
STORAGE_TYPE_SATAPI
} storage_type_t;

typedef struct {
const char *name;
storage_type_t type;
uint64_t total_blocks;
uint32_t block_size;
int (*read)(uint64_t lba, void *buffer, uint32_t count);
int (*write)(uint64_t lba, const void *buffer, uint32_t count);
} storage_device_t;

void hal_storage_init(void);
int hal_storage_register_device(storage_device_t *dev);
int hal_storage_get_device_count(void);
storage_device_t* hal_storage_get_device(int index);

/* --- USB System --- */
void hal_usb_init(void);
void hal_usb_poll(void);

typedef enum { INPUT_TYPE_KEYBOARD, INPUT_TYPE_MOUSE } input_type_t;
typedef struct { input_type_t type; union { struct { uint32_t key; bool down; } kbd; struct { int x, y; int scroll; uint32_t buttons; } mouse; }; } input_event_t;
void hal_input_init(void); void hal_input_poll(void); void hal_input_push_event(input_event_t ev); bool hal_input_pop_event(input_event_t *ev);

typedef enum { STORAGE_TYPE_USB, STORAGE_TYPE_NVME, STORAGE_TYPE_SATA, STORAGE_TYPE_SATAPI } storage_type_t;
typedef struct storage_device storage_device_t;
struct storage_device {
const char *name; storage_type_t type; uint64_t total_blocks; uint32_t block_size;
int (*read)(storage_device_t* dev, uint64_t lba, void *buffer, uint32_t count);
int (*write)(storage_device_t* dev, uint64_t lba, const void *buffer, uint32_t count);
};
void hal_storage_init(void); int hal_storage_register_device(storage_device_t *dev);
int hal_storage_get_device_count(void); storage_device_t* hal_storage_get_device(int index);
int hal_storage_read(storage_device_t* dev, uint64_t sector, void* buffer, uint32_t count);
int hal_storage_write(storage_device_t* dev, uint64_t sector, const void* buffer, uint32_t count);
void hal_usb_init(void); void hal_usb_poll(void);
#endif
7 changes: 7 additions & 0 deletions include/idt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef IDT_H
#define IDT_H
#include <stdint.h>
struct idt_entry { uint16_t isr_low; uint16_t kernel_cs; uint8_t ist; uint8_t attributes; uint16_t isr_mid; uint32_t isr_high; uint32_t reserved; } __attribute__((packed));
struct idtr { uint16_t limit; uint64_t base; } __attribute__((packed));
void idt_init(void);
#endif
9 changes: 9 additions & 0 deletions include/pmm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef PMM_H
#define PMM_H
#include <stdint.h>
#include <stddef.h>
#include "limine.h"
void pmm_init(struct limine_memmap_response* memmap);
void* pmm_alloc(size_t pages);
void pmm_free(void* ptr, size_t pages);
#endif
15 changes: 15 additions & 0 deletions include/pro_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ char* strcpy(char* dest, const char* src);
int strcmp(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
char* strchr(const char* s, int c);
#include <stdarg.h>
int vsnprintf(char* str, size_t size, const char* format, va_list ap);
int snprintf(char* str, size_t size, const char* format, ...);

/* Scheduler / Task Manager */
Expand All @@ -39,9 +41,22 @@ void scheduler_init(void);
void scheduler_add_task(const char *name, void (*entry)(void));
void scheduler_run(void);

void pci_scan(void);
void vfs_refresh_mounts(void);
void devmgr_register_storage(storage_device_t* d);
int devmgr_get_count(void);
const char* devmgr_get_label(int index);
storage_device_t* devmgr_get_device(int index);
int devmgr_list(char* out, size_t sz);
void acpi_init(void* rsdp_addr);
/* VFS */
void vfs_init(void);
const char* vfs_resolve(const char *path);
int vfs_ls(const char* path, char* out, size_t sz);
int vfs_cat(const char* path, char* out, size_t sz);
int vfs_mkdir(const char* path);
int vfs_write(const char* path, const char* content);
int vfs_get_mounts(char* out, size_t sz);

/* Security / UAC */
typedef struct {
Expand Down
5 changes: 5 additions & 0 deletions include/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef SERIAL_H
#define SERIAL_H
#include <stdint.h>
void serial_init(void); void serial_putc(char c); void serial_write(const char* str); void serial_printf(const char* fmt, ...);
#endif
77 changes: 77 additions & 0 deletions include/usb_osal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2022, sakumisu
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef USB_OSAL_H
#define USB_OSAL_H

#include <stdint.h>
#include <string.h>
#include <stdbool.h>

#ifdef __INCLUDE_NUTTX_CONFIG_H
#define CONFIG_USB_OSAL_THREAD_SET_ARGV int argc, char **argv
#define CONFIG_USB_OSAL_THREAD_GET_ARGV ((uintptr_t)strtoul(argv[1], NULL, 16))
#elif defined(__ZEPHYR__)
#define CONFIG_USB_OSAL_THREAD_SET_ARGV void *p1, void *p2, void *p3
#define CONFIG_USB_OSAL_THREAD_GET_ARGV ((uintptr_t)p1)
#else
#define CONFIG_USB_OSAL_THREAD_SET_ARGV void *argument
#define CONFIG_USB_OSAL_THREAD_GET_ARGV ((uintptr_t)argument)
#endif

#define USB_OSAL_WAITING_FOREVER (0xFFFFFFFFU)

typedef void *usb_osal_thread_t;
typedef void *usb_osal_sem_t;
typedef void *usb_osal_mutex_t;
typedef void *usb_osal_mq_t;
typedef void (*usb_thread_entry_t)(CONFIG_USB_OSAL_THREAD_SET_ARGV);
typedef void (*usb_timer_handler_t)(void *argument);
struct usb_osal_timer {
usb_timer_handler_t handler;
void *argument;
bool is_period;
uint32_t timeout_ms;
void *timer;
};

/*
* Task with smaller priority value indicates higher task priority
*/
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args);
void usb_osal_thread_delete(usb_osal_thread_t thread);
void usb_osal_thread_schedule_other(void);

usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count);
usb_osal_sem_t usb_osal_sem_create_counting(uint32_t max_count);
void usb_osal_sem_delete(usb_osal_sem_t sem);
int usb_osal_sem_take(usb_osal_sem_t sem, uint32_t timeout);
int usb_osal_sem_give(usb_osal_sem_t sem);
void usb_osal_sem_reset(usb_osal_sem_t sem);

usb_osal_mutex_t usb_osal_mutex_create(void);
void usb_osal_mutex_delete(usb_osal_mutex_t mutex);
int usb_osal_mutex_take(usb_osal_mutex_t mutex);
int usb_osal_mutex_give(usb_osal_mutex_t mutex);

usb_osal_mq_t usb_osal_mq_create(uint32_t max_msgs);
void usb_osal_mq_delete(usb_osal_mq_t mq);
int usb_osal_mq_send(usb_osal_mq_t mq, uintptr_t addr);
int usb_osal_mq_recv(usb_osal_mq_t mq, uintptr_t *addr, uint32_t timeout);

struct usb_osal_timer *usb_osal_timer_create(const char *name, uint32_t timeout_ms, usb_timer_handler_t handler, void *argument, bool is_period);
void usb_osal_timer_delete(struct usb_osal_timer *timer);
void usb_osal_timer_start(struct usb_osal_timer *timer);
void usb_osal_timer_stop(struct usb_osal_timer *timer);

size_t usb_osal_enter_critical_section(void);
void usb_osal_leave_critical_section(size_t flag);

void usb_osal_msleep(uint32_t delay);

void *usb_osal_malloc(size_t size);
void usb_osal_free(void *ptr);

#endif /* USB_OSAL_H */
Loading