Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/riscv Beginnings of RISCV kernel support. Note tha...



details:   https://anonhg.NetBSD.org/src/rev/010e30f8200b
branches:  trunk
changeset: 807104:010e30f8200b
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Mar 28 16:13:56 2015 +0000

description:
Beginnings of RISCV kernel support.  Note that the pmap support is not yet
committed and probably won't be for awhile.  This is mostly preliminary
waiting for the supervisor specification to come out.  Lots of missing pieces
but it mostly builds.

diffstat:

 sys/arch/riscv/conf/GENERIC             |  179 ++++++++++
 sys/arch/riscv/conf/INSTALL             |    5 +
 sys/arch/riscv/conf/INSTALL.config      |   13 +
 sys/arch/riscv/conf/Makefile.riscv      |  141 ++++++++
 sys/arch/riscv/conf/files.riscv         |   82 ++++
 sys/arch/riscv/conf/kern.ldscript       |  146 ++++++++
 sys/arch/riscv/conf/std.riscv           |   38 ++
 sys/arch/riscv/conf/std.riscv64         |    5 +
 sys/arch/riscv/htif/htif.c              |   72 ++++
 sys/arch/riscv/htif/htif_cons.c         |   64 +++
 sys/arch/riscv/htif/htif_disk.c         |   41 ++
 sys/arch/riscv/htif/htif_var.h          |   53 +++
 sys/arch/riscv/include/cpu.h            |    6 +-
 sys/arch/riscv/include/intr.h           |    4 +-
 sys/arch/riscv/include/locore.h         |   65 ++-
 sys/arch/riscv/include/sysreg.h         |   66 ++-
 sys/arch/riscv/include/types.h          |    3 +-
 sys/arch/riscv/riscv/autoconf.c         |   65 +++
 sys/arch/riscv/riscv/clock_machdep.c    |   45 ++
 sys/arch/riscv/riscv/core32_machdep.c   |    9 +
 sys/arch/riscv/riscv/core_machdep.c     |  102 +++++
 sys/arch/riscv/riscv/cpu_mainbus.c      |   61 +++
 sys/arch/riscv/riscv/cpu_subr.c         |   34 +
 sys/arch/riscv/riscv/db_disasm.c        |   56 +++
 sys/arch/riscv/riscv/db_machdep.c       |  244 ++++++++++++++
 sys/arch/riscv/riscv/db_trace.c         |   45 ++
 sys/arch/riscv/riscv/exec_machdep.c     |   68 +++
 sys/arch/riscv/riscv/fixup.c            |   34 +
 sys/arch/riscv/riscv/fpu.c              |  193 +++++++++++
 sys/arch/riscv/riscv/genassym.cf        |  197 +++++++++++
 sys/arch/riscv/riscv/kobj_machdep.c     |  174 +++++++++
 sys/arch/riscv/riscv/locore.S           |  557 ++++++++++++++++++++++++++++++++
 sys/arch/riscv/riscv/mainbus.c          |   74 ++++
 sys/arch/riscv/riscv/netbsd32_machdep.c |  187 ++++++++++
 sys/arch/riscv/riscv/pmap_machdep.c     |  208 +++++++++++
 sys/arch/riscv/riscv/process_machdep.c  |  106 ++++++
 sys/arch/riscv/riscv/procfs_machdep.c   |   51 ++
 sys/arch/riscv/riscv/riscv_machdep.c    |  376 +++++++++++++++++++++
 sys/arch/riscv/riscv/sig32_machdep.c    |   18 +
 sys/arch/riscv/riscv/sig_machdep.c      |  135 +++++++
 sys/arch/riscv/riscv/softint_machdep.c  |  110 ++++++
 sys/arch/riscv/riscv/spl.S              |  151 ++++++++
 sys/arch/riscv/riscv/stubs.c            |   34 +
 sys/arch/riscv/riscv/sys_machdep.c      |   48 ++
 sys/arch/riscv/riscv/syscall.c          |  251 ++++++++++++++
 sys/arch/riscv/riscv/trap.c             |  548 +++++++++++++++++++++++++++++++
 sys/arch/riscv/riscv/vm_machdep.c       |  283 ++++++++++++++++
 47 files changed, 5404 insertions(+), 43 deletions(-)

diffs (truncated from 5773 to 300 lines):

