aboutsummaryrefslogtreecommitdiffstats
path: root/com32/mboot/mem.c
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-06-08 14:07:37 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-06-08 14:07:37 +0100
commitb1b44de1264c40f806f672012bac590cf87eca92 (patch)
tree158a0f5b18260e65e6a68a24afc667786a0e37f8 /com32/mboot/mem.c
parente33c487c3930357a4f53455e019c72be0477ef98 (diff)
downloadsyslinux-b1b44de1264c40f806f672012bac590cf87eca92.tar.gz
syslinux-b1b44de1264c40f806f672012bac590cf87eca92.tar.xz
syslinux-b1b44de1264c40f806f672012bac590cf87eca92.zip
Delete all references to __com32.cs_bounce
The COM32 cs_bounce buffer is not usable with ELF modules, as we're trying to move to an environment where memory is dynamically allocated. All users of __com32.cs_bounce have been converted to using lmalloc() to allocate low memory. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/mboot/mem.c')
-rw-r--r--com32/mboot/mem.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/com32/mboot/mem.c b/com32/mboot/mem.c
index 6a31fac0..6e3995bf 100644
--- a/com32/mboot/mem.c
+++ b/com32/mboot/mem.c
@@ -49,9 +49,10 @@ struct e820_entry {
static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
{
com32sys_t ireg, oreg;
- struct e820_entry *e820buf = __com32.cs_bounce;
+ struct e820_entry *e820buf;
struct AddrRangeDesc *ard;
size_t ard_count, ard_space;
+ int rv = 0;
/* Use INT 12h to get DOS memory */
__intcall(0x12, &__com32_zero_regs, &oreg);
@@ -65,10 +66,14 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
*dosmem = 640 * 1024; /* Hope for the best... */
}
+ e820buf = lmalloc(sizeof(*e820buf));
+ if (!e820buf)
+ return 0;
+
/* Allocate initial space */
*ardp = ard = malloc(RANGE_ALLOC_BLOCK * sizeof *ard);
if (!ard)
- return 0;
+ goto out;
ard_count = 0;
ard_space = RANGE_ALLOC_BLOCK;
@@ -93,8 +98,10 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
if (ard_count >= ard_space) {
ard_space += RANGE_ALLOC_BLOCK;
*ardp = ard = realloc(ard, ard_space * sizeof *ard);
- if (!ard)
- return ard_count;
+ if (!ard) {
+ rv = ard_count;
+ goto out;
+ }
}
ard[ard_count].size = 20;
@@ -106,8 +113,10 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
ireg.ebx.l = oreg.ebx.l;
} while (oreg.ebx.l);
- if (ard_count)
- return ard_count;
+ if (ard_count) {
+ rv = ard_count;
+ goto out;
+ };
ard[0].size = 20;
ard[0].BaseAddr = 0;
@@ -129,10 +138,12 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
ard[2].BaseAddr = 16 << 20;
ard[2].Length = oreg.edx.w[0] << 16;
ard[2].Type = 1;
- return 3;
+ rv = 3;
} else {
- return 2;
+ rv = 2;
}
+
+ goto out;
}
/* Finally try INT 15h AH=88h */
@@ -142,10 +153,14 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
ard[1].BaseAddr = 1 << 20;
ard[1].Length = oreg.ecx.w[0] << 10;
ard[1].Type = 1;
- return 2;
+ rv = 2;
+ goto out;
}
- return 1; /* ... problematic ... */
+ rv = 1; /* ... problematic ... */
+out:
+ lfree(e820buf);
+ return rv;
}
void mboot_make_memmap(void)