S-AOS New Architecture :
BIOS
↓
bootloader.asm
↓
iclsco.asm
↓
64-bit long mode
↓
kernel_64.asm
↓
kernel subsystems
├── GDT / IDT
├── paging / memory management
├── exceptions
├── keyboard / mouse
├── storage
├── FAT32
├── syscall layer
├── Ring 3 user space
├── shell / parser
└── text desktop
```
The current implementation boots through BIOS and switches to x86-64 long mode.
---
# 1. Architecture
S-AOS uses a custom monolithic kernel design with a Ring-3 user-space layer.
### CPU mode
The kernel runs in:
```text
x86-64 Long Mode
64-bit
```
### Privilege levels
S-AOS uses:
```text
Ring 0 = Kernel
Ring 3 = User applications
```
Ring 0 contains the kernel, hardware access and drivers.
Ring 3 is used for `.XEC` applications.
The current user-space model is single-process rather than a full multitasking scheduler.
---
# 2. Boot Process
The boot process is split into several stages.
```text
BIOS
↓
bootloader.asm
↓
iclsco.asm
↓
paging / long-mode setup
↓
kernel_64.asm
↓
kernel initialization
↓
desktop / setup / login
```
### bootloader.asm
The bootloader starts execution in BIOS environment and loads the next stage.
### iclsco.asm
ICLSCO performs early protected-mode/long-mode preparation, paging setup and transition into the 64-bit kernel environment.
### kernel_64.asm
This is the main kernel entry point and pulls together the core S-AOS subsystems.
---
# 3. Memory Protection
S-AOS has paging and privilege separation.
The documented user-space layout is:
```text
USER_APP_BASE = 0x00400000
User application:
0x00400000
User heap:
0x00600000 - 0x00DFFFFF
User stack:
top around 0x00F00000
User range:
0x00400000 - 0x00FFFFFF
```
The paging configuration marks the user region as user-accessible while kernel regions remain supervisor-only.
A DPL=3 `int 0x80` gate is used for system calls.
This gives the architecture:
```text
Ring 3 application
↓
int 80h
↓
Ring 0 syscall handler
↓
kernel subsystem
↓
return value
↓
Ring 3
```
CPU exceptions and page faults are handled by the kernel rather than allowing an uncontrolled fault to immediately turn into a triple fault.
---
# 4. GDT
S-AOS contains GDT support for the kernel/user privilege structure.
Relevant modules include:
```text
gdt_32b.asm
gdt_64b.asm
```
The GDT is part of the transition into the 64-bit protected execution environment and is also used to establish the privilege levels required for Ring 0 and Ring 3.
---
# 5. IDT and Exceptions
S-AOS has its own interrupt descriptor table and exception handlers.
Relevant modules include:
```text
idt_64.asm
exceptions.asm
pf_handler.asm
```
These handle CPU fault conditions and page faults at the kernel level.
The goal is to keep hardware exceptions inside the S-AOS kernel rather than relying on another operating system.
---
# 6. Physical Memory Management
The project contains a physical memory manager:
```text
pmm.asm
```
This is used by the kernel for memory allocation/management.
User applications have their own user-space memory region and the syscall layer provides user-facing memory allocation through:
```text
SYS_ALLOC
```
---
# 7. System Calls
Ring-3 applications do not directly access kernel internals.
They use the S-AOS syscall interface.
The syscall ABI is:
```text
RAX = syscall number
RDI = arg1
RSI = arg2
RDX = arg3
R10 = arg4
R8 = arg5
R9 = arg6
return value = RAX
entry = int 0x80
```
Current documented system calls are:
```text
0 exit(status)
1 read(fd, buffer, count)
2 write(fd, buffer, count)
3 open(name)
4 close(fd)
5 lseek(fd, offset)
6 getkey()
7 clear()
8 create(name, attribute)
9 delete(name)
10 rename(old, new)
11 readdir(user_buffer, size)
12 gettime()
13 sleep(delay)
14 reboot()
15 halt()
16 getuser(buffer, max)
17 getcwd(buffer, max)
18 alloc(size)
19 getinfo(buffer, size)
20 run_app(app_id)
21 yield()
22 exec(name.xec)
```
File descriptors are defined as:
```text
0 stdin
1 stdout
2 stderr
3-10 filesystem handles
```
---
# 8. XEC User Applications
S-AOS uses its own `.XEC` application format.
The file starts with:
```text
XEC1
```
The documented 32-byte header contains:
```text
0x00 magic
0x04 version
0x06 flags
0x08 entry offset
0x0C image size
0x10 BSS size
0x14 stack size
0x18 ABI
0x1C reserved
```
The loader validates the application and loads it into the user-space region.
The current documented XEC image limit is:
```text
64 KiB
```
---
# 9. Example Ring-3 Application
A minimal S-AOS user application can use the syscall interface directly.
```asm
BITS 64
DEFAULT REL
%include "syscalls.inc"
start:
mov eax, SYS_WRITE
mov edi, STDOUT
lea rsi, [rel message]
mov edx, message_end-message
int 0x80
mov eax, SYS_EXIT
xor edi, edi
int 0x80
message db 'HELLO!',13,10
message_end:
```
The build system assembles the application and packages it into XEC format.
---
# 10. Current Ring-3 Applications
The current application set includes:
```text
FILES.XEC
EDITOR.XEC
SHELL.XEC
CALC.XEC
CALENDAR.XEC
SNAKE.XEC
HELLO.XEC
```
### FILES.XEC
The Files application is a Ring-3 syscall application.
It uses:
```text
SYS_READDIR
SYS_GETKEY
SYS_WRITE
SYS_CLEAR
SYS_EXIT
```
It reads directory information through the kernel rather than directly accessing the FAT32 driver.
The interface supports selecting directory entries with the keyboard.
### EDITOR.XEC
The current stable architecture uses a Ring-3 launcher around the existing mature S-AOS editor engine.
This keeps the already-developed editor functionality while the full editor implementation remains kernel-side.
### SHELL.XEC
Ring-3 launcher for the S-AOS shell functionality.
### CALC.XEC
Ring-3 launcher for the calculator engine.
### CALENDAR.XEC
Ring-3 launcher for the calendar application.
### SNAKE.XEC
Ring-3 launcher for the text-mode Snake application.
### HELLO.XEC
A minimal Ring-3 test application demonstrating the syscall interface.
---
# 11. Filesystem
S-AOS currently uses **FAT32**.
The FAT32 driver is responsible for filesystem-level operations.
Implemented filesystem functions include:
```text
FAT32 boot-sector probing
cluster → LBA conversion
FAT entry reading
FAT entry writing
directory scanning
file creation
directory creation
file deletion
file renaming
file reading
file writing
file-size updates
```
The current resource/image builder also supports files requiring multiple FAT32 clusters.
---
# 12. FAT32 Driver Architecture
The storage architecture separates filesystem logic from storage access.
Conceptually:
```text
Application
↓
Syscall
↓
FAT32
↓
Block storage backend
├── ATA PIO
└── USB Mass Storage
```
This allows the FAT32 layer to operate above different block-storage implementations.
The main FAT32 source module is:
```text
fat32_driver.asm
```
---
# 13. ATA PIO Driver
S-AOS contains an ATA PIO storage backend:
```text
ata_pio.asm
```
The ATA PIO driver provides sector-based storage access for the FAT32 layer.
The intended stack is:
```text
FAT32
↓
ATA PIO
↓
IDE/ATA device
```
The ATA PIO backend is currently the main storage path used in the QEMU testing environment.
---
# 14. USB / xHCI Driver
S-AOS also contains xHCI USB host-controller code:
```text
xhci_usb.asm
```
The USB storage architecture is:
```text
USB flash drive
↓
xHCI
↓
USB Mass Storage
↓
Bulk-Only Transport
↓
SCSI-style commands
↓
block storage
↓
FAT32
```
The USB stack therefore does not have to make FAT32 understand USB-specific details.
Instead:
```text
USB driver
↓
block device
↓
FAT32
```
This is similar to the abstraction used for other storage backends.
---
# 15. SCSI-Style USB Storage Commands
USB Mass Storage devices use the Bulk-Only Transport path.
S-AOS's USB storage layer contains the commands needed to communicate with mass-storage devices through the USB storage protocol.
This allows a USB flash drive to become a block-storage backend for the FAT32 layer.
---
# 16. AHCI Status
AHCI is **not currently implemented** in the documented source tree.
The current storage backends are:
```text
ATA PIO
USB xHCI / USB Mass Storage
```
The long-term storage architecture can be extended toward:
```text
FAT32
↓
storage abstraction
├── ATA PIO
├── AHCI
└── USB MSC
```
but AHCI itself is not currently part of the implementation.
---
# 17. Keyboard Driver
S-AOS currently uses a PS/2 keyboard implementation.
Source module:
```text
ps2_keyboard.asm
```
The current desktop/setup implementation uses keyboard polling.
The keyboard path is approximately:
```text
PS/2 keyboard
↓
scan code
↓
keyboard driver
↓
layout translation
↓
S-AOS input handling
```
The operating system supports keyboard-layout selection for:
```text
QWERTY
AZERTY
```
Arrow keys are also used by the desktop, setup system and Ring-3 `SYS_GETKEY`.
---
# 18. Mouse Driver
The source tree also contains:
```text
ps2_mouse.asm
```
for PS/2 mouse support.
---
# 19. Disk Enumeration
S-AOS contains a storage enumeration module:
```text
disk_enum.asm
```
This is used as part of detecting/working with available storage devices.
The shell also contains storage-related commands such as:
```text
disk see
disk format
disk avb
gt dir
gt ..
gt where
```
---
# 20. Shell / Command Parser
S-AOS includes its own command-line parser.
Main parser module:
```text
parser.asm
```
It handles the shell command set and integrates the filesystem and editor functionality.
Current command categories include:
```text
Power
Date / Time
Storage
Files
Editors
System
Input
Miscellaneous
```
---
# 21. Power Commands
```text
pwr reboot
pwr off
regs
```
---
# 22. Date and Time Commands
```text
shw time
show date
```
---
# 23. Storage Commands
```text
disk see
disk format
disk avb
gt dir
gt ..
gt where
```
---
# 24. File Commands
```text
crt file:name
crt folder:name
type name
type name = text
write filename
seek name
del name
```
These commands operate through the FAT32 layer.
S-AOS uses FAT-style 8.3 naming for its basic filesystem tools, for example:
```text
HELLO.TXT
HELLO.ASM
SNAKE.XEC
USER.DAT
```
---
# 25. Editor Commands
The shell provides:
```text
editor name
nano name
```
The editor supports:
```text
Arrow keys
Backspace
Enter
Ctrl+S
Ctrl+O
Ctrl+X
Esc
```
The editor also contains menu systems for file operations, utilities, help, information and exiting.
The file menu supports opening existing files and creating new files.
---
# 26. Visual/Text Editor
The mature S-AOS editor provides a text-mode editing environment.
Capabilities include:
```text
cursor movement
text insertion
text deletion
new lines
file opening
file creation
saving
save-and-exit
exit without save
navigation menus
calculator utilities
hex utilities
binary utilities
help
about
```
The editor operates directly with S-AOS filesystem functionality.
---
# 27. Desktop Environment
S-AOS includes a VGA text-mode desktop rather than a traditional pixel GUI.
The main desktop contains applications such as:
```text
Files
Editor
Shell
Calculator
Calendar
Snake
```
The taskbar also contains the same application/navigation entries.
Navigation uses the keyboard.
```text
Arrow keys = move
Enter = open
```
The desktop also includes a menu with power-related options.
---
# 28. Calendar
S-AOS includes a text-mode calendar application.
It is available from the desktop/taskbar and through the application system.
---
# 29. Calculator
The calculator is available from the desktop and editor utilities.
The editor also contains calculator-related utilities as part of its utilities menu.
---
# 30. Snake
S-AOS contains a text-mode Snake game.
Features include:
```text
arrow-key movement
food
growth
score
wall collision
self collision
fixed play area
exit behavior
```
---
# 31. Setup System
S-AOS includes its own first-run setup system.
The setup process creates:
```text
password
password confirmation
username
keyboard layout
language
password hint
```
The profile is stored in:
```text
USER.DAT
```
Passwords are masked when entered.
The setup validates that required fields are not empty and that the password and confirmation match.
---
# 32. Keyboard Layout Selection
The setup system allows:
```text
QWERTY
AZERTY
```
The selected layout is used by the keyboard translation path.
---
# 33. Language System
S-AOS supports:
```text
French
English
Spanish
```
Language IDs are:
```text
0 = French
1 = English
2 = Spanish
```
Language resources are stored as:
```text
LANG_FR.TXT
LANG_EN.TXT
LANG_SP.TXT
```
The setup/login system can load external language packs.
There is also a built-in fallback so early startup can continue if a language resource cannot be loaded.
---
# 34. Login System
After setup, the system can boot into its login screen.
The login system uses:
```text
username
password
password hint
```
The password is masked.
The stored password is compared with the supplied password before login succeeds.
---
# 35. User Profile
The profile data is persisted using:
```text
USER.DAT
```
This allows the operating system to retain setup information across boots.
---
# 36. Display
S-AOS currently uses the traditional VGA text-mode framebuffer:
```text
0xB8000
```
The desktop and shell are therefore implemented as text-mode interfaces rather than a full modern graphical compositor.
---
# 37. Driver Architecture
One of the important design goals of S-AOS is keeping hardware-specific code separate from higher-level OS functionality.
For example, filesystem code should not need to know whether a sector came from ATA or USB.
The structure is approximately:
```text
Applications
↓
Syscall API
↓
Kernel filesystem
FAT32
↓
Storage layer
↙ ↘
ATA PIO xHCI
↓
USB Mass Storage
↓
SCSI / BOT
↓
block device
```
Input is similarly separated:
```text
PS/2 keyboard
↓
keyboard driver
↓
scan-code translation
↓
kernel input
↓
shell / desktop / setup / SYS_GETKEY
```
This makes it possible to add another storage backend without rewriting the FAT32 filesystem itself.
---
# 38. Source Code Organization
Important source modules include:
```text
bootloader.asm
BIOS boot sector
iclsco.asm
early system setup, paging and long-mode transition
kernel_64.asm
kernel entry and core runtime
parser.asm
shell/parser and editor integration
editor.asm
mature text editor plus setup/login/language support
fat32_driver.asm
FAT32 filesystem and storage abstraction
ata_pio.asm
ATA PIO storage backend
xhci_usb.asm
xHCI / USB storage backend
usermode.asm
Ring-3 execution, XEC loader and syscalls
desktop.asm
text desktop, taskbar and applications
disk_enum.asm
storage enumeration
gdt_32b.asm
gdt_64b.asm
GDT support
idt_64.asm
IDT support
exceptions.asm
CPU exception handling
ps2_keyboard.asm
keyboard driver
ps2_mouse.asm
mouse driver
pmm.asm
physical memory management
pf_handler.asm
page-fault handling
klib.asm
krnl.asm
kernel helpers/runtime
```
---
# 39. Build System
The normal build process is:
```text
build.bat
```
It performs approximately:
```text
1. Assemble bootloader
2. Assemble stage 2
3. Assemble kernel
4. Check kernel/boot size limits
5. Build Ring-3 XEC applications
6. Build FAT32 image
7. Start QEMU
```
The XEC applications can also be built separately:
```text
build_xec_apps.bat
```
A static project verifier is also included:
```text
python verify_s_aos.py
```
---
# 40. Creating a New Ring-3 Application
A developer can create an application such as:
```text
apps/myapp.asm
```
using the syscall interface.
Example:
```asm
BITS 64
DEFAULT REL
%include "syscalls.inc"
start:
mov eax, SYS_WRITE
mov edi, STDOUT
lea rsi, [rel message]
mov edx, message_end-message
int 0x80
mov eax, SYS_EXIT
xor edi, edi
int 0x80
message db 'HELLO!',13,10
message_end:
```
The normal XEC build system then assembles and packages the application.
---
# 41. What Makes S-AOS Different
The main goal of the project is not to create a Linux distribution.
S-AOS has its own:
```text
boot process
kernel
memory/protection model
filesystem layer
storage drivers
USB storage path
syscall ABI
application format
Ring-3 environment
shell
desktop
editor
setup system
login system
language system
built-in applications
```
The project is intended as a complete operating-system architecture rather than just a bootloader or kernel experiment.
---
# 42. Current Limitations
The current implementation is still under active development.
Known limitations include:
```text
AHCI is not implemented.
The Ring-3 model is currently single-process
and is not yet a full scheduler.
PS/2 polling is used rather than a complete
preemptive IRQ-driven input subsystem.
Several mature applications still use
Ring-3 launcher/front-end architecture
around existing kernel engines.
The file read/write syscall interface is
still a relatively small/simple interface
rather than a complete POSIX layer.
USB support currently focuses on the implemented
xHCI / USB Mass Storage path and does not cover
every USB class, hubs, UAS or a complete hotplug system.
```
---
# 43. Project Status
S-AOS currently has working pieces across multiple OS layers:
```text
[BOOT]
BIOS boot
64-bit long mode
paging
[KERNEL]
Ring 0 kernel
GDT
IDT
exceptions
page faults
physical memory management
[USER SPACE]
Ring 3
XEC executable format
syscalls
user applications
[STORAGE]
FAT32
ATA PIO
xHCI
USB Mass Storage
BOT/SCSI-style storage path
file/directory operations
[INPUT]
PS/2 keyboard
QWERTY/AZERTY layouts
PS/2 mouse module
[UI]
CLI
text desktop
taskbar
editor
Files
Calculator
Calendar
Snake
[SYSTEM]
setup
login
user profile
password
password hint
French
English
Spanish
```
The project is still being developed, but the current tree is already structured as a complete small operating system with a kernel, hardware abstraction, filesystem, user-space ABI, applications and user interface.
---
# 44. Final Architecture Overview
The overall S-AOS architecture can be summarized as:
```text
S-AOS
│
┌────────────┴────────────┐
│ │
RING 0 RING 3
KERNEL .XEC APPS
│ │
┌───────┼────────┐ │
│ │ │ │
Memory Drivers FS/API Syscall API
│ │ │ │
│ ┌───┴───┐ │ │
│ │ │ │ │
│ ATA PIO xHCI FAT32 ◄──────────┘
│ │
│ USB MSC
│ │
│ BOT/SCSI
│
├── GDT
├── IDT
├── Paging
├── Exceptions
├── Keyboard
├── Mouse
├── Shell
└── Desktop
```
The project is intentionally built from low-level components upward:
```text
hardware
↓
drivers
↓
storage / input
↓
kernel services
↓
syscalls
↓
Ring-3 applications
↓
desktop / user interface
```
To Download S-AOS : https://github.com/moslemhamoudi6-cyber ... es/tag/XEC
Documentation For App Creation etc... is comming soon
Hope You Enjoy It!
*its still in beta so dont expect much