Skip to content

Commit e576fb7

Browse files
add support for a ton of additional intel e1000 derived cards
1 parent 996d237 commit e576fb7

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

modules/e1000/e1000.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ bool e1000_detect_eeprom() {
5050
return eerprom_exists;
5151
}
5252

53-
5453
uint32_t e1000_read_eeprom(uint8_t addr) {
5554
uint16_t data = 0;
5655
uint32_t tmp = 0;
@@ -304,23 +303,18 @@ bool e1000_start(pci_dev_t *pci_device) {
304303
// Cache actual detected device ID
305304
e1000_device_id = pci_read(*pci_device, PCI_DEVICE_ID);
306305

307-
// Reject unsupported devices
308-
if (e1000_device_id != E1000_82540EM && e1000_device_id != E1000_82541PI) {
309-
dprintf("e1000: Attempt to start unsupported device ID\n");
310-
return false;
311-
}
312-
313-
if (e1000_detect_eeprom()) {
306+
if ((e1000_device_id == E1000_82540EM || e1000_device_id == E1000_82541PI) && e1000_detect_eeprom()) {
314307
if (!e1000_read_mac_address()) {
315308
dprintf("e1000: Failed to read device MAC\n");
316309
return false;
317310
}
318311
} else {
319-
uint8_t *mem_base_mac = (uint8_t *) (mem_base + 0x5400);
312+
uint8_t *mem_base_mac = (uint8_t *) (mem_base + REG_RAL0);
320313
for (int i = 0; i < 6; ++i) {
321314
mac[i] = mem_base_mac[i];
322315
}
323316
}
317+
dprintf("e1000: MAC %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
324318

325319
interrupts_off();
326320
e1000_up();
@@ -411,7 +405,20 @@ void init_e1000() {
411405
bool found = false;
412406

413407
// Try supported devices only
414-
const uint16_t supported[] = {E1000_82540EM, E1000_82541PI};
408+
const uint16_t supported[] = {
409+
E1000_82540EM,
410+
E1000_82541PI,
411+
E1000_82577LM,
412+
E1000_I217,
413+
E1000_82567LM,
414+
E1000_82567LM_2,
415+
E1000_82567LM_3,
416+
E1000_82574L,
417+
E1000_82579LM,
418+
E1000_82583V,
419+
E1000_I218LM,
420+
E1000_I219LM,
421+
};
415422
for (size_t i = 0; i < sizeof(supported) / sizeof(supported[0]); i++) {
416423
pci_device = pci_get_device(INTEL_VEND, supported[i], -1);
417424
if (!pci_not_found(pci_device)) {

modules/e1000/e1000.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55
*/
66
#pragma once
77

8-
#include "kernel.h"
8+
#include <kernel.h>
9+
10+
#define INTEL_VEND (uint32_t)0x8086 /* Vendor ID for Intel */
11+
#define E1000_82540EM (uint32_t)0x100E /* Device ID for the e1000 Qemu, Bochs, and VirtualBox emulated NICs */
12+
#define E1000_I217 (uint32_t)0x153A /* Device ID for Intel I217 */
13+
#define E1000_82577LM (uint32_t)0x10EA /* Device ID for Intel 82577LM */
14+
#define E1000_82541PI (uint32_t)0x107C /* Device ID for Intel 82541PI */
15+
#define E1000_82567LM (uint32_t)0x10F5 /* Device ID for Intel 82567LM */
16+
#define E1000_82567LM_2 (uint32_t)0x10CC /* Device ID for Intel 82567LM v2 */
17+
#define E1000_82567LM_3 (uint32_t)0x10DE /* Device ID for Intel 82567LM v3 */
18+
#define E1000_82574L (uint32_t)0x10D3 /* Intel 82574L PCIe Gigabit Controller */
19+
#define E1000_82579LM (uint32_t)0x1502 /* Intel 82579LM PCH-LAN Controller */
20+
#define E1000_82583V (uint32_t)0x150C /* Intel 82583V PCIe Gigabit Controller */
21+
#define E1000_I218LM (uint32_t)0x15A2 /* Intel I218-LM PCH-LAN Controller */
22+
#define E1000_I219LM (uint32_t)0x15E3 /* Intel I219-LM PCH-LAN Controller */
923

10-
#define INTEL_VEND (uint32_t)0x8086 // Vendor ID for Intel
11-
#define E1000_82540EM (uint32_t)0x100E // Device ID for the e1000 Qemu, Bochs, and VirtualBox emulated NICs
12-
#define E1000_I217 (uint32_t)0x153A // Device ID for Intel I217
13-
#define E1000_82577LM (uint32_t)0x10EA // Device ID for Intel 82577LM
14-
#define E1000_82541PI (uint32_t)0x107C // Device ID for Intel 82541PI
15-
1624

1725
#define REG_CTRL 0x0000
1826
#define REG_STATUS 0x0008
@@ -33,6 +41,7 @@
3341
#define REG_TXDESCLEN 0x3808
3442
#define REG_TXDESCHEAD 0x3810
3543
#define REG_TXDESCTAIL 0x3818
44+
#define REG_RAL0 0x5400
3645

3746
#define ICR_TXDW 1 << 0)
3847
#define ICR_TXQE (1 << 1)

0 commit comments

Comments
 (0)