PERFORCE change 127972 for review

Rafal Jaworowski raj at FreeBSD.org
Tue Oct 23 13:08:49 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=127972

Change 127972 by raj at raj_mimi on 2007/10/23 20:07:56

	Adapt loader(8) and surroundings to the new U-Boot API
	
	This update requires that loader(8) is run on top of U-Boot that is
	fresh enough to include this new API; up-to-date support for FreeBSD
	can always be found at:
	http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot/u-boot-freebsd.git

Affected files ...

.. //depot/projects/e500/lib/libstand/Makefile#3 edit
.. //depot/projects/e500/sys/boot/ficl/Makefile#2 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/Makefile#2 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/conf.c#2 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/defs.sh#2 delete
.. //depot/projects/e500/sys/boot/powerpc/uboot/gnu/NOTES#2 delete
.. //depot/projects/e500/sys/boot/powerpc/uboot/gnu/global_data.h#2 delete
.. //depot/projects/e500/sys/boot/powerpc/uboot/gnu/u-boot.h#2 delete
.. //depot/projects/e500/sys/boot/powerpc/uboot/metadata.c#2 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/start.S#2 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/version#2 edit
.. //depot/projects/e500/sys/boot/uboot/common/calls.sh#2 delete
.. //depot/projects/e500/sys/boot/uboot/common/main.c#3 edit
.. //depot/projects/e500/sys/boot/uboot/gnu/NOTES#2 delete
.. //depot/projects/e500/sys/boot/uboot/gnu/_exports.h#2 delete
.. //depot/projects/e500/sys/boot/uboot/lib/Makefile#3 edit
.. //depot/projects/e500/sys/boot/uboot/lib/api_public.h#1 add
.. //depot/projects/e500/sys/boot/uboot/lib/console.c#2 edit
.. //depot/projects/e500/sys/boot/uboot/lib/devicename.c#2 edit
.. //depot/projects/e500/sys/boot/uboot/lib/glue.c#1 add
.. //depot/projects/e500/sys/boot/uboot/lib/libuboot.h#2 edit
.. //depot/projects/e500/sys/boot/uboot/lib/net.c#2 edit
.. //depot/projects/e500/sys/boot/uboot/lib/reboot.c#2 edit
.. //depot/projects/e500/sys/boot/uboot/lib/time.c#2 edit
.. //depot/projects/e500/sys/powerpc/include/bootinfo.h#3 edit

Differences ...

==== //depot/projects/e500/lib/libstand/Makefile#3 (text+ko) ====

@@ -23,7 +23,7 @@
 CFLAGS+=	-mno-sse3
 .endif
 .if ${MACHINE_ARCH} == "powerpc"
-CFLAGS+=	-msoft-float -D_STANDALONE
+CFLAGS+=	-ffixed-r14 -ffixed-r29 -msoft-float -D_STANDALONE
 .endif
 .if ${MACHINE_ARCH} == "amd64"
 CFLAGS+=	-m32 -I.

==== //depot/projects/e500/sys/boot/ficl/Makefile#2 (text+ko) ====

@@ -15,7 +15,13 @@
 CFLAGS+=	-mno-sse3
 .endif
 .if ${MACHINE_ARCH} == "powerpc"
-CFLAGS+=	-msoft-float
+#
+# Important notice: registers dedicated for U-Boot must NOT be used by the
+# loader code, as we are going to jump between loader(8) and U-Boot code back
+# and forth safely. For PowerPC these are r14 and r29, but always make
+# sure in the U-Boot cpu/{CPU}/config.mk, e.g. cpu/mpc85xx/config.mk
+#
+CFLAGS+=	-ffixed-r14 -ffixed-r29 -msoft-float
 .endif
 .if ${MACHINE} == "pc98"
 CFLAGS+=	-DPC98

==== //depot/projects/e500/sys/boot/powerpc/uboot/Makefile#2 (text+ko) ====

