Initial commit
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..d363c0ae
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+/**/*.o
+/**/*.bin
+/**/*.img
+/bochsout.txt
+/bx_enh_dbg.ini
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..b4fe92e0
--- /dev/null
+++ b/Makefile
@@ -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)
+
diff --git a/bochsrc b/bochsrc
new file mode 100644
index 00000000..990bafdd
--- /dev/null
+++ b/bochsrc
@@ -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
diff --git a/linker.ld b/linker.ld
new file mode 100644
index 00000000..31218ae9
--- /dev/null
+++ b/linker.ld
@@ -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)
+ }
+
+}
diff --git a/main.c b/main.c
new file mode 100644
index 00000000..374c915b
--- /dev/null
+++ b/main.c
@@ -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 (;;);
+}
