iPXE
pcibackup.c File Reference

PCI configuration space backup and restoration. More...

#include <stdint.h>
#include <ipxe/pci.h>
#include <ipxe/pcibackup.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int pci_backup_excluded (struct pci_device *pci, unsigned int offset, const uint8_t *exclude)
 Check PCI configuration space offset against exclusion list.
void pci_backup (struct pci_device *pci, struct pci_config_backup *backup, unsigned int limit, const uint8_t *exclude)
 Back up PCI configuration space.
void pci_restore (struct pci_device *pci, struct pci_config_backup *backup, unsigned int limit, const uint8_t *exclude)
 Restore PCI configuration space.

Detailed Description

PCI configuration space backup and restoration.

Definition in file pcibackup.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ pci_backup_excluded()

int pci_backup_excluded ( struct pci_device * pci,
unsigned int offset,
const uint8_t * exclude )
static

Check PCI configuration space offset against exclusion list.

Parameters
pciPCI device
offsetOffset within PCI configuration space
excludePCI configuration space backup exclusion list, or NULL

Definition at line 45 of file pcibackup.c.

46 {
47
48 if ( ! exclude )
49 return 0;
50 for ( ; *exclude != PCI_CONFIG_BACKUP_EXCLUDE_END ; exclude++ ) {
51 if ( offset == *exclude ) {
52 DBGC ( pci, "PCI %p skipping configuration offset "
53 "%02x\n", pci, offset );
54 return 1;
55 }
56 }
57 return 0;
58}
uint16_t offset
Offset to command line.
Definition bzimage.h:3
#define DBGC(...)
Definition compiler.h:505
#define PCI_CONFIG_BACKUP_EXCLUDE_END
PCI configuration space backup exclusion list end marker.
Definition pcibackup.h:27

References DBGC, offset, and PCI_CONFIG_BACKUP_EXCLUDE_END.

Referenced by pci_backup(), and pci_restore().

◆ 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 68 of file pcibackup.c.

69 {
70 unsigned int offset;
72
73 for ( offset = 0, dword = backup->dwords ; offset < limit ;
74 offset += sizeof ( *dword ) , dword++ ) {
75 if ( ! pci_backup_excluded ( pci, offset, exclude ) )
77 }
78}
unsigned int uint32_t
Definition stdint.h:12
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
uint16_t limit
Limit.
Definition librm.h:1
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:45
unsigned long int dword
Definition smc9000.h:40
uint32_t dwords[PCI_CONFIG_BACKUP_ALL/sizeof(uint32_t)]
Definition pcibackup.h:23

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 88 of file pcibackup.c.

89 {
90 unsigned int offset;
92
93 for ( offset = 0, dword = backup->dwords ; offset < limit ;
94 offset += sizeof ( *dword ) , dword++ ) {
95 if ( ! pci_backup_excluded ( pci, offset, exclude ) )
97 }
98}
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.

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().