Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch/i386/libsaio/networking.c

1/*
2 * Copyright (c) 2009 Evan Lojewski. All rights reserved.
3 *
4 * Merge into file from module compcept by ErmaC and Marchrius
5 *
6 */
7
8#include "boot.h"
9#include "bootstruct.h"
10#include "pci.h"
11#include "platform.h"
12#include "device_inject.h"
13#include "networking.h"
14
15#define STRINGIFY(x) #x
16#define TOSTRING(x) STRINGIFY(x)
17
18#define HEADER __FILE__ " [" TOSTRING(__LINE__) "]: "
19
20#ifndef DEBUG_ETHERNET
21#define DEBUG_ETHERNET 0
22#endif
23
24#if DEBUG_ETHERNET
25#define DBG(x...)printf(x)
26#else
27#define DBG(x...)
28#endif
29
30#ifndef DEBUG_WLAN
31#define DEBUG_WLAN 0
32#endif
33
34#if DEBUG_WLAN
35#define DBG(x...)printf(x)
36#else
37#define DBG(x...)
38#endif
39
40uint32_t builtin_set= 0;
41uint8_t builtin= 0;
42extern uint32_t location_number;
43
44static network_device known_ethernet_cards[] =
45{
46// Realtek
47{ PCI_VENDOR_ID_REALTEK, 0x8129, "8129 Gigabit Ethernet" },
48{ PCI_VENDOR_ID_REALTEK, 0x8136, "RTL8101E/RTL8102E PCI-E Fast Ethernet Controller" },
49{ PCI_VENDOR_ID_REALTEK, 0x8139, "RTL8139/810x Family Fast Ethernet" },
50{ PCI_VENDOR_ID_REALTEK, 0x8167, "8169/8110 Gigabit Ethernet" },
51{ PCI_VENDOR_ID_REALTEK, 0x8168, "RTL8111/8168 PCI-E Gigabit Ethernet" },
52{ PCI_VENDOR_ID_REALTEK, 0x8169, "8169/8110 Gigabit Ethernet" },
53
54{ 0x1113, 0x1211, "Realtek RTL8139 Family Fast Ethernet" },
55{ 0x1500, 0x1360, "Realtek RTL8139 Family Fast Ethernet" },
56{ 0x4033, 0x1360, "Realtek RTL8139 Family Fast Ethernet" },
57{ 0x1186, 0x1300, "Realtek RTL8139 Family Fast Ethernet" },
58{ 0x1186, 0x1340, "Realtek RTL8139 Family Fast Ethernet" },
59{ 0x13d1, 0xab06, "Realtek RTL8139 Family Fast Ethernet" },
60{ 0x1259, 0xa117, "Realtek RTL8139 Family Fast Ethernet" },
61{ 0x1259, 0xa11e, "Realtek RTL8139 Family Fast Ethernet" },
62{ 0x14ea, 0xab06, "Realtek RTL8139 Family Fast Ethernet" },
63{ 0x14ea, 0xab07, "Realtek RTL8139 Family Fast Ethernet" },
64{ 0x11db, 0x1234, "Realtek RTL8139 Family Fast Ethernet" },
65{ 0x1432, 0x9130, "Realtek RTL8139 Family Fast Ethernet" },
66{ 0x02ac, 0x1012, "Realtek RTL8139 Family Fast Ethernet" },
67{ 0x018a, 0x0106, "Realtek RTL8139 Family Fast Ethernet" },
68{ 0x126c, 0x1211, "Realtek RTL8139 Family Fast Ethernet" },
69{ 0x1743, 0x8139, "Realtek RTL8139 Family Fast Ethernet" },
70{ 0x021b, 0x8139, "Realtek RTL8139 Family Fast Ethernet" },
71
72// Marvell
73{ PCI_VENDOR_ID_MARVELL, 0x4320, "88E8001 Gigabit Ethernet Controller" },
74{ PCI_VENDOR_ID_MARVELL, 0x4340, "88E8021 PCI-X IPMI Gigabit Ethernet Controller" },
75{ PCI_VENDOR_ID_MARVELL, 0x4341, "88E8022 PCI-X IPMI Gigabit Ethernet Controller" },
76{ PCI_VENDOR_ID_MARVELL, 0x4342, "88E8061 PCI-E IPMI Gigabit Ethernet Controller" },
77{ PCI_VENDOR_ID_MARVELL, 0x4343, "88E8062 PCI-E IPMI Gigabit Ethernet Controller" },
78{ PCI_VENDOR_ID_MARVELL, 0x4344, "88E8021 PCI-X IPMI Gigabit Ethernet Controller" },
79{ PCI_VENDOR_ID_MARVELL, 0x4345, "88E8022 PCI-X IPMI Gigabit Ethernet Controller" },
80{ PCI_VENDOR_ID_MARVELL, 0x4346, "88E8061 PCI-E IPMI Gigabit Ethernet Controller" },
81{ PCI_VENDOR_ID_MARVELL, 0x4347, "88E8062 PCI-E IPMI Gigabit Ethernet Controller" },
82{ PCI_VENDOR_ID_MARVELL, 0x4350, "88E8035 PCI-E Fast Ethernet Controller" },
83{ PCI_VENDOR_ID_MARVELL, 0x4351, "88E8036 PCI-E Fast Ethernet Controller" },
84{ PCI_VENDOR_ID_MARVELL, 0x4352, "88E8038 PCI-E Fast Ethernet Controller" },
85{ PCI_VENDOR_ID_MARVELL, 0x4353, "88E8039 PCI-E Fast Ethernet Controller" },
86{ PCI_VENDOR_ID_MARVELL, 0x4354, "88E8040 PCI-E Fast Ethernet Controller" },
87{ PCI_VENDOR_ID_MARVELL, 0x4355, "88E8040T PCI-E Fast Ethernet Controller" },
88{ PCI_VENDOR_ID_MARVELL, 0x4356, "88EC033 PCI-E Fast Ethernet Controller" },
89{ PCI_VENDOR_ID_MARVELL, 0x4357, "88E8042 PCI-E Fast Ethernet Controller" },
90{ PCI_VENDOR_ID_MARVELL, 0x435A, "88E8048 PCI-E Fast Ethernet Controller" },
91{ PCI_VENDOR_ID_MARVELL, 0x4360, "88E8052 PCI-E ASF Gigabit Ethernet Controller" },
92{ PCI_VENDOR_ID_MARVELL, 0x4361, "88E8050 PCI-E ASF Gigabit Ethernet Controller" },
93{ PCI_VENDOR_ID_MARVELL, 0x4362, "88E8053 PCI-E Gigabit Ethernet Controller" },
94{ PCI_VENDOR_ID_MARVELL, 0x4363, "88E8055 PCI-E Gigabit Ethernet Controller" },
95{ PCI_VENDOR_ID_MARVELL, 0x4364, "88E8056 PCI-E Gigabit Ethernet Controller" },
96{ PCI_VENDOR_ID_MARVELL, 0x4365, "8E8070 based Ethernet Controller" },
97{ PCI_VENDOR_ID_MARVELL, 0x4366, "88EC036 PCI-E Gigabit Ethernet Controller" },
98{ PCI_VENDOR_ID_MARVELL, 0x4367, "88EC032 Ethernet Controller" },
99{ PCI_VENDOR_ID_MARVELL, 0x4368, "88EC034 Ethernet Controller" },
100{ PCI_VENDOR_ID_MARVELL, 0x4369, "88EC042 Ethernet Controller" },
101{ PCI_VENDOR_ID_MARVELL, 0x436A, "88E8058 PCI-E Gigabit Ethernet Controller" },
102{ PCI_VENDOR_ID_MARVELL, 0x436B, "88E8071 PCI-E Gigabit Ethernet Controller" },
103{ PCI_VENDOR_ID_MARVELL, 0x436C, "88E8072 PCI-E Gigabit Ethernet Controller" },
104{ PCI_VENDOR_ID_MARVELL, 0x436D, "88E8055 PCI-E Gigabit Ethernet Controller" },
105{ PCI_VENDOR_ID_MARVELL, 0x4370, "88E8075 PCI-E Gigabit Ethernet Controller" },
106{ PCI_VENDOR_ID_MARVELL, 0x4380, "88E8057 PCI-E Gigabit Ethernet Controller" },
107{ PCI_VENDOR_ID_MARVELL, 0x4381, "88E8059 PCI-E Gigabit Ethernet Controller" },
108{ PCI_VENDOR_ID_MARVELL, 0x4382, "88E8079 PCI-E Gigabit Ethernet Controller" },
109//{ PCI_VENDOR_ID_MARVELL, 0x5005, "Belkin F5D5005 Gigabit Desktop Network PCI Card" },
110
111// Broadcom
112{ PCI_VENDOR_ID_BROADCOM, 0x1600, "BCM5752 Gigabit Ethernet PCI Express" },
113{ PCI_VENDOR_ID_BROADCOM, 0x1655, "BCM5717 Gigabit Ethernet PCIe" },
114{ PCI_VENDOR_ID_BROADCOM, 0x1656, "BCM5718 Gigabit Ethernet PCIe" },
115{ PCI_VENDOR_ID_BROADCOM, 0x1657, "BCM5719 Gigabit Ethernet PCIe" },
116{ PCI_VENDOR_ID_BROADCOM, 0x1659, "BCM5721 Gigabit Ethernet PCI Express" },
117{ PCI_VENDOR_ID_BROADCOM, 0x165A, "BCM5722 Gigabit Ethernet PCI Express" },
118{ PCI_VENDOR_ID_BROADCOM, 0x166A, "BCM5780 Gigabit Ethernet" },
119{ PCI_VENDOR_ID_BROADCOM, 0x1672, "BCM5754M Gigabit Ethernet PCI Express" },
120{ PCI_VENDOR_ID_BROADCOM, 0x1673, "BCM5755M Gigabit Ethernet PCI Express" },
121{ PCI_VENDOR_ID_BROADCOM, 0x167A, "BCM5754 Gigabit Ethernet PCI Express" },
122{ PCI_VENDOR_ID_BROADCOM, 0x167B, "BCM5755 Gigabit Ethernet PCI Express" },
123{ PCI_VENDOR_ID_BROADCOM, 0x1684, "BCM5764M Gigabit Ethernet PCIe" },
124{ PCI_VENDOR_ID_BROADCOM, 0x1691, "BCM57788 Gigabit Ethernet PCIe" },
125{ PCI_VENDOR_ID_BROADCOM, 0x1693, "BCM5787M Gigabit Ethernet PCI Express" },
126{ PCI_VENDOR_ID_BROADCOM, 0x169B, "BCM5787 Gigabit Ethernet PCI Express" },
127{ PCI_VENDOR_ID_BROADCOM, 0x16B4, "BCM57765 Gigabit Ethernet PCIe" },
128{ PCI_VENDOR_ID_BROADCOM, 0x16B5, "BCM57785 Gigabit Ethernet PCIe" },
129{ PCI_VENDOR_ID_BROADCOM, 0x1712, "BCM5906 Fast Ethernet PCI Express" },
130{ PCI_VENDOR_ID_BROADCOM, 0x1713, "BCM5906M Fast Ethernet PCI Express" },
131
132// JMicron
133{ PCI_VENDOR_ID_JMICRON, 0x0250, "JMC250 PCI Express Gigabit Ethernet Controller" },
134{ PCI_VENDOR_ID_JMICRON, 0x0260, "JMC260 PCI Express Gigabit Ethernet Controller" },
135
136// Intel
137//{ PCI_VENDOR_ID_INTEL, 0x1000, "82542 Gigabit Ethernet Controller (Fiber)" },
138{ PCI_VENDOR_ID_INTEL, 0x1029, "8255x Ethernet" },
139{ PCI_VENDOR_ID_INTEL, 0x1030, "8255x Ethernet" },
140{ PCI_VENDOR_ID_INTEL, 0x1031, "8255x Ethernet" },
141{ PCI_VENDOR_ID_INTEL, 0x1032, "8255x Ethernet" },
142{ PCI_VENDOR_ID_INTEL, 0x1033, "8255x Ethernet" },
143{ PCI_VENDOR_ID_INTEL, 0x1034, "8255x Ethernet" },
144{ PCI_VENDOR_ID_INTEL, 0x1038, "8255x Ethernet" },
145{ PCI_VENDOR_ID_INTEL, 0x1039, "8255x Ethernet" },
146{ PCI_VENDOR_ID_INTEL, 0x103A, "8255x Ethernet" },
147{ PCI_VENDOR_ID_INTEL, 0x103B, "8255x Ethernet" },
148{ PCI_VENDOR_ID_INTEL, 0x103C, "8255x Ethernet" },
149{ PCI_VENDOR_ID_INTEL, 0x103D, "8255x Ethernet" },
150{ PCI_VENDOR_ID_INTEL, 0x103E, "8255x Ethernet" },
151//{ PCI_VENDOR_ID_INTEL, 0x1049, "82566MM Gigabit Network Connection" },
152//{ PCI_VENDOR_ID_INTEL, 0x104A, "82566DM Gigabit Network Connection" },
153//{ PCI_VENDOR_ID_INTEL, 0x104B, "82566DC Gigabit Network Connection" },
154//{ PCI_VENDOR_ID_INTEL, 0x104C, "82562V 10/100 Network Connection" },
155//{ PCI_VENDOR_ID_INTEL, 0x104D, "82566MC Gigabit Network Connection" },
156{ PCI_VENDOR_ID_INTEL, 0x1050, "82562EZ 10/100 Ethernet Controller" },
157{ PCI_VENDOR_ID_INTEL, 0x1051, "82801EB/ER (ICH5/ICH5R) integrated LAN Controller" },
158{ PCI_VENDOR_ID_INTEL, 0x1052, "PRO/100 VE Network Connection" },
159{ PCI_VENDOR_ID_INTEL, 0x1053, "PRO/100 VE Network Connection" },
160{ PCI_VENDOR_ID_INTEL, 0x1054, "PRO/100 VE Network Connection" },
161{ PCI_VENDOR_ID_INTEL, 0x1055, "PRO/100 VE Network Connection" },
162{ PCI_VENDOR_ID_INTEL, 0x1056, "PRO/100 VE Network Connection" },
163{ PCI_VENDOR_ID_INTEL, 0x1057, "PRO/100 VE Network Connection" },
164{ PCI_VENDOR_ID_INTEL, 0x1059, "82551QM Ethernet Controller" },
165//{ PCI_VENDOR_ID_INTEL, 0x105b "82546GB Gigabit Ethernet Controller (Copper)" },
166//{ PCI_VENDOR_ID_INTEL, 0x105E, "82546GB Gigabit Ethernet Controller" },
167//{ PCI_VENDOR_ID_INTEL, 0x105F, "82571EB Gigabit Ethernet Controller" },
168{ PCI_VENDOR_ID_INTEL, 0x1060, "82571EB Gigabit Ethernet Controller" },
169{ PCI_VENDOR_ID_INTEL, 0x1064, "82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller" },
170{ PCI_VENDOR_ID_INTEL, 0x1065, "82562ET/EZ/GT/GZ - PRO/100 VE Ethernet Controller" },
171{ PCI_VENDOR_ID_INTEL, 0x1066, "82562 EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller" },
172{ PCI_VENDOR_ID_INTEL, 0x1067, "82562 EM/EX/GX - PRO/100 VM Ethernet Controller" },
173{ PCI_VENDOR_ID_INTEL, 0x1068, "82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller Mobile" },
174{ PCI_VENDOR_ID_INTEL, 0x1069, "82562EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller Mobile" },
175{ PCI_VENDOR_ID_INTEL, 0x106A, "82562G - PRO/100 VE (LOM) Ethernet Controller" },
176{ PCI_VENDOR_ID_INTEL, 0x106B, "82562G - PRO/100 VE Ethernet Controller Mobile" },
177{ PCI_VENDOR_ID_INTEL, 0x1075, "82547GI Gigabit Ethernet Controller" },
178{ PCI_VENDOR_ID_INTEL, 0x1076, "82541GI Gigabit Ethernet Controller" },
179{ PCI_VENDOR_ID_INTEL, 0x1077, "82541GI Gigabit Ethernet Controller" },
180{ PCI_VENDOR_ID_INTEL, 0x1078, "82541ER Gigabit Ethernet Controller" },
181{ PCI_VENDOR_ID_INTEL, 0x1079, "82546GB Gigabit Ethernet Controller" },
182{ PCI_VENDOR_ID_INTEL, 0x107a, "82546GB Gigabit Ethernet Controller" },
183{ PCI_VENDOR_ID_INTEL, 0x107b, "82546GB Gigabit Ethernet Controller" },
184{ PCI_VENDOR_ID_INTEL, 0x107c, "82541PI Gigabit Ethernet Controller" },
185//{ PCI_VENDOR_ID_INTEL, 0x107D, "82572EI Gigabit Ethernet Controller (Copper)" },
186//{ PCI_VENDOR_ID_INTEL, 0x107E, "82572EI Gigabit Ethernet Controller (Fiber)" },
187//{ PCI_VENDOR_ID_INTEL, 0x107F, "82572EI Gigabit Ethernet Controller" },
188//{ PCI_VENDOR_ID_INTEL, 0x108a, "82546GB Gigabit Ethernet Controller" },
189//{ PCI_VENDOR_ID_INTEL, 0x108B, "82573V Gigabit Ethernet Controller (Copper)" },
190//{ PCI_VENDOR_ID_INTEL, 0x108C, "82573E Gigabit Ethernet Controller (Copper)" },
191{ PCI_VENDOR_ID_INTEL, 0x1091, "PRO/100 VM Network Connection" },
192{ PCI_VENDOR_ID_INTEL, 0x1092, "PRO/100 VE Network Connection" },
193{ PCI_VENDOR_ID_INTEL, 0x1093, "PRO/100 VM Network Connection" },
194{ PCI_VENDOR_ID_INTEL, 0x1094, "PRO/100 VE Network Connection" },
195{ PCI_VENDOR_ID_INTEL, 0x1095, "PRO/100 VE Network Connection" },
196//{ PCI_VENDOR_ID_INTEL, 0x1096, "80003ES2LAN Gigabit Ethernet Controller (Copper)" },
197//{ PCI_VENDOR_ID_INTEL, 0x1098, "80003ES2LAN Gigabit Ethernet Controller (Serdes)" },
198//{ PCI_VENDOR_ID_INTEL, 0x109A, "82573L Gigabit Ethernet Controller" },
199//{ PCI_VENDOR_ID_INTEL, 0x10A4, "82571EB Gigabit Ethernet Controller" },
200//{ PCI_VENDOR_ID_INTEL, 0x10A5, "82571EB Gigabit Ethernet Controller (Fiber)" },
201//{ PCI_VENDOR_ID_INTEL, 0x10BA, "Intel " },
202//{ PCI_VENDOR_ID_INTEL, 0x10BC, "Intel " },
203//{ PCI_VENDOR_ID_INTEL, 0x10B9, "Intel " },
204//{ PCI_VENDOR_ID_INTEL, 0x10BB, "Intel " },
205//{ PCI_VENDOR_ID_INTEL, 0x10BD, "Intel " },
206//{ PCI_VENDOR_ID_INTEL, 0x10BF, "Intel " },
207//{ PCI_VENDOR_ID_INTEL, 0x10C0, "Intel " },
208//{ PCI_VENDOR_ID_INTEL, 0x10C2, "Intel " },
209//{ PCI_VENDOR_ID_INTEL, 0x10C3, "Intel " },
210//{ PCI_VENDOR_ID_INTEL, 0x10C4, "Intel " },
211//{ PCI_VENDOR_ID_INTEL, 0x10C5, "Intel " },
212//{ PCI_VENDOR_ID_INTEL, 0x10CB, "Intel " },
213//{ PCI_VENDOR_ID_INTEL, 0x10CC, "Intel " },
214//{ PCI_VENDOR_ID_INTEL, 0x10CD, "Intel " },
215{ PCI_VENDOR_ID_INTEL, 0x10CE, "82567V-2 Gigabit Network Connection" },
216{ PCI_VENDOR_ID_INTEL, 0x10D3, "82574L Gigabit Network Connection" },
217//{ PCI_VENDOR_ID_INTEL, 0x10D5, "Intel " },
218{ PCI_VENDOR_ID_INTEL, 0x10d6, "82575GB Gigabit Network Connection" },
219//{ PCI_VENDOR_ID_INTEL, 0x10D9, "Intel " },
220//{ PCI_VENDOR_ID_INTEL, 0x10DA, "Intel " },
221//{ PCI_VENDOR_ID_INTEL, 0x10DE, "Intel " },
222//{ PCI_VENDOR_ID_INTEL, 0x10DF, "Intel " },
223//{ PCI_VENDOR_ID_INTEL, 0x10E5, "Intel " },
224//{ PCI_VENDOR_ID_INTEL, 0x10EA, "Intel " },
225//{ PCI_VENDOR_ID_INTEL, 0x10EB, "Intel " },
226//{ PCI_VENDOR_ID_INTEL, 0x10EF, "Intel " },
227//{ PCI_VENDOR_ID_INTEL, 0x10F5, "Intel " },
228//{ PCI_VENDOR_ID_INTEL, 0x10F6, "" },
229{ PCI_VENDOR_ID_INTEL, 0x10F0, "82578DC Gigabit Network Connection" },
230{ PCI_VENDOR_ID_INTEL, 0x10FE, "82552 10/100 Network Connection" },
231{ PCI_VENDOR_ID_INTEL, 0x1209, "8255xER/82551IT Fast Ethernet Controller" },
232{ PCI_VENDOR_ID_INTEL, 0x1227, "82865 EtherExpress PRO/100A" },
233{ PCI_VENDOR_ID_INTEL, 0x1228, "82556 EtherExpress PRO/100 Smart" },
234{ PCI_VENDOR_ID_INTEL, 0x1229, "82557/8/9/0/1 Ethernet Pro 100" },
235//{ PCI_VENDOR_ID_INTEL, 0x1501, "82567V-3 Gigabit Network Connection" },
236{ PCI_VENDOR_ID_INTEL, 0x1502, "82579LM Gigabit Network Connection" },
237{ PCI_VENDOR_ID_INTEL, 0x1503, "82579V Gigabit Network Controller" },
238//{ PCI_VENDOR_ID_INTEL, 0x150C, "82583V Gigabit Network Connection" },
239//{ PCI_VENDOR_ID_INTEL, 0x1525, "82567V-4 Gigabit Network Connection" },
240{ PCI_VENDOR_ID_INTEL, 0x153A, "Ethernet Connection I217-LM" },
241{ PCI_VENDOR_ID_INTEL, 0x153B, "Ethernet Connection I217-V" },
242{ PCI_VENDOR_ID_INTEL, 0x1559, "Ethernet Connection I218-V" },
243{ PCI_VENDOR_ID_INTEL, 0x155A, "Ethernet Connection I218-LM" },
244{ PCI_VENDOR_ID_INTEL, 0x15A0, "Ethernet Connection (2) I218-LM" },
245{ PCI_VENDOR_ID_INTEL, 0x15A1, "Ethernet Connection (2) I218-V" },
246{ PCI_VENDOR_ID_INTEL, 0x15A2, "Ethernet Connection (3) I218-LM" },
247{ PCI_VENDOR_ID_INTEL, 0x15A3, "Ethernet Connection (3) I218-V" },
248{ PCI_VENDOR_ID_INTEL, 0x2449, "82801BA/BAM/CA/CAM Ethernet Controller" },
249{ PCI_VENDOR_ID_INTEL, 0x2459, "82801E Ethernet Controller" },
250{ PCI_VENDOR_ID_INTEL, 0x245D, "82801E Ethernet Controller" },
251{ PCI_VENDOR_ID_INTEL, 0x27DC, "NM10/ICH7 Family LAN Controller" },
252//{ PCI_VENDOR_ID_INTEL, 0x294C, "82566DC-2 Gigabit Network Connection" },
253
254//Atheros (Qualcomm)
255{ PCI_VENDOR_ID_QUALCOMM, 0x1026, "AR8121/AR8113/AR8114 Ethernet" },
256{ PCI_VENDOR_ID_QUALCOMM, 0x1062, "AR8132 Fast Ethernet" },
257{ PCI_VENDOR_ID_QUALCOMM, 0x1063, "AR8131 Gigabit Ethernet" },
258{ PCI_VENDOR_ID_QUALCOMM, 0x1066, "AR8121/AR8113/AR8114 Ethernet" },
259{ PCI_VENDOR_ID_QUALCOMM, 0x1067, "L1c Gigabit Ethernet" },
260{ PCI_VENDOR_ID_QUALCOMM, 0x1073, "AR8151 v1.0 Gigabit 1000" },
261{ PCI_VENDOR_ID_QUALCOMM, 0x1083, "GbE LAN chip (10/100/1000 Mbit)" },
262{ PCI_VENDOR_ID_QUALCOMM, 0x1090, "AR8162 Fast Ethernet" },
263{ PCI_VENDOR_ID_QUALCOMM, 0x1091, "AR8161 Gigabit Ethernet" },
264{ PCI_VENDOR_ID_QUALCOMM, 0x10a0, "QCA8172 Fast Ethernet" },
265{ PCI_VENDOR_ID_QUALCOMM, 0x10a1, "QCA8171 Gigabit Ethernet" },
266{ PCI_VENDOR_ID_QUALCOMM, 0x2048, "L2 Fast Ethernet" },
267{ PCI_VENDOR_ID_QUALCOMM, 0x2060, "AR8152 v1.1 Fast 10/100" },
268{ PCI_VENDOR_ID_QUALCOMM, 0x2062, "AR8152 v2.0 Fast 10/100" }
269};
270#define ETH_DEVICES_LEN (sizeof(known_ethernet_cards) / sizeof(known_ethernet_cards[0]))
271
272static network_device known_wifi_cards[] =
273{
274// Broadcom
275{PCI_VENDOR_ID_BROADCOM, 0x4312, "BCM4311 802.11a/b/g"},
276//{PCI_VENDOR_ID_BROADCOM, 0x4313, "BCM4311 802.11a" },
277{PCI_VENDOR_ID_BROADCOM, 0x4315, "BCM4312 802.11b/g Wireless LAN Controller"},
278//{PCI_VENDOR_ID_BROADCOM, 0x4318, "BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller"},
279{PCI_VENDOR_ID_BROADCOM, 0x4319, "BCM4318 [AirForce 54g] 802.11a/b/g PCI Express Transceiver"},
280{PCI_VENDOR_ID_BROADCOM, 0x4320, "BCM4306 802.11b/g Wireless LAN Controller"},
281//{PCI_VENDOR_ID_BROADCOM, 0x4321, "BCM4321 802.11a Wireless Network Controller"},
282//{PCI_VENDOR_ID_BROADCOM, 0x4322, "BCM4322 802.11bgn Wireless Network Controller"},
283{PCI_VENDOR_ID_BROADCOM, 0x4324, "BCM4309 802.11abg Wireless Network Controller"},
284//{PCI_VENDOR_ID_BROADCOM, 0x4325, "BCM4306 802.11bg Wireless Network Controller"},
285{PCI_VENDOR_ID_BROADCOM, 0x4328, "BCM4321 802.11a/b/g/n"},
286//{PCI_VENDOR_ID_BROADCOM, 0x4329, "BCM4321 802.11b/g/n"},
287//{PCI_VENDOR_ID_BROADCOM, 0x432a, "BCM4321 802.11an Wireless Network Controller"},
288{PCI_VENDOR_ID_BROADCOM, 0x432b, "BCM4322 802.11a/b/g/n Wireless LAN Controller"},
289{PCI_VENDOR_ID_BROADCOM, 0x432c, "BCM4322 802.11b/g/n"},
290{PCI_VENDOR_ID_BROADCOM, 0x432d, "BCM4322 802.11an Wireless Network Controller"},
291{PCI_VENDOR_ID_BROADCOM, 0x4331, "BCM4331 802.11a/b/g/n"},
292//{PCI_VENDOR_ID_BROADCOM, 0x4350, "BCM43222 Wireless Network Adapter"},
293//{PCI_VENDOR_ID_BROADCOM, 0x4351, "BCM43222 802.11abgn Wireless Network Adapter"},
294//{PCI_VENDOR_ID_BROADCOM, 0x4353, "BCM43224 802.11a/b/g/n"},
295//{PCI_VENDOR_ID_BROADCOM, 0x4357, "BCM43225 802.11b/g/n"},
296//{PCI_VENDOR_ID_BROADCOM, 0x4358, "BCM43227 802.11b/g/n"},
297{PCI_VENDOR_ID_BROADCOM, 0x4359, "BCM43228 802.11a/b/g/n"},
298//{PCI_VENDOR_ID_BROADCOM, 0x4360, "BCM4360 802.11ac Wireless Network Adapter"},
299{PCI_VENDOR_ID_BROADCOM, 0x4365, "BCM43142 802.11b/g/n"},
300//{PCI_VENDOR_ID_BROADCOM, 0x43a0, "BCM4360 802.11ac Wireless Network Adapter"},
301//{PCI_VENDOR_ID_BROADCOM, 0x43a1, "BCM4360 802.11ac Wireless Network Adapter"},
302//{PCI_VENDOR_ID_BROADCOM, 0x43a2, "BCM4360 802.11ac Wireless Network Adapter"},
303//{PCI_VENDOR_ID_BROADCOM, 0x43a9, "BCM43217 802.11b/g/n"},
304//{PCI_VENDOR_ID_BROADCOM, 0x43aa, "BCM43131 802.11b/g/n"},
305//{PCI_VENDOR_ID_BROADCOM, 0x43b1, "BCM4352 802.11ac Wireless Network Adapter"},
306//{PCI_VENDOR_ID_BROADCOM, 0x43ba, "BCM43602 802.11ac Wireless LAN SoC"},
307//{PCI_VENDOR_ID_BROADCOM, 0x43bb, "BCM43602 802.11ac Wireless LAN SoC"},
308//{PCI_VENDOR_ID_BROADCOM, 0x43bc, "BCM43602 802.11ac Wireless LAN SoC"},
309//{PCI_VENDOR_ID_BROADCOM, 0x43d3, "BCM43567 802.11ac Wireless Network Adapter"},
310//{PCI_VENDOR_ID_BROADCOM, 0x43d9, "BCM43570 802.11ac Wireless Network Adapter"},
311//{PCI_VENDOR_ID_BROADCOM, 0x43df, "BCM4354 802.11ac Wireless LAN SoC"},
312//{PCI_VENDOR_ID_BROADCOM, 0x43ec, "BCM4356 802.11ac Wireless Network Adapter"},
313//{PCI_VENDOR_ID_BROADCOM, 0xa8d8, "BCM43224/5 Wireless Network Adapter"},
314
315// Atheros
316{PCI_VENDOR_ID_ATHEROS, 0x0020, "AR5513 802.11abg Wireless NIC"},
317{PCI_VENDOR_ID_ATHEROS, 0x0023, "AR5416 Wireless Network Adapter"},
318{PCI_VENDOR_ID_ATHEROS, 0x0024, "AR5418 Wireless Network Adapter"},
319{PCI_VENDOR_ID_ATHEROS, 0x0027, "AR9160 Wireless Network Adapter"},
320{PCI_VENDOR_ID_ATHEROS, 0x0029, "AR922X Wireless Network Adapter"},
321{PCI_VENDOR_ID_ATHEROS, 0x002A, "AR928X Wireless Network Adapter"}, // "pci168c,2a"
322{PCI_VENDOR_ID_ATHEROS, 0x002B, "AR9285 Wireless Network Adapter"},
323{PCI_VENDOR_ID_ATHEROS, 0x002C, "AR2427 Wireless Network Adapter"},
324{PCI_VENDOR_ID_ATHEROS, 0x002D, "AR9227 Wireless Network Adapter"},
325{PCI_VENDOR_ID_ATHEROS, 0x002E, "AR9287 Wireless Network Adapter"},
326{PCI_VENDOR_ID_ATHEROS, 0x0030, "AR93xx Wireless Network Adapter"},
327{PCI_VENDOR_ID_ATHEROS, 0x0032, "AR9485 Wireless Network Adapter"},
328{PCI_VENDOR_ID_ATHEROS, 0x0033, "AR9580 Wireless Network Adapter"},
329{PCI_VENDOR_ID_ATHEROS, 0x0034, "AR9462 Wireless Network Adapter"},
330{PCI_VENDOR_ID_ATHEROS, 0x0036, "AR9565 Wireless Network Adapter"},
331{PCI_VENDOR_ID_ATHEROS, 0x0037, "AR9485 Wireless Network Adapter"}
332};
333#define WLAN_DEVICES_LEN (sizeof(known_wifi_cards) / sizeof(known_wifi_cards[0]))
334
335char *get_ethernet_model(uint32_t vendor_id, uint32_t device_id)
336{
337static char desc[128];
338
339const char *name_format = NULL;
340int i;
341
342/* Get format for vendor ID */
343switch ( vendor_id )
344{
345case PCI_VENDOR_ID_REALTEK:
346name_format = "Realteck %s"; break;
347
348case PCI_VENDOR_ID_MARVELL:
349name_format = "Marvell %s"; break;
350
351case PCI_VENDOR_ID_JMICRON:
352name_format = "JMicron %s"; break;
353
354case PCI_VENDOR_ID_ATHEROS:
355case PCI_VENDOR_ID_QUALCOMM:
356name_format = "Atheros %s"; break;
357
358case PCI_VENDOR_ID_BROADCOM:
359name_format = "Broadcom %s"; break;
360
361case PCI_VENDOR_ID_INTEL:
362name_format = "Intel %s"; break;
363
364default:
365break;
366}
367
368for( i = 0 ; i < ETH_DEVICES_LEN; i++ )
369{
370if ( ( vendor_id == known_ethernet_cards[i].vendor_id ) && ( device_id == known_ethernet_cards[i].device_id ) )
371{
372snprintf( desc, sizeof(desc), name_format, known_ethernet_cards[i].model );
373return desc;
374}
375}
376// NOT in know table... assign generic
377/* Not in table */
378snprintf( desc, sizeof(desc), name_format, "Ethernet Controller" );
379return desc;
380}
381
382char *get_wlan_model(uint32_t vendor_id, uint32_t device_id)
383{
384
385static char desc[128];
386
387const char *name_format = NULL;
388int i;
389
390/* Get format for vendor ID */
391switch ( vendor_id )
392{
393case PCI_VENDOR_ID_REALTEK:
394name_format = "Realteck %s"; break;
395
396case PCI_VENDOR_ID_ATHEROS:
397case PCI_VENDOR_ID_QUALCOMM:
398name_format = "Atheros %s"; break;
399
400case PCI_VENDOR_ID_BROADCOM:
401name_format = "Broadcom %s"; break;
402
403default:
404break;
405}
406
407for( i = 0 ; i < WLAN_DEVICES_LEN; i++ )
408{
409if ( ( vendor_id == known_wifi_cards[i].vendor_id ) && ( device_id == known_wifi_cards[i].device_id ) )
410{
411snprintf( desc, sizeof(desc), name_format, known_wifi_cards[i].model );
412return desc;
413}
414}
415// NOT in know table... assign generic
416/* Not in table */
417snprintf( desc, sizeof(desc), name_format, "Wireless Controller" );
418return desc;
419}
420
421void setup_eth_devdrop(pci_dt_t *eth_dev)
422{
423char *devicepath = get_pci_dev_path(eth_dev);
424char *name_model = NULL;
425builtin = 0;
426
427bool do_eth_devprop = getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);
428
429DevPropDevice *device = (DevPropDevice *)malloc(sizeof(DevPropDevice));
430
431verbose("\tClass code: [%04x]\n", eth_dev->class_id);
432verbose("\tEthernetBuiltIn = %s\n", do_eth_devprop ? "Yes" : "No");
433
434if (!string)
435{
436string = devprop_create_string();
437if (!string)
438{
439return;
440}
441}
442
443device = devprop_add_device(string, devicepath);
444if(device)
445{
446name_model = get_ethernet_model(eth_dev->vendor_id, eth_dev->device_id);
447
448if ( do_eth_devprop )
449{
450verbose("\tLocation number: %d\n", location_number);
451verbose("\tSetting up lan keys\n");
452if( ( eth_dev->vendor_id != PCI_VENDOR_ID_ATHEROS ) && ( builtin_set == 0 ))
453{
454builtin_set = 1;
455builtin = 0x01;
456}
457
458devprop_add_value(device, "location", (uint8_t *)&location_number, 1);
459
460//devprop_add_value(device, "AAPL,slot-name", "Slot-x"
461//devprop_add_value(device, "device-id" 0xF6,,
462//devprop_add_value(device, "revision-id",
463//devprop_add_value(device, "subsystem-id",
464//devprop_add_value(device, "subsystem-vendor-id",
465
466devprop_add_value(device, "built-in", (uint8_t *)&builtin, 1);
467devprop_add_value(device, "model", (uint8_t *)name_model, (strlen(name_model) + 1));
468devprop_add_value(device, "device_type", (uint8_t *)"ethernet", sizeof("Ethernet"));
469
470stringdata = (uint8_t *)malloc(sizeof(uint8_t) * string->length);
471if(stringdata)
472{
473memcpy(stringdata, (uint8_t *)devprop_generate_string(string), string->length);
474stringlength = string->length;
475}
476
477}
478}
479
480verbose("\t%s [%04x:%04x]\n\t%s\n",name_model, eth_dev->vendor_id, eth_dev->device_id, devicepath);
481
482// location number
483location_number++;
484
485verbose("\n");
486}
487
488void setup_wifi_devdrop(pci_dt_t *wlan_dev) // ARPT
489{
490char *devicepath = get_pci_dev_path(wlan_dev);
491char *name_model = NULL;
492
493builtin = 0;
494
495bool do_wifi_devprop = getBoolForKey(kEnableWifi, &do_wifi_devprop, &bootInfo->chameleonConfig);
496
497DevPropDevice *device = (DevPropDevice *)malloc(sizeof(DevPropDevice));
498
499verbose("\tClass code: [%04x]\n", wlan_dev->class_id);
500verbose("\tEnableWifi = %s\n", do_wifi_devprop ? "Yes" : "No");
501
502if (!string)
503{
504string = devprop_create_string();
505if (!string)
506{
507return;
508}
509}
510
511device = devprop_add_device(string, devicepath);
512if(device)
513{
514name_model = get_wlan_model(wlan_dev->vendor_id, wlan_dev->device_id);
515
516if ( do_wifi_devprop )
517{
518verbose("\tSetting up wifi keys\n");
519devprop_add_value(device, "built-in", (uint8_t *)&builtin, 1);
520devprop_add_value(device, "model", (uint8_t *)name_model, (strlen(name_model) + 1));
521//devprop_add_value(device, "name", (uint8_t *)"AirPort Extreme", sizeof("AirPort Extreme"));
522
523//devprop_add_value(device, "vendor-id",
524//devprop_add_value(device, "device-id",
525//devprop_add_value(device, "subsystem-id",
526//devprop_add_value(device, "subsystem-vendor-id",
527// NOTE: I would set the subsystem id and subsystem vendor id here,
528// however, those values seem to be ovverriden in the boot process.
529// A better method would be injecting the DTGP dsdt method
530// and then injecting the subsystem id there.
531
532devprop_add_value(device, "device_type", (uint8_t *)"Airport", sizeof("Airport"));
533devprop_add_value(device, "AAPL,slot-name", (uint8_t *)"Airport", sizeof("Airport"));
534
535stringdata = (uint8_t *)malloc(sizeof(uint8_t) *string->length);
536if(stringdata)
537{
538memcpy(stringdata, (uint8_t *)devprop_generate_string(string), string->length);
539stringlength = string->length;
540}
541}
542}
543
544verbose("\t%s [%04x:%04x]\n\t%s\n", name_model, wlan_dev->vendor_id, wlan_dev->device_id, devicepath);
545verbose("\n");
546}
547

Archive Download this file

Revision: 2688