define bootloader size in linker script so later I can use it for relocating bootloader to 0050:0000 memory region
This commit is contained in:
parent
d62f1dad13
commit
9643f450ac
3 changed files with 31 additions and 10 deletions
15
Makefile
15
Makefile
|
|
@ -5,6 +5,7 @@ OBJCOPY = objcopy
|
|||
CLFAGS = -g -Wall
|
||||
ASFLAGS =
|
||||
LDFLAGS = -g
|
||||
QEMU = qemu-system-x86_64
|
||||
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
|
|
@ -105,6 +106,20 @@ mbr_test_clean:
|
|||
rm $(BIN_DIR)/mbr_test.bin
|
||||
rm $(OBJ_DIR)/mbr_test.o
|
||||
|
||||
mbr_test_qemu: mbr_test
|
||||
$(QEMU) -accel tcg,thread=single \
|
||||
-cpu core2duo \
|
||||
-m 128 \
|
||||
-no-reboot \
|
||||
-serial stdio \
|
||||
-smp 1 \
|
||||
-vga std \
|
||||
-d int \
|
||||
-d guest_errors \
|
||||
-s \
|
||||
-drive format=raw,media=disk,file=$(BIN_DIR)/mbr_test.bin \
|
||||
-drive format=raw,media=disk,file=$(BIN_DIR)/disk.img
|
||||
|
||||
clean:
|
||||
rm -f bin/*
|
||||
rm -f obj/*
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
MEMORY
|
||||
{
|
||||
BOOTLOADER (RWX) : ORIGIN = 0x7C00, LENGTH = 440
|
||||
UNIQUE_ID (R) : ORIGIN = 0x7DB8, LENGTH = 4
|
||||
RESERVED (R) : ORIGIN = 0x7DBC, LENGTH = 2
|
||||
PTABLE (R) : ORIGIN = 0x7DBE, LENGTH = 64
|
||||
MBR_MAGIC (R) : ORIGIN = 0x7DFE, LENGTH = 2
|
||||
BOOTLOADER (RWX) : ORIGIN = 0x0000, LENGTH = 440
|
||||
UNIQUE_ID (R) : ORIGIN = 0x01B8, LENGTH = 4
|
||||
RESERVED (R) : ORIGIN = 0x01BC, LENGTH = 2
|
||||
PTABLE (R) : ORIGIN = 0x01BE, LENGTH = 64
|
||||
MBR_MAGIC (R) : ORIGIN = 0x01FE, LENGTH = 2
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x7C00;
|
||||
. = 0;
|
||||
.text : {
|
||||
BOOTLOADER_START = .;
|
||||
*(.text)
|
||||
*(.data)
|
||||
BOOTLOADER_END = .;
|
||||
BOOTLOADER_SIZE = BOOTLOADER_END - BOOTLOADER_START;
|
||||
} > BOOTLOADER
|
||||
|
||||
.unique_id : {
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
.section .text
|
||||
.code16
|
||||
|
||||
mov $BOOTLOADER_SIZE, %ax
|
||||
|
||||
mov $0x07C0, %ax
|
||||
mov %ax, %dx
|
||||
mov %ax, %ds
|
||||
|
||||
mov msg, %si
|
||||
cld
|
||||
.putc_loop:
|
||||
lodsb
|
||||
or %al, %al
|
||||
jz .halt
|
||||
|
||||
mov $0x0E, %ah
|
||||
mov $0, %al
|
||||
mov $0x00, %bh
|
||||
int $0x10
|
||||
jmp .putc_loop
|
||||
.halt:
|
||||
hlt
|
||||
jmp .halt
|
||||
|
||||
.section .data
|
||||
msg: .asciz "Test MBR hello world\x0D\x0A" # len 22
|
||||
msg: .asciz "Test MBR hello world\r\n"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue