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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#include "rtl8139.h"
#include "string.h"
#include "stdio.h"
#define DEBUG
/*
Offset (from IO base) Size Name
0x08 8 MAR0-7
0x30 4 RBSTART
0x37 1 CMD
0x3C 2 IMR
0x3E 2 ISR
*/
static rtl8139_vtable_t const rtl8139_vtable = {
{
rtl8139_activate,
rtl8139_deactivate,
rtl8139_deinit,
rtl8139_print_info
}
};
#define REG_MAC0 0
#define REG_MAC4 4
void rtl8139_init( rtl8139_t *rtl8139, pci_device_descriptor_t *descriptor, interrupt_t *interrupt, void *context )
{
memset( rtl8139, 0, sizeof( rtl8139_t ) );
network_init( (network_t *)rtl8139, interrupt, context );
puts( "Initializing driver for Realtek 8139 network card.." );
#ifdef DEBUG
printf( "using I/O base 0x%X\n", descriptor->port_base );
printf( "using interrupt %d\n", descriptor->interrupt );
#endif
port32_init( &rtl8139->MAC0_port, descriptor->port_base + REG_MAC0 );
port16_init( &rtl8139->MAC4_port, descriptor->port_base + REG_MAC4 );
interrupt_handler_init( &rtl8139->interrupt_handler, IRQ_BASE + descriptor->interrupt, interrupt, rtl8139_handle_interrupt, rtl8139 );
interrupts_register_interrupt_handler( rtl8139->interrupt_handler );
((driver_t *)rtl8139)->vtable = (driver_vtable_t *)&rtl8139_vtable;
}
void rtl8139_activate( void *obj )
{
puts( "Activating driver for Realtek 8139 network card.." );
rtl8139_t *rtl8139 = obj;
}
void rtl8139_deactivate( void *obj )
{
puts( "Dectivating driver for Realtek 8139 network card.." );
rtl8139_t *rtl8139 = obj;
}
void rtl8139_deinit( void *obj )
{
// nothing to do
}
uint32_t rtl8139_handle_interrupt( interrupt_handler_t *handler, uint32_t esp )
{
rtl8139_t *rtl8139 = (rtl8139_t *)handler->driver;
#ifdef DEBUG
printf( "RTL INTERRUPT\n" );
#endif
return esp;
}
void rtl8139_print_info( void *obj )
{
puts( "Realtek 8139 network card driver" );
}
|