Sun May 16 11:27:50 2010 UTC ()
Make netboot generate a BTINFO_NET bootinfo node for the Synology sk(4) NIC.
It will pass the MAC address, which is read from Flash ROM, into the kernel.
The kernel creates a "mac-address" device-property, which is used by sk(4),
when given, before reading the MAC from its EEPROM.


(phx)
diff -r1.4 -r1.5 src/sys/arch/sandpoint/include/bootinfo.h
diff -r1.19 -r1.20 src/sys/arch/sandpoint/sandpoint/autoconf.c
diff -r1.13 -r1.14 src/sys/arch/sandpoint/stand/netboot/brdsetup.c
diff -r1.14 -r1.15 src/sys/arch/sandpoint/stand/netboot/globals.h
diff -r1.28 -r1.29 src/sys/arch/sandpoint/stand/netboot/main.c
diff -r1.2 -r1.3 src/sys/arch/sandpoint/stand/netboot/skg.c
diff -r1.66 -r1.67 src/sys/dev/pci/if_sk.c

cvs diff -r1.4 -r1.5 src/sys/arch/sandpoint/include/bootinfo.h (expand / switch to unified diff)

--- src/sys/arch/sandpoint/include/bootinfo.h 2007/10/17 19:56:56 1.4
+++ src/sys/arch/sandpoint/include/bootinfo.h 2010/05/16 11:27:49 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bootinfo.h,v 1.4 2007/10/17 19:56:56 garbled Exp $ */ 1/* $NetBSD: bootinfo.h,v 1.5 2010/05/16 11:27:49 phx Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 4 * Copyright (c) 1997
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -32,26 +32,27 @@ @@ -32,26 +32,27 @@
32#define BOOTINFO_MAGIC 0xb007babe 32#define BOOTINFO_MAGIC 0xb007babe
33 33
34struct btinfo_common { 34struct btinfo_common {
35 int next; /* offset of next item, or zero */ 35 int next; /* offset of next item, or zero */
36 int type; 36 int type;
37}; 37};
38 38
39#define BTINFO_MAGIC 1 39#define BTINFO_MAGIC 1
40#define BTINFO_MEMORY 2 40#define BTINFO_MEMORY 2
41#define BTINFO_CONSOLE 3 41#define BTINFO_CONSOLE 3
42#define BTINFO_CLOCK 4 42#define BTINFO_CLOCK 4
43#define BTINFO_BOOTPATH 5 43#define BTINFO_BOOTPATH 5
44#define BTINFO_ROOTDEVICE 6 44#define BTINFO_ROOTDEVICE 6
 45#define BTINFO_NET 7
