From 32f507ce5f66dd9c89a45854688f46bde33c5e3d Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 10 Nov 2010 09:20:50 +0100 Subject: Initial import of nios2sim (http://nios2sim.googlecode.com/svn/trunk/ r16) --- io_device.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 io_device.h (limited to 'io_device.h') diff --git a/io_device.h b/io_device.h new file mode 100644 index 0000000..e520ff0 --- /dev/null +++ b/io_device.h @@ -0,0 +1,65 @@ +/* + Nios-sim - one simple NIOSII simulator only for personal interest and fun. + Copyright (C) 2010 chysun2000@gmail.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#ifndef __IO_DEVICE_H__ +#define __IO_DEVICE_H__ +#include + +#define ADDR_IS_NOT_DEV (0) +#define ADDR_IS_DEV (1) + +#define DEV_HAS_IRQ (1) +#define DEV_NO_IRQ (0) + +struct io_device; +struct io_device { + void * priv_data; + char * name; + uint32_t irq_enable_mask; + void (*init)(struct io_device * self); + int32_t (*is_belong)(uint32_t address); + uint32_t (*read_data)(struct io_device * self, uint32_t addr, uint32_t data_len); + void (*write_data)(struct io_device * self, uint32_t addr, uint32_t data, uint32_t data_len); + int32_t (*has_irq)(struct io_device * self); + void (*simulate)(struct io_device * self); + +}; + +struct io_reg { + uint32_t addr; + uint32_t value; + uint32_t valid_mask; + uint32_t only_read_mask; +}; + +extern void init_devices(void); +extern struct io_device * get_device(uint32_t address); + +extern uint32_t io_write_data(uint32_t old_data, uint32_t new_data, uint32_t data_len); +extern uint32_t io_read_data(uint32_t old_data, uint32_t data_len); +extern uint32_t io_write_data_mask(uint32_t old_data, uint32_t new_data, uint32_t data_len, + uint32_t valid_mask, uint32_t only_read_mask); +extern void hw_simulating(void); +extern uint32_t get_io_irq_status(void); + +extern uint32_t check_reg_bit(uint32_t value, uint32_t mask); +#endif + + -- cgit v1.2.3-54-g00ecf