summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsgalabov <sgalabov@FreeBSD.org>2016-02-29 07:27:49 +0000
committersgalabov <sgalabov@FreeBSD.org>2016-02-29 07:27:49 +0000
commitac10683bf2d5a35b0658d48d697ccb24e84ad119 (patch)
tree6d56406f4f66342b70a3b5bc3b747d44a15ed30c
parent8b886cf3a72e7ac9a7a9b625f43e0deb76ed2952 (diff)
downloadFreeBSD-src-ac10683bf2d5a35b0658d48d697ccb24e84ad119.zip
FreeBSD-src-ac10683bf2d5a35b0658d48d697ccb24e84ad119.tar.gz
These changes attempt to put things in order before the introduction of MIPS
ubldr. The changes are mostly dealing with removing unnecessary casts from the U-Boot API (we're passing only pointers, no obvious reason to cast them to uint32_t), cleaning up some compiler warnings and using the proper printf format specifiers in order to be able to compile cleanly for both 32-bit and 64-bit MIPS targets. Reviewed by: imp Approved by: adrian (mentor) Sponsored by: Smartcom - Bulgaria AD Differential Revision: https://reviews.freebsd.org/D5312
-rw-r--r--sys/boot/common/Makefile.inc2
-rw-r--r--sys/boot/common/dev_net.c3
-rw-r--r--sys/boot/fdt/fdt_loader_cmd.c6
-rw-r--r--sys/boot/uboot/common/main.c8
-rw-r--r--sys/boot/uboot/lib/disk.c3
-rw-r--r--sys/boot/uboot/lib/elf_freebsd.c6
-rw-r--r--sys/boot/uboot/lib/glue.c25
-rw-r--r--sys/boot/uboot/lib/glue.h20
8 files changed, 51 insertions, 22 deletions
diff --git a/sys/boot/common/Makefile.inc b/sys/boot/common/Makefile.inc
index d647fe3..bce0eb5 100644
--- a/sys/boot/common/Makefile.inc
+++ b/sys/boot/common/Makefile.inc
@@ -20,6 +20,8 @@ SRCS+= load_elf64.c reloc_elf64.c
SRCS+= load_elf64.c reloc_elf64.c
.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el"
SRCS+= load_elf64.c reloc_elf64.c
+.elif ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mipsel"
+SRCS+= load_elf32.c reloc_elf32.c
.endif
.if defined(LOADER_NET_SUPPORT)
diff --git a/sys/boot/common/dev_net.c b/sys/boot/common/dev_net.c
index 091ed02..58958e5 100644
--- a/sys/boot/common/dev_net.c
+++ b/sys/boot/common/dev_net.c
@@ -164,8 +164,7 @@ net_open(struct open_file *f, ...)
* info from bootp or other sources.
*/
d = socktodesc(netdev_sock);
- sprintf(temp, "%6D", d->myea, ":");
- setenv("boot.netif.hwaddr", temp, 1);
+ setenv("boot.netif.hwaddr", ether_sprintf(d->myea), 1);
setenv("boot.netif.ip", inet_ntoa(myip), 1);
setenv("boot.netif.netmask", intoa(netmask), 1);
setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
diff --git a/sys/boot/fdt/fdt_loader_cmd.c b/sys/boot/fdt/fdt_loader_cmd.c
index a1eaf9d..8cd8ab5 100644
--- a/sys/boot/fdt/fdt_loader_cmd.c
+++ b/sys/boot/fdt/fdt_loader_cmd.c
@@ -296,8 +296,8 @@ fdt_setup_fdtp()
/* If we were given the address of a valid blob in memory, use it. */
if (fdt_to_load != NULL) {
if (fdt_load_dtb_addr(fdt_to_load) == 0) {
- printf("Using DTB from memory address 0x%08X.\n",
- (unsigned int)fdt_to_load);
+ printf("Using DTB from memory address 0x%p.\n",
+ fdt_to_load);
return (0);
}
}
@@ -427,6 +427,7 @@ fdt_fixup_cpubusfreqs(unsigned long cpufreq, unsigned long busfreq)
}
}
+#ifdef notyet
static int
fdt_reg_valid(uint32_t *reg, int len, int addr_cells, int size_cells)
{
@@ -458,6 +459,7 @@ fdt_reg_valid(uint32_t *reg, int len, int addr_cells, int size_cells)
}
return (0);
}
+#endif
void
fdt_fixup_memory(struct fdt_mem_region *region, size_t num)
diff --git a/sys/boot/uboot/common/main.c b/sys/boot/uboot/common/main.c
index 6c7b893..f4fe214 100644
--- a/sys/boot/uboot/common/main.c
+++ b/sys/boot/uboot/common/main.c
@@ -132,8 +132,8 @@ meminfo(void)
for (i = 0; i < 3; i++) {
size = memsize(si, t[i]);
if (size > 0)
- printf("%s: %lldMB\n", ub_mem_type(t[i]),
- size / 1024 / 1024);
+ printf("%s: %juMB\n", ub_mem_type(t[i]),
+ (uintmax_t)(size / 1024 / 1024));
}
}
@@ -426,7 +426,7 @@ main(void)
* Set up console.
*/
cons_probe();
- printf("Compatible U-Boot API signature found @%x\n", (uint32_t)sig);
+ printf("Compatible U-Boot API signature found @%p\n", sig);
printf("\n");
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
@@ -511,7 +511,7 @@ static int
command_heap(int argc, char *argv[])
{
- printf("heap base at %p, top at %p, used %d\n", end, sbrk(0),
+ printf("heap base at %p, top at %p, used %td\n", end, sbrk(0),
sbrk(0) - end);
return (CMD_OK);
diff --git a/sys/boot/uboot/lib/disk.c b/sys/boot/uboot/lib/disk.c
index 4681e1b..a8b7853 100644
--- a/sys/boot/uboot/lib/disk.c
+++ b/sys/boot/uboot/lib/disk.c
@@ -156,7 +156,8 @@ stor_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf,
}
if (size % SI(dev).bsize) {
- stor_printf("size=%d not multiple of device block size=%d\n",
+ stor_printf("size=%zu not multiple of device "
+ "block size=%d\n",
size, SI(dev).bsize);
return (EIO);
}
diff --git a/sys/boot/uboot/lib/elf_freebsd.c b/sys/boot/uboot/lib/elf_freebsd.c
index b72d07c..b4fd1b3 100644
--- a/sys/boot/uboot/lib/elf_freebsd.c
+++ b/sys/boot/uboot/lib/elf_freebsd.c
@@ -31,6 +31,10 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/linker.h>
+#ifdef __mips__
+#include <sys/proc.h>
+#include <machine/frame.h>
+#endif
#include <machine/md_var.h>
#include <machine/metadata.h>
#include <machine/elf.h>
@@ -81,7 +85,7 @@ __elfN(uboot_exec)(struct preloaded_file *fp)
return (error);
entry = (void *)e->e_entry;
- printf("Kernel entry at 0x%x...\n", (unsigned)entry);
+ printf("Kernel entry at 0x%p...\n", entry);
dev_cleanup();
printf("Kernel args: %s\n", fp->f_args);
diff --git a/sys/boot/uboot/lib/glue.c b/sys/boot/uboot/lib/glue.c
index 32c4df2..4c843f0 100644
--- a/sys/boot/uboot/lib/glue.c
+++ b/sys/boot/uboot/lib/glue.c
@@ -83,8 +83,9 @@ api_search_sig(struct api_signature **sig)
if (uboot_address == 0)
uboot_address = 255 * 1024 * 1024;
- sp = (void *)(uboot_address & ~0x000fffff);
- spend = sp + 0x00300000 - API_SIG_MAGLEN;
+ sp = (void *)(uboot_address & API_SIG_SEARCH_MASK);
+ spend = sp + API_SIG_SEARCH_LEN - API_SIG_MAGLEN;
+
while (sp < spend) {
if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) {
*sig = (struct api_signature *)sp;
@@ -109,7 +110,7 @@ ub_getc(void)
{
int c;
- if (!syscall(API_GETC, NULL, (uint32_t)&c))
+ if (!syscall(API_GETC, NULL, &c))
return (-1);
return (c);
@@ -120,24 +121,24 @@ ub_tstc(void)
{
int t;
- if (!syscall(API_TSTC, NULL, (uint32_t)&t))
+ if (!syscall(API_TSTC, NULL, &t))
return (-1);
return (t);
}
void
-ub_putc(char c)
+ub_putc(const char c)
{
- syscall(API_PUTC, NULL, (uint32_t)&c);
+ syscall(API_PUTC, NULL, &c);
}
void
ub_puts(const char *s)
{
- syscall(API_PUTS, NULL, (uint32_t)s);
+ syscall(API_PUTS, NULL, s);
}
/****************************************
@@ -166,7 +167,7 @@ ub_get_sys_info(void)
si.mr_no = UB_MAX_MR;
memset(&mr, 0, sizeof(mr));
- if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si))
+ if (!syscall(API_GET_SYS_INFO, &err, &si))
return (NULL);
return ((err) ? NULL : &si);
@@ -433,7 +434,7 @@ ub_dump_di(int handle)
int i;
printf("device info (%d):\n", handle);
- printf(" cookie\t= 0x%08x\n", (uint32_t)di->cookie);
+ printf(" cookie\t= 0x%p\n", di->cookie);
printf(" type\t\t= 0x%08x\n", di->type);
if (di->type == DEV_TYP_NET) {
@@ -483,7 +484,7 @@ ub_env_get(const char *name)
{
char *value;
- if (!syscall(API_ENV_GET, NULL, (uint32_t)name, (uint32_t)&value))
+ if (!syscall(API_ENV_GET, NULL, name, &value))
return (NULL);
return (value);
@@ -493,7 +494,7 @@ void
ub_env_set(const char *name, char *value)
{
- syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value);
+ syscall(API_ENV_SET, NULL, name, value);
}
static char env_name[256];
@@ -510,7 +511,7 @@ ub_env_enum(const char *last)
* internally, which handles such case
*/
env = NULL;
- if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
+ if (!syscall(API_ENV_ENUM, NULL, last, &env))
return (NULL);
if (env == NULL || last == env)
diff --git a/sys/boot/uboot/lib/glue.h b/sys/boot/uboot/lib/glue.h
index 2e818ba..b9c60b6 100644
--- a/sys/boot/uboot/lib/glue.h
+++ b/sys/boot/uboot/lib/glue.h
@@ -35,6 +35,26 @@
#include "api_public.h"
+/*
+ * Mask used to align the start address for API signature search to 1MiB
+ */
+#define API_SIG_SEARCH_MASK ~0x000fffff
+
+#ifdef __mips__
+/*
+ * On MIPS, U-Boot passes us a hint address, which is very close to the end of
+ * RAM (less than 1MiB), so searching for the API signature within more than
+ * that leads to exception.
+ */
+#define API_SIG_SEARCH_LEN 0x00100000
+#else
+/*
+ * Search for the API signature within 3MiB of the 1MiB-aligned address that
+ * U-Boot has hinted us.
+ */
+#define API_SIG_SEARCH_LEN 0x00300000
+#endif
+
int syscall(int, int *, ...);
void *syscall_ptr;
OpenPOWER on IntegriCloud