int type)
{
char c, sign, tmp[66];
- const char *digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+ const char *digits = "0123456789abcdef";
int i;
if (type & LARGE)
- digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ digits = "0123456789ABCDEF";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return str;
}
-/* Forward decl. needed for IP address printing stuff... */
-int sprintf(char *buf, const char *fmt, ...);
-
int vsprintf(char *buf, const char *fmt, va_list args)
{
int len;
return str - buf;
}
+#if 0
int sprintf(char *buf, const char *fmt, ...)
{
va_list args;
va_end(args);
return i;
}
+#endif
+
+int vprintf(const char *fmt, va_list args)
+{
+ char printf_buf[2048];
+ int printed;
+
+ printed = vsprintf(printf_buf, fmt, args);
+ puts(printf_buf);
+ return printed;
+}
int printf(const char *fmt, ...)
{
- char printf_buf[1024];
va_list args;
int printed;
va_start(args, fmt);
- printed = vsprintf(printf_buf, fmt, args);
+ printed = vprintf(fmt, args);
va_end(args);
+ return printed;
+}
- puts(printf_buf);
+/*
+ * Jump here if all hope is gone...
+ */
+void __attribute__ ((noreturn)) die(const char *fmt, ...)
+{
+ va_list ap;
- return printed;
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+
+ sti();
+ for (;;)
+ asm volatile("hlt");
}
#define CMD_BOOL ((char *)-2) /* Found boolean option */
#define CMD_HASDATA(X) ((int)(X) >= 0)
-const char *getcmditem(const char *what)
+static const char *getcmditem(const char *what)
{
const char *p;
const char *wp = what;
&orig_crc, &offset) == 0) {
if (offset + zbytes > size) {
- /* Assertion failure; check_zip is supposed to guarantee this
- never happens. */
- puts("internal error: check_zip returned nonsense\n");
- die();
+ /*
+ * Assertion failure; check_zip is supposed to guarantee this
+ * never happens.
+ */
+ die("internal error: check_zip returned nonsense\n");
}
- /* Find a good place to put it: search memory ranges in descending order
- until we find one that is legal and fits */
+ /*
+ * Find a good place to put it: search memory ranges in descending
+ * order until we find one that is legal and fits
+ */
okmem = 0;
for (i = nranges - 1; i >= 0; i--) {
- /* We can't use > 4G memory (32 bits only.) Truncate to 2^32-1
- so we don't have to deal with funny wraparound issues. */
+ /*
+ * We can't use > 4G memory (32 bits only.) Truncate to 2^32-1
+ * so we don't have to deal with funny wraparound issues.
+ */
/* Must be memory */
if (ranges[i].type != 1)
if (startrange >= endrange)
continue;
- /* Must be large enough... don't rely on gzwhere for this (wraparound) */
+ /*
+ * Must be large enough... don't rely on gzwhere for this
+ * (wraparound)
+ */
if (endrange - startrange < gzdatasize)
continue;
- /* This is where the gz image should be put if we put it in this range */
+ /*
+ * This is where the gz image would be put if we put it in this
+ * range...
+ */
gzwhere = (endrange - gzdatasize) & ~(UNZIP_ALIGN - 1);
/* Cast to uint64_t just in case we're flush with the top byte */
if ((uint64_t) where + size >= gzwhere && where < endrange) {
- /* Need to move source data to avoid compressed/uncompressed overlap */
+ /*
+ * Need to move source data to avoid compressed/uncompressed
+ * overlap
+ */
uint32_t newwhere;
if (gzwhere - startrange < size)
break;
}
- if (!okmem) {
- printf
- ("Not enough memory to decompress image (need 0x%08x bytes)\n",
+ if (!okmem)
+ die("Not enough memory to decompress image (need 0x%08x bytes)\n",
gzdatasize);
- die();
- }
printf("gzip image: decompressed addr 0x%08x, len 0x%08x: ",
target, gzdatasize);
#define FOUR(a,b,c,d) (((a) << 24)|((b) << 16)|((c) << 8)|(d))
-const struct geometry *get_disk_image_geometry(uint32_t where, uint32_t size)
+static const struct geometry *get_disk_image_geometry(uint32_t where, uint32_t size)
{
static struct geometry hd_geometry;
struct dosemu_header dosemu;
}
/*
- * Jump here if all hope is gone...
- */
-void __attribute__ ((noreturn)) die(void)
-{
- sti();
- for (;;)
- asm volatile("hlt");
-}
-
-/*
* Find a $PnP installation check structure; return (ES << 16) + DI value
*/
static uint32_t pnp_install_check(void)
/* Show signs of life */
printf("%s %s\n", memdisk_version, copyright);
- if (!shdr->ramdisk_image || !shdr->ramdisk_size) {
- puts("MEMDISK: No ramdisk image specified!\n");
- die();
- }
+ if (!shdr->ramdisk_image || !shdr->ramdisk_size)
+ die("MEMDISK: No ramdisk image specified!\n");
ramdisk_image = shdr->ramdisk_image;
ramdisk_size = shdr->ramdisk_size;
printf("Total size needed = %u bytes, allocating %uK\n",
total_size, (total_size + 0x3ff) >> 10);
- if (total_size > dos_mem) {
- puts("MEMDISK: Insufficient low memory\n");
- die();
- }
+ if (total_size > dos_mem)
+ die("MEMDISK: Insufficient low memory\n");
driveraddr = stddosmem - total_size;
driveraddr &= ~0x3FF;
/* Relocate the real-mode code to below the stub */
rm_base = (driveraddr - rm_args.rm_size) & ~15;
- if (rm_base < boot_base + boot_len) {
- puts("MEMDISK: bootstrap too large to load\n");
- die();
- }
+ if (rm_base < boot_base + boot_len)
+ die("MEMDISK: bootstrap too large to load\n");
+
relocate_rm_code(rm_base);
/* Reboot into the new "disk" */