uefi4kos

Kernel boot-loaders discussion
User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

uefi4kos

Post by dunkaist »

Hello,

I implemented a small UEFI module to boot kolibri without CSM, find it here.

It is done in fasm, using uefi.inc. A thread by XVilka was especially helpful for booting on real hardware.

How it works:
- Choose and set video mode via UEFI graphics output protocol;
- Get memory map and convert it to E820 format;
- Load kernel and disk image into memory;
- Set boot params at 0x9000+;
- Load new GDT;
- Go to compatibility and then protected mode;
- Clear cr4.pae bit;
- Jump to the kernel.

What doesn't work:
- 'blue screen' (to choose video mode type its number and press enter, no indication so far!);
- reboot/poweroff.
Attachments
uefi4kos.7z
(1.19 MiB) Downloaded 528 times
Wildwest
Posts: 1001
Joined: Wed May 18, 2005 7:27 pm

Re: uefi4kos

Post by Wildwest »

User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

Re: uefi4kos

Post by dunkaist »

Hello.

Current kernel.asm (read: kernel.mnt) starts with 16-bit bios-related part which is of no use for UEFI loader that wants to jump just after this part, to os_code:B32. Unfortunately, B32 label offset depends on the size of preceeding 16-bit code and therefore UEFI loader can't guess where to jump.

I attached a patch that splits bootbios.asm and kernel.asm:
  • Move bios-related part of kernel.asm before B32 label to bootbios.asm file;
  • Move bx_from_load, boot_dev and kernel_restart_bootblock variables to BOOT_* 0x9000 block;
  • Update Tupfile.lua, Makefile, build.bat, build.sh accordingly;
  • Now bios and uefi loaders can jump to very first byte of the kernel.
Any objections?
Attachments
bootbios.diff
(18.4 KiB) Downloaded 364 times
User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

Re: uefi4kos

Post by dunkaist »

Current UEFI guide for brave:
  1. Download the latest floppy image nightbuild.
  2. Download the latest devman by Serge.
  3. Copy acpi and acpi.dll files to /drivers directory.
  4. Boot this modified image any way you can.
  5. Run /drivers/acpi manually.
  6. Copy /drivers/devices.dat somewhere or open it in the hex editor and take a photo.
  7. Boot into your main OS, remove /drivers/acpi*, copy devices.dat to /drivers.
  8. Put resulting kolibri.img to /data directory in your local source tree.
  9. Go to /kernel/trunk. Run fasm kernel.asm kernel.bin -dUEFI=1.
  10. Go to /kernel/trunk/boot. Run fasm uefi4kos.asm kolibri.efi.
  11. Add kolibri.efi to your bootloader's config file. E.g. for grub (aka grub2) menuentry is as follows:

Code: Select all

menuentry "KolibriOS" {
                insmod part_gpt
                insmod fat
                insmod chain
                chainloader /EFI/kolibri.efi
        }
Antonio
Posts: 74
Joined: Sat Jan 19, 2019 5:17 pm

Re: uefi4kos

Post by Antonio »

What about minimum system requirements?
How to modify the image? Sorry for offtopic.
:?: :arrow: :idea:
User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

Re: uefi4kos

Post by dunkaist »

Antonio wrote:What about minimum system requirements?
uefi4kos is a bootloader, it takes few MBs. In theory, it should work on most modern computers with 64-bit UEFI and Secure Boot disabled.
APIC and interrupts are still an issue. You can workaround it as Serge suggested here.
Antonio wrote:How to modify the image? Sorry for offtopic.
https://wiki.osdev.org/Disk_Images
User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

Re: uefi4kos

Post by dunkaist »

Current UEFI guide:
  1. Generate DEVICES.DAT file as described from 1 to 6 by Serge. Devman is here.
  2. Put obtained DEVICES.DAT, kolibri.ini, kolibri.img, kolibri.efi and kolibri.krn to EFI System Partition: /EFI/Boot/.
  3. Edit kolibri.ini, e.g. define screen resolution. There is no interactive boot menu in uefi loader.
  4. Add kolibri.efi to your bootloader's config file. E.g. for grub (aka grub2) menuentry is as follows:

Code: Select all

menuentry "KolibriOS" {
                insmod part_gpt
                insmod fat
                insmod chain
                chainloader /EFI/Boot/kolibri.efi
        }
User avatar
Evgeniy
Posts: 76
Joined: Thu Oct 22, 2020 5:41 pm

Re: uefi4kos

Post by Evgeniy »

I have notebook with UEFI and Flash device. And i try new boot and rufus installer it not work. How to install KolibriOS to Flash device? Do you have automatic installator? Or full manual?
2004: Kolibri OS - Operating system that fits on a single floppy disk (Система которая умещается на дискете).
2020: Kolibri OS - Operating system that can only be run under Virtual machine (Система которую можно запустить только на виртуальной машине).
User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

Re: uefi4kos

Post by dunkaist »

  1. Create GPT layout on your flash device.
  2. Create EFI System Partition (ESP) on it.
  3. Format ESP as FAT32.
  4. Make /EFI/BOOT directory on ESP.
  5. Edit kolibri.ini file according to your needs.
  6. Copy kolibri.efi as /EFI/BOOT/BOOTX64.EFI.
  7. Copy kolibri.{krn,img.ini} files to /EFI/BOOT/.
  8. Optionally, copy DEVICES.DAT file to /EFI/BOOT/.
Files kolibri.* and DEVICES.DAT are mentioned in the above posts.

For Linux host and /dev/sdd flash this procedure is as follows:

Code: Select all

