Hi Daniel, Sorry, sent an unfinished mail by mistake.
Regarding reusing existing code, there is grub-core/loader/efi/fdt.c which is mentioned in git log as not really platform specific (although it was part of arm64, and does follow EBBR to a degree), but i'm not sure if i can really use this for x86. grub-core/loader/efi/ftd.c uses grub_efi_allocate_pages_real which, if i understand correctly, calls UEFI to allocate memory in EfiACPIReclaimMemory. Not sure if this would work for x86 (regarding ACPI and its handling in Linux) and also it doesn't use grub_relocator_alloc_chunk_align as you mention. Br, Mislav -----Original Message----- From: Mislav Stublić Sent: Monday, August 02, 2021 2:57 PM To: 'Daniel Kiper' Cc: [email protected] Subject: RE: Device tree support for x86 on Linux Hi Daniel, Regarding reusing existing code, there is grub-core/loader/efi/fdt.c which atleast df s a f -----Original Message----- From: Daniel Kiper [mailto:[email protected]] Sent: Friday, July 30, 2021 2:59 PM To: Mislav Stublić Cc: [email protected] Subject: Re: Device tree support for x86 on Linux Hi Mislav, On Thu, Jul 29, 2021 at 08:43:45AM +0000, Mislav Stublić wrote: > Hi, > > I am planning to add support for device tree loading on x86 with UEFI > and Linux as i understand this is currently not supported. We need > this for a board we are developing so i would test my patches in our > development environment. > > I have gone through current x86 loader code and some similar use cases > so i believe i could provide a patch but i also have some questions. > > Is this a feature you would accept upstream? I do not see any issues with it. It would be nice if you could reuse existing code as much as possible. And please remember that current GRUB code does not allow you to load device tree files if UEFI Secure Boot is enabled. You can find more info here: grub-core/kern/lockdown.c. > As for technical questions, for this to work grub would need to set > setup_data pointer (part of setup_header for linux kernel) that points > to memory holding loaded dtb. But i'm not sure if such memory can just > be allocated with grub_zalloc or is there some other allocation The grub_zalloc() et consortes can be used for the GRUB "runtime" only. > mechanism that would guarantee this will be preserved once control is > handed over to linux kernel. There are two functions in the GRUB which are doing what you want: grub_relocator_alloc_chunk_align() and grub_relocator_alloc_chunk_addr(). It seems to me the former should be better for you. Daniel ----- Disclaimer ----- This e-mail message and its attachments may contain privileged and/or confidential information. Please do not read the message if You are not its designated recipient. If You have received this message by mistake, please inform its sender and destroy the original message and its attachments without reading or storing of any kind. Any unauthorized use, distribution, reproduction or publication of this message is forbidden. ----- Pravne napomene ----- Ova elektronicka poruka i njeni prilozi mogu sadrzavati povlastene informacije i/ili povjerljive informacije. Molimo Vas da poruku ne citate ako niste njen naznaceni primatelj. Ako ste ovu poruku primili greskom, molimo Vas da o tome obavijestite posiljatelja i da izvornu poruku i njene privitke unistite bez citanja ili bilo kakvog pohranjivanja. Svaka neovlastena upotreba, distribucija, reprodukcija ili priopcavanje ove poruke zabranjena je. _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
