Skip to content

Commit cfbbfc6

Browse files
authored
Merge pull request #91 from kushagra765/0.10
Merge changes from '0.10' branch
2 parents 8b21b20 + d82f068 commit cfbbfc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+958
-1660
lines changed

.clang-format

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ AllowShortFunctionsOnASingleLine: None
1515
AllowShortIfStatementsOnASingleLine: Never
1616
AllowShortLoopsOnASingleLine: false
1717
BreakStringLiterals: false
18-
ReflowComments: true
19-
SortIncludes: true
20-
UseTab: Never
18+
ReflowComments: true
19+
SortIncludes: true
20+
UseTab: Never
2121
...

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
scripts/gen_initrd
99
toolchain/compiler/
1010
isodir/
11+
kernel/include/generated/

Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# Makefile for Platypus OS
22

33
VERSION = 0.10
4-
EXTRAVERSION = -rc3
4+
EXTRAVERSION =
55

66
MAKEFILE_BUILD = ./scripts/Makefile.build
77
MAKEFILE_RUN = ./scripts/Makefile.run
88

99
.PHONY: all
1010

1111
all:
12-
make -f $(MAKEFILE_BUILD) -j$(nproc)
12+
@./scripts/gen_config.sh
13+
@make -f $(MAKEFILE_BUILD) -j$(nproc)
1314

1415
clean:
15-
make -f $(MAKEFILE_BUILD) clean
16+
@make -f $(MAKEFILE_BUILD) clean
1617

1718
run:
18-
make -f $(MAKEFILE_RUN)
19+
@make -f $(MAKEFILE_RUN)

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ To build the OS, read the [build guide](docs/Building.md).
1818
See the [Mailing Patches](docs/Mailing-Patches.md) file.
1919

2020
# Screenshot
21-
![Image](screenshots/Screenshot-0.10-rc3.png)
21+
Version 0.10 (GitHub Actions Build ISO)
22+
![Image](screenshots/Screenshot-0.10.png)
2223

