Skip to content

Commit 1a974c3

Browse files
committed
no more kernel, this is a bootloader
1 parent b6856c0 commit 1a974c3

32 files changed

+18
-708
lines changed

Makefile

+16-43
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,20 @@
1-
# Automatically generate lists of sources using wildcard.
2-
C_SOURCES = $(wildcard kernel/*.c kernel/drivers/vga/*.c drivers/*.c kernel/drivers/io/*.c)
3-
HEADERS = $(wildcard kernel/*.h kernel/drivers/vga/*.h drivers/*.h kernel/drivers/io/*.h)
1+
all:
2+
# actual bootloader
3+
nasm -f elf stage2/start_loader.asm -o start_loader.o
4+
5+
x86_64-elf-gcc -m32 -ffreestanding -c stage2/fs.c -o fs.o
6+
x86_64-elf-gcc -m32 -ffreestanding -c stage2/mbr.c -o mbr.o
7+
x86_64-elf-gcc -m32 -ffreestanding -c stage2/loader.c -o loader.o
48

5-
# Convert *.c filenames to *.o as a list of object files to build.
6-
OBJ = ${C_SOURCES:.c=.o}
9+
x86_64-elf-ld -melf_i386 -o bootloader.bin -Ttext 0x1000 --oformat binary start_loader.o loader.o fs.o mbr.o
710

8-
# Clean, build, and run.
9-
all: clean os-image run
11+
# stage1
12+
nasm -f bin stage1/load_kernel.asm -o load_kernel.bin -D USE_GRAPHICS
1013

11-
# Removes all built files.
1214
clean:
13-
rm -f boot/*.bin
14-
rm -f drivers/*.o
15-
rm -f example/*.bin example/*.o
16-
rm -f kernel/*.bin kernel/*.o
17-
rm -f kernel/drivers/vga/*.o
18-
rm -f os-image
19-
20-
# Kernel code --------------------------------------------------------------------------------------
21-
22-
# Create kernel binary by linking kernel entry code, kernel main, and other object files.
23-
kernel/kernel.bin: kernel/enter_kernel.o $(OBJ)
24-
x86_64-elf-ld -melf_i386 -o $@ -Ttext 0x1000 --oformat binary $^
25-
26-
# Create executable image by prepending kernel binary with boot sector.
27-
os-image: boot/load_kernel.bin kernel/kernel.bin
28-
cat $^ > $@
29-
30-
# Compile assembly sources into binary.
31-
%.bin: %.asm
32-
nasm $< -f bin -o $@ -D USE_GRAPHICS
33-
#nasm $< -f bin -o $@
34-
35-
# Assemble the kernel entry to an object file.
36-
%.o: %.asm
37-
nasm $< -f elf -o $@
38-
39-
# Compile C sources into object files.
40-
%.o: %.c
41-
x86_64-elf-gcc -m32 -ffreestanding -c $< -o $@
42-
43-
# --------------------------------------------------------------------------------------------------
44-
45-
# Run operating system on emulated x86.
46-
run: os-image
47-
qemu-system-x86_64 -drive file=$<,format=raw -net none -no-reboot -no-shutdown -monitor stdio --enable-kvm
15+
rm -f load_kernel.bin
16+
rm -f start_loader.o
17+
rm -f loader.o
18+
rm -f bootloader.bin
19+
rm -f fs.o
20+
rm -f mbr.o

bochsrc.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
megs: 128
22
romimage: file=/usr/share/bochs/BIOS-bochs-latest, address=0xfffe0000
33
vgaromimage: file=/home/dev/VGABIOS/VGABIOS-lgpl-latest.bin
4-
floppya: 1_44=os-image, status=inserted
5-
boot: floppy
4+
ata0-master: type=disk, path="image.img", mode=flat
5+
boot: disk
66
mouse: enabled=0

boot/Makefile

-20
This file was deleted.

boot/image.img

-10 MB
Binary file not shown.

kernel/drivers/disk/disk.asm.demo

-67
This file was deleted.

kernel/drivers/disk/disk.c

-44
This file was deleted.

kernel/drivers/disk/disk.h

-3
This file was deleted.

kernel/drivers/io/io.c

-15
This file was deleted.

kernel/drivers/io/io.h

-4
This file was deleted.

kernel/drivers/serial/serial.c

-51
This file was deleted.

kernel/drivers/serial/serial.h

-2
This file was deleted.

0 commit comments

Comments
 (0)