*
* @v pci PCI device
* @v backup PCI configuration space backup
+ * @v limit Maximum offset in PCI configuration space
* @v exclude PCI configuration space backup exclusion list, or NULL
*/
void pci_backup ( struct pci_device *pci, struct pci_config_backup *backup,
- const uint8_t *exclude ) {
+ unsigned int limit, const uint8_t *exclude ) {
unsigned int offset;
uint32_t *dword;
- for ( offset = 0, dword = backup->dwords ; offset < 0x100 ;
+ for ( offset = 0, dword = backup->dwords ; offset < limit ;
offset += sizeof ( *dword ) , dword++ ) {
if ( ! pci_backup_excluded ( pci, offset, exclude ) )
pci_read_config_dword ( pci, offset, dword );
*
* @v pci PCI device
* @v backup PCI configuration space backup
+ * @v limit Maximum offset in PCI configuration space
* @v exclude PCI configuration space backup exclusion list, or NULL
*/
void pci_restore ( struct pci_device *pci, struct pci_config_backup *backup,
- const uint8_t *exclude ) {
+ unsigned int limit, const uint8_t *exclude ) {
unsigned int offset;
uint32_t *dword;
- for ( offset = 0, dword = backup->dwords ; offset < 0x100 ;
+ for ( offset = 0, dword = backup->dwords ; offset < limit ;
offset += sizeof ( *dword ) , dword++ ) {
if ( ! pci_backup_excluded ( pci, offset, exclude ) )
pci_write_config_dword ( pci, offset, *dword );
unsigned int i;
/* Perform device reset and preserve PCI configuration */
- pci_backup ( pci, &backup, backup_exclude );
+ pci_backup ( pci, &backup, PCI_CONFIG_BACKUP_ALL, backup_exclude );
writel ( ARBEL_RESET_MAGIC,
( arbel->config + ARBEL_RESET_OFFSET ) );
for ( i = 0 ; i < ARBEL_RESET_WAIT_TIME_MS ; i++ ) {
if ( vendor != 0xffff )
break;
}
- pci_restore ( pci, &backup, backup_exclude );
+ pci_restore ( pci, &backup, PCI_CONFIG_BACKUP_ALL, backup_exclude );
}
/**
hermon->toggle = 0;
/* Perform device reset and preserve PCI configuration */
- pci_backup ( pci, &backup, backup_exclude );
+ pci_backup ( pci, &backup, PCI_CONFIG_BACKUP_ALL, backup_exclude );
writel ( HERMON_RESET_MAGIC,
( hermon->config + HERMON_RESET_OFFSET ) );
if ( vendor == pci->vendor ) {
/* Restore PCI configuration */
- pci_restore ( pci, &backup, backup_exclude );
+ pci_restore ( pci, &backup, PCI_CONFIG_BACKUP_ALL,
+ backup_exclude );
DBGC ( hermon, "Hermon %p reset after %dms\n",
hermon, i );
struct pci_config_backup backup;
/* Back up PCI configuration space */
- pci_backup ( pci, &backup, NULL );
+ pci_backup ( pci, &backup, PCI_CONFIG_BACKUP_ALL, NULL );
/* Assert reset */
memset ( &control, 0, sizeof ( control ) );
mdelay ( 1000 );
/* Restore PCI configuration space */
- pci_restore ( pci, &backup, NULL );
+ pci_restore ( pci, &backup, PCI_CONFIG_BACKUP_ALL, NULL );
}
/**
#include <stdint.h>
+/** Limit of PCI configuration space */
+#define PCI_CONFIG_BACKUP_ALL 0x100
+
+/** Limit of standard PCI configuration space */
+#define PCI_CONFIG_BACKUP_STANDARD 0x40
+
/** A PCI configuration space backup */
struct pci_config_backup {
- uint32_t dwords[64];
+ uint32_t dwords[ PCI_CONFIG_BACKUP_ALL / sizeof ( uint32_t ) ];
};
/** PCI configuration space backup exclusion list end marker */
extern void pci_backup ( struct pci_device *pci,
struct pci_config_backup *backup,
- const uint8_t *exclude );
+ unsigned int limit, const uint8_t *exclude );
extern void pci_restore ( struct pci_device *pci,
struct pci_config_backup *backup,
- const uint8_t *exclude );
+ unsigned int limit, const uint8_t *exclude );
#endif /* _IPXE_PCIBACKUP_H */