From 3db568e482918d54739cf6d27955a3a5d3d5cd12 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Sat, 5 Feb 2011 16:56:21 -0500 Subject: memdisk: New parameter (int15maxres) for specifying maximum RAM Add a new parameter, int15maxres, for specifying (in decimal bytes) the maximum amount of free RAM that different calls will return. The RAM is tagged in INT15h AXe820h as reserved in order to satisfy this. --- memdisk/setup.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/memdisk/setup.c b/memdisk/setup.c index 43151898..bf3d5d63 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -705,6 +705,39 @@ static int stack_needed(void) return v; } +/* + * Specify max RAM by reservation + * Adds a reservation to data in INT15h to prevent access to the top of RAM + * if there's any above the point specified. + */ +void int15maxres(uint32_t restop) +{ + uint32_t ramtop; + + if (high_mem) { + ramtop = high_mem + (1<<24); + } else if (low_mem) { + ramtop = low_mem + (1<<20); + } else { + ramtop = 0; + } + + /* printf(" TOP RAM-%08x RES-%08x", ramtop, restop); */ + if (restop < ramtop) { + /* printf(" (A)"); */ + insertrange(restop, (ramtop - restop), 3); + parse_mem(); + } + if (high_mem) { + ramtop = high_mem + (1<<24); + } else if (low_mem) { + ramtop = low_mem + (1<<20); + } else { + ramtop = 0; + } + /* printf(" NOW RAM-%08x\n", ramtop); */ +} + struct real_mode_args rm_args; /* @@ -737,6 +770,7 @@ void setup(const struct real_mode_args *rm_args_ptr) int no_bpt; /* No valid BPT presented */ uint32_t boot_seg = 0; /* Meaning 0000:7C00 */ uint32_t boot_len = 512; /* One sector */ + const char *p; /* We need to copy the rm_args into their proper place */ memcpy(&rm_args, rm_args_ptr, sizeof rm_args); @@ -942,6 +976,10 @@ void setup(const struct real_mode_args *rm_args_ptr) pptr->cd_pkt.geom3 = (uint8_t)(pptr->heads); } + if ((p = getcmditem("int15maxres")) != CMD_NOTFOUND) { + int15maxres(atou(p)); + } + /* The size is given by hptr->total_size plus the size of the E820 map -- 12 bytes per range; we may need as many as 2 additional ranges (each insertrange() can worst-case turn 1 area into 3) -- cgit v1.2.1 From 8bfabb61d921d429b2b3caa151779ced276316d9 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Sun, 6 Feb 2011 22:03:55 -0500 Subject: memdisk/setup: Move duplicate code in int15maxres to new function --- memdisk/setup.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index bf3d5d63..de1433a2 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -705,6 +705,17 @@ static int stack_needed(void) return v; } +uint32_t getramtop(void) +{ + if (high_mem) { + return high_mem + (1<<24); + } else if (low_mem) { + return low_mem + (1<<20); + } else { + return 0; + } +} + /* * Specify max RAM by reservation * Adds a reservation to data in INT15h to prevent access to the top of RAM @@ -714,27 +725,14 @@ void int15maxres(uint32_t restop) { uint32_t ramtop; - if (high_mem) { - ramtop = high_mem + (1<<24); - } else if (low_mem) { - ramtop = low_mem + (1<<20); - } else { - ramtop = 0; - } - + ramtop = getramtop(); /* printf(" TOP RAM-%08x RES-%08x", ramtop, restop); */ if (restop < ramtop) { /* printf(" (A)"); */ insertrange(restop, (ramtop - restop), 3); parse_mem(); } - if (high_mem) { - ramtop = high_mem + (1<<24); - } else if (low_mem) { - ramtop = low_mem + (1<<20); - } else { - ramtop = 0; - } + ramtop = getramtop(); /* printf(" NOW RAM-%08x\n", ramtop); */ } -- cgit v1.2.1 From 3bf596b7900af8c07231f5d316cf15b303fffb7a Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Sun, 6 Feb 2011 22:04:58 -0500 Subject: memdisk/setup: change option to mem --- memdisk/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index de1433a2..623c9cd0 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -974,7 +974,7 @@ void setup(const struct real_mode_args *rm_args_ptr) pptr->cd_pkt.geom3 = (uint8_t)(pptr->heads); } - if ((p = getcmditem("int15maxres")) != CMD_NOTFOUND) { + if ((p = getcmditem("mem")) != CMD_NOTFOUND) { int15maxres(atou(p)); } -- cgit v1.2.1 From e10b3d5c70245484868d85a18c331e410d8b1a2d Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Sun, 6 Feb 2011 22:59:53 -0500 Subject: memdisk/setup: Change int15maxres to parse memory range lines Only touch the ranges that are type 1 (available) --- memdisk/setup.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index 623c9cd0..75e84756 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -724,16 +724,21 @@ uint32_t getramtop(void) void int15maxres(uint32_t restop) { uint32_t ramtop; + struct e820range *ep; ramtop = getramtop(); - /* printf(" TOP RAM-%08x RES-%08x", ramtop, restop); */ - if (restop < ramtop) { - /* printf(" (A)"); */ - insertrange(restop, (ramtop - restop), 3); - parse_mem(); + for (ep = ranges; ep->type != -1U; ep++) { + if (ep->type == 1) { /* Only if available */ + if (ep->start >= restop) { + printf(" %08x -> 2\n", ep->start); + ep->type = 2; + } else if (ep[1].start > restop) { + printf(" +%08x =2; cut %08x\n", restop, ep->start); + insertrange(restop, (ep[1].start - restop), 2); + } + } } - ramtop = getramtop(); - /* printf(" NOW RAM-%08x\n", ramtop); */ + parse_mem(); } struct real_mode_args rm_args; -- cgit v1.2.1 From 4fb75f3467c0924e0ba9d471dd634e227d1d96d0 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Sun, 6 Feb 2011 23:09:57 -0500 Subject: memdisk/setup: int15maxres: Use 1 const; comment out printf() --- memdisk/setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index 75e84756..9dad0942 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -725,16 +725,17 @@ void int15maxres(uint32_t restop) { uint32_t ramtop; struct e820range *ep; + const int int15restype = 2; ramtop = getramtop(); for (ep = ranges; ep->type != -1U; ep++) { if (ep->type == 1) { /* Only if available */ if (ep->start >= restop) { - printf(" %08x -> 2\n", ep->start); - ep->type = 2; + /* printf(" %08x -> 2\n", ep->start); */ + ep->type = int15restype; } else if (ep[1].start > restop) { - printf(" +%08x =2; cut %08x\n", restop, ep->start); - insertrange(restop, (ep[1].start - restop), 2); + /* printf(" +%08x =2; cut %08x\n", restop, ep->start); */ + insertrange(restop, (ep[1].start - restop), int15restype); } } } -- cgit v1.2.1 From 9db4955a474ef60e9f405fad37aa3bf9ab358c7f Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Sun, 6 Feb 2011 23:16:57 -0500 Subject: memdisk/setup: remove unneeded code associated with int15maxres --- memdisk/setup.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index 9dad0942..7286210e 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -705,17 +705,6 @@ static int stack_needed(void) return v; } -uint32_t getramtop(void) -{ - if (high_mem) { - return high_mem + (1<<24); - } else if (low_mem) { - return low_mem + (1<<20); - } else { - return 0; - } -} - /* * Specify max RAM by reservation * Adds a reservation to data in INT15h to prevent access to the top of RAM @@ -723,11 +712,9 @@ uint32_t getramtop(void) */ void int15maxres(uint32_t restop) { - uint32_t ramtop; struct e820range *ep; const int int15restype = 2; - ramtop = getramtop(); for (ep = ranges; ep->type != -1U; ep++) { if (ep->type == 1) { /* Only if available */ if (ep->start >= restop) { -- cgit v1.2.1 From fac8edfb3d4e80eaf23c2bab3ff47d59ae472934 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Mon, 7 Feb 2011 18:53:46 -0500 Subject: memdisk: Add strtoull from libcom32 by #include --- memdisk/Makefile | 1 + memdisk/ctypes.c | 1 + memdisk/strntoumax.c | 1 + memdisk/strtoull.c | 1 + memdisk/strtox.c | 1 + 5 files changed, 5 insertions(+) create mode 100644 memdisk/ctypes.c create mode 100644 memdisk/strntoumax.c create mode 100644 memdisk/strtoull.c create mode 100644 memdisk/strtox.c diff --git a/memdisk/Makefile b/memdisk/Makefile index d2f20c51..0f519b20 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -39,6 +39,7 @@ endif OBJS16 = init.o16 init32.o OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \ memmove.o unzip.o dskprobe.o eltorito.o \ + ctypes.o strntoumax.o strtoull.o \ memdisk_chs_512.o memdisk_edd_512.o \ memdisk_iso_512.o memdisk_iso_2048.o diff --git a/memdisk/ctypes.c b/memdisk/ctypes.c new file mode 100644 index 00000000..f87ca055 --- /dev/null +++ b/memdisk/ctypes.c @@ -0,0 +1 @@ +#include "../com32/lib/ctypes.c" diff --git a/memdisk/strntoumax.c b/memdisk/strntoumax.c new file mode 100644 index 00000000..6fa2f357 --- /dev/null +++ b/memdisk/strntoumax.c @@ -0,0 +1 @@ +#include "../com32/lib/strntoumax.c" diff --git a/memdisk/strtoull.c b/memdisk/strtoull.c new file mode 100644 index 00000000..e2425df3 --- /dev/null +++ b/memdisk/strtoull.c @@ -0,0 +1 @@ +#include "../com32/lib/strtoull.c" diff --git a/memdisk/strtox.c b/memdisk/strtox.c new file mode 100644 index 00000000..445681f4 --- /dev/null +++ b/memdisk/strtox.c @@ -0,0 +1 @@ +#include "../com32/lib/strtox.c" -- cgit v1.2.1 From d3c03fe651a932f058aca7596311ada76b80ba81 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Mon, 7 Feb 2011 20:13:48 -0500 Subject: libutil: copy suffix_number() from com32/lib/syslinux/load_linux.c --- com32/libutil/Makefile | 3 +- com32/libutil/include/suffix_number.h | 41 ++++++++++++++++++++ com32/libutil/suffix_number.c | 72 +++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 com32/libutil/include/suffix_number.h create mode 100644 com32/libutil/suffix_number.c diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile index 02789ca6..d9466aa5 100644 --- a/com32/libutil/Makefile +++ b/com32/libutil/Makefile @@ -33,7 +33,8 @@ topdir = ../.. include ../MCONFIG LIBOBJS = ansiline.o ansiraw.o get_key.o sha1hash.o unbase64.o \ - md5.o crypt-md5.o sha256crypt.o sha512crypt.o base64.o + md5.o crypt-md5.o sha256crypt.o sha512crypt.o base64.o \ + suffix_number.o LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS)) all: libutil_com.a libutil_lnx.a diff --git a/com32/libutil/include/suffix_number.h b/com32/libutil/include/suffix_number.h new file mode 100644 index 00000000..e2349b41 --- /dev/null +++ b/com32/libutil/include/suffix_number.h @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------- * + * + * 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. + * + * ----------------------------------------------------------------------- */ + +/* + * suffix_number.h + * + * Definitions used to convert a string of a number with potential SI suffix + * to int-type. + */ + +#ifndef LIBUTIL_SUFFIX_NUMBER_H +#define LIBUTIL_SUFFIX_NUMBER_H + +unsigned long long suffix_number(const char *); + +#endif /* LIBUTIL_SUFFIX_NUMBER_H */ + diff --git a/com32/libutil/suffix_number.c b/com32/libutil/suffix_number.c new file mode 100644 index 00000000..df073a00 --- /dev/null +++ b/com32/libutil/suffix_number.c @@ -0,0 +1,72 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2009 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. + * + * ----------------------------------------------------------------------- */ + +/* + * suffix_number.c + * + * Convert a string of a number with potential SI suffix to int-type + */ + +#include +#include + +/* Get a value with a potential suffix (k/m/g/t/p/e) */ +unsigned long long suffix_number(const char *str) +{ + char *ep; + unsigned long long v; + int shift; + + v = strtoull(str, &ep, 0); + switch (*ep | 0x20) { + case 'k': + shift = 10; + break; + case 'm': + shift = 20; + break; + case 'g': + shift = 30; + break; + case 't': + shift = 40; + break; + case 'p': + shift = 50; + break; + case 'e': + shift = 60; + break; + default: + shift = 0; + break; + } + v <<= shift; + + return v; +} -- cgit v1.2.1 From 79c5db6df34806d082fbf7d7c40e249f6a10d823 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Mon, 7 Feb 2011 20:53:13 -0500 Subject: memdisk/setup: Allow suffix processing on mem= parameter --- memdisk/Makefile | 4 ++-- memdisk/setup.c | 12 ++++++++++-- memdisk/suffix_number.c | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 memdisk/suffix_number.c diff --git a/memdisk/Makefile b/memdisk/Makefile index 0f519b20..73305d5e 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -15,7 +15,7 @@ topdir = .. include $(topdir)/MCONFIG.embedded -include $(topdir)/version.mk -INCLUDES = -I$(topdir)/com32/include +INCLUDES = -I$(topdir)/com32/include -I$(topdir)/com32/libutil/include CFLAGS += -D__MEMDISK__ -DDATE='"$(DATE)"' LDFLAGS = $(GCCOPT) -g NASM = nasm @@ -39,7 +39,7 @@ endif OBJS16 = init.o16 init32.o OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \ memmove.o unzip.o dskprobe.o eltorito.o \ - ctypes.o strntoumax.o strtoull.o \ + ctypes.o strntoumax.o strtoull.o suffix_number.o \ memdisk_chs_512.o memdisk_edd_512.o \ memdisk_iso_512.o memdisk_iso_2048.o diff --git a/memdisk/setup.c b/memdisk/setup.c index 7286210e..8317971e 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -14,6 +14,8 @@ * ----------------------------------------------------------------------- */ #include +#include +#include #include "bda.h" #include "dskprobe.h" #include "e820.h" @@ -710,11 +712,17 @@ static int stack_needed(void) * Adds a reservation to data in INT15h to prevent access to the top of RAM * if there's any above the point specified. */ -void int15maxres(uint32_t restop) +void int15maxres(unsigned long long restop_ull) { + uint32_t restop; struct e820range *ep; const int int15restype = 2; + /* insertrange() works on uint32_t */ + restop = min(restop_ull, UINT32_MAX); + /* printf(" int15maxres '%08x%08x' => %08x\n", + (unsigned int)(restop_ull>>32), (unsigned int)restop_ull, restop); */ + for (ep = ranges; ep->type != -1U; ep++) { if (ep->type == 1) { /* Only if available */ if (ep->start >= restop) { @@ -968,7 +976,7 @@ void setup(const struct real_mode_args *rm_args_ptr) } if ((p = getcmditem("mem")) != CMD_NOTFOUND) { - int15maxres(atou(p)); + int15maxres(suffix_number(p)); } /* The size is given by hptr->total_size plus the size of the E820 diff --git a/memdisk/suffix_number.c b/memdisk/suffix_number.c new file mode 100644 index 00000000..dd266426 --- /dev/null +++ b/memdisk/suffix_number.c @@ -0,0 +1 @@ +#include "../com32/libutil/suffix_number.c" -- cgit v1.2.1 From ecf7474b269c442d1277c08a50a487a9fc0b574e Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 12:05:25 -0500 Subject: memdisk: remove unnecessary files; add vpath instead; add files to CSRC This removes the need to have these tiny files around. This also changes it to be relative to $(topdir), allowing for memdisk to be moved if needed in the future. --- memdisk/Makefile | 6 +++++- memdisk/ctypes.c | 1 - memdisk/strntoumax.c | 1 - memdisk/strtoull.c | 1 - memdisk/strtox.c | 1 - memdisk/suffix_number.c | 1 - 6 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 memdisk/ctypes.c delete mode 100644 memdisk/strntoumax.c delete mode 100644 memdisk/strtoull.c delete mode 100644 memdisk/strtox.c delete mode 100644 memdisk/suffix_number.c diff --git a/memdisk/Makefile b/memdisk/Makefile index 73305d5e..beead608 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -43,12 +43,16 @@ OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \ memdisk_chs_512.o memdisk_edd_512.o \ memdisk_iso_512.o memdisk_iso_2048.o -CSRC = setup.c msetup.c e820func.c conio.c unzip.c dskprobe.c eltorito.c +CSRC = setup.c msetup.c e820func.c conio.c unzip.c dskprobe.c eltorito.c \ + $(topdir)/com32/lib/ctypes.c $(topdir)/com32/lib/strntoumax.c \ + $(topdir)/com32/lib/strtoull.c $(topdir)/com32/libutil/suffix_number.c SSRC = start32.S memcpy.S memset.S memmove.S NASMSRC = memdisk_chs_512.asm memdisk_edd_512.asm \ memdisk_iso_512.asm memdisk_iso_2048.asm \ memdisk16.asm +vpath %.c $(topdir)/com32/lib:$(topdir)/com32/libutil + all: memdisk # e820test # tidy, clean removes everything except the final binary diff --git a/memdisk/ctypes.c b/memdisk/ctypes.c deleted file mode 100644 index f87ca055..00000000 --- a/memdisk/ctypes.c +++ /dev/null @@ -1 +0,0 @@ -#include "../com32/lib/ctypes.c" diff --git a/memdisk/strntoumax.c b/memdisk/strntoumax.c deleted file mode 100644 index 6fa2f357..00000000 --- a/memdisk/strntoumax.c +++ /dev/null @@ -1 +0,0 @@ -#include "../com32/lib/strntoumax.c" diff --git a/memdisk/strtoull.c b/memdisk/strtoull.c deleted file mode 100644 index e2425df3..00000000 --- a/memdisk/strtoull.c +++ /dev/null @@ -1 +0,0 @@ -#include "../com32/lib/strtoull.c" diff --git a/memdisk/strtox.c b/memdisk/strtox.c deleted file mode 100644 index 445681f4..00000000 --- a/memdisk/strtox.c +++ /dev/null @@ -1 +0,0 @@ -#include "../com32/lib/strtox.c" diff --git a/memdisk/suffix_number.c b/memdisk/suffix_number.c deleted file mode 100644 index dd266426..00000000 --- a/memdisk/suffix_number.c +++ /dev/null @@ -1 +0,0 @@ -#include "../com32/libutil/suffix_number.c" -- cgit v1.2.1 From 46e063f4cd54b2325eab16bfa9f52bb984e33ead Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 19:40:43 -0500 Subject: memdisk: Undo addition of vpath and removal of tiny files --- memdisk/Makefile | 2 -- memdisk/ctypes.c | 1 + memdisk/strntoumax.c | 1 + memdisk/strtoull.c | 1 + memdisk/strtox.c | 1 + memdisk/suffix_number.c | 1 + 6 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 memdisk/ctypes.c create mode 100644 memdisk/strntoumax.c create mode 100644 memdisk/strtoull.c create mode 100644 memdisk/strtox.c create mode 100644 memdisk/suffix_number.c diff --git a/memdisk/Makefile b/memdisk/Makefile index beead608..ddb05530 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -51,8 +51,6 @@ NASMSRC = memdisk_chs_512.asm memdisk_edd_512.asm \ memdisk_iso_512.asm memdisk_iso_2048.asm \ memdisk16.asm -vpath %.c $(topdir)/com32/lib:$(topdir)/com32/libutil - all: memdisk # e820test # tidy, clean removes everything except the final binary diff --git a/memdisk/ctypes.c b/memdisk/ctypes.c new file mode 100644 index 00000000..f87ca055 --- /dev/null +++ b/memdisk/ctypes.c @@ -0,0 +1 @@ +#include "../com32/lib/ctypes.c" diff --git a/memdisk/strntoumax.c b/memdisk/strntoumax.c new file mode 100644 index 00000000..6fa2f357 --- /dev/null +++ b/memdisk/strntoumax.c @@ -0,0 +1 @@ +#include "../com32/lib/strntoumax.c" diff --git a/memdisk/strtoull.c b/memdisk/strtoull.c new file mode 100644 index 00000000..e2425df3 --- /dev/null +++ b/memdisk/strtoull.c @@ -0,0 +1 @@ +#include "../com32/lib/strtoull.c" diff --git a/memdisk/strtox.c b/memdisk/strtox.c new file mode 100644 index 00000000..445681f4 --- /dev/null +++ b/memdisk/strtox.c @@ -0,0 +1 @@ +#include "../com32/lib/strtox.c" diff --git a/memdisk/suffix_number.c b/memdisk/suffix_number.c new file mode 100644 index 00000000..dd266426 --- /dev/null +++ b/memdisk/suffix_number.c @@ -0,0 +1 @@ +#include "../com32/libutil/suffix_number.c" -- cgit v1.2.1 From e86bdcd32ceb8550d0b1e59b73fb0ee243f3edad Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 19:54:20 -0500 Subject: com32: Move suffix_number() from libutil to libcom32 --- com32/include/suffix_number.h | 41 ++++++++++++++++++++ com32/lib/Makefile | 2 + com32/lib/suffix_number.c | 71 ++++++++++++++++++++++++++++++++++ com32/libutil/Makefile | 3 +- com32/libutil/include/suffix_number.h | 41 -------------------- com32/libutil/suffix_number.c | 72 ----------------------------------- 6 files changed, 115 insertions(+), 115 deletions(-) create mode 100644 com32/include/suffix_number.h create mode 100644 com32/lib/suffix_number.c delete mode 100644 com32/libutil/include/suffix_number.h delete mode 100644 com32/libutil/suffix_number.c diff --git a/com32/include/suffix_number.h b/com32/include/suffix_number.h new file mode 100644 index 00000000..e2349b41 --- /dev/null +++ b/com32/include/suffix_number.h @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------- * + * + * 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. + * + * ----------------------------------------------------------------------- */ + +/* + * suffix_number.h + * + * Definitions used to convert a string of a number with potential SI suffix + * to int-type. + */ + +#ifndef LIBUTIL_SUFFIX_NUMBER_H +#define LIBUTIL_SUFFIX_NUMBER_H + +unsigned long long suffix_number(const char *); + +#endif /* LIBUTIL_SUFFIX_NUMBER_H */ + diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 2035df22..754c8c33 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -32,6 +32,8 @@ LIBOBJS = \ \ dprintf.o vdprintf.o \ \ + suffix_number.o \ + \ sys/readdir.o getcwd.o chdir.o fdopendir.o \ \ libgcc/__ashldi3.o libgcc/__udivdi3.o \ diff --git a/com32/lib/suffix_number.c b/com32/lib/suffix_number.c new file mode 100644 index 00000000..49217f74 --- /dev/null +++ b/com32/lib/suffix_number.c @@ -0,0 +1,71 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2009 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. + * + * ----------------------------------------------------------------------- */ + +/* + * suffix_number.c + * + * Convert a string of a number with potential SI suffix to int-type + */ + +#include + +/* Get a value with a potential suffix (k/m/g/t/p/e) */ +unsigned long long suffix_number(const char *str) +{ + char *ep; + unsigned long long v; + int shift; + + v = strtoull(str, &ep, 0); + switch (*ep | 0x20) { + case 'k': + shift = 10; + break; + case 'm': + shift = 20; + break; + case 'g': + shift = 30; + break; + case 't': + shift = 40; + break; + case 'p': + shift = 50; + break; + case 'e': + shift = 60; + break; + default: + shift = 0; + break; + } + v <<= shift; + + return v; +} diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile index d9466aa5..02789ca6 100644 --- a/com32/libutil/Makefile +++ b/com32/libutil/Makefile @@ -33,8 +33,7 @@ topdir = ../.. include ../MCONFIG LIBOBJS = ansiline.o ansiraw.o get_key.o sha1hash.o unbase64.o \ - md5.o crypt-md5.o sha256crypt.o sha512crypt.o base64.o \ - suffix_number.o + md5.o crypt-md5.o sha256crypt.o sha512crypt.o base64.o LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS)) all: libutil_com.a libutil_lnx.a diff --git a/com32/libutil/include/suffix_number.h b/com32/libutil/include/suffix_number.h deleted file mode 100644 index e2349b41..00000000 --- a/com32/libutil/include/suffix_number.h +++ /dev/null @@ -1,41 +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. - * - * ----------------------------------------------------------------------- */ - -/* - * suffix_number.h - * - * Definitions used to convert a string of a number with potential SI suffix - * to int-type. - */ - -#ifndef LIBUTIL_SUFFIX_NUMBER_H -#define LIBUTIL_SUFFIX_NUMBER_H - -unsigned long long suffix_number(const char *); - -#endif /* LIBUTIL_SUFFIX_NUMBER_H */ - diff --git a/com32/libutil/suffix_number.c b/com32/libutil/suffix_number.c deleted file mode 100644 index df073a00..00000000 --- a/com32/libutil/suffix_number.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2007-2009 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. - * - * ----------------------------------------------------------------------- */ - -/* - * suffix_number.c - * - * Convert a string of a number with potential SI suffix to int-type - */ - -#include -#include - -/* Get a value with a potential suffix (k/m/g/t/p/e) */ -unsigned long long suffix_number(const char *str) -{ - char *ep; - unsigned long long v; - int shift; - - v = strtoull(str, &ep, 0); - switch (*ep | 0x20) { - case 'k': - shift = 10; - break; - case 'm': - shift = 20; - break; - case 'g': - shift = 30; - break; - case 't': - shift = 40; - break; - case 'p': - shift = 50; - break; - case 'e': - shift = 60; - break; - default: - shift = 0; - break; - } - v <<= shift; - - return v; -} -- cgit v1.2.1 From 6d63144949d795320bb7f70a6156b46615864f5f Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 20:07:43 -0500 Subject: memdisk & libcom32: Fix minor errors in previous commit --- com32/lib/syslinux/load_linux.c | 37 +------------------------------------ memdisk/Makefile | 2 +- memdisk/suffix_number.c | 2 +- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c index df793625..3ac6e5d0 100644 --- a/com32/lib/syslinux/load_linux.c +++ b/com32/lib/syslinux/load_linux.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -96,42 +97,6 @@ struct linux_header { #define LOAD_HIGH 0x01 #define CAN_USE_HEAP 0x80 -/* Get a value with a potential suffix (k/m/g/t/p/e) */ -static unsigned long long suffix_number(const char *str) -{ - char *ep; - unsigned long long v; - int shift; - - v = strtoull(str, &ep, 0); - switch (*ep | 0x20) { - case 'k': - shift = 10; - break; - case 'm': - shift = 20; - break; - case 'g': - shift = 30; - break; - case 't': - shift = 40; - break; - case 'p': - shift = 50; - break; - case 'e': - shift = 60; - break; - default: - shift = 0; - break; - } - v <<= shift; - - return v; -} - /* * Find the last instance of a particular command line argument * (which should include the final =; do not use for boolean arguments) diff --git a/memdisk/Makefile b/memdisk/Makefile index ddb05530..ef0aca8a 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -15,7 +15,7 @@ topdir = .. include $(topdir)/MCONFIG.embedded -include $(topdir)/version.mk -INCLUDES = -I$(topdir)/com32/include -I$(topdir)/com32/libutil/include +INCLUDES = -I$(topdir)/com32/include CFLAGS += -D__MEMDISK__ -DDATE='"$(DATE)"' LDFLAGS = $(GCCOPT) -g NASM = nasm diff --git a/memdisk/suffix_number.c b/memdisk/suffix_number.c index dd266426..d01c5a37 100644 --- a/memdisk/suffix_number.c +++ b/memdisk/suffix_number.c @@ -1 +1 @@ -#include "../com32/libutil/suffix_number.c" +#include "../com32/lib/suffix_number.c" -- cgit v1.2.1 From e8404ed6a9d57fdc7d95eba029b1d18cb0f0f2e6 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 20:31:28 -0500 Subject: memdisk: Fix CSRC in Makefile --- memdisk/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/memdisk/Makefile b/memdisk/Makefile index ef0aca8a..92f565a4 100644 --- a/memdisk/Makefile +++ b/memdisk/Makefile @@ -44,8 +44,7 @@ OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \ memdisk_iso_512.o memdisk_iso_2048.o CSRC = setup.c msetup.c e820func.c conio.c unzip.c dskprobe.c eltorito.c \ - $(topdir)/com32/lib/ctypes.c $(topdir)/com32/lib/strntoumax.c \ - $(topdir)/com32/lib/strtoull.c $(topdir)/com32/libutil/suffix_number.c + ctypes.c strntoumax.c strtoull.c suffix_number.c SSRC = start32.S memcpy.S memset.S memmove.S NASMSRC = memdisk_chs_512.asm memdisk_edd_512.asm \ memdisk_iso_512.asm memdisk_iso_2048.asm \ -- cgit v1.2.1 From 282527de6f2e3cce635b69c9ad13ffdbe98700a3 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 20:59:35 -0500 Subject: libcom32: Add header to suffix_number.c In case we ever define anything in the header --- com32/lib/suffix_number.c | 1 + 1 file changed, 1 insertion(+) diff --git a/com32/lib/suffix_number.c b/com32/lib/suffix_number.c index 49217f74..df073a00 100644 --- a/com32/lib/suffix_number.c +++ b/com32/lib/suffix_number.c @@ -33,6 +33,7 @@ */ #include +#include /* Get a value with a potential suffix (k/m/g/t/p/e) */ unsigned long long suffix_number(const char *str) -- cgit v1.2.1 From a028af928b5d22c2aec9cf09916e8334ca4f694f Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 21:38:40 -0500 Subject: memdisk/setup: Rename int15maxres to setmaxmem The old name was intended as a test to prevent collision. New name seems more logical and appropriate. By reusing the mem= parameter and adjusting all of the memory calls that MEMDISK replaces through the use of insertrange(), there's nothing better that we can do. --- memdisk/setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index 8317971e..61cf420c 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -708,11 +708,11 @@ static int stack_needed(void) } /* - * Specify max RAM by reservation - * Adds a reservation to data in INT15h to prevent access to the top of RAM + * Set max memory by reservation + * Adds reservations to data in INT15h to prevent access to the top of RAM * if there's any above the point specified. */ -void int15maxres(unsigned long long restop_ull) +void setmaxmem(unsigned long long restop_ull) { uint32_t restop; struct e820range *ep; @@ -720,7 +720,7 @@ void int15maxres(unsigned long long restop_ull) /* insertrange() works on uint32_t */ restop = min(restop_ull, UINT32_MAX); - /* printf(" int15maxres '%08x%08x' => %08x\n", + /* printf(" setmaxmem '%08x%08x' => %08x\n", (unsigned int)(restop_ull>>32), (unsigned int)restop_ull, restop); */ for (ep = ranges; ep->type != -1U; ep++) { @@ -976,7 +976,7 @@ void setup(const struct real_mode_args *rm_args_ptr) } if ((p = getcmditem("mem")) != CMD_NOTFOUND) { - int15maxres(suffix_number(p)); + setmaxmem(suffix_number(p)); } /* The size is given by hptr->total_size plus the size of the E820 -- cgit v1.2.1