Skip to content

Commit 1537cb2

Browse files
committed
Refactoring file and trying to use dependencies as static libraries.
1 parent d75a41d commit 1537cb2

Some content is hidden

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

41 files changed

+523
-530
lines changed

Makefile

Lines changed: 99 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
BL_SRC_DIR = src/bootloader
2-
KERNEL_SRC_DIR = src/kernel
3-
KERNEL_DRIVERS_SRC_DIR = src/kernel/drivers
4-
SYSCALLS_SRC_DIR = src/lib/syscalls
5-
LIB_SRC_DIR = src/lib
6-
UTIL_SRC_DIR = src/lib/util
71
BUILD_DIR = build
8-
APP_DIR = src/app
2+
3+
SRC_BOOTLOADER = src/bootloader
4+
SRC_KERNEL = src/kernel
5+
SRC_DRIVERS = src/drivers
6+
SRC_LIB_UTILS = src/lib/utils
7+
SRC_LIB = src/lib
8+
SRC_APP = src/app
9+
10+
BUILD_BOOTLOADER = build/bootloader
11+
BUILD_KERNEL = build/kernel
12+
BUILD_DRIVERS = build/drivers
13+
BUILD_LIB_UTILS = build/lib/utils
14+
BUILD_LIB = build/lib
15+
BUILD_APP = build/app
916

1017
.PHONY: all clean
1118

1219
# Files
13-
bt_stage1 = $(BUILD_DIR)/bt_stage1
14-
bt_stage2_c_o = $(BUILD_DIR)/bt_stage2_c.o
15-
bt_stage2_asm_o = $(BUILD_DIR)/bt_stage2_asm.o
16-
bt_stage2 = $(BUILD_DIR)/bt_stage2
20+
bt_stage1 = $(BUILD_BOOTLOADER)/stage1
21+
bt_stage2 = $(BUILD_BOOTLOADER)/stage2
1722
image_vmdk = $(BUILD_DIR)/image.vmdk
18-
app_entry_o = $(BUILD_DIR)/app_entry.o
23+
app_entry = $(BUILD_LIB)/app/entry
1924

2025
# Kernel
21-
kernel_core = $(BUILD_DIR)/kernel_core
22-
kernel_core_c_o = $(BUILD_DIR)/kernel_core_c.o
23-
kernel_core_asm_o = $(BUILD_DIR)/kernel_core_asm.o
26+
kernel_core = $(BUILD_DIR)/kernel/core
2427

2528
# Apps
26-
app_calc = $(BUILD_DIR)/calc
27-
app_ttt = $(BUILD_DIR)/ttt
28-
app_dashboard = $(BUILD_DIR)/dashboard
29+
app_calc = $(BUILD_APP)/calc
30+
app_tick_tac_toe = $(BUILD_APP)/tick_tac_toe
31+
app_dashboard = $(BUILD_APP)/dashboard
2932

3033
# Parameters
3134
BT_STAGE2_SECTOR_COUNT = 19 # In Hex
@@ -42,7 +45,7 @@ images: $(image_vmdk)
4245

4346
binaries: $(bt_stage1) $(bt_stage2) $(kernel_core)
4447

45-
$(image_vmdk): $(bt_stage1) $(bt_stage2) $(kernel_core) $(app_calc) $(app_ttt)
48+
$(image_vmdk): $(bt_stage1) $(bt_stage2) $(kernel_core) $(app_calc) $(app_tick_tac_toe)
4649
dd bs=512 count=2 if=$(bt_stage1) of=$@
4750
/bin/echo -ne "\x55\xaa" | dd seek=510 bs=1 of=$@
4851
@echo "Stage 1 Size : " $$(stat -c %s $(bt_stage1))
@@ -57,54 +60,17 @@ $(image_vmdk): $(bt_stage1) $(bt_stage2) $(kernel_core) $(app_calc) $(app_ttt)
5760
@echo "AppCalc Sector Count : "$$(( $$(stat -c %s $(app_calc)) / 512))
5861
@echo "App Calc Size : " $$(stat -c %s $(app_calc))
5962

