aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/uboot/lib
diff options
context:
space:
mode:
authorRafal Jaworowski <raj@FreeBSD.org>2008-09-03 17:48:41 +0000
committerRafal Jaworowski <raj@FreeBSD.org>2008-09-03 17:48:41 +0000
commitcf725aeb0b72ed6c389dd23346fd8c7ee2b88b5d (patch)
tree9f80471a654432e5c01c980e48859aa9f7411fe9 /sys/boot/uboot/lib
parent387a29b78d340eb1861c1ed93f40d4ed7aa4896e (diff)
downloadsrc-cf725aeb0b72ed6c389dd23346fd8c7ee2b88b5d.tar.gz
src-cf725aeb0b72ed6c389dd23346fd8c7ee2b88b5d.zip
Improve loader support for U-Boot.
- add new diag commands: devinfo, sysinfo for U-Boot-style details about the system configuration - better memory info summary - style corrections Obtained from: Semihalf
Notes
Notes: svn path=/head/; revision=182732
Diffstat (limited to 'sys/boot/uboot/lib')
-rw-r--r--sys/boot/uboot/lib/glue.c92
-rw-r--r--sys/boot/uboot/lib/glue.h42
2 files changed, 109 insertions, 25 deletions
diff --git a/sys/boot/uboot/lib/glue.c b/sys/boot/uboot/lib/glue.c
index fe982d65e8fd..0aca89c7d555 100644
--- a/sys/boot/uboot/lib/glue.c
+++ b/sys/boot/uboot/lib/glue.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
+ * Copyright (c) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
#endif
/* Some random address used by U-Boot. */
-extern long uboot_address;
+extern long uboot_address;
/* crc32 stuff stolen from lib/libdisk/write_ia64_disk.c */
static uint32_t crc32_tab[] = {
@@ -138,7 +138,6 @@ valid_sig(struct api_signature *sig)
int
api_search_sig(struct api_signature **sig)
{
-
unsigned char *sp, *spend;
if (sig == NULL)
@@ -176,7 +175,7 @@ ub_getc(void)
if (!syscall(API_GETC, NULL, (uint32_t)&c))
return (-1);
- return c;
+ return (c);
}
int
@@ -187,7 +186,7 @@ ub_tstc(void)
if (!syscall(API_TSTC, NULL, (uint32_t)&t))
return (-1);
- return t;
+ return (t);
}
void
@@ -313,7 +312,7 @@ ub_dev_enum(void)
di->cookie = devices[n - 1].cookie;
if (!syscall(API_DEV_ENUM, NULL, di))
- return 0;
+ return (0);
}
return (n);
@@ -461,6 +460,87 @@ ub_dev_send(int handle, void *buf, int len)
return (err);
}
+static char *
+ub_stor_type(int type)
+{
+
+ if (type & DT_STOR_IDE)
+ return ("IDE");
+
+ if (type & DT_STOR_SCSI)
+ return ("SCSI");
+
+ if (type & DT_STOR_USB)
+ return ("USB");
+
+ if (type & DT_STOR_MMC);
+ return ("MMC");
+
+ return ("Unknown");
+}
+
+char *
+ub_mem_type(int flags)
+{
+
+ switch(flags & 0x000F) {
+ case MR_ATTR_FLASH:
+ return ("FLASH");
+ case MR_ATTR_DRAM:
+ return ("DRAM");
+ case MR_ATTR_SRAM:
+ return ("SRAM");
+ default:
+ return ("Unknown");
+ }
+}
+
+void
+ub_dump_di(int handle)
+{
+ struct device_info *di = ub_dev_get(handle);
+ int i;
+
+ printf("device info (%d):\n", handle);
+ printf(" cookie\t= 0x%08x\n", (uint32_t)di->cookie);
+ printf(" type\t\t= 0x%08x\n", di->type);
+
+ if (di->type == DEV_TYP_NET) {
+ printf(" hwaddr\t= ");
+ for (i = 0; i < 6; i++)
+ printf("%02x ", di->di_net.hwaddr[i]);
+
+ printf("\n");
+
+ } else if (di->type & DEV_TYP_STOR) {
+ printf(" type\t\t= %s\n", ub_stor_type(di->type));
+ printf(" blk size\t\t= %ld\n", di->di_stor.block_size);
+ printf(" blk count\t\t= %ld\n", di->di_stor.block_count);
+ }
+}
+
+void
+ub_dump_si(struct sys_info *si)
+{
+ int i;
+
+ printf("sys info:\n");
+ printf(" clkbus\t= %ld MHz\n", si->clk_bus / 1000 / 1000);
+ printf(" clkcpu\t= %ld MHz\n", si->clk_cpu / 1000 / 1000);
+ printf(" bar\t\t= 0x%08lx\n", si->bar);
+
+ printf("---\n");
+ for (i = 0; i < si->mr_no; i++) {
+ if (si->mr[i].flags == 0)
+ break;
+
+ printf(" start\t= 0x%08lx\n", si->mr[i].start);
+ printf(" size\t= 0x%08lx\n", si->mr[i].size);
+ printf(" type\t= %s\n", ub_mem_type(si->mr[i].flags));
+ printf("---\n");
+ }
+}
+
/****************************************
*
* env vars
diff --git a/sys/boot/uboot/lib/glue.h b/sys/boot/uboot/lib/glue.h
index 72aff3b55c07..06944b2158f0 100644
--- a/sys/boot/uboot/lib/glue.h
+++ b/sys/boot/uboot/lib/glue.h
@@ -35,10 +35,10 @@
#include "api_public.h"
-int syscall(int, int *, ...);
-void *syscall_ptr;
+int syscall(int, int *, ...);
+void *syscall_ptr;
-int api_search_sig(struct api_signature **sig);
+int api_search_sig(struct api_signature **sig);
/*
* The ub_ library calls are part of the application, not U-Boot code! They
@@ -48,32 +48,36 @@ int api_search_sig(struct api_signature **sig);
*/
/* console */
-int ub_getc(void);
-int ub_tstc(void);
-void ub_putc(char c);
-void ub_puts(const char *s);
+int ub_getc(void);
+int ub_tstc(void);
+void ub_putc(char c);
+void ub_puts(const char *s);
/* system */
-void ub_reset(void);
+void ub_reset(void);
struct sys_info *ub_get_sys_info(void);
/* time */
-void ub_udelay(unsigned long);
-unsigned long ub_get_timer(unsigned long);
+void ub_udelay(unsigned long);
+unsigned long ub_get_timer(unsigned long);
/* env vars */
-char *ub_env_get(const char *name);
-void ub_env_set(const char *name, char *value);
-const char *ub_env_enum(const char *last);
+char *ub_env_get(const char *name);
+void ub_env_set(const char *name, char *value);
+const char *ub_env_enum(const char *last);
/* devices */
-int ub_dev_enum(void);
-int ub_dev_open(int handle);
-int ub_dev_close(int handle);
-int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start);
-int ub_dev_send(int handle, void *buf, int len);
-int ub_dev_recv(int handle, void *buf, int len);
+int ub_dev_enum(void);
+int ub_dev_open(int handle);
+int ub_dev_close(int handle);
+int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start);
+int ub_dev_send(int handle, void *buf, int len);
+int ub_dev_recv(int handle, void *buf, int len);
struct device_info * ub_dev_get(int);
+void ub_dump_di(int);
+void ub_dump_si(struct sys_info *);
+char *ub_mem_type(int);
+
#endif /* _API_GLUE_H_ */