| 200 | } |
| 201 | |
| 202 | void Intel8254x::InitializeTx(){ |
| 203 | uint64_t txDescPhys = Memory::AllocatePhysicalMemoryBlock(); // The card wants a physical address |
| 204 | txDescriptors = (t_desc_t*)Memory::GetIOMapping(txDescPhys); |
| 205 | uint32_t txLow = txDescPhys & 0xFFFFFFFF; |
| 206 | uint32_t txHigh = txDescPhys >> 32; |
| 207 | uint32_t txLen = 4096; // Memory block size |
| 208 | uint32_t txHead = 0; |
| 209 | uint32_t _txTail = RX_DESC_COUNT; // Offset from base |
| 210 | |
| 211 | txDescriptorsVirt = (void**)kmalloc(TX_DESC_COUNT * sizeof(void*)); |
| 212 | |
| 213 | WriteMem32(I8254_REGISTER_TDESC_LO, txLow); |
| 214 | WriteMem32(I8254_REGISTER_TDESC_HI, txHigh); |
| 215 | WriteMem32(I8254_REGISTER_TDESC_LEN, txLen); |
| 216 | WriteMem32(I8254_REGISTER_TDESC_HEAD, txHead); |
| 217 | WriteMem32(I8254_REGISTER_TDESC_TAIL, _txTail); |
| 218 | |
| 219 | for(int i = 0; i < TX_DESC_COUNT; i++){ |
| 220 | t_desc_t* txd = &txDescriptors[i]; |
| 221 | uint64_t phys = Memory::AllocatePhysicalMemoryBlock(); |
| 222 | txd->addr = phys; |
| 223 | txd->status = 0; |
| 224 | |
| 225 | txDescriptorsVirt[i] = Memory::KernelAllocate4KPages(1); |
| 226 | Memory::KernelMapVirtualMemory4K(phys, (uintptr_t)txDescriptorsVirt[i], 1); |
| 227 | } |
| 228 | |
| 229 | WriteMem32(I8254_REGISTER_RCTRL, (RCTRL_ENABLE | RCTRL_SBP | RCTRL_UPE | RCTRL_MPE | RCTRL_LPE | RCTRL_BAM | RCTRL_SECRC | BSIZE_4096)); |
| 230 | } |
| 231 | |
| 232 | Intel8254x::Intel8254x(PCIDevice& device) : pciDevice(device){ |
| 233 | assert(device.vendorID != 0xFFFF); |
nothing calls this directly
no test coverage detected