1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00

Load initrd as Grub module

This commit is contained in:
bzt 2018-07-22 08:34:56 +02:00
parent c6d433bb32
commit 7fe5e32477
4 changed files with 54 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View file

@ -5,7 +5,7 @@ See [BOOTBOOT Protocol](https://gitlab.com/bztsrc/bootboot) for common details.
On [BIOS](http://www.scs.stanford.edu/05au-cs240c/lab/specsbbs101.pdf) based systems, the same image can be loaded via
[Multiboot](https://www.gnu.org/software/grub/manual/multiboot/multiboot.html),
chainload from MBR or VBR (GPT hybrid booting) or run as a BIOS Expansion ROM
chainload from MBR or VBR (GPT hybrid booting via __boot.bin__) or run as a BIOS Expansion ROM
(so not only the ramdisk can be in ROM, but the loader as well).
Machine state
@ -24,7 +24,17 @@ Installation
2. *BIOS ROM*: install __bootboot.bin__ in a **_BIOS Expansion ROM_**.
3. *GRUB*: specify __bootboot.bin__ as "kernel" in grub.cfg, or you can chainload __boot.bin__.
3. *GRUB*: specify __bootboot.bin__ as a Multiboot "kernel" in grub.cfg, or you can also chainload __boot.bin__. You can load
the initrd and the environment file as modules, if not given, they will be loaded from disk as usual. Example:
```
menuentry "MyKernel" {
multiboot /bootboot/loader # bootboot.bin
module /bootboot/initrd # first module is the initrd (optional)
module /bootboot/config # second module is the environment file (optional)
boot
}
```
Limitations
-----------

View file

@ -178,7 +178,7 @@ loader: db 55h,0AAh ;ROM magic
.pnpptr: dw 0
.flags: dd 0
MB_MAGIC equ 01BADB002h
MB_FLAGS equ 0D43h
MB_FLAGS equ 010001h
align 8
.mb_header: dd MB_MAGIC ;magic
dd MB_FLAGS ;flags
@ -200,19 +200,46 @@ MB_FLAGS equ 0D43h
multiboot_start:
cld
cli
xor dl, dl
;clear drive code, initrd ptr and environment
xor edx, edx
mov edi, 9000h
mov dword [edi], edx
mov dword [bootboot.initrd_ptr], edx
mov dword [bootboot.initrd_size], edx
;no GRUB environment available?
cmp eax, 2BADB002h
jne @f
;save drive code for boot device
mov dl, byte [ebx+12]
;is there a module? mod_count!=0
cmp dword [ebx+20], 0
jz @f
;mod_addr!=0
mov eax, dword [ebx+24]
or eax, eax
jz @f
;mods[0].end
mov ecx, dword [eax+4]
sub ecx, dword [eax]
mov dword [bootboot.initrd_size], ecx
;mods[0].start
mov ecx, dword [eax]
mov dword [bootboot.initrd_ptr], ecx
inc byte [hasinitrd]
;mod_count>1?
cmp dword [ebx+20], 1
jbe @f
;mods[1], copy environment (4k)
mov esi, dword [eax+16]
mov ecx, 1024
repnz movsd
@@: jmp CODE_BOOT:.real ;load 16 bit mode segment into cs
USE16
.real: mov eax, CR0
and al, 0FEh ;switching back to real mode
mov CR0, eax
xor ax, ax
mov ds, ax ;load registers 2nd turn
mov ds, ax ;load segment registers
mov es, ax
mov ss, ax
jmp 0:realmode_start
@ -388,9 +415,15 @@ getmemmap:
DBG dbg_mem
xor eax, eax
mov dword [bootboot.acpi_ptr], eax
mov dword [bootboot.smbi_ptr], eax
mov edi, bootboot.acpi_ptr
mov ecx, 16
repnz stosd
cmp byte [hasinitrd], 0
jnz @f
mov dword [bootboot.initrd_ptr], eax
mov dword [bootboot.initrd_size], eax
@@: mov dword [bootboot.initrd_ptr+4], eax
mov dword [bootboot.initrd_size+4], eax
mov eax, bootboot_MAGIC
mov dword [bootboot.magic], eax
mov dword [bootboot.size], 128
@ -828,6 +861,8 @@ protmode_start:
mov esp, 7C00h
; ------- Locate initrd --------
cmp byte [hasinitrd], 0
jnz .initrdrom
mov esi, 0C8000h
.nextrom: cmp word [esi], 0AA55h
jne @f
@ -1056,7 +1091,7 @@ protmode_start:
jne .notcfg
cmp dword [esi+7], ' '
jne .notcfg
; load environment from FS0:/BOOTBOOT/CONFIG
push edx
push esi
push edi
@ -1864,7 +1899,6 @@ core_ptr: dd 0
core_len: dd 0
ebdaptr: dd 0
hw_stack: dd 0
lastmsg: dd 0
bpb_sec: dd 0 ;ESP's first sector
root_sec: dd 0 ;root directory's first sector
data_sec: dd 0 ;first data sector
@ -1882,6 +1916,7 @@ lbapacket: ;lba packet for BIOS
reqwidth: dd 1024
reqheight: dd 768
bootdev: db 0
hasinitrd: db 0
fattype: db 0
vbememsize: dw 0
bkp: dd ' '