Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
43093ea
README.md
Aditya-B-007 Sep 11, 2025
725faca
README.md
Aditya-B-007 Sep 16, 2025
24f42a9
Merge branch 'Kernel_Update_1' into main
Aditya-B-007 Sep 18, 2025
5f7714e
Add files via upload
Aditya-B-007 Sep 23, 2025
86a312e
Merge pull request #4 from Aditya-B-007/Kernel-update-3
Aditya-B-007 Sep 23, 2025
3659a55
README.md
Aditya-B-007 Sep 26, 2025
3490e47
Kernel-Update-5
Aditya-B-007 Sep 30, 2025
8083675
Merge pull request #8 from Aditya-B-007/Kernel-Update-5
Aditya-B-007 Sep 30, 2025
5d697f3
README.md
Aditya-B-007 Oct 7, 2025
d169957
README.md
Aditya-B-007 Oct 7, 2025
872b8df
Add files via upload
Aditya-B-007 Oct 11, 2025
f67decf
Merge pull request #9 from Aditya-B-007/Patch_Work_Mutex
Aditya-B-007 Oct 11, 2025
c4794bb
Add files via upload
Aditya-B-007 Oct 12, 2025
ea08f2c
Merge pull request #10 from Aditya-B-007/Update_GUI
Aditya-B-007 Oct 12, 2025
451f3e8
Add files via upload
Aditya-B-007 Oct 14, 2025
2d961a1
Merge pull request #11 from Aditya-B-007/GUI-Update-2
Aditya-B-007 Oct 14, 2025
140eda8
README.md
Aditya-B-007 Oct 14, 2025
7139335
README.md
Aditya-B-007 Oct 14, 2025
cbf0e29
Add files via upload
Aditya-B-007 Nov 30, 2025
c076ee1
Merge pull request #12 from Aditya-B-007/Kernel_Update-After-a-long-time
Aditya-B-007 Nov 30, 2025
dfe7da0
Add files via upload
Aditya-B-007 Dec 9, 2025
eb17190
Merge pull request #13 from Aditya-B-007/Patch-1a
Aditya-B-007 Dec 9, 2025
dd881df
patch-1b
Aditya-B-007 Dec 10, 2025
7473b42
Merge pull request #14 from Aditya-B-007/Patch-1b
Aditya-B-007 Dec 10, 2025
b2f1450
Add files via upload
Aditya-B-007 Dec 13, 2025
a4add95
Merge pull request #15 from Aditya-B-007/Image-possible-code
Aditya-B-007 Dec 13, 2025
de60523
Add files via upload
Aditya-B-007 Dec 16, 2025
896043f
Merge pull request #16 from Aditya-B-007/Patch-xyz
Aditya-B-007 Dec 16, 2025
f72a197
Add files via upload
Aditya-B-007 Dec 17, 2025
b8a82e3
Merge pull request #17 from Aditya-B-007/Update-17th-Dec-2025
Aditya-B-007 Dec 17, 2025
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
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CC = gcc
LD = ld
OBJCOPY = objcopy
NASM = nasm

CFLAGS = -m32 -ffreestanding -O2 -Wall -Wextra -I. -std=gnu99 -MMD
# Use -f win32 for MinGW, -f elf32 for Linux/Cross-Compiler
NASMFLAGS = -f win32
LDFLAGS = -T linker.ld

# Auto-detect all .c files in the current folder
C_SOURCES = $(wildcard *.c)
# Exclude spinlock.c if it exists (replaced by sync.h implementation)
C_SOURCES := $(filter-out spinlock.c, $(C_SOURCES))
# Create a list of .o files to build
OBJ = $(C_SOURCES:.c=.o)

# Default target
all: os.img

os.img: boot.bin kernel.bin
cat boot.bin kernel.bin > os.img

boot.bin: boot.asm
$(NASM) -f bin boot.asm -o boot.bin

kernel.bin: kernel.tmp
$(OBJCOPY) -O binary kernel.tmp kernel.bin

kernel.tmp: $(OBJ) interrupt.o
$(LD) $(LDFLAGS) -o kernel.tmp $(OBJ) interrupt.o

