iPXE
Data Structures | Macros | Functions
pcibackup.h File Reference

PCI configuration space backup and restoration. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  pci_config_backup
 A PCI configuration space backup. More...
 

Macros

#define PCI_CONFIG_BACKUP_ALL   0x100
 Limit of PCI configuration space. More...
 
#define PCI_CONFIG_BACKUP_STANDARD   0x40
 Limit of standard PCI configuration space. More...
 
#define PCI_CONFIG_BACKUP_EXCLUDE_END   0xff
 PCI configuration space backup exclusion list end marker. More...
 
#define PCI_CONFIG_BACKUP_EXCLUDE(...)   { __VA_ARGS__, PCI_CONFIG_BACKUP_EXCLUDE_END }
 Define a PCI configuration space backup exclusion list. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void pci_backup (struct pci_device *pci, struct pci_config_backup *backup, unsigned int limit, const uint8_t *exclude)
 Back up PCI configuration space. More...
 
void pci_restore (struct pci_device *pci, struct pci_config_backup *backup, unsigned int limit, const uint8_t *exclude)
 Restore PCI configuration space. More...
 

Detailed Description

PCI configuration space backup and restoration.

Definition in file pcibackup.h.

Macro Definition Documentation

◆ PCI_CONFIG_BACKUP_ALL

#define PCI_CONFIG_BACKUP_ALL   0x100

Limit of PCI configuration space.

Definition at line 15 of file pcibackup.h.

◆ PCI_CONFIG_BACKUP_STANDARD

#define PCI_CONFIG_BACKUP_STANDARD   0x40

Limit of standard PCI configuration space.

Definition at line 18 of file pcibackup.h.

◆ PCI_CONFIG_BACKUP_EXCLUDE_END

#define PCI_CONFIG_BACKUP_EXCLUDE_END   0xff

PCI configuration space backup exclusion list end marker.

Definition at line 26 of file pcibackup.h.

◆ PCI_CONFIG_BACKUP_EXCLUDE

#define PCI_CONFIG_BACKUP_EXCLUDE (   ...)    { __VA_ARGS__, PCI_CONFIG_BACKUP_EXCLUDE_END }

Define a PCI configuration space backup exclusion list.

Definition at line 29 of file pcibackup.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pci_backup()

void pci_backup ( struct pci_device pci,
struct pci_config_backup backup,
unsigned int  limit,
const uint8_t exclude 
)

Back up PCI configuration space.

Parameters
pciPCI device
backupPCI configuration space backup
limitMaximum offset in PCI configuration space
excludePCI configuration space backup exclusion list, or NULL

Definition at line 67 of file pcibackup.c.

68  {
69  unsigned int offset;
70  uint32_t *dword;
71 
72  for ( offset = 0, dword = backup->dwords ; offset < limit ;
73  offset += sizeof ( *dword ) , dword++ ) {
74  if ( ! pci_backup_excluded ( pci, offset, exclude ) )
76  }
77 }
uint32_t dwords[PCI_CONFIG_BACKUP_ALL/sizeof(uint32_t)]
Definition: pcibackup.h:22
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
uint16_t limit
Limit.
Definition: librm.h:250
unsigned int uint32_t
Definition: stdint.h:12
unsigned long int dword
Definition: smc9000.h:40
static int pci_backup_excluded(struct pci_device *pci, unsigned int offset, const uint8_t *exclude)
Check PCI configuration space offset against exclusion list.
Definition: pcibackup.c:44

References pci_config_backup::dwords, limit, offset, pci_backup_excluded(), and pci_read_config_dword().

Referenced by arbel_reset(), hermon_reset(), pci_reset(), and qib7322_reset().

◆ pci_restore()

void pci_restore ( struct pci_device pci,
struct pci_config_backup backup,
unsigned int  limit,
const uint8_t exclude 
)

Restore PCI configuration space.

Parameters
pciPCI device
backupPCI configuration space backup
limitMaximum offset in PCI configuration space
excludePCI configuration space backup exclusion list, or NULL

Definition at line 87 of file pcibackup.c.

88  {
89  unsigned int offset;
90  uint32_t *dword;
91 
92  for ( offset = 0, dword = backup->dwords ; offset < limit ;
93  offset += sizeof ( *dword ) , dword++ ) {
94  if ( ! pci_backup_excluded ( pci, offset, exclude ) )
96  }
97 }
uint32_t dwords[PCI_CONFIG_BACKUP_ALL/sizeof(uint32_t)]
Definition: pcibackup.h:22
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
uint16_t limit
Limit.
Definition: librm.h:250
unsigned int uint32_t
Definition: stdint.h:12
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
unsigned long int dword
Definition: smc9000.h:40
static int pci_backup_excluded(struct pci_device *pci, unsigned int offset, const uint8_t *exclude)
Check PCI configuration space offset against exclusion list.
Definition: pcibackup.c:44

References pci_config_backup::dwords, limit, offset, pci_backup_excluded(), and pci_write_config_dword().

Referenced by arbel_reset(), hermon_reset(), pci_reset(), and qib7322_reset().