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
|
CLFAGS = -g -Wall
|
||||||
ASFLAGS =
|
ASFLAGS =
|
||||||
LDFLAGS = -g
|
LDFLAGS = -g
|
||||||
|
QEMU = qemu-system-x86_64
|
||||||
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
OBJ_DIR = obj
|
OBJ_DIR = obj
|
||||||
|
|
@ -105,6 +106,20 @@ mbr_test_clean:
|
||||||
rm $(BIN_DIR)/mbr_test.bin
|
rm $(BIN_DIR)/mbr_test.bin
|
||||||
rm $(OBJ_DIR)/mbr_test.o
|
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:
|
clean:
|
||||||
rm -f bin/*
|
rm -f bin/*
|
||||||
rm -f obj/*
|
rm -f obj/*
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,21 @@
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
BOOTLOADER (RWX) : ORIGIN = 0x7C00, LENGTH = 440
|
BOOTLOADER (RWX) : ORIGIN = 0x0000, LENGTH = 440
|
||||||
UNIQUE_ID (R) : ORIGIN = 0x7DB8, LENGTH = 4
|
UNIQUE_ID (R) : ORIGIN = 0x01B8, LENGTH = 4
|
||||||
RESERVED (R) : ORIGIN = 0x7DBC, LENGTH = 2
|
RESERVED (R) : ORIGIN = 0x01BC, LENGTH = 2
|
||||||
PTABLE (R) : ORIGIN = 0x7DBE, LENGTH = 64
|
PTABLE (R) : ORIGIN = 0x01BE, LENGTH = 64
|
||||||
MBR_MAGIC (R) : ORIGIN = 0x7DFE, LENGTH = 2
|
MBR_MAGIC (R) : ORIGIN = 0x01FE, LENGTH = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0x7C00;
|
. = 0;
|
||||||
.text : {
|
.text : {
|
||||||
|
BOOTLOADER_START = .;
|
||||||
*(.text)
|
*(.text)
|
||||||
*(.data)
|
*(.data)
|
||||||
|
BOOTLOADER_END = .;
|
||||||
|
BOOTLOADER_SIZE = BOOTLOADER_END - BOOTLOADER_START;
|
||||||
} > BOOTLOADER
|
} > BOOTLOADER
|
||||||
|
|
||||||
.unique_id : {
|
.unique_id : {
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,24 @@
|
||||||
.section .text
|
.section .text
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
|
mov $BOOTLOADER_SIZE, %ax
|
||||||
|
|
||||||
mov $0x07C0, %ax
|
mov $0x07C0, %ax
|
||||||
mov %ax, %dx
|
mov %ax, %ds
|
||||||
|
|
||||||
mov msg, %si
|
mov msg, %si
|
||||||
|
cld
|
||||||
.putc_loop:
|
.putc_loop:
|
||||||
lodsb
|
lodsb
|
||||||
or %al, %al
|
or %al, %al
|
||||||
jz .halt
|
jz .halt
|
||||||
|
|
||||||
mov $0x0E, %ah
|
mov $0x0E, %ah
|
||||||
mov $0, %al
|
mov $0x00, %bh
|
||||||
int $0x10
|
int $0x10
|
||||||
jmp .putc_loop
|
jmp .putc_loop
|
||||||
.halt:
|
.halt:
|
||||||
hlt
|
jmp .halt
|
||||||
|
|
||||||
.section .data
|
.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