]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - pci/pci-raw.c
more licensing
[netwatch.git] / pci / pci-raw.c
... / ...
CommitLineData
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
11#include <io.h>
12#include <stdint.h>
13#include <pci.h>
14
15static void __pci_config(int bus, int slot, int fn, int addr)
16{
17 outl(0xCF8, 0x80000000ULL | (bus << 16) | (slot << 11) | (fn << 8) | (addr & ~3));
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);
47 return inw(0xCFC + (addr & 2));
48}
49
50uint8_t pci_read8(int bus, int slot, int fn, int addr)
51{
52 __pci_config(bus, slot, fn, addr);
53 return inb(0xCFC + (addr & 3));
54}
This page took 0.021515 seconds and 4 git commands to generate.