|
@@ -60,8 +60,11 @@ int pci_find_capability ( struct pci_device *pci, int cap ) {
|
60
|
60
|
* function.
|
61
|
61
|
*/
|
62
|
62
|
unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ) {
|
|
63
|
+ uint16_t cmd;
|
63
|
64
|
uint32_t start, size;
|
64
|
65
|
|
|
66
|
+ /* Save the original command register */
|
|
67
|
+ pci_read_config_word ( pci, PCI_COMMAND, &cmd );
|
65
|
68
|
/* Save the original bar */
|
66
|
69
|
pci_read_config_dword ( pci, reg, &start );
|
67
|
70
|
/* Compute which bits can be set */
|
|
@@ -70,6 +73,8 @@ unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ) {
|
70
|
73
|
/* Restore the original size */
|
71
|
74
|
pci_write_config_dword ( pci, reg, start );
|
72
|
75
|
/* Find the significant bits */
|
|
76
|
+ /* Restore the original command register. This reenables decoding. */
|
|
77
|
+ pci_write_config_word ( pci, PCI_COMMAND, cmd );
|
73
|
78
|
if ( start & PCI_BASE_ADDRESS_SPACE_IO ) {
|
74
|
79
|
size &= PCI_BASE_ADDRESS_IO_MASK;
|
75
|
80
|
} else {
|