I am currently working on a bootloader for my operating system. In one part of it, I need to know what the highest usable address of conventional memory is, which also is the base of the EBDA from based on what I've seen. My only issue is that I know that the size of EBDA can vary from BIOS to BIOS. So my question is: What is the most reliable method to obtain the base address of the EBDA / highest usable conventional memory address. I know the BDA can have the EBDA base in it, but it isn't the most reliable way to find it from what I've heard.
Thanks,
nexos
Best way to detect the size of EBDA
Re: Best way to detect the size of EBDA
On a BIOS system, just ask E820. The memory map returned that way will not list the EBDA as usable memory. Funnily enough, it will usually list the IVT and BDA as usable, which I guess is true if you don't want to return to BIOS mode. Else, touching either of them is a good way to get the system to crash or misbehave.
There is also a BIOS function somewhere to return the size of conventional memory, though I failed to find it, glancing through RBIL just now. I remember that some DOS TSRs would actually hook that function to return a lower value to reserve some memory to themselves.
There is also a BIOS function somewhere to return the size of conventional memory, though I failed to find it, glancing through RBIL just now. I remember that some DOS TSRs would actually hook that function to return a lower value to reserve some memory to themselves.
Carpe diem!
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Best way to detect the size of EBDA
Use INT 0x12 or INT 0x15 EAX=0x0000E801.nexos wrote:I need to know what the highest usable address of conventional memory is,
Use INT 0x15 AH=0xC1. There can be memory reserved for other purposes between the conventional memory and the EBDA.nexos wrote:which also is the base of the EBDA from based on what I've seen.
It's only unreliable if your bootloader might run on a PC that predates the widespread use of an EBDA.nexos wrote:I know the BDA can have the EBDA base in it, but it isn't the most reliable way to find it from what I've heard.
Re: Best way to detect the size of EBDA
Thank you all for the help. I decided to use BDA address 0x413 to detect the size of conventional memory, as that makes the most sense to me. That works on all my machines, so I guess that must be pretty reliable, right?
It is INT 0x12nullplan wrote:There is also a BIOS function somewhere to return the size of conventional memory
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Best way to detect the size of EBDA
It actually is reliable, but I wouldn't take "it works for me" as confirmation.nexos wrote:That works on all my machines, so I guess that must be pretty reliable, right?
INT 0x12 returns the contents of address 0x413.