@@ -64,10 +64,10 @@
 #
 # Important notice: registers dedicated for U-Boot must NOT be used by the
 # loader code, as we are going to jump between loader(8) and U-Boot code back
-# and forth safely. For PowerPC these are r2, r14 and r29, but always make
+# and forth safely. For PowerPC these are r14 and r29, but always make
 # sure in the U-Boot cpu/{CPU}/config.mk, e.g. cpu/mpc85xx/config.mk
 #
-CFLAGS+=	-ffreestanding -ffixed-r2 -ffixed-r14 -ffixed-r29
+CFLAGS+=	-ffreestanding -ffixed-r14 -ffixed-r29
 
 LDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.powerpc
 

==== //depot/projects/e500/sys/boot/powerpc/uboot/conf.c#2 (text+ko) ====

@@ -1,5 +1,4 @@
 /*-
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj at semihalf.com>
  * Copyright (c) 1999 Michael Smith <msmith at freebsd.org>
  * All rights reserved.
  *

==== //depot/projects/e500/sys/boot/powerpc/uboot/metadata.c#2 (text+ko) ====

@@ -39,10 +39,11 @@
 #include <machine/metadata.h>
 #include <machine/bootinfo.h>
 
+#include "api_public.h"
 #include "bootstrap.h"
-#include "u-boot_defs.h"
 
-extern gd_t	*uboot_global_data;
+/* XXX should this go into header? */
+struct sys_info *ub_get_sys_info(void);
 
 /*
  * Return a 'boothowto' value corresponding to the kernel arguments in
@@ -270,7 +271,7 @@
     vm_offset_t			envp;
     vm_offset_t			size;
     vm_offset_t			vaddr;
-    bd_t			*bd = uboot_global_data->bd;
+    struct sys_info		*si;
     char			*rootdevname;
     int				howto;
     int				i;
@@ -309,18 +310,31 @@
     addr = roundup(addr, PAGE_SIZE);
 
     /* Fill information structure */
+    if (!(si = ub_get_sys_info()))
+	panic("can't retrieve U-Boot sysinfo");
+
+    /* Extract mem info */
+    for (i = 0; i < si->mr_no; i++)
+        if (si->mr[i].flags == MR_ATTR_DRAM) {
+	    bootinfo.mem_base = si->mr[i].start;
+	    bootinfo.mem_size = si->mr[i].size;
+	    break;
+	}
+
+    if (i == si->mr_no)
+        panic("can't retrieve memory info");
+
     bootinfo.version = 1;
-    bootinfo.mem_base = bd->bi_memstart;
-    bootinfo.mem_size = bd->bi_memsize;
-    bootinfo.bar_base = bd->BI_BAR_BASE;
-    bootinfo.cpu_clk = uboot_global_data->cpu_clk;
-    bootinfo.bus_clk = uboot_global_data->bus_clk;
-    bootinfo.baudrate = uboot_global_data->baudrate;
+    bootinfo.bar_base = si->bar;
+    bootinfo.cpu_clk = si->clk_cpu;
+    bootinfo.bus_clk = si->clk_bus;
+
+#if 0
     memcpy(bootinfo.eth0_addr, bd->bi_enetaddr, sizeof(bootinfo.eth0_addr));
 #ifdef CONFIG_HAS_ETH1
     memcpy(bootinfo.eth1_addr, bd->bi_enet1addr, sizeof(bootinfo.eth1_addr));
 #endif
-    bootinfo.eth_speed = bd->bi_ethspeed;
+#endif
 
     kernend = 0;
     kfp = file_findfile(NULL, "elf32 kernel");
@@ -340,7 +354,7 @@
     md = file_findmetadata(kfp, MODINFOMD_KERNEND);
     bcopy(&kernend, md->md_data, sizeof kernend);
 