45 46
46struct btinfo_magic { 47struct btinfo_magic {
47 struct btinfo_common common; 48 struct btinfo_common common;
48 unsigned magic; 49 unsigned magic;
49}; 50};
50 51
51struct btinfo_memory { 52struct btinfo_memory {
52 struct btinfo_common common; 53 struct btinfo_common common;
53 int memsize; 54 int memsize;
54}; 55};
55 56
56struct btinfo_console { 57struct btinfo_console {
57 struct btinfo_common common; 58 struct btinfo_common common;
@@ -66,20 +67,26 @@ struct btinfo_clock { @@ -66,20 +67,26 @@ struct btinfo_clock {
66}; 67};
67 68
68struct btinfo_bootpath { 69struct btinfo_bootpath {
69 struct btinfo_common common; 70 struct btinfo_common common;
70 char bootpath[80]; 71 char bootpath[80];
71}; 72};
72 73
73struct btinfo_rootdevice { 74struct btinfo_rootdevice {
74 struct btinfo_common common; 75 struct btinfo_common common;
75 char devname[16]; 76 char devname[16];
76 unsigned cookie; 77 unsigned cookie;
77}; 78};
78 79
 80struct btinfo_net {
 81 struct btinfo_common common;
 82 char devname[16];
 83 uint8_t mac_address[6];
 84};
 85
79#define BOOTINFO_MAXSIZE 4096 86#define BOOTINFO_MAXSIZE 4096
80 87
81#ifdef _KERNEL 88#ifdef _KERNEL
82void *lookup_bootinfo(int); 89void *lookup_bootinfo(int);
83#endif 90#endif
84 91
85#endif /* _MACHINE_BOOTINFO_H_ */ 92#endif /* _MACHINE_BOOTINFO_H_ */

cvs diff -r1.19 -r1.20 src/sys/arch/sandpoint/sandpoint/autoconf.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/sandpoint/autoconf.c 2009/03/18 10:22:35 1.19
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c 2010/05/16 11:27:49 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: autoconf.c,v 1.19 2009/03/18 10:22:35 cegger Exp $ */ 1/* $NetBSD: autoconf.c,v 1.20 2010/05/16 11:27:49 phx Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1990 The Regents of the University of California. 4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz. 8 * William Jolitz.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,88 +25,102 @@ @@ -25,88 +25,102 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)autoconf.c 7.1 (Berkeley) 5/9/91 34 * @(#)autoconf.c 7.1 (Berkeley) 5/9/91
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.19 2009/03/18 10:22:35 cegger Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.20 2010/05/16 11:27:49 phx Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/conf.h> 42#include <sys/conf.h>
43#include <sys/device.h> 43#include <sys/device.h>
 44
 45#include <dev/cons.h>
44#include <dev/pci/pcivar.h> 46#include <dev/pci/pcivar.h>
45 47
 48#include <net/if.h>
 49#include <net/if_ether.h>
 50
46#include <machine/bootinfo.h> 51#include <machine/bootinfo.h>
 52#include <machine/pio.h>
47 53
48static struct btinfo_rootdevice *bi_rdev; 54static struct btinfo_rootdevice *bi_rdev;
49static struct btinfo_bootpath *bi_path; 55static struct btinfo_bootpath *bi_path;
50 56static struct btinfo_net *bi_net;
51#include <dev/cons.h> 
52#include <machine/pio.h> 
53 
54 57
55/* 58/*
56 * Determine i/o configuration for a machine. 59 * Determine i/o configuration for a machine.
57 */ 60 */
58void 61void
59cpu_configure(void) 62cpu_configure(void)
60{ 63{
61 64
62 bi_rdev = lookup_bootinfo(BTINFO_ROOTDEVICE); 65 bi_rdev = lookup_bootinfo(BTINFO_ROOTDEVICE);
63 bi_path = lookup_bootinfo(BTINFO_BOOTPATH); 66 bi_path = lookup_bootinfo(BTINFO_BOOTPATH);
 67 bi_net = lookup_bootinfo(BTINFO_NET);
64 68
65 if (config_rootfound("mainbus", NULL) == NULL) 69 if (config_rootfound("mainbus", NULL) == NULL)
66 panic("configure: mainbus not configured"); 70 panic("configure: mainbus not configured");
67 71
68 genppc_cpu_configure(); 72 genppc_cpu_configure();
69} 73}
70 74
71char *booted_kernel; /* should be a genuine filename */ 75char *booted_kernel; /* should be a genuine filename */
72 76
73void 77void
74cpu_rootconf(void) 78cpu_rootconf(void)
75{ 79{
76 80
77 if (bi_path != NULL) 81 if (bi_path != NULL)
78 booted_kernel = bi_path->bootpath; 82 booted_kernel = bi_path->bootpath;
79 83
80 aprint_normal("boot device: %s\n", 84 aprint_normal("boot device: %s\n",
81 booted_device ? booted_device->dv_xname : "<unknown>"); 85 booted_device ? booted_device->dv_xname : "<unknown>");
82 setroot(booted_device, booted_partition); 86 setroot(booted_device, booted_partition);
83} 87}
84 88
85void 89void
86device_register(struct device *dev, void *aux) 90device_register(struct device *dev, void *aux)
87{ 91{
 92 struct pci_attach_args *pa;
88 93
89 if (bi_rdev == NULL) 94 if (dev->dv_class == DV_IFNET) {
90 return; /* no clue to determine */ 95 pa = aux;
91 96 if (bi_rdev != NULL && device_is_a(dev, bi_rdev->devname)
92 if (dev->dv_class == DV_IFNET 97 && bi_rdev->cookie == pa->pa_tag)
93 && device_is_a(dev, bi_rdev->devname)) { 
94 struct pci_attach_args *pa = aux; 
95 
96 if (bi_rdev->cookie == pa->pa_tag) 
97 booted_device = dev; 98 booted_device = dev;
 99 if (bi_net != NULL && device_is_a(dev, bi_net->devname)) {
 100 prop_data_t pd;
 101
 102 pd = prop_data_create_data_nocopy(bi_net->mac_address,
 103 ETHER_ADDR_LEN);
 104 KASSERT(pd != NULL);
 105 if (prop_dictionary_set(device_properties(dev),
 106 "mac-address", pd) == false)
 107 printf("WARNING: unable to set mac-addr "
 108 "property for %s\n", dev->dv_xname);
 109 prop_object_release(pd);
 110 bi_net = NULL; /* do it just once */
 111 }
98 } 112 }
99 if (dev->dv_class == DV_DISK 113 if (bi_rdev != NULL && dev->dv_class == DV_DISK
100 && device_is_a(dev, bi_rdev->devname)) { 114 && device_is_a(dev, bi_rdev->devname)) {
101 booted_device = dev; 115 booted_device = dev;
102 booted_partition = 0; 116 booted_partition = 0;
103 } 117 }
104} 118}
105 119
106#if 0 120#if 0
107void 121void
108findroot(void) 122findroot(void)
109{ 123{
110 int unit, part; 124 int unit, part;
111 device_t dv; 125 device_t dv;
112 const char *name; 126 const char *name;

cvs diff -r1.13 -r1.14 src/sys/arch/sandpoint/stand/netboot/Attic/brdsetup.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/netboot/Attic/brdsetup.c 2010/05/13 10:40:02 1.13
+++ src/sys/arch/sandpoint/stand/netboot/Attic/brdsetup.c 2010/05/16 11:27:49 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: brdsetup.c,v 1.13 2010/05/13 10:40:02 phx Exp $ */ 1/* $NetBSD: brdsetup.c,v 1.14 2010/05/16 11:27:49 phx Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -697,13 +697,87 @@ pcifixup(void) @@ -697,13 +697,87 @@ pcifixup(void)
697 697
698 usb = pcimaketag(0, 14, 1); 698 usb = pcimaketag(0, 14, 1);
699 val = pcicfgread(usb, 0x3c) & 0xffff0000; 699 val = pcicfgread(usb, 0x3c) & 0xffff0000;
700 val |= (('B' - '@') << 8) | 14; 700 val |= (('B' - '@') << 8) | 14;
701 pcicfgwrite(usb, 0x3c, val); 701 pcicfgwrite(usb, 0x3c, val);
702 702
703 usb = pcimaketag(0, 14, 2); 703 usb = pcimaketag(0, 14, 2);
704 val = pcicfgread(usb, 0x3c) & 0xffff0000; 704 val = pcicfgread(usb, 0x3c) & 0xffff0000;
705 val |= (('C' - '@') << 8) | 14; 705 val |= (('C' - '@') << 8) | 14;
706 pcicfgwrite(usb, 0x3c, val); 706 pcicfgwrite(usb, 0x3c, val);
707 break; 707 break;
708 } 708 }
709} 709}
 710
 711struct fis_dir_entry {
 712 char name[16];
 713 uint32_t startaddr;
 714 uint32_t loadaddr;
 715 uint32_t flashsize;
 716 uint32_t entryaddr;
 717 uint32_t filesize;
 718 char pad[256 - (16 + 5 * sizeof(uint32_t))];
 719};
 720
 721#define FIS_LOWER_LIMIT 0xfff00000
 722
 723/*
 724 * Look for a Redboot-style Flash Image System FIS-directory and
 725 * return a pointer to the start address of the requested file.
 726 */
 727static void *
 728redboot_fis_lookup(const char *filename)
 729{
 730 static const char FISdirname[16] = {
 731 'F', 'I', 'S', ' ',
 732 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', 0, 0, 0
 733 };
 734 struct fis_dir_entry *dir;
 735
 736 /*
 737 * The FIS directory is usually in the last sector of the flash.
 738 * But we do not know the sector size (erase size), so start
 739 * at 0xffffff00 and scan backwards in steps of the FIS directory
 740 * entry size (0x100).
 741 */
 742 for (dir = (struct fis_dir_entry *)0xffffff00;
 743 (uint32_t)dir >= FIS_LOWER_LIMIT; dir--)
 744 if (memcmp(dir->name, FISdirname, sizeof(FISdirname)) == 0)
 745 break;
 746 if ((uint32_t)dir < FIS_LOWER_LIMIT) {
 747 printf("No FIS directory found!\n");
 748 return NULL;
 749 }
 750
 751 /* Now find filename by scanning the directory from beginning. */
 752 dir = (struct fis_dir_entry *)dir->startaddr;
 753 while (dir->name[0] != 0xff && (uint32_t)dir < 0xffffff00) {
 754 if (strcmp(dir->name, filename) == 0)
 755 return (void *)dir->startaddr; /* found */
 756 dir++;
 757 }
 758 printf("\"%s\" not found in FIS directory!\n", filename);
 759 return NULL;
 760}
 761
 762/*
 763 * For cost saving reasons some NAS boxes are missing the ROM for the
 764 * NIC's ethernet address and keep it in their Flash memory.
 765 */
 766void
 767read_mac_from_flash(uint8_t *mac)
 768{
 769 uint8_t *p;
 770
 771 if (brdtype == BRD_SYNOLOGY) {
 772 p = redboot_fis_lookup("vendor");
 773 if (p != NULL) {
 774 memcpy(mac, p, 6);
 775 return;
 776 }
 777 } else
 778 printf("Warning: This board has no known method defined "
 779 "to determine its MAC address!\n");
 780
 781 /* set to 00:00:00:00:00:00 in case of error */
 782 memset(mac, 0, 6);
 783}

cvs diff -r1.14 -r1.15 src/sys/arch/sandpoint/stand/netboot/Attic/globals.h (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/netboot/Attic/globals.h 2010/05/08 19:41:07 1.14
+++ src/sys/arch/sandpoint/stand/netboot/Attic/globals.h 2010/05/16 11:27:49 1.15
@@ -1,38 +1,39 @@ @@ -1,38 +1,39 @@
1/* $NetBSD: globals.h,v 1.14 2010/05/08 19:41:07 phx Exp $ */ 1/* $NetBSD: globals.h,v 1.15 2010/05/16 11:27:49 phx Exp $ */
2 2
3/* clock feed */ 3/* clock feed */
4#ifndef EXT_CLK_FREQ 4#ifndef EXT_CLK_FREQ
5#define EXT_CLK_FREQ 33333333 /* external clock (PCI clock) */ 5#define EXT_CLK_FREQ 33333333 /* external clock (PCI clock) */
6#endif 6#endif
7 7
8/* brd type */ 8/* brd type */
9extern int brdtype; 9extern int brdtype;
10#define BRD_SANDPOINTX2 2 10#define BRD_SANDPOINTX2 2
11#define BRD_SANDPOINTX3 3 11#define BRD_SANDPOINTX3 3
12#define BRD_ENCOREPP1 10 12#define BRD_ENCOREPP1 10
13#define BRD_KUROBOX 100 13#define BRD_KUROBOX 100
14#define BRD_QNAPTS101 101 14#define BRD_QNAPTS101 101
15#define BRD_SYNOLOGY 102 15#define BRD_SYNOLOGY 102
16#define BRD_STORCENTER 103 16#define BRD_STORCENTER 103
17#define BRD_UNKNOWN -1 17#define BRD_UNKNOWN -1
18 18
19extern char *consname; 19extern char *consname;
20extern int consport; 20extern int consport;
21extern int consspeed; 21extern int consspeed;
22extern int ticks_per_sec; 22extern int ticks_per_sec;
23extern uint32_t cpuclock, busclock; 23extern uint32_t cpuclock, busclock;
24 24
25unsigned mpc107memsize(void); 25unsigned mpc107memsize(void);
 26void read_mac_from_flash(uint8_t *);
26 27
27/* PPC processor ctl */ 28/* PPC processor ctl */
28void __syncicache(void *, size_t); 29void __syncicache(void *, size_t);
29 30
30/* byte swap access */ 31/* byte swap access */
31void out16rb(unsigned, unsigned); 32void out16rb(unsigned, unsigned);
32void out32rb(unsigned, unsigned); 33void out32rb(unsigned, unsigned);
33unsigned in16rb(unsigned); 34unsigned in16rb(unsigned);
34unsigned in32rb(unsigned); 35unsigned in32rb(unsigned);
35void iohtole16(unsigned, unsigned); 36void iohtole16(unsigned, unsigned);
36void iohtole32(unsigned, unsigned); 37void iohtole32(unsigned, unsigned);
37unsigned iole32toh(unsigned); 38unsigned iole32toh(unsigned);
38unsigned iole16toh(unsigned); 39unsigned iole16toh(unsigned);

cvs diff -r1.28 -r1.29 src/sys/arch/sandpoint/stand/netboot/Attic/main.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/netboot/Attic/main.c 2010/05/13 10:40:02 1.28
+++ src/sys/arch/sandpoint/stand/netboot/Attic/main.c 2010/05/16 11:27:49 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.28 2010/05/13 10:40:02 phx Exp $ */ 1/* $NetBSD: main.c,v 1.29 2010/05/16 11:27:49 phx Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -59,26 +59,27 @@ char *consname = CONSNAME; @@ -59,26 +59,27 @@ char *consname = CONSNAME;
59int consport = CONSPORT; 59int consport = CONSPORT;
60int consspeed = CONSSPEED; 60int consspeed = CONSSPEED;
61int ticks_per_sec; 61int ticks_per_sec;
62uint32_t busclock, cpuclock; 62uint32_t busclock, cpuclock;
63 63
64void 64void
65main(void) 65main(void)
66{ 66{
67 struct btinfo_memory bi_mem; 67 struct btinfo_memory bi_mem;
68 struct btinfo_console bi_cons; 68 struct btinfo_console bi_cons;
69 struct btinfo_clock bi_clk; 69 struct btinfo_clock bi_clk;
70 struct btinfo_bootpath bi_path; 70 struct btinfo_bootpath bi_path;
71 struct btinfo_rootdevice bi_rdev; 71 struct btinfo_rootdevice bi_rdev;
 72 struct btinfo_net bi_net;
72 unsigned long marks[MARK_MAX]; 73 unsigned long marks[MARK_MAX];
73 unsigned lata[1][2], lnif[1][2]; 74 unsigned lata[1][2], lnif[1][2];
74 unsigned memsize, tag; 75 unsigned memsize, tag;
75 int b, d, f, fd, howto, n; 76 int b, d, f, fd, howto, n;
76 77
77 /* determine SDRAM size */ 78 /* determine SDRAM size */
78 memsize = mpc107memsize(); 79 memsize = mpc107memsize();
79 80
80 printf("\n"); 81 printf("\n");
81 printf(">> NetBSD/sandpoint Boot, Revision %s\n", bootprog_rev); 82 printf(">> NetBSD/sandpoint Boot, Revision %s\n", bootprog_rev);
82 printf(">> (%s, %s)\n", bootprog_maker, bootprog_date); 83 printf(">> (%s, %s)\n", bootprog_maker, bootprog_date);
83 switch (brdtype) { 84 switch (brdtype) {
84 case BRD_SANDPOINTX3: 85 case BRD_SANDPOINTX3:
@@ -148,32 +149,39 @@ main(void) @@ -148,32 +149,39 @@ main(void)
148#endif 149#endif
149 150
150 bootinfo = (void *)0x4000; 151 bootinfo = (void *)0x4000;
151 bi_init(bootinfo); 152 bi_init(bootinfo);
152 153
153 bi_mem.memsize = memsize; 154 bi_mem.memsize = memsize;
154 snprintf(bi_cons.devname, sizeof(bi_cons.devname), consname); 155 snprintf(bi_cons.devname, sizeof(bi_cons.devname), consname);
155 bi_cons.addr = consport; 156 bi_cons.addr = consport;
156 bi_cons.speed = consspeed; 157 bi_cons.speed = consspeed;
157 bi_clk.ticks_per_sec = ticks_per_sec; 158 bi_clk.ticks_per_sec = ticks_per_sec;
158 snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), bootfile); 159 snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), bootfile);
159 snprintf(bi_rdev.devname, sizeof(bi_rdev.devname), rootdev); 160 snprintf(bi_rdev.devname, sizeof(bi_rdev.devname), rootdev);
160 bi_rdev.cookie = tag; /* PCI tag for fxp netboot case */ 161 bi_rdev.cookie = tag; /* PCI tag for fxp netboot case */
 162 if (brdtype == BRD_SYNOLOGY) {
 163 /* need to set MAC address for Marvell-SKnet */
 164 strcpy(bi_net.devname, "sk");
 165 memcpy(bi_net.mac_address, en, sizeof(en));
 166 }
161 167
162 bi_add(&bi_cons, BTINFO_CONSOLE, sizeof(bi_cons)); 168 bi_add(&bi_cons, BTINFO_CONSOLE, sizeof(bi_cons));
163 bi_add(&bi_mem, BTINFO_MEMORY, sizeof(bi_mem)); 169 bi_add(&bi_mem, BTINFO_MEMORY, sizeof(bi_mem));
164 bi_add(&bi_clk, BTINFO_CLOCK, sizeof(bi_clk)); 170 bi_add(&bi_clk, BTINFO_CLOCK, sizeof(bi_clk));
165 bi_add(&bi_path, BTINFO_BOOTPATH, sizeof(bi_path)); 171 bi_add(&bi_path, BTINFO_BOOTPATH, sizeof(bi_path));
166 bi_add(&bi_rdev, BTINFO_ROOTDEVICE, sizeof(bi_rdev)); 172 bi_add(&bi_rdev, BTINFO_ROOTDEVICE, sizeof(bi_rdev));
 173 if (brdtype == BRD_SYNOLOGY)
 174 bi_add(&bi_net, BTINFO_NET, sizeof(bi_net));
167 175
168 printf("entry=%p, ssym=%p, esym=%p\n", 176 printf("entry=%p, ssym=%p, esym=%p\n",
169 (void *)marks[MARK_ENTRY], 177 (void *)marks[MARK_ENTRY],
170 (void *)marks[MARK_SYM], 178 (void *)marks[MARK_SYM],
171 (void *)marks[MARK_END]); 179 (void *)marks[MARK_END]);
172 180
173 __syncicache((void *)marks[MARK_ENTRY], 181 __syncicache((void *)marks[MARK_ENTRY],
174 (u_int)marks[MARK_SYM] - (u_int)marks[MARK_ENTRY]); 182 (u_int)marks[MARK_SYM] - (u_int)marks[MARK_ENTRY]);
175 183
176 run((void *)marks[MARK_SYM], (void *)marks[MARK_END], 184 run((void *)marks[MARK_SYM], (void *)marks[MARK_END],
177 (void *)howto, bootinfo, (void *)marks[MARK_ENTRY]); 185 (void *)howto, bootinfo, (void *)marks[MARK_ENTRY]);
178 186
179 /* should never come here */ 187 /* should never come here */

cvs diff -r1.2 -r1.3 src/sys/arch/sandpoint/stand/netboot/Attic/skg.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/netboot/Attic/skg.c 2010/05/03 18:55:09 1.2
+++ src/sys/arch/sandpoint/stand/netboot/Attic/skg.c 2010/05/16 11:27:49 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: skg.c,v 1.2 2010/05/03 18:55:09 phx Exp $ */ 1/* $NetBSD: skg.c,v 1.3 2010/05/16 11:27:49 phx Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Frank Wille. 4 * Copyright (c) 2010 Frank Wille.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Frank Wille for The NetBSD Project. 7 * Written by Frank Wille for The NetBSD Project.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -217,45 +217,40 @@ skg_init(unsigned tag, void *data) @@ -217,45 +217,40 @@ skg_init(unsigned tag, void *data)
217 CSR_WRITE_2(l, SK_CSR, CSR_MASTER_RESET); 217 CSR_WRITE_2(l, SK_CSR, CSR_MASTER_RESET);
218 CSR_WRITE_2(l, SK_LINK_CTRL, LINK_RESET_SET); 218 CSR_WRITE_2(l, SK_LINK_CTRL, LINK_RESET_SET);
219 DELAY(1000); 219 DELAY(1000);
220 CSR_WRITE_2(l, SK_CSR, CSR_SW_UNRESET); 220 CSR_WRITE_2(l, SK_CSR, CSR_SW_UNRESET);
221 DELAY(2); 221 DELAY(2);
222 CSR_WRITE_2(l, SK_CSR, CSR_MASTER_UNRESET); 222 CSR_WRITE_2(l, SK_CSR, CSR_MASTER_UNRESET);
223 CSR_WRITE_2(l, SK_LINK_CTRL, LINK_RESET_CLEAR); 223 CSR_WRITE_2(l, SK_LINK_CTRL, LINK_RESET_CLEAR);
224 CSR_WRITE_4(l, SK_RAMCTL, 2); /* enable RAM interface */ 224 CSR_WRITE_4(l, SK_RAMCTL, 2); /* enable RAM interface */
225 225
226 mii_initphy(l); 226 mii_initphy(l);
227 227
228 /* read ethernet address */ 228 /* read ethernet address */
229 en = data; 229 en = data;
230 for (i = 0; i < 6; i++) 230 if (brdtype == BRD_SYNOLOGY)
231 en[i] = CSR_READ_1(l, SK_MAC0 + i); 231 read_mac_from_flash(en);
 232 else
 233 for (i = 0; i < 6; i++)
 234 en[i] = CSR_READ_1(l, SK_MAC0 + i);
232 printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", 235 printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
233 en[0], en[1], en[2], en[3], en[4], en[5]); 236 en[0], en[1], en[2], en[3], en[4], en[5]);
234 printf("PHY %d (%04x.%04x)\n", l->phy, 237 printf("PHY %d (%04x.%04x)\n", l->phy,
235 mii_read(l, l->phy, 2), mii_read(l, l->phy, 3)); 238 mii_read(l, l->phy, 2), mii_read(l, l->phy, 3));
236 239
237 /* set station address */ 240 /* set station address */
238 for (i = 0; i < 3; i++) { 241 for (i = 0; i < 3; i++)
239#if 0 
240 CSR_WRITE_2(l, YUKON_SA1 + i * 4, 
241 CSR_READ_2(l, SK_MAC0 + i * 2)); 
242 CSR_WRITE_2(l, YUKON_SA2 + i * 4, 
243 CSR_READ_2(l, SK_MAC1 + i * 2)); 
244#else 
245 CSR_WRITE_2(l, YUKON_SA1 + i * 4, 242 CSR_WRITE_2(l, YUKON_SA1 + i * 4,
246 (en[i * 2] << 8) | en[i * 2 + 1]); 243 (en[i * 2] << 8) | en[i * 2 + 1]);
247#endif 
248 } 
249 244
250 /* configure RX and TX MAC FIFO */ 245 /* configure RX and TX MAC FIFO */
251 CSR_WRITE_1(l, SK_RXMF1_CTRL_TEST, RFCTL_RESET_CLEAR); 246 CSR_WRITE_1(l, SK_RXMF1_CTRL_TEST, RFCTL_RESET_CLEAR);
252 CSR_WRITE_4(l, SK_RXMF1_CTRL_TEST, RFCTL_OPERATION_ON); 247 CSR_WRITE_4(l, SK_RXMF1_CTRL_TEST, RFCTL_OPERATION_ON);
253 CSR_WRITE_1(l, SK_TXMF1_CTRL_TEST, TFCTL_RESET_CLEAR); 248 CSR_WRITE_1(l, SK_TXMF1_CTRL_TEST, TFCTL_RESET_CLEAR);
254 CSR_WRITE_4(l, SK_TXMF1_CTRL_TEST, TFCTL_OPERATION_ON); 249 CSR_WRITE_4(l, SK_TXMF1_CTRL_TEST, TFCTL_OPERATION_ON);
255 250
256 mii_dealan(l, 5); 251 mii_dealan(l, 5);
257 252
258 switch (PSSR_SPEED(l->pssr)) { 253 switch (PSSR_SPEED(l->pssr)) {
259 case SPEED1000: 254 case SPEED1000:
260 printf("1000Mbps"); 255 printf("1000Mbps");
261 break; 256 break;

cvs diff -r1.66 -r1.67 src/sys/dev/pci/if_sk.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_sk.c 2010/04/05 07:20:27 1.66
+++ src/sys/dev/pci/if_sk.c 2010/05/16 11:27:49 1.67
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_sk.c,v 1.66 2010/04/05 07:20:27 joerg Exp $ */ 1/* $NetBSD: if_sk.c,v 1.67 2010/05/16 11:27:49 phx Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -105,27 +105,27 @@ @@ -105,27 +105,27 @@
105 * interface with DMA support. Each card may have between 512K and 105 * interface with DMA support. Each card may have between 512K and
106 * 2MB of SRAM on board depending on the configuration. 106 * 2MB of SRAM on board depending on the configuration.
107 * 107 *
108 * The SysKonnect GEnesis controller can have either one or two XMAC 108 * The SysKonnect GEnesis controller can have either one or two XMAC
109 * chips connected to it, allowing single or dual port NIC configurations. 109 * chips connected to it, allowing single or dual port NIC configurations.
110 * SysKonnect has the distinction of being the only vendor on the market 110 * SysKonnect has the distinction of being the only vendor on the market
111 * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs, 111 * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs,
112 * dual DMA queues, packet/MAC/transmit arbiters and direct access to the 112 * dual DMA queues, packet/MAC/transmit arbiters and direct access to the
113 * XMAC registers. This driver takes advantage of these features to allow 113 * XMAC registers. This driver takes advantage of these features to allow
114 * both XMACs to operate as independent interfaces. 114 * both XMACs to operate as independent interfaces.
115 */ 115 */
116 116
117#include <sys/cdefs.h> 117#include <sys/cdefs.h>
118__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.66 2010/04/05 07:20:27 joerg Exp $"); 118__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.67 2010/05/16 11:27:49 phx Exp $");
119 119
120#include "rnd.h" 120#include "rnd.h"
121 121
122#include <sys/param.h> 122#include <sys/param.h>
123#include <sys/systm.h> 123#include <sys/systm.h>
124#include <sys/sockio.h> 124#include <sys/sockio.h>
125#include <sys/mbuf.h> 125#include <sys/mbuf.h>
126#include <sys/malloc.h> 126#include <sys/malloc.h>
127#include <sys/mutex.h> 127#include <sys/mutex.h>
128#include <sys/kernel.h> 128#include <sys/kernel.h>
129#include <sys/socket.h> 129#include <sys/socket.h>
130#include <sys/device.h> 130#include <sys/device.h>
131#include <sys/queue.h> 131#include <sys/queue.h>
@@ -1199,26 +1199,27 @@ sk_probe(device_t parent, cfdata_t match @@ -1199,26 +1199,27 @@ sk_probe(device_t parent, cfdata_t match
1199 * Each XMAC chip is attached as a separate logical IP interface. 1199 * Each XMAC chip is attached as a separate logical IP interface.
1200 * Single port cards will have only one logical interface of course. 1200 * Single port cards will have only one logical interface of course.
1201 */ 1201 */
1202void 1202void
1203sk_attach(device_t parent, device_t self, void *aux) 1203sk_attach(device_t parent, device_t self, void *aux)
1204{ 1204{
1205 struct sk_if_softc *sc_if = device_private(self); 1205 struct sk_if_softc *sc_if = device_private(self);
1206 struct sk_softc *sc = device_private(parent); 1206 struct sk_softc *sc = device_private(parent);
1207 struct skc_attach_args *sa = aux; 1207 struct skc_attach_args *sa = aux;
1208 struct sk_txmap_entry *entry; 1208 struct sk_txmap_entry *entry;
1209 struct ifnet *ifp; 1209 struct ifnet *ifp;
1210 bus_dma_segment_t seg; 1210 bus_dma_segment_t seg;
1211 bus_dmamap_t dmamap; 1211 bus_dmamap_t dmamap;
 1212 prop_data_t data;
1212 void *kva; 1213 void *kva;
1213 int i, rseg; 1214 int i, rseg;
1214 int mii_flags = 0; 1215 int mii_flags = 0;
1215 1216
1216 aprint_naive("\n"); 1217 aprint_naive("\n");
1217 1218
1218 sc_if->sk_dev = self; 1219 sc_if->sk_dev = self;
1219 sc_if->sk_port = sa->skc_port; 1220 sc_if->sk_port = sa->skc_port;
1220 sc_if->sk_softc = sc; 1221 sc_if->sk_softc = sc;
1221 sc->sk_if[sa->skc_port] = sc_if; 1222 sc->sk_if[sa->skc_port] = sc_if;
1222 1223
1223 if (sa->skc_port == SK_PORT_A) 1224 if (sa->skc_port == SK_PORT_A)
1224 sc_if->sk_tx_bmu = SK_BMU_TXS_CSR0; 1225 sc_if->sk_tx_bmu = SK_BMU_TXS_CSR0;
@@ -1226,30 +1227,40 @@ sk_attach(device_t parent, device_t self @@ -1226,30 +1227,40 @@ sk_attach(device_t parent, device_t self
1226 sc_if->sk_tx_bmu = SK_BMU_TXS_CSR1; 1227 sc_if->sk_tx_bmu = SK_BMU_TXS_CSR1;
1227 1228
1228 DPRINTFN(2, ("begin sk_attach: port=%d\n", sc_if->sk_port)); 1229 DPRINTFN(2, ("begin sk_attach: port=%d\n", sc_if->sk_port));
1229 1230
1230 /* 1231 /*
1231 * Get station address for this interface. Note that 1232 * Get station address for this interface. Note that
1232 * dual port cards actually come with three station 1233 * dual port cards actually come with three station
1233 * addresses: one for each port, plus an extra. The 1234 * addresses: one for each port, plus an extra. The
1234 * extra one is used by the SysKonnect driver software 1235 * extra one is used by the SysKonnect driver software
1235 * as a 'virtual' station address for when both ports 1236 * as a 'virtual' station address for when both ports
1236 * are operating in failover mode. Currently we don't 1237 * are operating in failover mode. Currently we don't
1237 * use this extra address. 1238 * use this extra address.
1238 */ 1239 */
1239 for (i = 0; i < ETHER_ADDR_LEN; i++) 1240 data = prop_dictionary_get(device_properties(self), "mac-address");
1240 sc_if->sk_enaddr[i] = 1241 if (data != NULL) {
1241 sk_win_read_1(sc, SK_MAC0_0 + (sa->skc_port * 8) + i); 1242 /*
1242 1243 * Try to get the station address from device properties
 1244 * first, in case the ROM is missing.
 1245 */
 1246 KASSERT(prop_object_type(data) == PROP_TYPE_DATA);
 1247 KASSERT(prop_data_size(data) == ETHER_ADDR_LEN);
 1248 memcpy(sc_if->sk_enaddr, prop_data_data_nocopy(data),
 1249 ETHER_ADDR_LEN);
 1250 } else
 1251 for (i = 0; i < ETHER_ADDR_LEN; i++)
 1252 sc_if->sk_enaddr[i] = sk_win_read_1(sc,
 1253 SK_MAC0_0 + (sa->skc_port * 8) + i);
1243 1254
1244 aprint_normal(": Ethernet address %s\n", 1255 aprint_normal(": Ethernet address %s\n",
1245 ether_sprintf(sc_if->sk_enaddr)); 1256 ether_sprintf(sc_if->sk_enaddr));
1246 1257
1247 /* 1258 /*
1248 * Set up RAM buffer addresses. The NIC will have a certain 1259 * Set up RAM buffer addresses. The NIC will have a certain
1249 * amount of SRAM on it, somewhere between 512K and 2MB. We 1260 * amount of SRAM on it, somewhere between 512K and 2MB. We
1250 * need to divide this up a) between the transmitter and 1261 * need to divide this up a) between the transmitter and
1251 * receiver and b) between the two XMACs, if this is a 1262 * receiver and b) between the two XMACs, if this is a
1252 * dual port NIC. Our algorithm is to divide up the memory 1263 * dual port NIC. Our algorithm is to divide up the memory
1253 * evenly so that everyone gets a fair share. 1264 * evenly so that everyone gets a fair share.
1254 */ 1265 */
1255 if (sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC) { 1266 if (sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC) {