]> Joshua Wise's Git repositories - netwatch.git/blame - pci/pci-raw.c
More ICH2-specific code diked out.
[netwatch.git] / pci / pci-raw.c
CommitLineData
98e930a2
JP
1/* pci-raw.c
2 * Raw PCI implementation
3 * NetWatch system management mode administration console
4 *
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.
8 *
9 */
10
035d7af7 11#include <io.h>
7e16b8e6 12#include <stdint.h>
81148fa1 13#include <pci.h>
035d7af7
JW
14
15static void __pci_config(int bus, int slot, int fn, int addr)
16{
c2e34447 17 outl(0xCF8, 0x80000000ULL | (bus << 16) | (slot << 11) | (fn << 8) | (addr & ~3));
035d7af7
JW
18}
19
20void pci_write32(int bus, int slot, int fn, int addr, uint32_t data)
21{
22 __pci_config(bus, slot, fn, addr);
23 outl(0xCFC, data);
24}
25
26void pci_write16(int bus, int slot, int fn, int addr, uint16_t data)
27{
28 __pci_config(bus, slot, fn, addr);
29 outw(0xCFC, data);
30}
31
32void pci_write8(int bus, int slot, int fn, int addr, uint8_t data)
33{
34 __pci_config(bus, slot, fn, addr);
35 outb(0xCFC, data);
36}
37
38uint32_t pci_read32(int bus, int slot, int fn, int addr)
39{
40 __pci_config(bus, slot, fn, addr);
41 return inl(0xCFC);
42}
43
44uint16_t pci_read16(int bus, int slot, int fn, int addr)
45{
46 __pci_config(bus, slot, fn, addr);
c2e34447 47 return inw(0xCFC + (addr & 2));
035d7af7
JW
48}
49
50uint8_t pci_read8(int bus, int slot, int fn, int addr)
51{
52 __pci_config(bus, slot, fn, addr);
c2e34447 53 return inb(0xCFC + (addr & 3));
035d7af7 54}
This page took 0.037693 seconds and 5 git commands to generate.