mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Mapping only MCFG according to it size and not maximum
This commit is contained in:
parent
c817e97ae4
commit
50041a8bed
@ -77,6 +77,7 @@ struct PciDev_t {
|
|||||||
void IoInitPCI();
|
void IoInitPCI();
|
||||||
void IoPciEnumerate();
|
void IoPciEnumerate();
|
||||||
PciDev_t *IoPciGetDevice(ushort vendorID, ushort deviceID);
|
PciDev_t *IoPciGetDevice(ushort vendorID, ushort deviceID);
|
||||||
|
PciDev_t *IoPciGetDeviceByClass(uchar classID, uchar subclassID);
|
||||||
|
|
||||||
uchar IoPciReadConfigByte(PciDev_t *device, ushort offset);
|
uchar IoPciReadConfigByte(PciDev_t *device, ushort offset);
|
||||||
ushort IoPciReadConfigWord(PciDev_t *device, ushort offset);
|
ushort IoPciReadConfigWord(PciDev_t *device, ushort offset);
|
||||||
|
@ -141,6 +141,34 @@ PciDev_t *IoPciGetDevice(ushort vendorID, ushort deviceID)
|
|||||||
PciDev_t *pciDevicePtr = (PciDev_t *)malloc(sizeof(PciDev_t));
|
PciDev_t *pciDevicePtr = (PciDev_t *)malloc(sizeof(PciDev_t));
|
||||||
pciDevicePtr->vendorID = vendorID;
|
pciDevicePtr->vendorID = vendorID;
|
||||||
pciDevicePtr->deviceID = deviceID;
|
pciDevicePtr->deviceID = deviceID;
|
||||||
|
pciDevicePtr->classID = pciReadConfigByte((uchar)bus, device, function, PCI_REG_CLASS);
|
||||||
|
pciDevicePtr->subclassID = pciReadConfigByte((uchar)bus, device, function, PCI_REG_SUBCLASS);
|
||||||
|
pciDevicePtr->configAddr = pciGetConfigAddr((uchar)bus, device, function, 0);
|
||||||
|
return pciDevicePtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PciDev_t *IoPciGetDeviceByClass(uchar classID, uchar subclassID)
|
||||||
|
{
|
||||||
|
if(pciConfigBaseAddress == NULL) {
|
||||||
|
KeStartPanic("Unable to access PCI configuration : MCFG table not reachable\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ushort bus = 0; bus < 256; bus++) {
|
||||||
|
for(uchar device = 0; device < 32; device++) {
|
||||||
|
for(uchar function = 0; function < 8; function++) {
|
||||||
|
if(classID == pciReadConfigByte((uchar)bus, device, function, PCI_REG_CLASS)
|
||||||
|
&& subclassID == pciReadConfigByte((uchar)bus, device, function, PCI_REG_SUBCLASS)) {
|
||||||
|
PciDev_t *pciDevicePtr = (PciDev_t *)malloc(sizeof(PciDev_t));
|
||||||
|
pciDevicePtr->vendorID = pciReadConfigWord((uchar)bus, device, function, PCI_REG_VENDOR);
|
||||||
|
pciDevicePtr->deviceID = pciReadConfigWord((uchar)bus, device, function, PCI_REG_DEVICE);
|
||||||
|
pciDevicePtr->classID = classID;
|
||||||
|
pciDevicePtr->subclassID = subclassID;
|
||||||
pciDevicePtr->configAddr = pciGetConfigAddr((uchar)bus, device, function, 0);
|
pciDevicePtr->configAddr = pciGetConfigAddr((uchar)bus, device, function, 0);
|
||||||
return pciDevicePtr;
|
return pciDevicePtr;
|
||||||
}
|
}
|
||||||
@ -160,9 +188,11 @@ void IoInitPCI()
|
|||||||
DebugLog("PCI Config Base address = 0x%p\n", pciConfigBaseAddress);
|
DebugLog("PCI Config Base address = 0x%p\n", pciConfigBaseAddress);
|
||||||
|
|
||||||
// Give R/W access to the configuration space
|
// Give R/W access to the configuration space
|
||||||
int maxI = (256 * 32 * 8 * 4096) / KPAGESIZE;
|
int maxI = (MCFG_table->length) / KPAGESIZE; // More secure,
|
||||||
for(int i=0; i < maxI; i++)
|
for(int i=0; i < maxI; i++)
|
||||||
{
|
{
|
||||||
|
// XXX verify that page is marked busy
|
||||||
|
|
||||||
MmMapPage((void *)((ulong)pciConfigBaseAddress + i * KPAGESIZE),
|
MmMapPage((void *)((ulong)pciConfigBaseAddress + i * KPAGESIZE),
|
||||||
(void *)((ulong)pciConfigBaseAddress + i * KPAGESIZE),
|
(void *)((ulong)pciConfigBaseAddress + i * KPAGESIZE),
|
||||||
PRESENT | READWRITE);
|
PRESENT | READWRITE);
|
||||||
|
Loading…
Reference in New Issue
Block a user