I am wondering if anybody here have any experience on what is the best
way to dynamically allocate buffer for Option ROM during BIOS POST and
bootloader execution.
Since our code size is quite big, I don't want to waste any
significant code space for data storage in Option ROM image. The
option ROM requires around 20K for the data buffer and I'll want it to
be valid during the POST and after int19 OS bootstrap is running
because our code provide the int13 function to access this storage
controller. I was thinking to use PMM or EBDA. But according to PMM
spec, the PMM memory is not available after BIOS call int19. And EBDA
also seems not an option for me because the part of the buffer I use
is for the this controller's host DMA buffer. The EBDA memory address
can be changed if other Option ROM after mine also allocates EBDA
memory. Then my controller can overwrite the host memory that no
longer belongs to my option ROM. So what are the other methods to get
memory? Can I use any free conventional memory for my purpose? If so,
how do I guarantee that nobody else will touch it? Will OS bootloader
touch conventional memory?
Thanks a lot!
William
> Hi All,
Hello,
> I am wondering if anybody here have any experience on what is the best
> way to dynamically allocate buffer for Option ROM during BIOS POST and
> bootloader execution.
> Since our code size is quite big, I don't want to waste any
> significant code space for data storage in Option ROM image. The
> option ROM requires around 20K for the data buffer and I'll want it to
> be valid during the POST and after int19 OS bootstrap is running
> because our code provide the int13 function to access this storage
> controller. I was thinking to use PMM or EBDA. But according to PMM
> spec, the PMM memory is not available after BIOS call int19. And EBDA
> also seems not an option for me because the part of the buffer I use
> is for the this controller's host DMA buffer. The EBDA memory address
> can be changed if other Option ROM after mine also allocates EBDA
> memory. Then my controller can overwrite the host memory that no
> longer belongs to my option ROM.
> So what are the other methods to get memory?
If you mean a part of the RAM which isn't affected by POST/reboot
then your search may be in vain.
Use a flash-RAM instead of a ROM ?
If I had to design a device now, it would act as a PCI-device
and also follow the Int13h rules similar how graphic-cards do.
> Can I use any free conventional memory for my purpose? If so,
> how do I guarantee that nobody else will touch it?
Never :)
> Will OS bootloader touch conventional memory?
Yes, almost all bootloaders start in real mode.
An option could be to have your ROM at D_0000h (32K, but reporting
64K) and have a writeable shadow RAM at D_8000h, again like VGA.
But I think this also may not keep its contents during INT19h reboot.
__
wolfgang
The standard way of doing this is to lower the Free Base Memory pointer
at address 0x413 and keep a pointer in your ROM area (during preboot the
"ROM area" will actually be writable in a PCI-compliant system; it gets
switched to readonly before INT 19h when the PMM system is torn down.)
Since you're only talking 20K, there probably isn't any reason to do
anything more exotic like using PMM to allocate upper memory but hooking
INT 15h to mask it from the OS.
-hpa
Make that: "H. Peter Anvin" <spamtrap@ inspire... etc.
Sorry 'bout that, Peter. (and others) We're workin' on it.
Best,
Frank
No, you don't need to hook INT 15h since you're dealing with a small
amount of memory. If you needed *lots* of memory you would have to
allocate memory from > 1 MB and that would require hooking INT 15h.
You don't need to hook anything. Instead, just lower the amount of
conventional memory available at address 0x413.
For example, if the value in 0x413 (it's a word-sized variable, uint16_t
in C99 terminology) is 638, you would reduce it to 618, and the address
would be (618 << 10) = 0x9a800, or equivalently a segment address of
(618 << 6) = 9A80h:0000.
-hpa
Are you sure this method works?
I've attempted to do just that in a couple of bootloaders, but the OSes I've
tried (DOS, Linux) don't seem to respect memory allocation via this method.
I think his driver is "toast" if it has any code in writable ram, whether
just below 640k or 512k via 0x413, or in a UMB (upper memory block) in ram
in the HMA (high memory area).
Rod Pemberton
PS. Added alt.os.development, comp.os.msdos.programmer.
(They may be interested, if not it's a cross-post test to non-moderated
groups from clax's new robomod.)
Egads!
> in the HMA (high memory area).
Correction, that should've said:
"in the UMA (upper memory area)."
Rod Pemberton
On Feb 11, 1:55 pm, "H. Peter Anvin" <spamt...@inspiretomorrow.net>
wrote:
No, the EBDA will already have adjusted 0x413.
The OS bootloader, or a BIOS-using real mode operating system, like DOS,
will respect this area; a protected-mode operating system will not (but
you should have a real hardware driver there.)
-hpa
http://groups.google.com/group/comp.lang.asm.x86/browse_thread/thread/e35228bd2a0cf6b0
Hi All,
I am wondering if anybody here have any experience on what is the best
way to dynamically allocate buffer for Option ROM during BIOS POST and
bootloader execution.
Since our code size is quite big, I don't want to waste any
significant code space for data storage in Option ROM image. The
option ROM requires around 20K for the data buffer and I'll want it to
be valid during the POST and after int19 OS bootstrap is running
because our code provide the int13 function to access this storage
controller. I was thinking to use PMM or EBDA. But according to PMM
spec, the PMM memory is not available after BIOS call int19. And EBDA
also seems not an option for me because the part of the buffer I use
is for the this controller's host DMA buffer. The EBDA memory address
can be changed if other Option ROM after mine also allocates EBDA
memory. Then my controller can overwrite the host memory that no
longer belongs to my option ROM. So what are the other methods to get
memory? Can I use any free conventional memory for my purpose? If so,
how do I guarantee that nobody else will touch it? Will OS bootloader
touch conventional memory?
Thanks a lot!
William
On Feb 11, 5:14 pm, "Rod Pemberton" <do_not_h...@havenone.cmm> wrote:
> "Rod Pemberton" <do_not_h...@havenone.cmm> wrote in message
>
> news:hl28r3$8me$1...@speranza.aioe.org...
>
>
>
> > "H. Peter Anvin" <spamt...@inspiretomorrow.net> wrote in message
Hi All,
I am wondering if anybody here have any experience on what is the best
way to dynamically allocate buffer for Option ROM during BIOS POST and
bootloader execution.
Since our code size is quite big, I don't want to waste any
significant code space for data storage in Option ROM image. The
option ROM requires around 20K for the data buffer and I'll want it to
be valid during the POST and after int19 OS bootstrap is running
because our code provide the int13 function to access this storage
controller. I was thinking to use PMM or EBDA. But according to PMM
spec, the PMM memory is not available after BIOS call int19. And EBDA
also seems not an option for me because the part of the buffer I use
is for the this controller's host DMA buffer. The EBDA memory address
can be changed if other Option ROM after mine also allocates EBDA
memory. Then my controller can overwrite the host memory that no
longer belongs to my option ROM. So what are the other methods to get
memory? Can I use any free conventional memory for my purpose? If so,
how do I guarantee that nobody else will touch it? Will OS bootloader
touch conventional memory?
Thanks a lot!
William
On Feb 11, 5:14 pm, "Rod Pemberton" <do_not_h...@havenone.cmm> wrote:
> "Rod Pemberton" <do_not_h...@havenone.cmm> wrote in message
>
> news:hl28r3$8me$1...@speranza.aioe.org...
>
>
>
> > "H. Peter Anvin" <spamt...@inspiretomorrow.net> wrote in message
The only way to (try to?) guarantee that that memory doesn't get used
is to hook to all BIOS functions that enumerate memory (e.g. int 0x12,
int 0x15 fxns 0xE801, 0xE820, etc etc) and return reduced ranges.
There may be other places to consider (e.g. CMOS, tables for
multiprocessor configurations).
Alex
The BIOS should keep track of where the EBDA is located separately
from the top-of-conventional-memory figure. On some systems the 2
bytes at 0x40e tells where the EBDA is. This won't change so if you
allocate 20k below it the EBDA will still be where it was and your
memory will be below the EBDA. For some references search for the
heading "the machine architecture" in
By the way, please post to Usenet *after* the message you are replying
to.
James
INT 0x12 reads the variable at 0x413.
-hpa
Perhaps I see this from another aspect, but all my BIOSes
(x486,K7,K8,Phenom II) report 639 KB free after POST/Int19h.
The one KB missing is just the realmode IDT at the bottom.
The top of convential memory (below a0000h) may be used from
BIOS as default stack until the bootloader setup its own stack.
DOS,winDOS,win.com,ntldr,grub,... may use this range for stack
during bootup and/or even lateron (ie:DOS 6.00) as well.
I'm not sure if INT19h wont set 0x413 to 639KB default in general.
__
wolfgang
Shouldn't the "missing" be the 1KB just below 640KB used for the EBDA?
RP
No. The 1K missing is the EBDA at the top. The realmode IDT and basic
BDA at the bottom are counted in those 639K.
-hpa
>> Perhaps I see this from another aspect, but all my BIOSes
>> (x486,K7,K8,Phenom II) report 639 KB free after POST/Int19h.
>> The one KB missing is just the realmode IDT at the bottom.
> No. The 1K missing is the EBDA at the top. The realmode IDT and basic
> BDA at the bottom are counted in those 639K.
Thanks, interesting and 'new' to me :)
Seems I skipped some information and ignored EBDA since decades.
same answer to Rod.
the question still is if INT19h wont reset 0413h to default.
__
wolfgang
It doesn't. PXE, for example, relies on that.
-hpa