| 230 | } |
| 231 | |
| 232 | Intel8254x::Intel8254x(PCIDevice& device) : pciDevice(device){ |
| 233 | assert(device.vendorID != 0xFFFF); |
| 234 | |
| 235 | txTail = rxTail = 0; |
| 236 | |
| 237 | memBase = device.GetBaseAddressRegister(0); |
| 238 | |
| 239 | if(device.BarIsIOPort(1)) { |
| 240 | ioBase = device.GetBaseAddressRegister(1); |
| 241 | } else if(device.BarIsIOPort(2)) { |
| 242 | ioBase = device.GetBaseAddressRegister(2); |
| 243 | } |
| 244 | |
| 245 | memBaseVirt = (void*)Memory::GetIOMapping(memBase); |
| 246 | hasEEPROM = CheckForEEPROM(); |
| 247 | |
| 248 | Log::Info("[i8254x] Base Address: %x, Base Address (virtual): %x, IO Base: %x, EEPROM Present: %s, Base Address 1: %x, Base Address 2: %x", device.GetBaseAddressRegister(0), memBaseVirt, ioBase, (hasEEPROM ? "true" : "false"), device.GetBaseAddressRegister(1), device.GetBaseAddressRegister(2)); |
| 249 | |
| 250 | if(!hasEEPROM){ |
| 251 | Log::Error("[i8254x] No EEPROM Present!"); |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | int irqNum = device.AllocateVector(PCIVectors::PCIVectorAny); |
| 256 | Log::Write(",IRQ: "); |
| 257 | Log::Write(irqNum); |
| 258 | IDT::RegisterInterruptHandler(irqNum, reinterpret_cast<isr_t>(&Intel8254x::InterruptHandler), this); |
| 259 | |
| 260 | uint8_t macAddr[6]; |
| 261 | |
| 262 | pciDevice.EnableBusMastering(); |
| 263 | |
| 264 | uint32_t t; |
| 265 | t = ReadEEPROM(0); |
| 266 | macAddr[0] = t & 0xFF; |
| 267 | macAddr[1] = t >> 8; |
| 268 | t = ReadEEPROM(1); |
| 269 | macAddr[2] = t & 0xFF; |
| 270 | macAddr[3] = t >> 8; |
| 271 | t = ReadEEPROM(2); |
| 272 | macAddr[4] = t & 0xFF; |
| 273 | macAddr[5] = t >> 8; |
| 274 | |
| 275 | Log::Write(", MAC Address: "); |
| 276 | Log::Write(macAddr[0]); |
| 277 | Log::Write(":"); |
| 278 | Log::Write(macAddr[1]); |
| 279 | Log::Write(":"); |
| 280 | Log::Write(macAddr[2]); |
| 281 | Log::Write(":"); |
| 282 | Log::Write(macAddr[3]); |
| 283 | Log::Write(":"); |
| 284 | Log::Write(macAddr[4]); |
| 285 | Log::Write(":"); |
| 286 | Log::Write(macAddr[5]); |
| 287 | |
| 288 | mac = macAddr; |
| 289 |
nothing calls this directly
no test coverage detected