Check if e1000 init happened before calling e1000*

上级 10285b77
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define RX_RING_SIZE 64 #define RX_RING_SIZE 64
int e1000irq; int e1000irq;
int e1000init;
static struct { static struct {
u32 membase; u32 membase;
...@@ -296,5 +297,6 @@ e1000attach(struct pci_func *pcif) ...@@ -296,5 +297,6 @@ e1000attach(struct pci_func *pcif)
for (i = 0; i < WMREG_MTA; i+=4) for (i = 0; i < WMREG_MTA; i+=4)
ewr(WMREG_CORDOVA_MTA+i, 0); ewr(WMREG_CORDOVA_MTA+i, 0);
e1000init = 1;
return 0; return 0;
} }
...@@ -76,6 +76,7 @@ void crange_print(struct crange *cr, int); ...@@ -76,6 +76,7 @@ void crange_print(struct crange *cr, int);
// e1000.c // e1000.c
extern int e1000irq; extern int e1000irq;
extern int e1000init;
void e1000intr(void); void e1000intr(void);
int e1000tx(void *buf, u32 len); int e1000tx(void *buf, u32 len);
void e1000hwaddr(u8 *hwaddr); void e1000hwaddr(u8 *hwaddr);
......
...@@ -37,12 +37,16 @@ netalloc(void) ...@@ -37,12 +37,16 @@ netalloc(void)
int int
nettx(void *va, u16 len) nettx(void *va, u16 len)
{ {
if (e1000init == 0)
return -1;
return e1000tx(va, len); return e1000tx(va, len);
} }
void void
nethwaddr(u8 *hwaddr) nethwaddr(u8 *hwaddr)
{ {
if (e1000init == 0)
return;
e1000hwaddr(hwaddr); e1000hwaddr(hwaddr);
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论