blob: c983fb6416d59065b79bd68085507c8c8af9cb2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
CC := gcc
CFLAGS := -std=c99 -m32 -ffreestanding -O0 -g -Wall -Werror
LD := ld
all: image.bin
image.bin: boot.bin kernel.bin
cat boot.bin kernel.bin > image.bin
# truncate to correct number of sectors, we have
# 512 (boot, first stage) + N * 512 (N currenty is 3) + M * 512 (M is currently 3)
truncate -s 4096 image.bin
boot.bin: boot.asm gdt.asm stage1_functions.asm stage2_functions.asm switch_mode.asm
nasm boot.asm -f bin -o boot.bin
kernel.bin: kernel.o vga.o string.o
$(LD) -o kernel.bin -n -Ttext 0x8000 --oformat binary \
kernel.o vga.o string.o
kernel.o: kernel.c
$(CC) $(CFLAGS) -O0 -c -o kernel.o kernel.c
vga.o: vga.c
$(CC) $(CFLAGS) -O0 -c -o vga.o vga.c
string.o: string.c
$(CC) $(CFLAGS) -O0 -c -o string.o string.c
clean:
-rm -f boot.bin kernel.bin image.bin *.o
run-qemu: image.bin
qemu-system-i386 -m 32 -drive "file=image.bin,if=ide,format=raw"
run-bochs:
bochs -q -f bochs.config 'boot:floppy' 'floppya: 1_44=image.bin, status=inserted'
|