Rev 1302 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1302 | Rev 1324 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /* |
1 | /* |
| 2 | * The PCI Library -- Generic Direct Access Functions |
2 | * The PCI Library -- Generic Direct Access Functions |
| 3 | * |
3 | * |
| 4 | * Copyright (c) 1997--2000 Martin Mares <mj@ucw.cz> |
4 | * Copyright (c) 1997--2000 Martin Mares <mj@ucw.cz> |
| 5 | * |
5 | * |
| 6 | * Modified and ported to HelenOS by Jakub Jermar. |
6 | * May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar. |
| 7 | * |
7 | * |
| 8 | * Can be freely distributed and used under the terms of the GNU GPL. |
8 | * Can be freely distributed and used under the terms of the GNU GPL. |
| 9 | */ |
9 | */ |
| 10 | 10 | ||
| 11 | #include <string.h> |
11 | #include <string.h> |
| Line 104... | Line 104... | ||
| 104 | cnt = 1; |
104 | cnt = 1; |
| 105 | break; |
105 | break; |
| 106 | } |
106 | } |
| 107 | if (cnt) { |
107 | if (cnt) { |
| 108 | for (i = 0; i < cnt; i++) { |
108 | for (i = 0; i < cnt; i++) { |
| 109 | u32 x = |
- | |
| 110 | pci_read_long(d, |
- | |
| 111 | PCI_BASE_ADDRESS_0 + |
109 | u32 x = pci_read_long(d, PCI_BASE_ADDRESS_0 + i * 4); |
| 112 | i * 4); |
- | |
| 113 | if (!x || x == (u32) ~ 0) |
110 | if (!x || x == (u32) ~ 0) |
| 114 | continue; |
111 | continue; |
| 115 | if ((x & PCI_BASE_ADDRESS_SPACE) == |
112 | if ((x & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) |
| 116 | PCI_BASE_ADDRESS_SPACE_IO) |
- | |
| 117 | d->base_addr[i] = x; |
113 | d->base_addr[i] = x; |
| 118 | else { |
114 | else { |
| 119 | if ((x & |
- | |
| 120 | PCI_BASE_ADDRESS_MEM_TYPE_MASK) |
115 | if ((x & PCI_BASE_ADDRESS_MEM_TYPE_MASK) != PCI_BASE_ADDRESS_MEM_TYPE_64) |
| 121 | != |
- | |
| 122 | PCI_BASE_ADDRESS_MEM_TYPE_64) |
- | |
| 123 | d->base_addr[i] = x; |
116 | d->base_addr[i] = x; |
| 124 | else if (i >= cnt - 1) |
117 | else if (i >= cnt - 1) |
| 125 | a->warning |
- | |
| 126 | ("%04x:%02x:%02x.%d: Invalid 64-bit address seen for BAR %d.", |
118 | a->warning("%04x:%02x:%02x.%d: Invalid 64-bit address seen for BAR %d.", |
| 127 | d->domain, d->bus, |
119 | d->domain, d->bus, |
| 128 | d->dev, d->func, i); |
120 | d->dev, d->func, i); |
| 129 | else { |
121 | else { |
| 130 | u32 y = |
- | |
| 131 | pci_read_long(d, |
- | |
| 132 | PCI_BASE_ADDRESS_0 |
122 | u32 y = pci_read_long(d, PCI_BASE_ADDRESS_0 + (++i) * 4); |
| 133 | + |
- | |
| 134 | (++i) * |
- | |
| 135 | 4); |
- | |
| 136 | #ifdef PCI_HAVE_64BIT_ADDRESS |
123 | #ifdef PCI_HAVE_64BIT_ADDRESS |
| 137 | d->base_addr[i - 1] = |
- | |
| 138 | x | (((pciaddr_t) y) << |
124 | d->base_addr[i - 1] = x | (((pciaddr_t) y) << 32); |
| 139 | 32); |
- | |
| 140 | #else |
125 | #else |
| 141 | if (y) |
126 | if (y) |
| 142 | a->warning |
- | |
| 143 | ("%04x:%02x:%02x.%d 64-bit device address ignored.", |
127 | a->warning("%04x:%02x:%02x.%d 64-bit device address ignored.", |
| 144 | d->domain, |
128 | d->domain, |
| 145 | d->bus, |
129 | d->bus, |
| 146 | d->dev, |
130 | d->dev, |
| 147 | d->func); |
131 | d->func); |
| 148 | else |
132 | else |
| 149 | d->base_addr[i - |
133 | d->base_addr[i - 1] = x; |
| 150 | 1] = |
- | |
| 151 | x; |
- | |
| 152 | #endif |
134 | #endif |
| 153 | } |
135 | } |
| 154 | } |
136 | } |
| 155 | } |
137 | } |
| 156 | } |
138 | } |
| Line 213... | Line 195... | ||
| 213 | return 1; |
195 | return 1; |
| 214 | } |
196 | } |
| 215 | 197 | ||
| 216 | int pci_generic_block_read(struct pci_dev *d, int pos, byte * buf, int len) |
198 | int pci_generic_block_read(struct pci_dev *d, int pos, byte * buf, int len) |
| 217 | { |
199 | { |
| 218 | return pci_generic_block_op(d, pos, buf, len, |
200 | return pci_generic_block_op(d, pos, buf, len, d->access->methods->read); |
| 219 | d->access->methods->read); |
- | |
| 220 | } |
201 | } |
| 221 | 202 | ||
| 222 | int pci_generic_block_write(struct pci_dev *d, int pos, byte * buf, int len) |
203 | int pci_generic_block_write(struct pci_dev *d, int pos, byte * buf, int len) |
| 223 | { |
204 | { |
| 224 | return pci_generic_block_op(d, pos, buf, len, |
205 | return pci_generic_block_op(d, pos, buf, len, d->access->methods->write); |
| 225 | d->access->methods->write); |
- | |
| 226 | } |
206 | } |