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