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
This commit is contained in:
parent
77394b18ab
commit
b981b8bd86
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296182
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user