Initial commit
This commit is contained in:
parent
cd38e24806
commit
276928841a
|
@ -0,0 +1,5 @@
|
|||
/**/*.o
|
||||
/**/*.bin
|
||||
/**/*.img
|
||||
/bochsout.txt
|
||||
/bx_enh_dbg.ini
|
|
@ -0,0 +1,40 @@
|
|||
CC = gcc
|
||||
LD = ld
|
||||
|
||||
CFLAGS = -O2 -pipe -Wall -Wextra
|
||||
|
||||
INTERNAL_CFLAGS = \
|
||||
-m16 \
|
||||
-ffreestanding \
|
||||
-nostdlib \
|
||||
-masm=intel \
|
||||
-fno-pic \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-I.
|
||||
|
||||
LDFLAGS =
|
||||
|
||||
INTERNAL_LDFLAGS = \
|
||||
-m elf_i386 \
|
||||
-nostdlib \
|
||||
-Tlinker.ld
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
C_FILES := $(shell find ./ -type f -name '*.c')
|
||||
OBJ := $(C_FILES:.c=.o)
|
||||
|
||||
all: qloader2.bin
|
||||
|
||||
qloader2.bin: $(OBJ)
|
||||
$(LD) $(LDFLAGS) $(INTERNAL_LDFLAGS) $(OBJ) -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
cpu: count=2, reset_on_triple_fault=0
|
||||
|
||||
display_library: x, options="gui_debug"
|
||||
|
||||
megs: 512
|
||||
|
||||
clock: sync=realtime, time0=local
|
||||
|
||||
ata0-master: type=disk, path="qloader2.img", mode=flat
|
||||
|
||||
boot: c
|
||||
|
||||
log: ./bochsout.txt
|
||||
|
||||
mouse: enabled=0
|
||||
|
||||
magic_break: enabled=1
|
|
@ -0,0 +1,21 @@
|
|||
OUTPUT_FORMAT(binary)
|
||||
ENTRY(main)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x7c00;
|
||||
|
||||
.text : {
|
||||
bootsect_begin = .;
|
||||
KEEP(*(.early_boot*))
|
||||
KEEP(*(.text*))
|
||||
}
|
||||
|
||||
.data : {
|
||||
KEEP(*(.data*))
|
||||
KEEP(*(.bss*))
|
||||
. += 510 - (. - bootsect_begin);
|
||||
SHORT(0xaa55)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
asm (
|
||||
".section .early_boot\n\t"
|
||||
"cli\n\t"
|
||||
"jmp 0x0:1f\n\t"
|
||||
"1:\n\t"
|
||||
"xor ax, ax\n\t"
|
||||
"mov ds, ax\n\t"
|
||||
"mov es, ax\n\t"
|
||||
"mov fs, ax\n\t"
|
||||
"mov gs, ax\n\t"
|
||||
"mov ss, ax\n\t"
|
||||
"mov sp, 0x7c00\n\t"
|
||||
"xor dh, dh\n\t"
|
||||
"push edx\n\t"
|
||||
"call main\n\t"
|
||||
);
|
||||
|
||||
void bios_print(const char *str) {
|
||||
asm (
|
||||
"1:\n\t"
|
||||
"lodsb\n\t"
|
||||
"test al, al\n\t"
|
||||
"jz 2f\n\t"
|
||||
"int 0x10\n\t"
|
||||
"jmp 1b\n\t"
|
||||
"2:\n\t"
|
||||
:
|
||||
: "a"(0x0e00), "S"(str)
|
||||
: "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void main(int boot_drive) {
|
||||
// TODO
|
||||
bios_print("hello world from qloader2");
|
||||
for (;;);
|
||||
}
|
Loading…
Reference in New Issue