# -*- perl -*-
#
# I/O device configuration
#

# Common constants
our %consts = (
    '_PC_RESET'  => 0x10,
    '_PC_IRQ'    => 0x20,
    'SRAM_ADDR'  => 0,
    'SRAM_BITS'  => 15,
    'SDRAM_ADDR' => 0x40000000,
    'SDRAM_BITS' => 25,
    'SYS_MAGIC_MAX80' => unpack('V', 'MAX8'),
    'TIMER_SHIFT' => 5,		# 32 Hz
    'TTY_CHANNELS' => 4
    );

# I/O address definitions
our $xdev_addr_bits   = 2;
our $xdev_addr_shift  = 28;
our $iodev_addr_bits  = 4;
our $iodev_addr_shift = 7;

# Special IRQs (CPU or non-device)
our @sysirqs = ('timer', 'ebreak', 'buserr');

# Define -irq to a string of 'e' (edge) or 'l' (level)
# for a corresponding number of IRQs.
our @iodevs = (
    { -name => 'sys' },

    { -name => 'abc',       -irq => 'l' },
    { -name => 'abcmemmap', -xdev => 1 },

    { -name => 'sysclock',  -irq => 'e' },
    { -name => 'tty',       -irq => 'l' x $consts{'TTY_CHANNELS'} },
    { -name => 'usbdesc',   -xdev => 1 },

    { -name => 'romcopy',   -irq => 'l' },
    { -name => 'sdcard',    -irq => 'l' },
    { -name => 'i2c',       -irq => 'l' },
    { -name => 'esp',       -irq => 'l' },
    { -name => 'random',    -irq => 'l' },

    { -name => 'vjtag',     -irq => 'e' }
);
