diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-02-12 18:38:39 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-02-12 18:39:36 -0800 |
commit | 32a5fabdf5a79aa339e4b6a9b710a287792fe6ad (patch) | |
tree | 3540124b8f8385d7a52994b3bb8f42f7f4fdbb4b /com32/lib/syslinux/shuffle.c | |
parent | 4980115d540a6ccfcfb141312c7f4f017972d316 (diff) | |
download | syslinux-32a5fabdf5a79aa339e4b6a9b710a287792fe6ad.tar.gz |
The shuffle descriptors need to be unused for input *and* outputsyslinux-3.62-pre3
The memory used to hold shuffle descriptors must be unused during the
entire execution of the shuffle sequence, and therefore needs to be
free at input *and* output time.
Once we have picked a region for the shuffle descriptors, we can free
this working copy and start over with a clean memory map, the only
thing we do there is mark as reserved the memory used by the
descriptors.
Diffstat (limited to 'com32/lib/syslinux/shuffle.c')
-rw-r--r-- | com32/lib/syslinux/shuffle.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/com32/lib/syslinux/shuffle.c b/com32/lib/syslinux/shuffle.c index 708382c7..cb2751af 100644 --- a/com32/lib/syslinux/shuffle.c +++ b/com32/lib/syslinux/shuffle.c @@ -89,17 +89,28 @@ int syslinux_prepare_shuffle(struct syslinux_movelist *fraglist, nzero++; } + /* Find the larges contiguous region unused by input *and* output; + this is where we put the move descriptor list */ + rxmap = syslinux_dup_memmap(memmap); + if (!rxmap) + goto bail; for (mp = fraglist; mp; mp = mp->next) { - if (syslinux_add_memmap(&rxmap, mp->src, mp->len, SMT_ALLOC)) + if (syslinux_add_memmap(&rxmap, mp->src, mp->len, SMT_ALLOC) || + syslinux_add_memmap(&rxmap, mp->dst, mp->len, SMT_ALLOC)) goto bail; } - if (syslinux_memmap_largest(rxmap, SMT_FREE, &desczone, &descfree)) goto bail; + syslinux_free_memmap(rxmap); + dprintf("desczone = 0x%08x, descfree = 0x%08x\n", desczone, descfree); + rxmap = syslinux_dup_memmap(memmap); + if (!rxmap) + goto bail; + desc_blocks = (nzero+DESC_BLOCK_SIZE)/(DESC_BLOCK_SIZE-1); for (;;) { addr_t descmem = desc_blocks* @@ -108,8 +119,9 @@ int syslinux_prepare_shuffle(struct syslinux_movelist *fraglist, if (descfree < descmem) goto bail; /* No memory block large enough */ + /* Mark memory used by shuffle descriptors as reserved */ descaddr = desczone + descfree - descmem; - if (syslinux_add_memmap(&rxmap, descaddr, descmem, SMT_ALLOC)) + if (syslinux_add_memmap(&rxmap, descaddr, descmem, SMT_RESERVED)) goto bail; #if DEBUG @@ -118,7 +130,7 @@ int syslinux_prepare_shuffle(struct syslinux_movelist *fraglist, if (syslinux_compute_movelist(&moves, fraglist, rxmap)) goto bail; - + nmoves = 0; for (mp = moves; mp; mp = mp->next) nmoves++; @@ -182,7 +194,7 @@ int syslinux_prepare_shuffle(struct syslinux_movelist *fraglist, dp++; np++; nb = 0; } - + dp->dst = ml->start; dp->src = (addr_t)-1; /* bzero region */ dp->len = ml->next->start - ml->start; |