aboutsummaryrefslogtreecommitdiffstats
path: root/com32/chain/utility.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/chain/utility.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/chain/utility.c')
-rw-r--r--com32/chain/utility.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/com32/chain/utility.c b/com32/chain/utility.c
index fb59551b..b54e0cd2 100644
--- a/com32/chain/utility.c
+++ b/com32/chain/utility.c
@@ -94,24 +94,30 @@ void lba2chs(disk_chs *dst, const struct disk_info *di, uint64_t lba, uint32_t m
uint32_t get_file_lba(const char *filename)
{
com32sys_t inregs;
- uint32_t lba;
+ uint32_t lba = 0;
+ int size = 65536;
+ char *buf;
/* Start with clean registers */
memset(&inregs, 0, sizeof(com32sys_t));
+ buf = lmalloc(size);
+ if (!buf)
+ return 0;
+
/* Put the filename in the bounce buffer */
- strlcpy(__com32.cs_bounce, filename, __com32.cs_bounce_size);
+ strlcpy(buf, filename, size);
/* Call comapi_open() which returns a structure pointer in SI
* to a structure whose first member happens to be the LBA.
*/
inregs.eax.w[0] = 0x0006;
- inregs.esi.w[0] = OFFS(__com32.cs_bounce);
- inregs.es = SEG(__com32.cs_bounce);
+ inregs.esi.w[0] = OFFS(buf);
+ inregs.es = SEG(buf);
__com32.cs_intcall(0x22, &inregs, &inregs);
if ((inregs.eflags.l & EFLAGS_CF) || inregs.esi.w[0] == 0) {
- return 0; /* Filename not found */
+ goto fail; /* Filename not found */
}
/* Since the first member is the LBA, we simply cast */
@@ -121,14 +127,16 @@ uint32_t get_file_lba(const char *filename)
memset(&inregs, 0, sizeof(com32sys_t));
/* Put the filename in the bounce buffer */
- strlcpy(__com32.cs_bounce, filename, __com32.cs_bounce_size);
+ strlcpy(buf, filename, size);
/* Call comapi_close() to free the structure */
inregs.eax.w[0] = 0x0008;
- inregs.esi.w[0] = OFFS(__com32.cs_bounce);
- inregs.es = SEG(__com32.cs_bounce);
+ inregs.esi.w[0] = OFFS(buf);
+ inregs.es = SEG(buf);
__com32.cs_intcall(0x22, &inregs, &inregs);
+fail:
+ lfree(buf);
return lba;
}