1 /* Realtek RTL8169 Family Driver
2 * Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
4 * Permission to use, copy, modify and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies, and that both the
7 * copyright notice and this permission notice appear in supporting documentation.
9 * Marcus Overhagen makes no representations about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
12 * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
13 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
14 * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
15 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 #define TX_TIMEOUT 6000000 // 6 seconds
28 #define FRAME_SIZE 1536 // must be multiple of 8
29 #define DEFAULT_TX_BUF_COUNT 256 // must be <= 1024
30 #define DEFAULT_RX_BUF_COUNT 256 // must be <= 1024
32 extern pci_module_info
*gPci
;
34 status_t
rtl8169_open(const char *name
, uint32 flags
, void** cookie
);
35 status_t
rtl8169_read(void* cookie
, off_t position
, void *buf
, size_t* num_bytes
);
36 status_t
rtl8169_write(void* cookie
, off_t position
, const void* buffer
, size_t* num_bytes
);
37 status_t
rtl8169_control(void *cookie
, uint32 op
, void *arg
, size_t len
);
38 status_t
rtl8169_close(void* cookie
);
39 status_t
rtl8169_free(void* cookie
);
45 volatile bool nonblocking
;
49 volatile int intTotalCount
;
50 volatile int intTotalCountOld
;
51 volatile int intRxTotalCount
;
52 volatile int intTxTotalCount
;
53 volatile int intTimerTotalCount
;
54 volatile int intCurrentCount
;
55 volatile int intRxCurrentCount
;
56 volatile int intTxCurrentCount
;
57 volatile int intTimerCurrentCount
;
63 volatile int32 txNextIndex
; // next descriptor that will be used for writing
64 volatile int32 txIntIndex
; // current descriptor that needs be checked
65 volatile int32 txUsed
;
70 volatile int32 rxNextIndex
; // next descriptor that will be used for reading
71 volatile int32 rxIntIndex
; // current descriptor that needs be checked
72 volatile int32 rxFree
;
75 volatile buf_desc
* txDesc
;
76 volatile buf_desc
* rxDesc
;
100 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
101 sem_id linkChangeSem
;
106 #define read8(offset) (*(volatile uint8 *) ((char *)(device->regAddr) + (offset)))
107 #define read16(offset) (*(volatile uint16 *)((char *)(device->regAddr) + (offset)))
108 #define read32(offset) (*(volatile uint32 *)((char *)(device->regAddr) + (offset)))
109 #define write8(offset, value) (*(volatile uint8 *) ((char *)(device->regAddr) + (offset)) = value)
110 #define write16(offset, value) (*(volatile uint16 *)((char *)(device->regAddr) + (offset)) = value)
111 #define write32(offset, value) (*(volatile uint32 *)((char *)(device->regAddr) + (offset)) = value)