3 * NetWatch system management mode administration console
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
12 #include <pci-bother.h>
16 unsigned short origstate;
17 unsigned long origbars[6];
20 static struct pci_bother bothers[MAX_BOTHERS];
21 static int nbothers = 0;
23 int pci_bother_add(pci_dev_t *dev)
27 if (nbothers == MAX_BOTHERS)
30 bothers[nbothers].bus = dev->bus;
31 bothers[nbothers].dev = dev->dev;
32 bothers[nbothers].fn = dev->fn;
34 bothers[nbothers].origstate = pci_read16(dev->bus, dev->dev, dev->fn, 0x04);
35 for (i = 0; i < 6; i++)
36 bothers[nbothers].origbars[i] = pci_read32(dev->bus, dev->dev, dev->fn, 0x10 + i * 4);
47 for (i = 0; i < nbothers; i++)
49 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, 0x0);
50 for (j = 0; j < 6; j++)
51 pci_write32(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x10 + j * 4, 0);
55 void pci_unbother_all()
59 for (i = 0; i < nbothers; i++)
61 pci_write16(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x04, bothers[i].origstate);
62 for (j = 0; j < 6; j++)
63 pci_write32(bothers[i].bus, bothers[i].dev, bothers[i].fn, 0x10 + j * 4, bothers[i].origbars[j]);