Index: head/sys/arm/altera/socfpga/files.socfpga =================================================================== --- head/sys/arm/altera/socfpga/files.socfpga (revision 273468) +++ head/sys/arm/altera/socfpga/files.socfpga (revision 273469) @@ -1,25 +1,28 @@ # $FreeBSD$ kern/kern_clocksource.c standard arm/arm/bus_space_generic.c standard arm/arm/bus_space_asm_generic.S standard arm/arm/cpufunc_asm_armv5.S standard arm/arm/cpufunc_asm_arm10.S standard arm/arm/cpufunc_asm_arm11.S standard arm/arm/cpufunc_asm_armv7.S standard arm/arm/bus_space-v6.c standard arm/arm/gic.c standard arm/arm/mpcore_timer.c standard arm/altera/socfpga/socfpga_common.c standard arm/altera/socfpga/socfpga_machdep.c standard arm/altera/socfpga/socfpga_manager.c standard arm/altera/socfpga/socfpga_rstmgr.c standard arm/altera/socfpga/socfpga_mp.c optional smp dev/dwc/if_dwc.c optional dwc dev/mii/micphy.c optional micphy dev/mmc/host/dwmmc.c optional dwmmc + +# BERI specific dev/beri/beri_ring.c optional beri_ring +dev/beri/beri_mem.c optional beri_mem Index: head/sys/arm/conf/SOCKIT-BERI =================================================================== --- head/sys/arm/conf/SOCKIT-BERI (revision 273468) +++ head/sys/arm/conf/SOCKIT-BERI (revision 273469) @@ -1,141 +1,142 @@ # Kernel configuration for Terasic SoCKit (Altera Cyclone V SoC). # # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # # http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the # FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the # latest information. # # An exhaustive list of options and more detailed explanations of the # device lines is also present in the ../../conf/NOTES and NOTES files. # If you are in doubt as to the purpose or necessity of a line, check first # in NOTES. # # $FreeBSD$ ident SOCKIT-BERI include "../altera/socfpga/std.socfpga" makeoptions MODULES_OVERRIDE="" makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols makeoptions WERROR="-Werror" options HZ=100 options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols options GEOM_PART_BSD # BSD partition scheme options GEOM_PART_MBR # MBR partition scheme options GEOM_PART_GPT # GUID partition tables options TMPFS # Efficient memory filesystem options FFS # Berkeley Fast Filesystem options SOFTUPDATES options UFS_ACL # Support for access control lists options UFS_DIRHASH # Improve performance on big directories options MSDOSFS # MSDOS Filesystem options CD9660 # ISO 9660 Filesystem options PROCFS # Process filesystem (requires PSEUDOFS) options PSEUDOFS # Pseudo-filesystem framework options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!] options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI options KTRACE options SYSVSHM # SYSV-style shared memory options SYSVMSG # SYSV-style message queues options SYSVSEM # SYSV-style semaphores options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions options KBD_INSTALL_CDEV options PREEMPTION options FREEBSD_BOOT_LOADER options VFP # vfp/neon options SMP # Debugging makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols options BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB options DDB # Enable the kernel debugger options INVARIANTS # Enable calls of extra sanity checking options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS #options WITNESS # Enable checks to detect deadlocks and cycles #options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed #options DIAGNOSTIC # NFS support options NFSCL # Network Filesystem Client options NFSLOCKD # Network Lock Manager options NFS_ROOT # NFS usable as /, requires NFSCLIENT # Uncomment this for NFS root #options NFS_ROOT # NFS usable as /, requires NFSCL #options BOOTP_NFSROOT #options BOOTP_COMPAT #options BOOTP #options BOOTP_NFSV3 #options BOOTP_WIRED_TO=ue0 device mmc # mmc/sd bus device mmcsd # mmc/sd flash cards device dwmmc options ROOTDEVNAME=\"ufs:/dev/mmcsd0s4\" # Pseudo devices device loop device random device pty device md device gpio # USB support options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. device usb options USB_DEBUG #options USB_REQ_DEBUG #options USB_VERBOSE #device musb device dwcotg device umass device scbus # SCSI bus (required for ATA/SCSI) device da # Direct Access (disks) device pass # Serial ports device uart device uart_ns8250 # I2C (TWSI) device iic device iicbus # SPI device spibus # BERI specific device beri_ring +device beri_mem # Ethernet device ether device mii device smsc device smscphy device dwc device micphy # USB ethernet support, requires miibus device miibus device axe # ASIX Electronics USB Ethernet device bpf # Berkeley packet filter #FDT options FDT options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=socfpga-sockit-beri.dts Index: head/sys/boot/fdt/dts/arm/socfpga-sockit-beri.dts =================================================================== --- head/sys/boot/fdt/dts/arm/socfpga-sockit-beri.dts (revision 273468) +++ head/sys/boot/fdt/dts/arm/socfpga-sockit-beri.dts (revision 273469) @@ -1,118 +1,124 @@ /*- * Copyright (c) 2014 Ruslan Bukin * 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$ */ /dts-v1/; /include/ "socfpga.dtsi" / { model = "Terasic SoCKit"; compatible = "altr,socfpga-cyclone5", "altr,socfpga"; /* Reserve first page for secondary CPU trampoline code */ memreserve = < 0x00000000 0x1000 >; memory { device_type = "memory"; reg = < 0x00000000 0x40000000 >; /* 1G RAM */ }; SOC: socfpga { serial0: serial@ffc02000 { status = "okay"; }; usb1: usb@ffb40000 { status = "okay"; }; gmac1: ethernet@ff702000 { status = "okay"; rxd0-skew-ps = <0>; rxd1-skew-ps = <0>; rxd2-skew-ps = <0>; rxd3-skew-ps = <0>; txen-skew-ps = <0>; txc-skew-ps = <2600>; rxdv-skew-ps = <0>; rxc-skew-ps = <2000>; }; mmc: dwmmc@ff704000 { status = "okay"; num-slots = <1>; supports-highspeed; broken-cd; bus-frequency = <25000000>; slot@0 { reg = <0>; bus-width = <4>; }; }; + beri_mem: mem@d0000000 { + compatible = "sri-cambridge,beri-mem"; + reg = <0xd0000000 0x10000000>; + status = "okay"; + }; + beri_debug: ring@c0000000 { compatible = "sri-cambridge,beri-ring"; reg = <0xc0000000 0x3000>; interrupts = < 72 73 >; interrupt-parent = <&GIC>; device_name = "beri_debug"; data_size = <0x1000>; data_read = <0x0>; data_write = <0x1000>; control_read = <0x2000>; control_write = <0x2010>; status = "okay"; }; beri_console: ring@c0004000 { compatible = "sri-cambridge,beri-ring"; reg = <0xc0004000 0x3000>; interrupts = < 74 75 >; interrupt-parent = <&GIC>; device_name = "beri_console"; data_size = <0x1000>; data_read = <0x0>; data_write = <0x1000>; control_read = <0x2000>; control_write = <0x2010>; status = "okay"; }; }; chosen { bootargs = "-v"; stdin = "serial0"; stdout = "serial0"; }; }; Index: head/sys/dev/beri/beri_mem.c =================================================================== --- head/sys/dev/beri/beri_mem.c (nonexistent) +++ head/sys/dev/beri/beri_mem.c (revision 273469) @@ -0,0 +1,186 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * 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. + */ + +/* + * BERI memory interface. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +struct beri_mem_softc { + struct resource *res[1]; + struct cdev *mem_cdev; + device_t dev; + int mem_size; + int mem_start; +}; + +static struct resource_spec beri_mem_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int +mem_open(struct cdev *dev, int flags __unused, + int fmt __unused, struct thread *td __unused) +{ + struct beri_mem_softc *sc; + + sc = dev->si_drv1; + + return (0); +} + +static int +mem_close(struct cdev *dev, int flags __unused, + int fmt __unused, struct thread *td __unused) +{ + struct beri_mem_softc *sc; + + sc = dev->si_drv1; + + return (0); +} + +static int +mem_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, + struct thread *td) +{ + + return (0); +} + +static int +mem_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, + vm_memattr_t *memattr) +{ + struct beri_mem_softc *sc; + + sc = dev->si_drv1; + + if (offset < sc->mem_size) { + *paddr = sc->mem_start + offset; + return (0); + } + + return (EINVAL); +} + +static struct cdevsw mem_cdevsw = { + .d_version = D_VERSION, + .d_open = mem_open, + .d_close = mem_close, + .d_ioctl = mem_ioctl, + .d_mmap = mem_mmap, + .d_name = "BERI memory", +}; + +static int +beri_mem_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "sri-cambridge,beri-mem")) + return (ENXIO); + + device_set_desc(dev, "BERI memory"); + return (BUS_PROBE_DEFAULT); +} + +static int +beri_mem_attach(device_t dev) +{ + struct beri_mem_softc *sc; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (bus_alloc_resources(dev, beri_mem_spec, sc->res)) { + device_printf(dev, "could not allocate resources\n"); + return (ENXIO); + } + + /* Memory info */ + sc->mem_size = rman_get_size(sc->res[0]); + sc->mem_start = rman_get_start(sc->res[0]); + + sc->mem_cdev = make_dev(&mem_cdevsw, 0, UID_ROOT, GID_WHEEL, + 0600, "beri_mem"); + + if (sc->mem_cdev == NULL) { + device_printf(dev, "Failed to create character device.\n"); + return (ENXIO); + } + + sc->mem_cdev->si_drv1 = sc; + + return (0); +} + +static device_method_t beri_mem_methods[] = { + DEVMETHOD(device_probe, beri_mem_probe), + DEVMETHOD(device_attach, beri_mem_attach), + { 0, 0 } +}; + +static driver_t beri_mem_driver = { + "beri_mem", + beri_mem_methods, + sizeof(struct beri_mem_softc), +}; + +static devclass_t beri_mem_devclass; + +DRIVER_MODULE(beri_mem, simplebus, beri_mem_driver, beri_mem_devclass, 0, 0); Property changes on: head/sys/dev/beri/beri_mem.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property