1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2% Copyright (c) 2009, 2011, ETH Zurich. 3% All rights reserved. 4% 5% This file is distributed under the terms in the attached LICENSE file. 6% If you do not find this file, copies can be found by writing to: 7% ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11% query the current physical address of a BAR of a given device 12%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 14pci_physical_address(Bus,Dev,Fun,Vendor,DeviceID,Class,SubClass,ProgIf,BAR,Base,High,Size) :- 15 device(_,addr(Bus,Dev,Fun),Vendor,DeviceID, Class, SubClass, ProgIf,_), 16 currentbar(addr(Bus,Dev,Fun),BAR,Base,High,Size). 17 18 19%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20% get the list of implemented BARs for a given device 21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 23pci_get_implemented_bars(Bus,Device,Function,BAR, BARList) :- 24 findall(BAR, bar(addr(Bus,Device,Function),BAR,_,_,_,_,_), BARList). 25 26 27%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28% get the current physical address of all implemented BARs of the given device 29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 31pci_get_implemented_BAR_addresses(Bus,Dev,Fun,Vendor,DeviceID,Class,SubClass,ProgIf,BARAddrList) :- 32 findall(baraddr(BAR,Base,High,Size), 33 pci_physical_address(Bus,Dev,Fun,Vendor,DeviceID,Class,SubClass,ProgIf,BAR,Base,High,Size), 34 BARAddrListUnsorted), 35 % need to pass the BAR addresses in increasing BAR number/index, 36 % because the drivers expect them in this order. A explicit 37 % number transferred over the IDC msg mybe be better. 38 sort(1, =<, BARAddrListUnsorted, BARAddrList). 39 40 41%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 42% Retrieves the addresses of the devices present on this platform to add to 43% the VT-d identity domain 44%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45 46find_devices(DevList) :- findall(address(Type,Bus,Dev,Func), 47 device(Type,addr(Bus,Dev,Func),_,_,_,_,_,_), 48 DevList). 49 50 51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 52% Retrieves the addresses of PCIe-to-PCIe bridges present on this platform 53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54 55pcie_bridges(DevList) :- findall(address(Bus,Dev,Func), 56 bridge(pcie,addr(Bus,Dev,Func),_,_,_,_,_,_), 57 DevList). 58 59 60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 61% Retrieves the addresses of devices reported in DMAR translation structures 62%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 63 64dmar_devices(DevList) :- findall(address(Seg,Bus,Dev,Func), 65 dmar_device(_,_,_,addr(Seg,Bus,Dev,Func),_), 66 DevList). 67