-    /* Convert the address to the final VA */
+    /* Convert addresses to the final VA */
     *modulep -= __elfN(relocation_offset);
 
     for (i = 0; i < sizeof mdt / sizeof mdt[0]; i++) {

==== //depot/projects/e500/sys/boot/powerpc/uboot/start.S#2 (text+ko) ====

@@ -25,7 +25,6 @@
  */
 
 #include <machine/asm.h>
-#include "u-boot_calls.h"
 
 #define STACK_SIZE 8192
 
@@ -39,43 +38,17 @@
 	lis	%r1, stack at ha
 	addi	%r1, %r1, stack at l
 	addi	%r1, %r1, (STACK_SIZE - 32)
-
-	/* The global_data ptr is passed in R29 - save it */
-	lis	%r4, uboot_global_data at ha
-	addi	%r4, %r4, uboot_global_data at l
-	stw	%r29, 0(%r4)
-
 	b	main
 
-
-#define UB_CALL(FUNC)				\
-	ENTRY(ub_ ## FUNC)			\
-	lis	%r11, uboot_jump_table at ha;	\
-	addi	%r11, %r11, uboot_jump_table at l;	\
-	lwz	%r11, 0(%r11);			\
-						\
-	lwz	%r11, 4*XF_ ## FUNC(%r11);	\
-	mtctr	%r11;				\
-	bctr
-
 /*
- * U-Boot jump table entries - refer to <u-boot>/include/exports.h
- *
- * The calls can then be used in the loader code with ub_ prefix like
- * ub_getc() etc.
+ * syscall()
  */
-UB_CALL(get_version);
-UB_CALL(getc);
-UB_CALL(tstc);
-UB_CALL(putc);
-UB_CALL(udelay);
-UB_CALL(get_timer);
-UB_CALL(do_reset);
-UB_CALL(eth_init);
-UB_CALL(eth_halt);
-UB_CALL(eth_send);
-UB_CALL(eth_receive);
-
+ENTRY(syscall)
+	lis	%r11, syscall_ptr at ha
+	addi	%r11, %r11, syscall_ptr at l
+	lwz	%r11, 0(%r11)
+	mtctr	%r11
+	bctr
 
 /*
  * Data section
@@ -85,8 +58,5 @@
 stack:
 	.space	STACK_SIZE
 
-GLOBAL(uboot_global_data)
-        .long   0
-
-GLOBAL(uboot_jump_table)
+GLOBAL(syscall_ptr)
 	.long	0

==== //depot/projects/e500/sys/boot/powerpc/uboot/version#2 (text+ko) ====

@@ -3,6 +3,7 @@
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important.  Make sure the current version number is on line 6.
 
+0.6:	Integrated with the new U-Boot API
 0.5:	Full network functionality.
 0.2:	Initial U-Boot/PowerPC version derived from the existing
 	OpenFirmware-based.

==== //depot/projects/e500/sys/boot/uboot/common/main.c#3 (text+ko) ====

@@ -33,12 +33,13 @@
 #include "bootstrap.h"
 
 #include "libuboot.h"
-#include "u-boot_defs.h"
+#include "api_public.h"
 
-#define XF_VERSION	4		/* required U-Boot API version */
+#define DEBUG
 
 struct uboot_devdesc	currdev;
 struct arch_switch	archsw;		/* MI/MD interface boundary */
+int			devs_no;
 
 extern char end[];
 extern char bootprog_name[];
@@ -46,9 +47,6 @@
 extern char bootprog_date[];
 extern char bootprog_maker[];
 
-extern gd_t *uboot_global_data;
-extern void **uboot_jump_table;
-
 static char bootargs[128];
 
 extern unsigned char _etext[];
@@ -58,24 +56,59 @@
 extern unsigned char __sbss_end[];
 extern unsigned char _end[];
 
+extern void *		syscall_ptr;
+
+struct sys_info *	ub_get_sys_info(void);
+
+
+void dump_si(struct sys_info *si)
+{
+#ifdef DEBUG
+	printf("sys info:\n");
+	printf("  clkbus\t= 0x%08x\n", si->clk_bus);
+	printf("  clkcpu\t= 0x%08x\n", si->clk_cpu);
+	printf("  bar\t\t= 0x%08x\n", si->bar);
+#endif
+}
+
+static void dump_sig(struct api_signature *sig)
+{
+#ifdef DEBUG
+	printf("signature:\n");
+	printf("  version\t= %d\n", sig->version);
+	printf("  checksum\t= 0x%08x\n", sig->checksum);
+	printf("  sc entry\t= 0x%08x\n", sig->syscall);
+#endif
+}
 static void
 dump_addr_info(void)
 {
-	printf("\nimage addresses:\n");
+#ifdef DEBUG
+	printf("\naddresses info:\n");
 	printf(" _etext (sdata) = 0x%08x\n", (u_int32_t)_etext);
 	printf(" _edata         = 0x%08x\n", (u_int32_t)_edata);
 	printf(" __sbss_start   = 0x%08x\n", (u_int32_t)__sbss_start);
 	printf(" __sbss_end     = 0x%08x\n", (u_int32_t)__sbss_end);
 	printf(" __sbss_start   = 0x%08x\n", (u_int32_t)__bss_start);
 	printf(" _end           = 0x%08x\n", (u_int32_t)_end);
-	printf(" global_data    = 0x%08x\n", (u_int32_t)uboot_global_data);
-	printf(" jumptable      = 0x%08x\n", (u_int32_t)uboot_jump_table);
+	printf(" syscall entry  = 0x%08x\n", (u_int32_t)syscall_ptr);
+#endif
 }
 
-uint64_t
-memsize(void)
+static uint64_t
+memsize(int flags)
 {
-	return (uboot_global_data->ram_size);
+	int i;
+	struct sys_info * si;
+
+	if ((si = ub_get_sys_info()) == NULL)
+		return 0;
+	
+	for (i = 0; i < si->mr_no; i++)
+		if (si->mr[i].flags == flags && si->mr[i].size)
+			return (si->mr[i].size);
+
+	return 0;
 }
 
 int
@@ -86,8 +119,17 @@
 	int		bargc;
 	char		**bargv;
 
-	/* Extract JT pointer */
-	uboot_jump_table = uboot_global_data->jt;
+	struct api_signature *sig = NULL;
+
+	if (!api_search_sig(&sig))
+		return -1;
+
+	syscall_ptr = sig->syscall;
+	if (syscall_ptr == NULL)
+		return -2;
+
+	if (sig->version > API_SIG_VERSION)
+		return -3;
 
         /* Clear BSS sections */
 	bzero(__sbss_start, __sbss_end - __sbss_start);
@@ -98,22 +140,26 @@
          */
 	cons_probe();
 
-	/* Check if we're compatible */
-	if (ub_get_version() < XF_VERSION)
-		panic("U-Boot API version too low: %d, expected: %d",
-			ub_get_version(), XF_VERSION);
+	printf("Compatible API signature found @%x\n", sig);
 
-	printf("Found compatible API, ver. %d\n", ub_get_version());
-#if 0
+	dump_sig(sig);
 	dump_addr_info();
-#endif
+
 	/*
 	 * Initialise the heap as early as possible.  Once this is done,
 	 * alloc() is usable. The stack is buried inside us, so this is
 	 * safe.
 	 */
-	setheap((void *)end, (void *)(end + 512*1024));
+	setheap((void *)end, (void *)(end + 512 * 1024));
+
+	/*
+	 * Enumerate U-Boot devices
+	 */
+	if ((devs_no = ub_dev_enum()) == 0)
+		panic("no devices found");
+	printf("Number of U-Boot devices found %d\n", devs_no);
 
+	/* XXX all our dv_init()s currently don't do anything... */
 	/*
 	 * March through the device switch probing for things.
 	 */
@@ -124,20 +170,21 @@
 	printf("\n");
 	printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
 	printf("(%s, %s)\n", bootprog_maker, bootprog_date);
-	printf("Memory: %lldMB\n", memsize() / 1024 / 1024);
+	printf("Memory: %lldMB\n", memsize(MR_ATTR_DRAM) / 1024 / 1024);
+	printf("FLASH:  %lldMB\n", memsize(MR_ATTR_FLASH) / 1024 / 1024);
+//	printf("SRAM:   %lldMB\n", memsize(MR_ATTR_SRAM) / 1024 / 1024);
 
 	/* 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)
+	for (i = 0; devsw[i] != NULL; i++)
+		if (strncmp(devsw[i]->dv_name, "net", strlen(devsw[i]->dv_name)) == 0)
 			break;
-	}
+
 	if (devsw[i] == NULL)
 		panic("no network devices?!");
 
 	currdev.d_dev = devsw[i];
 	currdev.d_type = currdev.d_dev->dv_type;
-	currdev.d_kind.netif.unit = 0;
+	currdev.d_unit = 0;
 
 	env_setenv("currdev", EV_VOLATILE, uboot_fmtdev(&currdev),
 			uboot_setcurrdev, env_nounset);
@@ -174,8 +221,8 @@
 command_reboot(int argc, char *argv[])
 {
 	printf("Resetting...\n");
-	ub_eth_halt();
-	ub_do_reset();
+	ub_reset();
 
-	panic("Reset failed!");
+	printf("Reset failed!\n");
+	while(1);
 }

==== //depot/projects/e500/sys/boot/uboot/lib/Makefile#3 (text+ko) ====

@@ -1,11 +1,9 @@
-# $FreeBSD: src/sys/boot/ofw/libofw/Makefile,v 1.9 2004/10/24 15:32:50 ru Exp $
 
 LIB=		uboot
 INTERNALLIB=
 
 SRCS=	devicename.c elf_freebsd.c console.c copy.c disk.c \
-	module.c net.c reboot.c \
-	time.c
+	module.c net.c reboot.c time.c glue.c
 
 CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
 
@@ -13,15 +11,16 @@
 CFLAGS+=	-I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
 
 CFLAGS+=	-ffreestanding
+
 .if ${MACHINE_ARCH} == "powerpc"
 #
 # Important notice: registers dedicated for U-Boot must NOT be used by the
 # loader code, as we are going to jump between loader(8) and U-Boot code back
-# and forth safely. For PowerPC these are r2, r14 and r29, but always make
+# and forth safely. For PowerPC these are r14 and r29, but always make
 # sure in the U-Boot cpu/{CPU}/config.mk, e.g. cpu/mpc85xx/config.mk
 #
 # FIXME this should be integrated with the whole system build settings
-CFLAGS+=	-msoft-float -Wa,-me500 -ffixed-r2 -ffixed-r14 -ffixed-r29
+CFLAGS+=	-msoft-float -Wa,-me500 -ffixed-r14 -ffixed-r29
 .endif
 
 .ifdef(BOOT_DISK_DEBUG)
@@ -32,16 +31,8 @@
 machine:
 	ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine
 
-defs:
-	sh ${.CURDIR}/../../${MACHINE_ARCH}/uboot/defs.sh \
-	    ${.CURDIR}/../../${MACHINE_ARCH}/uboot > u-boot_defs.h
-
-calls:
-	sh ${.CURDIR}/../common/calls.sh \
-	    ${.CURDIR}/../gnu/_exports.h > u-boot_calls.h
-
-CLEANFILES+=	machine u-boot_defs.h u-boot_calls.h
+CLEANFILES+=	machine
 
 .include <bsd.lib.mk>
 
-beforedepend ${OBJS}: machine defs calls
+beforedepend ${OBJS}: machine

==== //depot/projects/e500/sys/boot/uboot/lib/console.c#2 (text+ko) ====

@@ -24,15 +24,16 @@
  * SUCH DAMAGE.
  */
 
+#include <stand.h>
 #include "bootstrap.h"
 
 int console;
 
 static void uboot_cons_probe(struct console *cp);
 static int uboot_cons_init(int);
-void uboot_cons_putchar(int);
-int uboot_cons_getchar(void);
-int uboot_cons_poll(void);
+static void uboot_cons_putchar(int);
+static int uboot_cons_getchar(void);
+static int uboot_cons_poll(void);
 
 struct console uboot_console = {
 	"uboot",
@@ -57,7 +58,7 @@
 	return 0;
 }
 
-void
+static void
 uboot_cons_putchar(int c)
 {
 	if (c == '\n')
@@ -66,13 +67,13 @@
 	ub_putc(c);
 }
 
-int
+static int
 uboot_cons_getchar()
 {
 	return (ub_getc());
 }
 
-int
+static int
 uboot_cons_poll()
 {
 	return (ub_tstc());

==== //depot/projects/e500/sys/boot/uboot/lib/devicename.c#2 (text+ko) ====

@@ -143,7 +143,7 @@
 	    goto fail;
 	}
 
-	idev->d_kind.disk.unit = unit;
+	idev->d_unit = unit;
 	idev->d_kind.disk.slice = slice;
 	idev->d_kind.disk.partition = partition;
 	if (path != NULL)
@@ -166,7 +166,7 @@
 	}
 
 	if (dv->dv_type == DEVT_NET)
-	    idev->d_kind.netif.unit = unit;
+	    idev->d_unit = unit;
 
 	if (path != NULL)
 	    *path = (*cp == 0) ? cp : cp + 1;
@@ -205,7 +205,7 @@
 
     case DEVT_DISK:
 	cp = buf;
-	cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.disk.unit);
+	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)
@@ -214,7 +214,7 @@
 	break;
 
     case DEVT_NET:
-	sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit);
+	sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
 	break;
     }
     return(buf);

==== //depot/projects/e500/sys/boot/uboot/lib/libuboot.h#2 (text+ko) ====

@@ -34,20 +34,15 @@
 {
     struct devsw	*d_dev;
     int			d_type;
+    int			d_unit;
     union 
     {
 	struct 
 	{
-	    int		unit;
+	    void	*data;
 	    int		slice;
 	    int		partition;
-	    void	*data;
 	} disk;
-
-	struct 
-	{
-	    int		unit;
-	} netif;
     } d_kind;
 };
 

==== //depot/projects/e500/sys/boot/uboot/lib/net.c#2 (text+ko) ====

@@ -42,13 +42,14 @@
 #include <net.h>
 #include <netif.h>
 
+#include "api_public.h"
 #include "libuboot.h"
-#include "u-boot_defs.h"
 
+#define NETIF_DEBUG
+#define NETIF_VERBOSE_DEBUG
 #undef NETIF_DEBUG
 #undef NETIF_VERBOSE_DEBUG
 
-extern gd_t	*uboot_global_data;
 
 static int	net_probe(struct netif *, void *);
 static int	net_match(struct netif *, void *);
@@ -57,6 +58,9 @@
 static int	net_put(struct iodesc *, void *, size_t);
 static void	net_end(struct netif *);
 