# parted -s /dev/sdd mktable gpt
# parted -s /dev/sdd unit MiB mkpart fat32 1 100%
# parted -s /dev/sdd set 1 esp on
# mkfs.vfat -F32 -n KOLIBRIOS /dev/sdd1
mkfs.fat 4.1 (2017-01-24)
# mmd -i /dev/sdd1 ::EFI
# mmd -i /dev/sdd1 ::EFI/BOOT
# mcopy -moi /dev/sdd1 kolibri.efi ::EFI/BOOT/BOOTX64.EFI
# mcopy -moi /dev/sdd1 kolibri.krn ::EFI/BOOT/KOLIBRI.KRN
# mcopy -moi /dev/sdd1 kolibri.img ::EFI/BOOT/KOLIBRI.IMG
# mcopy -moi /dev/sdd1 kolibri.ini ::EFI/BOOT/KOLIBRI.INI
You are welcome to write and share instructions for Windows users.
User avatar
Evgeniy
Posts: 76
Joined: Thu Oct 22, 2020 5:41 pm

Re: uefi4kos

Post by Evgeniy »

To Dunkaist

Thank you for the detailed instructions. But I don't have a Linux distribution. Obviously, the Windows 10 distribution does not have such utilities as mktable... Apparently, to run KOS, you must first create a Linux Live USB distribution. Now I understand why this OS is abandoned and so not popular...

On Russian:
Спасибо за развернутую инструкцию. Но у меня нет дистрибутива Linux. Очевидно дистрибутив Windows 10 не имеет таких утилит как mktable... Видимо чтобы запустить KOS нужно сначала создать дистрибутив Linux Live USB. Теперь я понимаю почему эта ОС заброшена и так не популярна...
2004: Kolibri OS - Operating system that fits on a single floppy disk (Система которая умещается на дискете).
2020: Kolibri OS - Operating system that can only be run under Virtual machine (Система которую можно запустить только на виртуальной машине).
User avatar
Evgeniy
Posts: 76
Joined: Thu Oct 22, 2020 5:41 pm

Re: uefi4kos

Post by Evgeniy »

Maybe it possible if use BOOTICE under windows? BOOTICE much powerfull utilite.
https://www.bootdev.ru/2015/10/bootice.html
2004: Kolibri OS - Operating system that fits on a single floppy disk (Система которая умещается на дискете).
2020: Kolibri OS - Operating system that can only be run under Virtual machine (Система которую можно запустить только на виртуальной машине).
maxcodehack
Posts: 412
Joined: Mon Sep 07, 2020 7:09 pm

Re: uefi4kos

Post by maxcodehack »

Подпись очень обманчива.
Точнее написать: "2020: Kolibri OS - Система которую я могу запустить только с флоппика, и больше с ничего"
(просто редко захожу на пару минут)
User avatar
dunkaist
Mentor
Posts: 730
Joined: Mon Oct 19, 2009 10:58 am
Has thanked: 4 times
Been thanked: 2 times

Re: uefi4kos

Post by dunkaist »

Evgeniy wrote:Thank you for the detailed instructions.
You are welcome.
Evgeniy wrote:But I don't have a Linux distribution. Obviously, the Windows 10 distribution does not have such utilities as mktable... Apparently, to run KOS, you must first create a Linux Live USB distribution.
Currently it is not possible to partition disks from KolibriOS, therefore you have to use some other OS to do this.
Windows is absolutely okay, you can use standard diskpart utility or any suitable gui tool (mentioned bootice looks promising).

Alternatively, you can try prebuilt flash image. It hasn't been tested properly yet, you can help with this.
User avatar
Evgeniy
Posts: 76
Joined: Thu Oct 22, 2020 5:41 pm

Re: uefi4kos

Post by Evgeniy »

maxcodehack wrote:Подпись очень обманчива.
Точнее написать: "2020: Kolibri OS - Система которую я могу запустить только с флоппика, и больше с ничего"
Исправил. Флоппи дисководы сейчас уже редко встретишь...
2004: Kolibri OS - Operating system that fits on a single floppy disk (Система которая умещается на дискете).
2020: Kolibri OS - Operating system that can only be run under Virtual machine (Система которую можно запустить только на виртуальной машине).
User avatar
Evgeniy
Posts: 76
Joined: Thu Oct 22, 2020 5:41 pm

Re: uefi4kos

Post by Evgeniy »

dunkaist wrote:
Evgeniy wrote:But I don't have a Linux distribution. Obviously, the Windows 10 distribution does not have such utilities as mktable... Apparently, to run KOS, you must first create a Linux Live USB distribution.
Currently it is not possible to partition disks from KolibriOS, therefore you have to use some other OS to do this.
Windows is absolutely okay, you can use standard diskpart utility or any suitable gui tool (mentioned bootice looks promising).

Alternatively, you can try prebuilt flash image. It hasn't been tested properly yet, you can help with this.
Im write youre raw image on usb by rawrite32.

First notebook doesn't see the flash drive as boot uefi, but it have feature "run from file".I found the file "EFI\BOOT\BOOTX64.EFI" is it really on the flash drive? Im run it, and get blue rectangle on black screen with label

'\EFI\BOOT\BOOTX64.EFI boot failed. [OK]"

However, I can't understand why the bootloader is x64? We have a 32-bit system.

... Yep im reboot an test it again. Kolibri Flash drive have file BOOTX64.EFI - thats true.

For example hardrive have 32 bit file bootia32.efi for init system.

Thats All... Anyway, thanks for trying.

Second notebook freezee with logo. Maybe its hardware is not compatible with Kolibri :roll:... Processor is x64, but the motherboard may not be compatible. But other uefi live usb runs ok on this device.
2004: Kolibri OS - Operating system that fits on a single floppy disk (Система которая умещается на дискете).
2020: Kolibri OS - Operating system that can only be run under Virtual machine (Система которую можно запустить только на виртуальной машине).
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest