aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/chrtclib.h
Commit message (Expand)AuthorAgeFilesLines
* git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4276 35acf78f-673a-0410...gdisirio2012-06-141-6/+6
* chrtclib. Added forgotten prototype.barthess2012-05-191-0/+1
* SDC. Merged code from development branch.barthess2012-04-171-0/+0
* RTC. High level staff moved to chrtclib.barthess2012-03-091-0/+56
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
/******************************************************************************
 * pci.c
 * 
 * Architecture-dependent PCI access functions.
 */

#include <xen/spinlock.h>
#include <xen/pci.h>
#include <xen/init.h>
#include <asm/io.h>

#define PCI_CONF_ADDRESS(bus, dev, func, reg) \
    (0x80000000 | (bus << 16) | (dev << 11) | (func << 8) | (reg & ~3))

uint8_t pci_conf_read8(
    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
    unsigned int reg)
{
    if ( seg || (reg > 255) )
        return ~0;
    BUG_ON((bus > 255) || (dev > 31) || (func > 7));
    return pci_conf_read(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 3, 1);
}

uint16_t pci_conf_read16(
    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
    unsigned int reg)
{
    if ( seg || (reg > 255) )
        return ~0;
    BUG_ON((bus > 255) || (dev > 31) || (func > 7));
    return pci_conf_read(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 2, 2);
}

uint32_t pci_conf_read32(
    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
    unsigned int reg)
{
    if ( seg || (reg > 255) )
        return ~0;
    BUG_ON((bus > 255) || (dev > 31) || (func > 7));
    return pci_conf_read(PCI_CONF_ADDRESS(bus, dev, func, reg), 0, 4);
}

void pci_conf_write8(
    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
    unsigned int reg, uint8_t data)
{
    if ( seg )
        return;
    BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
    pci_conf_write(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 3, 1, data);
}

void pci_conf_write16(
    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
    unsigned int reg, uint16_t data)
{
    if ( seg )
        return;
    BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
    pci_conf_write(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 2, 2, data);
}

void pci_conf_write32(
    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
    unsigned int reg, uint32_t data)
{
    if ( seg )
        return;
    BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
    pci_conf_write(PCI_CONF_ADDRESS(bus, dev, func, reg), 0, 4, data);
}

void __init arch_pci_ro_device(int seg, int bdf)
{
}