diff options
| author | Matt Fleming <matt.fleming@linux.intel.com> | 2011-05-25 08:39:47 +0100 |
|---|---|---|
| committer | Matt Fleming <matt.fleming@linux.intel.com> | 2011-05-25 08:44:48 +0100 |
| commit | 565952b9d86d769471d500caab5ebba9bc36c363 (patch) | |
| tree | 46ca624afd1d6997d4ebfb91345613b42deb5e70 /com32/lib/syslinux | |
| parent | eecc876ef99deb4cf753db5b31d5eb1f83600b6c (diff) | |
| download | syslinux-565952b9d86d769471d500caab5ebba9bc36c363.tar.gz | |
ldlinux: Add support for Auxillary Data Vector
Move all the code for the ADV into ldlinux so that it doesn't have any
dependencies on other modules.
We also need a way to initialize the ADV from ldlinux, so add another
vector to the comboot API.
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
Diffstat (limited to 'com32/lib/syslinux')
| -rw-r--r-- | com32/lib/syslinux/adv.c | 49 | ||||
| -rw-r--r-- | com32/lib/syslinux/advwrite.c | 45 | ||||
| -rw-r--r-- | com32/lib/syslinux/getadv.c | 68 | ||||
| -rw-r--r-- | com32/lib/syslinux/setadv.c | 116 |
4 files changed, 0 insertions, 278 deletions
diff --git a/com32/lib/syslinux/adv.c b/com32/lib/syslinux/adv.c deleted file mode 100644 index be38e89d..00000000 --- a/com32/lib/syslinux/adv.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall - * be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * ----------------------------------------------------------------------- */ - -/* - * syslinux/adv.c - * - * Access the syslinux auxilliary data vector - */ - -#include <syslinux/adv.h> -#include <klibc/compiler.h> -#include <com32.h> - -void *__syslinux_adv_ptr; -size_t __syslinux_adv_size; - -void __constructor __syslinux_get_adv(void) -{ - static com32sys_t reg; - - reg.eax.w[0] = 0x001c; - __intcall(0x22, ®, ®); - __syslinux_adv_ptr = MK_PTR(reg.es, reg.ebx.w[0]); - __syslinux_adv_size = reg.ecx.w[0]; -} diff --git a/com32/lib/syslinux/advwrite.c b/com32/lib/syslinux/advwrite.c deleted file mode 100644 index 4152eea5..00000000 --- a/com32/lib/syslinux/advwrite.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall - * be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * ----------------------------------------------------------------------- */ - -/* - * syslinux/advwrite.c - * - * Write back the ADV - */ - -#include <syslinux/adv.h> -#include <klibc/compiler.h> -#include <com32.h> - -int syslinux_adv_write(void) -{ - static com32sys_t reg; - - reg.eax.w[0] = 0x001d; - __intcall(0x22, ®, ®); - return (reg.eflags.l & EFLAGS_CF) ? -1 : 0; -} diff --git a/com32/lib/syslinux/getadv.c b/com32/lib/syslinux/getadv.c deleted file mode 100644 index 5578313e..00000000 --- a/com32/lib/syslinux/getadv.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall - * be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * ----------------------------------------------------------------------- */ - -/* - * syslinux/getadv.c - * - * Get a data item from the auxilliary data vector. Returns a pointer - * and sets *size on success; NULL on failure. - */ - -#include <syslinux/adv.h> -#include <klibc/compiler.h> -#include <inttypes.h> - -const void *syslinux_getadv(int tag, size_t * size) -{ - const uint8_t *p; - size_t left; - - p = syslinux_adv_ptr(); - left = syslinux_adv_size(); - - while (left >= 2) { - uint8_t ptag = *p++; - size_t plen = *p++; - left -= 2; - - if (ptag == ADV_END) - return NULL; /* Not found */ - - if (left < plen) - return NULL; /* Item overrun */ - - if (ptag == tag) { - *size = plen; - return p; - } - - p += plen; - left -= plen; - } - - return NULL; -} diff --git a/com32/lib/syslinux/setadv.c b/com32/lib/syslinux/setadv.c deleted file mode 100644 index 40f00a4e..00000000 --- a/com32/lib/syslinux/setadv.c +++ /dev/null @@ -1,116 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved - * Copyright 2009 Intel Corporation; author: H. Peter Anvin - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall - * be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * ----------------------------------------------------------------------- */ - -/* - * syslinux/setadv.c - * - * (Over)write a data item in the auxilliary data vector. To - * delete an item, set its length to zero. - * - * Return 0 on success, -1 on error, and set errno. - * - * NOTE: Data is not written to disk unless - * syslinux_adv_write() is called. - */ - -#include <syslinux/adv.h> -#include <klibc/compiler.h> -#include <inttypes.h> -#include <string.h> -#include <errno.h> -#include <alloca.h> - -int syslinux_setadv(int tag, size_t size, const void *data) -{ - uint8_t *p, *advtmp; - size_t rleft, left; - - if ((unsigned)tag - 1 > 254) { - errno = EINVAL; - return -1; /* Impossible tag value */ - } - - if (size > 255) { - errno = ENOSPC; /* Max 255 bytes for a data item */ - return -1; - } - - rleft = left = syslinux_adv_size(); - p = advtmp = alloca(left); - memcpy(p, syslinux_adv_ptr(), left); /* Make working copy */ - - while (rleft >= 2) { - uint8_t ptag = p[0]; - size_t plen = p[1] + 2; - - if (ptag == ADV_END) - break; - - if (ptag == tag) { - /* Found our tag. Delete it. */ - - if (plen >= rleft) { - /* Entire remainder is our tag */ - break; - } - memmove(p, p + plen, rleft - plen); - rleft -= plen; /* Fewer bytes to read, but not to write */ - } else { - /* Not our tag */ - if (plen > rleft) - break; /* Corrupt tag (overrun) - overwrite it */ - - left -= plen; - rleft -= plen; - p += plen; - } - } - - /* Now (p, left) reflects the position to write in and how much space - we have for our data. */ - - if (size) { - if (left < size + 2) { - errno = ENOSPC; /* Not enough space for data */ - return -1; - } - - *p++ = tag; - *p++ = size; - memcpy(p, data, size); - p += size; - left -= size + 2; - } - - memset(p, 0, left); - - /* If we got here, everything went OK, commit the write to low memory */ - memcpy(syslinux_adv_ptr(), advtmp, syslinux_adv_size()); - - return 0; -} |
