aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stand/i386/common/cons.c3
-rw-r--r--stand/i386/common/drv.c6
-rw-r--r--stand/i386/gptboot/gptboot.c30
-rw-r--r--stand/i386/zfsboot/zfsboot.c41
-rw-r--r--stand/libsa/gpt.c2
-rw-r--r--stand/libsa/stand.h8
-rw-r--r--stand/libsa/util.c182
-rw-r--r--stand/libsa/util.h53
-rw-r--r--stand/mips/beri/common/altera_jtag_uart.c2
-rw-r--r--stand/mips/beri/common/cfi.c2
10 files changed, 14 insertions, 315 deletions
diff --git a/stand/i386/common/cons.c b/stand/i386/common/cons.c
index 5fb1a936bde7..96e782fda5c9 100644
--- a/stand/i386/common/cons.c
+++ b/stand/i386/common/cons.c
@@ -22,9 +22,10 @@ __FBSDID("$FreeBSD$");
#include <btxv86.h>
+#include "stand.h"
+
#include "lib.h"
#include "rbx.h"
-#include "util.h"
#include "cons.h"
#define SECOND 18 /* Circa that many ticks in a second. */
diff --git a/stand/i386/common/drv.c b/stand/i386/common/drv.c
index a805c41f9c44..e2e4d55e533c 100644
--- a/stand/i386/common/drv.c
+++ b/stand/i386/common/drv.c
@@ -21,8 +21,8 @@ __FBSDID("$FreeBSD$");
#include <btxv86.h>
+#include "stand.h"
#include "rbx.h"
-#include "util.h"
#include "drv.h"
#include "edd.h"
@@ -69,7 +69,7 @@ drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
v86.esi = VTOPOFF(&packet);
v86int();
if (V86_CY(v86.efl)) {
- printf("%s: error %u lba %u\n",
+ printf("%s: error %u lba %llu\n",
BOOTPROG, v86.eax >> 8 & 0xff, lba);
return (-1);
}
@@ -94,7 +94,7 @@ drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
v86.esi = VTOPOFF(&packet);
v86int();
if (V86_CY(v86.efl)) {
- printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba);
+ printf("error %u lba %llu\n", v86.eax >> 8 & 0xff, lba);
return (-1);
}
return (0);
diff --git a/stand/i386/gptboot/gptboot.c b/stand/i386/gptboot/gptboot.c
index 80e02ec865ad..49c2d5f82c54 100644
--- a/stand/i386/gptboot/gptboot.c
+++ b/stand/i386/gptboot/gptboot.c
@@ -32,15 +32,12 @@ __FBSDID("$FreeBSD$");
#include <btxv86.h>
-/* Forward declared to avoid warnings -- these shouldn't be needed */
-int strcasecmp(const char *s1, const char *s2);
-void explicit_bzero(void *b, size_t len);
+#include "stand.h"
#include "bootargs.h"
#include "lib.h"
#include "rbx.h"
#include "drv.h"
-#include "util.h"
#include "cons.h"
#include "gpt.h"
#include "paths.h"
@@ -109,35 +106,11 @@ void exit(int);
static void load(void);
static int parse_cmds(char *, int *);
static int dskread(void *, daddr_t, unsigned);
-void *malloc(size_t n);
-void free(void *ptr);
#ifdef LOADER_GELI_SUPPORT
static int vdev_read(void *vdev __unused, void *priv, off_t off, void *buf,
size_t bytes);
#endif
-void *
-malloc(size_t n)
-{
- char *p = heap_next;
- if (p + n > heap_end) {
- printf("malloc failure\n");
- for (;;)
- ;
- /* NOTREACHED */
- return (0);
- }
- heap_next += n;
- return (p);
-}
-
-void
-free(void *ptr)
-{
-
- return;
-}
-
#include "ufsread.c"
#include "gpt.c"
#ifdef LOADER_GELI_SUPPORT
@@ -291,6 +264,7 @@ main(void)
heap_next = (char *)dmadat + sizeof(*dmadat);
heap_end = (char *)PTOV(bios_basemem);
}
+ setheap(heap_next, heap_end);
v86.ctl = V86_FLAGS;
v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c
index a568f6886b78..fe75cd9764bc 100644
--- a/stand/i386/zfsboot/zfsboot.c
+++ b/stand/i386/zfsboot/zfsboot.c
@@ -16,6 +16,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "stand.h"
+
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/diskmbr.h>
@@ -36,15 +38,10 @@ __FBSDID("$FreeBSD$");
#include <btxv86.h>
-/* Forward declared to avoid warnings -- these shouldn't be needed */
-int strcasecmp(const char *s1, const char *s2);
-void explicit_bzero(void *b, size_t len);
-
#include "lib.h"
#include "rbx.h"
#include "drv.h"
#include "edd.h"
-#include "util.h"
#include "cons.h"
#include "bootargs.h"
#include "paths.h"
@@ -127,40 +124,8 @@ void reboot(void);
static void load(void);
static int parse_cmd(void);
static void bios_getmem(void);
-void *malloc(size_t n);
-void free(void *ptr);
int main(void);
-void *
-malloc(size_t n)
-{
- char *p = heap_next;
- if (p + n > heap_end) {
- printf("malloc failure\n");
- for (;;)
- ;
- /* NOTREACHED */
- return (0);
- }
- heap_next += n;
- return (p);
-}
-
-void
-free(void *ptr)
-{
-
- return;
-}
-
-static char *
-strdup(const char *s)
-{
- char *p = malloc(strlen(s) + 1);
- strcpy(p, s);
- return (p);
-}
-
#ifdef LOADER_GELI_SUPPORT
#include "geliboot.c"
static char gelipw[GELI_PW_MAXLEN];
@@ -503,7 +468,6 @@ drvsize_ext(struct dsk *dskp)
if (V86_CY(v86.efl) || /* carry set */
(v86.edx & 0xff) <= (unsigned)(dskp->drive & 0x7f)) /* unit # bad */
return (0);
-
cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1;
/* Convert max head # -> # of heads */
hds = ((v86.edx & 0xff00) >> 8) + 1;
@@ -721,6 +685,7 @@ main(void)
heap_next = (char *)dmadat + sizeof(*dmadat);
heap_end = (char *)PTOV(bios_basemem);
}
+ setheap(heap_next, heap_end);
dsk = malloc(sizeof(struct dsk));
dsk->drive = *(uint8_t *)PTOV(ARGS);
diff --git a/stand/libsa/gpt.c b/stand/libsa/gpt.c
index 7ab3fc6d04e0..900f2d5c79f2 100644
--- a/stand/libsa/gpt.c
+++ b/stand/libsa/gpt.c
@@ -34,9 +34,9 @@ __FBSDID("$FreeBSD$");
#error gpt.c works only for little endian architectures
#endif
+#include "stand.h"
#include "crc32.h"
#include "drv.h"
-#include "util.h"
#include "gpt.h"
static struct gpt_hdr hdr_primary, hdr_backup, *gpthdr;
diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h
index 4ccd943f6e73..aa5f056706c6 100644
--- a/stand/libsa/stand.h
+++ b/stand/libsa/stand.h
@@ -265,12 +265,6 @@ static __inline int tolower(int c)
extern void setheap(void *base, void *top);
extern char *sbrk(int incr);
-/* Matt Dillon's zalloc/zmalloc */
-extern void *malloc(size_t bytes);
-extern void free(void *ptr);
-/*#define free(p) {CHK("free %p", p); free(p);} */ /* use for catching guard violations */
-extern void *calloc(size_t n1, size_t n2);
-extern void *realloc(void *ptr, size_t size);
extern void *reallocf(void *ptr, size_t size);
extern void mallocstats(void);
@@ -427,7 +421,7 @@ void *Calloc(size_t, size_t, const char *, int);
void *Realloc(void *, size_t, const char *, int);
void Free(void *, const char *, int);
-#if 1
+#ifdef DEBUG_MALLOC
#define malloc(x) Malloc(x, __FILE__, __LINE__)
#define calloc(x, y) Calloc(x, y, __FILE__, __LINE__)
#define free(x) Free(x, __FILE__, __LINE__)
diff --git a/stand/libsa/util.c b/stand/libsa/util.c
deleted file mode 100644
index 49f42ebe2da9..000000000000
--- a/stand/libsa/util.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*-
- * Copyright (c) 1998 Robert Nordier
- * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are freely
- * permitted provided that the above copyright notice and this
- * paragraph and the following disclaimer are duplicated in all
- * such forms.
- *
- * This software is provided "AS IS" and without any express or
- * implied warranties, including, without limitation, the implied
- * warranties of merchantability and fitness for a particular
- * purpose.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-
-#include <stdarg.h>
-
-#include "cons.h"
-#include "util.h"
-
-void
-memcpy(void *dst, const void *src, int len)
-{
- const char *s = src;
- char *d = dst;
-
- while (len--)
- *d++ = *s++;
-}
-
-void
-memset(void *b, int c, size_t len)
-{
- char *bp = b;
-
- while (len--)
- *bp++ = (unsigned char)c;
-}
-
-int
-memcmp(const void *b1, const void *b2, size_t len)
-{
- const unsigned char *p1, *p2;
-
- for (p1 = b1, p2 = b2; len > 0; len--, p1++, p2++) {
- if (*p1 != *p2)
- return ((*p1) - (*p2));
- }
- return (0);
-}
-
-int
-strcmp(const char *s1, const char *s2)
-{
-
- for (; *s1 == *s2 && *s1 != '\0'; s1++, s2++)
- ;
- return ((unsigned char)*s1 - (unsigned char)*s2);
-}
-
-int
-strncmp(const char *s1, const char *s2, size_t len)
-{
-
- for (; len > 0 && *s1 == *s2 && *s1 != '\0'; len--, s1++, s2++)
- ;
- return (len == 0 ? 0 : (unsigned char)*s1 - (unsigned char)*s2);
-}
-
-void
-strcpy(char *dst, const char *src)
-{
-
- while (*src != '\0')
- *dst++ = *src++;
- *dst = '\0';
-}
-
-void
-strcat(char *dst, const char *src)
-{
-
- while (*dst != '\0')
- dst++;
- while (*src != '\0')
- *dst++ = *src++;
- *dst = '\0';
-}
-
-char *
-strchr(const char *s, char ch)
-{
-
- for (; *s != '\0'; s++) {
- if (*s == ch)
- return ((char *)(uintptr_t)(const void *)s);
- }
- return (NULL);
-}
-
-size_t
-strlen(const char *s)
-{
- size_t len = 0;
-
- while (*s++ != '\0')
- len++;
- return (len);
-}
-
-int
-printf(const char *fmt, ...)
-{
- va_list ap;
- const char *hex = "0123456789abcdef";
- char buf[32], *s;
- uint16_t *S;
- unsigned long long u;
- int c, l;
-
- va_start(ap, fmt);
- while ((c = *fmt++) != '\0') {
- if (c != '%') {
- putchar(c);
- continue;
- }
- l = 0;
-nextfmt:
- c = *fmt++;
- switch (c) {
- case 'l':
- l++;
- goto nextfmt;
- case 'c':
- putchar(va_arg(ap, int));
- break;
- case 's':
- for (s = va_arg(ap, char *); *s != '\0'; s++)
- putchar(*s);
- break;
- case 'S': /* Assume console can cope with wide chars */
- for (S = va_arg(ap, uint16_t *); *S != 0; S++)
- putchar(*S);
- break;
- case 'd': /* A lie, always prints unsigned */
- case 'u':
- case 'x':
- switch (l) {
- case 2:
- u = va_arg(ap, unsigned long long);
- break;
- case 1:
- u = va_arg(ap, unsigned long);
- break;
- default:
- u = va_arg(ap, unsigned int);
- break;
- }
- s = buf;
- if (c == 'd' || c == 'u') {
- do
- *s++ = '0' + (u % 10U);
- while (u /= 10);
- } else {
- do
- *s++ = hex[u & 0xfu];
- while (u >>= 4);
- }
- while (--s >= buf)
- putchar(*s);
- break;
- }
- }
- va_end(ap);
- return (0);
-}
diff --git a/stand/libsa/util.h b/stand/libsa/util.h
deleted file mode 100644
index 88a99f19f0b3..000000000000
--- a/stand/libsa/util.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _UTIL_H_
-#define _UTIL_H_
-
-#include <sys/types.h>
-
-#include <stdarg.h>
-
-void memcpy(void *dst, const void *src, int len);
-void memset(void *b, int c, size_t len);
-int memcmp(const void *b1, const void *b2, size_t len);
-
-#define bcopy(src, dst, len) memcpy((dst), (src), (len))
-#define bzero(buf, size) memset((buf), 0, (size))
-#define bcmp(b1, b2, len) (memcmp((b1), (b2), (len)) != 0)
-
-int strcmp(const char *s1, const char *s2);
-int strncmp(const char *s1, const char *s2, size_t len);
-void strcpy(char *dst, const char *src);
-void strcat(char *dst, const char *src);
-char *strchr(const char *s, char ch);
-size_t strlen(const char *s);
-
-int printf(const char *fmt, ...);
-
-#endif /* !_UTIL_H_ */
diff --git a/stand/mips/beri/common/altera_jtag_uart.c b/stand/mips/beri/common/altera_jtag_uart.c
index e8230fe556c5..4bed67d5ed95 100644
--- a/stand/mips/beri/common/altera_jtag_uart.c
+++ b/stand/mips/beri/common/altera_jtag_uart.c
@@ -30,7 +30,7 @@
* $FreeBSD$
*/
-#include "util.h"
+#include "stand.h"
#include "mips.h"
/*-
diff --git a/stand/mips/beri/common/cfi.c b/stand/mips/beri/common/cfi.c
index a6798f4a7451..cd788de56e7f 100644
--- a/stand/mips/beri/common/cfi.c
+++ b/stand/mips/beri/common/cfi.c
@@ -30,7 +30,7 @@
* $FreeBSD$
*/
-#include "util.h"
+#include "stand.h"
#include "mips.h"
#include "cfi.h"