2 * Arbitrary PCI space reader/writer utility
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.
14 int main(int argc, char **argv)
16 unsigned int bus, dev, fn, addr;
17 unsigned char type = 'b';
26 if ((argc < 5) || (argc > 7))
29 printf("usage: %s bus dev fn addr [b|w|l [datum]]\n", argv[0]);
33 bus = strtoul(argv[1], NULL, 0);
34 dev = strtoul(argv[2], NULL, 0);
35 fn = strtoul(argv[3], NULL, 0);
36 addr = strtoul(argv[4], NULL, 0);
43 datum = strtoul(argv[6], NULL, 0);
48 pci_write8(bus, dev, fn, addr, datum);
49 printf("Wrote byte 0x%02x to %02x:%02x.%x[%02x]\n", datum, bus, dev, fn, addr);
53 pci_write16(bus, dev, fn, addr, datum);
54 printf("Wrote word 0x%04x to %02x:%02x.%x[%02x]\n", datum, bus, dev, fn, addr);
57 pci_write32(bus, dev, fn, addr, datum);
58 printf("Wrote long 0x%08x to %02x:%02x.%x[%02x]\n", datum, bus, dev, fn, addr);
67 datum = pci_read8(bus, dev, fn, addr);
68 printf("Read byte 0x%02x from %02x:%02x.%x[%02x]\n", datum, bus, dev, fn, addr);
71 datum = pci_read16(bus, dev, fn, addr);
72 printf("Read word 0x%04x from %02x:%02x.%x[%02x]\n", datum, bus, dev, fn, addr);
75 datum = pci_read32(bus, dev, fn, addr);
76 printf("Read long 0x%08x from %02x:%02x.%x[%02x]\n", datum, bus, dev, fn, addr);