-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnic.c
More file actions
47 lines (41 loc) · 1.19 KB
/
nic.c
File metadata and controls
47 lines (41 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* =====================================================================================
*
* Filename: nic.c
*
* Description: Network Interface Card drivers
*
* Version: 1.0
* Created: 11.01.2012 13:27:14
* Revision: none
* Compiler: gcc
*
* Author: Georg Wassen (gw) (),
* Company:
*
* =====================================================================================
*/
#include "pci.h"
#include "system.h"
#include "cpu.h"
#include "config.h"
#define IFV if (VERBOSE > 0 || VERBOSE_DRIVER > 0)
#define IFVV if (VERBOSE > 1 || VERBOSE_DRIVER > 1)
int rtl8139_init(unsigned bus, unsigned slot)
{
uint16_t iobase;
iobase = pci_config_read(bus, slot, 0, 0x10);
if (iobase & 1) {
// io-port: ignore 2 least significant bits
iobase &= ~0x03;
}
IFV printf("rtl8139: iobase = 0x%x\n", iobase);
uint8_t mac[6];
unsigned u;
for (u=0; u<6; u++) {
mac[u] = inportb(iobase + u);
}
IFV printf("rtl8139: mac = %x:%x:%x:%x:%x:%x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return 1; // the driver was not loaded, so far, we just print some information
}