diff options
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/uboot/Makefile | 4 | ||||
-rw-r--r-- | sys/boot/uboot/common/main.c | 17 | ||||
-rw-r--r-- | sys/boot/uboot/lib/Makefile | 5 | ||||
-rw-r--r-- | sys/boot/uboot/lib/api_public.h | 54 | ||||
-rw-r--r-- | sys/boot/uboot/lib/copy.c | 4 | ||||
-rw-r--r-- | sys/boot/uboot/lib/devicename.c | 305 | ||||
-rw-r--r-- | sys/boot/uboot/lib/disk.c | 10 | ||||
-rw-r--r-- | sys/boot/uboot/lib/elf_freebsd.c | 7 | ||||
-rw-r--r-- | sys/boot/uboot/lib/glue.c | 88 | ||||
-rw-r--r-- | sys/boot/uboot/lib/glue.h | 20 | ||||
-rw-r--r-- | sys/boot/uboot/lib/libuboot.h | 20 | ||||
-rw-r--r-- | sys/boot/uboot/lib/module.c | 1 | ||||
-rw-r--r-- | sys/boot/uboot/lib/net.c | 19 | ||||
-rw-r--r-- | sys/boot/uboot/lib/reboot.c | 1 |
14 files changed, 297 insertions, 258 deletions
diff --git a/sys/boot/uboot/Makefile b/sys/boot/uboot/Makefile index d60f27e..1116ee6 100644 --- a/sys/boot/uboot/Makefile +++ b/sys/boot/uboot/Makefile @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= lib - +SUBDIR= lib + .include <bsd.subdir.mk> diff --git a/sys/boot/uboot/common/main.c b/sys/boot/uboot/common/main.c index 762c6ce..9b4379f 100644 --- a/sys/boot/uboot/common/main.c +++ b/sys/boot/uboot/common/main.c @@ -110,11 +110,9 @@ memsize(int flags) int main(void) { - int i; - char *ch; - int bargc; - char **bargv; - + char **bargv; + char *ch; + int bargc, i; struct api_signature *sig = NULL; if (!api_search_sig(&sig)) @@ -172,7 +170,8 @@ main(void) /* XXX only support netbooting for now */ for (i = 0; devsw[i] != NULL; i++) - if (strncmp(devsw[i]->dv_name, "net", strlen(devsw[i]->dv_name)) == 0) + if (strncmp(devsw[i]->dv_name, "net", + strlen(devsw[i]->dv_name)) == 0) break; if (devsw[i] == NULL) @@ -183,9 +182,9 @@ main(void) currdev.d_unit = 0; env_setenv("currdev", EV_VOLATILE, uboot_fmtdev(&currdev), - uboot_setcurrdev, env_nounset); + uboot_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, uboot_fmtdev(&currdev), - env_noset, env_nounset); + env_noset, env_nounset); setenv("LINES", "24", 1); /* optional */ setenv("prompt", "loader>", 1); @@ -207,7 +206,7 @@ static int command_heap(int argc, char *argv[]) { printf("heap base at %p, top at %p, used %ld\n", end, sbrk(0), - sbrk(0) - end); + sbrk(0) - end); return(CMD_OK); } diff --git a/sys/boot/uboot/lib/Makefile b/sys/boot/uboot/lib/Makefile index 564177d..5e66bfb 100644 --- a/sys/boot/uboot/lib/Makefile +++ b/sys/boot/uboot/lib/Makefile @@ -6,13 +6,12 @@ INTERNALLIB= SRCS= devicename.c elf_freebsd.c console.c copy.c disk.c \ module.c net.c reboot.c time.c glue.c -CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ +CFLAGS+= -ffreestanding -msoft-float +CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ # Pick up the bootstrap header for some interface items CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. -CFLAGS+= -ffreestanding -msoft-float - .ifdef(BOOT_DISK_DEBUG) # Make the disk code more talkative CFLAGS+= -DDISK_DEBUG diff --git a/sys/boot/uboot/lib/api_public.h b/sys/boot/uboot/lib/api_public.h index 09fb8a0..0ec6129 100644 --- a/sys/boot/uboot/lib/api_public.h +++ b/sys/boot/uboot/lib/api_public.h @@ -55,25 +55,25 @@ */ #ifndef _API_PUBLIC_H_ -#define _API_PUBLIC_H_ +#define _API_PUBLIC_H_ -#define API_EINVAL 1 /* invalid argument(s) */ -#define API_ENODEV 2 /* no device */ -#define API_ENOMEM 3 /* no memory */ -#define API_EBUSY 4 /* busy, occupied etc. */ -#define API_EIO 5 /* I/O error */ +#define API_EINVAL 1 /* invalid argument(s) */ +#define API_ENODEV 2 /* no device */ +#define API_ENOMEM 3 /* no memory */ +#define API_EBUSY 4 /* busy, occupied etc. */ +#define API_EIO 5 /* I/O error */ -typedef int (*scp_t)(int, int *, ...); +typedef int (*scp_t)(int, int *, ...); -#define API_SIG_VERSION 1 -#define API_SIG_MAGIC "UBootAPI" -#define API_SIG_MAGLEN 8 +#define API_SIG_VERSION 1 +#define API_SIG_MAGIC "UBootAPI" +#define API_SIG_MAGLEN 8 struct api_signature { char magic[API_SIG_MAGLEN]; /* magic string */ - uint16_t version; /* API version */ - uint32_t checksum; /* checksum of this sig struct */ - scp_t syscall; /* entry point to the API */ + uint16_t version; /* API version */ + uint32_t checksum; /* checksum of this sig struct */ + scp_t syscall; /* entry point to the API */ }; enum { @@ -97,9 +97,9 @@ enum { API_MAXCALL }; -#define MR_ATTR_FLASH 0x0001 -#define MR_ATTR_DRAM 0x0002 -#define MR_ATTR_SRAM 0x0003 +#define MR_ATTR_FLASH 0x0001 +#define MR_ATTR_DRAM 0x0002 +#define MR_ATTR_SRAM 0x0003 struct mem_region { unsigned long start; @@ -123,17 +123,17 @@ typedef unsigned long lbasize_t; #endif typedef unsigned long lbastart_t; -#define DEV_TYP_NONE 0x0000 -#define DEV_TYP_NET 0x0001 +#define DEV_TYP_NONE 0x0000 +#define DEV_TYP_NET 0x0001 -#define DEV_TYP_STOR 0x0002 -#define DT_STOR_IDE 0x0010 -#define DT_STOR_SCSI 0x0020 -#define DT_STOR_USB 0x0040 -#define DT_STOR_MMC 0x0080 +#define DEV_TYP_STOR 0x0002 +#define DT_STOR_IDE 0x0010 +#define DT_STOR_SCSI 0x0020 +#define DT_STOR_USB 0x0040 +#define DT_STOR_MMC 0x0080 -#define DEV_STA_CLOSED 0x0000 /* invalid, closed */ -#define DEV_STA_OPEN 0x0001 /* open i.e. active */ +#define DEV_STA_CLOSED 0x0000 /* invalid, closed */ +#define DEV_STA_OPEN 0x0001 /* open i.e. active */ struct device_info { int type; @@ -149,8 +149,8 @@ struct device_info { unsigned char hwaddr[6]; } net; } info; -#define di_stor info.storage -#define di_net info.net +#define di_stor info.storage +#define di_net info.net int state; }; diff --git a/sys/boot/uboot/lib/copy.c b/sys/boot/uboot/lib/copy.c index bc5f1a4..e5e4626 100644 --- a/sys/boot/uboot/lib/copy.c +++ b/sys/boot/uboot/lib/copy.c @@ -40,8 +40,8 @@ ssize_t uboot_copyin(const void *src, vm_offset_t dest, const size_t len) { - bcopy(src, (void *)dest, len); - return (len); + bcopy(src, (void *)dest, len); + return (len); } ssize_t diff --git a/sys/boot/uboot/lib/devicename.c b/sys/boot/uboot/lib/devicename.c index 2bf2bea..c56d842 100644 --- a/sys/boot/uboot/lib/devicename.c +++ b/sys/boot/uboot/lib/devicename.c @@ -27,16 +27,17 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/disklabel.h> + #include <stand.h> #include <string.h> -#include <sys/disklabel.h> #include "bootstrap.h" #include "libuboot.h" static int uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, const char **path); -/* +/* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, * use that. If not, use the default device. @@ -44,27 +45,26 @@ static int uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, const int uboot_getdev(void **vdev, const char *devspec, const char **path) { - struct uboot_devdesc **dev = (struct uboot_devdesc **)vdev; - int rv; - - /* - * If it looks like this is just a path and no - * device, go with the current device. - */ - if ((devspec == NULL) || - (devspec[0] == '/') || - (strchr(devspec, ':') == NULL)) { - - if (((rv = uboot_parsedev(dev, getenv("currdev"), NULL)) == 0) && - (path != NULL)) + struct uboot_devdesc **dev = (struct uboot_devdesc **)vdev; + int rv; + + /* + * If it looks like this is just a path and no + * device, go with the current device. + */ + if ((devspec == NULL) || (devspec[0] == '/') || + (strchr(devspec, ':') == NULL)) { + + if (((rv = uboot_parsedev(dev, getenv("currdev"), NULL)) == 0) + && (path != NULL)) *path = devspec; - return(rv); - } - - /* - * Try to parse the device name off the beginning of the devspec - */ - return(uboot_parsedev(dev, devspec, path)); + return(rv); + } + + /* + * Try to parse the device name off the beginning of the devspec. + */ + return(uboot_parsedev(dev, devspec, path)); } /* @@ -79,159 +79,166 @@ uboot_getdev(void **vdev, const char *devspec, const char **path) * For disk-type devices, the syntax is: * * disk<unit>[s<slice>][<partition>]: - * + * */ static int -uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, const char **path) +uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, + const char **path) { - struct uboot_devdesc *idev; - struct devsw *dv; - int i, unit, slice, partition, err; - char *cp; - const char *np; - - /* minimum length check */ - if (strlen(devspec) < 2) - return(EINVAL); - - /* look for a device that matches */ - for (i = 0, dv = NULL; devsw[i] != NULL; i++) { - if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { - dv = devsw[i]; - break; + struct uboot_devdesc *idev; + struct devsw *dv; + char *cp; + const char *np; + int i, unit, slice, partition, err; + + /* minimum length check */ + if (strlen(devspec) < 2) + return(EINVAL); + + /* look for a device that matches */ + for (i = 0, dv = NULL; devsw[i] != NULL; i++) { + if (!strncmp(devspec, devsw[i]->dv_name, + strlen(devsw[i]->dv_name))) { + dv = devsw[i]; + break; + } } - } - if (dv == NULL) - return(ENOENT); - idev = malloc(sizeof(struct uboot_devdesc)); - err = 0; - np = (devspec + strlen(dv->dv_name)); - - switch(dv->dv_type) { - case DEVT_NONE: /* XXX what to do here? Do we care? */ - break; - - case DEVT_DISK: - unit = -1; - slice = -1; - partition = -1; - if (*np && (*np != ':')) { - unit = strtol(np, &cp, 10); /* next comes the unit number */ - if (cp == np) { - err = EUNIT; + if (dv == NULL) + return(ENOENT); + idev = malloc(sizeof(struct uboot_devdesc)); + err = 0; + np = (devspec + strlen(dv->dv_name)); + + switch(dv->dv_type) { + case DEVT_NONE: /* XXX what to do here? Do we care? */ + break; + + case DEVT_DISK: + unit = -1; + slice = -1; + partition = -1; + if (*np && (*np != ':')) { + /* next comes the unit number */ + unit = strtol(np, &cp, 10); + if (cp == np) { + err = EUNIT; + goto fail; + } + if (*cp == 's') { /* got a slice number */ + np = cp + 1; + slice = strtol(np, &cp, 10); + if (cp == np) { + err = ESLICE; + goto fail; + } + } + if (*cp && (*cp != ':')) { + /* get a partition number */ + partition = *cp - 'a'; + if ((partition < 0) || + (partition >= MAXPARTITIONS)) { + err = EPART; + goto fail; + } + cp++; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; goto fail; - } - if (*cp == 's') { /* got a slice number */ - np = cp + 1; - slice = strtol(np, &cp, 10); - if (cp == np) { - err = ESLICE; - goto fail; } - } - if (*cp && (*cp != ':')) { - partition = *cp - 'a'; /* get a partition number */ - if ((partition < 0) || (partition >= MAXPARTITIONS)) { - err = EPART; - goto fail; + + idev->d_unit = unit; + idev->d_kind.disk.slice = slice; + idev->d_kind.disk.partition = partition; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + case DEVT_NET: + unit = 0; + + if (*np && (*np != ':')) { + /* get unit number if present */ + unit = strtol(np, &cp, 0); + if (cp == np) { + err = EUNIT; + goto fail; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; } - cp++; - } - } - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - idev->d_unit = unit; - idev->d_kind.disk.slice = slice; - idev->d_kind.disk.partition = partition; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; + if (dv->dv_type == DEVT_NET) + idev->d_unit = unit; - case DEVT_NET: - unit = 0; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; - if (*np && (*np != ':')) { - unit = strtol(np, &cp, 0); /* get unit number if present */ - if (cp == np) { - err = EUNIT; + default: + err = EINVAL; goto fail; - } } - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; + idev->d_dev = dv; + idev->d_type = dv->dv_type; + if (dev == NULL) { + free(idev); + } else { + *dev = idev; } + return(0); - if (dv->dv_type == DEVT_NET) - idev->d_unit = unit; - - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - - default: - err = EINVAL; - goto fail; - } - idev->d_dev = dv; - idev->d_type = dv->dv_type; - if (dev == NULL) { +fail: free(idev); - } else { - *dev = idev; - } - return(0); - - fail: - free(idev); - return(err); + return(err); } char * uboot_fmtdev(void *vdev) { - struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev; - static char buf[128]; /* XXX device length constant? */ - char *cp; - - switch(dev->d_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_DISK: - cp = buf; - cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit); - if (dev->d_kind.disk.slice > 0) - cp += sprintf(cp, "s%d", dev->d_kind.disk.slice); - if (dev->d_kind.disk.partition >= 0) - cp += sprintf(cp, "%c", dev->d_kind.disk.partition + 'a'); - strcat(cp, ":"); - break; - - case DEVT_NET: - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); - break; - } - return(buf); + struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev; + char *cp; + static char buf[128]; /* XXX device length constant? */ + + switch(dev->d_type) { + case DEVT_NONE: + strcpy(buf, "(no device)"); + break; + + case DEVT_DISK: + cp = buf; + cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit); + if (dev->d_kind.disk.slice > 0) + cp += sprintf(cp, "s%d", dev->d_kind.disk.slice); + if (dev->d_kind.disk.partition >= 0) + cp += sprintf(cp, "%c", dev->d_kind.disk.partition + + 'a'); + strcat(cp, ":"); + break; + + case DEVT_NET: + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); + break; + } + return(buf); } /* - * Set currdev to suit the value being supplied in (value) + * Set currdev to suit the value being supplied in (value). */ int uboot_setcurrdev(struct env_var *ev, int flags, const void *value) { - struct uboot_devdesc *ncurr; - int rv; - - if ((rv = uboot_parsedev(&ncurr, value, NULL)) != 0) - return(rv); - free(ncurr); - env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); - return(0); + struct uboot_devdesc *ncurr; + int rv; + + if ((rv = uboot_parsedev(&ncurr, value, NULL)) != 0) + return(rv); + free(ncurr); + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + return(0); } diff --git a/sys/boot/uboot/lib/disk.c b/sys/boot/uboot/lib/disk.c index 2adc6ba..796973d 100644 --- a/sys/boot/uboot/lib/disk.c +++ b/sys/boot/uboot/lib/disk.c @@ -40,8 +40,8 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" static int d_init(void); -static int d_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); +static int d_strategy(void *devdata, int flag, daddr_t dblk, + size_t size, char *buf, size_t *rsize); static int d_open(struct open_file *f, ...); static int d_close(struct open_file *f); static int d_ioctl(struct open_file *f, u_long cmd, void *data); @@ -68,6 +68,7 @@ SLIST_HEAD(, opened_dev) opened_devs = SLIST_HEAD_INITIALIZER(opened_dev); static int d_init(void) { + return 0; } @@ -75,24 +76,28 @@ static int d_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize) { + return (EINVAL); } static int d_open(struct open_file *f, ...) { + return (EINVAL); } static int d_close(struct open_file *f) { + return (EINVAL); } static int d_ioctl(struct open_file *f, u_long cmd, void *data) { + return (EINVAL); } @@ -100,4 +105,5 @@ static void d_print(int verbose) { + return; } diff --git a/sys/boot/uboot/lib/elf_freebsd.c b/sys/boot/uboot/lib/elf_freebsd.c index 735dd31..31da240 100644 --- a/sys/boot/uboot/lib/elf_freebsd.c +++ b/sys/boot/uboot/lib/elf_freebsd.c @@ -63,9 +63,9 @@ int __elfN(uboot_exec)(struct preloaded_file *fp) { struct file_metadata *fmp; - vm_offset_t mdp; + vm_offset_t mdp; Elf_Ehdr *e; - int error; + int error; if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { return (EFTYPE); @@ -83,8 +83,7 @@ __elfN(uboot_exec)(struct preloaded_file *fp) panic("exec returned"); } -struct file_format uboot_elf = -{ +struct file_format uboot_elf = { __elfN(uboot_load), __elfN(uboot_exec) }; diff --git a/sys/boot/uboot/lib/glue.c b/sys/boot/uboot/lib/glue.c index 6ba01ab..fe982d6 100644 --- a/sys/boot/uboot/lib/glue.c +++ b/sys/boot/uboot/lib/glue.c @@ -35,9 +35,9 @@ __FBSDID("$FreeBSD$"); #undef DEBUG #ifdef DEBUG -#define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt,##args); } while (0) +#define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt,##args); } while (0) #else -#define debugf(fmt, args...) +#define debugf(fmt, args...) #endif /* Some random address used by U-Boot. */ @@ -106,7 +106,8 @@ crc32(const void *buf, size_t size) } -static int valid_sig(struct api_signature *sig) +static int +valid_sig(struct api_signature *sig) { uint32_t checksum; struct api_signature s; @@ -134,7 +135,9 @@ static int valid_sig(struct api_signature *sig) * * returns 1/0 depending on found/not found result */ -int api_search_sig(struct api_signature **sig) { +int +api_search_sig(struct api_signature **sig) +{ unsigned char *sp, *spend; @@ -165,7 +168,8 @@ int api_search_sig(struct api_signature **sig) { * ****************************************/ -int ub_getc(void) +int +ub_getc(void) { int c; @@ -175,7 +179,8 @@ int ub_getc(void) return c; } -int ub_tstc(void) +int +ub_tstc(void) { int t; @@ -185,13 +190,17 @@ int ub_tstc(void) return t; } -void ub_putc(char c) +void +ub_putc(char c) { + syscall(API_PUTC, NULL, (uint32_t)&c); } -void ub_puts(const char *s) +void +ub_puts(const char *s) { + syscall(API_PUTS, NULL, (uint32_t)s); } @@ -201,25 +210,28 @@ void ub_puts(const char *s) * ****************************************/ -void ub_reset(void) +void +ub_reset(void) { + syscall(API_RESET, NULL); } -#define MR_MAX 5 +#define MR_MAX 5 static struct mem_region mr[MR_MAX]; static struct sys_info si; -struct sys_info * ub_get_sys_info(void) +struct sys_info * +ub_get_sys_info(void) { int err = 0; - + memset(&si, 0, sizeof(struct sys_info)); si.mr = mr; si.mr_no = MR_MAX; memset(&mr, 0, sizeof(mr)); - + if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si)) return (NULL); @@ -233,16 +245,18 @@ struct sys_info * ub_get_sys_info(void) * ****************************************/ -void ub_udelay(unsigned long usec) +void +ub_udelay(unsigned long usec) { syscall(API_UDELAY, NULL, &usec); } -unsigned long ub_get_timer(unsigned long base) +unsigned long +ub_get_timer(unsigned long base) { unsigned long cur; - + if (!syscall(API_GET_TIMER, NULL, &cur, &base)) return (0); @@ -258,12 +272,14 @@ unsigned long ub_get_timer(unsigned long base) * ***************************************************************************/ -#define MAX_DEVS 6 +#define MAX_DEVS 6 static struct device_info devices[MAX_DEVS]; -struct device_info * ub_dev_get(int i) +struct device_info * +ub_dev_get(int i) { + return ((i < 0 || i >= MAX_DEVS) ? NULL : &devices[i]); } @@ -273,7 +289,8 @@ struct device_info * ub_dev_get(int i) * * returns: number of devices found */ -int ub_dev_enum(void) +int +ub_dev_enum(void) { struct device_info *di; int n = 0; @@ -308,7 +325,8 @@ int ub_dev_enum(void) * * returns: 0 when OK, err otherwise */ -int ub_dev_open(int handle) +int +ub_dev_open(int handle) { struct device_info *di; int err = 0; @@ -323,7 +341,8 @@ int ub_dev_open(int handle) return (err); } -int ub_dev_close(int handle) +int +ub_dev_close(int handle) { struct device_info *di; @@ -345,7 +364,8 @@ int ub_dev_close(int handle) * * returns: 0/1 accordingly */ -static int dev_valid(int handle) +static int +dev_valid(int handle) { if (handle < 0 || handle >= MAX_DEVS) @@ -357,7 +377,8 @@ static int dev_valid(int handle) return (1); } -static int dev_stor_valid(int handle) +static int +dev_stor_valid(int handle) { if (!dev_valid(handle)) @@ -369,7 +390,8 @@ static int dev_stor_valid(int handle) return (1); } -int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start) +int +ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start) { struct device_info *di; lbasize_t act_len; @@ -391,7 +413,8 @@ int ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start) return (0); } -static int dev_net_valid(int handle) +static int +dev_net_valid(int handle) { if (!dev_valid(handle)) @@ -403,7 +426,8 @@ static int dev_net_valid(int handle) return (1); } -int ub_dev_recv(int handle, void *buf, int len) +int +ub_dev_recv(int handle, void *buf, int len) { struct device_info *di; int err = 0, act_len; @@ -421,7 +445,8 @@ int ub_dev_recv(int handle, void *buf, int len) return (act_len); } -int ub_dev_send(int handle, void *buf, int len) +int +ub_dev_send(int handle, void *buf, int len) { struct device_info *di; int err = 0; @@ -442,7 +467,8 @@ int ub_dev_send(int handle, void *buf, int len) * ****************************************/ -char * ub_env_get(const char *name) +char * +ub_env_get(const char *name) { char *value; @@ -452,7 +478,8 @@ char * ub_env_get(const char *name) return (value); } -void ub_env_set(const char *name, char *value) +void +ub_env_set(const char *name, char *value) { syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value); @@ -461,7 +488,8 @@ void ub_env_set(const char *name, char *value) static char env_name[256]; -const char * ub_env_enum(const char *last) +const char * +ub_env_enum(const char *last) { const char *env, *str; int i; diff --git a/sys/boot/uboot/lib/glue.h b/sys/boot/uboot/lib/glue.h index b079415..a7d0868 100644 --- a/sys/boot/uboot/lib/glue.h +++ b/sys/boot/uboot/lib/glue.h @@ -52,7 +52,7 @@ 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 */ @@ -60,18 +60,18 @@ 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); +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); #endif /* _API_GLUE_H_ */ diff --git a/sys/boot/uboot/lib/libuboot.h b/sys/boot/uboot/lib/libuboot.h index 771b7ce..e658008 100644 --- a/sys/boot/uboot/lib/libuboot.h +++ b/sys/boot/uboot/lib/libuboot.h @@ -49,24 +49,24 @@ struct uboot_devdesc /* * Default network packet alignment in memory */ -#define PKTALIGN 32 +#define PKTALIGN 32 -extern int uboot_getdev(void **vdev, const char *devspec, const char **path); -extern char *uboot_fmtdev(void *vdev); -extern int uboot_setcurrdev(struct env_var *ev, int flags, const void *value); +int uboot_getdev(void **vdev, const char *devspec, const char **path); +char *uboot_fmtdev(void *vdev); +int uboot_setcurrdev(struct env_var *ev, int flags, const void *value); -extern struct netif_driver uboot_net; -extern struct devsw uboot_disk; +extern struct netif_driver uboot_net; +extern struct devsw uboot_disk; ssize_t uboot_copyin(const void *src, vm_offset_t dest, const size_t len); -ssize_t uboot_copyout(const vm_offset_t src, void *dest, const size_t len); -ssize_t uboot_readin(const int fd, vm_offset_t dest, const size_t len); +ssize_t uboot_copyout(const vm_offset_t src, void *dest, const size_t len); +ssize_t uboot_readin(const int fd, vm_offset_t dest, const size_t len); extern int uboot_autoload(void); struct preloaded_file; struct file_format; -extern struct file_format uboot_elf; +extern struct file_format uboot_elf; -extern void reboot(void); +void reboot(void); diff --git a/sys/boot/uboot/lib/module.c b/sys/boot/uboot/lib/module.c index 3928857..f03d644 100644 --- a/sys/boot/uboot/lib/module.c +++ b/sys/boot/uboot/lib/module.c @@ -42,5 +42,6 @@ __FBSDID("$FreeBSD$"); int uboot_autoload(void) { + return(0); } diff --git a/sys/boot/uboot/lib/net.c b/sys/boot/uboot/lib/net.c index 92d9a54..6e05e73 100644 --- a/sys/boot/uboot/lib/net.c +++ b/sys/boot/uboot/lib/net.c @@ -64,7 +64,7 @@ extern int devs_no; extern struct netif_stats net_stats[]; struct netif_dif net_ifs[] = { - /* dif_unit dif_nsel dif_stats dif_private */ + /* dif_unit dif_nsel dif_stats dif_private */ { 0, 1, &net_stats[0], 0, }, }; @@ -107,16 +107,16 @@ net_match(struct netif *nif, void *machdep_hint) static int net_probe(struct netif *nif, void *machdep_hint) { - int i; struct device_info *di; + int i; for (i = 0; i < devs_no; i++) if (di = ub_dev_get(i)) if (di->type == DEV_TYP_NET) break; if (i == devs_no) { - printf("net_probe: no network devices found, maybe not\ - enumerated yet..?\n"); + printf("net_probe: no network devices found, maybe not" + " enumerated yet..?\n"); return (-1); } @@ -172,14 +172,12 @@ net_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout) { struct netif *nif = desc->io_netif; struct uboot_softc *sc = nif->nif_devdata; - time_t t; int length; #if defined(NETIF_DEBUG) printf("net_get: pkt %x, len %d, timeout %d\n", pkt, len, timeout); #endif - t = getsecs(); do { length = ub_dev_recv(sc->sc_handle, sc->sc_rxbuf, len); @@ -207,11 +205,11 @@ net_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout) static void net_init(struct iodesc *desc, void *machdep_hint) { - int i, err; struct netif *nif = desc->io_netif; struct uboot_softc *sc; struct device_info *di; - + int err, i; + sc = nif->nif_devdata = &uboot_softc; if (err = ub_dev_open(sc->sc_handle)) @@ -234,15 +232,16 @@ net_init(struct iodesc *desc, void *machdep_hint) /* Set correct alignment for TX packets */ sc->sc_txbufp = sc->sc_txbuf; if ((unsigned long)sc->sc_txbufp % PKTALIGN) - sc->sc_txbufp += PKTALIGN - (unsigned long)sc->sc_txbufp % PKTALIGN; + sc->sc_txbufp += PKTALIGN - + (unsigned long)sc->sc_txbufp % PKTALIGN; } static void net_end(struct netif *nif) { - int err; struct uboot_softc *sc = nif->nif_devdata; + int err; if (err = ub_dev_close(sc->sc_handle)) panic("%s%d: net_end failed with error %d\n", diff --git a/sys/boot/uboot/lib/reboot.c b/sys/boot/uboot/lib/reboot.c index e709d50..6271ed1 100644 --- a/sys/boot/uboot/lib/reboot.c +++ b/sys/boot/uboot/lib/reboot.c @@ -30,5 +30,6 @@ __FBSDID("$FreeBSD$"); void exit(int code) { + ub_reset(); } |