summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-20 09:07:56 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-05-20 09:07:56 +0200
commitd1e408a2f7931732bc98809d36c28c47563fdbd3 (patch)
treef6c2b3ed49516df57fa6ef75650bcf498e92d5a2
parent45212640af40bed34a21c9b0b0640e17e945ed5c (diff)
downloadabaos-d1e408a2f7931732bc98809d36c28c47563fdbd3.tar.gz
abaos-d1e408a2f7931732bc98809d36c28c47563fdbd3.tar.bz2
precomputing MAGIC in makefile, magic.asm and stage2 magic check are in different assembly units, so we cannot use date and time
-rw-r--r--src/Makefile5
-rw-r--r--src/kernel.c4
-rw-r--r--src/magic.asm6
-rw-r--r--src/stage2_functions.asm2
4 files changed, 8 insertions, 9 deletions
diff --git a/src/Makefile b/src/Makefile
index affe3e3..1b77e89 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,6 +4,7 @@ LD := ld
NASMFLAGS := -f elf32
NASM := nasm
OBJCOPY := objcopy
+MAGIC = $(shell printf '%x' `date +%s`)
all: image.bin kernel.sym
@@ -19,7 +20,7 @@ image.bin: boot.bin kernel.bin magic.bin
cat image.tmp magic.bin > 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
+ $(NASM) boot.asm -DMAGIC='"$(MAGIC)"' -f bin -o boot.bin
kernel.bin: kernel.elf
$(OBJCOPY) -O binary kernel.elf kernel.bin
@@ -33,7 +34,7 @@ kernel.elf: kernel.o console.o vga.o serial.o port.o port_asm.o interrupts.o int
interrupts.o interrupts_asm.o string.o stdlib.o
magic.bin: magic.asm
- $(NASM) magic.asm -f bin -o magic.bin
+ $(NASM) magic.asm -DMAGIC='"$(MAGIC)"' -f bin -o magic.bin
kernel.o: kernel.c
$(CC) $(CFLAGS) -c -o kernel.o kernel.c
diff --git a/src/kernel.c b/src/kernel.c
index adebb21..5080156 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -23,7 +23,7 @@ void entry( void )
interrupt_t interrupt;
interrupts_init( &interrupt );
- interrupts_enable( );
+ //~ interrupts_enable( );
int y = 1;
int x = 12 / y;
@@ -42,7 +42,7 @@ void entry( void )
serial_put_char( &serial, '.' );
}
vga_put_char_at( &vga, x_pos, y_pos, bar[i%4] );
- for( int j = 0; j < 150000; j++ ) {
+ for( int j = 0; j < 1500; j++ ) {
}
}
vga_put_char_at( &vga, x_pos, y_pos, '.' );
diff --git a/src/magic.asm b/src/magic.asm
index d62cea1..f7aaf0d 100644
--- a/src/magic.asm
+++ b/src/magic.asm
@@ -1,11 +1,9 @@
; pad rest of sector with zeroes so we get 512 bytes in the end
-times 512-31-($-$$) db 0
+times 512-14-($-$$) db 0
; the magic string we search for in stage 2 to ensure we don't read
; a truncated kernel image
; we make it unique per compilation to avoid funny problems if
; the size of the image differs between compilation steps and the
; host system doens't initialize or randomize the RAM.
-; __UTC_DATE_NUM__ is YYYY-MM-DD
-; __UTC_TIME_NUM__ is HH:mm:SS
-db "ABAOSMAGIC ", __UTC_DATE__, " ", __UTC_TIME__, 0
+db "ABAOS", %[MAGIC], 0
diff --git a/src/stage2_functions.asm b/src/stage2_functions.asm
index 61a574c..208c2e4 100644
--- a/src/stage2_functions.asm
+++ b/src/stage2_functions.asm
@@ -210,7 +210,7 @@ check_magic:
ret
COMPARE_MAGIC:
-db "ABAOSMAGIC ", __UTC_DATE__, " ", __UTC_TIME__, 0
+db "ABAOS", %[MAGIC], 0
MAGICLEN equ $ - COMPARE_MAGIC
MAGIC_NOT_OK_MSG: