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.
19 #include <KernelExport.h>
34 #define VENDOR_ID_REALTEK 0x10ec
37 static const uint32 kSupportedDevices
[] = {
43 int32 api_version
= B_CUR_DRIVER_API_VERSION
;
45 char* gDevNameList
[MAX_CARDS
+ 1];
46 pci_info
*gDevList
[MAX_CARDS
];
47 pci_module_info
*gPci
;
49 static device_hooks sDeviceHooks
= {
60 get_next_supported_pci_info(int32
*_cookie
, pci_info
*info
)
62 int32 index
= *_cookie
;
67 for (; gPci
->get_nth_pci_info(index
, info
) == B_OK
; index
++) {
69 if (info
->vendor_id
!= VENDOR_ID_REALTEK
)
73 for (i
= 0; i
< sizeof(kSupportedDevices
)
74 / sizeof(kSupportedDevices
[0]); i
++) {
75 if (info
->device_id
== kSupportedDevices
[i
]) {
82 return B_ENTRY_NOT_FOUND
;
96 TRACE("init_hardware()\n");
98 if (get_module(B_PCI_MODULE_NAME
, (module_info
**)&gPci
) < B_OK
)
101 result
= get_next_supported_pci_info(&cookie
, &info
);
102 put_module(B_PCI_MODULE_NAME
);
111 struct pci_info
*item
;
116 set_dprintf_enabled(true);
117 load_driver_symbols("rtl8169");
123 item
= (pci_info
*)malloc(sizeof(pci_info
));
127 if (get_module(B_PCI_MODULE_NAME
, (module_info
**)&gPci
) < B_OK
) {
132 while (get_next_supported_pci_info(&index
, item
) == B_OK
) {
134 sprintf(name
, "net/rtl8169/%d", cards
);
135 gDevList
[cards
] = item
;
136 gDevNameList
[cards
] = strdup(name
);
137 gDevNameList
[cards
+ 1] = NULL
;
140 item
= (pci_info
*)malloc(sizeof(pci_info
));
144 if (cards
== MAX_CARDS
)
148 TRACE("found %d cards\n", cards
);
155 if (initialize_timer() != B_OK
) {
156 ERROR("timer init failed\n");
165 for (index
= 0; index
< cards
; index
++) {
166 free(gDevList
[index
]);
167 free(gDevNameList
[index
]);
169 put_module(B_PCI_MODULE_NAME
);
179 TRACE("uninit_driver()\n");
183 for (i
= 0; gDevNameList
[i
] != NULL
; i
++) {
185 free(gDevNameList
[i
]);
188 put_module(B_PCI_MODULE_NAME
);
195 return (const char**)gDevNameList
;
200 find_device(const char* name
)
202 return &sDeviceHooks
;