Skip to content

Commit 075e30c

Browse files
committed
Initial commit
0 parents  commit 075e30c

File tree

30 files changed

+1802
-0
lines changed

30 files changed

+1802
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
.vscode/*

docs/Readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SectorOS RE2
2+
3+
Second rewrite of the SectorOS project. Written in C and assembly.
4+
5+
## Features
6+
7+
* Fully functional printf and sprintf
8+
* Interrupt and exception handling
9+
* string stdlib
10+
* Vga color changing
11+
* IDT and GDT functional
12+
13+
## TODO
14+
15+
* Implement driver for serial port, keyboard, mouse and other devices
16+
* Implement VFS
17+
* Implement memory management
18+
* Implement paging
19+
* etc...
20+
21+
## Build
22+
23+
To build the project, run the following command:
24+
```bash
25+
make -f src/Makefile
26+
```
27+
28+
To build an ISO image, run the following command:
29+
```bash
30+
make -f src/Makefile iso
31+
```
32+
33+
To run the project, run the following command:
34+
```bash
35+
make -f src/Makefile run
36+
```

docs/bochsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
megs: 32
2+
romimage: file=/usr/share/bochs/BIOS-bochs-latest, address=0xf0000
3+
vgaromimage: /usr/share/bochs/VGABIOS-elpin-2.40
4+
floppya: 1_44=/dev/loop0, status=inserted
5+
boot: a
6+
log: bochsout.txt
7+
mouse: enabled=0
8+
clock: sync=realtime
9+
cpu: ips=500000

src/Include/gdt.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef __GDT_H
2+
#define __GDT_H
3+
4+
#include "system.h"
5+
6+
typedef struct gdt_entry
7+
{
8+
uint16_t limit_low;
9+
uint16_t base_low;
10+
uint8_t base_middle;
11+
uint8_t access;
12+
uint8_t granularity;
13+
uint8_t base_high;
14+
} __attribute__((packed)) gdt_entry_t;
15+
16+
typedef struct gdt_ptr
17+
{
18+
uint16_t limit;
19+
uint32_t base;
20+
}__attribute__((packed)) gdt_ptr_t;
21+
22+
void init_gdt();
23+
void gdt_set_gate(int32_t num, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran);
24+
25+
#endif

src/Include/idt.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef __IDT_H__
2+
#define __IDT_H__
3+
4+
#include "system.h"
5+
#include "printf.h"
6+
#include "isr.h"
7+
8+
typedef struct {
9+
uint16_t offset_low;
10+
uint16_t selector;
11+
uint8_t always0;
12+
uint8_t flags;
13+
uint16_t offset_high;
14+
} __attribute__((packed)) idt_entry_t;
15+
16+
typedef struct {
17+
uint16_t limit;
18+
uint32_t base;
19+
} __attribute__((packed)) idt_ptr_t;
20+
21+
22+
void init_idt();
23+
void idt_set_gate(uint8_t num, uint32_t base, uint16_t selector, uint8_t flags);
24+
25+
#endif

src/Include/isr.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#ifndef __ISR_H
2+
#define __ISR_H
3+
4+
#include "system.h"
5+
6+
typedef void (*isr_t)(registers_t *);
7+
extern isr_t interrupt_handlers[256];
8+
9+
void register_interrupt_handler(int num, isr_t handler);
10+
11+
12+
// Pointer to the Interrupts in idt_helper.asm
13+
extern void exception0(); // 0x00: Exception 0: Divide Error
14+
extern void exception1(); // 0x01: Exception 1: Debug
15+
extern void exception2(); // 0x02: Exception 2: Non Maskable Interrupt
16+
extern void exception3(); // 0x03: Exception 3: Breakpoint
17+
extern void exception4(); // 0x04: Exception 4: Overflow
18+
extern void exception5(); // 0x05: Exception 5: Bound Range Exceeded
19+
extern void exception6(); // 0x06: Exception 6: Invalid Opcode
20+
extern void exception7(); // 0x07: Exception 7: Device Not Available
21+
extern void exception8(); // 0x08: Exception 8: Double Fault
22+
extern void exception9(); // 0x09: Exception 9: Coprocessor Segment Overrun [386][GPF]
23+
extern void exception10(); // 0x0A: Exception 10: Invalid TSS
24+
extern void exception11(); // 0x0B: Exception 11: Segment Not Present
25+
extern void exception12(); // 0x0C: Exception 12: Stack Fault
26+
extern void exception13(); // 0x0D: Exception 13: General Protection Fault
27+
extern void exception14(); // 0x0E: Exception 14: Page Fault
28+
extern void exception15(); // 0x0F: Exception 15: Reserved
29+
extern void exception16(); // 0x10: Exception 16: x87 FPU Floating-Point Error
30+
extern void exception17(); // 0x11: Exception 17: Alignment Check
31+
extern void exception18(); // 0x12: Exception 18: Machine Check
32+
extern void exception19(); // 0x13: Exception 19: SIMD Floating-Point Exception
33+
extern void exception20(); // 0x14: Exception 20: Virtualization Exception
34+
extern void exception21(); // 0x15: Exception 21: Control Protection Exception
35+
extern void exception22(); // 0x16: Exception 22: Security Exception
36+
extern void exception23(); // 0x17: Exception 23: Spare
37+
extern void exception24(); // 0x18: Exception 24: Spare
38+
extern void exception25(); // 0x19: Exception 25: Spare
39+
extern void exception26(); // 0x1A: Exception 26: Spare
40+
extern void exception27(); // 0x1B: Exception 27: Spare
41+
extern void exception28(); // 0x1C: Exception 28: Spare
42+
extern void exception29(); // 0x1D: Exception 29: Spare
43+
extern void exception30(); // 0x1E: Exception 30: Spare
44+
extern void exception31(); // 0x1F: Exception 31: Spare
45+
46+
// Pointer to the Interrupts in idt_helper.asm
47+
extern void irq0(); // 0x20: IRQ 0: Programmable Interrupt Timer
48+
extern void irq1(); // 0x21: IRQ 1: Keyboard
49+
extern void irq2(); // 0x22: IRQ 2: Cascade (2)
50+
extern void irq3(); // 0x23: IRQ 3: Cascade (3)
51+
extern void irq4(); // 0x24: IRQ 4: Cascade (4)
52+
extern void irq5(); // 0x25: IRQ 5: Cascade (5)
53+
extern void irq6(); // 0x26: IRQ 6: Cascade (6)
54+
extern void irq7(); // 0x27: IRQ 7: Cascade (7)
55+
extern void irq8(); // 0x28: IRQ 8: Cascade (8)
56+
extern void irq9(); // 0x29: IRQ 9: Cascade (9)
57+
extern void irq10(); // 0x2A: IRQ 10: Cascade (10)
58+
extern void irq11(); // 0x2B: IRQ 11: Cascade (11)
59+
extern void irq12(); // 0x2C: IRQ 12: Cascade (12)
60+
extern void irq13(); // 0x2D: IRQ 13: Cascade (13)
61+
extern void irq14(); // 0x2E: IRQ 14: Cascade (14)
62+
extern void irq15(); // 0x2F: IRQ 15: Cascade (15)
63+
64+
65+
#endif

0 commit comments

Comments
 (0)