summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-14 03:30:52 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-14 03:30:52 +0100
commit03fb41e835ff4d10325351c1460e9445e4b572ca (patch)
treef9438c664583e5a1be5339fb5cbfc9bcc1895453
parent51c9f5abe06571845191b31f7442370ccb26f83a (diff)
improving build system
-rw-r--r--Makefile40
-rw-r--r--Makefile.common11
-rw-r--r--boot/Makefile16
-rw-r--r--boot/stage2.asm14
-rw-r--r--boot0/Makefile16
-rw-r--r--boot0/mbr.asm4
-rw-r--r--boot0/print_string_16.asm115
7 files changed, 182 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index 0fc5520..87ecc15 100644
--- a/Makefile
+++ b/Makefile
@@ -48,42 +48,30 @@ DEPS=$(patsubst %.c, %.d, $(SOURCES))
ASMOBJECTS=$(patsubst %.asm, %.o, $(ASMSOURCES))
KERNEL_ENTRY=./boot/kernel_entry.o
-#master boot record asm
+############ final image (default target) ############
+all: FoolOS.vdi
+new: clean all
+newrun: clean run
+
+include Makefile.common
+-include $(DEPS)
+#master boot record
MBR=./boot0/mbr.bin
+$(MBR):
+ make -C boot0
#stage 2 bootloader
STAGE2=./boot/stage2.bin
+$(STAGE2):
+ make -C boot
#multiprocessor binary entry
MP_BIN=./boot/mp.bin
-
#some fillup data (zeros)
FILLUP=./data/fill.bin
-
-############ final image (default target) ############
-all: FoolOS.vdi
-new: clean all
-newrun: clean run
-
-############ nasm assembling rules ############
-
-%.o: %.asm
- nasm -f elf $^ -o $@
-
-%.bin: %.asm
- nasm -f bin $^ -o $@
-
-%.o: %.c
- $(CC) -c $(CFLAGS) $*.c -o $*.o
- $(CC) -MM -MT $*.o $(CFLAGS) $*.c > $*.d
-
-
-# include dependancies of our object files
--include $(DEPS)
-
############ linking kernel binary ############
@@ -93,7 +81,6 @@ kernel.bin: $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS)
############ fool-font ############
-
binfont.bin: data/binfont.src
python tools/binarize.py $< $@
@@ -140,6 +127,8 @@ stick: FoolOS.img
clean_release:
-rm *.bin FoolData.img binfont.img bochs.log $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS) $(FILLUP) $(MBR) $(MP_BIN) bochs.out ne2k-tx.log ne2k-txdump.txt $(STAGE2) $(DEPS)
make -C userspace clean
+ make -C boot0 clean
+ make -C boot clean
clean: clean_release
-rm FoolOS.img FoolOS.vdi
@@ -148,6 +137,7 @@ release: new
-mv FoolOS.img release/
make clean_release
+####### userspace #########
userspace/ext2.img:
make -C userspace
diff --git a/Makefile.common b/Makefile.common
new file mode 100644
index 0000000..304356b
--- /dev/null
+++ b/Makefile.common
@@ -0,0 +1,11 @@
+%.o: %.asm
+ nasm -f elf $*.asm -o $@
+
+%.bin: %.asm
+ nasm -f bin $*.asm -o $@
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) $*.c -o $*.o
+ $(CC) -MM -MT $*.o $(CFLAGS) $*.c > $*.d
+
+
diff --git a/boot/Makefile b/boot/Makefile
new file mode 100644
index 0000000..17dc454
--- /dev/null
+++ b/boot/Makefile
@@ -0,0 +1,16 @@
+#master boot record
+
+include ../Makefile.common
+
+STAGE2=stage2.bin
+
+ASM_SOURCES=$(wildcard *.asm)
+
+$(STAGE2): $(ASM_SOURCES)
+
+clean:
+ -rm $(STAGE2)
+
+
+
+
diff --git a/boot/stage2.asm b/boot/stage2.asm
index 6ac0fd1..0a3ee87 100644
--- a/boot/stage2.asm
+++ b/boot/stage2.asm
@@ -73,25 +73,25 @@ STR_PM:
;
;;lets put our temporary GDT (Global Descriptor Table) here
;;kernel should move this away
-%include "boot/GDT.asm"
+%include "GDT.asm"
;
;;include 16-bit real mode routines (print_string, disk_load, vesa_setup,check_a20)
-%include "boot/disk_load_16.asm"
+%include "disk_load_16.asm"
;%include "boot/check_a20_16.asm"
-%include "boot/print_string_16.asm"
-%include "boot/vesa_setup_16.asm"
+%include "print_string_16.asm"
+%include "vesa_setup_16.asm"
;
;;include our routines for switching to 32-bit protected mode
-%include "boot/pm.asm"
+%include "pm.asm"
;include some pm mode helpers
-%include "boot/common_pm.asm"
+%include "common_pm.asm"
;
;
;
;;get memory map routine
-%include "boot/memmap.asm"
+%include "memmap.asm"
;
;;;;;;;;; BOOT 16-bit real ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
diff --git a/boot0/Makefile b/boot0/Makefile
new file mode 100644
index 0000000..e930498
--- /dev/null
+++ b/boot0/Makefile
@@ -0,0 +1,16 @@
+#master boot record
+
+include ../Makefile.common
+
+MBR=mbr.bin
+
+ASM_SOURCES=$(wildcard *.asm)
+
+$(MBR): $(ASM_SOURCES)
+
+clean:
+ -rm $(MBR)
+
+
+
+
diff --git a/boot0/mbr.asm b/boot0/mbr.asm
index 1673c0c..c0a555d 100644
--- a/boot0/mbr.asm
+++ b/boot0/mbr.asm
@@ -40,8 +40,8 @@ STR_BOOT: db "Boot drive: ",0
BOOT_DRIVE: db 0xff
; include print and disk load routines
-%include "boot/print_string_16.asm"
-%include "boot0/disk_load_16.asm"
+%include "print_string_16.asm"
+%include "disk_load_16.asm"
; Here we start!
stage1:
diff --git a/boot0/print_string_16.asm b/boot0/print_string_16.asm
new file mode 100644
index 0000000..9f81a87
--- /dev/null
+++ b/boot0/print_string_16.asm
@@ -0,0 +1,115 @@
+[bits 16]
+
+BLANK:
+ db 0x12
+
+SPACE:
+ db " ",0
+
+;print_string routine ([bx])
+;this routine will print a null terminated string at [bx] to the screen.
+print_string:
+
+ pusha ;push all registers
+ mov ah,0x0e
+
+ print_string_loop:
+
+ ;check if value at [bx] is "\0" (end of string)
+ mov cl,[bx]
+ cmp cl,0
+ je print_string_finish
+
+ ;otherwise instruct BIOS to print the current char
+ mov al,cl
+ int 0x10
+
+ ;proceed with next char
+ inc bx
+ jmp print_string_loop
+
+ print_string_finish:
+
+ popa ;pop all registers
+ ret ;return to caller
+
+print_clear:
+
+pusha
+ mov ah,0x6 ;func
+ mov al,0 ;scroll one line
+ mov bh,[BLANK] ;blank char
+
+ mov ch,0 ;upper left corner
+ mov cl,0
+ mov dh,20 ;lower right corner
+ mov dl,40
+ int 0x10
+
+ mov ah,0x2
+ mov bh,0
+ mov dl,0
+ mov dh,20
+ int 0x10
+popa
+
+print_nextline:
+
+ pusha
+
+ mov ah,0x6 ;func
+ mov al,1 ;scroll one line
+ mov bh,[BLANK] ;blank char
+
+ mov ch,0 ;upper left corner
+ mov cl,0
+ mov dh,20 ;lower right corner
+ mov dl,40
+ int 0x10
+
+
+ mov ah,0x3
+ mov bh,0
+ int 0x10
+
+
+ mov ah,0x2
+ mov dl,0
+ int 0x10
+
+ mov bx,SPACE
+ call print_string
+
+ popa
+ ret
+
+
+;print byte from al to screen
+ print_hex_byte:
+
+ pusha
+
+ mov [.temp],al
+ shr al,4
+ cmp al,10
+ sbb al,69h
+ das
+
+ mov ah,0Eh
+ int 10h
+
+ mov al,[.temp]
+ ror al,4
+ shr al,4
+ cmp al,10
+ sbb al,69h
+ das
+
+ mov ah,0Eh
+ int 10h
+
+popa
+
+ ret
+
+ .temp db 0