interrupt.o: interrupt.asm
$(NASM) $(NASMFLAGS) interrupt.asm -o interrupt.o

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

-include $(OBJ:.o=.d)

clean:
rm -f *.o *.d *.bin *.tmp os.img
7 changes: 3 additions & 4 deletions NIC.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void rtl8139_handler(registers_t *r) {
void rtl8139_init(void) {
vga_print_string("Initializing RTL8139... ");

// --- Find the card (same as before) ---
// --- Find the card ---
uint8_t found = 0;
for (uint16_t bus = 0; bus < 256; bus++) {
for (uint8_t device = 0; device < 32; device++) {
Expand Down Expand Up @@ -65,9 +65,8 @@ void rtl8139_init(void) {
// 2. Software Reset
outb(rtl8139_io_base + REG_COMMAND, 0x10);
while((inb(rtl8139_io_base + REG_COMMAND) & 0x10) != 0) { /* wait */ }

// 3. Allocate Receive Buffer (8K + 16 bytes)
rx_buffer = (uint8_t*)pmm_alloc(8192 + 16);
// 3. Allocate an 16KB block, ie 4 blocks (order 1) for the receive buffer.
rx_buffer = (uint8_t*)pmm_alloc_blocks(4);
outl(rtl8139_io_base + REG_RX_BUF, (uint32_t)rx_buffer);

// 4. Set Interrupt Mask (Enable Receive OK interrupt)
Expand Down
194 changes: 192 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,192 @@
Operating System still under development
This is a lightweight, Machine Learning based (under the hood for memory management, process allocation etc ) based operating system
# SimpleOS - A Lightweight x86 Operating System

SimpleOS is a lightweight, robust operating system for the x86 architecture, written in C and Assembly. It provides a foundational set of OS features, including protected mode, memory segmentation, and a full interrupt handling system, making it ideal for embedded applications, legacy system revival, or as a base for custom OS development.

## Features

- **Bootloader**: Custom 16-bit bootloader that transitions to protected mode
- **GDT (Global Descriptor Table)**: Memory segmentation with kernel/user segments
- **IDT (Interrupt Descriptor Table)**: Complete interrupt handling system with exception messages
- **VGA Text Driver**: Full-featured text output with scrolling, colors, and formatting
- **Keyboard Driver**: PS/2 keyboard support with scan code translation
- **Interactive Shell**: Command-line interface with built-in commands
- **Memory Management**: Basic protected mode memory setup
- **Interrupt Handling**: Proper CPU exception and hardware interrupt handling

## Architecture

### Boot Process
1. **Real Mode Boot**: 16-bit bootloader loads from sector 0
2. **A20 Line**: Enable extended memory access
3. **Protected Mode**: Switch to 32-bit protected mode
4. **Kernel Entry**: Jump to kernel main function

### Kernel Components

#### VGA Driver (`vga.c`, `vga.h`)
- Text mode output at 0xB8000
- 80x25 character display
- 16-color palette support
- Automatic scrolling
- Hex/decimal number formatting

#### GDT Manager (`gdt.c`, `gdt.h`)
- 5-entry descriptor table (null, kernel code/data, user code/data)
- Proper segment reloading
- 4GB flat memory model

#### IDT Manager (`idt.c`, `idt.h`)
- 256 interrupt descriptors
- Exception handlers with descriptive messages
- Hardware interrupt support (PIC reprogramming)
- Assembly interrupt stubs (`interrupt.asm`)

#### Keyboard Driver (`keyboard.c`, `keyboard.h`)
- PS/2 keyboard interrupt handler (IRQ1)
- Scan code to ASCII translation
- Shift and Caps Lock support
- Key buffer for input queuing
- Integration with shell interface

#### Interactive Shell (`shell.c`, `shell.h`)
- Command-line interface
- Built-in commands: help, clear, about, reboot, halt
- Command history and input processing
- Backspace support and line editing

#### Kernel Main (`kernel.c`)
- System initialization sequence
- Colorized boot messages
- Shell initialization and main loop

## Building

### Prerequisites

You need a cross-compilation toolchain for i686-elf:
- `i686-elf-gcc` (C compiler)
- `i686-elf-ld` (Linker)
- `nasm` (Netwide Assembler)

### Installation on Ubuntu/Debian:
```bash
sudo apt-get install build-essential nasm qemu-system-x86
# For the cross-compiler, you can build it from source.
# A good guide can be found here: https://wiki.osdev.org/GCC_Cross-Compiler
# Alternatively, some package managers might have pre-built toolchains.
```

### Installation on Windows:
1. Install MSYS2
2. Install cross-compilation tools:
```bash
pacman -S mingw-w64-i686-gcc nasm
```

### Compilation
```bash
make all # Build OS image
make clean # Remove build files
make qemu # Run with QEMU (if installed)
make bochs # Run with Bochs (if installed)
make help # Show available targets
```

## Running

### QEMU (Recommended)
```bash
qemu-system-i386 -fda build/os.img
```

### Bochs
```bash
bochs -f bochsrc.txt
```

### VirtualBox/VMware
1. Create new VM with floppy disk
2. Mount `build/os.img` as floppy image
3. Boot from floppy

## Using the Shell

Once the system boots, you'll see the SimpleOS shell prompt:

```
SimpleOS>
```

The agent will process your request and respond accordingly.

### Example Interactions
- `> what time is it?`
- `> create a new file named notes.txt`
- `> tell me about the CPU`
- `> reboot the machine in 5 minutes`

## File Structure

```
SimpleOS/
├── boot/
│ └── boot.asm # 16-bit bootloader
├── kernel/
│ ├── kernel.c # Kernel main and initialization
│ ├── gdt.c/.h # Global Descriptor Table
│ ├── idt.c/.h # Interrupt Descriptor Table
│ ├── vga.c/.h # VGA text driver
│ ├── keyboard.c/.h # PS/2 keyboard driver
│ ├── agent.c/.h # The core AI agent logic
│ └── interrupt.asm # Assembly interrupt handlers
├── build/ # Build output (auto-generated)
├── Makefile # Build configuration
├── linker.ld # Linker script
└── README.md # This file
```

## Technical Details

### Memory Layout
- **0x00007C00**: Bootloader load address
- **0x00100000**: Kernel load address (1MB)
- **0x000B8000**: VGA text buffer
- **0x00090000**: Stack pointer

### Interrupts
- **ISR 0-31**: CPU exceptions (division error, page fault, etc.)
- **IRQ 0-15**: Hardware interrupts (timer, keyboard, etc.)
- **PIC Remapping**: Master PIC (0x20-0x27), Slave PIC (0x28-0x2F)

### Color Codes (VGA)
- 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta
- 6=Brown, 7=Light Grey, 8=Dark Grey, 9=Light Blue
- 10=Light Green, 11=Light Cyan, 12=Light Red
- 13=Light Magenta, 14=Light Brown, 15=White

## Roadmap

Future development is focused on expanding the kernel's capabilities. Key areas on our roadmap include:

- **Agent Tooling**: Expanding the set of kernel functions (tools) the LLM agent can use.
- **Long-Term Memory**: Implementing a file system to give the agent persistent memory.
- **Multitasking**: Allowing the agent to manage and execute multiple background processes.

### Debugging
- Connect GDB: `gdb -ex "target remote :1234"`
- Enable QEMU monitor: Add `-monitor stdio`

## Contributing

SimpleOS is an open-source product and we welcome contributions from the community. If you are interested in contributing, please feel free to fork the repository, make your changes, and submit a pull request. We are actively looking for improvements in drivers, memory management, and performance optimizations.

## License

This product is released under the MIT License. See the LICENSE file for details.

## References

- [OSDev Wiki](https://wiki.osdev.org/) - Comprehensive OS development resource
- [Intel 80386 Manual](https://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.html)
- [Bran's Kernel Development Tutorial](http://www.osdever.net/bkerndev/Docs/title.htm)
- [JamesM's Kernel Development Tutorials](https://web.archive.org/web/20160412174753/http://www.jamesmolloy.co.uk/tutorial_html/index.html)
Loading