2324
# Acknowledgments
2425
## Projects
25-
- [pdclib](https://github.com/DevSolar/pdclib) (The libc is based on pdclib)
26+
- [pdclib](https://github.com/DevSolar/pdclib)
27+
- [libc11](https://github.com/dryc/libc11)
2628

2729
# License
2830
This project is licensed under GPL v2. See the [`LICENSE`](LICENSE) file for more info.

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Version | Supported |
66
| ------- | ------------------ |
7-
| 0.10-rc2 | :white_check_mark: |
7+
| 0.10 | :white_check_mark: |
88
| 0.09 | :x: |
99
| 0.08 | :x: |
1010
| 0.07 | :x: |

docs/Building.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ cd ./toolchain/
55
sh ./build_toolchain.sh
66
```
77

8-
After the toolchain is built, you can build the OS by running: <br/>
9-
`make`
8+
After the toolchain is built, you can build the OS by running: `make`
109

1110
# Building the OS (without toolchain)
1211
If you already have the `i686-elf-gcc` toolchain, there's no need to build it again. Open the `scripts/Makefile.build` file and change the `CC` variable to the path where you have installed the toolchain and run `make`.
13-
14-
# Booting the OS
15-
After building the OS, you can boot it by running `make run`.
File renamed without changes.

docs/user-guide/User-Guide.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# User Guide
22
This is what you should read if you're a user, and you want to try it out.
3+
34
## Prerequisites
45
1. [Building](../Building.md)
6+
57
## Table Of Contents
6-
1. [The Terminal](terminal.md)
8+
1. [The Terminal](Terminal.md)

init/main.c

+37-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#include "multiboot.h"
2+
#include <assert.h>
23
#include <cpu/gdt.h>
34
#include <cpu/idt.h>
45
#include <cpu/irq.h>
56
#include <cpu/isr.h>
7+
#include <floppy/floppy.h>
68
#include <initrd/initrd.h>
7-
#include <kernel/paging.h>
9+
#include <kernel/device.h>
10+
#include <kernel/elf.h>
11+
#include <kernel/kheap.h>
12+
#include <kernel/pmm.h>
813
#include <kernel/printm.h>
9-
#include <kernel/task.h>
14+
#include <kernel/vmm.h>
1015
#include <keyboard/keyboard.h>
1116
#include <pit/pit.h>
1217
#include <rtc/rtc.h>
@@ -17,8 +22,8 @@
1722
#include <vga/framebuffer.h>
1823
#include <vga/vga.h>
1924

20-
extern uint32_t placement_address;
2125
uint32_t initial_esp;
26+
elf_t kernel_elf;
2227

2328
void welcome_screen() {
2429
settextcolor(LIGHT_YELLOW, BLACK);
@@ -43,13 +48,12 @@ void welcome_screen() {
4348
settextcolor(BLUE, BLACK);
4449
writestr("Version: ");
4550
settextcolor(LIGHT_RED, BLACK);
46-
writestr("0.10-rc3\n");
51+
writestr("0.10\n");
4752
reset_text_color();
4853
writestr("\n");
4954
}
5055

51-
void kernel_main(multiboot_info_t *mboot_info, uint32_t initial_stack) {
52-
initial_esp = initial_stack;
56+
void kernel_main(multiboot_info_t *mboot_info) {
5357

5458
// Initialize VGA and Framebuffer
5559
init_vga();
@@ -60,24 +64,39 @@ void kernel_main(multiboot_info_t *mboot_info, uint32_t initial_stack) {
6064
init_idt();
6165
init_isr();
6266
init_irq();
63-
writestr("[OK] Load GDT, IDT, ISR and IRQ\n");
67+
printm("[OK] Load GDT, IDT, ISR and IRQ\n");
6468

6569
// Load Drivers
6670
init_pit(1000);
6771
init_keyboard();
68-
register_snd_driver();
72+
init_pcspkr();
6973
init_serial();
7074
init_rtc();
71-
writestr("[OK] Load Drivers\n");
75+
printm("[OK] Load Drivers\n");
7276

77+
init_pmm(mboot_info->mem_upper);
78+
init_vmm();
79+
80+
uint32_t i = mboot_info->mmap_addr;
81+
while (i < mboot_info->mmap_addr + mboot_info->mmap_length) {
82+
multiboot_memory_map_t *entry = (multiboot_memory_map_t *)i;
83+
84+
if (entry->type == MULTIBOOT_MEMORY_AVAILABLE) {
85+
uint32_t j;
86+
for (j = entry->base_addr_low;
87+
j < entry->base_addr_low + entry->length_low; j += 0x1000) {
88+
free_page_pmm(j);
89+
}
90+
}
91+
i += entry->size + sizeof(uint32_t);
92+
}
93+
94+
kernel_elf = elf_from_multiboot(mboot_info->u.elf_sec);
95+
96+
ASSERT(mboot_info->mods_count > 0);
7397
uint32_t initrd = *((uint32_t *)mboot_info->mods_addr);
74-
uint32_t initrd_end = *(uint32_t *)(mboot_info->mods_addr + 4);
75-
placement_address = initrd_end;
7698

77-
// Initialize paging and tasking
78-
init_paging();
79-
init_tasking();
80-
writestr("[OK] Initialize paging and tasking\n");
99+
init_device_manager();
81100

82101
irq_enable();
83102

@@ -87,8 +106,9 @@ void kernel_main(multiboot_info_t *mboot_info, uint32_t initial_stack) {
87106
writestr("Kernel command line: %s\n", mboot_info->cmdline);
88107
uint32_t memsize = (mboot_info->mem_lower + mboot_info->mem_upper) / 1024;
89108
writestr("Total memory: %d MB\n", memsize);
90-
writestr("Initrd at address: %x", initrd);
91-
writestr("\n\n");
109+
writestr("Initrd at address: %x\n", initrd);
110+
detect_drives_floppy();
111+
writestr("\n");
92112

93113
vfs_root = init_initrd(initrd);
94114

init/multiboot.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ struct multiboot_color {
222222

223223
struct multiboot_mmap_entry {
224224
multiboot_uint32_t size;
225-
multiboot_uint32_t addr;
226-
multiboot_uint32_t len;
225+
multiboot_uint32_t base_addr_low;
226+
multiboot_uint32_t base_addr_high;
227+
multiboot_uint32_t length_low;
228+
multiboot_uint32_t length_high;
227229
#define MULTIBOOT_MEMORY_AVAILABLE 1
228230
#define MULTIBOOT_MEMORY_RESERVED 2
229231
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3

initrd/initrd.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ vfs_node_t *initrd_finddir(vfs_node_t *node, char *name) {
5252
return initrd_dev;
5353
}
5454

55-
int i;
56-
for (i = 0; i < nroot_nodes; i++) {
55+
for (int i = 0; i < nroot_nodes; i++) {
5756
if (strcmp(name, root_nodes[i].name) == 0) {
5857
return &root_nodes[i];
5958
}

kernel/arch/i386/boot.asm

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ ALIGN 4
99
multiboot:
1010

1111
PAGE_ALIGN equ 1<<0
12-
MEMORY_INFO equ 1<<0
13-
KLUDGE_AOUT equ 1<<16
12+
MEMORY_INFO equ 1<<1
1413
MAGIC equ 0x1BADB002
15-
FLAGS equ PAGE_ALIGN | MEMORY_INFO | KLUDGE_AOUT
14+
FLAGS equ PAGE_ALIGN | MEMORY_INFO
1615
CHECKSUM equ -(MAGIC + FLAGS)
1716

1817
EXTERN code, bss, end
@@ -28,7 +27,6 @@ multiboot:
2827

2928
stublet:
3029
extern kernel_main
31-
push esp
3230
push ebx
3331
call kernel_main
3432
jmp $

kernel/arch/i386/linker.ld

-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ SECTIONS
2828
}
2929

3030
end = .;
31-
__kernel_end = .;
3231
}

kernel/cpu/gdt.c

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "gdt.h"
2-
#include "tss.h"
32
#include <stdint.h>
43
#include <string.h>
54

@@ -17,9 +16,8 @@ struct pointer_gdt {
1716
uint32_t base;
1817
} __attribute__((packed));
1918

20-
struct entry_gdt gdt[6];
19+
struct entry_gdt gdt[3];
2120
struct pointer_gdt gdt_ptr;
22-
struct tss_entry __tss_entry;
2321

2422
void set_gate_gdt(int num, uint32_t base, uint32_t limit, uint8_t access,
2523
uint8_t gran) {
@@ -38,34 +36,13 @@ void set_gate_gdt(int num, uint32_t base, uint32_t limit, uint8_t access,
3836
gdt[num].access = access;
3937
}
4038

41-
void write_tss(int32_t num, uint16_t ss0, uint32_t esp0) {
42-
uint32_t base = (uint32_t)&__tss_entry;
43-
uint32_t limit = base + sizeof(__tss_entry);
44-
45-
set_gate_gdt(num, base, limit, 0xE9, 0x00);
46-
memset(&__tss_entry, 0, sizeof(__tss_entry));
47-
__tss_entry.ss0 = ss0;
48-
__tss_entry.esp0 = esp0;
49-
__tss_entry.cs = 0x0b;
50-
__tss_entry.ss = __tss_entry.ds = __tss_entry.es = __tss_entry.fs =
51-
__tss_entry.gs = 0x13;
52-
}
53-
54-
void set_kernel_stack(uint32_t stack) {
55-
__tss_entry.esp0 = stack;
56-
}
57-
5839
void init_gdt() {
5940
gdt_ptr.limit = (sizeof(struct entry_gdt) * 6) - 1;
6041
gdt_ptr.base = (uintptr_t)&gdt;
6142

6243
set_gate_gdt(0, 0, 0, 0, 0);
6344
set_gate_gdt(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
6445
set_gate_gdt(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
65-
set_gate_gdt(3, 0, 0xFFFFFFFF, 0xFA, 0xCF);
66-
set_gate_gdt(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
67-
write_tss(5, 0x10, 0x0);
6846

6947
gdt_load();
70-
flush_tss();
7148
}

kernel/cpu/idt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void set_gate_idt(int num, uint32_t base, uint16_t sel, uint8_t flags) {
2525
idt[num].hi_base = (base >> 16) & 0xFFFF;
2626
idt[num].sel = sel;
2727
idt[num].always0 = 0;
28-
idt[num].flags = flags | 0x60;
28+
idt[num].flags = flags;
2929
}
3030

3131
void init_idt() {

kernel/cpu/isr.c

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "isr.h"
22
#include "idt.h"
33
#include <kernel/panic.h>
4+
#include <kernel/vmm.h>
45
#include <stdint.h>
56

67
void init_isr() {
@@ -76,6 +77,9 @@ const char *exceptions[] = {"Division by zero",
7677
"Reserved"};
7778

7879
void handler_isr(struct registers *regs) {
80+
if (regs->int_no == 14) {
81+
page_fault(regs);
82+
}
7983

8084
if (regs->int_no <= 31) {
8185
panic(exceptions[regs->int_no]);

kernel/cpu/load_gdt.asm

-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,3 @@ gdt_load:
1313

1414
flush_gdt:
1515
ret
16-
17-
global flush_tss
18-
flush_tss:
19-
mov ax, 0x2B
20-
ltr ax
21-
ret

kernel/cpu/tss.h

-40
This file was deleted.

0 commit comments

Comments
 (0)