Booting kernel
Posted: Sat Dec 09, 2023 8:44 am
Dear KolibriOS developers!
First, sorry, I don't speak Russian. Second, I really like what you have done here. So much so, that I've decided to support it in my current project.
I'm working on a FOSS, GPL'd boot manager Easyboot, which supports both BIOS and UEFI, and can already load several kernels, including KolibriOS on BIOS machines (here is the source). Now I wish to add support for booting KolibriOS on UEFI machines too, and that's where my headache starts.
I've read through these forums, studied uefi4kos.asm, and as far as I can tell, now KOLIBRI.KRN and KERNEL.MNT are two different files. This is very problematic for several reasons: a) makes shipping KolibiriOS more complicated b) there's no magic bytes in KOLIBRI.KRN, so nobody can tell that's actually a KolibriOS kernel.
My understanding is, this separation was done by dunkaist, because his UEFI loader didn't know where the BIOS code ends.
If you don't mind, my I suggest a different solution? It only increases the kernel's size by 7 bytes, but makes the file separation unnecessary.
In biosboot.asm, right after the identifier string and before including bootstr.inc:This would add a dword with the size at a fixed location, so then uefi4kos.asm in kernel_trampoline could do something like
This would keep backward compatibility with the current solution, but also works with the very same kernel file like BIOS, rendering the two separate kernels unnecessary.
What are your thoughts?
bzt
First, sorry, I don't speak Russian. Second, I really like what you have done here. So much so, that I've decided to support it in my current project.
I'm working on a FOSS, GPL'd boot manager Easyboot, which supports both BIOS and UEFI, and can already load several kernels, including KolibriOS on BIOS machines (here is the source). Now I wish to add support for booting KolibriOS on UEFI machines too, and that's where my headache starts.
I've read through these forums, studied uefi4kos.asm, and as far as I can tell, now KOLIBRI.KRN and KERNEL.MNT are two different files. This is very problematic for several reasons: a) makes shipping KolibiriOS more complicated b) there's no magic bytes in KOLIBRI.KRN, so nobody can tell that's actually a KolibriOS kernel.
My understanding is, this separation was done by dunkaist, because his UEFI loader didn't know where the BIOS code ends.
If you don't mind, my I suggest a different solution? It only increases the kernel's size by 7 bytes, but makes the file separation unnecessary.
In biosboot.asm, right after the identifier string and before including bootstr.inc:
Code: Select all
jmp start_of_code
if lang eq sp
include "kernelsp.inc" ; spanish kernel messages
else if lang eq et
version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0
else
version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0
end if
+ db 2Ch-($-$$) dup 0 ; place the BIOS initialization's code size at 2C
+ dd B32-10000h
include "boot/bootstr.inc" ; language-independent boot messages
Code: Select all
mov eax, cr4
and eax, not CR4_PAE
mov cr4, eax
- push KERNEL_BASE
+ mov eax, KERNEL_BASE
+ ; is it the new unified KERNEL.MNT or the old separated KOLIBRI.KRN?
+ cmp 'Koli', dword [eax + 3]
+ jne @f
+ add eax, dword [eax + 2Ch]
+@@: push eax
retn
What are your thoughts?
bzt