1 [IFDEF] CONFIG_DRIVER_PCI
3 : pci-addr-encode ( addr.lo addr.mi addr.hi )
10 : pci-len-encode ( len.lo len.hi )
12 rot encode-int encode+
15 \ Get region offset for BAR reg
16 : pci-bar-offset@ ( bar-reg -- off.lo off.hi -1 | 0 )
17 " reg" active-package get-package-property 0= if
19 decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi )
26 \ Drop the size as we don't need it
27 decode-int drop decode-int drop
37 \ Get region size for BAR reg
38 : pci-bar-size@ ( bar-reg -- size )
39 " reg" active-package get-package-property 0= if
41 decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi )
54 0 \ default size of 0 if BAR not found
58 \ Get base address for configured BAR reg
59 : pci-bar-base@ ( bar-reg -- addr.lo addr.hi -1 | 0 )
60 " assigned-addresses" active-package get-package-property 0= if
62 decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi )
69 \ Drop the size as we don't need it
70 decode-int drop decode-int drop
80 \ Get PCI bus address and size for configured BAR reg
81 : pci-bar>pci-region ( bar-reg -- addr.lo addr.hi size )
84 swap r@ pci-bar-base@ if