cf8248866d
CPU cores on Altera FPGAs. The device driver allows memory-mapped devices on Altera's Avalon SoC bus to be exported to userspace via device nodes. device.hints directories dictate device name, permissible access methods, physical address and length, and I/O alignment. Devices can be accessed using read(2)/write(2), but also memory mapped in userspace using mmap(2). Devices attach directly to the Nexus, as is common for embedded device drivers; in the future something more mature might be desirable. There is currently no facility to support directing device-originated interrupts to userspace. In the future, this device driver may be renamed to socgen(4), as it can in principle also be used with other system-on-chip (SoC) busses, such as Axi on ASICs and FPGAs. However, we have only tested it on Avalon busses with memory-mapped ROMs, frame buffers, etc. Sponsored by: DARPA, AFRL
84 lines
2.8 KiB
C
84 lines
2.8 KiB
C
/*-
|
|
* Copyright (c) 2012 Robert N. M. Watson
|
|
* All rights reserved.
|
|
*
|
|
* This software was developed by SRI International and the University of
|
|
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
|
|
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#ifndef _DEV_ALTERA_AVALON_H_
|
|
#define _DEV_ALTERA_AVALON_H_
|
|
|
|
struct altera_avgen_softc {
|
|
/*
|
|
* Bus-related fields.
|
|
*/
|
|
device_t avg_dev;
|
|
int avg_unit;
|
|
|
|
/*
|
|
* The device node and memory-mapped I/O region.
|
|
*/
|
|
struct cdev *avg_cdev;
|
|
struct resource *avg_res;
|
|
int avg_rid;
|
|
|
|
/*
|
|
* Access properties configured by device.hints.
|
|
*/
|
|
u_int avg_flags;
|
|
u_int avg_width;
|
|
};
|
|
|
|
/*
|
|
* Various flags extracted from device.hints to configure operations on the
|
|
* device.
|
|
*/
|
|
#define ALTERA_AVALON_FLAG_READ 0x01
|
|
#define ALTERA_AVALON_FLAG_WRITE 0x02
|
|
#define ALTERA_AVALON_FLAG_MMAP_READ 0x04
|
|
#define ALTERA_AVALON_FLAG_MMAP_WRITE 0x08
|
|
#define ALTERA_AVALON_FLAG_MMAP_EXEC 0x10
|
|
|
|
#define ALTERA_AVALON_CHAR_READ 'r'
|
|
#define ALTERA_AVALON_CHAR_WRITE 'w'
|
|
#define ALTERA_AVALON_CHAR_EXEC 'x'
|
|
|
|
#define ALTERA_AVALON_STR_WIDTH "width"
|
|
#define ALTERA_AVALON_STR_FILEIO "fileio"
|
|
#define ALTERA_AVALON_STR_MMAPIO "mmapio"
|
|
#define ALTERA_AVALON_STR_DEVNAME "devname"
|
|
#define ALTERA_AVALON_STR_DEVUNIT "devunit"
|
|
|
|
/*
|
|
* Driver setup routines from the bus attachment/teardown.
|
|
*/
|
|
int altera_avgen_attach(struct altera_avgen_softc *sc);
|
|
void altera_avgen_detach(struct altera_avgen_softc *sc);
|
|
|
|
#endif /* _DEV_ALTERA_AVALON_H_ */
|