Messages in this thread Patch in this message | | | From | Palmer Dabbelt <> | Subject | [PATCH 2/7] RISC-V: arch/riscv Makefile and Kconfigs | Date | Mon, 22 May 2017 17:41:02 -0700 |
| |
--- arch/riscv/.gitignore | 35 ++++ arch/riscv/Kconfig | 300 +++++++++++++++++++++++++++++++++++ arch/riscv/Makefile | 64 ++++++++ arch/riscv/configs/riscv32_spike | 47 ++++++ arch/riscv/configs/riscv64_freedom-u | 52 ++++++ arch/riscv/configs/riscv64_qemu | 64 ++++++++ arch/riscv/configs/riscv64_spike | 45 ++++++ 7 files changed, 607 insertions(+) create mode 100644 arch/riscv/.gitignore create mode 100644 arch/riscv/Kconfig create mode 100644 arch/riscv/Makefile create mode 100644 arch/riscv/configs/riscv32_spike create mode 100644 arch/riscv/configs/riscv64_freedom-u create mode 100644 arch/riscv/configs/riscv64_qemu create mode 100644 arch/riscv/configs/riscv64_spike
diff --git a/arch/riscv/.gitignore b/arch/riscv/.gitignore new file mode 100644 index 000000000000..376d06eb5d52 --- /dev/null +++ b/arch/riscv/.gitignore @@ -0,0 +1,35 @@ +# Now un-ignore all files. +!* + +# But then re-ignore the files listed in the Linux .gitignore +# Normal rules +# +.* +*.o +*.o.* +*.a +*.s +*.ko +*.so +*.so.dbg +*.mod.c +*.i +*.lst +*.symtypes +*.order +modules.builtin +*.elf +*.bin +*.gz +*.bz2 +*.lzma +*.xz +*.lzo +*.patch +*.gcno + +include/generated +kernel/vmlinux.lds + +# Then reinclude .gitignore. +!.gitignore diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig new file mode 100644 index 000000000000..510ead1d3343 --- /dev/null +++ b/arch/riscv/Kconfig @@ -0,0 +1,300 @@ +# +# For a description of the syntax of this configuration file, +# see Documentation/kbuild/kconfig-language.txt. +# + +config RISCV + def_bool y + select OF + select OF_EARLY_FLATTREE + select OF_IRQ + select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE + select ARCH_WANT_FRAME_POINTERS + select CLONE_BACKWARDS + select COMMON_CLK + select GENERIC_CLOCKEVENTS + select GENERIC_CPU_DEVICES + select GENERIC_IRQ_SHOW + select GENERIC_PCI_IOMAP + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER + select GENERIC_SMP_IDLE_THREAD + select GENERIC_ATOMIC64 if !64BIT || !RV_ATOMIC + select ARCH_WANT_OPTIONAL_GPIOLIB + select HAVE_MEMBLOCK + select HAVE_DMA_API_DEBUG + select HAVE_DMA_CONTIGUOUS + select HAVE_GENERIC_DMA_COHERENT + select IRQ_DOMAIN + select NO_BOOTMEM + select RV_ATOMIC if SMP + select RV_SYSRISCV_ATOMIC if !RV_ATOMIC + select SPARSE_IRQ + select SYSCTL_EXCEPTION_TRACE + select HAVE_ARCH_TRACEHOOK + select MODULES_USE_ELF_RELA if MODULES + +config MMU + def_bool y + +# even on 32-bit, physical (and DMA) addresses are > 32-bits +config ARCH_PHYS_ADDR_T_64BIT + def_bool y + +config ARCH_DMA_ADDR_T_64BIT + def_bool y + +config STACKTRACE_SUPPORT + def_bool y + +config RWSEM_GENERIC_SPINLOCK + def_bool y + +config GENERIC_BUG + def_bool y + depends on BUG + select GENERIC_BUG_RELATIVE_POINTERS if 64BIT + +config GENERIC_BUG_RELATIVE_POINTERS + bool + +config GENERIC_CALIBRATE_DELAY + def_bool y + +config GENERIC_CSUM + def_bool y + +config GENERIC_HWEIGHT + def_bool y + +config PGTABLE_LEVELS + int + default 3 if 64BIT + default 2 + +config HAVE_KPROBES + def_bool n + +config DMA_NOOP_OPS + def_bool y + +menu "Platform type" + +config SMP + bool "Symmetric Multi-Processing" + help + This enables support for systems with more than one CPU. If + you say N here, the kernel will run on single and + multiprocessor machines, but will use only one CPU of a + multiprocessor machine. If you say Y here, the kernel will run + on many, but not all, single processor machines. On a single + processor machine, the kernel will run faster if you say N + here. + + If you don't know what to do here, say N. + +config NR_CPUS + int "Maximum number of CPUs (2-32)" + range 2 32 + depends on SMP + default "8" + +choice + prompt "CPU selection" + default CPU_RV_GENERIC + +config CPU_RV_GENERIC + bool "Generic RISC-V" + select CPU_SUPPORTS_32BIT_KERNEL + select CPU_SUPPORTS_64BIT_KERNEL + +endchoice + +config PLIC + bool "Platform-Level Interrupt Controller" + default y + help + This enables support for the PLIC chip found in standard RISC-V + systems. The PLIC is the top-most interrupt controller found in + the system, connected directly to the core complex. All other + interrupt sources (MSI, GPIO, etc) are subordinate to the PLIC. + + If you don't know what to do here, say Y. + +config CPU_SUPPORTS_32BIT_KERNEL + bool +config CPU_SUPPORTS_64BIT_KERNEL + bool + +config SBI_CONSOLE + tristate "SBI console support" + select TTY + default y + +config RVC + bool "Use compressed instructions (RV32C or RV64C)" + default n + +config RV_ATOMIC + bool "Use atomic memory instructions (RV32A or RV64A)" + default y + +config RV_SYSRISCV_ATOMIC + bool "Include support for atomic operation syscalls" + default n + help + If atomic memory instructions are present, i.e., + CONFIG_RV_ATOMIC, this includes support for the syscall that + provides atomic accesses. This is only useful to run + binaries that require atomic access but were compiled with + -mno-atomic. + + If CONFIG_RV_ATOMIC is unset, this option is mandatory. + +config RV_PUM + def_bool y + prompt "Protect User Memory" if EXPERT + ---help--- + Protect User Memory (PUM) prevents the kernel from inadvertently + accessing user-space memory. There is a small performance cost + and kernel size increase if this is enabled. + + If unsure, say Y. + +endmenu + +menu "Kernel type" + +choice + prompt "Kernel code model" + default 64BIT + +config 32BIT + bool "32-bit kernel" + depends on CPU_SUPPORTS_32BIT_KERNEL + help + Select this option to build a 32-bit kernel. + +config 64BIT + bool "64-bit kernel" + depends on CPU_SUPPORTS_64BIT_KERNEL + help + Select this option to build a 64-bit kernel. + +endchoice + +source "mm/Kconfig" + +source "kernel/Kconfig.preempt" + +source "kernel/Kconfig.hz" + +endmenu + +menu "Bus support" + +config PCI + bool "PCI support" + select PCI_MSI + help + This feature enables support for PCI bus system. If you say Y + here, the kernel will include drivers and infrastructure code + to support PCI bus devices. + +config PCI_DOMAINS + def_bool PCI + +config PCI_DOMAINS_GENERIC + def_bool PCI + +config PCI_SYSCALL + def_bool PCI + +source "drivers/pci/Kconfig" + +endmenu + +source "init/Kconfig" + +source "kernel/Kconfig.freezer" + +menu "Executable file formats" + +source "fs/Kconfig.binfmt" + +endmenu + +menu "Power management options" + +source kernel/power/Kconfig + +endmenu + +source "net/Kconfig" + +source "drivers/Kconfig" + +source "fs/Kconfig" + +menu "Kernel hacking" + +config CMDLINE_BOOL + bool "Built-in kernel command line" + default n + help + For most platforms, it is firmware or second stage bootloader + that by default specifies the kernel command line options. + However, it might be necessary or advantageous to either override + the default kernel command line or add a few extra options to it. + For such cases, this option allows hardcoding command line options + directly into the kernel. + + For that, choose 'Y' here and fill in the extra boot parameters + in CONFIG_CMDLINE. + + The built-in options will be concatenated to the default command + line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default + command line will be ignored and replaced by the built-in string. + +config CMDLINE + string "Built-in kernel command string" + depends on CMDLINE_BOOL + default "" + help + Supply command-line options at build time by entering them here. + +config CMDLINE_OVERRIDE + bool "Built-in command line overrides bootloader arguments" + default n + depends on CMDLINE_BOOL + help + Set this option to 'Y' to have the kernel ignore the bootloader + or firmware command line. Instead, the built-in command line + will be used exclusively. + +config EARLY_PRINTK + bool "Early printk" + default n + help + This option enables special console drivers which allow the kernel + to print messages very early in the bootup process. + + This is useful for kernel debugging when your machine crashes very + early before the console code is initialized. For normal operation + it is not recommended because it looks ugly and doesn't cooperate + with klogd/syslogd or the X server. You should normally N here, + unless you want to debug such a crash. + + +source "lib/Kconfig.debug" + +config CMDLINE_BOOL + bool +endmenu + +source "security/Kconfig" + +source "crypto/Kconfig" + +source "lib/Kconfig" + diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile new file mode 100644 index 000000000000..07ef200e0675 --- /dev/null +++ b/arch/riscv/Makefile @@ -0,0 +1,64 @@ +# This file is included by the global makefile so that you can add your own +# architecture-specific flags and dependencies. Remember to do have actions +# for "archclean" and "archdep" for cleaning up and making dependencies for +# this architecture +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file "COPYING" in the main directory of this archive +# for more details. +# + +LDFLAGS := +OBJCOPYFLAGS := -O binary +LDFLAGS_vmlinux := +KBUILD_AFLAGS_MODULE += -fPIC +KBUILD_CFLAGS_MODULE += -fPIC + +ifeq ($(ARCH),riscv) + KBUILD_DEFCONFIG = riscv64_spike +else + KBUILD_DEFCONFIG = $(ARCH)_spike +endif + +export BITS +ifeq ($(CONFIG_64BIT),y) + BITS := 64 + UTS_MACHINE := riscv64 + + KBUILD_CFLAGS += -mabi=lp64 + KBUILD_AFLAGS += -mabi=lp64 + KBUILD_MARCH = rv64im + LDFLAGS += -melf64lriscv +else + BITS := 32 + UTS_MACHINE := riscv32 + + KBUILD_CFLAGS += -mabi=ilp32 + KBUILD_AFLAGS += -mabi=ilp32 + KBUILD_MARCH = rv32im + LDFLAGS += -melf32lriscv +endif + +ifeq ($(CONFIG_RV_ATOMIC),y) + KBUILD_RV_ATOMIC = a +endif + +KBUILD_CFLAGS += -Wall + +ifeq ($(CONFIG_RVC),y) + KBUILD_RVC = c +endif + +KBUILD_AFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_RV_ATOMIC)fd$(KBUILD_RVC) + +KBUILD_CFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_RV_ATOMIC)$(KBUILD_RVC) +KBUILD_CFLAGS += -mno-save-restore +KBUILD_CFLAGS += -mstrict-align + +head-y := arch/riscv/kernel/head.o + +core-y += arch/riscv/kernel/ arch/riscv/mm/ + +libs-y += arch/riscv/lib/ + +all: vmlinux diff --git a/arch/riscv/configs/riscv32_spike b/arch/riscv/configs/riscv32_spike new file mode 100644 index 000000000000..c224f7dcb4da --- /dev/null +++ b/arch/riscv/configs/riscv32_spike @@ -0,0 +1,47 @@ +CONFIG_64BIT=n +CONFIG_32BIT=y +CONFIG_PCI=y +CONFIG_DEFAULT_HOSTNAME="ucbvax" +# CONFIG_CROSS_MEMORY_ATTACH is not set +# CONFIG_FHANDLE is not set +CONFIG_NAMESPACES=y +CONFIG_EMBEDDED=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_EFI_PARTITION is not set +# CONFIG_IOSCHED_DEADLINE is not set +CONFIG_NET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_DIAG is not set +# CONFIG_IPV6 is not set +# CONFIG_WIRELESS is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_FIRMWARE_IN_KERNEL is not set +# CONFIG_BLK_DEV is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_VT is not set +CONFIG_DEVKMEM=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HWMON is not set +CONFIG_FB=y +# CONFIG_USB_SUPPORT is not set +# CONFIG_IOMMU_SUPPORT is not set +CONFIG_EXT2_FS=y +# CONFIG_FILE_LOCKING is not set +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +# CONFIG_PROC_PAGE_MONITOR is not set +# CONFIG_SYSFS is not set +CONFIG_TMPFS=y +# CONFIG_MISC_FILESYSTEMS is not set +# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_PRINTK_TIME=y +CONFIG_DEBUG_SECTION_MISMATCH=y +# CONFIG_FRAME_POINTER is not set +# CONFIG_CRYPTO_HW is not set diff --git a/arch/riscv/configs/riscv64_freedom-u b/arch/riscv/configs/riscv64_freedom-u new file mode 100644 index 000000000000..519cb8219b40 --- /dev/null +++ b/arch/riscv/configs/riscv64_freedom-u @@ -0,0 +1,52 @@ +CONFIG_CROSS_COMPILE="riscv64-unknown-linux-gnu-" +CONFIG_DEFAULT_HOSTNAME="ucbvax" +# CONFIG_CROSS_MEMORY_ATTACH is not set +# CONFIG_FHANDLE is not set +CONFIG_NAMESPACES=y +# CONFIG_SGETMASK_SYSCALL is not set +CONFIG_EMBEDDED=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_EFI_PARTITION is not set +# CONFIG_IOSCHED_DEADLINE is not set +# CONFIG_COMPACTION is not set +CONFIG_HZ_100=y +CONFIG_PCI_MSI=y +CONFIG_NET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_DIAG is not set +# CONFIG_IPV6 is not set +# CONFIG_WIRELESS is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_FIRMWARE_IN_KERNEL is not set +CONFIG_OF=y +# CONFIG_BLK_DEV is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_VT is not set +CONFIG_DEVKMEM=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HWMON is not set +CONFIG_FB=y +# CONFIG_USB_SUPPORT is not set +# CONFIG_IOMMU_SUPPORT is not set +CONFIG_EXT2_FS=y +# CONFIG_FILE_LOCKING is not set +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +# CONFIG_PROC_PAGE_MONITOR is not set +# CONFIG_SYSFS is not set +CONFIG_TMPFS=y +# CONFIG_MISC_FILESYSTEMS is not set +# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_PRINTK_TIME=y +# CONFIG_UNUSED_SYMBOLS is not set +CONFIG_DEBUG_SECTION_MISMATCH=y +# CONFIG_FRAME_POINTER is not set +# CONFIG_EARLY_PRINTK is not set +# CONFIG_CRYPTO_HW is not set diff --git a/arch/riscv/configs/riscv64_qemu b/arch/riscv/configs/riscv64_qemu new file mode 100644 index 000000000000..4b1190ad2676 --- /dev/null +++ b/arch/riscv/configs/riscv64_qemu @@ -0,0 +1,64 @@ +# CONFIG_COMPACTION is not set +# CONFIG_CROSS_MEMORY_ATTACH is not set +CONFIG_HZ_100=y +# CONFIG_CROSS_COMPILE is not set +CONFIG_DEFAULT_HOSTNAME="ucbvax" +CONFIG_NAMESPACES=y +CONFIG_EMBEDDED=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_IOSCHED_DEADLINE is not set +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +# CONFIG_INET_DIAG is not set +# CONFIG_IPV6 is not set +# CONFIG_WIRELESS is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_FIRMWARE_IN_KERNEL is not set +# CONFIG_BLK_DEV is not set +CONFIG_SCSI=y +CONFIG_BLK_DEV_SD=y +CONFIG_SCSI_VIRTIO=y +CONFIG_NETDEVICES=y +CONFIG_VIRTIO_NET=y +# CONFIG_ETHERNET is not set +# CONFIG_WLAN is not set +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_VT is not set +CONFIG_SERIAL_8250=y +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=1 +CONFIG_SERIAL_8250_RUNTIME_UARTS=1 +CONFIG_VIRTIO_CONSOLE=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HWMON is not set +CONFIG_FB=y +# CONFIG_USB_SUPPORT is not set +CONFIG_VIRTIO_MMIO=y +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y +# CONFIG_IOMMU_SUPPORT is not set +CONFIG_EXT4_FS=y +# CONFIG_FILE_LOCKING is not set +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +# CONFIG_PROC_PAGE_MONITOR is not set +CONFIG_TMPFS=y +# CONFIG_MISC_FILESYSTEMS is not set +# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_CMDLINE_BOOL=y +CONFIG_CMDLINE="virtio_mmio.device=0x200@0x400:1 virtio_mmio.device=0x200@0x600:2 virtio_mmio.device=0x200@0x800:3 lpj=100000" +CONFIG_CMDLINE_OVERRIDE=y +CONFIG_PRINTK_TIME=y +CONFIG_DEBUG_SECTION_MISMATCH=y +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set diff --git a/arch/riscv/configs/riscv64_spike b/arch/riscv/configs/riscv64_spike new file mode 100644 index 000000000000..a48e92cba88e --- /dev/null +++ b/arch/riscv/configs/riscv64_spike @@ -0,0 +1,45 @@ +CONFIG_PCI=y +CONFIG_DEFAULT_HOSTNAME="ucbvax" +# CONFIG_CROSS_MEMORY_ATTACH is not set +# CONFIG_FHANDLE is not set +CONFIG_NAMESPACES=y +CONFIG_EMBEDDED=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_EFI_PARTITION is not set +# CONFIG_IOSCHED_DEADLINE is not set +CONFIG_NET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_DIAG is not set +# CONFIG_IPV6 is not set +# CONFIG_WIRELESS is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_FIRMWARE_IN_KERNEL is not set +# CONFIG_BLK_DEV is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_VT is not set +CONFIG_DEVKMEM=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HWMON is not set +CONFIG_FB=y +# CONFIG_USB_SUPPORT is not set +# CONFIG_IOMMU_SUPPORT is not set +CONFIG_EXT2_FS=y +# CONFIG_FILE_LOCKING is not set +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +# CONFIG_PROC_PAGE_MONITOR is not set +# CONFIG_SYSFS is not set +CONFIG_TMPFS=y +# CONFIG_MISC_FILESYSTEMS is not set +# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_PRINTK_TIME=y +CONFIG_DEBUG_SECTION_MISMATCH=y +# CONFIG_FRAME_POINTER is not set +# CONFIG_CRYPTO_HW is not set -- 2.13.0
| |