Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/stand/boot2440 - add TFTP loading facility.



details:   https://anonhg.NetBSD.org/src/rev/37a9ee9f09d2
branches:  trunk
changeset: 773339:37a9ee9f09d2
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Tue Jan 31 11:04:17 2012 +0000

description:
- add TFTP loading facility.
- SD/MMC load default is now "ld0a:netbsd"

diffstat:

 sys/arch/evbarm/stand/boot2440/Makefile  |   4 ++--
 sys/arch/evbarm/stand/boot2440/dev_net.c |  24 +++++++++++++++++-------
 sys/arch/evbarm/stand/boot2440/devopen.c |  17 ++++++++++++++++-
 3 files changed, 35 insertions(+), 10 deletions(-)

diffs (137 lines):

diff -r 5be85dab2267 -r 37a9ee9f09d2 sys/arch/evbarm/stand/boot2440/Makefile
--- a/sys/arch/evbarm/stand/boot2440/Makefile   Tue Jan 31 09:53:44 2012 +0000
+++ b/sys/arch/evbarm/stand/boot2440/Makefile   Tue Jan 31 11:04:17 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.1 2012/01/30 03:28:34 nisimura Exp $
+#      $NetBSD: Makefile,v 1.2 2012/01/31 11:04:17 nisimura Exp $
 
 S=             ${.CURDIR}/../../../..
 PROG=          bootmini2440
@@ -11,7 +11,7 @@
 CFLAGS+=       -Wall -Wno-main -ffreestanding -march=armv4
 CPPFLAGS+=     -D_STANDALONE -DSUPPORT_DHCP 
 CPPFLAGS+=     -DDM9000MAC="0x08,0x08,0x11,0x18,0x12,0x27" 
-CPPFLAGS+=     -DDEFAULT_BOOTFILE="ld0e:netbsd;net:"
+CPPFLAGS+=     -DDEFAULT_BOOTFILE="ld0a:netbsd;net:"
 CPPFLAGS+=     -nostdinc -I. -I${.CURDIR} -I${.OBJDIR} -I${S} -I${S}/arch
 DBG=           
 
diff -r 5be85dab2267 -r 37a9ee9f09d2 sys/arch/evbarm/stand/boot2440/dev_net.c
--- a/sys/arch/evbarm/stand/boot2440/dev_net.c  Tue Jan 31 09:53:44 2012 +0000
+++ b/sys/arch/evbarm/stand/boot2440/dev_net.c  Tue Jan 31 11:04:17 2012 +0000
@@ -42,12 +42,16 @@
 extern int netif_open(void*);
 extern int netif_init(unsigned int tag);
 
+extern struct in_addr servip;
+
+static int netdev_sock = -1;
+
 int
 net_open(struct open_file *f, ...)
 {
        va_list ap;
-       char *path;
-       int sock, error = 0;
+       char *path, *proto;
+       int error = 0;
 
        if( netif_init(0) == 0 ) {
                error = ENODEV;
@@ -55,15 +59,16 @@
        }
 
        va_start(ap, f);
-
        path = va_arg(ap, char *);
-       if ((sock = netif_open(path)) < 0) {
+       proto = va_arg(ap, char *);
+       va_end(ap);
+       if ((netdev_sock = netif_open(path)) < 0) {
                error = errno;
                goto out;
        }
 
        /* send DHCP request */
-       bootp(sock);
+       bootp(netdev_sock);
 
        /* IP address was not found */
        if (myip.s_addr == 0) {
@@ -96,6 +101,9 @@
                        printf("Root path: %s\n", rootpath);
                        strcpy(bootfile, ++filename);
                        printf("Bootfile: %s\n", bootfile);
+               } else {
+                       /* No ':' found, assume it's just a filename */
+                       strcpy(bootfile, path);
                }
        }
 
@@ -103,12 +111,14 @@
        if (bootfile[0] == '\0')
                strcpy(bootfile, "netbsd");
 
-       if (nfs_mount(sock, rootip, rootpath) != 0) {
+       if (strcmp(proto, "nfs") == 0
+           && (nfs_mount(netdev_sock, rootip, rootpath) != 0)) {
                error = errno;
                goto out;
        }
+
+       f->f_devdata = &netdev_sock;
 out:
-       va_end(ap);
        return (error);
 }
 
diff -r 5be85dab2267 -r 37a9ee9f09d2 sys/arch/evbarm/stand/boot2440/devopen.c
--- a/sys/arch/evbarm/stand/boot2440/devopen.c  Tue Jan 31 09:53:44 2012 +0000
+++ b/sys/arch/evbarm/stand/boot2440/devopen.c  Tue Jan 31 11:04:17 2012 +0000
@@ -34,6 +34,7 @@
 #include <lib/libkern/libkern.h>
 #include <lib/libsa/stand.h>
 #include <lib/libsa/nfs.h>
+#include <lib/libsa/tftp.h>
 #include <lib/libsa/ext2fs.h>
 #include <lib/libsa/dosfs.h>
 #include <lib/libsa/ufs.h>
@@ -58,6 +59,7 @@
 };
 
 struct fs_ops ops_nfs = FS_OPS(nfs);
+struct fs_ops ops_tftp = FS_OPS(tftp);
 struct fs_ops ops_ext2fs = FS_OPS(ext2fs);
 struct fs_ops ops_dosfs = FS_OPS(dosfs);
 struct fs_ops ops_bsdfs = FS_OPS(ufs);
@@ -78,16 +80,29 @@
        if (strncmp("net:", name, 4) == 0 ||
            strncmp("nfs:", name, 4) == 0 ) {
                of->f_dev = &devsw[0];
-               if ((error = net_open(of, name+4)) != 0)
+               if ((error = net_open(of, name+4, "nfs")) != 0)
                        return error;
                file_system[0] = ops_nfs;
                *file = bootfile;
                strncpy(bi_path.bootpath, bootfile, sizeof(bi_path.bootpath));
 
                return 0;
+       } else if (strncmp("tftp:", name, 5) == 0) {
+               of->f_dev = &devsw[0];
+               if ((error = net_open(of, name+5, "tftp")) != 0) {
+                       return error;
+               }
+               file_system[0] = ops_tftp;
+               *file = bootfile;
+               strncpy(bi_path.bootpath, bootfile, sizeof(bi_path.bootpath));
+
+               return 0;
        } else if (name[0] == 'l' && name[1] == 'd') {
                int unit, part;
                parseunit(&name[2], &unit, &part, file);
+               if (*file == NULL || strlen(*file) == 0) {
+                       strcpy(*file, "netbsd");
+               }
                of->f_dev = &devsw[1];
                if ((error = sdmmc_open(of, unit, part)) != 0)
                        return error;



Home | Main Index | Thread Index | Old Index