1 /* Intel PRO/1000 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>
31 int32 api_version
= B_CUR_DRIVER_API_VERSION
;
33 pci_module_info
*gPci
;
35 char* gDevNameList
[MAX_CARDS
+ 1];
36 pci_info
*gDevList
[MAX_CARDS
];
39 identify_device(const pci_info
*info
)
41 if (info
->vendor_id
!= 0x8086)
43 switch (info
->device_id
) {
44 case 0x1000: return "82542";
45 case 0x1001: return "82543GC FIBER";
46 case 0x1004: return "82543GC COPPER";
47 case 0x1008: return "82544EI COPPER";
48 case 0x1009: return "82544EI FIBER";
49 case 0x100C: return "82544GC COPPER";
50 case 0x100D: return "82544GC LOM";
51 case 0x100E: return "82540EM";
52 case 0x100F: return "82545EM COPPER";
53 case 0x1010: return "82546EB COPPER";
54 case 0x1011: return "82545EM FIBER";
55 case 0x1012: return "82546EB FIBER";
56 case 0x1013: return "82541EI";
57 case 0x1014: return "unknown 1014";
58 case 0x1015: return "82540EM LOM";
59 case 0x1016: return "82540EP LOM";
60 case 0x1017: return "82540EP";
61 case 0x1018: return "82541EI MOBILE";
62 case 0x1019: return "82547EI";
63 case 0x101A: return "unknown 101A";
64 case 0x101D: return "82546EB QUAD COPPER";
65 case 0x101E: return "82540EP LP";
66 case 0x1026: return "82545GM COPPER";
67 case 0x1027: return "82545GM FIBER";
68 case 0x1028: return "82545GM SERDES";
69 case 0x1075: return "82547GI";
70 case 0x1076: return "82541GI";
71 case 0x1077: return "82541GI MOBILE";
72 case 0x1078: return "82541ER";
73 case 0x1079: return "82546GB COPPER";
74 case 0x107A: return "82546GB FIBER";
75 case 0x107B: return "82546GB SERDES";
76 case 0x107C: return "82541PI";
89 INIT_DEBUGOUT("init_hardware()");
91 if (get_module(B_PCI_MODULE_NAME
, (module_info
**)&pci
) < B_OK
)
93 for (res
= B_ERROR
, i
= 0; pci
->get_nth_pci_info(i
, &info
) == B_OK
; i
++) {
94 if (identify_device(&info
)) {
99 put_module(B_PCI_MODULE_NAME
);
108 struct pci_info
*item
;
113 set_dprintf_enabled(true);
114 load_driver_symbols("ipro1000");
117 dprintf("ipro1000: " INFO
"\n");
119 item
= (pci_info
*)malloc(sizeof(pci_info
));
123 if (get_module(B_PCI_MODULE_NAME
, (module_info
**)&gPci
) < B_OK
) {
128 for (cards
= 0, index
= 0; gPci
->get_nth_pci_info(index
++, item
) == B_OK
; ) {
129 const char *info
= identify_device(item
);
132 sprintf(name
, "net/ipro1000/%d", cards
);
133 dprintf("ipro1000: /dev/%s is a %s\n", name
, info
);
134 gDevList
[cards
] = item
;
135 gDevNameList
[cards
] = strdup(name
);
136 gDevNameList
[cards
+ 1] = NULL
;
138 item
= (pci_info
*)malloc(sizeof(pci_info
));
141 if (cards
== MAX_CARDS
)
151 if (initialize_timer() != B_OK
) {
152 ERROROUT("timer init failed");
156 if (mempool_init(cards
* 768) != B_OK
) {
157 ERROROUT("mempool init failed");
168 for (index
= 0; index
< cards
; index
++) {
169 free(gDevList
[index
]);
170 free(gDevNameList
[index
]);
172 put_module(B_PCI_MODULE_NAME
);
182 INIT_DEBUGOUT("uninit_driver()");
188 for (i
= 0; gDevNameList
[i
] != NULL
; i
++) {
190 free(gDevNameList
[i
]);
193 put_module(B_PCI_MODULE_NAME
);
211 return (const char**)gDevNameList
;
216 find_device(const char* name
)
218 return &gDeviceHooks
;