Add support functions for capturing and restoring PCI configuration

registers for power management code.
This commit is contained in:
jmcneill 2005-01-26 21:49:00 +00:00
parent 109219993b
commit 9c40186bce
2 changed files with 33 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci.c,v 1.89 2004/09/13 12:22:52 drochner Exp $ */
/* $NetBSD: pci.c,v 1.90 2005/01/26 21:49:00 jmcneill Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.89 2004/09/13 12:22:52 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.90 2005/01/26 21:49:00 jmcneill Exp $");
#include "opt_pci.h"
@ -700,3 +700,27 @@ pci_dma64_available(struct pci_attach_args *pa)
#endif
return 0;
}
void
pci_conf_capture(pci_chipset_tag_t pc, pcitag_t tag,
struct pci_conf_state *pcs)
{
int off;
for (off = 0; off < 16; off++)
pcs->reg[off] = pci_conf_read(pc, tag, (off * 4));
return;
}
void
pci_conf_restore(pci_chipset_tag_t pc, pcitag_t tag,
struct pci_conf_state *pcs)
{
int off;
for (off = 0; off < 16; off++)
pci_conf_write(pc, tag, (off * 4), pcs->reg[off]);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcivar.h,v 1.67 2004/09/13 12:22:53 drochner Exp $ */
/* $NetBSD: pcivar.h,v 1.68 2005/01/26 21:49:00 jmcneill Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -171,6 +171,10 @@ struct pci_softc {
#define PCI_SC_DEVICESC(d, f) sc_devices[(d) * 8 + (f)]
};
struct pci_conf_state {
pcireg_t reg[16];
};
extern struct cfdriver pci_cd;
int pcibusprint(void *, const char *);
@ -232,7 +236,8 @@ const char *pci_findproduct __P((pcireg_t));
int pci_find_device(struct pci_attach_args *pa,
int (*match)(struct pci_attach_args *));
int pci_dma64_available(struct pci_attach_args *);
void pci_conf_capture(pci_chipset_tag_t, pcitag_t, struct pci_conf_state *);
void pci_conf_restore(pci_chipset_tag_t, pcitag_t, struct pci_conf_state *);
#endif /* _KERNEL */