Raphael S.Carvalho
2013-Oct-17 22:05 UTC
[syslinux] [PATCH] chain: Fix chainloading on 6.02
From: Raphael S. Carvalho <raphael.scarv at gmail.com> My commit 09f4ac33 broke 'com32/lib/syslinux/disk.c' __lowmem doesn't work for declarations outside the core. Using __lowmem outside the core wouldn't have the desired effect, then lmalloc must be used instead to store dapa into the correct section (".lowmem"). Reported-by: Dark Raven <drdarkraven at gmail.com> Signed-off-by: Raphael S. Carvalho <raphael.scarv at gmail.com> --- com32/lib/syslinux/disk.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c index 0b0c737..47ecb52 100644 --- a/com32/lib/syslinux/disk.c +++ b/com32/lib/syslinux/disk.c @@ -171,22 +171,28 @@ out: static void *ebios_setup(const struct disk_info *const diskinfo, com32sys_t *inreg, uint64_t lba, uint8_t count, uint8_t op_code) { - static __lowmem struct disk_ebios_dapa dapa; + static struct disk_ebios_dapa *dapa = NULL; void *buf; + if (!dapa) { + dapa = lmalloc(sizeof *dapa); + if (!dapa) + return NULL; + } + buf = lmalloc(count * diskinfo->bps); if (!buf) return NULL; - dapa.len = sizeof(dapa); - dapa.count = count; - dapa.off = OFFS(buf); - dapa.seg = SEG(buf); - dapa.lba = lba; + dapa->len = sizeof(*dapa); + dapa->count = count; + dapa->off = OFFS(buf); + dapa->seg = SEG(buf); + dapa->lba = lba; inreg->eax.b[1] = op_code; - inreg->esi.w[0] = OFFS(&dapa); - inreg->ds = SEG(&dapa); + inreg->esi.w[0] = OFFS(dapa); + inreg->ds = SEG(dapa); inreg->edx.b[0] = diskinfo->disk; return buf; -- 1.7.2.5
On 10/17/2013 03:05 PM, Raphael S.Carvalho wrote:> From: Raphael S. Carvalho <raphael.scarv at gmail.com> > > My commit 09f4ac33 broke 'com32/lib/syslinux/disk.c' > > __lowmem doesn't work for declarations outside the core. > Using __lowmem outside the core wouldn't have the desired effect, then lmalloc > must be used instead to store dapa into the correct section (".lowmem"). > > Reported-by: Dark Raven <drdarkraven at gmail.com> > Signed-off-by: Raphael S. Carvalho <raphael.scarv at gmail.com>It probably would make sense to unify this with the diskio code in the core (ideally making it so the core code can simply be called.) In particular, the diskio code in the core handles some corner cases which this code doesn't, e.g. firmware which doesn't handle 64K crossings and so on. -hpa
Maybe Matching Threads
- [PATCH 2/4 v3] com32/disk: Code cleanup at disk_write_sectors and disk_read_sectors.
- [PATCH 2/2 v2] com32/disk: Improve flow at disk_write_sectors and disk_read_sectors.
- [PATCH] com32/disk: add UEFI support
- [PATCH 2/2] com32/disk: Improve flow at disk_write_sectors and disk_read_sectors.
- [GIT PULL] elflink bug fixes