+struct device_info * ub_dev_get(int i);
+
+extern int			devs_no;
 extern struct netif_stats	net_stats[];
 
 struct netif_dif net_ifs[] = {
@@ -83,6 +87,7 @@
 	u_int8_t	sc_rxbuf[ETHER_MAX_LEN];
 	u_int8_t	sc_txbuf[ETHER_MAX_LEN + PKTALIGN];
 	u_int8_t	*sc_txbufp;
+	int		sc_handle;	/* device handle for ub_dev_xxx */
 };
 
 static struct uboot_softc uboot_softc;
@@ -102,6 +107,24 @@
 static int
 net_probe(struct netif *nif, void *machdep_hint)
 {
+	int			i;
+	struct device_info	*di;
+
+	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");
+		return -1;
+	}
+
+#if defined(NETIF_DEBUG)
+	printf("net_probe: network device found: %d\n", i);
+#endif
+	uboot_softc.sc_handle = i;
+	
 	return 0;
 }
 
@@ -131,10 +154,10 @@
 
 	memcpy(sc->sc_txbufp, pkt, len);
 
-	rv = ub_eth_send(sc->sc_txbufp, sendlen);
+	rv = ub_dev_send(sc->sc_handle, sc->sc_txbufp, sendlen);
 
 #if defined(NETIF_DEBUG)
