Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Boot Haiku OS #13

Open
JohnAZoidberg opened this issue Mar 1, 2021 · 9 comments
Open

Boot Haiku OS #13

JohnAZoidberg opened this issue Mar 1, 2021 · 9 comments

Comments

@JohnAZoidberg
Copy link
Collaborator

Haiku doesn't currently boot. The bootloader returns EFI_UNSUPPORTED.
Probably some driver isn't included in our build that the Haiki bootloader requires.
See: #7 (comment)

@kallisti5 where can I find the code and how can I build it easily? Or can you try to add some debugging prints to see what causes EFI_UNSUPPORTED?

@JohnAZoidberg
Copy link
Collaborator Author

Here, right? https://github.com/haiku/haiku/blob/master/src/system/boot/platform/efi/start.cpp#L194
Hmm, it always returns 'EFI_SUCCESS`?

It calls acpi_init? We don't have ACPI yet. But looking at the implementation, it should be fine, if there's no RSDT, right?

Good to see that you're trying to get the device tree from the system config table! We already put it there :)

I can't see anything wrong but I can't find where main is defined: https://github.com/haiku/haiku/blob/master/src/system/boot/platform/efi/start.cpp#L222

@JohnAZoidberg
Copy link
Collaborator Author

JohnAZoidberg commented Mar 1, 2021

@JohnAZoidberg
Copy link
Collaborator Author

Here's the image with more debug output: http://danielschaefer.me/static/U540-virt-haiku-debug-mar1.fd
Based on this commit: riscvarchive/riscv-edk2@4476a27

@kallisti5
Copy link

I did some debugging and this is where EFI_UNSUPPORTED comes from. Seems like something is wrong with your bootloader executable.

Odd. I thought we had the Pe issues sorted out (u-boot's bootefi seems happy)

Here are the relevant files which generate our RV64 EFI bootloader:

@JohnAZoidberg
Copy link
Collaborator Author

JohnAZoidberg commented Mar 1, 2021

I found the issue.
https://git.haiku-os.org/haiku/tree/src/system/boot/platform/efi/arch/riscv64/crt0-efi-riscv64.S#n90 is 6 when it should really be 16. I guess this could be a typo.

https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-windows-specific-fields-image-only says this value should be the number of data directory entries of which there are 16.

I patched the binary and I can start the bootloader and make it start Haiku (but it gets stuck)!

image

I'd like to find out how to contribute to Haiku and send this as a patch. I'll try to figure it out tomorrow. I'm happy about operating system diversity :)

These are the last few lines when it appears to be stuck:

  0xbf982000-0xbf9b2000  0x0 0x5 0x800000000000000f
  0xbf9b2000-0xbf9d6000  0x0 0x6 0x800000000000000f
  0xbf9d6000-0xbf9e6000  0x0 0x7 0xf
  0xbf9e6000-0xbfa07000  0x0 0x4 0xf
  0xbfa07000-0xbfa45000  0x0 0x3 0xf
  0xbfa45000-0xbffd6000  0x0 0x4 0xf
  0xbffd6000-0xbfffe000  0x0 0x3 0xf
  0xbfffe000-0xc0000000  0x0 0x4 0xf
Calling ExitBootServices. So long, EFI!
TimerDriverSetTimerPeriod(0x0)
SetUefiImageMemoryAttributes - 0x00000000BF9A9000 - 0x0000000000009000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BF9A1000 - 0x0000000000008000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BF999000 - 0x0000000000008000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BF992000 - 0x0000000000007000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BE8EA000 - 0x0000000000018000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BF98A000 - 0x0000000000008000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BF982000 - 0x0000000000008000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BE8D3000 - 0x0000000000006000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet
SetUefiImageMemoryAttributes - 0x00000000BE8CC000 - 0x0000000000007000 (0x0000000000000000)
CpuSetMemoryAttributes: Set memory attributes not supported yet

The stuff about memory attributes comes from our edk2 changes.
I guess we really need to implement them? Do you think they would cause the hang?

@tqh
Copy link

tqh commented Mar 1, 2021

Oh, nice! We use Gerrit for patches. Here are the guidelines for patches: https://dev.haiku-os.org/wiki/CodingGuidelines/SubmittingPatches

@kallisti5
Copy link

Nice!! I can apply that fix to our codebase @JohnAZoidberg if you don't have the bandwidth / time :-)

@kallisti5
Copy link

ooh.. also the cause of the hang jumping into our kernel isn't a EDK2 unique issue.

I've been working through a patchset to setup a new Sv39 page table from our bootloader
before jumping into our kernel.

https://review.haiku-os.org/c/haiku/+/3733

It's getting there... but I don't know what I'm doing 😅

@JohnAZoidberg
Copy link
Collaborator Author

JohnAZoidberg commented May 12, 2021

Linux boots fine, please try again when you've got time :)
I see the change request isn't merged yet.

You cant get the latest FD from Github Actions. Now it is here: https://github.com/riscv/riscv-edk2-platforms/suites/2725452052/artifacts/60114481 (unpack the zip)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants