david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Use {get,set}_fbms() so that allocated base memory is correctly hidden.

This commit is contained in:
Michael Brown 2007-01-14 00:01:16 +00:00
parent 0b0e34e667
commit f547f148d3
1 changed files with 7 additions and 12 deletions

View File

@ -23,6 +23,7 @@
#include <realmode.h> #include <realmode.h>
#include <bios.h> #include <bios.h>
#include <pnpbios.h> #include <pnpbios.h>
#include <basemem.h>
#include <gpxe/pci.h> #include <gpxe/pci.h>
#include <undi.h> #include <undi.h>
#include <undirom.h> #include <undirom.h>
@ -51,7 +52,6 @@ static SEGOFF16_t __data16 ( undi_loader_entry );
*/ */
int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) { int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
struct s_PXE ppxe; struct s_PXE ppxe;
uint16_t fbms;
unsigned int fbms_seg; unsigned int fbms_seg;
uint16_t exit; uint16_t exit;
int rc; int rc;
@ -65,9 +65,8 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
undi_loader.DI = find_pnp_bios(); undi_loader.DI = find_pnp_bios();
/* Allocate base memory for PXE stack */ /* Allocate base memory for PXE stack */
get_real ( fbms, BDA_SEG, BDA_FBMS ); undi->restore_fbms = get_fbms();
undi->restore_fbms = fbms; fbms_seg = ( undi->restore_fbms << 6 );
fbms_seg = ( fbms << 6 );
fbms_seg -= ( ( undirom->code_size + 0x0f ) >> 4 ); fbms_seg -= ( ( undirom->code_size + 0x0f ) >> 4 );
undi_loader.UNDI_CS = fbms_seg; undi_loader.UNDI_CS = fbms_seg;
fbms_seg -= ( ( undirom->data_size + 0x0f ) >> 4 ); fbms_seg -= ( ( undirom->data_size + 0x0f ) >> 4 );
@ -129,9 +128,8 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
undi->entry.segment, undi->entry.offset ); undi->entry.segment, undi->entry.offset );
/* Update free base memory counter */ /* Update free base memory counter */
fbms = ( fbms_seg >> 6 ); undi->fbms = ( fbms_seg >> 6 );
put_real ( fbms, BDA_SEG, BDA_FBMS ); set_fbms ( undi->fbms );
undi->fbms = fbms;
DBGC ( undi, "UNDI %p using [%d,%d) kB of base memory\n", DBGC ( undi, "UNDI %p using [%d,%d) kB of base memory\n",
undi, undi->fbms, undi->restore_fbms ); undi, undi->fbms, undi->restore_fbms );
@ -149,7 +147,6 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
*/ */
int undi_unload ( struct undi_device *undi ) { int undi_unload ( struct undi_device *undi ) {
static uint32_t dead = 0xdeaddead; static uint32_t dead = 0xdeaddead;
uint16_t fbms;
DBGC ( undi, "UNDI %p unloading\n", undi ); DBGC ( undi, "UNDI %p unloading\n", undi );
@ -160,12 +157,10 @@ int undi_unload ( struct undi_device *undi ) {
put_real ( dead, undi->ppxe.segment, undi->ppxe.offset ); put_real ( dead, undi->ppxe.segment, undi->ppxe.offset );
/* Free base memory, if possible */ /* Free base memory, if possible */
get_real ( fbms, BDA_SEG, BDA_FBMS ); if ( undi->fbms == get_fbms() ) {
if ( fbms == undi->fbms ) {
DBGC ( undi, "UNDI %p freeing [%d,%d) kB of base memory\n", DBGC ( undi, "UNDI %p freeing [%d,%d) kB of base memory\n",
undi, undi->fbms, undi->restore_fbms ); undi, undi->fbms, undi->restore_fbms );
fbms = undi->restore_fbms; set_fbms ( undi->restore_fbms );
put_real ( fbms, BDA_SEG, BDA_FBMS );
return 0; return 0;
} else { } else {
DBGC ( undi, "UNDI %p leaking [%d,%d) kB of base memory\n", DBGC ( undi, "UNDI %p leaking [%d,%d) kB of base memory\n",