3 * - By John Hodge (thePowersGang)
8 #include <virtual_pci.h>
11 Uint32 VPCI_Read(tVPCI_Device *Dev, Uint8 Offset, Uint8 Size)
15 if( Size > 4 || Size == 3 || Size == 0 )
17 if( Offset & (Size - 1) )
22 case 0: // Vendor[0:15], Device[16:31]
23 tmp_dword = (Dev->Vendor) | (Dev->Device << 16);
25 // 1: Command[0:15], Status[16:31]
27 tmp_dword = Dev->Class;
29 // 3: Cache Line Size, Latency Timer, Header Type, BIST
30 case 4 ... 9: // 4-9: BARs
31 tmp_dword = Dev->BARs[ (Offset>>2) - 4 ];
33 // 10: Unused (Cardbus CIS Pointer)
34 // 11: Subsystem Vendor ID, Subsystem ID
35 // 12: Expansion ROM Address
36 // 13: Capabilities[0:8], Reserved[9:31]
38 // 15: Interrupt Line, Interrupt Pin, Min Grant, Max Latency
41 tmp_dword = Dev->Read(Dev->Ptr, Offset >> 2);
45 tmp_dword >>= 8*(Offset & 3);
49 case 2: tmp_dword &= 0xFFFF; break;
50 case 1: tmp_dword &= 0xFF;
56 void VPCI_Write(tVPCI_Device *Dev, Uint8 Offset, Uint8 Size, Uint32 Data)
59 if( Size > 4 || Size == 3 || Size == 0 )
61 if( Offset & (Size - 1) )
66 case 0: // Vendor / Device IDs
72 if( Size != 4 && Dev->Read )
73 tmp_dword = Dev->Read(Dev->Ptr, Offset>>2);
78 case 4: tmp_dword = 0; break;
80 tmp_dword &= ~(0xFFFF << ((Offset&2)*16));
84 tmp_dword &= ~(0xFF << ((Offset&3)*8));
88 tmp_dword |= Data << ((Offset&3)*8);
90 Dev->Write(Dev->Ptr, Offset>>2, tmp_dword);