Rev 1896 | Rev 1912 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1896 | Rev 1897 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | #include <arch/memstr.h> |
39 | #include <arch/memstr.h> |
40 | #include <func.h> |
40 | #include <func.h> |
41 | #include <panic.h> |
41 | #include <panic.h> |
42 | #include <macros.h> |
42 | #include <macros.h> |
43 | 43 | ||
44 | #define PCI_SPACE_MASK 0x03000000 |
44 | #define PCI_SPACE_MASK 0x03000000 |
- | 45 | #define PCI_ABS_MASK 0x80000000 |
|
- | 46 | #define PCI_REG_MASK 0x000000ff |
|
45 | 47 | ||
46 | bool ofw_pci_apply_ranges(ofw_tree_node_t *node, ofw_pci_reg_t *reg, uintptr_t *pa) |
48 | bool ofw_pci_apply_ranges(ofw_tree_node_t *node, ofw_pci_reg_t *reg, uintptr_t *pa) |
47 | { |
49 | { |
48 | ofw_tree_property_t *prop; |
50 | ofw_tree_property_t *prop; |
49 | ofw_pci_range_t *range; |
51 | ofw_pci_range_t *range; |
Line 71... | Line 73... | ||
71 | } |
73 | } |
72 | 74 | ||
73 | return false; |
75 | return false; |
74 | } |
76 | } |
75 | 77 | ||
- | 78 | bool ofw_pci_reg_absolutize(ofw_tree_node_t *node, ofw_pci_reg_t *reg, ofw_pci_reg_t *out) |
|
- | 79 | { |
|
- | 80 | if (reg->space & PCI_ABS_MASK) { |
|
- | 81 | /* already absolute */ |
|
- | 82 | out->space = reg->space; |
|
- | 83 | out->addr = reg->addr; |
|
- | 84 | out->size = reg->size; |
|
- | 85 | return true; |
|
- | 86 | } |
|
- | 87 | ||
- | 88 | ofw_tree_property_t *prop; |
|
- | 89 | ofw_pci_reg_t *assigned_address; |
|
- | 90 | count_t assigned_addresses; |
|
- | 91 | ||
- | 92 | prop = ofw_tree_getprop(node, "assigned-addresses"); |
|
- | 93 | if (!prop) |
|
- | 94 | panic("Can't find \"assigned-addresses\" property.\n"); |
|
- | 95 | ||
- | 96 | assigned_addresses = prop->size / sizeof(ofw_pci_reg_t); |
|
- | 97 | assigned_address = prop->value; |
|
- | 98 | ||
- | 99 | int i; |
|
- | 100 | ||
- | 101 | for (i = 0; i < assigned_addresses; i++) { |
|
- | 102 | if ((assigned_address[i].space & PCI_REG_MASK) == (reg->space & PCI_REG_MASK)) { |
|
- | 103 | out->space = assigned_address[i].space; |
|
- | 104 | out->addr = reg->addr + assigned_address[i].addr; |
|
- | 105 | out->size = reg->size; |
|
- | 106 | return true; |
|
- | 107 | } |
|
- | 108 | } |
|
- | 109 | ||
- | 110 | return false; |
|
- | 111 | } |
|
- | 112 | ||
76 | /** @} |
113 | /** @} |
77 | */ |
114 | */ |