This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
RedBoot - validated ethernet station addresses
- From: Gary Thomas <gary at mlbassoc dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 02 Oct 2003 14:15:08 -0600
- Subject: RedBoot - validated ethernet station addresses
- Organization: MLB Associates
Allow platforms to validate ESA as stored in 'fconfig'. Also,
some platform (MOAB) changes to actually make use of this.
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: devs/eth/ns/dp83816/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/ns/dp83816/current/ChangeLog,v
retrieving revision 1.1
diff -u -5 -p -r1.1 ChangeLog
--- devs/eth/ns/dp83816/current/ChangeLog 30 Sep 2003 15:25:31 -0000 1.1
+++ devs/eth/ns/dp83816/current/ChangeLog 2 Oct 2003 20:05:53 -0000
@@ -1,5 +1,10 @@
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * src/dp83816.h: Let default ESA be a pointer, so platforms can more
+ easily set it a runtime.
+
2003-09-30 Gary Thomas <gary@mlbassoc.com>
* src/if_dp83816.c:
* src/dp83816.h:
* cdl/ns_dp83816_eth_drivers.cdl: New package - ethernet driver for
Index: devs/eth/ns/dp83816/current/src/dp83816.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/ns/dp83816/current/src/dp83816.h,v
retrieving revision 1.1
diff -u -5 -p -r1.1 dp83816.h
--- devs/eth/ns/dp83816/current/src/dp83816.h 30 Sep 2003 15:25:31 -0000 1.1
+++ devs/eth/ns/dp83816/current/src/dp83816.h 2 Oct 2003 19:46:56 -0000
@@ -84,11 +84,11 @@ typedef struct dp83816_bd {
// ------------------------------------------------------------------------
// Private driver structure
typedef struct dp83816_priv_data {
char *esa_key; // RedBoot 'key' for device ESA
- unsigned char enaddr[6];
+ unsigned char *enaddr;
int rxnum; // Number of Rx buffers
unsigned char *rxbuf; // Rx buffer space
dp83816_bd_t *rxd; // Rx descriptor pool
int txnum; // Number of Tx buffers
unsigned char *txbuf; // Tx buffer space
Index: devs/eth/powerpc/moab/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/moab/current/ChangeLog,v
retrieving revision 1.3
diff -u -5 -p -r1.3 ChangeLog
--- devs/eth/powerpc/moab/current/ChangeLog 30 Sep 2003 17:50:55 -0000 1.3
+++ devs/eth/powerpc/moab/current/ChangeLog 2 Oct 2003 20:06:42 -0000
@@ -1,5 +1,11 @@
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * include/moab_eth_dp83816.inl:
+ * include/moab_eth.inl: Default ethernet station addresses are now
+ computed by system startup, based on CPU serial number.
+
2003-09-30 Gary Thomas <gary@mlbassoc.com>
* include/moab_eth_dp83816.inl:
* include/moab_eth.inl: Change device names used by RedBoot to eth0/eth1
* include/moab_eth_dp83816.inl:
Index: devs/eth/powerpc/moab/current/include/moab_eth.inl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/moab/current/include/moab_eth.inl,v
retrieving revision 1.2
diff -u -5 -p -r1.2 moab_eth.inl
--- devs/eth/powerpc/moab/current/include/moab_eth.inl 30 Sep 2003 17:50:56 -0000 1.2
+++ devs/eth/powerpc/moab/current/include/moab_eth.inl 2 Oct 2003 19:52:16 -0000
@@ -68,14 +68,15 @@ ETH_PHY_REG_LEVEL_ACCESS_FUNS(eth0_phy,
static unsigned char ppc405_eth_rxbufs[RxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
static unsigned char ppc405_eth_txbufs[TxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
static mal_bd_t ppc405_eth_rxbd[CYGNUM_DEVS_ETH_POWERPC_PPC405_RxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
static mal_bd_t ppc405_eth_txbd[CYGNUM_DEVS_ETH_POWERPC_PPC405_TxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
+extern char _moab_eth0_ESA[];
static struct ppc405_eth_info ppc405_eth0_info = {
0, // Interrupt vector
"eth0_esa",
- { 0x08, 0x00, 0x3C, 0x28, 0x7A, 0xBA}, // Default ESA
+ _moab_eth0_ESA,
CYGNUM_DEVS_ETH_POWERPC_PPC405_RxNUM, // Number of Rx buffers
ppc405_eth_rxbufs, // Rx buffer space
ppc405_eth_rxbd, // Rx buffer headers
CYGNUM_DEVS_ETH_POWERPC_PPC405_TxNUM, // Number of Tx buffers
ppc405_eth_txbufs, // Tx buffer space
@@ -107,11 +108,11 @@ NETDEVTAB_ENTRY(ppc405_netdev,
#include <redboot.h>
#include <flash_config.h>
RedBoot_config_option("eth0 network hardware address [MAC]",
eth0_esa,
ALWAYS_ENABLED, true,
- CONFIG_ESA, &ppc405_eth0_info.enaddr
+ CONFIG_ESA, _moab_eth0_ESA
);
#endif // CYGSEM_REDBOOT_FLASH_CONFIG
#endif // CYGPKG_REDBOOT
#endif // CYGHWR_DEVS_ETH_POWERPC_MOAB_ETH0
Index: devs/eth/powerpc/moab/current/include/moab_eth_dp83816.inl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/moab/current/include/moab_eth_dp83816.inl,v
retrieving revision 1.3
diff -u -5 -p -r1.3 moab_eth_dp83816.inl
--- devs/eth/powerpc/moab/current/include/moab_eth_dp83816.inl 30 Sep 2003 21:10:11 -0000 1.3
+++ devs/eth/powerpc/moab/current/include/moab_eth_dp83816.inl 2 Oct 2003 19:52:17 -0000
@@ -106,13 +106,14 @@ _le2h(unsigned long val)
static unsigned char dp83816_eth_rxbufs[RxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
static unsigned char dp83816_eth_txbufs[TxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
static dp83816_bd_t dp83816_eth_rxbd[CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
static dp83816_bd_t dp83816_eth_txbd[CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
+extern char _moab_eth1_ESA[];
static dp83816_priv_data_t dp83816_eth1_priv_data = {
"eth1_esa",
- { 0x08, 0x00, 0x3C, 0x29, 0x7A, 0xBA}, // Default ESA
+ _moab_eth1_ESA,
CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM, // Number of Rx buffers
dp83816_eth_rxbufs, // Rx buffer space
dp83816_eth_rxbd, // Rx buffer headers
CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM, // Number of Tx buffers
dp83816_eth_txbufs, // Tx buffer space
@@ -143,11 +144,11 @@ NETDEVTAB_ENTRY(dp83816_netdev,
#include <redboot.h>
#include <flash_config.h>
RedBoot_config_option("eth1 network hardware address [MAC]",
eth1_esa,
ALWAYS_ENABLED, true,
- CONFIG_ESA, &dp83816_eth1_priv_data.enaddr
+ CONFIG_ESA, _moab_eth1_ESA
);
#endif // CYGSEM_REDBOOT_FLASH_CONFIG
#else
#ifndef CONFIG_ESA
#define CONFIG_ESA 6
Index: devs/eth/powerpc/ppc405/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/ppc405/current/ChangeLog,v
retrieving revision 1.1
diff -u -5 -p -r1.1 ChangeLog
--- devs/eth/powerpc/ppc405/current/ChangeLog 19 Sep 2003 17:11:20 -0000 1.1
+++ devs/eth/powerpc/ppc405/current/ChangeLog 2 Oct 2003 20:07:22 -0000
@@ -1,5 +1,10 @@
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * src/ppc405_enet.h: Let default ESA be a pointer so that platforms
+ may set/change it a runtime.
+
2003-09-19 Gary Thomas <gary@mlbassoc.com>
* src/ppc405_enet.h:
* src/if_ppc405.c:
* cdl/ppc405_eth_drivers.cdl: New package - generic ethernet driver
Index: devs/eth/powerpc/ppc405/current/src/ppc405_enet.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/ppc405/current/src/ppc405_enet.h,v
retrieving revision 1.1
diff -u -5 -p -r1.1 ppc405_enet.h
--- devs/eth/powerpc/ppc405/current/src/ppc405_enet.h 19 Sep 2003 17:11:21 -0000 1.1
+++ devs/eth/powerpc/ppc405/current/src/ppc405_enet.h 2 Oct 2003 19:46:13 -0000
@@ -336,11 +336,11 @@ typedef struct mal_bd {
//
struct ppc405_eth_info {
// These fields should be defined by the implementation
int int_vector;
char *esa_key; // RedBoot 'key' for device ESA
- unsigned char enaddr[6];
+ unsigned char *enaddr;
int rxnum; // Number of Rx buffers
unsigned char *rxbuf; // Rx buffer space
mal_bd_t *rxbd_table; // Rx buffer headers
int txnum; // Number of Tx buffers
unsigned char *txbuf; // Tx buffer space
Index: hal/powerpc/moab/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/moab/current/ChangeLog,v
retrieving revision 1.9
diff -u -5 -p -r1.9 ChangeLog
--- hal/powerpc/moab/current/ChangeLog 30 Sep 2003 17:51:04 -0000 1.9
+++ hal/powerpc/moab/current/ChangeLog 2 Oct 2003 20:08:09 -0000
@@ -1,5 +1,11 @@
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * src/hal_aux.c:
+ * cdl/hal_powerpc_moab.cdl: Add code to set and check ethernet station
+ addresses, based on CPU serial number. Force RedBoot to validate them.
+
2003-09-30 Gary Thomas <gary@mlbassoc.com>
* include/plf_io.h (CYGARC_VIRTUAL_ADDRESS): Added.
Scan all possible PCI slots.
Index: hal/powerpc/moab/current/cdl/hal_powerpc_moab.cdl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/moab/current/cdl/hal_powerpc_moab.cdl,v
retrieving revision 1.4
diff -u -5 -p -r1.4 hal_powerpc_moab.cdl
--- hal/powerpc/moab/current/cdl/hal_powerpc_moab.cdl 28 Sep 2003 11:23:16 -0000 1.4
+++ hal/powerpc/moab/current/cdl/hal_powerpc_moab.cdl 2 Oct 2003 19:11:39 -0000
@@ -78,10 +78,11 @@ cdl_package CYGPKG_HAL_POWERPC_MOAB {
((CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA == "EEPROM") &&
(CYGNUM_REDBOOT_FLASH_CONFIG_SIZE == CYGNUM_HAL_EEPROM_SIZE) &&
(CYGNUM_REDBOOT_FLASH_STRING_SIZE == 64) &&
(CYGNUM_REDBOOT_FLASH_SCRIPT_SIZE == 256)) }
requires { !CYGPKG_REDBOOT || CYGBLD_REDBOOT_MAX_MEM_SEGMENTS == 2 }
+ requires { !CYGPKG_REDBOOT || CYGSEM_REDBOOT_PLF_ESA_VALIDATE == 1 }
define_proc {
puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_powerpc_ppc40x.h>"
puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_powerpc_moab.h>"
puts $::cdl_system_header "#define CYGBLD_HAL_PLF_IO_H <cyg/hal/plf_io.h>"
Index: hal/powerpc/moab/current/src/hal_aux.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/moab/current/src/hal_aux.c,v
retrieving revision 1.1
diff -u -5 -p -r1.1 hal_aux.c
--- hal/powerpc/moab/current/src/hal_aux.c 19 Sep 2003 17:11:28 -0000 1.1
+++ hal/powerpc/moab/current/src/hal_aux.c 2 Oct 2003 20:04:51 -0000
@@ -84,13 +84,32 @@ CYGARC_MEMDESC_TABLE CYGBLD_ATTRIB_WEAK
CYGARC_MEMDESC_TABLE_END
};
//--------------------------------------------------------------------------
// Platform init code.
+
+// Board/CPU serial number
+cyg_uint32 _moab_serial_no[2];
+unsigned char _moab_eth0_ESA[] = { 0x00, 0x20, 0xCF, 0x01, 0x11, 0x11}; // Default ESA
+unsigned char _moab_eth1_ESA[] = { 0x00, 0x20, 0xCF, 0x81, 0x11, 0x11}; // Default ESA
+
void
hal_platform_init(void)
{
+
+ CYGARC_MFDCR(DCR_CPC0_ECID0, _moab_serial_no[0]);
+ CYGARC_MFDCR(DCR_CPC0_ECID1, _moab_serial_no[1]);
+ // Set default ethernet ESA
+ _moab_eth0_ESA[3] = ((_moab_serial_no[1] & 0x007F0000) >> 16) | 0x00;
+ _moab_eth0_ESA[4] = ((_moab_serial_no[1] & 0x0000FF00) >> 8);
+ _moab_eth0_ESA[5] = ((_moab_serial_no[1] & 0x000000FF) >> 0);
+ _moab_eth1_ESA[3] = ((_moab_serial_no[1] & 0x007F0000) >> 16) | 0x80;
+ _moab_eth1_ESA[4] = ((_moab_serial_no[1] & 0x0000FF00) >> 8);
+ _moab_eth1_ESA[5] = ((_moab_serial_no[1] & 0x000000FF) >> 0);
+#ifdef CYGPKG_REDBOOT
+ diag_printf("CPU serial number: %08x/%08x\n", _moab_serial_no[0], _moab_serial_no[1]);
+#endif
}
#ifdef CYGSEM_REDBOOT_PLF_STARTUP
void
cyg_plf_redboot_startup(void)
@@ -103,15 +122,28 @@ cyg_plf_redboot_startup(void)
script = "fi lo RedBoot;go\n";
script_timeout = 1;
}
}
#endif
+
+#ifdef CYGSEM_REDBOOT_PLF_ESA_VALIDATE
+//
+// Verify that the given ESA is valid for this platform
+//
+bool
+cyg_plf_redboot_esa_validate(unsigned char *val)
+{
+ return ((val[0] == 0x00) && (val[1] == 0x20) && (val[2] == 0xCF));
+}
+#endif
+
//
// Initialize serial ports - called during hal_if_init()
// Note: actual serial port support code is supported by the PPC405 variant layer
// Having this call here allows for additional platform specific additions
//
+externC void cyg_hal_var_serial_init(void);
void
cyg_hal_plf_comms_init(void)
{
static int initialized = 0;
@@ -136,12 +168,12 @@ _moab_reset(void)
// Memory map [segment] support for RedBoot
void
cyg_plf_memory_segment(int seg, unsigned char **start, unsigned char **end)
{
if (seg == 1) {
- *start = _MOAB_OCM;
- *end = _MOAB_OCM + 0x1000;
+ *start = (unsigned char *)_MOAB_OCM;
+ *end = (unsigned char *)_MOAB_OCM + 0x1000;
} else {
diag_printf("** Invalid memory segment #%d - ignored\n", seg);
*start = NO_MEMORY;
*end = NO_MEMORY;
}
@@ -181,11 +213,11 @@ read_eeprom(unsigned char *buf, int len)
page = 0xAF; page_addr = 0;
for (i = 0; i < len; i += size) {
addr[0] = page_addr >> 8; addr[1] = (page_addr & 0xFF);
size = (len - i);
if (size > 32) size = 32;
- if (!hal_ppc405_i2c_put_bytes(page, &addr, 2)) {
+ if (!hal_ppc405_i2c_put_bytes(page, addr, 2)) {
diag_printf("%s - Can't select address %x\n", __FUNCTION__, page);
return;
}
if (!hal_ppc405_i2c_get_bytes(page, &buf[i], size)) {
diag_printf("%s - Can't read bytes\n", __FUNCTION__);
@@ -201,12 +233,15 @@ read_eeprom(unsigned char *buf, int len)
}
void
write_eeprom(unsigned char *buf, int len)
{
- int i, j, page, page_addr, size, left;
+ int i, j, page, page_addr, size;
cyg_uint8 addr[32+2];
+#if CYGNUM_HAL_EEPROM_SIZE == 1024
+ int left;
+#endif
#if 0
diag_printf("EEPROM data - write\n");
diag_dump_buf(buf, len < 256 ? len : 256);
#endif
Index: hal/powerpc/ppc40x/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/ppc40x/current/ChangeLog,v
retrieving revision 1.10
diff -u -5 -p -r1.10 ChangeLog
--- hal/powerpc/ppc40x/current/ChangeLog 26 Sep 2003 10:39:39 -0000 1.10
+++ hal/powerpc/ppc40x/current/ChangeLog 2 Oct 2003 20:08:33 -0000
@@ -1,5 +1,9 @@
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * include/var_regs.h: Add CPU serial number registers (405 only)
+
2003-09-26 Gary Thomas <gary@mlbassoc.com>
* src/ppc405_pci.c: IRQ mapping now defined by platform.
2003-09-20 Gary Thomas <gary@mlbassoc.com>
Index: hal/powerpc/ppc40x/current/include/var_regs.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/ppc40x/current/include/var_regs.h,v
retrieving revision 1.6
diff -u -5 -p -r1.6 var_regs.h
--- hal/powerpc/ppc40x/current/include/var_regs.h 19 Sep 2003 17:11:29 -0000 1.6
+++ hal/powerpc/ppc40x/current/include/var_regs.h 2 Oct 2003 18:52:57 -0000
@@ -132,10 +132,12 @@
#define DCR_EBC0_CFGADDR 0x12
#define DCR_EBC0_CFGDATA 0x13
#define DCR_CPC0_CR0 0xB1
#define DCR_CPC0_CR1 0xB2
#define DCR_CPC0_ECR 0xAA
+#define DCR_CPC0_ECID0 0xA8 // 64 bit unique chip serial number
+#define DCR_CPC0_ECID1 0xA9 // 64 bit unique chip serial number
// External bus controller (indirect via EBC0_CFGADDR/EBC0_CFGDATA)
#define DCR_EBC0_B0CR 0x00
#define DCR_EBC0_B1CR 0x01
#define DCR_EBC0_B2CR 0x02
Index: redboot/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.143
diff -u -5 -p -r1.143 ChangeLog
--- redboot/current/ChangeLog 30 Sep 2003 21:17:43 -0000 1.143
+++ redboot/current/ChangeLog 2 Oct 2003 20:09:07 -0000
@@ -1,5 +1,11 @@
+2003-10-02 Gary Thomas <gary@mlbassoc.com>
+
+ * src/fconfig.c:
+ * cdl/redboot.cdl: Allow platforms to provide a function to validate
+ ethernet station addresses.
+
2003-09-30 Gary Thomas <gary@mlbassoc.com>
* src/fconfig.c (do_flash_config): Fix typo in error message.
2003-09-30 David Vrabel <dvrabel@arcom.com>
Index: redboot/current/cdl/redboot.cdl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.55
diff -u -5 -p -r1.55 redboot.cdl
--- redboot/current/cdl/redboot.cdl 22 Sep 2003 17:35:38 -0000 1.55
+++ redboot/current/cdl/redboot.cdl 2 Oct 2003 19:10:59 -0000
@@ -459,10 +459,21 @@ cdl_package CYGPKG_REDBOOT {
processing. This allows the platform to perform any special
setups before RedBoot actually starts running. Note: the entire
RedBoot environment will already be initialized at this point."
}
+ cdl_option CYGSEM_REDBOOT_PLF_ESA_VALIDATE {
+ display "Run a platform specific ESA validation function."
+ flavor bool
+ default_value 0
+ description "
+ If this option is enabled then RedBoot will execute a platform
+ specific function to validate an ethernet ESA. This would be
+ useful if the address must conform to standards set by the
+ hardware manufacturer, etc."
+ }
+
cdl_option CYGPKG_REDBOOT_MAX_CMD_LINE {
display "Maximum command line length"
flavor data
default_value 256
description "
Index: redboot/current/src/fconfig.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/fconfig.c,v
retrieving revision 1.4
diff -u -5 -p -r1.4 fconfig.c
--- redboot/current/src/fconfig.c 30 Sep 2003 21:17:44 -0000 1.4
+++ redboot/current/src/fconfig.c 2 Oct 2003 19:10:58 -0000
@@ -65,10 +65,14 @@
#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_EEPROM
externC void write_eeprom(void *buf, int len);
externC void read_eeprom(void *buf, int len);
#endif
+#ifdef CYGSEM_REDBOOT_PLF_ESA_VALIDATE
+externC bool cyg_plf_redboot_esa_validate(unsigned char *val);
+#endif
+
// Round a quantity up
#define _rup(n,s) ((((n)+(s-1))/s)*s)
#include <flash_config.h>
@@ -340,10 +344,16 @@ get_config(unsigned char *dp, char *titl
memcpy(val_ptr, &hold_esa_val, sizeof(enet_addr_t));
return CONFIG_BAD;
}
((unsigned char *)val_ptr)[esa_ptr] = esa_byte;
}
+#ifdef CYGSEM_REDBOOT_PLF_ESA_VALIDATE
+ if (!cyg_plf_redboot_esa_validate(val_ptr)) {
+ memcpy(val_ptr, &hold_esa_val, sizeof(enet_addr_t));
+ return CONFIG_BAD;
+ }
+#endif
return CONFIG_CHANGED;
break;
#if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
case CONFIG_NETPORT:
if (strlen(line) >= MAX_STRING_LENGTH || net_devindex(line) < 0) {