module pci;

import base;

errors
{
    NOT_FOUND,
    INVALID_ADDR,
    NO_IRQ_FOR_DEVICE,
    IRQ_ALREADY_ENABLED
};

type PciIdentifier =
{
    U16 vendor,
    U8 class,
    U8 subclass,
};

type PciBarType = enum
{
    BAR_INVALID,
    BAR_MMIO_32,
    BAR_MMIO_64,
    BAR_PIO,
};

type PciAddr =
{
    U16 seg,
    U8 bus,
    U8 slot,
    U8 func,
};

type PciBarInfo =
{
    U64 base,
    U32 size,
    PciBarType type,
};

interface Device
{
};

interface Bus
{
    method query PciIdentifier -> PciAddr;

    method bar { PciAddr addr, U8 num } -> PciBarInfo;

    method enable_irq { PciAddr addr } -> U8;
};