60-
@echo "AppTTT Sector Start : "$$(( 1 + $$(stat -c %s $(image_vmdk)) / 512 ))
61-
cat $(app_ttt) >> $@
62-
@echo "AppTTT Sector Count : "$$(( $$(stat -c %s $(app_ttt)) / 512))
63-
@echo "App TTT Size : " $$(stat -c %s $(app_ttt))
63+
@echo "App TickTacToe Sector Start : "$$(( 1 + $$(stat -c %s $(image_vmdk)) / 512 ))
64+
cat $(app_tick_tac_toe) >> $@
65+
@echo "App TickTacToe Sector Count : "$$(( $$(stat -c %s $(app_tick_tac_toe)) / 512))
66+
@echo "App TickTacToe Size : " $$(stat -c %s $(app_tick_tac_toe))
6467

6568
@echo "Kernel Core Sector Start : "$$(( 1 + $$(stat -c %s $(image_vmdk)) / 512 ))
6669
cat $(kernel_core) >> $@
6770
@echo "Kernel Core Sector Count : "$$(( $$(stat -c %s $(kernel_core)) / 512))
6871
@echo "Kernel Core Size : " $$(stat -c %s $(kernel_core))
6972
@echo "Image Size : " $$(stat -c %s $@)
7073

71-
$(bt_stage1): $(BL_SRC_DIR)/stage1.asm $(BL_SRC_DIR)/constants.asm $(BL_SRC_DIR)/io.asm $(BL_SRC_DIR)/disk.asm
72-
nasm -o $@ -f bin -i $(BL_SRC_DIR)/ -D BT_STAGE2_SECTOR_COUNT=$(BT_STAGE2_SECTOR_COUNT) $<
73-
truncate --size=%512 $@
74-
75-
$(bt_stage2): $(bt_stage2_asm_o) $(bt_stage2_c_o)
76-
ld --oformat binary -m elf_i386 -Ttext 0x8000 --strip-all -o $@ $^
77-
truncate --size=%512 $@
78-
79-
$(bt_stage2_c_o): $(BL_SRC_DIR)/stage2.c $(SYSCALLS_SRC_DIR)/basic.h $(SYSCALLS_SRC_DIR)/io.h $(SYSCALLS_SRC_DIR)/time.h $(SYSCALLS_SRC_DIR)/color.h $(UTIL_SRC_DIR)/string.h $(APP_DIR)/dashboard.c
80-
gcc -m16 -fno-pie -c -Isrc -o $@ $<
81-
82-
$(bt_stage2_asm_o): $(BL_SRC_DIR)/stage2.asm $(BL_SRC_DIR)/constants.asm $(BL_SRC_DIR)/io.asm $(SYSCALLS_SRC_DIR)/io_interface_bios.asm $(SYSCALLS_SRC_DIR)/time_syscall.asm $(bt_stage2_o) $(SYSCALLS_SRC_DIR)/disk_syscall.asm
83-
nasm -o $@ -f elf32 -i $(BL_SRC_DIR)/ -i$(SYSCALLS_SRC_DIR)/ $<
84-
85-
$(kernel_core): $(kernel_core_asm_o) $(kernel_core_c_o)
86-
ld --oformat binary -m elf_i386 -Ttext 0xC000 --strip-all -o $@ $^
87-
truncate --size=%512 $@
88-
89-
$(kernel_core_asm_o): $(KERNEL_SRC_DIR)/core.asm
90-
nasm -o $@ -f elf32 -i $(KERNEL_SRC_DIR)/ -i $(KERNEL_DRIVERS_SRC_DIR)/ -i$(SYSCALLS_SRC_DIR)/ $<
91-
92-
$(kernel_core_c_o): $(KERNEL_SRC_DIR)/core.c
93-
gcc -m16 -fno-pie -c -D__SOURCE_SNAPSHOT__=$(SOURCE_SNAPSHOT) -Isrc -o $@ $<
94-
95-
$(app_entry_o): $(LIB_SRC_DIR)/app/entry.asm $(BL_SRC_DIR)/constants.asm $(BL_SRC_DIR)/io.asm $(SYSCALLS_SRC_DIR)/io_interface_bios.asm $(SYSCALLS_SRC_DIR)/time_syscall.asm
96-
nasm -o $@ -f elf32 -i $(BL_SRC_DIR)/ -i$(SYSCALLS_SRC_DIR)/ $<
97-
98-
$(app_calc): $(app_entry_o) $(APP_DIR)/calc.c $(SYSCALLS_SRC_DIR)/basic.h $(SYSCALLS_SRC_DIR)/io.h $(SYSCALLS_SRC_DIR)/time.h $(SYSCALLS_SRC_DIR)/color.h $(UTIL_SRC_DIR)/string.h $(BL_SRC_DIR)/constants.asm $(BL_SRC_DIR)/io.asm $(SYSCALLS_SRC_DIR)/io_interface_bios.asm $(SYSCALLS_SRC_DIR)/time_syscall.asm
99-
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_DIR)/calc.o $(APP_DIR)/calc.c
100-
ld --oformat binary -m elf_i386 -Ttext 0x2000 --strip-all -o $@ $(app_entry_o) $(BUILD_DIR)/calc.o
101-
truncate --size=%512 $@
102-
103-
$(app_ttt): $(app_entry_o) $(APP_DIR)/tic_tac_toe.c $(SYSCALLS_SRC_DIR)/basic.h $(SYSCALLS_SRC_DIR)/io.h $(SYSCALLS_SRC_DIR)/time.h $(SYSCALLS_SRC_DIR)/color.h $(UTIL_SRC_DIR)/string.h $(BL_SRC_DIR)/constants.asm $(BL_SRC_DIR)/io.asm $(SYSCALLS_SRC_DIR)/io_interface_bios.asm $(SYSCALLS_SRC_DIR)/time_syscall.asm
104-
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_DIR)/ttt.o $(APP_DIR)/tic_tac_toe.c
105-
ld --oformat binary -m elf_i386 -Ttext 0xC000 --strip-all -o $@ $(app_entry_o) $(BUILD_DIR)/ttt.o
106-
truncate --size=%512 $@
107-
10874
debug_stage1: $(bt_stage1)
10975
objdump -b binary -mi386 -Maddr16,data16 -D $<
11076
xxd $<
@@ -113,31 +79,85 @@ debug_stage2: $(bt_stage2)
11379
objdump -b binary -mi386 -Maddr16,data16 -D $<
11480
xxd $<
11581

