OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:47 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Best way to detect the size of EBDA
PostPosted: Thu Aug 19, 2021 12:03 pm 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: Best way to detect the size of EBDA
PostPosted: Thu Aug 19, 2021 1:16 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Best way to detect the size of EBDA
PostPosted: Thu Aug 19, 2021 3:22 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
nexos wrote:
I need to know what the highest usable address of conventional memory is,

Use INT 0x12 or INT 0x15 EAX=0x0000E801.

nexos wrote:
which also is the base of the EBDA from based on what I've seen.

Use INT 0x15 AH=0xC1. There can be memory reserved for other purposes between the conventional memory and the 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.

It's only unreliable if your bootloader might run on a PC that predates the widespread use of an EBDA.


Top
 Profile  
 
 Post subject: Re: Best way to detect the size of EBDA
PostPosted: Thu Aug 19, 2021 3:32 pm 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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?

nullplan wrote:
There is also a BIOS function somewhere to return the size of conventional memory

It is INT 0x12 :)

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: Best way to detect the size of EBDA
PostPosted: Thu Aug 19, 2021 5:11 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
nexos wrote:
That works on all my machines, so I guess that must be pretty reliable, right?

It actually is reliable, but I wouldn't take "it works for me" as confirmation. :P

INT 0x12 returns the contents of address 0x413.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 66 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group