2018-11-08 22:12:51 +01:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* COS2000 - Compatible Operating System - LGPL v3 - Hord<72> Nicolas */
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
#include "asm.h"
|
|
|
|
|
#include "types.h"
|
|
|
|
|
#include "pci.h"
|
|
|
|
|
|
|
|
|
|
#define MAX_BUS_SCAN 256
|
|
|
|
|
#define MAX_DEVICE_SCAN 32
|
|
|
|
|
#define MAX_FUNCTION_SCAN 8
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2018-11-09 16:44:56 +01:00
|
|
|
|
/* R<>cup<75>re les identifiants vendeur / periph<70>rique du periph<70>rique PCI donn<6E>e */
|
2018-11-08 22:12:51 +01:00
|
|
|
|
|
2018-11-09 16:44:56 +01:00
|
|
|
|
pcidev getPCImininfo(const u8 bus, const u8 dev, const u8 function)
|
2018-11-08 22:12:51 +01:00
|
|
|
|
{
|
|
|
|
|
pcidev result;
|
2018-11-09 16:44:56 +01:00
|
|
|
|
if ((result.vendor = pciConfigReadWord(bus,dev,function,0x0)) != 0xFFFF) {
|
|
|
|
|
result.device = pciConfigReadWord(bus,dev,function,0x2);
|
|
|
|
|
}
|
2018-11-08 22:12:51 +01:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-09 16:44:56 +01:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* R<>cup<75>re les informations sur le periph<70>rique PCI donn<6E>e */
|
|
|
|
|
|
|
|
|
|
u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function, const u8 offset)
|
|
|
|
|
{
|
|
|
|
|
u16 tmp = 0;
|
|
|
|
|
u32 addr = (0x80000000|(bus << 16)|(dev << 11)|(function << 8)|(offset & 0xFC));
|
|
|
|
|
outd(0xCF8, addr);
|
|
|
|
|
tmp = (u16)((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 22:12:51 +01:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Scan le bus PCI et affiche les p<>riph<70>riques */
|
|
|
|
|
|
|
|
|
|
void scanPCI(void)
|
|
|
|
|
{
|
2018-11-09 16:44:56 +01:00
|
|
|
|
u16 bus,device,function;
|
2018-11-08 22:12:51 +01:00
|
|
|
|
pcidev result;
|
|
|
|
|
for (bus=0; bus<MAX_BUS_SCAN; ++bus)
|
|
|
|
|
for (device=0; device<MAX_DEVICE_SCAN; ++device)
|
|
|
|
|
for (function=0; function<MAX_FUNCTION_SCAN; ++function)
|
|
|
|
|
{
|
2018-11-09 16:44:56 +01:00
|
|
|
|
result = getPCImininfo(bus,device,function);
|
|
|
|
|
if (result.vendor != 0xFFFF)
|
|
|
|
|
printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx\r\n",bus, device, function, result.vendor, result.device);
|
2018-11-08 22:12:51 +01:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|