116-
debug_stage2_c: $(bt_stage2_c_o)
117-
objdump -d -Maddr16,data16 $<
118-
xxd $<
119-
120-
debug_stage2_asm: $(bt_stage2_asm_o)
121-
objdump -d -Maddr16,data16 $<
122-
xxd $<
123-
12482
debug_kernel: $(kernel_core)
12583
objdump -b binary -mi386 -Maddr16,data16 -D $<
12684
xxd $<
12785

128-
debug_kernel_c: $(kernel_core_c_o)
129-
objdump -d -Maddr16,data16 $<
130-
xxd $<
131-
132-
debug_kernel_asm: $(kernel_core_asm_o)
133-
objdump -d -Maddr16,data16 $<
134-
xxd $<
135-
136-
qemu: $(image_vmdk) images
86+
qemu: $(image_vmdk)
13787
cpulimit -f -l 10 -- qemu-system-x86_64 -smp 1 -m 128M -hda $< -no-shutdown -no-reboot
13888

139-
qemu_debug: $(image_vmdk) images
89+
qemu_debug: $(image_vmdk)
14090
qemu-system-x86_64 -smp 1 -m 128M -hda $< -no-shutdown -no-reboot -d cpu,exec,in_asm
14191

14292
clean:
143-
rm -f $(image_vmdk) $(bt_stage1) $(bt_stage2) $(bt_stage2_c_o) $(bt_stage2_asm_o) $(kernel_core) $(kernel_core_c_o) $(kernel_core_asm_o) $(app_calc) $(app_ttt)
93+
rm -r $(BUILD_DIR)/ || echo "Build directory is clean."
94+
95+
# Fuzzy OS
96+
$(bt_stage1): $(SRC_BOOTLOADER)/stage1.asm $(SRC_BOOTLOADER)/constants.asm $(SRC_BOOTLOADER)/io.asm $(SRC_BOOTLOADER)/disk.asm
97+
mkdir -p $$(dirname $(bt_stage1))
98+
nasm -o $@ -f bin -i $(SRC_BOOTLOADER)/ -D BT_STAGE2_SECTOR_COUNT=$(BT_STAGE2_SECTOR_COUNT) $<
99+
truncate --size=%512 $@
100+
101+
$(bt_stage2): $(SRC_BOOTLOADER)/stage2.asm $(SRC_BOOTLOADER)/stage2.c $(SRC_BOOTLOADER)/io.asm $(SRC_BOOTLOADER)/constants.asm $(BUILD_LIB_UTILS)/libutils $(BUILD_DRIVERS)/display/libtm_bios
102+
mkdir -p $$(dirname $(bt_stage2))
103+
nasm -o $(BUILD_BOOTLOADER)/stage2_asm.o -f elf32 -i $(SRC_BOOTLOADER)/ $(SRC_BOOTLOADER)/stage2.asm
104+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_BOOTLOADER)/stage2_c.o $(SRC_BOOTLOADER)/stage2.c
105+
ld --oformat binary -m elf_i386 -Ttext 0x8000 --strip-all -o $@ $(BUILD_BOOTLOADER)/stage2_asm.o $(BUILD_BOOTLOADER)/stage2_c.o $(BUILD_LIB_UTILS)/libutils $(BUILD_DRIVERS)/display/libtm_bios
106+
truncate --size=%512 $@
107+
108+
$(kernel_core): $(SRC_KERNEL)/core.asm $(SRC_KERNEL)/core.c $(SRC_KERNEL)/essentials.c $(SRC_LIB_UTILS)/io.h $(BUILD_LIB_UTILS)/libutils $(BUILD_DRIVERS)/display/libtm_vga # And other io.h dependecies -_-
109+
mkdir -p $$(dirname $(kernel_core))
110+
nasm -o $(BUILD_KERNEL)/core_asm.o -f elf32 $(SRC_KERNEL)/core.asm
111+
gcc -m16 -fno-pie -c -D__SOURCE_SNAPSHOT__=$(SOURCE_SNAPSHOT) -Isrc -o $(BUILD_KERNEL)/core_c.o $(SRC_KERNEL)/core.c
112+
ld --oformat binary -m elf_i386 -Ttext 0xC000 --strip-all -o $(kernel_core) $(BUILD_KERNEL)/core_asm.o $(BUILD_KERNEL)/core_c.o $(BUILD_LIB_UTILS)/libutils $(BUILD_DRIVERS)/display/libtm_vga
113+
truncate --size=%512 $(kernel_core)
114+
115+
# Libraries
116+
117+
$(app_entry): $(SRC_LIB)/app/entry.asm
118+
mkdir -p $$(dirname $(app_entry))
119+
nasm -o $@ -f elf32 $<
120+
121+
$(BUILD_DRIVERS)/display/libtm_bios: $(SRC_DRIVERS)/display/text_mode_bios.c $(SRC_DRIVERS)/display/text_mode_bios.asm $(SRC_DRIVERS)/display/text_mode.h
122+
mkdir -p $(BUILD_DRIVERS)/display/
123+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_DRIVERS)/display/text_mode_bios_c.o $(SRC_DRIVERS)/display/text_mode_bios.c
124+
nasm -o $(SRC_DRIVERS)/display/text_mode_bios_asm.o -f elf32 $(SRC_DRIVERS)/display/text_mode_bios.asm
125+
ar rc $@ $(BUILD_DRIVERS)/display/text_mode_bios_c.o $(SRC_DRIVERS)/display/text_mode_bios_asm.o
126+
127+
$(BUILD_DRIVERS)/display/libtm_vga: $(SRC_DRIVERS)/display/text_mode_vga.c $(SRC_DRIVERS)/display/text_mode_vga.asm $(SRC_DRIVERS)/display/text_mode.h
128+
mkdir -p $(BUILD_DRIVERS)/display/
129+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_DRIVERS)/display/text_mode_vga_c.o $(SRC_DRIVERS)/display/text_mode_vga.c
130+
nasm -o $(SRC_DRIVERS)/display/text_mode_vga_asm.o -f elf32 $(SRC_DRIVERS)/display/text_mode_vga.asm
131+
ar rc $@ $(BUILD_DRIVERS)/display/text_mode_vga_c.o $(SRC_DRIVERS)/display/text_mode_vga_asm.o
132+
133+
$(BUILD_DRIVERS)/keyboard/libkeyboard: $(SRC_DRIVERS)/keyboard/keyboard.c $(SRC_DRIVERS)/keyboard/keyboard.asm
134+
mkdir -p $(BUILD_DRIVERS)/keyboard/
135+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_DRIVERS)/keyboard/keyboard_c.o $(SRC_DRIVERS)/keyboard/keyboard.c
136+
nasm -o $(SRC_DRIVERS)/keyboard/keyboard_asm.o -f elf32 $(SRC_DRIVERS)/keyboard/keyboard.asm
137+
ar rc $@ $(BUILD_DRIVERS)/keyboard/keyboard_c.o $(SRC_DRIVERS)/keyboard/keyboard_asm.o
138+
139+
$(BUILD_LIB_UTILS)/libutils: $(SRC_LIB_UTILS)/io.c $(SRC_LIB_UTILS)/io.h $(SRC_LIB_UTILS)/string.c $(SRC_LIB_UTILS)/string.h $(SRC_LIB_UTILS)/disk.c $(SRC_LIB_UTILS)/disk.asm $(SRC_LIB_UTILS)/disk.h $(SRC_LIB_UTILS)/panic.c $(SRC_LIB_UTILS)/panic.h $(SRC_LIB_UTILS)/panic.asm $(SRC_LIB_UTILS)/time.c $(SRC_LIB_UTILS)/time.h $(SRC_LIB_UTILS)/time.asm $(SRC_LIB_UTILS)/color.c $(SRC_LIB_UTILS)/color.h
140+
mkdir -p $(BUILD_LIB_UTILS)/
141+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_LIB_UTILS)/io.o $(SRC_LIB_UTILS)/io.c
142+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_LIB_UTILS)/string.o $(SRC_LIB_UTILS)/string.c
143+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_LIB_UTILS)/color.o $(SRC_LIB_UTILS)/color.c
144+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_LIB_UTILS)/disk_c.o $(SRC_LIB_UTILS)/disk.c
145+
nasm -o $(BUILD_LIB_UTILS)/disk_asm.o -f elf32 $(SRC_LIB_UTILS)/disk.asm
146+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_LIB_UTILS)/panic_c.o $(SRC_LIB_UTILS)/panic.c
147+
nasm -o $(BUILD_LIB_UTILS)/panic_asm.o -f elf32 $(SRC_LIB_UTILS)/panic.asm
148+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_LIB_UTILS)/time_c.o $(SRC_LIB_UTILS)/time.c
149+
nasm -o $(BUILD_LIB_UTILS)/time_asm.o -f elf32 $(SRC_LIB_UTILS)/time.asm
150+
ar rc $@ $(BUILD_LIB_UTILS)/io.o $(BUILD_LIB_UTILS)/string.o $(BUILD_LIB_UTILS)/color.o $(BUILD_LIB_UTILS)/disk_c.o $(BUILD_LIB_UTILS)/disk_asm.o $(BUILD_LIB_UTILS)/panic_c.o $(BUILD_LIB_UTILS)/panic_asm.o $(BUILD_LIB_UTILS)/time_c.o $(BUILD_LIB_UTILS)/time_asm.o
151+
152+
# User Applications
153+
$(app_calc): $(app_entry) $(SRC_APP)/calc.c $(SRC_LIB_UTILS)/io.h $(SRC_LIB_UTILS)/time.h $(BUILD_LIB_UTILS)/libutils # And dependecies :/
154+
mkdir -p $$(dirname $(app_calc))
155+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_APP)/calc.o $(SRC_APP)/calc.c
156+
ld --oformat binary -m elf_i386 -Ttext 0x2000 --strip-all -o $@ $(app_entry) $(BUILD_APP)/calc.o $(BUILD_LIB_UTILS)/libutils $(BUILD_DRIVERS)/display/libtm_vga
157+
truncate --size=%512 $@
158+
159+
$(app_tick_tac_toe): $(app_entry) $(SRC_APP)/tic_tac_toe.c $(SRC_LIB_UTILS)/io.h $(SRC_LIB_UTILS)/time.h $(BUILD_LIB_UTILS)/libutils # And dependecies :/
160+
mkdir -p $$(dirname $(app_tick_tac_toe))
161+
gcc -m16 -fno-pie -c -Isrc -o $(BUILD_APP)/tic_tac_toe.o $(SRC_APP)/tic_tac_toe.c
162+
ld --oformat binary -m elf_i386 -Ttext 0x2000 --strip-all -o $@ $(app_entry) $(BUILD_APP)/tic_tac_toe.o $(BUILD_LIB_UTILS)/libutils $(BUILD_DRIVERS)/display/libtm_vga
163+
truncate --size=%512 $@