diff -r 54ca9c2a8e33 -r 010e30f8200b sys/arch/riscv/conf/GENERIC
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/riscv/conf/GENERIC       Sat Mar 28 16:13:56 2015 +0000
@@ -0,0 +1,179 @@
+# $NetBSD: GENERIC,v 1.1 2015/03/28 16:13:56 matt Exp $
+#
+# GENERIC machine description file
+#
+# This machine description file is used to generate the default NetBSD
+# kernel.  The generic kernel does not include all options, subsystems
+# and device drivers, but should be useful for most applications.
+#
+# The machine description file can be customised for your specific
+# machine to reduce the kernel size and improve its performance.
+#
+# For further information on compiling NetBSD kernels, see the config(8)
+# man page.
+#
+# For further information on hardware support for this architecture, see
+# the intro(4) man page.  For further information about kernel options
+# for this architecture, see the options(4) man page.  For an explanation
+# of each device driver in this file see the section 4 man page for the
+# device.
+
+include        "arch/riscv/conf/std.riscv64"
+
+options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
+
+#ident                 "GENERIC-$Revision: 1.1 $"
+
+maxusers       64              # estimated number of users
+
+# Standard system options
+
+options        NTP             # NTP phase/frequency locked loop
+
+options        KTRACE          # system call tracing via ktrace(1)
+
+# Note: SysV IPC parameters could be changed dynamically, see sysctl(8).
+options        SYSVMSG         # System V-like message queues
+options        SYSVSEM         # System V-like semaphores
+options        SYSVSHM         # System V-like memory sharing
+
+options        MODULAR         # new style module(7) framework
+options        MODULAR_DEFAULT_AUTOLOAD
+options        USERCONF        # userconf(4) support
+#options       PIPE_SOCKETPAIR # smaller, but slower pipe(2)
+options        SYSCTL_INCLUDE_DESCR    # Include sysctl descriptions in kernel
+
+# Alternate buffer queue strategies for better responsiveness under high
+# disk I/O load.
+#options       BUFQ_READPRIO
+options        BUFQ_PRIOCSCAN
+
+# Diagnostic/debugging support options
+options        DIAGNOSTIC      # inexpensive kernel consistency checks
+                               # XXX to be commented out on release branch
+#options       DEBUG           # expensive debugging checks/support
+#options       LOCKDEBUG       # expensive locking checks/support
+#options       KMEMSTATS       # kernel memory statistics (vmstat -m)
+
+#
+# Because gcc omits the frame pointer for any -O level, the line below
+# is needed to make backtraces in DDB work.
+#
+#makeoptions   COPTS="-O2 -fno-omit-frame-pointer"
+makeoptions    COPY_SYMTAB=1
+options        DDB             # in-kernel debugger
+#options       DDB_COMMANDONENTER="bt" # execute command when ddb is entered
+#options       DDB_ONPANIC=1   # see also sysctl(7): `ddb.onpanic'
+options        DDB_HISTORY_SIZE=512    # enable history editing in DDB
+#options       KGDB            # remote debugger
+#options       KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
+#options       SYSCALL_STATS   # per syscall counts
+#options       SYSCALL_TIMES   # per syscall times
+#options       SYSCALL_TIMES_HASCOUNTER        # use 'broken' rdtsc (soekris)
+
+# Compatibility options
+options        COMPAT_70       # NetBSD 7.0 binary compatibility.
+options        COMPAT_43       # and 4.3BSD
+
+options        COMPAT_OSSAUDIO
+options        COMPAT_NETBSD32
+#options       COMPAT_LINUX
+#options       COMPAT_LINUX32  # req. COMPAT_LINUX and COMPAT_NETBSD32
+#options       EXEC_ELF32
+options        COMPAT_BSDPTY   # /dev/[pt]ty?? ptys.
+
+# Wedge support
+options        DKWEDGE_AUTODISCOVER    # Automatically add dk(4) instances
+options        DKWEDGE_METHOD_GPT      # Supports GPT partitions as wedges
+options        DKWEDGE_METHOD_BSDLABEL # Support disklabel entries as wedges
+options        DKWEDGE_METHOD_MBR      # Support MBR partitions as wedges
+options                DKWEDGE_METHOD_APPLE    # Support Apple partitions as wedges
+
+include                "conf/filesystems.config"
+
+# File system options
+options        QUOTA           # legacy UFS quotas
+options        QUOTA2          # new, in-filesystem UFS quotas
+options        FFS_EI          # FFS Endian Independent support
+options        WAPBL           # File system journaling support
+# Note that UFS_DIRHASH is suspected of causing kernel memory corruption.
+# It is not recommended for general use.
+#options       UFS_DIRHASH     # UFS Large Directory Hashing - Experimental
+options        NFSSERVER       # Network File System server
+#options       EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
+                               # immutable) behave as system flags.
+#options       FFS_NO_SNAPSHOT # No FFS snapshot support
+
+# Networking options
+#options       GATEWAY         # packet forwarding
+options        INET            # IP + ICMP + TCP + UDP
+options        INET6           # IPV6
+options        IPSEC           # IP security
+#options       IPSEC_DEBUG     # debug for IP security
+#options       MPLS            # MultiProtocol Label Switching (needs ifmpls)
+#options       MROUTING        # IP multicast routing
+#options       PIM             # Protocol Independent Multicast
+#options       NETATALK        # AppleTalk networking protocols
+#options       PPP_BSDCOMP     # BSD-Compress compression support for PPP
+#options       PPP_DEFLATE     # Deflate compression support for PPP
+#options       PPP_FILTER      # Active filter support for PPP (requires bpf)
+#options       IPFILTER_LOG    # ipmon(8) log support
+#options       IPFILTER_LOOKUP # ippool(8) support
+#options       IPFILTER_COMPAT # Compat for IP-Filter
+#options       IPFILTER_DEFAULT_BLOCK  # block all packets by default
+#options       TCP_DEBUG       # Record last TCP_NDEBUG packets with SO_DEBUG
+
+#options       ALTQ            # Manipulate network interfaces' output queues
+#options       ALTQ_BLUE       # Stochastic Fair Blue
+#options       ALTQ_CBQ        # Class-Based Queueing
+#options       ALTQ_CDNR       # Diffserv Traffic Conditioner
+#options       ALTQ_FIFOQ      # First-In First-Out Queue
+#options       ALTQ_FLOWVALVE  # RED/flow-valve (red-penalty-box)
+#options       ALTQ_HFSC       # Hierarchical Fair Service Curve
+#options       ALTQ_LOCALQ     # Local queueing discipline
+#options       ALTQ_PRIQ       # Priority Queueing
+#options       ALTQ_RED        # Random Early Detection
+#options       ALTQ_RIO        # RED with IN/OUT
+#options       ALTQ_WFQ        # Weighted Fair Queueing
+
+# These options enable verbose messages for several subsystems.
+# Warning, these may compile large string tables into the kernel!
+
+# Kernel root file system and dump configuration.
+config         netbsd  root on ? type ?
+
+#
+# Device configuration
+#
+mainbus0       at root
+cpu0           at mainbus0
+htif0          at mainbus0
+htifcons0      at htif0
+htifdisk0      at htif0
+ld0            at htifdisk0
+
+
+# Pseudo-Devices
+
+pseudo-device  crypto                  # /dev/crypto device
+pseudo-device  swcrypto                # software crypto implementation
+
+# disk/mass storage pseudo-devices
+#pseudo-device md                      # memory disk device (ramdisk)
+#options       MEMORY_DISK_HOOKS       # enable root ramdisk
+#options       MEMORY_DISK_DYNAMIC     # loaded via kernel module(7)
+
+pseudo-device  vnd                     # disk-like interface to files
+options        VND_COMPRESSION         # compressed vnd(4)
+
+pseudo-device  loop                    # network loopback
+pseudo-device  pty                     # pseudo-terminals
+pseudo-device  clockctl                # user control of clock subsystem
+pseudo-device  ksyms                   # /dev/ksyms
+pseudo-device  lockstat                # lock profiling
+
+# userland interface to drivers, including autoconf and properties retrieval
+pseudo-device  drvctl
+
+options        PAX_MPROTECT=0          # PaX mprotect(2) restrictions
+options        PAX_ASLR=0              # PaX Address Space Layout Randomization
diff -r 54ca9c2a8e33 -r 010e30f8200b sys/arch/riscv/conf/INSTALL
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/riscv/conf/INSTALL       Sat Mar 28 16:13:56 2015 +0000
@@ -0,0 +1,5 @@
+#
+#
+#
+include "arch/riscv/conf/GENERIC"
+include "arch/riscv/conf/INSTALL.config"
diff -r 54ca9c2a8e33 -r 010e30f8200b sys/arch/riscv/conf/INSTALL.config
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/riscv/conf/INSTALL.config        Sat Mar 28 16:13:56 2015 +0000
@@ -0,0 +1,13 @@
+#      $NetBSD: INSTALL.config,v 1.1 2015/03/28 16:13:56 matt Exp $
+#
+#      INSTALL -- Common configuration fragment for install kernels.
+#
+
+options        MEMORY_DISK_HOOKS
+options        MEMORY_DISK_IS_ROOT     # Force root on ramdisk
+options        MEMORY_DISK_ROOT_SIZE=8192
+options        MEMORY_DISK_RBFLAGS=RB_SINGLE   # boot in single-user mode
+
+makeoptions    NEED_MDSETIMAGE="yes"
+
+pseudo-device  md
diff -r 54ca9c2a8e33 -r 010e30f8200b sys/arch/riscv/conf/Makefile.riscv
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/riscv/conf/Makefile.riscv        Sat Mar 28 16:13:56 2015 +0000
@@ -0,0 +1,141 @@
+#      $NetBSD: Makefile.riscv,v 1.1 2015/03/28 16:13:56 matt Exp $
+
+# Makefile for NetBSD
+#
+# This makefile is constructed from a machine description:
+#      config machineid
+# Most changes should be made in the machine description
+#      /sys/arch/<machine>/conf/``machineid''
+# after which you should do
+#      config machineid
+# Machine generic makefile changes should be made in
+#      /sys/arch/riscv/conf/Makefile.riscv
+# after which config should be rerun for all machines of that type.
+#
+# To specify debugging, add the config line: makeoptions DEBUG="-g"
+# A better way is to specify -g only for a few files.
+#
+#      makeoptions DEBUGLIST="uvm* trap if_*"
+
+USETOOLS?=     no
+NEED_OWN_INSTALL_TARGET?=no
+.include <bsd.own.mk>
+
+##
+## (1) port identification
+##
+.ifndef S
+S=             ../../../..
+.endif
+THISRISCV=     $S/arch/${MACHINE}
+RISCV=         $S/arch/riscv
+GENASSYM_CONF= ${RISCV}/riscv/genassym.cf
+.-include "${THISRISCV}/conf/Makefile.${MACHINE}.inc"
+
+##
+## (2) compile settings
+##
+## Note: -ffixed-?? must be kept in sync with cpu.h.
+##
+CPPFLAGS+=     -D${MACHINE}
+CFLAGS+=       -fPIC -Wa,-fno-pic -msoft-float
+.if !defined(LP64) || ${LP64} == "no"
+CFLAGS+=       -m32
+AFLAGS+=       -m32
+LDFLAGS+=      -m elf32lriscv
+LINKFORMAT+=   -m elf32lriscv
+SYSTEM_LD_TAIL_EXTRA+= \
+               ;echo ${OBJCOPY} -O elf32-littleriscv $@ $@.elf32; \
+               ${OBJCOPY} -O elf32-littleriscv $@ $@.elf32
+.endif # LP64=no
+AFLAGS+=       -x assembler-with-cpp ${AOPTS}
+
+##
+## (3) libkern and compat
+##
+OPT_MODULAR=   %MODULAR%
+.if !empty(OPT_MODULAR)
+KERN_AS=       obj
+.else
+KERN_AS=       library
+.endif
+
+##
+## (4) local objects, compile rules, and dependencies
+##
+MD_OBJS=       locore.o
+MD_CFILES=
+MD_SFILES=     ${RISCV}/riscv/locore.S
+
+locore.o: ${RISCV}/riscv/locore.S assym.h
+       ${NORMAL_S}
+
+##
+## (5) link settings
+##
+.if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
+TEXTADDR?=              0xFFFFFFFF80002000
+.else   
+TEXTADDR?=             0xC0001000
+.endif
+KERNLDSCRIPT?=         ${RISCV}/conf/kern.ldscript
+LINKFORMAT+=           -T ${KERNLDSCRIPT}
+EXTRA_LINKFLAGS=       ${LDOPTS} --relax
+LINKFLAGS_NORMAL=      -X
+STRIPFLAGS=            -g -X
+
+##



Home | Main Index | Thread Index | Old Index