提交 75b43dcd 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

e1000hwaddr: retrieve hardware address

上级 2cd67e63
...@@ -20,6 +20,8 @@ static struct { ...@@ -20,6 +20,8 @@ static struct {
u32 rxclean; u32 rxclean;
u32 rxuse; u32 rxuse;
u8 hwaddr[6];
struct wiseman_txdesc txd[TX_RING_SIZE] __attribute__((aligned (16))); struct wiseman_txdesc txd[TX_RING_SIZE] __attribute__((aligned (16)));
struct wiseman_rxdesc rxd[RX_RING_SIZE] __attribute__((aligned (16))); struct wiseman_rxdesc rxd[RX_RING_SIZE] __attribute__((aligned (16)));
} e1000; } e1000;
...@@ -183,6 +185,12 @@ e1000intr(void) ...@@ -183,6 +185,12 @@ e1000intr(void)
} }
} }
void
e1000hwaddr(u8 *hwaddr)
{
memmove(hwaddr, e1000.hwaddr, sizeof(e1000.hwaddr));
}
static static
void e1000reset(void) void e1000reset(void)
{ {
...@@ -239,8 +247,6 @@ void e1000reset(void) ...@@ -239,8 +247,6 @@ void e1000reset(void)
ewr(WMREG_IMS, ICR_TXDW | ICR_RXO | ICR_RXT0); ewr(WMREG_IMS, ICR_TXDW | ICR_RXO | ICR_RXT0);
} }
//#define E1000_WRITE_FLUSH() erd(WMREG_STATUS)
int int
e1000attach(struct pci_func *pcif) e1000attach(struct pci_func *pcif)
{ {
...@@ -259,14 +265,12 @@ e1000attach(struct pci_func *pcif) ...@@ -259,14 +265,12 @@ e1000attach(struct pci_func *pcif)
e1000reset(); e1000reset();
// Get the MAC address // Get the MAC address
u16 myaddr[3]; r = eeprom_read((u16*)e1000.hwaddr, EEPROM_OFF_MACADDR, 3);
r = eeprom_read(&myaddr[0], EEPROM_OFF_MACADDR, 3);
if (r < 0) if (r < 0)
return 0; return 0;
u8 *addr = (u8*) &myaddr[0];
cprintf("%x:%x:%x:%x:%x:%x\n", cprintf("%x:%x:%x:%x:%x:%x\n",
addr[0], addr[1], addr[2], e1000.hwaddr[0], e1000.hwaddr[1], e1000.hwaddr[2],
addr[3], addr[4], addr[5]); e1000.hwaddr[3], e1000.hwaddr[4], e1000.hwaddr[5]);
return 0; return 0;
} }
...@@ -85,6 +85,7 @@ void crange_print(struct crange *cr, int); ...@@ -85,6 +85,7 @@ void crange_print(struct crange *cr, int);
extern int e1000irq; extern int e1000irq;
void e1000intr(void); void e1000intr(void);
int e1000tx(void *buf, u32 len); int e1000tx(void *buf, u32 len);
void e1000hwaddr(u8 *hwaddr);
// exec.c // exec.c
int exec(char*, char**); int exec(char*, char**);
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论