build/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/app/calc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ void print_int(int x) {
1212
printf("%d", x);
1313
}
1414
#else
15-
#include <lib/syscalls/io.h>
16-
#include <lib/syscalls/io_interface_protected.c>
17-
#include <lib/syscalls/time.h>
18-
#include <lib/util/string.h>
15+
#include <lib/utils/io.h>
16+
#include <lib/utils/time.h>
17+
#include <lib/utils/string.h>
1918
#endif
2019

2120
int err;
@@ -107,7 +106,7 @@ int handle_expression(char str[]) {
107106
void console_init() {
108107
set_color_bg(C_BLACK);
109108
set_color_fg(C_WHITE);
110-
print_rectangle(0, 0, WINDOW_WIDTH-1, WINDOW_HEIGHT-1);
109+
print_rectangle(0, 0, TEXT_WINDOW_WIDTH-1, TEXT_WINDOW_HEIGHT-1);
111110
move_xy(0,0);
112111
}
113112

src/app/dashboard.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#include <app/calc.c>
2-
#include <lib/syscalls/io_interface_bios.c>
3-
#include <lib/syscalls/io.h>
4-
#include <lib/syscalls/time.h>
5-
#include <lib/syscalls/color.h>
6-
#include <lib/syscalls/disk.h>
7-
#include <lib/util/string.h>
2+
#include <lib/utils/io.h>
3+
#include <lib/utils/time.h>
4+
#include <lib/utils/color.h>
5+
#include <lib/utils/disk.h>
6+
#include <lib/utils/string.h>
87

98
char query_app_number[] = "Enter Application Number: ";
109
char application_list[5][15] = {"Calculator", "Sample 2", "Sample 3", "Sample 4", "Sample 5"};

src/app/tic_tac_toe.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
#define BUILD_FOR_FUZZY
33
#ifndef BUILD_FOR_FUZZY
44
#else
5-
#include <lib/syscalls/io_interface_protected.c>
6-
#include <lib/syscalls/io.h>
7-
#include <lib/syscalls/time.h>
8-
#include <lib/util/string.h>
5+
#include <lib/utils/io.h>
6+
#include <lib/utils/time.h>
7+
#include <lib/utils/string.h>
98
#endif
109

1110
void console_init() {
1211
set_color_bg(C_BLACK);
1312
set_color_fg(C_WHITE);
14-
print_rectangle(0, 0, WINDOW_WIDTH-1, WINDOW_HEIGHT-1);
13+
print_rectangle(0, 0, TEXT_WINDOW_WIDTH-1, TEXT_WINDOW_HEIGHT-1);
1514
move_xy(0,0);
1615
}
1716

src/bootloader/stage2.asm

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
; Fuzzy Bootloader Stage 2
22
%include "constants.asm"
33
%include "io.asm"
4-
%include "io_interface_bios.asm"
5-
%include "time_syscall.asm"
6-
%include "disk_syscall.asm"
74

85
[BITS 16]
96

@@ -19,7 +16,6 @@ global label_exit
1916

2017
print_string_ext bl_stage_2, bl_stage_2_len, 04, 09, C_WHITE, C_BLACK, 0
2118
call entry_stage
22-
JMP label_exit
2319

2420
enter_protected_mode:
2521
; Args: (gdtr_address)
@@ -49,10 +45,6 @@ global label_exit
4945
HLT
5046
JMP label_exit
5147

52-
PLUGIN_SYSCALLS_IO
53-
PLUGIN_SYSCALLS_TIME
54-
PLUGIN_SYSCALLS_DISK
55-
5648

5749
[SECTION .data]
5850
bl_stage_2 db "Bootloader: Stage 2"
@@ -69,23 +61,5 @@ global label_exit
6961
mov fs, ax
7062
mov gs, ax
7163

72-
; Print Done
73-
mov ah,0x0F
74-
mov ebx,0xb8000
75-
mov al,'D'
76-
mov [ebx],ax
77-
78-
add ebx, 2
79-
mov al,'o'
80-
mov [ebx],ax
81-
82-
add ebx, 2
83-
mov al,'n'
84-
mov [ebx],ax
85-
86-
add ebx, 2
87-
mov al,'e'
88-
mov [ebx],ax
89-
9064
; Hardcoded Kernel Load Address
9165
jmp 0x08:0xC000

src/bootloader/stage2.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#include <lib/syscalls/color.h>
2-
#include <lib/syscalls/disk.h>
3-
#include <lib/syscalls/io_interface_bios.c>
4-
#include <lib/syscalls/io.h>
5-
#include <lib/syscalls/time.h>
1+
#include <lib/utils/color.h>
2+
#include <lib/utils/disk.h>
3+
#include <lib/utils/io.h>
4+
#include <lib/utils/time.h>
65

76
char message_welcome[] = "C says 'Hello World'";
87
char message_dashboard[] = "Opening App 'Dashboard'";
@@ -87,7 +86,8 @@ int populate_gdt_table() {
8786
void load_kernel() {
8887
int err = load_sectors(0xC000, 0x80, DISK_KERNEL_SECTOR_START, DISK_KERNEL_SECTOR_COUNT);
8988
if(err) {
90-
print_line("Failed to load kernel in memory.");
89+
print_line("Failed to load kernel in memory: ");
90+
print_int(err);
9191
label_exit();
9292
} else {
9393
print_memory_hex((char*)0xC000, 16);
@@ -98,6 +98,7 @@ void load_calc() {
9898
int err = load_sectors(0x2000, 0x80, 27, 25);
9999
if(err) {
100100
print_line("Failed to load calc in memory.");
101+
print_int(err);
101102
label_exit();
102103
} else {
103104
print_memory_hex((char*)0x2000, 16);
@@ -119,7 +120,7 @@ void entry_stage() {
119120
move_xy(6, 14);
120121
print_line(message_protected_mode);
121122
int gdtr_address = populate_gdt_table();
122-
// Note: enter_protected_mode never returns.
123+
// Enter_protected_mode never returns.
123124
enter_protected_mode(gdtr_address);
124-
// PC should never reach here :)
125+
// And thus PC should never reach here :)
125126
}

0 commit comments

Comments
 (0)