Get EFI/UEFI Memory Map

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Coconut9
Member
Member
Posts: 51
Joined: Sat May 20, 2017 1:25 am
Location: PCI bus: 3, slot: 9, function: 5

Get EFI/UEFI Memory Map

Post by Coconut9 »

How can i get EFI/UEFI memory map like BIOS eax=0x0000E820, int 0x15 ?
Also how can detect if the os is running under Bios or EFI/UEFI ?
How people react when a new update of your OS is coming:
Linux user: Cool, more free stuff!
Mac user: Ooh I have to pay!
Windows user: Ah not again!
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Get EFI/UEFI Memory Map

Post by no92 »

It seems that you haven't done your homework. Just searching for 'UEFI' on the wiki gets me to this page. Getting the memory map in UEFI involves calling a function that will return it to you. To figure out which one exactly it is is your job. Tip: you need a part of the memory map information to exit boot services. Also, judging by the wiki, it would probably take some major hack to get a UEFI (kernel) binary to also be a valid multiboot(2)-kernel at the same time. I haven't seen this done before, and you probably shouldn't be eager to be the first to do it.

All of this goes to say that by doing basic research, it is fairly obvious that you know whether you're running on UEFI or good old BIOS at compile time, as you'll be creating separate binaries.
User avatar
zaval
Member
Member
Posts: 659
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Get EFI/UEFI Memory Map

Post by zaval »

zero effort. I understand, you want to do great things, but you don't want to mess around learning and routines. this combination always fails.
go and read the UEFI specification. it writes about memory map quite well.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
Scoopta
Member
Member
Posts: 26
Joined: Tue Jun 13, 2017 3:17 am
Libera.chat IRC: Scoopta

Re: Get EFI/UEFI Memory Map

Post by Scoopta »

no92 wrote:It seems that you haven't done your homework. Just searching for 'UEFI' on the wiki gets me to this page. Getting the memory map in UEFI involves calling a function that will return it to you. To figure out which one exactly it is is your job. Tip: you need a part of the memory map information to exit boot services. Also, judging by the wiki, it would probably take some major hack to get a UEFI (kernel) binary to also be a valid multiboot(2)-kernel at the same time. I haven't seen this done before, and you probably shouldn't be eager to be the first to do it.

All of this goes to say that by doing basic research, it is fairly obvious that you know whether you're running on UEFI or good old BIOS at compile time, as you'll be creating separate binaries.
Linux has a compile option (CONFIG_EFI_STUB) that when enabled makes it valid for both UEFI and multiboot.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Get EFI/UEFI Memory Map

Post by Brendan »

Hi,
Scoopta wrote:Linux has a compile option (CONFIG_EFI_STUB) that when enabled makes it valid for both UEFI and multiboot.
Note: Linux doesn't use multi-boot (normally it uses Linux Boot Protocol).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Get EFI/UEFI Memory Map

Post by Schol-R-LEA »

Brendan wrote:
Scoopta wrote:Linux has a compile option (CONFIG_EFI_STUB) that when enabled makes it valid for both UEFI and multiboot.
Note: Linux doesn't use multi-boot (normally it uses Linux Boot Protocol).
I would call this splitting hairs, though it is fair to say that it is not so much that Linux running MultiBoot as it is MultiBoot running Linux.

While Linux has the LBP, that is not in and of itself a boot loader; rather, it is a protocol for communicating with a boot loader during the pass-off. It doesn't much care how it is loaded, so long as the loader provides the necessary information and sets the operational mode before transferring control.

MultiBoot was designed specifically with LBP in mind. Most of the oddities of MultiBoot, and of GRUB in particular, are due to the requirements of the Linux initialization. It was written to work with other systems, of course, Windows in particular (though you will not that, last I checked, it chainboots Windows rather than loading it), as being able to boot both Windows and Linux on a single system was the entire point of it, but it is primarily a Linux-oriented protocol.

AFAIK, the 'official' default boot loader for Linux is still LILO, but in practice, the majority of Linux installations have used GRUB since around 2005.
Last edited by Schol-R-LEA on Thu Jun 15, 2017 8:50 am, edited 2 times in total.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Get EFI/UEFI Memory Map

Post by Rusky »

You seem to be confusing multiboot and grub? All of LILO, Grub, Syslinux, etc. use Linux's boot protocol. All of ones that boot Windows use chainloading. At no point is multiboot involved.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Get EFI/UEFI Memory Map

Post by Schol-R-LEA »

Rusky wrote:You seem to be confusing multiboot and grub? All of LILO, Grub, Syslinux, etc. use Linux's boot protocol. All of ones that boot Windows use chainloading. At no point is multiboot involved.
GRUB is a MultiBoot loader, and in fact was originally intended as the reference implementation of the MultiBoot protocol - part of the reason its UI is so shallow and minimal is because the expectation was that other implementations would follow. GRUB is, or at least was, meant only to demonstrate how the MultiBoot Protocol works.

Windows is chainloaded on all MB loaders because Windows doesn't support MB, and in fact doesn't work with any loader other than its own. The provision for chainloading was a core feature of MBP from the start, because the whole point was to make it easier for Linux and Windows to exist on the same box. Windows doesn't play well with others, hence the need for chainloading.

What surprises me is that multi-booting - or even single-booting an OS directly on bare metal - is still a thing at all. I would have expected that the use of hypervisors (with a rump OS that just lets you launch and switch between OSes) would be universal by now, but given the massive pain that can be involved in using either HyperV or Xen I suppose I can see why. Also, a lot of people can't afford the memory and disk space to make it feasible - I know I can't - but still, I would expect it to be the rule rather than the exception, even for consumers who would have no need or wish to run multiple systems.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Get EFI/UEFI Memory Map

Post by Rusky »

Chainloading isn't part of MultiBoot, it merely happens to be supported by several bootloaders that also support MultiBoot and the Linux protocol.

(FWIW, I think most people do use VMs for running multiple OSes at this point, and only use rebooting for experimentation or if they need graphics acceleration and don't want to bother with PCI passthrough.)
Post Reply