-	printf("net_put: eth_send returned %d\n", rv);
+	printf("net_put: ub_send returned %d\n", rv);
 #endif
 	if (rv == 0)
 		rv = len;
@@ -160,7 +183,7 @@
 
 	t = getsecs();
 	do {
-		length = ub_eth_receive(sc->sc_rxbuf, len);
+		length = ub_dev_recv(sc->sc_handle, sc->sc_rxbuf, len);
 	} while ((length == -1 || length == 0) &&
 		(getsecs() - t < timeout));
 
@@ -185,13 +208,20 @@
 static void
 net_init(struct iodesc *desc, void *machdep_hint)
 {
-	int			i;
-	bd_t			*bd = uboot_global_data->bd;
+	int			i, err;
 	struct netif		*nif = desc->io_netif;
 	struct uboot_softc	*sc;
+	struct device_info	*di;
+	
+	sc = nif->nif_devdata = &uboot_softc;
 
+	if (err = ub_dev_open(sc->sc_handle))
+		panic("%s%d: initialisation failed with error %d\n",
+			nif->nif_driver->netif_bname, nif->nif_unit, err);
+
 	/* Get MAC address */
-	memcpy(desc->myea, bd->bi_enetaddr, 6);
+	di = ub_dev_get(sc->sc_handle);
+	memcpy(desc->myea, di->di_net.hwaddr, 6);
 	if (memcmp (desc->myea, "\0\0\0\0\0\0", 6) == 0) {
 		panic("%s%d: empty ethernet address!",
 			nif->nif_driver->netif_bname, nif->nif_unit);
@@ -202,21 +232,21 @@
 		nif->nif_unit, ether_sprintf(desc->myea));
 #endif
 
-	sc = nif->nif_devdata = &uboot_softc;
-	
 	/* 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;
+}
 
-	if (!ub_eth_init(bd))
-		panic("%s%d: initialisation failed.\n",
-			nif->nif_driver->netif_bname, nif->nif_unit);
-}
 
 static void
 net_end(struct netif *nif)
 {
-	ub_eth_halt();
+	int			err;
+	struct uboot_softc	*sc = nif->nif_devdata;
+
+	if (err = ub_dev_close(sc->sc_handle))
+		panic("%s%d: net_end failed with error %d\n",
+			nif->nif_driver->netif_bname, nif->nif_unit, err);
 }

==== //depot/projects/e500/sys/boot/uboot/lib/reboot.c#2 (text+ko) ====

@@ -27,5 +27,5 @@
 void
 exit(int code)
 {
-	ub_do_reset();
+	ub_reset();
 }

==== //depot/projects/e500/sys/boot/uboot/lib/time.c#2 (text+ko) ====

@@ -30,12 +30,15 @@
 
 #include <stand.h>
 
+/*
+ * Return the time in seconds since the beginning of the day.
+ */
 time_t
 time(time_t *tloc)
 {
 	int secs;
 
-	secs = ub_get_timer() / 1000;
+	secs = ub_get_timer(0) / 1000;
 	if (tloc)
 		*tloc = secs;
 
@@ -45,10 +48,7 @@
 int
 getsecs()
 {
-	time_t	n = 0;
-
-	time(&n);
-	return n;
+	return (time(NULL));
 }
 
 /*

==== //depot/projects/e500/sys/powerpc/include/bootinfo.h#3 (text+ko) ====

@@ -37,10 +37,7 @@
 	vm_offset_t	bar_base;
 	u_int32_t	cpu_clk;
 	u_int32_t	bus_clk;
-	u_int32_t	baudrate;
 	u_int8_t	eth0_addr[6];
-	u_int8_t	eth1_addr[6];
-	u_int16_t	eth_speed;
 };
 
 extern struct bootinfo *bootinfo;


More information about the p4-projects mailing list