fix: multiboot in stpdboot.sys
This commit is contained in:
parent
6b36d17a5e
commit
9aaad60e6e
2
Makefile
2
Makefile
|
@ -14,7 +14,7 @@ SUBDIRS := tools boot kernel lib bin
|
|||
TARGET = stupid.tar.gz floppy_boot.img
|
||||
ifneq ($(OS),Windows_NT)
|
||||
EXEXT =
|
||||
TARGET += stupid.iso stdupid.hdd
|
||||
TARGET += stupid.iso stupid.hdd
|
||||
else
|
||||
EXEXT = .exe
|
||||
endif
|
||||
|
|
|
@ -1,51 +1,54 @@
|
|||
INCLUDE 'const.inc'
|
||||
INCLUDE 'multiboot.inc'
|
||||
INCLUDE 'multiboot.inc'
|
||||
|
||||
ORG STAGE1_BASE
|
||||
USE16
|
||||
ORG STAGE1_BASE
|
||||
USE32
|
||||
|
||||
jmp _start
|
||||
|
||||
mb_header MultibootHeader mb_header
|
||||
ALIGN 4
|
||||
multiboot_header:
|
||||
mb_header MultibootHeader multiboot_header
|
||||
|
||||
_start:
|
||||
cmp eax, MULTIBOOT_MAGIC
|
||||
je .multiboot
|
||||
cmp eax, MULTIBOOT_MAGIC
|
||||
je .multiboot
|
||||
|
||||
USE16
|
||||
;; non multiboot process
|
||||
push cs
|
||||
pop ds
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
mov si, msg_stage2
|
||||
call bios_print
|
||||
mov si, msg_stage2
|
||||
call bios_print
|
||||
|
||||
call a20_enable
|
||||
jc .error_a20
|
||||
call a20_enable
|
||||
jc .error_a20
|
||||
|
||||
; detect memory
|
||||
call memory_get_map
|
||||
jc .error_memory
|
||||
xchg bx, bx
|
||||
; detect memory
|
||||
call memory_get_map
|
||||
jc .error_memory
|
||||
xchg bx, bx
|
||||
|
||||
call video_setup
|
||||
|
||||
.multiboot:
|
||||
jmp .hang
|
||||
jmp .hang
|
||||
|
||||
.error_memory:
|
||||
mov si, msg_error_memory
|
||||
jmp .error
|
||||
mov si, msg_error_memory
|
||||
jmp .error
|
||||
.error_a20:
|
||||
mov si, msg_error_a20
|
||||
mov si, msg_error_a20
|
||||
.error:
|
||||
call bios_print
|
||||
call bios_print
|
||||
.hang:
|
||||
hlt
|
||||
jmp $
|
||||
hlt
|
||||
jmp $
|
||||
|
||||
INCLUDE 'a20.inc'
|
||||
INCLUDE 'utils.inc'
|
||||
INCLUDE 'memory.inc'
|
||||
INCLUDE 'a20.inc'
|
||||
INCLUDE 'utils.inc'
|
||||
INCLUDE 'memory.inc'
|
||||
INCLUDE 'video.inc'
|
||||
|
||||
msg_stage2 db "StupidOS Bootloader (Stage 1)", CR, LF, 0
|
||||
|
@ -59,7 +62,7 @@ bi_screen_height: dw 0
|
|||
|
||||
_edata:
|
||||
|
||||
; BSS
|
||||
rb 0x4000
|
||||
; BSS
|
||||
rb 0x4000
|
||||
|
||||
_end:
|
||||
|
|
|
@ -4,6 +4,7 @@ LF = 0x0A
|
|||
; -------- Address ----------
|
||||
STAGE0_BASE = 0x7C00
|
||||
STAGE1_BASE = 0x1000
|
||||
MULTIBOOT_BASE = 0x100000
|
||||
DISK_BUFFER = 0x8000
|
||||
KERNEL_PRELOAD = 0xF000
|
||||
STACK_TOP = 0x7000
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
MULTIBOOT_HDR_MAGIC = 0x1BADB002
|
||||
MULTIBOOT_MAGIC = 0x2BADB002
|
||||
|
||||
MULTIBOOT_HDR_ALIGN = 0x1
|
||||
MULTIBOOT_HDR_MEMINFO = 0x2
|
||||
MULTIBOOT_HDR_VIDEO = 0x4
|
||||
MULTIBOOT_FLAGS = MULTIBOOT_HDR_ALIGN or MULTIBOOT_HDR_MEMINFO or MULTIBOOT_HDR_VIDEO
|
||||
MULTIBOOT_HDR_ALIGN = 0x1
|
||||
MULTIBOOT_HDR_MEMINFO = 0x2
|
||||
MULTIBOOT_HDR_VIDEO = 0x4
|
||||
MULTIBOOT_HDR_AOUT_KLUDGE = 0x10000
|
||||
MULTIBOOT_FLAGS = MULTIBOOT_HDR_ALIGN or MULTIBOOT_HDR_MEMINFO or MULTIBOOT_HDR_VIDEO or MULTIBOOT_HDR_AOUT_KLUDGE
|
||||
|
||||
struc MultibootHeader addr
|
||||
{
|
||||
|
@ -15,8 +16,8 @@ struc MultibootHeader addr
|
|||
; address fields (we'll just skip them)
|
||||
.header_addr dd addr
|
||||
.load_addr dd STAGE1_BASE
|
||||
.load_end_addr dd _edata - STAGE1_BASE
|
||||
.bss_end_addr dd _end - STAGE1_BASE
|
||||
.load_end_addr dd _edata
|
||||
.bss_end_addr dd _end
|
||||
.entry_addr dd _start
|
||||
|
||||
; Video mode
|
||||
|
|
|
@ -8,7 +8,8 @@ set default=0
|
|||
menuentry "StupidOS" {
|
||||
echo "verify system integrity"
|
||||
hashsum --hash sha256 --check /boot/hashfile --prefix /
|
||||
multiboot /vmstupid
|
||||
multiboot /stpdboot.sys
|
||||
module /vmstupid.sys
|
||||
boot
|
||||
}
|
||||
|
||||
|
@ -18,7 +19,10 @@ EOF
|
|||
gen_iso_file() {
|
||||
mkdir -p "$2/boot/grub"
|
||||
echo "$grub_config" > "$2/boot/grub/grub.cfg"
|
||||
sha256sum "$2/vmstupid" > "$2/boot/hashfile"
|
||||
sha256sum "$2/vmstupid.sys" > "$2/boot/hashfile"
|
||||
sha256sum "$2/stpdboot.sys" >> "$2/boot/hashfile"
|
||||
|
||||
grub-file --is-x86-multiboot "$2/stpdboot.sys" || exit 1
|
||||
|
||||
grub-mkrescue -o $1 $2
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue