| 170 | } |
| 171 | |
| 172 | void Intel8254x::InitializeRx(){ |
| 173 | uint64_t rxDescPhys = Memory::AllocatePhysicalMemoryBlock(); // The card wants a physical address |
| 174 | rxDescriptors = (r_desc_t*)Memory::GetIOMapping(rxDescPhys); |
| 175 | uint32_t rxLow = rxDescPhys & 0xFFFFFFFF; |
| 176 | uint32_t rxHigh = rxDescPhys >> 32; |
| 177 | uint32_t rxLen = 4096; // Memory block size |
| 178 | uint32_t rxHead = 0; |
| 179 | uint32_t _rxTail = RX_DESC_COUNT; // Offset from base |
| 180 | |
| 181 | rxDescriptorsVirt = (void**)kmalloc(RX_DESC_COUNT * sizeof(void*)); |
| 182 | |
| 183 | WriteMem32(I8254_REGISTER_RDESC_LO, rxLow); |
| 184 | WriteMem32(I8254_REGISTER_RDESC_HI, rxHigh); |
| 185 | WriteMem32(I8254_REGISTER_RDESC_LEN, rxLen); |
| 186 | WriteMem32(I8254_REGISTER_RDESC_HEAD, rxHead); |
| 187 | WriteMem32(I8254_REGISTER_RDESC_TAIL, _rxTail); |
| 188 | |
| 189 | for(int i = 0; i < RX_DESC_COUNT; i++){ |
| 190 | r_desc_t* rxd = &rxDescriptors[i]; |
| 191 | uint64_t phys = Memory::AllocatePhysicalMemoryBlock(); |
| 192 | rxd->addr = phys; |
| 193 | rxd->status = 0; |
| 194 | |
| 195 | rxDescriptorsVirt[i] = Memory::KernelAllocate4KPages(1); |
| 196 | Memory::KernelMapVirtualMemory4K(phys, (uintptr_t)rxDescriptorsVirt[i], 1); |
| 197 | } |
| 198 | |
| 199 | WriteMem32(I8254_REGISTER_TCTRL, (TCTRL_ENABLE | TCTRL_PSP)); |
| 200 | } |
| 201 | |
| 202 | void Intel8254x::InitializeTx(){ |
| 203 | uint64_t txDescPhys = Memory::AllocatePhysicalMemoryBlock(); // The card wants a physical address |
nothing calls this directly
no test coverage detected