00001
00002
00003
00004
00005
00006
00007
00008 #include <utility/ostream.h>
00009 #include <pci.h>
00010
00011 __USING_SYS
00012
00013 int main()
00014 {
00015 OStream cout;
00016
00017 cout << "PC_PCI test\n";
00018
00019 PC_PCI pci;
00020
00021 for(int bus = 0; bus <= Traits<PC_PCI>::MAX_BUS; bus++) {
00022 for(int dev_fn = 0; dev_fn <= Traits<PC_PCI>::MAX_DEV_FN; dev_fn++) {
00023 PC_PCI::Header hdr;
00024
00025 pci.header(PC_PCI::Locator(bus, dev_fn), &hdr);
00026 if(hdr) {
00027 cout << (int)bus << ":" << (dev_fn >> 3) << "." << (dev_fn & 7)
00028 << " Class " << hdr.class_id << " " << hdr.vendor_id
00029 << ":" << hdr.device_id
00030 << " (rev " << (int)hdr.revision_id
00031 << ")";
00032 for(int i = 0; i < PC_PCI::Region::N; i++)
00033 if(hdr.region[i].size)
00034 cout << " #" << i
00035 << "(" << (void *)hdr.region[i].phy_addr
00036 << "," << (void *)hdr.region[i].size << ")";
00037 cout << "\n";
00038 }
00039 }
00040 }
00041
00042 PC_PCI::Locator loc = pci.scan(32902, 28945, 0);
00043
00044 PC_PCI::Header hdr;
00045 pci.header(loc, &hdr);
00046 if(hdr) {
00047 cout << hdr.locator.bus << ":" << (hdr.locator.dev_fn >> 3)
00048 << "." << (hdr.locator.dev_fn & 7)
00049 << " Class " << hdr.class_id << " " << hdr.vendor_id
00050 << ":" << hdr.device_id
00051 << " (rev " << (int)hdr.revision_id
00052 << ")";
00053 for(int i = 0; i < 6; i++)
00054 if(hdr.region[i].size)
00055 cout << " #" << i
00056 << "(" << (void *)hdr.region[i].phy_addr
00057 << "," << (void *)hdr.region[i].size << ")";
00058 cout << "\n";
00059 }
00060
00061 cout << "Finish!\n";
00062
00063 return 0;
00064 }