nios2 Linux kernel port
Subsystems (7)
cover nios2 Linux kernel port
This patchset adds the Linux kernel port for Nios II processor from Altera. The nios2 Linux port follows the guidance for new architecture ports using generic headers (including unistd.h).
About Nios II Cores
-------------------
Nios II is a 32-bit embedded-processor architecture designed specifically for the Altera family of FPGAs.
More information is available at http://www.altera.com/devices/processor/nios2/ni2-index.html
Instruction set and architecture overview documents can be found on the following page:
http://www.altera.com/literature/lit-nio2.jsp
Nios2 GCC port is in mainline and and will be in the FSF 4.9 release.
These patches are also available on this branch:git://git.rocketboards.org/linux-socfpga-next.git nios2-upstream
Regards,
Ley Foon
Ley Foon Tan (28):
nios2: Build infrastructure
nios2: Assembly macros and definitions
nios2: Kernel booting and initialization
nios2: Exception handling
nios2: Traps exception handling
nios2: Memory management
nios2: I/O Mapping
nios2: MMU Fault handling
nios2: Page table management
nios2: Process management
nios2: Cache handling
nios2: TLB handling
nios2: Interrupt handling
nios2: DMA mapping API
nios2: ELF definitions
nios2: System calls handling
nios2: Signal handling support
nios2: Library functions
nios2: Device tree support
nios2: Time keeping
nios2: Cpuinfo handling
nios2: Miscellaneous header files
nios2: Nios2 registers
nios2: Module support
nios2: ptrace support
Add ELF machine define for Nios2
MAINTAINERS: Add nios2 maintainer
Documentation: Add documentation for Nios2 architecture
Documentation/nios2/README | 23 ++ MAINTAINERS | 7 + arch/nios2/Kconfig | 213 +++++++++++ arch/nios2/Kconfig.debug | 17 + arch/nios2/Makefile | 78 ++++ arch/nios2/boot/Makefile | 51 +++ arch/nios2/boot/dts/3c120_devboard.dts | 205 +++++++++++ arch/nios2/boot/linked_dtb.S | 19 + arch/nios2/configs/3c120_defconfig | 77 ++++ arch/nios2/include/asm/Kbuild | 66 ++++ arch/nios2/include/asm/asm-macros.h | 309 ++++++++++++++++ arch/nios2/include/asm/asm-offsets.h | 20 ++ arch/nios2/include/asm/cache.h | 36 ++ arch/nios2/include/asm/cacheflush.h | 48 +++ arch/nios2/include/asm/checksum.h | 78 ++++ arch/nios2/include/asm/cmpxchg.h | 61 ++++ arch/nios2/include/asm/cpuinfo.h | 58 +++ arch/nios2/include/asm/delay.h | 92 +++++ arch/nios2/include/asm/dma-mapping.h | 113 ++++++ arch/nios2/include/asm/elf.h | 101 ++++++ arch/nios2/include/asm/entry.h | 152 ++++++++ arch/nios2/include/asm/gpio.h | 23 ++ arch/nios2/include/asm/io.h | 227 ++++++++++++ arch/nios2/include/asm/irq.h | 34 ++ arch/nios2/include/asm/irqflags.h | 69 ++++ arch/nios2/include/asm/linkage.h | 25 ++ arch/nios2/include/asm/mmu.h | 18 + arch/nios2/include/asm/mmu_context.h | 66 ++++ arch/nios2/include/asm/mutex.h | 1 + arch/nios2/include/asm/page.h | 111 ++++++ arch/nios2/include/asm/pci.h | 25 ++ arch/nios2/include/asm/pgalloc.h | 86 +++++ arch/nios2/include/asm/pgtable-bits.h | 35 ++ arch/nios2/include/asm/pgtable.h | 304 ++++++++++++++++ arch/nios2/include/asm/processor.h | 102 ++++++ arch/nios2/include/asm/prom.h | 26 ++ arch/nios2/include/asm/ptrace.h | 40 +++ arch/nios2/include/asm/registers.h | 65 ++++ arch/nios2/include/asm/setup.h | 38 ++ arch/nios2/include/asm/signal.h | 22 ++ arch/nios2/include/asm/string.h | 24 ++ arch/nios2/include/asm/switch_to.h | 31 ++ arch/nios2/include/asm/syscalls.h | 25 ++ arch/nios2/include/asm/thread_info.h | 120 +++++++ arch/nios2/include/asm/timex.h | 27 ++ arch/nios2/include/asm/tlb.h | 34 ++ arch/nios2/include/asm/tlbflush.h | 46 +++ arch/nios2/include/asm/traps.h | 19 + arch/nios2/include/asm/uaccess.h | 233 ++++++++++++ arch/nios2/include/asm/ucontext.h | 34 ++ arch/nios2/include/uapi/asm/Kbuild | 14 + arch/nios2/include/uapi/asm/byteorder.h | 22 ++ arch/nios2/include/uapi/asm/elf.h | 67 ++++ arch/nios2/include/uapi/asm/ptrace.h | 123 +++++++ arch/nios2/include/uapi/asm/sigcontext.h | 30 ++ arch/nios2/include/uapi/asm/signal.h | 23 ++ arch/nios2/include/uapi/asm/stat.h | 23 ++ arch/nios2/include/uapi/asm/statfs.h | 24 ++ arch/nios2/include/uapi/asm/swab.h | 37 ++ arch/nios2/include/uapi/asm/unistd.h | 25 ++ arch/nios2/kernel/Makefile | 14 + arch/nios2/kernel/asm-offsets.c | 88 +++++ arch/nios2/kernel/cpuinfo.c | 201 +++++++++++ arch/nios2/kernel/entry.S | 551 ++++++++++++++++++++++++++++ arch/nios2/kernel/head.S | 175 +++++++++ arch/nios2/kernel/insnemu.S | 592 +++++++++++++++++++++++++++++++ arch/nios2/kernel/irq.c | 90 +++++ arch/nios2/kernel/misaligned.c | 319 +++++++++++++++++ arch/nios2/kernel/module.c | 135 +++++++ arch/nios2/kernel/nios2_ksyms.c | 35 ++ arch/nios2/kernel/process.c | 262 ++++++++++++++ arch/nios2/kernel/prom.c | 67 ++++ arch/nios2/kernel/ptrace.c | 198 +++++++++++ arch/nios2/kernel/setup.c | 214 +++++++++++ arch/nios2/kernel/signal.c | 364 +++++++++++++++++++ arch/nios2/kernel/sys_nios2.c | 72 ++++ arch/nios2/kernel/syscall_table.c | 29 ++ arch/nios2/kernel/time.c | 150 ++++++++ arch/nios2/kernel/traps.c | 185 ++++++++++ arch/nios2/kernel/vmlinux.lds.S | 75 ++++ arch/nios2/lib/Makefile | 1 + arch/nios2/lib/memcpy.c | 199 +++++++++++ arch/nios2/lib/memmove.c | 82 +++++ arch/nios2/lib/memset.c | 81 +++++ arch/nios2/mm/Makefile | 12 + arch/nios2/mm/cacheflush.c | 255 +++++++++++++ arch/nios2/mm/dma-mapping.c | 186 ++++++++++ arch/nios2/mm/extable.c | 25 ++ arch/nios2/mm/fault.c | 242 +++++++++++++ arch/nios2/mm/init.c | 152 ++++++++ arch/nios2/mm/ioremap.c | 188 ++++++++++ arch/nios2/mm/mmu_context.c | 116 ++++++ arch/nios2/mm/pgtable.c | 73 ++++ arch/nios2/mm/tlb.c | 274 ++++++++++++++ arch/nios2/mm/uaccess.c | 162 +++++++++ arch/nios2/platform/Kconfig.platform | 129 +++++++ arch/nios2/platform/Makefile | 1 + arch/nios2/platform/platform.c | 69 ++++ include/uapi/linux/elf-em.h | 1 + 99 files changed, 10186 insertions(+) create mode 100644 Documentation/nios2/README create mode 100644 arch/nios2/Kconfig create mode 100644 arch/nios2/Kconfig.debug create mode 100644 arch/nios2/Makefile create mode 100644 arch/nios2/boot/Makefile create mode 100644 arch/nios2/boot/dts/3c120_devboard.dts create mode 100644 arch/nios2/boot/linked_dtb.S create mode 100644 arch/nios2/configs/3c120_defconfig create mode 100644 arch/nios2/include/asm/Kbuild create mode 100644 arch/nios2/include/asm/asm-macros.h create mode 100644 arch/nios2/include/asm/asm-offsets.h create mode 100644 arch/nios2/include/asm/cache.h create mode 100644 arch/nios2/include/asm/cacheflush.h create mode 100644 arch/nios2/include/asm/checksum.h create mode 100644 arch/nios2/include/asm/cmpxchg.h create mode 100644 arch/nios2/include/asm/cpuinfo.h create mode 100644 arch/nios2/include/asm/delay.h create mode 100644 arch/nios2/include/asm/dma-mapping.h create mode 100644 arch/nios2/include/asm/elf.h create mode 100644 arch/nios2/include/asm/entry.h create mode 100644 arch/nios2/include/asm/gpio.h create mode 100644 arch/nios2/include/asm/io.h create mode 100644 arch/nios2/include/asm/irq.h create mode 100644 arch/nios2/include/asm/irqflags.h create mode 100644 arch/nios2/include/asm/linkage.h create mode 100644 arch/nios2/include/asm/mmu.h create mode 100644 arch/nios2/include/asm/mmu_context.h create mode 100644 arch/nios2/include/asm/mutex.h create mode 100644 arch/nios2/include/asm/page.h create mode 100644 arch/nios2/include/asm/pci.h create mode 100644 arch/nios2/include/asm/pgalloc.h create mode 100644 arch/nios2/include/asm/pgtable-bits.h create mode 100644 arch/nios2/include/asm/pgtable.h create mode 100644 arch/nios2/include/asm/processor.h create mode 100644 arch/nios2/include/asm/prom.h create mode 100644 arch/nios2/include/asm/ptrace.h create mode 100644 arch/nios2/include/asm/registers.h create mode 100644 arch/nios2/include/asm/setup.h create mode 100644 arch/nios2/include/asm/signal.h create mode 100644 arch/nios2/include/asm/string.h create mode 100644 arch/nios2/include/asm/switch_to.h create mode 100644 arch/nios2/include/asm/syscalls.h create mode 100644 arch/nios2/include/asm/thread_info.h create mode 100644 arch/nios2/include/asm/timex.h create mode 100644 arch/nios2/include/asm/tlb.h create mode 100644 arch/nios2/include/asm/tlbflush.h create mode 100644 arch/nios2/include/asm/traps.h create mode 100644 arch/nios2/include/asm/uaccess.h create mode 100644 arch/nios2/include/asm/ucontext.h create mode 100644 arch/nios2/include/uapi/asm/Kbuild create mode 100644 arch/nios2/include/uapi/asm/byteorder.h create mode 100644 arch/nios2/include/uapi/asm/elf.h create mode 100644 arch/nios2/include/uapi/asm/ptrace.h create mode 100644 arch/nios2/include/uapi/asm/sigcontext.h create mode 100644 arch/nios2/include/uapi/asm/signal.h create mode 100644 arch/nios2/include/uapi/asm/stat.h create mode 100644 arch/nios2/include/uapi/asm/statfs.h create mode 100644 arch/nios2/include/uapi/asm/swab.h create mode 100644 arch/nios2/include/uapi/asm/unistd.h create mode 100644 arch/nios2/kernel/Makefile create mode 100644 arch/nios2/kernel/asm-offsets.c create mode 100644 arch/nios2/kernel/cpuinfo.c create mode 100644 arch/nios2/kernel/entry.S create mode 100644 arch/nios2/kernel/head.S create mode 100644 arch/nios2/kernel/insnemu.S create mode 100644 arch/nios2/kernel/irq.c create mode 100644 arch/nios2/kernel/misaligned.c create mode 100644 arch/nios2/kernel/module.c create mode 100644 arch/nios2/kernel/nios2_ksyms.c create mode 100644 arch/nios2/kernel/process.c create mode 100644 arch/nios2/kernel/prom.c create mode 100644 arch/nios2/kernel/ptrace.c create mode 100644 arch/nios2/kernel/setup.c create mode 100644 arch/nios2/kernel/signal.c create mode 100644 arch/nios2/kernel/sys_nios2.c create mode 100644 arch/nios2/kernel/syscall_table.c create mode 100644 arch/nios2/kernel/time.c create mode 100644 arch/nios2/kernel/traps.c create mode 100644 arch/nios2/kernel/vmlinux.lds.S create mode 100644 arch/nios2/lib/Makefile create mode 100644 arch/nios2/lib/memcpy.c create mode 100644 arch/nios2/lib/memmove.c create mode 100644 arch/nios2/lib/memset.c create mode 100644 arch/nios2/mm/Makefile create mode 100644 arch/nios2/mm/cacheflush.c create mode 100644 arch/nios2/mm/dma-mapping.c create mode 100644 arch/nios2/mm/extable.c create mode 100644 arch/nios2/mm/fault.c create mode 100644 arch/nios2/mm/init.c create mode 100644 arch/nios2/mm/ioremap.c create mode 100644 arch/nios2/mm/mmu_context.c create mode 100644 arch/nios2/mm/pgtable.c create mode 100644 arch/nios2/mm/tlb.c create mode 100644 arch/nios2/mm/uaccess.c create mode 100644 arch/nios2/platform/Kconfig.platform create mode 100644 arch/nios2/platform/Makefile create mode 100644 arch/nios2/platform/platform.c
Signature · 1 line
1.8.3.2
PATCH 1/28 nios2: Build infrastructure
This patch adds Makefile and Kconfig files required for building a nios2 kernel.
--- arch/nios2/Kconfig | 213 +++++++++++++++++++++++++++++++++++ arch/nios2/Kconfig.debug | 17 +++ arch/nios2/Makefile | 78 +++++++++++++ arch/nios2/boot/Makefile | 51 +++++++++ arch/nios2/configs/3c120_defconfig | 77 +++++++++++++ arch/nios2/include/asm/Kbuild | 66 +++++++++++ arch/nios2/include/uapi/asm/Kbuild | 14 +++ arch/nios2/kernel/Makefile | 14 +++ arch/nios2/kernel/nios2_ksyms.c | 35 ++++++ arch/nios2/kernel/vmlinux.lds.S | 75 ++++++++++++ arch/nios2/lib/Makefile | 1 + arch/nios2/mm/Makefile | 12 ++ arch/nios2/platform/Kconfig.platform | 129 +++++++++++++++++++++ arch/nios2/platform/Makefile | 1 + 14 files changed, 783 insertions(+) create mode 100644 arch/nios2/Kconfig create mode 100644 arch/nios2/Kconfig.debug create mode 100644 arch/nios2/Makefile create mode 100644 arch/nios2/boot/Makefile create mode 100644 arch/nios2/configs/3c120_defconfig create mode 100644 arch/nios2/include/asm/Kbuild create mode 100644 arch/nios2/include/uapi/asm/Kbuild create mode 100644 arch/nios2/kernel/Makefile create mode 100644 arch/nios2/kernel/nios2_ksyms.c create mode 100644 arch/nios2/kernel/vmlinux.lds.S create mode 100644 arch/nios2/lib/Makefile create mode 100644 arch/nios2/mm/Makefile create mode 100644 arch/nios2/platform/Kconfig.platform create mode 100644 arch/nios2/platform/Makefile
arch/nios2/Kconfig new file +213 -0
@@ -0,0 +1,213 @@ +config NIOS2 + def_bool y + select OF + select OF_EARLY_FLATTREE + select USB_ARCH_HAS_HCD if USB_SUPPORT + select ARCH_WANT_OPTIONAL_GPIOLIB + select GENERIC_IRQ_PROBE + select GENERIC_IRQ_SHOW + select GENERIC_CPU_DEVICES + select GENERIC_ATOMIC64 + select MODULES_USE_ELF_RELA + select IRQ_DOMAIN + select SOC_BUS + select CLKSRC_OF + +config GENERIC_CSUM + def_bool y + +config GENERIC_FIND_NEXT_BIT + def_bool y + +config GENERIC_HWEIGHT + def_bool y + +config GENERIC_CALIBRATE_DELAY + def_bool y + + +config NO_IOPORT + def_bool y + +config HAS_DMA + def_bool y + +config ZONE_DMA + def_bool y + +config FPU + def_bool n + +config SWAP + def_bool n + +config RWSEM_GENERIC_SPINLOCK + def_bool y + +config TRACE_IRQFLAGS_SUPPORT + def_bool n + +source "init/Kconfig" + +menu "Kernel features" + +source "kernel/Kconfig.preempt" + +source "kernel/Kconfig.freezer" + +source "kernel/Kconfig.hz" + +source "mm/Kconfig" + +config FORCE_MAX_ZONEORDER + int "Maximum zone order" + range 9 20 + default "11" + help + The kernel memory allocator divides physically contiguous memory + blocks into "zones", where each zone is a power of two number of + pages. This option selects the largest power of two that the kernel + keeps in the memory allocator. If you need to allocate very large + blocks of physically contiguous memory, then you may need to + increase this value. + + This config option is actually maximum order plus one. For example, + a value of 11 means that the largest free memory block is 2^10 pages. + +endmenu + +source "arch/nios2/platform/Kconfig.platform" + +menu "Processor type and features" + +config MMU + def_bool y + +config ALIGNMENT_TRAP + bool "Catch alignment trap" + default y + help + Nios II CPUs cannot fetch/store data which is not bus aligned, + i.e., a 2 or 4 byte fetch must start at an address divisible by + 2 or 4. Any non-aligned load/store instructions will be trapped and + emulated in software if you say Y here, which has a performance + impact. + +comment "Boot options" + +config CMDLINE_BOOL + bool "Default bootloader kernel arguments" + default y + +config CMDLINE + string "Default kernel command string" + default "" + depends on CMDLINE_BOOL + help + On some platforms, there is currently no way for the boot loader to + pass arguments to the kernel. For these platforms, you can supply + some command-line options at build time by entering them here. In + other cases you can specify kernel args so that you don't have + to set them up in board prom initialization routines. + +config CMDLINE_FORCE + bool "Force default kernel command string" + depends on CMDLINE_BOOL + help + Set this to have arguments from the default kernel command string + override those passed by the boot loader. + +config CMDLINE_IGNORE_DTB + bool "Ignore kernel command string from DTB" + depends on !CMDLINE_FORCE + default y + help + Set this to ignore the bootargs property from the devicetree's + chosen node and fall back to CMDLINE if nothing is passed. + +config PASS_CMDLINE + bool "Passed kernel command line from u-boot" + default n + help + Use bootargs env variable from u-boot for kernel command line. + will override "Default kernel command string". + Say N if you are unsure. + +config BOOT_LINK_OFFSET + hex "Link address offset for booting" + default "0x00500000" + help + This option allows you to set the link address offset of the zImage. + This can be useful if you are on a board which has a small amount of + memory. + +endmenu + +menu "Advanced setup" + +config ADVANCED_OPTIONS + bool "Prompt for advanced kernel configuration options" + help + +comment "Default settings for advanced configuration options are used" + depends on !ADVANCED_OPTIONS + +config KERNEL_MMU_REGION_BASE_BOOL + bool "Set custom kernel MMU region base address" + depends on ADVANCED_OPTIONS + help + This option allows you to set the virtual address of the kernel MMU region. + + Say N here unless you know what you are doing. + +config KERNEL_MMU_REGION_BASE + hex "Virtual base address of the kernel MMU region " if KERNEL_MMU_REGION_BASE_BOOL + default "0x80000000" + help + This option allows you to set the virtual base address of the kernel MMU region. + +config KERNEL_REGION_BASE_BOOL + bool "Set custom kernel region base address" + depends on ADVANCED_OPTIONS + help + This option allows you to set the virtual address of the kernel region. + + Say N here unless you know what you are doing. + +config KERNEL_REGION_BASE + hex "Virtual base address of the kernel region " if KERNEL_REGION_BASE_BOOL + default "0xc0000000" + +config IO_REGION_BASE_BOOL + bool "Set custom I/O region base address" + depends on ADVANCED_OPTIONS + help + This option allows you to set the virtual address of the I/O region. + + Say N here unless you know what you are doing. + +config IO_REGION_BASE + hex "Virtual base address of the I/O region " if IO_REGION_BASE_BOOL + default "0xe0000000" + +endmenu + +menu "Executable file formats" + +source "fs/Kconfig.binfmt" + +endmenu + +source "net/Kconfig" + +source "drivers/Kconfig" + +source "fs/Kconfig" + +source "arch/nios2/Kconfig.debug" + +source "security/Kconfig" + +source "crypto/Kconfig" + +source "lib/Kconfig"
arch/nios2/Kconfig.debug new file +17 -0
@@ -0,0 +1,17 @@ +menu "Kernel hacking" + +config TRACE_IRQFLAGS_SUPPORT + def_bool y + +source "lib/Kconfig.debug" + +config DEBUG_STACK_USAGE + bool "Enable stack utilization instrumentation" + depends on DEBUG_KERNEL + help + Enables the display of the minimum amount of free stack which each + task has ever had available in the sysrq-T and sysrq-P debug output. + + This option will slow down process creation somewhat. + +endmenu
arch/nios2/Makefile new file +78 -0
78 lines not on this page · raw message
arch/nios2/boot/Makefile new file +51 -0
51 lines not on this page · raw message
arch/nios2/configs/3c120_defconfig new file +77 -0
77 lines not on this page · raw message
arch/nios2/include/asm/Kbuild new file +66 -0
66 lines not on this page · raw message
arch/nios2/include/uapi/asm/Kbuild new file +14 -0
@@ -0,0 +1,14 @@ +include include/uapi/asm-generic/Kbuild.asm + +header-y += byteorder.h +header-y += elf.h +header-y += kvm_para.h +header-y += processor.h +header-y += ptrace.h +header-y += setup.h +header-y += sigcontext.h +header-y += signal.h +header-y += stat.h +header-y += statfs.h +header-y += swab.h +header-y += unistd.h
arch/nios2/kernel/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# Makefile for the nios2 linux kernel. +# + +extra-y := head.o vmlinux.lds + +obj-y += entry.o + +obj-y += cpuinfo.o insnemu.o irq.o nios2_ksyms.o process.o prom.o ptrace.o \ + setup.o signal.o sys_nios2.o syscall_table.o time.o traps.o + +obj-$(CONFIG_MODULES) += module.o +obj-$(CONFIG_CONSOLE) += console.o +obj-$(CONFIG_ALIGNMENT_TRAP) += misaligned.o
arch/nios2/kernel/nios2_ksyms.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* 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. +*/ + +#include <linux/export.h> +#include <linux/string.h> + +/* string functions */ + +EXPORT_SYMBOL (memcpy); +EXPORT_SYMBOL (memset); +EXPORT_SYMBOL (memmove); + +/* +* libgcc functions - functions that are used internally by the +* compiler... (prototypes are not correct though, but that +* doesn't really matter since they're not versioned). +*/ +#define DECLARE_EXPORT (name) extern void name(void); EXPORT_SYMBOL(name) + +DECLARE_EXPORT (__gcc_bcmp); +DECLARE_EXPORT (__divdi3); +DECLARE_EXPORT (__divsi3); +DECLARE_EXPORT (__moddi3); +DECLARE_EXPORT (__modsi3); +DECLARE_EXPORT (__udivdi3); +DECLARE_EXPORT (__udivmoddi4); +DECLARE_EXPORT (__udivsi3); +DECLARE_EXPORT (__umoddi3); +DECLARE_EXPORT (__umodsi3); +DECLARE_EXPORT (__muldi3);
arch/nios2/kernel/vmlinux.lds.S new file +75 -0
75 lines not on this page · raw message
arch/nios2/lib/Makefile new file +1 -0
@@ -0,0 +1 @@ +lib-y = memset.o memcpy.o memmove.o
arch/nios2/mm/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Makefile for the Nios2-specific parts of the memory manager. +# + +obj-y := init.o + +obj-y += cacheflush.o + +obj-y += pgtable.o tlb.o uaccess.o fault.o +obj-y += ioremap.o extable.o mmu_context.o + +obj-y += dma-mapping.o
arch/nios2/platform/Kconfig.platform new file +129 -0
129 lines not on this page · raw message
arch/nios2/platform/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += platform.o
Signature · 1 line
1.8.3.2
PATCH 4/28 nios2: Exception handling
In reply to Ley Foon TanThis patch contains the exception entry code (kernel/entry.S) and misaligned exception.
--- arch/nios2/kernel/entry.S | 551 +++++++++++++++++++++++++++++++++++++++++ arch/nios2/kernel/misaligned.c | 319 ++++++++++++++++++++++++ 2 files changed, 870 insertions(+) create mode 100644 arch/nios2/kernel/entry.S create mode 100644 arch/nios2/kernel/misaligned.c
arch/nios2/kernel/entry.S new file +551 -0
@@ -0,0 +1,551 @@ +/* + * linux/arch/nios2/kernel/entry.S + * + * Copyright (C) 2013 Altera Corporation + * Copyright (C) 2009, Wind River Systems Inc + * + * Implemented by [email protected] and [email protected] + * + * Based on: + * + * linux/arch/nios2/kernel/entry.S + * + * Copyright (C) 1999-2002, Greg Ungerer ([email protected]) + * Copyright (C) 1998 D. Jeff Dionne <[email protected]>, + * Kenneth Albanowski <[email protected]>, + * Copyright (C) 2000 Lineo Inc. (www.lineo.com) + * Copyright (C) 2004 Microtronix Datacom Ltd. + * + * Based on: + * + * linux/arch/m68knommu/kernel/entry.S + * + * Copyright (C) 1991, 1992 Linus Torvalds + * + * 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. + * + * Linux/m68k support by Hamish Macdonald + * + * 68060 fixes by Jesper Skov + * ColdFire support by Greg Ungerer ([email protected]) + * 5307 fixes by David W. Miller + * linux 2.4 support David McCullough <[email protected]> + */ + +#include <linux/sys.h> +#include <linux/linkage.h> +#include <asm/asm-offsets.h> +#include <asm/asm-macros.h> +#include <asm/thread_info.h> +#include <asm/errno.h> +#include <asm/setup.h> +#include <asm/entry.h> +#include <asm/unistd.h> +#include <asm/processor.h> + +.macro GET_THREAD_INFO reg +.if THREAD_SIZE & 0xffff0000 + andhi \reg, sp, %hi(~(THREAD_SIZE-1)) +.else + addi \reg, r0, %lo(~(THREAD_SIZE-1)) + and \reg, \reg, sp +.endif +.endm + +.macro kuser_cmpxchg_check + /* + * Make sure our user space atomic helper is restarted if it was + * interrupted in a critical region. + * ea-4 = address of interrupted insn (ea must be preserved). + * sp = saved regs. + * cmpxchg_ldw = first critical insn, cmpxchg_stw = last critical insn. + * If ea <= cmpxchg_stw and ea > cmpxchg_ldw then saved EA is set to + * cmpxchg_ldw + 4. + */ + /* et = cmpxchg_stw + 4 */ + movui et, (KUSER_BASE + 4 + (cmpxchg_stw - __kuser_helper_start)) + bgtu ea, et, 1f + + subi et, et, (cmpxchg_stw - cmpxchg_ldw) /* et = cmpxchg_ldw + 4 */ + bltu ea, et, 1f + stw et, PT_EA(sp) /* fix up EA */ + mov ea, et +1: +.endm + +.section .rodata +.align 4 +exception_table: + .word unhandled_exception /* 0 - Reset */ + .word unhandled_exception /* 1 - Processor-only Reset */ + .word external_interrupt /* 2 - Interrupt */ + .word handle_trap /* 3 - Trap Instruction */ + + .word instruction_trap /* 4 - Unimplemented instruction */ + .word handle_illegal /* 5 - Illegal instruction */ + .word handle_unaligned /* 6 - Misaligned data access */ + .word handle_unaligned /* 7 - Misaligned destination address */ + + .word handle_diverror /* 8 - Division error */ + .word protection_exception_ba /* 9 - Supervisor-only instr. address */ + .word protection_exception_instr /* 10 - Supervisor only instruction */ + .word protection_exception_ba /* 11 - Supervisor only data address */ + + .word unhandled_exception /* 12 - Double TLB miss (data) */ + .word protection_exception_pte /* 13 - TLB permission violation (x) */ + .word protection_exception_pte /* 14 - TLB permission violation (r) */ + .word protection_exception_pte /* 15 - TLB permission violation (w) */ + + .word unhandled_exception /* 16 - MPU region violation */ + +trap_table: + .word handle_system_call /* 0 */ + .word instruction_trap /* 1 */ + .word instruction_trap /* 2 */ + .word instruction_trap /* 3 */ + .word instruction_trap /* 4 */ + .word instruction_trap /* 5 */ + .word instruction_trap /* 6 */ + .word instruction_trap /* 7 */ + .word instruction_trap /* 8 */ + .word instruction_trap /* 9 */ + .word instruction_trap /* 10 */ + .word instruction_trap /* 11 */ + .word instruction_trap /* 12 */ + .word instruction_trap /* 13 */ + .word instruction_trap /* 14 */ + .word instruction_trap /* 15 */ + .word instruction_trap /* 16 */ + .word instruction_trap /* 17 */ + .word instruction_trap /* 18 */ + .word instruction_trap /* 19 */ + .word instruction_trap /* 20 */ + .word instruction_trap /* 21 */ + .word instruction_trap /* 22 */ + .word instruction_trap /* 23 */ + .word instruction_trap /* 24 */ + .word instruction_trap /* 25 */ + .word instruction_trap /* 26 */ + .word instruction_trap /* 27 */ + .word instruction_trap /* 28 */ + .word instruction_trap /* 29 */ + .word instruction_trap /* 30 */ + .word handle_breakpoint /* 31 */ + +.text +.set noat +.set nobreak + +ENTRY(inthandler) + SAVE_ALL + + kuser_cmpxchg_check + + /* Clear EH bit before we get a new excpetion in the kernel + * and after we have saved it to the exception frame. This is done + * wheter it's trap, tlb-miss or interrupt. If we don't do this + * estatus is not updated the next exception. + */ + rdctl r24, status + movi r9, %lo(~STATUS_EH) + and r24, r24, r9 + wrctl status, r24 + + /* Read cause and vector and branch to the associated handler */ + mov r4, sp + rdctl r5, exception + movia r9, exception_table + add r24, r9, r5 + ldw r24, 0(r24) + jmp r24 + + +/*********************************************************************** + * Handle traps + *********************************************************************** + */ +ENTRY(handle_trap) + ldw r24, -4(ea) /* instruction that caused the exception */ + srli r24, r24, 4 + andi r24, r24, 0x7c + movia r9,trap_table + add r24, r24, r9 + ldw r24, 0(r24) + jmp r24 + + +/*********************************************************************** + * Handle system calls + *********************************************************************** + */ +ENTRY(handle_system_call) + /* Enable interrupts */ + rdctl r10, status + ori r10, r10, STATUS_PIE + wrctl status, r10 + + /* Reload registers destroyed by common code. */ + ldw r4, PT_R4(sp) + ldw r5, PT_R5(sp) + + /* Check that the requested system call is within limits */ + movui r1, __NR_syscalls + bgeu r2, r1, ret_invsyscall + slli r1, r2, 2 + movhi r11, %hiadj(sys_call_table) + add r1, r1, r11 + ldw r1, %lo(sys_call_table)(r1) + beq r1, r0, ret_invsyscall + + /* Get thread info pointer */ + movi r11, %lo(0xfffff000) + and r11, sp, r11 + ldw r11, TI_FLAGS(r11) + + /* If someone is ptrace:ing us, take the long way. */ + BTBNZ r11, r11, TIF_SYSCALL_TRACE, traced_system_call + + /* Execute the system call */ + callr r1 + + /* If the syscall returns a negative result: + * Set r7 to 1 to indicate error, + * Negate r2 to get a positive error code + * If the syscall returns zero or a positive value: + * Set r7 to 0. + * The sigreturn system calls will skip the code below by + * adding to register ra. To avoid destroying registers + */ +translate_rc_and_ret: + movi r1, 0 + bge r2, zero, 3f + sub r2, zero, r2 + movi r1, 1 +3: + stw r2, PT_R2(sp) + stw r1, PT_R7(sp) +end_translate_rc_and_ret: + +ret_from_exception: + ldw r1, PT_ESTATUS(sp) + /* if so, skip resched, signals */ + TSTBNZ r1, r1, ESTATUS_EU, Luser_return + +restore_all: + rdctl r10, status /* disable intrs */ + andi r10, r10, %lo(~STATUS_PIE) + wrctl status, r10 + RESTORE_ALL + eret + + /* If the syscall number was invalid return ENOSYS */ +ret_invsyscall: + movi r2, -ENOSYS + br translate_rc_and_ret + + /* This implements the same as above, except it calls + * syscall_trace before and after the syscall in order + * for utilities like strace and gdb to work. + */ +traced_system_call: + SAVE_SWITCH_STACK + call syscall_trace + RESTORE_SWITCH_STACK + + /* Create system call register arguments. The 5th and 6th + arguments on stack are already in place at the beginning + of pt_regs. */ + ldw r2, PT_R2(sp) + ldw r4, PT_R4(sp) + ldw r5, PT_R5(sp) + ldw r6, PT_R6(sp) + ldw r7, PT_R7(sp) + + /* Fetch the syscall function, we don't need to check the boundaries + * since this is already done. + */ + slli r1, r2, 2 + movhi r11,%hiadj(sys_call_table) + add r1, r1, r11 + ldw r1, %lo(sys_call_table)(r1) + + callr r1 + + /* If the syscall returns a negative result: + * Set r7 to 1 to indicate error, + * Negate r2 to get a positive error code + * If the syscall returns zero or a positive value: + * Set r7 to 0. + * The sigreturn system calls will skip the code below by + * adding to register ra. To avoid destroying registers + */ +translate_rc_and_ret2: + movi r1, 0 + bge r2, zero, 4f + sub r2, zero, r2 + movi r1, 1 +4: + stw r2, PT_R2(sp) + stw r1, PT_R7(sp) +end_translate_rc_and_ret2: + SAVE_SWITCH_STACK + call syscall_trace + RESTORE_SWITCH_STACK + br ret_from_exception + +Luser_return: + GET_THREAD_INFO r11 /* get thread_info pointer */ + ldw r10, TI_FLAGS(r11) /* get thread_info->flags */ + ANDI32 r11, r10, _TIF_WORK_MASK + beq r11, r0, restore_all /* Nothing to do */ + BTBZ r1, r10, TIF_NEED_RESCHED, Lsignal_return + + /* Reschedule work */ + call schedule + br ret_from_exception + +Lsignal_return: + ANDI32 r1, r10, _TIF_SIGPENDING | _TIF_NOTIFY_RESUME + beq r1, r0, restore_all + mov r4, sp /* pt_regs */ + SAVE_SWITCH_STACK + mov r5, r0 /* oldset = 0 */ + movi r6, 1 /* in_syscall = 1 */ + call do_notify_resume + RESTORE_SWITCH_STACK + br restore_all + + + +/*********************************************************************** + * Handle external interrupts. + *********************************************************************** + */ +/* + * This is the generic interrupt handler (for all hardware interrupt + * sources). It figures out the vector number and calls the appropriate + * interrupt service routine directly. + */ +external_interrupt: + rdctl r12, ipending + rdctl r9, ienable + and r12, r12, r9 + /* skip if no interrupt is pending */ + beq r12, r0, ret_from_interrupt + + movi r24, -1 + stw r24, PT_ORIG_R2(sp) + + /* + * Process an external hardware interrupt. + */ + + addi ea, ea, -4 /* re-issue the interrupted instruction */ + stw ea, PT_EA(sp) +2: movi r4, %lo(-1) /* Start from bit position 0, + highest priority */ + /* This is the IRQ # for handler call */ +1: andi r10, r12, 1 /* Isolate bit we are interested in */ + srli r12, r12, 1 /* shift count is costly without hardware + multiplier */ + addi r4, r4, 1 + beq r10, r0, 1b + mov r5, sp /* Setup pt_regs pointer for handler call */ + call do_IRQ + rdctl r12, ipending /* check again if irq still pending */ + rdctl r9, ienable /* Isolate possible interrupts */ + and r12, r12, r9 + bne r12, r0, 2b + /* br ret_from_interrupt */ /* fall throught to ret_from_interrupt */ + +ENTRY(ret_from_interrupt) + ldw r1, PT_ESTATUS(sp) /* check if returning to kernel */ + TSTBNZ r1, r1, ESTATUS_EU, Luser_return + +#ifdef CONFIG_PREEMPT + GET_THREAD_INFO r1 + ldw r4, TI_PREEMPT_COUNT(r1) + bne r4, r0, restore_all + +need_resched: + ldw r4, TI_FLAGS(r1) /* ? Need resched set */ + BTBZ r10, r4, TIF_NEED_RESCHED, restore_all + ldw r4, PT_ESTATUS(sp) /* ? Interrupts off */ + andi r10, r4, ESTATUS_EPIE + beq r10, r0, restore_all + movia r4, PREEMPT_ACTIVE + stw r4, TI_PREEMPT_COUNT(r1) + rdctl r10, status /* enable intrs again */ + ori r10, r10 ,STATUS_PIE + wrctl status, r10 + PUSH r1 + call schedule + POP r1 + mov r4, r0 + stw r4, TI_PREEMPT_COUNT(r1) + rdctl r10, status /* disable intrs */ + andi r10, r10, %lo(~STATUS_PIE) + wrctl status, r10 + br need_resched +#else + br restore_all +#endif + +/*********************************************************************** + * A few syscall wrappers + *********************************************************************** + */ +/* + * int clone(unsigned long clone_flags, unsigned long newsp, + * int __user * parent_tidptr, int __user * child_tidptr, + * int tls_val) + */ +ENTRY(sys_clone) + SAVE_SWITCH_STACK + addi sp, sp, -4 + stw r7, 0(sp) /* Pass 5th arg thru stack */ + mov r7, r6 /* 4th arg is 3rd of clone() */ + mov r6, zero /* 3rd arg always 0 */ + call do_fork + addi sp, sp, 4 + RESTORE_SWITCH_STACK + ret + +ENTRY(sys_rt_sigreturn) + SAVE_SWITCH_STACK + mov r4, sp + call do_rt_sigreturn + RESTORE_SWITCH_STACK + addi ra, ra, (end_translate_rc_and_ret - translate_rc_and_ret) + ret + +/*********************************************************************** + * A few other wrappers and stubs + *********************************************************************** + */ +protection_exception_pte: + rdctl r6, pteaddr + slli r6, r6, 10 + call do_page_fault + br ret_from_exception + +protection_exception_ba: + rdctl r6, badaddr + call do_page_fault + br ret_from_exception + +protection_exception_instr: + call handle_supervisor_instr + br ret_from_exception + +handle_breakpoint: + call breakpoint_c + br ret_from_exception + +#ifdef CONFIG_ALIGNMENT_TRAP +handle_unaligned: + SAVE_SWITCH_STACK + call handle_unaligned_c + RESTORE_SWITCH_STACK + br ret_from_exception +#else +handle_unaligned: + call handle_unaligned_c + br ret_from_exception +#endif + +handle_illegal: + call handle_illegal_c + br ret_from_exception + +handle_diverror: + call handle_diverror_c + br ret_from_exception + +/* + * Beware - when entering resume, prev (the current task) is + * in r4, next (the new task) is in r5, don't change these + * registers. + */ +ENTRY(resume) + + rdctl r7, status /* save thread status reg */ + stw r7, TASK_THREAD + THREAD_KPSR(r4) + + andi r7, r7, %lo(~STATUS_PIE) /* disable interrupts */ + wrctl status, r7 + + SAVE_SWITCH_STACK + stw sp, TASK_THREAD + THREAD_KSP(r4)/* save kernel stack pointer */ + ldw sp, TASK_THREAD + THREAD_KSP(r5)/* restore new thread stack */ + movia r24, _current_thread /* save thread */ + GET_THREAD_INFO r1 + stw r1, 0(r24) + RESTORE_SWITCH_STACK + + ldw r7, TASK_THREAD + THREAD_KPSR(r5)/* restore thread status reg */ + wrctl status, r7 + ret + +ENTRY(ret_from_fork) + call schedule_tail + br ret_from_exception + +ENTRY(ret_from_kernel_thread) + call schedule_tail + mov r4,r17 /* arg */ + callr r16 /* function */ + br ret_from_exception + +/* + * Kernel user helpers. + * + * Each segment is 64-byte aligned and will be mapped to the <User space>. + * New segments (if ever needed) must be added after the existing ones. + * This mechanism should be used only for things that are really small and + * justified, and not be abused freely. + * + */ + + /* Filling pads with undefined instructions. */ +.macro kuser_pad sym size + .if ((. - \sym) & 3) + .rept (4 - (. - \sym) & 3) + .byte 0 + .endr + .endif + .rept ((\size - (. - \sym)) / 4) + .word 0xdeadbeef + .endr +.endm + + .align 6 + .globl __kuser_helper_start +__kuser_helper_start: + +__kuser_helper_version: /* @ 0x1000 */ + .word ((__kuser_helper_end - __kuser_helper_start) >> 6) + +__kuser_cmpxchg: /* @ 0x1004 */ + /* + * r4 pointer to exchange variable + * r5 old value + * r6 new value + */ +cmpxchg_ldw: + ldw r2, 0(r4) /* load current value */ + sub r2, r2, r5 /* compare with old value */ + bne r2, zero, cmpxchg_ret + + /* We had a match, store the new value */ +cmpxchg_stw: + stw r6, 0(r4) +cmpxchg_ret: + ret + + kuser_pad __kuser_cmpxchg, 64 + + .globl __kuser_helper_end +__kuser_helper_end:
arch/nios2/kernel/misaligned.c new file +319 -0
319 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 6/28 nios2: Memory management
In reply to Ley Foon TanThis patch contains the initialisation of the memory blocks, MMU attributes and the memory map.
--- arch/nios2/include/asm/mmu.h | 18 +++ arch/nios2/include/asm/page.h | 111 +++++++++++++++++++ arch/nios2/include/asm/uaccess.h | 233 +++++++++++++++++++++++++++++++++++++++ arch/nios2/mm/init.c | 152 +++++++++++++++++++++++++ arch/nios2/mm/uaccess.c | 162 +++++++++++++++++++++++++++ 5 files changed, 676 insertions(+) create mode 100644 arch/nios2/include/asm/mmu.h create mode 100644 arch/nios2/include/asm/page.h create mode 100644 arch/nios2/include/asm/uaccess.h create mode 100644 arch/nios2/mm/init.c create mode 100644 arch/nios2/mm/uaccess.c
arch/nios2/include/asm/mmu.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* Taken from m68knommu. +* +* 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. +*/ + +#ifndef _ASM_NIOS2_MMU_H +#define _ASM_NIOS2_MMU_H + +/* Default "unsigned long" context */ +typedef unsigned long mm_context_t ; + +#endif /* _ASM_NIOS2_MMU_H */
arch/nios2/include/asm/page.h new file +111 -0
111 lines not on this page · raw message
arch/nios2/include/asm/uaccess.h new file +233 -0
233 lines not on this page · raw message
arch/nios2/mm/init.c new file +152 -0
152 lines not on this page · raw message
arch/nios2/mm/uaccess.c new file +162 -0
162 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 8/28 nios2: MMU Fault handling
In reply to Ley Foon TanThis patch adds support for the handling of the MMU faults (exception entry code introduced by a previous patch, kernel/entry.S).
--- arch/nios2/mm/extable.c | 25 +++++ arch/nios2/mm/fault.c | 242 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 267 insertions(+) create mode 100644 arch/nios2/mm/extable.c create mode 100644 arch/nios2/mm/fault.c
arch/nios2/mm/extable.c new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (C) 2010, Tobias Klauser <[email protected]> +* Copyright (C) 2009, Wind River Systems Inc +* Implemented by [email protected] and [email protected] +* +* 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. +*/ + +#include <linux/module.h> +#include <linux/uaccess.h> + +int fixup_exception (struct pt_regs *regs) +{ +const struct exception_table_entry *fixup; + + fixup =search_exception_tables (regs->ea); +if (fixup) { + regs->ea = fixup->fixup; +return 1 ; + } + +return 0 ; +}
arch/nios2/mm/fault.c new file +242 -0
242 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 11/28 nios2: Cache handling
In reply to Ley Foon TanThis patch adds functionality required for cache maintenance.
--- arch/nios2/include/asm/cache.h | 36 +++++ arch/nios2/include/asm/cacheflush.h | 48 +++++++ arch/nios2/mm/cacheflush.c | 255 ++++++++++++++++++++++++++++++++++++ 3 files changed, 339 insertions(+) create mode 100644 arch/nios2/include/asm/cache.h create mode 100644 arch/nios2/include/asm/cacheflush.h create mode 100644 arch/nios2/mm/cacheflush.c
arch/nios2/include/asm/cache.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* All rights reserved. +* +* 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, GOOD TITLE or +* NON INFRINGEMENT. See the GNU General Public License for more +* details. +*/ + +#ifndef _ASM_NIOS2_CACHE_H +#define _ASM_NIOS2_CACHE_H + +#define NIOS2_DCACHE_SIZE CONFIG_NIOS2_DCACHE_SIZE +#define NIOS2_ICACHE_SIZE CONFIG_NIOS2_ICACHE_SIZE +#define NIOS2_DCACHE_LINE_SIZE CONFIG_NIOS2_DCACHE_LINE_SIZE +#define NIOS2_ICACHE_LINE_SHIFT 5 +#define NIOS2_ICACHE_LINE_SIZE (1 << NIOS2_ICACHE_LINE_SHIFT) + +/* bytes per L1 cache line */ +#define L1_CACHE_SHIFT NIOS2_ICACHE_LINE_SHIFT +#define L1_CACHE_BYTES NIOS2_ICACHE_LINE_SIZE + +#define ARCH_DMA_MINALIGN L1_CACHE_BYTES + +#define __cacheline_aligned +#define ____cacheline_aligned + +#endif
arch/nios2/include/asm/cacheflush.h new file +48 -0
48 lines not on this page · raw message
arch/nios2/mm/cacheflush.c new file +255 -0
255 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 17/28 nios2: Signal handling support
In reply to Ley Foon TanThis patch adds support for signal handling.
--- arch/nios2/include/asm/signal.h | 22 ++ arch/nios2/include/asm/ucontext.h | 34 +++ arch/nios2/include/uapi/asm/sigcontext.h | 30 +++ arch/nios2/include/uapi/asm/signal.h | 23 ++ arch/nios2/kernel/signal.c | 364 +++++++++++++++++++++++++++++++ 5 files changed, 473 insertions(+) create mode 100644 arch/nios2/include/asm/signal.h create mode 100644 arch/nios2/include/asm/ucontext.h create mode 100644 arch/nios2/include/uapi/asm/sigcontext.h create mode 100644 arch/nios2/include/uapi/asm/signal.h create mode 100644 arch/nios2/kernel/signal.c
arch/nios2/include/asm/signal.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright Altera Corporation (C) 2013. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ +#ifndef _NIOS2_SIGNAL_H +#define _NIOS2_SIGNAL_H + +#include <uapi/asm/signal.h> + +#endif /* _NIOS2_SIGNAL_H */
arch/nios2/include/asm/ucontext.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* derived from m68knommu +* +* 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. +*/ + +#ifndef _ASM_NIOS2_UCONTEXT_H +#define _ASM_NIOS2_UCONTEXT_H + +typedef int greg_t ; +#define NGREG 32 +typedef greg_t gregset_t [NGREG ]; + +struct mcontext { +int version; +gregset_t gregs; +}; + +#define MCONTEXT_VERSION 2 + +struct ucontext { +unsigned long uc_flags; +struct ucontext *uc_link; +stack_t uc_stack; +struct mcontext uc_mcontext; +sigset_t uc_sigmask;/* mask last for extensibility */ +}; + +#endif
arch/nios2/include/uapi/asm/sigcontext.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Taken from the m68knommu. +* +* Copyright (C) 2004, Microtronix Datacom Ltd. +* +* All rights reserved. +* +* 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, GOOD TITLE or +* NON INFRINGEMENT. See the GNU General Public License for more +* details. +*/ + +#ifndef _ASM_NIOS2_SIGCONTEXT_H +#define _ASM_NIOS2_SIGCONTEXT_H + +#include <asm/ptrace.h> + +struct sigcontext { +struct pt_regs regs; +unsigned long sc_mask;/* old sigmask */ +}; + +#endif
arch/nios2/include/uapi/asm/signal.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright Altera Corporation (C) 2013. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ +#ifndef _ASM_NIOS2_SIGNAL_H +#define _ASM_NIOS2_SIGNAL_H + +#define SA_RESTORER 0x04000000 +#include <asm-generic/signal.h> + +#endif /* _ASM_NIOS2_SIGNAL_H */
arch/nios2/kernel/signal.c new file +364 -0
364 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 19/28 nios2: Device tree support
In reply to Ley Foon TanAdd device tree support to arch/nios2.
--- arch/nios2/boot/dts/3c120_devboard.dts | 205 +++++++++++++++++++++++++++++++++ arch/nios2/boot/linked_dtb.S | 19 +++ arch/nios2/include/asm/prom.h | 26 +++++ arch/nios2/kernel/prom.c | 67 +++++++++++ arch/nios2/platform/platform.c | 69 +++++++++++ 5 files changed, 386 insertions(+) create mode 100644 arch/nios2/boot/dts/3c120_devboard.dts create mode 100644 arch/nios2/boot/linked_dtb.S create mode 100644 arch/nios2/include/asm/prom.h create mode 100644 arch/nios2/kernel/prom.c create mode 100644 arch/nios2/platform/platform.c
arch/nios2/boot/dts/3c120_devboard.dts new file +205 -0
@@ -0,0 +1,205 @@ +/* + * Copyright (C) 2013 Altera Corporation + * + * 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, see <http://www.gnu.org/licenses/>. + * + * This file is generated by sopc2dts. + */ + +/dts-v1/; + +/ { + model = "ALTR,qsys_ghrd_3c120"; + compatible = "ALTR,qsys_ghrd_3c120"; + #address-cells = < 1 >; + #size-cells = < 1 >; + + cpus { + #address-cells = < 1 >; + #size-cells = < 0 >; + + cpu: cpu@0x0 { + device_type = "cpu"; + compatible = "ALTR,nios2-1.0"; + reg = < 0x00000000 >; + interrupt-controller; + #interrupt-cells = < 1 >; + clock-frequency = < 125000000 >; + dcache-line-size = < 32 >; + icache-line-size = < 32 >; + dcache-size = < 32768 >; + icache-size = < 32768 >; + ALTR,implementation = "fast"; + ALTR,pid-num-bits = < 8 >; + ALTR,tlb-num-ways = < 16 >; + ALTR,tlb-num-entries = < 128 >; + ALTR,tlb-ptr-sz = < 7 >; + ALTR,has-div = < 1 >; + ALTR,has-mul = < 1 >; + ALTR,reset-addr = < 0xc2800000 >; + ALTR,fast-tlb-miss-addr = < 0xc7fff400 >; + ALTR,exception-addr = < 0xd0000020 >; + ALTR,has-initda = < 1 >; + ALTR,has-mmu = < 1 >; + }; //end cpu@0x0 (cpu) + }; //end cpus + + memory@0 { + device_type = "memory"; + reg = < 0x10000000 0x08000000 + 0x07FFF400 0x00000400 >; + }; //end memory@0 + + sopc@0 { + device_type = "soc"; + ranges; + #address-cells = < 1 >; + #size-cells = < 1 >; + compatible = "ALTR,avalon", "simple-bus"; + bus-frequency = < 125000000 >; + + pb_cpu_to_io: bridge@0x8000000 { + compatible = "simple-bus"; + reg = < 0x08000000 0x00800000 >; + #address-cells = < 1 >; + #size-cells = < 1 >; + ranges = < 0x00400000 0x08400000 0x00000020 + 0x00004D40 0x08004D40 0x00000008 + 0x00004D50 0x08004D50 0x00000008 + 0x00004000 0x08004000 0x00000400 + 0x00004400 0x08004400 0x00000040 + 0x00004800 0x08004800 0x00000040 + 0x00002000 0x08002000 0x00002000 + 0x00004C80 0x08004C80 0x00000020 + 0x00004CC0 0x08004CC0 0x00000010 + 0x00004CE0 0x08004CE0 0x00000010 + 0x00004D00 0x08004D00 0x00000010 >; + + timer_1ms: timer@0x400000 { + compatible = "ALTR,timer-1.0"; + reg = < 0x00400000 0x00000020 >; + interrupt-parent = < &cpu >; + interrupts = < 11 >; + clock-frequency = < 125000000 >; + }; //end timer@0x400000 (timer_1ms) + + sysid: sysid@0x4d40 { + compatible = "ALTR,sysid-1.0"; + reg = < 0x00004D40 0x00000008 >; + id = < 0 >; + timestamp = < 1364882880 >; + }; //end sysid@0x4d40 (sysid) + + jtag_uart: serial@0x4d50 { + compatible = "ALTR,juart-1.0"; + reg = < 0x00004D50 0x00000008 >; + interrupt-parent = < &cpu >; + interrupts = < 1 >; + }; //end serial@0x4d50 (jtag_uart) + + tse_mac: ethernet@0x4000 { + compatible = "ALTR,tse-1.0"; + reg = < 0x00004000 0x00000400 + 0x00004400 0x00000040 + 0x00004800 0x00000040 + 0x00002000 0x00002000 >; + reg-names = "control_port", "rx_csr", "tx_csr", "s1"; + interrupt-parent = < &cpu >; + interrupts = < 2 3 >; + interrupt-names = "rx_irq", "tx_irq"; + rx-fifo-depth = < 8192 >; + tx-fifo-depth = < 8192 >; + address-bits = < 48 >; + max-frame-size = < 1518 >; + local-mac-address = [ 02 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + ALTR,mii-id = < 0 >; + phy-handle = < &phy0 >; + tse_mac_mdio: mdio { + compatible = "altr,tse-mdio"; + #address-cells = < 1 >; + #size-cells = < 0 >; + phy0: ethernet-phy@18 { + reg = < 18 >; + device_type = "ethernet-phy"; + }; + }; + }; //end ethernet@0x4000 (tse_mac) + + uart: serial@0x4c80 { + compatible = "ALTR,uart-1.0"; + reg = < 0x00004C80 0x00000020 >; + interrupt-parent = < &cpu >; + interrupts = < 10 >; + current-speed = < 115200 >; + clock-frequency = < 62500000 >; + }; //end serial@0x4c80 (uart) + + user_led_pio_8out: gpio@0x4cc0 { + compatible = "ALTR,pio-1.0"; + reg = < 0x00004CC0 0x00000010 >; + width = < 8 >; + resetvalue = < 255 >; + #gpio-cells = < 2 >; + gpio-controller; + }; //end gpio@0x4cc0 (user_led_pio_8out) + + user_dipsw_pio_8in: gpio@0x4ce0 { + compatible = "ALTR,pio-1.0"; + reg = < 0x00004CE0 0x00000010 >; + interrupt-parent = < &cpu >; + interrupts = < 8 >; + width = < 8 >; + resetvalue = < 0 >; + edge_type = < 2 >; + level_trigger = < 0 >; + altr,interrupt_type = < 3 >; + #gpio-cells = < 2 >; + gpio-controller; + }; //end gpio@0x4ce0 (user_dipsw_pio_8in) + + user_pb_pio_4in: gpio@0x4d00 { + compatible = "ALTR,pio-1.0"; + reg = < 0x00004D00 0x00000010 >; + interrupt-parent = < &cpu >; + interrupts = < 9 >; + width = < 4 >; + resetvalue = < 0 >; + edge_type = < 2 >; + level_trigger = < 0 >; + altr,interrupt_type = < 3 >; + #gpio-cells = < 2 >; + gpio-controller; + }; //end gpio@0x4d00 (user_pb_pio_4in) + }; //end bridge@0x8000000 (pb_cpu_to_io) + + cfi_flash_64m: flash@0x0 { + compatible = "cfi-flash"; + reg = < 0x00000000 0x04000000 >; + bank-width = < 2 >; + device-width = < 1 >; + #address-cells = < 1 >; + #size-cells = < 1 >; + + partition@800000 { + reg = < 0x00800000 0x01E00000 >; + label = "JFFS2 Filesystem"; + }; //end partition@800000 + }; //end flash@0x0 (cfi_flash_64m) + }; //end sopc@0 + + chosen { + bootargs = "debug console=ttyJ0,115200"; + }; //end chosen +}; //end /
arch/nios2/boot/linked_dtb.S new file +19 -0
@@ -0,0 +1,19 @@ +/* + * Copyright (C) 2011 Thomas Chou <[email protected]> + * + * 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, see <http://www.gnu.org/licenses/>. + * + */ +.section .dtb.init.rodata,"a" +.incbin "arch/nios2/boot/system.dtb"
arch/nios2/include/asm/prom.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_PROM_H +#define _ASM_NIOS2_PROM_H + +extern int __dtb_start; + +extern unsigned long early_altera_uart_or_juart_console (void ); + +#endif /* _ASM_NIOS2_PROM_H */
arch/nios2/kernel/prom.c new file +67 -0
67 lines not on this page · raw message
arch/nios2/platform/platform.c new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 20/28 nios2: Time keeping
In reply to Ley Foon TanAdd time keeping code for nios2.
--- arch/nios2/include/asm/delay.h | 92 +++++++++++++++++++++++++ arch/nios2/include/asm/timex.h | 27 ++++++++ arch/nios2/kernel/time.c | 150 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+) create mode 100644 arch/nios2/include/asm/delay.h create mode 100644 arch/nios2/include/asm/timex.h create mode 100644 arch/nios2/kernel/time.c
arch/nios2/include/asm/delay.h new file +92 -0
@@ -0,0 +1,92 @@ +/* +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* 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. +*/ + +#ifndef _ASM_NIOS2_DELAY_H +#define _ASM_NIOS2_DELAY_H + +#include <asm/param.h> + +static inline void __delay (unsigned long loops) +{ +int dummy; + + __asm__ __volatile__( +"1:\n\t" +" beq %0,zero,2f\n\t" +" addi %0, %0, -1\n\t" +" br 1b\n\t" +"2:\n\t" + :"=r" (dummy)/* Need output for optimizer */ + :"0" (loops));/* %0 Input */ +} + +/* +* Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so +* loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32. +* +* The mul instruction gives us loops = (a * b) / 2^32. +* We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226 +* because this lets us support a wide range of HZ and +* loops_per_jiffy values without either a or b overflowing 2^32. +* Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and +* loops_per_jiffy <= (2^32 - 1) / 226 = 19004280 +* (which corresponds to ~3800 bogomips at HZ = 100). +* -- paulus +*/ +#define __MAX_UDELAY (226050910UL/HZ)/* maximum udelay argument */ +#define __MAX_NDELAY (4294967295UL/HZ)/* maximum ndelay argument */ + +extern unsigned long loops_per_jiffy; + +static inline void __udelay (unsigned int x) +{ +unsigned int loops; + +/* +* Note, if this is compiled with -mhw-mulx it will produce a "mulxuu" +* (at least in toolchain 145) so there is no need for inline +* assembly here anymore, which might in turn be emulated if unsupported +* by the design. +*/ + loops = (unsigned int )((((unsigned long long )(x) * + (unsigned long long )(loops_per_jiffy *226 ))) >>32 ); + +/* +__asm__("mulxuu %0,%1,%2" : "=r" (loops) : +"r" (x), "r" (loops_per_jiffy * 226)); +*/ +__delay (loops); +} + +static inline void __ndelay (unsigned int x) +{ +unsigned int loops; + +/* see comment in __udelay */ + loops = (unsigned int )((((unsigned long long )(x) * + (unsigned long long )(loops_per_jiffy *5 ))) >>32 ); + +/* +__asm__("mulxuu %0,%1,%2" : "=r" (loops) : +"r" (x), "r" (loops_per_jiffy * 5)); +*/ +__delay (loops); +} + +extern void __bad_udelay (void );/* deliberately undefined */ +extern void __bad_ndelay (void );/* deliberately undefined */ + +#define udelay (n) (__builtin_constant_p(n) ? \ + ((n) > __MAX_UDELAY ? __bad_udelay() : __udelay((n) * (19 * HZ))) : \ + __udelay((n) * (19 * HZ))) + +#define ndelay (n) (__builtin_constant_p(n) ? \ + ((n) > __MAX_NDELAY ? __bad_ndelay() : __ndelay((n) * HZ)) : \ + __ndelay((n) * HZ)) + +#endif /* _ASM_NIOS2_DELAY_H */
arch/nios2/include/asm/timex.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 2010 Thomas Chou <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_TIMEX_H +#define _ASM_NIOS2_TIMEX_H + +/* Supply dummy tick-rate. Real value will be read from devicetree */ +#define CLOCK_TICK_RATE (HZ * 100000UL) + +#include <asm-generic/timex.h> + +#endif
arch/nios2/kernel/time.c new file +150 -0
150 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 21/28 nios2: Cpuinfo handling
In reply to Ley Foon Tan--- arch/nios2/include/asm/cpuinfo.h | 58 +++++++++++ arch/nios2/kernel/cpuinfo.c | 201 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 arch/nios2/include/asm/cpuinfo.h create mode 100644 arch/nios2/kernel/cpuinfo.c
arch/nios2/include/asm/cpuinfo.h new file +58 -0
@@ -0,0 +1,58 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_CPUINFO_H +#define _ASM_NIOS2_CPUINFO_H + +#include <linux/types.h> +#include <asm/prom.h> + +struct cpuinfo { +/* Core CPU configuration */ +char cpu_impl[12 ]; +u32 cpu_clock_freq; +u32 mmu; +u32 has_div; +u32 has_mul; +u32 has_mulx; + +/* CPU caches */ +u32 icache_line_size; +u32 icache_size; +u32 dcache_line_size; +u32 dcache_size; + +/* TLB */ +u32 tlb_pid_num_bits;/* number of bits used for the PID in TLBMISC */ +u32 tlb_num_ways; +u32 tlb_num_ways_log2; +u32 tlb_num_entries; +u32 tlb_num_lines; +u32 tlb_ptr_sz; + +/* Addresses */ +u32 reset_addr; +u32 exception_addr; +u32 fast_tlb_miss_exc_addr; +}; + +extern struct cpuinfo cpuinfo; + +extern void setup_cpuinfo (void ); + +#endif /* _ASM_NIOS2_CPUINFO_H */
arch/nios2/kernel/cpuinfo.c new file +201 -0
201 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 24/28 nios2: Module support
In reply to Ley Foon TanThis patch adds support for loadable modules.
--- arch/nios2/kernel/module.c | 135 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 arch/nios2/kernel/module.c
arch/nios2/kernel/module.c new file +135 -0
@@ -0,0 +1,135 @@ +/* +* Kernel module support for Nios II. +* +* Copyright (C) 2004 Microtronix Datacom Ltd. +* Written by Wentao Xu <[email protected]> +* Copyright (C) 2001, 2003 Rusty Russell +* +* 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. +*/ + +#include <linux/moduleloader.h> +#include <linux/elf.h> +#include <linux/mm.h> +#include <linux/vmalloc.h> +#include <linux/slab.h> +#include <linux/fs.h> +#include <linux/string.h> +#include <linux/kernel.h> + +#include <asm/pgtable.h> +#include <asm/cacheflush.h> + +void *module_alloc (unsigned long size) +{ +if (size ==0 ) +return NULL ; +return kmalloc (size,GFP_KERNEL ); +} + +/* Free memory returned from module_alloc */ +void module_free (struct module *mod,void *module_region) +{ +kfree (module_region); +} + +int apply_relocate_add (Elf32_Shdr *sechdrs,const char *strtab, +unsigned int symindex,unsigned int relsec, +struct module *mod) +{ +unsigned int i; +Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr; + +pr_debug ("Applying relocate section %u to %u\n" , relsec, + sechdrs[relsec].sh_info); + +for (i =0 ; i < sechdrs[relsec].sh_size /sizeof (*rela); i++) { +/* This is where to make the change */ +uint32_t word; +uint32_t *loc + = ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + + rela[i].r_offset); +/* This is the symbol it is referring to. Note that all +undefined symbols have been resolved. */ +Elf32_Sym *sym + = ((Elf32_Sym *)sechdrs[symindex].sh_addr + +ELF32_R_SYM (rela[i].r_info)); +uint32_t v = sym->st_value + rela[i].r_addend; +pr_debug ("reltype %d 0x%x name:<%s>\n" , +ELF32_R_TYPE (rela[i].r_info), + rela[i].r_offset, strtab + sym->st_name); + +switch (ELF32_R_TYPE (rela[i].r_info)) { +case R_NIOS2_NONE : +break ; +case R_NIOS2_BFD_RELOC_32 : + *loc += v; +break ; +case R_NIOS2_PCREL16 : + v -= (uint32_t )loc +4 ; +if ((int32_t )v >0x7fff || + (int32_t )v < -(int32_t )0x8000 ) { +pr_err ("module %s: relocation overflow\n" , + mod->name); +return -ENOEXEC ; + } + word = *loc; + *loc = ((((word >>22 ) <<16 ) | (v &0xffff )) <<6 ) | + (word &0x3f ); +break ; +case R_NIOS2_CALL26 : +if (v &3 ) { +pr_err ("module %s: dangerous relocation\n" , + mod->name); +return -ENOEXEC ; + } +if ((v >>28 ) != ((uint32_t )loc >>28 )) { +pr_err ("module %s: relocation overflow\n" , + mod->name); +return -ENOEXEC ; + } + *loc = (*loc &0x3f ) | ((v >>2 ) <<6 ); +break ; +case R_NIOS2_HI16 : + word = *loc; + *loc = ((((word >>22 ) <<16 ) | + ((v >>16 ) &0xffff )) <<6 ) | (word &0x3f ); +break ; +case R_NIOS2_LO16 : + word = *loc; + *loc = ((((word >>22 ) <<16 ) | (v &0xffff )) <<6 ) | + (word &0x3f ); +break ; +case R_NIOS2_HIADJ16 : + { +Elf32_Addr word2; + + word = *loc; + word2 = ((v >>16 ) + ((v >>15 ) &1 )) &0xffff ; + *loc = ((((word >>22 ) <<16 ) | word2) <<6 ) | + (word &0x3f ); + } +break ; + +default : +pr_err ("module %s: Unknown reloc: %u\n" , + mod->name,ELF32_R_TYPE (rela[i].r_info)); +return -ENOEXEC ; + } + } + +return 0 ; +} + +int module_finalize (const Elf_Ehdr *hdr,const Elf_Shdr *sechdrs, +struct module *me) +{ +flush_cache_all (); +return 0 ; +} + +void module_arch_cleanup (struct module *mod) +{ +}
Signature · 1 line
1.8.3.2
PATCH 25/28 nios2: ptrace support
In reply to Ley Foon TanAdd ptrace support for nios2.
--- arch/nios2/include/asm/ptrace.h | 40 +++++++ arch/nios2/include/uapi/asm/ptrace.h | 123 ++++++++++++++++++++++ arch/nios2/kernel/ptrace.c | 198 +++++++++++++++++++++++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 arch/nios2/include/asm/ptrace.h create mode 100644 arch/nios2/include/uapi/asm/ptrace.h create mode 100644 arch/nios2/kernel/ptrace.c
arch/nios2/include/asm/ptrace.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2013 Altera Corporation +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* based on m68k asm/processor.h +* +* 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. +*/ + +#ifndef _ASM_NIOS2_PTRACE_H +#define _ASM_NIOS2_PTRACE_H + +#include <uapi/asm/ptrace.h> + +#ifndef __ASSEMBLY__ + +/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 + +/* +* Supervisor mode +*/ + +# define user_mode (regs) (((regs)->estatus & ESTATUS_EU)) + + +#define instruction_pointer (regs) ((regs)->ra) +#define profile_pc (regs) instruction_pointer(regs) +#define user_stack_pointer (regs) ((regs)->sp) +extern void show_regs (struct pt_regs *); + +#define current_pt_regs () \ + ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\ + - 1) +#endif /* __ASSEMBLY__ */ +#endif /* _ASM_NIOS2_PTRACE_H */
arch/nios2/include/uapi/asm/ptrace.h new file +123 -0
123 lines not on this page · raw message
arch/nios2/kernel/ptrace.c new file +198 -0
198 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 26/28 Add ELF machine define for Nios2
In reply to Ley Foon Tan--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/elf-em.h +1 -0
@@ -33,6 +33,7 @@#define EM_M32R 88/* Renesas M32R */ #define EM_MN10300 89/* Panasonic/MEI MN10300, AM33 */ #define EM_BLACKFIN 106/* ADI Blackfin Processor */ +#define EM_ALTERA_NIOS2 113/* Altera Nios II soft-core processor */ #define EM_TI_C6000 140/* TI C6X DSPs */ #define EM_AARCH64 183/* ARM 64 bit */ #define EM_FRV 0x5441/* Fujitsu FR-V */
Signature · 1 line
1.8.3.2
PATCH 28/28 Documentation: Add documentation for Nios2 architecture
In reply to Ley Foon Tan--- Documentation/nios2/README | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/nios2/README
Documentation/nios2/README new file +23 -0
@@ -0,0 +1,23 @@ +Linux on the Nios II architecture +================================= + +This is a port of Linux to Nios II (nios2) processor. + +In order to compile for Nios II, you need a version of GCC with support for the generic +system call ABI. Please see this link for more information on how compiling and booting +software for the Nios II platform: +http://www.rocketboards.org/foswiki/Documentation/NiosIILinuxUserManual + +For reference, please see the following link: +http://www.altera.com/literature/lit-nio2.jsp + +What is Nios II? +================ +Nios II is a 32-bit embedded-processor architecture designed specifically for the +Altera family of FPGAs. In order to support Linux system, Nios II needs to configure +with MMU and hardware multiplier enabled. + +Nios II ABI +=========== +Please refer to chapter "Application Binary Interface" in Nios II Processor Reference +Handbook.
Signature · 1 line
1.8.3.2
PATCH 9/28 nios2: Page table management
In reply to Ley Foon TanThis patch adds support for page table management.
--- arch/nios2/include/asm/pgalloc.h | 86 ++++++++++ arch/nios2/include/asm/pgtable-bits.h | 35 ++++ arch/nios2/include/asm/pgtable.h | 304 ++++++++++++++++++++++++++++++++++ arch/nios2/mm/pgtable.c | 73 ++++++++ 4 files changed, 498 insertions(+) create mode 100644 arch/nios2/include/asm/pgalloc.h create mode 100644 arch/nios2/include/asm/pgtable-bits.h create mode 100644 arch/nios2/include/asm/pgtable.h create mode 100644 arch/nios2/mm/pgtable.c
arch/nios2/include/asm/pgalloc.h new file +86 -0
@@ -0,0 +1,86 @@ +/* +* 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. +* +* Copyright (C) 1994 - 2001, 2003 by Ralf Baechle +* Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc. +*/ + +#ifndef _ASM_NIOS2_PGALLOC_H +#define _ASM_NIOS2_PGALLOC_H + +#include <linux/mm.h> + +static inline void pmd_populate_kernel (struct mm_struct *mm,pmd_t *pmd, +pte_t *pte) +{ +set_pmd (pmd,__pmd ((unsigned long )pte)); +} + +static inline void pmd_populate (struct mm_struct *mm,pmd_t *pmd, +pgtable_t pte) +{ +set_pmd (pmd,__pmd ((unsigned long )page_address (pte))); +} +#define pmd_pgtable (pmd) pmd_page(pmd) + +/* +* Initialize a new pmd table with invalid pointers. +*/ +extern void pmd_init (unsigned long page,unsigned long pagetable); + +extern pgd_t *pgd_alloc (struct mm_struct *mm); + +static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) +{ +free_pages ((unsigned long )pgd,PGD_ORDER ); +} + +static inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm, +unsigned long address) +{ +pte_t *pte; + + pte = (pte_t *)__get_free_pages (GFP_KERNEL |__GFP_REPEAT|__GFP_ZERO, +PTE_ORDER ); + +return pte; +} + +static inline pgtable_t pte_alloc_one (struct mm_struct *mm, +unsigned long address) +{ +struct page *pte; + + pte =alloc_pages (GFP_KERNEL | __GFP_REPEAT,PTE_ORDER ); +if (pte) { +if (!pgtable_page_ctor (pte)) { +__free_page (pte); +return NULL ; + } +clear_highpage (pte); + } +return pte; +} + +static inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) +{ +free_pages ((unsigned long )pte,PTE_ORDER ); +} + +static inline void pte_free (struct mm_struct *mm,struct page *pte) +{ +pgtable_page_dtor (pte); +__free_pages (pte,PTE_ORDER ); +} + +#define __pte_free_tlb (tlb, pte, addr) \ + do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb), (pte)); \ + } while (0) + +#define check_pgt_cache () do { } while (0) + +#endif /* _ASM_NIOS2_PGALLOC_H */
arch/nios2/include/asm/pgtable-bits.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* Copyright (C) 2009 Wind River Systems Inc +* +* 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. +*/ + +#ifndef _ASM_NIOS2_PGTABLE_BITS_H +#define _ASM_NIOS2_PGTABLE_BITS_H + +/* +* These are actual hardware defined protection bits in the tlbacc register +* which looks like this: +* +* 31 30 ... 26 25 24 23 22 21 20 19 18 ... 1 0 +* ignored........ C R W X G PFN............ +*/ +#define _PAGE_GLOBAL (1<<20) +#define _PAGE_EXEC (1<<21) +#define _PAGE_WRITE (1<<22) +#define _PAGE_READ (1<<23) +#define _PAGE_CACHED (1<<24)/* C: data access cacheable */ + +/* +* Software defined bits. They are ignored by the hardware and always read back +* as zero, but can be written as non-zero. +*/ +#define _PAGE_PRESENT (1<<25)/* PTE contains a translation */ +#define _PAGE_ACCESSED (1<<26)/* page referenced */ +#define _PAGE_DIRTY (1<<27)/* dirty page */ +#define _PAGE_FILE (1<<28)/* PTE used for file mapping or swap */ + +#endif /* _ASM_NIOS2_PGTABLE_BITS_H */
arch/nios2/include/asm/pgtable.h new file +304 -0
304 lines not on this page · raw message
arch/nios2/mm/pgtable.c new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 12/28 nios2: TLB handling
In reply to Ley Foon TanThis patch adds the TLB maintenance functions.
--- arch/nios2/include/asm/tlb.h | 34 +++++ arch/nios2/include/asm/tlbflush.h | 46 +++++++ arch/nios2/mm/tlb.c | 274 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 354 insertions(+) create mode 100644 arch/nios2/include/asm/tlb.h create mode 100644 arch/nios2/include/asm/tlbflush.h create mode 100644 arch/nios2/mm/tlb.c
arch/nios2/include/asm/tlb.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2009 Wind River Systems Inc +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* 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. +*/ + +#ifndef _ASM_NIOS2_TLB_H +#define _ASM_NIOS2_TLB_H + +#define tlb_flush (tlb) flush_tlb_mm((tlb)->mm) + +extern void set_mmu_pid (unsigned long pid); + +/* +* NiosII doesn't need any special per-pte or per-vma handling, except +* we need to flush cache for the area to be unmapped. +*/ +#define tlb_start_vma (tlb, vma) \ + do { \ + if (!tlb->fullmm) \ + flush_cache_range(vma, vma->vm_start, vma->vm_end); \ + } while (0) + +#define tlb_end_vma (tlb, vma) do { } while (0) +#define __tlb_remove_tlb_entry (tlb, ptep, address) do { } while (0) + +#include <linux/pagemap.h> +#include <asm-generic/tlb.h> + +#endif /* _ASM_NIOS2_TLB_H */
arch/nios2/include/asm/tlbflush.h new file +46 -0
46 lines not on this page · raw message
arch/nios2/mm/tlb.c new file +274 -0
274 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 15/28 nios2: ELF definitions
In reply to Ley Foon TanThis patch adds definitions for the ELF format
--- arch/nios2/include/asm/elf.h | 101 ++++++++++++++++++++++++++++++++++++++ arch/nios2/include/uapi/asm/elf.h | 67 +++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 arch/nios2/include/asm/elf.h create mode 100644 arch/nios2/include/uapi/asm/elf.h
arch/nios2/include/asm/elf.h new file +101 -0
@@ -0,0 +1,101 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_ELF_H +#define _ASM_NIOS2_ELF_H + +#include <uapi/asm/elf.h> + +/* +* This is used to ensure we don't load something for the wrong architecture. +*/ +#define elf_check_arch (x) ((x)->e_machine == EM_ALTERA_NIOS2) + +#define ELF_PLAT_INIT (_r, load_addr) + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +/* This is the location that an ET_DYN program is loaded if exec'ed. Typical +use of this is to invoke "./ld.so someprog" to test out a new version of +the loader. We need to make sure that it is out of the way of the program +that it will "exec", and that there is sufficient room for the brk. */ + +#define ELF_ET_DYN_BASE 0xD0000000UL + +/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is +now struct_user_regs, they are different) */ + +#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 +struct linux_binprm ; +extern int arch_setup_additional_pages (struct linux_binprm *bprm, +int uses_interp); +#define ELF_CORE_COPY_REGS(pr_reg, regs) \ +{ do { \ + /* Bleech. */ \ + pr_reg[0] = regs->r8; \ + pr_reg[1] = regs->r9; \ + pr_reg[2] = regs->r10; \ + pr_reg[3] = regs->r11; \ + pr_reg[4] = regs->r12; \ + pr_reg[5] = regs->r13; \ + pr_reg[6] = regs->r14; \ + pr_reg[7] = regs->r15; \ + pr_reg[8] = regs->r1; \ + pr_reg[9] = regs->r2; \ + pr_reg[10] = regs->r3; \ + pr_reg[11] = regs->r4; \ + pr_reg[12] = regs->r5; \ + pr_reg[13] = regs->r6; \ + pr_reg[14] = regs->r7; \ + pr_reg[15] = regs->orig_r2; \ + pr_reg[16] = regs->ra; \ + pr_reg[17] = regs->fp; \ + pr_reg[18] = regs->sp; \ + pr_reg[19] = regs->gp; \ + pr_reg[20] = regs->estatus; \ + pr_reg[21] = regs->ea; \ + pr_reg[22] = regs->orig_r7; \ + { \ + struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \ + pr_reg[23] = sw->r16; \ + pr_reg[24] = sw->r17; \ + pr_reg[25] = sw->r18; \ + pr_reg[26] = sw->r19; \ + pr_reg[27] = sw->r20; \ + pr_reg[28] = sw->r21; \ + pr_reg[29] = sw->r22; \ + pr_reg[30] = sw->r23; \ + pr_reg[31] = sw->fp; \ + pr_reg[32] = sw->gp; \ + pr_reg[33] = sw->ra; \ + } \ +} while (0); } + +/* This yields a mask that user programs can use to figure out what +instruction set this cpu supports. */ + +#define ELF_HWCAP (0) + +/* This yields a string that ld.so will use to load implementation +specific libraries for optimization. This is more specific in +intent than poking at uname or /proc/cpuinfo. */ + +#define ELF_PLATFORM (NULL) + +#endif /* _ASM_NIOS2_ELF_H */
arch/nios2/include/uapi/asm/elf.h new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 23/28 nios2: Nios2 registers
In reply to Ley Foon TanThis file contains constants for the instruction macros, cpu registers, fields and bits.
--- arch/nios2/include/asm/registers.h | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 arch/nios2/include/asm/registers.h
arch/nios2/include/asm/registers.h new file +65 -0
@@ -0,0 +1,65 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_REGISTERS_H +#define _ASM_NIOS2_REGISTERS_H + +/* control register numbers */ +#define CTL_STATUS 0 +#define CTL_ESTATUS 1 +#define CTL_BSTATUS 2 +#define CTL_IENABLE 3 +#define CTL_IPENDING 4 +#define CTL_CPUID 5 +#define CTL_RSV1 6 +#define CTL_EXCEPTION 7 +#define CTL_PTEADDR 8 +#define CTL_TLBACC 9 +#define CTL_TLBMISC 10 +#define CTL_RSV2 11 +#define CTL_BADADDR 12 +#define CTL_CONFIG 13 +#define CTL_MPUBASE 14 +#define CTL_MPUACC 15 + +/* access control registers using GCC builtins */ +#define RDCTL (r) __builtin_rdctl(r) +#define WRCTL (r, v) __builtin_wrctl(r, v) + +/* status register bits */ +#define STATUS_PIE (1 << 0)/* processor interrupt enable */ +#define STATUS_U (1 << 1)/* user mode */ +#define STATUS_EH (1 << 2)/* Exception mode */ + +/* estatus register bits */ +#define ESTATUS_EPIE (1 << 0)/* processor interrupt enable */ +#define ESTATUS_EU (1 << 1)/* user mode */ +#define ESTATUS_EH (1 << 2)/* Exception mode */ + +/* tlbmisc register bits */ +#define TLBMISC_PID_SHIFT 4 +#define TLBMISC_PID_MASK ((1UL << cpuinfo.tlb_pid_num_bits) - 1) +#define TLBMISC_WAY_MASK 0xf +#define TLBMISC_WAY_SHIFT 20 + +#define TLBMISC_PID (TLBMISC_PID_MASK << TLBMISC_PID_SHIFT)/* TLB PID */ +#define TLBMISC_WE (1 << 18)/* TLB write enable */ +#define TLBMISC_RD (1 << 19)/* TLB read */ +#define TLBMISC_WAY (TLBMISC_WAY_MASK << TLBMISC_WAY_SHIFT)/* TLB way */ + +#endif /* _ASM_NIOS2_REGISTERS_H */
Signature · 1 line
1.8.3.2
PATCH 10/28 nios2: Process management
In reply to Ley Foon TanThis patch adds support for thread creation and context switching.
--- arch/nios2/include/asm/mmu_context.h | 66 +++++++++ arch/nios2/include/asm/processor.h | 102 ++++++++++++++ arch/nios2/include/asm/switch_to.h | 31 +++++ arch/nios2/include/asm/thread_info.h | 120 ++++++++++++++++ arch/nios2/kernel/process.c | 262 +++++++++++++++++++++++++++++++++++ arch/nios2/mm/mmu_context.c | 116 ++++++++++++++++ 6 files changed, 697 insertions(+) create mode 100644 arch/nios2/include/asm/mmu_context.h create mode 100644 arch/nios2/include/asm/processor.h create mode 100644 arch/nios2/include/asm/switch_to.h create mode 100644 arch/nios2/include/asm/thread_info.h create mode 100644 arch/nios2/kernel/process.c create mode 100644 arch/nios2/mm/mmu_context.c
arch/nios2/include/asm/mmu_context.h new file +66 -0
@@ -0,0 +1,66 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 1996, 1997, 1998, 1999 by Ralf Baechle +* Copyright (C) 1999 Silicon Graphics, Inc. +* +* based on MIPS asm/mmu_context.h +* +* 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. +*/ + +#ifndef _ASM_NIOS2_MMU_CONTEXT_H +#define _ASM_NIOS2_MMU_CONTEXT_H + +#include <asm-generic/mm_hooks.h> + +extern void mmu_context_init (void ); +extern unsigned long get_pid_from_context (mm_context_t *ctx); + +/* +* For the fast tlb miss handlers, we keep a pointer to the current pgd. +* processor. +*/ +extern pgd_t *pgd_current; + +static inline void enter_lazy_tlb (struct mm_struct *mm,struct task_struct *tsk) +{ +} + +/* +* Initialize the context related info for a new mm_struct instance. +* +* Set all new contexts to 0, that way the generation will never match +* the currently running generation when this context is switched in. +*/ +static inline int init_new_context (struct task_struct *tsk, +struct mm_struct *mm) +{ + mm->context =0 ; +return 0 ; +} + +/* +* Destroy context related info for an mm_struct that is about +* to be put to rest. +*/ +static inline void destroy_context (struct mm_struct *mm) +{ +} + +void switch_mm (struct mm_struct *prev,struct mm_struct *next, +struct task_struct *tsk); + +static inline void deactivate_mm (struct task_struct *tsk, +struct mm_struct *mm) +{ +} + +/* +* After we have set current->mm to a new value, this activates +* the context for the new mm so we see the new mappings. +*/ +void activate_mm (struct mm_struct *prev,struct mm_struct *next); + +#endif /* _ASM_NIOS2_MMU_CONTEXT_H */
arch/nios2/include/asm/processor.h new file +102 -0
102 lines not on this page · raw message
arch/nios2/include/asm/switch_to.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* 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. +*/ +#ifndef _ASM_NIOS2_SWITCH_TO_H +#define _ASM_NIOS2_SWITCH_TO_H + +/* +* switch_to(n) should switch tasks to task ptr, first checking that +* ptr isn't the current task, in which case it does nothing. This +* also clears the TS-flag if the task we switched to has used the +* math co-processor latest. +*/ +#define switch_to (prev, next, last) \ +{ \ + void *_last; \ + __asm__ __volatile__ ( \ + "mov r4, %1\n" \ + "mov r5, %2\n" \ + "call resume\n" \ + "mov %0,r4\n" \ + : "=r" (_last) \ + : "r" (prev), "r" (next) \ + : "r4", "r5", "r7", "r8", "ra"); \ + (last) = _last; \ +} + +#endif /* _ASM_NIOS2_SWITCH_TO_H */
arch/nios2/include/asm/thread_info.h new file +120 -0
120 lines not on this page · raw message
arch/nios2/kernel/process.c new file +262 -0
262 lines not on this page · raw message
arch/nios2/mm/mmu_context.c new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 2/28 nios2: Assembly macros and definitions
In reply to Ley Foon TanThis patch add assembly macros and definitions used in the .S files across arch/nios2/ and together with asm-offsets.c.
--- arch/nios2/include/asm/asm-macros.h | 309 +++++++++++++++++++++++++++++++++++ arch/nios2/include/asm/asm-offsets.h | 20 +++ arch/nios2/kernel/asm-offsets.c | 88 ++++++++++ 3 files changed, 417 insertions(+) create mode 100644 arch/nios2/include/asm/asm-macros.h create mode 100644 arch/nios2/include/asm/asm-offsets.h create mode 100644 arch/nios2/kernel/asm-offsets.c
arch/nios2/include/asm/asm-macros.h new file +309 -0
@@ -0,0 +1,309 @@ +/* +* Macro used to simplify coding multi-line assembler. +* Some of the bit test macro can simplify down to one line +* depending on the mask value. +* +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* All rights reserved. +* +* 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, GOOD TITLE or +* NON INFRINGEMENT. See the GNU General Public License for more +* details. +* +*/ +#ifndef _ASM_NIOS2_ASMMACROS_H +#define _ASM_NIOS2_ASMMACROS_H +/* +* ANDs reg2 with mask and places the result in reg1. +* +* You cannnot use the same register for reg1 & reg2. +*/ + +.macro ANDI32 reg1, reg2, mask +.if \mask & 0xffff + .if \mask & 0xffff0000 + movhi \reg1, %hi(\mask) + movui \reg1, %lo(\mask) + and \reg1, \reg1, \reg2 + .else + andi \reg1, \reg2, %lo(\mask) + .endif +.else + andhi \reg1, \reg2, %hi(\mask) +.endif +.endm + +/* + * ORs reg2 with mask and places the result in reg1. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro ORI32 reg1, reg2, mask +.if \mask & 0xffff + .if \mask & 0xffff0000 + orhi \reg1, \reg2, %hi(\mask) + ori \reg1, \reg2, %lo(\mask) + .else + ori \reg1, \reg2, %lo(\mask) + .endif +.else + orhi \reg1, \reg2, %hi(\mask) +.endif +.endm + +/* + * XORs reg2 with mask and places the result in reg1. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro XORI32 reg1, reg2, mask +.if \mask & 0xffff + .if \mask & 0xffff0000 + xorhi \reg1, \reg2, %hi(\mask) + xori \reg1, \reg1, %lo(\mask) + .else + xori \reg1, \reg2, %lo(\mask) + .endif +.else + xorhi \reg1, \reg2, %hi(\mask) +.endif +.endm + +/* + * This is a support macro for BTBZ & BTBNZ. It checks + * the bit to make sure it is valid 32 value. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro BT reg1, reg2, bit +.if \bit > 31 + .err +.else + .if \bit < 16 + andi \reg1, \reg2, (1 << \bit) + .else + andhi \reg1, \reg2, (1 << (\bit - 16)) + .endif +.endif +.endm + +/* + * Tests the bit in reg2 and branches to label if the + * bit is zero. The result of the bit test is stored in reg1. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro BTBZ reg1, reg2, bit, label + BT \reg1, \reg2, \bit + beq \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and branches to label if the + * bit is non-zero. The result of the bit test is stored in reg1. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro BTBNZ reg1, reg2, bit, label + BT \reg1, \reg2, \bit + bne \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and then compliments the bit in reg2. + * The result of the bit test is stored in reg1. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTC reg1, reg2, bit +.if \bit > 31 + .err +.else + .if \bit < 16 + andi \reg1, \reg2, (1 << \bit) + xori \reg2, \reg2, (1 << \bit) + .else + andhi \reg1, \reg2, (1 << (\bit - 16)) + xorhi \reg2, \reg2, (1 << (\bit - 16)) + .endif +.endif +.endm + +/* + * Tests the bit in reg2 and then sets the bit in reg2. + * The result of the bit test is stored in reg1. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTS reg1, reg2, bit +.if \bit > 31 + .err +.else + .if \bit < 16 + andi \reg1, \reg2, (1 << \bit) + ori \reg2, \reg2, (1 << \bit) + .else + andhi \reg1, \reg2, (1 << (\bit - 16)) + orhi \reg2, \reg2, (1 << (\bit - 16)) + .endif +.endif +.endm + +/* + * Tests the bit in reg2 and then resets the bit in reg2. + * The result of the bit test is stored in reg1. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTR reg1, reg2, bit +.if \bit > 31 + .err +.else + .if \bit < 16 + andi \reg1, \reg2, (1 << \bit) + andi \reg2, \reg2, %lo(~(1 << \bit)) + .else + andhi \reg1, \reg2, (1 << (\bit - 16)) + andhi \reg2, \reg2, %lo(~(1 << (\bit - 16))) + .endif +.endif +.endm + +/* + * Tests the bit in reg2 and then compliments the bit in reg2. + * The result of the bit test is stored in reg1. If the + * original bit was zero it branches to label. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTCBZ reg1, reg2, bit, label + BTC \reg1, \reg2, \bit + beq \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and then compliments the bit in reg2. + * The result of the bit test is stored in reg1. If the + * original bit was non-zero it branches to label. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTCBNZ reg1, reg2, bit, label + BTC \reg1, \reg2, \bit + bne \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and then sets the bit in reg2. + * The result of the bit test is stored in reg1. If the + * original bit was zero it branches to label. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTSBZ reg1, reg2, bit, label + BTS \reg1, \reg2, \bit + beq \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and then sets the bit in reg2. + * The result of the bit test is stored in reg1. If the + * original bit was non-zero it branches to label. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTSBNZ reg1, reg2, bit, label + BTS \reg1, \reg2, \bit + bne \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and then resets the bit in reg2. + * The result of the bit test is stored in reg1. If the + * original bit was zero it branches to label. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTRBZ reg1, reg2, bit, label + BTR \reg1, \reg2, \bit + bne \reg1, r0, \label +.endm + +/* + * Tests the bit in reg2 and then resets the bit in reg2. + * The result of the bit test is stored in reg1. If the + * original bit was non-zero it branches to label. + * + * It is NOT safe to use the same register for reg1 & reg2. + */ + +.macro BTRBNZ reg1, reg2, bit, label + BTR \reg1, \reg2, \bit + bne \reg1, r0, \label +.endm + +/* + * Tests the bits in mask against reg2 stores the result in reg1. + * If the all the bits in the mask are zero it branches to label. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro TSTBZ reg1, reg2, mask, label + ANDI32 \reg1, \reg2, \mask + beq \reg1, r0, \label +.endm + +/* + * Tests the bits in mask against reg2 stores the result in reg1. + * If the any of the bits in the mask are 1 it branches to label. + * + * It is safe to use the same register for reg1 & reg2. + */ + +.macro TSTBNZ reg1, reg2, mask, label + ANDI32 \reg1, \reg2, \mask + bne \reg1, r0, \label +.endm + +/* + * Pushes reg onto the stack. + */ + +.macro PUSH reg + addi sp, sp, -4 + stw \reg, 0(sp) +.endm + +/* + * Pops the top of the stack into reg. + */ + +.macro POP reg + ldw \reg, 0(sp) + addi sp, sp, 4 +.endm + + +#endif /* _ASM_NIOS2_ASMMACROS_H */
arch/nios2/include/asm/asm-offsets.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2009 Thomas Chou <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#include <generated/asm-offsets.h>
arch/nios2/kernel/asm-offsets.c new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 18/28 nios2: Library functions
In reply to Ley Foon TanAdd optimised library functions for nios2.
--- arch/nios2/include/asm/checksum.h | 78 +++++++++++++++ arch/nios2/include/asm/string.h | 24 +++++ arch/nios2/lib/memcpy.c | 199 ++++++++++++++++++++++++++++++++++++++ arch/nios2/lib/memmove.c | 82 ++++++++++++++++ arch/nios2/lib/memset.c | 81 ++++++++++++++++ 5 files changed, 464 insertions(+) create mode 100644 arch/nios2/include/asm/checksum.h create mode 100644 arch/nios2/include/asm/string.h create mode 100644 arch/nios2/lib/memcpy.c create mode 100644 arch/nios2/lib/memmove.c create mode 100644 arch/nios2/lib/memset.c
arch/nios2/include/asm/checksum.h new file +78 -0
@@ -0,0 +1,78 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* 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. +*/ + +#ifndef _ASM_NIOS_CHECKSUM_H +#define _ASM_NIOS_CHECKSUM_H + +/* Take these from lib/checksum.c */ +extern __wsum csum_partial (const void *buff,int len,__wsum sum); +extern __wsum csum_partial_copy (const void *src,void *dst,int len, +__wsum sum); +extern __wsum csum_partial_copy_from_user (const void __user *src,void *dst, +int len,__wsum sum,int *csum_err); +#define csum_partial_copy_nocheck (src, dst, len, sum) \ + csum_partial_copy((src), (dst), (len), (sum)) + +extern __sum16 ip_fast_csum (const void *iph,unsigned int ihl); +extern __sum16 ip_compute_csum (const void *buff,int len); + +/* +* Fold a partial checksum +*/ +static inline __sum16 csum_fold (__wsum sum) +{ + __asm__ __volatile__( +"add %0, %1, %0\n" +"cmpltu r8, %0, %1\n" +"srli %0, %0, 16\n" +"add %0, %0, r8\n" +"nor %0, %0, %0\n" + :"=r" (sum) + :"r" (sum <<16 ),"0" (sum) + :"r8" ); +return (__force __sum16 ) sum; +} + +/* +* computes the checksum of the TCP/UDP pseudo-header +* returns a 16-bit checksum, already complemented +*/ +#define csum_tcpudp_nofold csum_tcpudp_nofold +static inline __wsum csum_tcpudp_nofold (__be32 saddr,__be32 daddr, +unsigned short len, +unsigned short proto, +__wsum sum) +{ + __asm__ __volatile__( +"add %0, %1, %0\n" +"cmpltu r8, %0, %1\n" +"add %0, %0, r8\n" /* add carry */ +"add %0, %2, %0\n" +"cmpltu r8, %0, %2\n" +"add %0, %0, r8\n" /* add carry */ +"add %0, %3, %0\n" +"cmpltu r8, %0, %3\n" +"add %0, %0, r8\n" /* add carry */ + :"=r" (sum),"=r" (saddr) + :"r" (daddr),"r" ((ntohs (len) <<16 ) + (proto *256 )), +"0" (sum), +"1" (saddr) + :"r8" ); + +return sum; +} + +static inline __sum16 csum_tcpudp_magic (__be32 saddr,__be32 daddr, +unsigned short len, +unsigned short proto,__wsum sum) +{ +return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); +} + +#endif /* _ASM_NIOS_CHECKSUM_H */
arch/nios2/include/asm/string.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* 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. +*/ + +#ifndef _ASM_NIOS2_STRING_H +#define _ASM_NIOS2_STRING_H + +#ifdef __KERNEL__ + +#define __HAVE_ARCH_MEMSET +#define __HAVE_ARCH_MEMCPY +#define __HAVE_ARCH_MEMMOVE + +extern void *memset (void *s,int c,size_t count); +extern void *memcpy (void *d,const void *s,size_t count); +extern void *memmove (void *d,const void *s,size_t count); + +#endif /* __KERNEL__ */ + +#endif /* _ASM_NIOS2_STRING_H */
arch/nios2/lib/memcpy.c new file +199 -0
199 lines not on this page · raw message
arch/nios2/lib/memmove.c new file +82 -0
82 lines not on this page · raw message
arch/nios2/lib/memset.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 27/28 MAINTAINERS: Add nios2 maintainer
In reply to Ley Foon Tan--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -6247,6 +6247,13 @@ S: Maintained F: Documentation/scsi/NinjaSCSI.txt F: drivers/scsi/nsp32* +NIOS2 ARCHITECTURE +M: Ley Foon Tan <[email protected]> +L: [email protected] (moderated for non-subscribers) +T: git://git.rocketboards.org/linux-socfpga.git +S: Maintained +F: arch/nios2/ + NTB DRIVER M: Jon Mason <[email protected]> S: Supported
Signature · 1 line
1.8.3.2
PATCH 16/28 nios2: System calls handling
In reply to Ley Foon TanThis patch adds support for system calls from userspaces. It uses the asm-generic/unistd.h definitions with architecture spcific syscall. The sys_call_table is just an array defined in a C file and it contains pointers to the syscall functions.
--- arch/nios2/include/asm/syscalls.h | 25 +++++++++++++ arch/nios2/include/uapi/asm/unistd.h | 25 +++++++++++++ arch/nios2/kernel/sys_nios2.c | 72 ++++++++++++++++++++++++++++++++++++ arch/nios2/kernel/syscall_table.c | 29 +++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 arch/nios2/include/asm/syscalls.h create mode 100644 arch/nios2/include/uapi/asm/unistd.h create mode 100644 arch/nios2/kernel/sys_nios2.c create mode 100644 arch/nios2/kernel/syscall_table.c
arch/nios2/include/asm/syscalls.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright Altera Corporation (C) 2013. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ +#ifndef __ASM_NIOS2_SYSCALLS_H +#define __ASM_NIOS2_SYSCALLS_H + +int sys_cacheflush (unsigned long addr,unsigned long len, +unsigned int op); + +#include <asm-generic/syscalls.h> + +#endif /* __ASM_NIOS2_SYSCALLS_H */
arch/nios2/include/uapi/asm/unistd.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (C) 2013 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#define sys_mmap2 sys_mmap_pgoff + +/* Use the standard ABI for syscalls */ +#include <asm-generic/unistd.h> + +/* Additional Nios II specific syscalls. */ +#define __NR_cacheflush (__NR_arch_specific_syscall) +__SYSCALL (__NR_cacheflush, sys_cacheflush)
arch/nios2/kernel/sys_nios2.c new file +72 -0
72 lines not on this page · raw message
arch/nios2/kernel/syscall_table.c new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright Altera Corporation (C) 2013. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#include <linux/syscalls.h> +#include <linux/signal.h> +#include <linux/unistd.h> + +#include <asm/syscalls.h> + +#undef __SYSCALL +#define __SYSCALL (nr, call) [nr] = (call), + +void *sys_call_table[__NR_syscalls] = { +#include <asm/unistd.h> +};
Signature · 1 line
1.8.3.2
PATCH 13/28 nios2: Interrupt handling
In reply to Ley Foon TanThis patch adds the support for IRQ handling.
--- arch/nios2/include/asm/irq.h | 34 +++++++++++++++ arch/nios2/include/asm/irqflags.h | 69 ++++++++++++++++++++++++++++++ arch/nios2/kernel/irq.c | 90 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 arch/nios2/include/asm/irq.h create mode 100644 arch/nios2/include/asm/irqflags.h create mode 100644 arch/nios2/kernel/irq.c
arch/nios2/include/asm/irq.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2013 Altera Corporation +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_IRQ_H +#define _ASM_NIOS2_IRQ_H + +#define NIOS2_CPU_NR_IRQS 32 +/* Reserve 32 additional interrupts for GPIO IRQs */ +#define NR_IRQS (NIOS2_CPU_NR_IRQS + 32) + +#ifndef NO_IRQ +#define NO_IRQ (-1) +#endif + +#include <asm-generic/irq.h> +#include <linux/irqdomain.h> + +#endif
arch/nios2/include/asm/irqflags.h new file +69 -0
69 lines not on this page · raw message
arch/nios2/kernel/irq.c new file +90 -0
90 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 22/28 nios2: Miscellaneous header files
In reply to Ley Foon TanThis patch introduces a few nios2-specific header files.
--- arch/nios2/include/asm/cmpxchg.h | 61 +++++++++++++++++++++++++++++++++ arch/nios2/include/asm/gpio.h | 23 +++++++++++++ arch/nios2/include/asm/linkage.h | 25 ++++++++++++++ arch/nios2/include/asm/mutex.h | 1 + arch/nios2/include/asm/pci.h | 25 ++++++++++++++ arch/nios2/include/uapi/asm/byteorder.h | 22 ++++++++++++ arch/nios2/include/uapi/asm/stat.h | 23 +++++++++++++ arch/nios2/include/uapi/asm/statfs.h | 24 +++++++++++++ arch/nios2/include/uapi/asm/swab.h | 37 ++++++++++++++++++++ 9 files changed, 241 insertions(+) create mode 100644 arch/nios2/include/asm/cmpxchg.h create mode 100644 arch/nios2/include/asm/gpio.h create mode 100644 arch/nios2/include/asm/linkage.h create mode 100644 arch/nios2/include/asm/mutex.h create mode 100644 arch/nios2/include/asm/pci.h create mode 100644 arch/nios2/include/uapi/asm/byteorder.h create mode 100644 arch/nios2/include/uapi/asm/stat.h create mode 100644 arch/nios2/include/uapi/asm/statfs.h create mode 100644 arch/nios2/include/uapi/asm/swab.h
arch/nios2/include/asm/cmpxchg.h new file +61 -0
@@ -0,0 +1,61 @@ +/* +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* 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. +*/ + +#ifndef _ASM_NIOS2_CMPXCHG_H +#define _ASM_NIOS2_CMPXCHG_H + +#include <linux/irqflags.h> + +#define xchg (ptr, x) \ + ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) + +struct __xchg_dummy {unsigned long a[100 ]; }; +#define __xg (x) ((volatile struct __xchg_dummy *)(x)) + +static inline unsigned long __xchg (unsigned long x,volatile void *ptr, +int size) +{ +unsigned long tmp, flags; + +local_irq_save (flags); + +switch (size) { +case 1 : + __asm__ __volatile__( +"ldb %0, %2\n" +"stb %1, %2\n" + :"=&r" (tmp) + :"r" (x),"m" (*__xg (ptr)) + :"memory" ); +break ; +case 2 : + __asm__ __volatile__( +"ldh %0, %2\n" +"sth %1, %2\n" + :"=&r" (tmp) + :"r" (x),"m" (*__xg (ptr)) + :"memory" ); +break ; +case 4 : + __asm__ __volatile__( +"ldw %0, %2\n" +"stw %1, %2\n" + :"=&r" (tmp) + :"r" (x),"m" (*__xg (ptr)) + :"memory" ); +break ; + } + +local_irq_restore (flags); +return tmp; +} + +#include <asm-generic/cmpxchg.h> +#include <asm-generic/cmpxchg-local.h> + +#endif /* _ASM_NIOS2_CMPXCHG_H */
arch/nios2/include/asm/gpio.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2013 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_GPIO_H +#define _ASM_NIOS2_GPIO_H + +#include <linux/gpio.h> + +#endif /* _ASM_NIOS2_GPIO_H */
arch/nios2/include/asm/linkage.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (C) 2009 Thomas Chou <[email protected]> +* +* All rights reserved. +* +* 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, GOOD TITLE or +* NON INFRINGEMENT. See the GNU General Public License for more +* details. +*/ + +#ifndef _ASM_NIOS2_LINKAGE_H +#define _ASM_NIOS2_LINKAGE_H + +/* This file is required by include/linux/linkage.h */ +#define __ALIGN .align 4 +#define __ALIGN_STR ".align 4" + +#endif
arch/nios2/include/asm/mutex.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/mutex-dec.h>
arch/nios2/include/asm/pci.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (C) 2013 Altera Corporation +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + + +#ifndef __ASM_NIOS2_PCI_H__ +#define __ASM_NIOS2_PCI_H__ + +/* We don't support PCI yet, but some drivers require this file anyway */ + +#endif /* __ASM_NIOS2_PCI_H__ */
arch/nios2/include/uapi/asm/byteorder.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2009 Thomas Chou <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* 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. +* +*/ + +#ifndef _ASM_NIOS2_BYTEORDER_H +#define _ASM_NIOS2_BYTEORDER_H + +#include <linux/byteorder/little_endian.h> + +#endif
arch/nios2/include/uapi/asm/stat.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright Altera Corporation (C) 2014. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _UAPI_ASM_NIOS2_STAT_H +#define _UAPI_ASM_NIOS2_STAT_H + +#include <asm-generic/stat.h> + +#endif
arch/nios2/include/uapi/asm/statfs.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright Altera Corporation (C) 2014. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _UAPI_ASM_NIOS2_STATFS_H +#define _UAPI_ASM_NIOS2_STATFS_H + +#define __statfs_word __s32 +#include <asm-generic/statfs.h> + +#endif
arch/nios2/include/uapi/asm/swab.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (C) 2012 Tobias Klauser <[email protected]> +* Copyright (C) 2011 Pyramid Technical Consultants, Inc. +* +* 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. +*/ + +#ifndef _ASM_NIOS2_SWAB_H +#define _ASM_NIOS2_SWAB_H + +#include <linux/types.h> +#include <asm-generic/swab.h> + +#ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT +#ifdef __GNUC__ + +#define __nios2_swab (x) \ + __builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x)) + +static inline __attribute__((const))__u16 __arch_swab16 (__u16 x) +{ +return (__u16 )__nios2_swab (((__u32 ) x) <<16 ); +} +#define __arch_swab16 __arch_swab16 + +static inline __attribute__((const))__u32 __arch_swab32 (__u32 x) +{ +return (__u32 )__nios2_swab (x); +} +#define __arch_swab32 __arch_swab32 + +#endif /* __GNUC__ */ +#endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */ + +#endif /* _ASM_NIOS2_SWAB_H */
Signature · 1 line
1.8.3.2
Re: [PATCH 01/28] nios2: Build infrastructure
In reply to Ley Foon TanQuoted 2 lines · Ley Foon Tan
This patch adds
MakefileandKconfigfiles required for building a nios2 kernel.
It is good practice to add build infrastructure last - so build is not broken. But for a new architecture it matters only little.
Some comments in the following.
Sam
Quoted 14 lines
Signed-off-by Ley Foon Tan <[email protected]>---
arch/nios2/Kconfig new file +4
-0@@ -0,0 +1,213 @@ +config NIOS2 + def_bool y + select OF + select OF_EARLY_FLATTREE
arch/nios2/Kconfig line 14
Quoted 10 lines
arch/nios2/Kconfig new file +10
-0+ select USB_ARCH_HAS_HCD if USB_SUPPORT + select ARCH_WANT_OPTIONAL_GPIOLIB + select GENERIC_IRQ_PROBE + select GENERIC_IRQ_SHOW + select GENERIC_CPU_DEVICES + select GENERIC_ATOMIC64 + select MODULES_USE_ELF_RELA + select IRQ_DOMAIN + select SOC_BUS + select CLKSRC_OF
If you keep this list sorted then merge issues are less likely.
Quoted 6 lines
arch/nios2/Kconfig new file +6
-0+menu "Advanced setup" + +config ADVANCED_OPTIONS + bool "Prompt for advanced kernel configuration options" + help +
arch/nios2/Kconfig line 161
Quoted 10 lines
arch/nios2/Kconfig new file +10
-0+comment "Default settings for advanced configuration options are used" + depends on !ADVANCED_OPTIONS + +config KERNEL_MMU_REGION_BASE_BOOL + bool "Set custom kernel MMU region base address" + depends on ADVANCED_OPTIONS + help + This option allows you to set the virtual address of the kernel MMU region. + + Say N here unless you know what you are doing.
All Nios2 specific options should be prefixed with NIOS2_ This is what is done for all new arch specific symbols.
Quoted 18 lines
arch/nios2/boot/Makefile new file +12
-0@@ -0,0 +1,51 @@ +# +# arch/nios2/boot/Makefile +# +# 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. +# + +UIMAGE_LOADADDR = $(shell $(NM) vmlinux | awk '$$NF == "_stext" {print $$1}') +UIMAGE_ENTRYADDR = $(shell $(NM) vmlinux | awk '$$NF == "_start" {print $$1}') +UIMAGE_COMPRESSION = gzip +
arch/nios2/boot/Makefile line 22
Quoted 10 lines
arch/nios2/boot/Makefile new file +10
-0+OBJCOPYFLAGS_vmlinux.bin := -O binary +$(obj)/vmlinux.bin: vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE + $(call if_changed,gzip) + +$(obj)/vmImage: $(obj)/vmlinux.gz + $(call if_changed,uimage) + @$(kecho) 'Kernel: $@ is ready'
Add:
targets += vmlinux.bin vmlinux.gz vmImage
to make $(call if_changed ... actually work.
arch/nios2/boot/Makefile line 24
Quoted 2 lines
arch/nios2/boot/Makefile new file +2
-0+obj-y += cpuinfo.o insnemu.o irq.o nios2_ksyms.o process.o prom.o ptrace.o \ + setup.o signal.o sys_nios2.o syscall_table.o time.o traps.o
In new stuff try to avoid using ... \
to contatenate lines.
Use:
obj-y += xxx
This is much more readable.
PATCH 3/28 nios2: Kernel booting and initialization
In reply to Ley Foon TanThis patch adds the kernel booting and the initial setup code.
--- arch/nios2/include/asm/entry.h | 152 +++++++++++++++++++++++++++++ arch/nios2/include/asm/setup.h | 38 ++++++++ arch/nios2/kernel/head.S | 175 +++++++++++++++++++++++++++++++++ arch/nios2/kernel/setup.c | 214 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 579 insertions(+) create mode 100644 arch/nios2/include/asm/entry.h create mode 100644 arch/nios2/include/asm/setup.h create mode 100644 arch/nios2/kernel/head.S create mode 100644 arch/nios2/kernel/setup.c
arch/nios2/include/asm/entry.h new file +152 -0
@@ -0,0 +1,152 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* Based on m68knommu asm/entry.h +* +* 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. +*/ + +#ifndef _ASM_NIOS2_ENTRY_H +#define _ASM_NIOS2_ENTRY_H + +#ifdef __ASSEMBLY__ + +#include <asm/processor.h> +#include <asm/registers.h> +#include <asm/asm-offsets.h> + +/* + * Stack layout in 'ret_from_exception': + * + * This allows access to the syscall arguments in registers r4-r8 + * + * 0(sp) - r8 + * 4(sp) - r9 + * 8(sp) - r10 + * C(sp) - r11 + * 10(sp) - r12 + * 14(sp) - r13 + * 18(sp) - r14 + * 1C(sp) - r15 + * 20(sp) - r1 + * 24(sp) - r2 + * 28(sp) - r3 + * 2C(sp) - r4 + * 30(sp) - r5 + * 34(sp) - r6 + * 38(sp) - r7 + * 3C(sp) - orig_r2 + * 40(sp) - ra + * 44(sp) - fp + * 48(sp) - sp + * 4C(sp) - gp + * 50(sp) - estatus + * 54(sp) - status_extension (NOMMU only) + * 58(sp) - ea + */ + +/* + * Standard Nios2 interrupt entry and exit macros. + * Must be called with interrupts disabled. + */ +.macro SAVE_ALL + rdctl r24, estatus + andi r24, r24, ESTATUS_EU + beq r24, r0, 1f /* In supervisor mode, already on kernel stack */ + + movia r24, _current_thread /* Switch to current kernel stack */ + ldw r24, 0(r24) /* using the thread_info */ + addi r24, r24, THREAD_SIZE-PT_REGS_SIZE + stw sp, PT_SP(r24) /* Save user stack before changing */ + mov sp, r24 + br 2f + +1 : mov r24, sp + addi sp, sp, -PT_REGS_SIZE /* Backup the kernel stack pointer */ + stw r24, PT_SP(sp) +2 : stw r1, PT_R1(sp) + stw r2, PT_R2(sp) + stw r3, PT_R3(sp) + stw r4, PT_R4(sp) + stw r5, PT_R5(sp) + stw r6, PT_R6(sp) + stw r7, PT_R7(sp) + stw r8, PT_R8(sp) + stw r9, PT_R9(sp) + stw r10, PT_R10(sp) + stw r11, PT_R11(sp) + stw r12, PT_R12(sp) + stw r13, PT_R13(sp) + stw r14, PT_R14(sp) + stw r15, PT_R15(sp) + stw r2, PT_ORIG_R2(sp) + stw r7, PT_ORIG_R7(sp) + + stw ra, PT_RA(sp) + stw fp, PT_FP(sp) + stw gp, PT_GP(sp) + rdctl r24, estatus + stw r24, PT_ESTATUS(sp) + stw ea, PT_EA(sp) +.endm + +.macro RESTORE_ALL + ldw r1, PT_R1(sp) /* Restore registers */ + ldw r2, PT_R2(sp) + ldw r3, PT_R3(sp) + ldw r4, PT_R4(sp) + ldw r5, PT_R5(sp) + ldw r6, PT_R6(sp) + ldw r7, PT_R7(sp) + ldw r8, PT_R8(sp) + ldw r9, PT_R9(sp) + ldw r10, PT_R10(sp) + ldw r11, PT_R11(sp) + ldw r12, PT_R12(sp) + ldw r13, PT_R13(sp) + ldw r14, PT_R14(sp) + ldw r15, PT_R15(sp) + ldw ra, PT_RA(sp) + ldw fp, PT_FP(sp) + ldw gp, PT_GP(sp) + ldw r24, PT_ESTATUS(sp) + wrctl estatus, r24 + ldw ea, PT_EA(sp) + ldw sp, PT_SP(sp) /* Restore sp last */ +.endm + +.macro SAVE_SWITCH_STACK + addi sp, sp, -SWITCH_STACK_SIZE + stw r16, SW_R16(sp) + stw r17, SW_R17(sp) + stw r18, SW_R18(sp) + stw r19, SW_R19(sp) + stw r20, SW_R20(sp) + stw r21, SW_R21(sp) + stw r22, SW_R22(sp) + stw r23, SW_R23(sp) + stw fp, SW_FP(sp) + stw gp, SW_GP(sp) + stw ra, SW_RA(sp) +.endm + +.macro RESTORE_SWITCH_STACK + ldw r16, SW_R16(sp) + ldw r17, SW_R17(sp) + ldw r18, SW_R18(sp) + ldw r19, SW_R19(sp) + ldw r20, SW_R20(sp) + ldw r21, SW_R21(sp) + ldw r22, SW_R22(sp) + ldw r23, SW_R23(sp) + ldw fp, SW_FP(sp) + ldw gp, SW_GP(sp) + ldw ra, SW_RA(sp) + addi sp, sp, SWITCH_STACK_SIZE +.endm + +#endif /* __ASSEMBLY__ */ +#endif /* _ASM_NIOS2_ENTRY_H */
arch/nios2/include/asm/setup.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_SETUP_H +#define _ASM_NIOS2_SETUP_H + +#include <asm-generic/setup.h> + +#ifndef __ASSEMBLY__ +# ifdef __KERNEL__ + +extern char exception_handler_hook[]; +extern char fast_handler[]; +extern char fast_handler_end[]; + +extern void pagetable_init (void ); + +extern void setup_early_printk (void ); + +# endif /* __KERNEL__ */ +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_NIOS2_SETUP_H */
arch/nios2/kernel/head.S new file +175 -0
175 lines not on this page · raw message
arch/nios2/kernel/setup.c new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 5/28 nios2: Traps exception handling
This patch contains traps exception handling.
--- arch/nios2/include/asm/traps.h | 19 ++ arch/nios2/kernel/insnemu.S | 592 +++++++++++++++++++++++++++++++++++++++++ arch/nios2/kernel/traps.c | 185 +++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 arch/nios2/include/asm/traps.h create mode 100644 arch/nios2/kernel/insnemu.S create mode 100644 arch/nios2/kernel/traps.c
arch/nios2/include/asm/traps.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* 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. +*/ + +#ifndef _ASM_NIOS2_TRAPS_H +#define _ASM_NIOS2_TRAPS_H + +#define TRAP_ID_SYSCALL 0 + +#ifndef __ASSEMBLY__ +void _exception (int signo,struct pt_regs *regs,int code,unsigned long addr); +#endif + +#endif /* _ASM_NIOS2_TRAPS_H */
arch/nios2/kernel/insnemu.S new file +592 -0
592 lines not on this page · raw message
arch/nios2/kernel/traps.c new file +185 -0
185 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 14/28 nios2: DMA mapping API
In reply to Ley Foon TanThis patch adds support for the DMA mapping API.
--- arch/nios2/include/asm/dma-mapping.h | 113 +++++++++++++++++++++ arch/nios2/mm/dma-mapping.c | 186 +++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 arch/nios2/include/asm/dma-mapping.h create mode 100644 arch/nios2/mm/dma-mapping.c
arch/nios2/include/asm/dma-mapping.h new file +113 -0
@@ -0,0 +1,113 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* Copyright (C) 2009 Wind River Systems Inc +* +* 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. +*/ + +#ifndef _ASM_NIOS2_DMA_MAPPING_H +#define _ASM_NIOS2_DMA_MAPPING_H + +#include <linux/scatterlist.h> +#include <linux/cache.h> +#include <asm/cacheflush.h> + +static inline void __dma_sync (void *vaddr,size_t size, +enum dma_data_direction direction) +{ +switch (direction) { +case DMA_FROM_DEVICE :/* invalidate cache */ +invalidate_dcache_range ((unsigned long )vaddr, + (unsigned long )(vaddr + size)); +break ; +case DMA_TO_DEVICE :/* flush and invalidate cache */ +case DMA_BIDIRECTIONAL : +flush_dcache_range ((unsigned long )vaddr, + (unsigned long )(vaddr + size)); +break ; +default : +BUG (); + } +} + +#define dma_alloc_noncoherent (d, s, h, f) dma_alloc_coherent(d, s, h, f) +#define dma_free_noncoherent (d, s, v, h) dma_free_coherent(d, s, v, h) + +void *dma_alloc_coherent (struct device *dev,size_t size, +dma_addr_t *dma_handle,gfp_t flag); + +void dma_free_coherent (struct device *dev,size_t size, +void *vaddr,dma_addr_t dma_handle); + +static inline dma_addr_t dma_map_single (struct device *dev,void *ptr, +size_t size, +enum dma_data_direction direction) +{ +__dma_sync (ptr, size, direction); +return virt_to_phys (ptr); +} + +static inline void dma_unmap_single (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) +{ +} + +extern int dma_map_sg (struct device *dev,struct scatterlist *sg,int nents, +enum dma_data_direction direction); +extern dma_addr_t dma_map_page (struct device *dev,struct page *page, +unsigned long offset,size_t size,enum dma_data_direction direction); +extern void dma_unmap_page (struct device *dev,dma_addr_t dma_address, +size_t size,enum dma_data_direction direction); +extern void dma_unmap_sg (struct device *dev,struct scatterlist *sg, +int nhwentries,enum dma_data_direction direction); +extern void dma_sync_single_for_cpu (struct device *dev,dma_addr_t dma_handle, +size_t size,enum dma_data_direction direction); +extern void dma_sync_single_for_device (struct device *dev, +dma_addr_t dma_handle,size_t size,enum dma_data_direction direction); +extern void dma_sync_single_range_for_cpu (struct device *dev, +dma_addr_t dma_handle,unsigned long offset,size_t size, +enum dma_data_direction direction); +extern void dma_sync_single_range_for_device (struct device *dev, +dma_addr_t dma_handle,unsigned long offset,size_t size, +enum dma_data_direction direction); +extern void dma_sync_sg_for_cpu (struct device *dev,struct scatterlist *sg, +int nelems,enum dma_data_direction direction); +extern void dma_sync_sg_for_device (struct device *dev,struct scatterlist *sg, +int nelems,enum dma_data_direction direction); + +static inline int dma_supported (struct device *dev,u64 mask) +{ +/* we fall back to GFP_DMA when the mask isn't all 1s, +* so we can't guarantee allocations that must be +* within a tighter range than GFP_DMA. +*/ +if (mask <0x00ffffff ) +return 0 ; + +return 1 ; +} + +static inline int dma_set_mask (struct device *dev,u64 mask) +{ +if (!dev->dma_mask || !dma_supported (dev, mask)) +return -EIO ; + + *dev->dma_mask = mask; + +return 0 ; +} + +static inline int dma_mapping_error (struct device *dev,dma_addr_t dma_addr) +{ +return 0 ; +} + +static inline void dma_cache_sync (struct device *dev,void *vaddr,size_t size, +enum dma_data_direction direction) +{ +__dma_sync (vaddr, size, direction); +} + +#endif /* _ASM_NIOS2_DMA_MAPPING_H */
arch/nios2/mm/dma-mapping.c new file +186 -0
186 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 7/28 nios2: I/O Mapping
In reply to Ley Foon TanThis patch adds several definitions for I/O accessors and ioremap().
--- arch/nios2/include/asm/io.h | 227 ++++++++++++++++++++++++++++++++++++++++++++ arch/nios2/mm/ioremap.c | 188 ++++++++++++++++++++++++++++++++++++ 2 files changed, 415 insertions(+) create mode 100644 arch/nios2/include/asm/io.h create mode 100644 arch/nios2/mm/ioremap.c
arch/nios2/include/asm/io.h new file +227 -0
@@ -0,0 +1,227 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd. +* +* 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. +*/ + +#ifndef _ASM_NIOS2_IO_H +#define _ASM_NIOS2_IO_H + +#include <asm/pgtable-bits.h> + +#define IO_SPACE_LIMIT 0xffffffff + +#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE +# define __IO_USE_DUFFS +#endif + +#ifdef __IO_USE_DUFFS + +/* Use "Duff's Device" to unroll the loops. */ +#define __IO_OUT_LOOP (a, b, l) \ + do { \ + if (l > 0) { \ + int _n = (l + 7) / 8; \ + switch (l % 8) { \ + case 0: \ + do { \ + *a = *b++; \ + case 7: \ + *a = *b++; \ + case 6: \ + *a = *b++; \ + case 5: \ + *a = *b++; \ + case 4: \ + *a = *b++; \ + case 3: \ + *a = *b++; \ + case 2: \ + *a = *b++; \ + case 1: \ + *a = *b++; \ + } while (--_n > 0); \ + } \ + } \ + } while (0) + +#define __IO_IN_LOOP (a, b, l) \ + do { \ + if (l > 0) { \ + int _n = (l + 7) / 8; \ + switch (l % 8) { \ + case 0: \ + do { \ + *b++ = *a; \ + case 7: \ + *b++ = *a; \ + case 6: \ + *b++ = *a; \ + case 5: \ + *b++ = *a; \ + case 4: \ + *b++ = *a; \ + case 3: \ + *b++ = *a; \ + case 2: \ + *b++ = *a; \ + case 1: \ + *b++ = *a; \ + } while (--_n > 0); \ + } \ + } \ + } while (0) + +#else /* __IO_USE_DUFFS */ + +/* Use simple loops. */ +#define __IO_OUT_LOOP (a, b, l) \ + do { \ + while (l--) \ + *a = *b++; \ + } while (0) + +#define __IO_IN_LOOP (a, b, l) \ + do { \ + while (l--) \ + *b++ = *a; \ + } while (0) + +#endif /* __IO_USE_DUFFS */ + +static inline void io_outsb (unsigned int addr,const void *buf,int len) +{ +volatile unsigned char *ap = (volatile unsigned char *)addr; +unsigned char *bp = (unsigned char *)buf; +__IO_OUT_LOOP (ap, bp, len); +} + +static inline void io_outsw (unsigned int addr,const void *buf,int len) +{ +volatile unsigned short *ap = (volatile unsigned short *)addr; +unsigned short *bp = (unsigned short *)buf; +__IO_OUT_LOOP (ap, bp, len); +} + +static inline void io_outsl (unsigned int addr,const void *buf,int len) +{ +volatile unsigned int *ap = (volatile unsigned int *)addr; +unsigned int *bp = (unsigned int *)buf; +__IO_OUT_LOOP (ap, bp, len); +} + +static inline void io_insb (unsigned int addr,void *buf,int len) +{ +volatile unsigned char *ap = (volatile unsigned char *)addr; +unsigned char *bp = (unsigned char *)buf; +__IO_IN_LOOP (ap, bp, len); +} + +static inline void io_insw (unsigned int addr,void *buf,int len) +{ +volatile unsigned short *ap = (volatile unsigned short *)addr; +unsigned short *bp = (unsigned short *)buf; +__IO_IN_LOOP (ap, bp, len); +} + +static inline void io_insl (unsigned int addr,void *buf,int len) +{ +volatile unsigned int *ap = (volatile unsigned int *)addr; +unsigned int *bp = (unsigned int *)buf; +__IO_IN_LOOP (ap, bp, len); +} + +#undef __IO_OUT_LOOP +#undef __IO_IN_LOOP +#undef __IO_USE_DUFFS + +#define readb_relaxed (addr) readb(addr) +#define readw_relaxed (addr) readw(addr) +#define readl_relaxed (addr) readl(addr) + +#define writeb_relaxed (x, addr) writeb(x, addr) +#define writew_relaxed (x, addr) writew(x, addr) +#define writel_relaxed (x, addr) writel(x, addr) + +#define outsb (a, b, l) io_outsb(a, b, l) +#define outsw (a, b, l) io_outsw(a, b, l) +#define outsl (a, b, l) io_outsl(a, b, l) + +#define insb (a, b, l) io_insb(a, b, l) +#define insw (a, b, l) io_insw(a, b, l) +#define insl (a, b, l) io_insl(a, b, l) + +#include <asm-generic/io.h> + +/* +* make the short names macros so specific devices +* can override them as required +*/ +#define inb (addr) readb(addr) +#define inw (addr) readw(addr) +#define inl (addr) readl(addr) +#define outb (x, addr) ((void) writeb(x, addr)) +#define outw (x, addr) ((void) writew(x, addr)) +#define outl (x, addr) ((void) writel(x, addr)) + +extern void __iomem *__ioremap (unsigned long physaddr,unsigned long size, +unsigned long cacheflag); +extern void __iounmap (void __iomem *addr); + +static inline void __iomem *ioremap (unsigned long physaddr,unsigned long size) +{ +return __ioremap (physaddr, size,0 ); +} + +static inline void __iomem *ioremap_nocache (unsigned long physaddr, +unsigned long size) +{ +return __ioremap (physaddr, size,0 ); +} + +static inline void __iomem *ioremap_writethrough (unsigned long physaddr, +unsigned long size) +{ +return __ioremap (physaddr, size,0 ); +} + +static inline void __iomem *ioremap_fullcache (unsigned long physaddr, +unsigned long size) +{ +return __ioremap (physaddr, size, _PAGE_CACHED); +} + +static inline void iounmap (void __iomem *addr) +{ +__iounmap (addr); +} + +/* Pages to physical address... */ +# define page_to_phys (page) virt_to_phys(page_to_virt(page)) +# define page_to_bus (page) page_to_virt(page) + +/* Macros used for converting between virtual and physical mappings. */ +# define phys_to_virt (vaddr) \ + ((void *)((unsigned long)(vaddr) | CONFIG_KERNEL_REGION_BASE)) +/* Clear top 3 bits */ +# define virt_to_phys (vaddr) \ + ((unsigned long)((unsigned long)(vaddr) & ~0xE0000000)) + +#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt + +#define ioport_map (port, nr) ioremap(port, nr) +#define ioport_unmap (port) iounmap(port) + +/* Macros used for smc91x.c driver */ +#define readsb (p, d, l) insb(p, d, l) +#define readsw (p, d, l) insw(p, d, l) +#define readsl (p, d, l) insl(p, d, l) +#define writesb (p, d, l) outsb(p, d, l) +#define writesw (p, d, l) outsw(p, d, l) +#define writesl (p, d, l) outsl(p, d, l) + +#endif /* _ASM_NIOS2_IO_H */
arch/nios2/mm/ioremap.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 01/28] nios2: Build infrastructure
In reply to Ley Foon Tanarch/nios2/Kconfig
Quoted 4 lines · Ley Foon Tan
arch/nios2/Kconfig +2
-0+config GENERIC_FIND_NEXT_BIT + def_bool y
This one is not needed, see commit 63e424c84429 ("arch: remove CONFIG_GENERIC_FIND_{NEXT_BIT,BIT_LE,LAST_BIT}").
arch/nios2/Kconfig
Quoted 2 lines
arch/nios2/Kconfig +2
-0+config NO_IOPORT + def_bool y
Did you mean NO_IOPORT_MAP?
Paul Bolle
Re: [PATCH 01/28] nios2: Build infrastructure
In reply to Ley Foon TanQuoted 1 line · Ley Foon Tan
arch/nios2/kernel/Makefile +0
-0
[...]
Quoted 1 line
+obj-$(CONFIG_CONSOLE) += console.o
CONFIG_CONSOLE seems never to be defined. And there appears to be no arch/nios2/console.c or .../console.S anyway.
Paul Bolle
Quoted 3 lines · Ley Foon Tan
This patchset adds the Linux kernel port for Nios II processor from Altera. The nios2 Linux port follows the guidance for new architecture ports using generic headers (including
unistd.h).
Did the generic headers ever get updated to match Linus' guidance that any new architecture ports should use a 64-bit time_t?
-hpa
Arnd Bergmann
maintainerQuoted 7 lines · H. Peter Anvin
Quoted 3 lines · Ley Foon Tan
This patchset adds the Linux kernel port for Nios II processor from Altera. The nios2 Linux port follows the guidance for new architecture ports using generic headers (including
unistd.h).Did the generic headers ever get updated to match Linus' guidance that any new architecture ports should use a 64-bit
time_t?
No, unfortunately not. With my rule that every architecture that gets added needs to clean up asm-generic some more, to make it easier to add the next one, we should probably do for nios2.
Arnd
Re: [PATCH 09/28] nios2: Page table management
In reply to Ley Foon TanHi!
Quoted 12 lines
This patch adds support for page table management.
Signed-off-by Ley Foon Tan <[email protected]>arch/nios2/mm/pgtable.c new file +8
-0+/* +* Initialize a new pgd / pmd table with invalid pointers. +*/ +static void pgd_init (pgd_t *pgd) +{ +unsigned long *p = (unsigned long *) pgd; +int i; +
arch/nios2/mm/pgtable.c line 51
Quoted 10 lines
arch/nios2/mm/pgtable.c new file +10
-0+for (i =0 ; i <USER_PTRS_PER_PGD ; i +=8 ) { + p[i +0 ] = (unsigned long ) invalid_pte_table; + p[i +1 ] = (unsigned long ) invalid_pte_table; + p[i +2 ] = (unsigned long ) invalid_pte_table; + p[i +3 ] = (unsigned long ) invalid_pte_table; + p[i +4 ] = (unsigned long ) invalid_pte_table; + p[i +5 ] = (unsigned long ) invalid_pte_table; + p[i +6 ] = (unsigned long ) invalid_pte_table; + p[i +7 ] = (unsigned long ) invalid_pte_table; + }
Umm. Manual loop unrolling. Does it really improve performance? Is the code hot enough to warrant the uglyness?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 16/28] nios2: System calls handling
In reply to Ley Foon Tanarch/nios2/include/uapi/asm/unistd.h line 25
Quoted 10 lines · Ley Foon Tan
This patch adds support for system calls from userspaces. It uses the
asm-generic/unistd.hdefinitions with architecture spcific syscall. Thesys_call_tableis just an array defined in a C file and it contains pointers to the syscall functions.Signed-off-by Ley Foon Tan <[email protected]>arch/nios2/include/uapi/asm/unistd.h new file +3
-0+/* Additional Nios II specific syscalls. */ +#define __NR_cacheflush (__NR_arch_specific_syscall) +__SYSCALL (__NR_cacheflush, sys_cacheflush)
I guess you should Cc: Michael Kerrisk on this one.
Also... explanation why you need this syscall while other architectures live happily without it would be nice.
arch/nios2/kernel/sys_nios2.c line 37
Quoted 8 lines
arch/nios2/kernel/sys_nios2.c new file +8
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ;
op is being ignored? You should remove it... or if (op) return -EINVAL if you want future extensions.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 17/28] nios2: Signal handling support
In reply to Ley Foon TanQuoted 341 lines · Ley Foon Tan
This patch adds support for signal handling.
Signed-off-by Ley Foon Tan <[email protected]>--- arch/nios2/include/asm/signal.h | 22 ++ arch/nios2/include/asm/ucontext.h | 34 +++ arch/nios2/include/uapi/asm/sigcontext.h | 30 +++ arch/nios2/include/uapi/asm/signal.h | 23 ++ arch/nios2/kernel/signal.c | 364 +++++++++++++++++++++++++++++++ 5 files changed, 473 insertions(+) create mode 100644 arch/nios2/include/asm/signal.h create mode 100644 arch/nios2/include/asm/ucontext.h create mode 100644 arch/nios2/include/uapi/asm/sigcontext.h create mode 100644 arch/nios2/include/uapi/asm/signal.h create mode 100644 arch/nios2/kernel/signal.carch/nios2/include/asm/signal.h new file +22
-0@@ -0,0 +1,22 @@ +/* +* Copyright Altera Corporation (C) 2013. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ +#ifndef _NIOS2_SIGNAL_H +#define _NIOS2_SIGNAL_H + +#include <uapi/asm/signal.h> + +#endif /* _NIOS2_SIGNAL_H */ arch/nios2/include/asm/ucontext.h new file +34
-0@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2010 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd +* +* derived from m68knommu +* +* 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. +*/ + +#ifndef _ASM_NIOS2_UCONTEXT_H +#define _ASM_NIOS2_UCONTEXT_H + +typedef int greg_t ; +#define NGREG 32 +typedef greg_t gregset_t [NGREG ]; + +struct mcontext { +int version; +gregset_t gregs; +}; + +#define MCONTEXT_VERSION 2 + +struct ucontext { +unsigned long uc_flags; +struct ucontext *uc_link; +stack_t uc_stack; +struct mcontext uc_mcontext; +sigset_t uc_sigmask;/* mask last for extensibility */ +}; + +#endif arch/nios2/include/uapi/asm/sigcontext.h new file +30
-0@@ -0,0 +1,30 @@ +/* +* Taken from the m68knommu. +* +* Copyright (C) 2004, Microtronix Datacom Ltd. +* +* All rights reserved. +* +* 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, GOOD TITLE or +* NON INFRINGEMENT. See the GNU General Public License for more +* details. +*/ + +#ifndef _ASM_NIOS2_SIGCONTEXT_H +#define _ASM_NIOS2_SIGCONTEXT_H + +#include <asm/ptrace.h> + +struct sigcontext { +struct pt_regs regs; +unsigned long sc_mask;/* old sigmask */ +}; + +#endif arch/nios2/include/uapi/asm/signal.h new file +23
-0@@ -0,0 +1,23 @@ +/* +* Copyright Altera Corporation (C) 2013. All rights reserved +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. +* +*/ +#ifndef _ASM_NIOS2_SIGNAL_H +#define _ASM_NIOS2_SIGNAL_H + +#define SA_RESTORER 0x04000000 +#include <asm-generic/signal.h> + +#endif /* _ASM_NIOS2_SIGNAL_H */ arch/nios2/kernel/signal.c new file +186
-0@@ -0,0 +1,364 @@ +/* +* Copyright (C) 2013 Altera Corporation +* Copyright (C) 2011-2012 Tobias Klauser <[email protected]> +* Copyright (C) 2004 Microtronix Datacom Ltd +* Copyright (C) 1991, 1992 Linus Torvalds +* +* This file is based on kernel/signal.c from m68knommu. +* +* 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. +*/ + +#include <linux/signal.h> +#include <linux/errno.h> +#include <linux/ptrace.h> +#include <linux/uaccess.h> +#include <linux/unistd.h> +#include <linux/personality.h> +#include <linux/tracehook.h> + +#include <asm/ucontext.h> +#include <asm/cacheflush.h> + +#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) + +static int do_signal (struct pt_regs *regs,sigset_t *oldset,int in_syscall); + +/* +* Do a signal return; undo the signal stack. +* +* Keep the return code on the stack quadword aligned! +* That makes the cache flush below easier. +*/ + +struct sigframe { +char retcode[12 ]; +unsigned long extramask[_NSIG_WORDS-1 ]; +struct sigcontext sc; +}; + +struct rt_sigframe { +char retcode[12 ]; +struct siginfo info; +struct ucontext uc; +}; + +static inline int rt_restore_ucontext (struct pt_regs *regs, +struct switch_stack *sw, +struct ucontext *uc,int *pr2) +{ +int temp; +greg_t *gregs = uc->uc_mcontext.gregs; +int err; + + err =__get_user (temp, &uc->uc_mcontext.version); +if (temp !=MCONTEXT_VERSION ) + goto badframe; +/* restore passed registers */ + err |=__get_user (regs->r1, &gregs[0 ]); + err |=__get_user (regs->r2, &gregs[1 ]); + err |=__get_user (regs->r3, &gregs[2 ]); + err |=__get_user (regs->r4, &gregs[3 ]); + err |=__get_user (regs->r5, &gregs[4 ]); + err |=__get_user (regs->r6, &gregs[5 ]); + err |=__get_user (regs->r7, &gregs[6 ]); + err |=__get_user (regs->r8, &gregs[7 ]); + err |=__get_user (regs->r9, &gregs[8 ]); + err |=__get_user (regs->r10, &gregs[9 ]); + err |=__get_user (regs->r11, &gregs[10 ]); + err |=__get_user (regs->r12, &gregs[11 ]); + err |=__get_user (regs->r13, &gregs[12 ]); + err |=__get_user (regs->r14, &gregs[13 ]); + err |=__get_user (regs->r15, &gregs[14 ]); + err |=__get_user (sw->r16, &gregs[15 ]); + err |=__get_user (sw->r17, &gregs[16 ]); + err |=__get_user (sw->r18, &gregs[17 ]); + err |=__get_user (sw->r19, &gregs[18 ]); + err |=__get_user (sw->r20, &gregs[19 ]); + err |=__get_user (sw->r21, &gregs[20 ]); + err |=__get_user (sw->r22, &gregs[21 ]); + err |=__get_user (sw->r23, &gregs[22 ]); +/* gregs[23] is handled below */ + err |=__get_user (sw->fp, &gregs[24 ]);/* Verify, should this be +settable */ + err |=__get_user (sw->gp, &gregs[25 ]);/* Verify, should this be +settable */ + + err |=__get_user (temp, &gregs[26 ]);/* Not really necessary no user +settable bits */ + err |=__get_user (regs->ea, &gregs[27 ]); + + err |=__get_user (regs->ra, &gregs[23 ]); + err |=__get_user (regs->sp, &gregs[28 ]); + + regs->estatus = (regs->estatus &0xffffffff ); + regs->orig_r2 =-1 ;/* disable syscall checks */ + + err |=restore_altstack (&uc->uc_stack); +if (err) + goto badframe; + + *pr2 = regs->r2; +return err; + +badframe: +return 1 ; +} + +asmlinkage int do_rt_sigreturn(struct switch_stack *sw) +{ +struct pt_regs *regs = (struct pt_regs *)(sw +1 ); +/* Verify, can we follow the stack back */ +struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp; +sigset_t set; +int rval; + +if (!access_ok (VERIFY_READ , frame,sizeof (*frame))) + goto badframe; + +if (__copy_from_user (&set, &frame->uc.uc_sigmask,sizeof (set))) + goto badframe; + +sigdelsetmask (&set, ~_BLOCKABLE); +spin_lock_irq (¤t->sighand->siglock); + current->blocked = set; +recalc_sigpending (); +spin_unlock_irq (¤t->sighand->siglock); + +if (rt_restore_ucontext (regs, sw, &frame->uc, &rval)) + goto badframe; + +return rval; + +badframe: +force_sig (SIGSEGV , current); +return 0 ; +} + +static inline int rt_setup_ucontext (struct ucontext *uc,struct pt_regs *regs) +{ +struct switch_stack *sw = (struct switch_stack *)regs -1 ; +greg_t *gregs = uc->uc_mcontext.gregs; +int err =0 ; + + err |=__put_user (MCONTEXT_VERSION , &uc->uc_mcontext.version); + err |=__put_user (regs->r1, &gregs[0 ]); + err |=__put_user (regs->r2, &gregs[1 ]); + err |=__put_user (regs->r3, &gregs[2 ]); + err |=__put_user (regs->r4, &gregs[3 ]); + err |=__put_user (regs->r5, &gregs[4 ]); + err |=__put_user (regs->r6, &gregs[5 ]); + err |=__put_user (regs->r7, &gregs[6 ]); + err |=__put_user (regs->r8, &gregs[7 ]); + err |=__put_user (regs->r9, &gregs[8 ]); + err |=__put_user (regs->r10, &gregs[9 ]); + err |=__put_user (regs->r11, &gregs[10 ]); + err |=__put_user (regs->r12, &gregs[11 ]); + err |=__put_user (regs->r13, &gregs[12 ]); + err |=__put_user (regs->r14, &gregs[13 ]); + err |=__put_user (regs->r15, &gregs[14 ]); + err |=__put_user (sw->r16, &gregs[15 ]); + err |=__put_user (sw->r17, &gregs[16 ]); + err |=__put_user (sw->r18, &gregs[17 ]); + err |=__put_user (sw->r19, &gregs[18 ]); + err |=__put_user (sw->r20, &gregs[19 ]); + err |=__put_user (sw->r21, &gregs[20 ]); + err |=__put_user (sw->r22, &gregs[21 ]); + err |=__put_user (sw->r23, &gregs[22 ]); + err |=__put_user (regs->ra, &gregs[23 ]); + err |=__put_user (sw->fp, &gregs[24 ]); + err |=__put_user (sw->gp, &gregs[25 ]); + err |=__put_user (regs->ea, &gregs[27 ]); + err |=__put_user (regs->sp, &gregs[28 ]); +return err; +} + +static inline void push_cache (unsigned long vaddr) +{ +flush_dcache_range (vaddr, vaddr +12 ); +flush_icache_range (vaddr, vaddr +12 ); +} + +static inline void *get_sigframe (struct k_sigaction *ka,struct pt_regs *regs, +size_t frame_size) +{
arch/nios2/kernel/signal.c line 196
Quoted 10 lines
arch/nios2/kernel/signal.c new file +10
-0+unsigned long usp; + +/* Default to using normal stack. */ + usp = regs->sp; + +/* This is the X/Open sanctioned signal stack switching. */ +if ((ka->sa.sa_flags &SA_ONSTACK ) && (current->sas_ss_sp !=0 )) { +if (!on_sig_stack (usp)) + usp = current->sas_ss_sp + current->sas_ss_size; + }
You can use sigsp() here.
Quoted 33 lines
arch/nios2/kernel/signal.c new file +33
-0+/* Verify, is it 32 or 64 bit aligned */ +return (void *)((usp - frame_size) &-8UL ); +} + +static void setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, +sigset_t *set,struct pt_regs *regs) +{ +struct rt_sigframe *frame; +int err =0 ; + + frame =get_sigframe (ka, regs,sizeof (*frame)); + +if (info) + err |=copy_siginfo_to_user (&frame->info, info); + +/* Create the ucontext. */ + err |=__put_user (0 , &frame->uc.uc_flags); + err |=__put_user (0 , &frame->uc.uc_link); + err |=__save_altstack (&frame->uc.uc_stack, regs->sp); + err |=rt_setup_ucontext (&frame->uc, regs); + err |=copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set)); + +/* Set up to return from userspace. */ + regs->ra = (unsigned long ) &frame->retcode[0 ]; + +/* movi r2,__NR_rt_sigreturn */ + err |=__put_user (0x00800004 + (__NR_rt_sigreturn <<6 ), + (long *)(frame->retcode)); +/* trap */ + err |=__put_user (0x003b683a , (long *)(frame->retcode +4 )); + +if (err) + goto give_sigsegv;
arch/nios2/kernel/signal.c line 240
Quoted 10 lines
arch/nios2/kernel/signal.c new file +10
-0+ +push_cache ((unsigned long ) &frame->retcode); + +/* Set up registers for signal handler */ + regs->sp = (unsigned long ) frame; + regs->r4 = (unsigned long ) (current_thread_info ()->exec_domain + &¤t_thread_info ()->exec_domain->signal_invmap + && sig <32 + ?current_thread_info ()->exec_domain->signal_invmap[sig] + : sig);
Does nios2 really need signal translation and supports execution domains?
Quoted 50 lines
arch/nios2/kernel/signal.c new file +50
-0+ regs->r5 = (unsigned long ) &frame->info; + regs->r6 = (unsigned long ) &frame->uc; + regs->ea = (unsigned long ) ka->sa.sa_handler; +return ; + +give_sigsegv: +force_sigsegv (sig, current); +} + +static inline void handle_restart (struct pt_regs *regs,struct k_sigaction *ka, +int has_handler) +{ +switch (regs->r2) { +case ERESTART_RESTARTBLOCK : +case ERESTARTNOHAND : + regs->r2 =EINTR ; + regs->r7 =1 ; +break ; +case ERESTARTSYS : +if (has_handler && !(ka->sa.sa_flags &SA_RESTART )) { + regs->r2 =EINTR ; + regs->r7 =1 ; +break ; + } +/* fallthrough */ +case ERESTARTNOINTR : + regs->r2 = regs->orig_r2; + regs->r7 = regs->orig_r7; + regs->ea -=4 ; +break ; + } +} + +/* +* OK, we're invoking a handler +*/ +static void handle_signal (int sig,struct k_sigaction *ka,siginfo_t *info, +sigset_t *oldset,struct pt_regs *regs) +{ +/* set up the stack frame */ +if (ka->sa.sa_flags &SA_SIGINFO ) +setup_rt_frame (sig, ka, info, oldset, regs); +else +setup_rt_frame (sig, ka,NULL , oldset, regs); + +if (!(ka->sa.sa_flags &SA_NODEFER )) { +spin_lock_irq (¤t->sighand->siglock); +sigorsets (¤t->blocked, ¤t->blocked, + &ka->sa.sa_mask); +sigaddset (¤t->blocked, sig);
arch/nios2/kernel/signal.c line 300
Quoted 10 lines
arch/nios2/kernel/signal.c new file +10
-0+recalc_sigpending (); +spin_unlock_irq (¤t->sighand->siglock); + } +} + +/* +* Note that 'init' is a special process: it doesn't get signals it doesn't +* want to handle. Thus you cannot kill init even with a SIGKILL even by +* mistake. +*/
Is this comment still needed? Looks like copy&paste...
Quoted 40 lines
arch/nios2/kernel/signal.c new file +40
-0+static int do_signal (struct pt_regs *regs,sigset_t *oldset,int in_syscall) +{ +struct k_sigaction ka; +siginfo_t info; +int signr; + + current->thread.kregs = regs; + +if (!oldset) + oldset = ¤t->blocked; + + signr =get_signal_to_deliver (&info, &ka, regs,NULL ); +if (signr >0 ) { +/* +* Are we from a system call? If so, check system call +* restarting. +*/ +if (in_syscall) +handle_restart (regs, &ka,1 ); +/* Whee! Actually deliver the signal. */ +handle_signal (signr, &ka, &info, oldset, regs); +return 1 ; + } + +/* +* No signal to deliver to the process - restart the syscall. +*/ +if (in_syscall) { +/* Did the syscall return an error code */ +if (regs->r7 ==1 ) { +if (regs->r2 ==ERESTARTNOHAND || + regs->r2 ==ERESTARTSYS || + regs->r2 ==ERESTARTNOINTR ) { + regs->r2 = regs->orig_r2; + regs->r7 = regs->orig_r7; + regs->ea -=4 ; + }else if (regs->r2 ==ERESTART_RESTARTBLOCK ) { + regs->r2 = __NR_restart_syscall; + regs->ea -=4 ; + }
arch/nios2/kernel/signal.c line 350
Quoted 10 lines
arch/nios2/kernel/signal.c new file +10
-0+ } + } + +return 0 ; +} + +asmlinkage void do_notify_resume(struct pt_regs *regs, sigset_t *oldset, +int in_syscall) +{ +pr_debug ("--> ENTERING %s\n" , __func__);
Please remove such printk()s.
If you need to know which functions get called, use ftrace.
Quoted 16 lines
arch/nios2/kernel/signal.c new file +14
-1+/* +* We want the common case to go fast, which is why we may in certain +* cases get here from kernel mode. Just return without doing anything +* if so. +*/ +if (!user_mode (regs)) +return ; + +if (test_thread_flag (TIF_SIGPENDING )) +do_signal (regs, oldset, in_syscall); + +if (test_and_clear_thread_flag (TIF_NOTIFY_RESUME )) +tracehook_notify_resume (regs); +} --1.8.3.2
Signature · 2 lines
Thanks, //richard
Re: [PATCH 16/28] nios2: System calls handling
In reply to Ley Foon TanQuoted 12 lines · Ley Foon Tan
arch/nios2/kernel/sys_nios2.c new file +12
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ; + +/* Check for overflow */ +if (addr + len < addr) +return -EFAULT ;
arch/nios2/kernel/sys_nios2.c line 51
Quoted 10 lines
arch/nios2/kernel/sys_nios2.c new file +10
-0+ +/* +* Verify that the specified address region actually belongs +* to this process. +*/ + vma =find_vma (current->mm, addr); +if (vma ==NULL || addr < vma->vm_start || addr + len > vma->vm_end) +return -EFAULT ; + +/* Ignore the scope and cache arguments. */
This function doesn't have scope and cache arguments (sys_cacheflush() on m68k does have them ;-)
Quoted 2 lines · Pavel Machek
Also... explanation why you need this syscall while other architectures live happily without it would be nice.
12 our of 28 architectures provide such a syscall...
Is flushing the cache a privileged operation on nios2?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 01/28] nios2: Build infrastructure
In reply to Sam RavnborgQuoted 6 lines · Sam Ravnborg
It is good practice to add build infrastructure last - so build is not broken. But for a new architecture it matters only little.
Some comments in the following.
Sam
Noted. But, I will keep the patch # for this time for consistency. Thanks.
Quoted 17 lines
Quoted 17 lines
Signed-off-by Ley Foon Tan <[email protected]>---
arch/nios2/Kconfig new file +7
-0@@ -0,0 +1,213 @@ +config NIOS2 + def_bool y + select OF + select OF_EARLY_FLATTREE + select USB_ARCH_HAS_HCD if USB_SUPPORT + select ARCH_WANT_OPTIONAL_GPIOLIB + select GENERIC_IRQ_PROBE
Quoted 8 lines
arch/nios2/Kconfig line 14
Quoted 7 lines
arch/nios2/Kconfig new file +7
-0+ select GENERIC_IRQ_SHOW + select GENERIC_CPU_DEVICES + select GENERIC_ATOMIC64 + select MODULES_USE_ELF_RELA + select IRQ_DOMAIN + select SOC_BUS + select CLKSRC_OFIf you keep this list sorted then merge issues are less likely.
Noted, will sort this list.
Quoted 10 lines
arch/nios2/Kconfig line 161
Quoted 7 lines
arch/nios2/Kconfig new file +7
-0+config KERNEL_MMU_REGION_BASE_BOOL + bool "Set custom kernel MMU region base address" + depends on ADVANCED_OPTIONS + help + This option allows you to set the virtual address of the kernel MMU region. + + Say N here unless you know what you are doing.All Nios2 specific options should be prefixed with
NIOS2_This is what is done for all new arch specific symbols.
Noted, will add NIOS2 prefix to these CONFIGs.
Quoted 12 lines
arch/nios2/boot/Makefile line 22
Quoted 8 lines
arch/nios2/boot/Makefile +5
-0+ $(call if_changed,gzip) + +$(obj)/vmImage: $(obj)/vmlinux.gz + $(call if_changed,uimage) + @$(kecho) 'Kernel: $@ is ready'Add:
targets += vmlinux.bin vmlinux.gz vmImage
to make $(callif_changed... actually work.
Sure, will change to this way.
Quoted 10 lines
arch/nios2/boot/Makefile
Quoted 4 lines
arch/nios2/boot/Makefile +2
-0+obj-y += cpuinfo.o insnemu.o irq.o nios2_ksyms.o process.o prom.o ptrace.o \ + setup.o signal.o sys_nios2.o syscall_table.o time.o traps.oIn new stuff try to avoid using ... \
to contatenate lines.
Use:
obj-y += xxx
Quoted 2 lines
This is much more readable.
Will fix this.
Re: [PATCH 01/28] nios2: Build infrastructure
In reply to Paul BolleQuoted 11 lines · Paul Bolle
Quoted 1 line · Ley Foon Tan
arch/nios2/kernel/Makefile +0
-0[...]
Quoted 1 line
+obj-$(CONFIG_CONSOLE) += console.o
CONFIG_CONSOLEseems never to be defined. And there appears to be noarch/nios2/console.cor.../console.Sanyway.Paul Bolle
Good catch. Will remove this.
Thanks.
Regards
Ley Foon
Re: [PATCH 01/28] nios2: Build infrastructure
In reply to Paul BolleQuoted 8 lines · Paul Bolle
arch/nios2/Kconfig
Quoted 4 lines · Ley Foon Tan
arch/nios2/Kconfig +2
-0+config GENERIC_FIND_NEXT_BIT + def_bool yThis one is not needed, see commit
63e424c84429("arch: remove CONFIG_GENERIC_FIND_{NEXT_BIT,BIT_LE,LAST_BIT}").
Okay, will remove this CONFIG.
Quoted 5 lines
arch/nios2/Kconfig
Quoted 3 lines
arch/nios2/Kconfig +2
-0+config NO_IOPORT + def_bool yDid you mean
NO_IOPORT_MAP?
Yes, will change it to NO_IOPORT_MAP
Thanks.
Regards
Ley Foon
Quoted 9 lines · Arnd Bergmann
Quoted 2 lines · H. Peter Anvin
Did the generic headers ever get updated to match Linus' guidance that any new architecture ports should use a 64-bit
time_t?No, unfortunately not. With my rule that every architecture that gets added needs to clean up asm-generic some more, to make it easier to add the next one, we should probably do for nios2.
Arnd
Can you give me the documentation on this new guidance and point me any architecture have implemented this?
Thanks.
Ley Foon
Quoted 9 lines · Ley Foon Tan
Quoted 8 lines · Arnd Bergmann
Quoted 2 lines · H. Peter Anvin
Did the generic headers ever get updated to match Linus' guidance that any new architecture ports should use a 64-bit
time_t?No, unfortunately not. With my rule that every architecture that gets added needs to clean up asm-generic some more, to make it easier to add the next one, we should probably do for nios2.
Quoted 6 lines
Quoted 1 line
Arnd
Can you give me the documentation on this new guidance and point me any architecture have implemented this?
Thanks.
We implemented it in the x32 ABI for x86. In generic code this is keyed by COMPAT_USE_64BIT_TIME, but in your case it isn't actually a matter of compat, so it should be easier.
See this thread including the discussion about time_t:
https://lkml.org/lkml/2011/8/26/415
-hpa
Quoted 21 lines · H. Peter Anvin
Quoted 9 lines · Ley Foon Tan
Quoted 8 lines · Arnd Bergmann
Quoted 2 lines · H. Peter Anvin
Did the generic headers ever get updated to match Linus' guidance that any new architecture ports should use a 64-bit
time_t?No, unfortunately not. With my rule that every architecture that gets added needs to clean up asm-generic some more, to make it easier to add the next one, we should probably do for nios2.
Quoted 6 lines
Quoted 1 line
Arnd
Can you give me the documentation on this new guidance and point me any architecture have implemented this?
Thanks.We implemented it in the x32 ABI for x86. In generic code this is keyed by
COMPAT_USE_64BIT_TIME, but in your case it isn't actually a matter of compat, so it should be easier.
Quoted 5 lines
See this thread including the discussion about
time_t:https://lkml.org/lkml/2011/8/26/415
-hpa
I'm not sure why we need CONFIG_USE_64BIT_TIME? We don't have any 32-on-64 problems.
My understanding of what Arnd meant, was to clean up asm-generic/posix_types.h such that for example, time_t should be defined as a 'long long' type, which should be 64-bit almost everywhere. At least AFAIK, that should work for all current asm-generic users.
Thanks,
Chung-Lin
Re: [PATCH 16/28] nios2: System calls handling
In reply to Geert UytterhoevenQuoted 9 lines · Geert Uytterhoeven
arch/nios2/kernel/sys_nios2.c line 51
Quoted 6 lines
arch/nios2/kernel/sys_nios2.c new file +6
-0+*/ + vma =find_vma (current->mm, addr); +if (vma ==NULL || addr < vma->vm_start || addr + len > vma->vm_end) +return -EFAULT ; + +/* Ignore the scope and cache arguments. */ This function doesn't have scope and cache arguments (
sys_cacheflush()on m68k does have them ;-)
Missed out the comment after rename the arguments.:) Will update the comment above.
Quoted 7 lines · Pavel Machek
Quoted 2 lines
Also... explanation why you need this syscall while other architectures live happily without it would be nice.
12 our of 28 architectures provide such a syscall...
Is flushing the cache a privileged operation on nios2?
Yes.
Thanks.
Regards
Ley Foon
Re: [PATCH 16/28] nios2: System calls handling
In reply to Pavel MachekQuoted 5 lines · Pavel Machek
arch/nios2/include/uapi/asm/unistd.h line 25
Quoted 3 lines
arch/nios2/include/uapi/asm/unistd.h new file +3
-0+/* Additional Nios II specific syscalls. */ +#define __NR_cacheflush (__NR_arch_specific_syscall) +__SYSCALL (__NR_cacheflush, sys_cacheflush)I guess you should Cc: Michael Kerrisk on this one.
CC him this email.
Quoted 3 lines
Also... explanation why you need this syscall while other architectures live happily without it would be nice.
This syscall exist in nios2 port since old days and some users already used it for sometimes.
Like mentioned by Greet, 12 our of 28 architectures provide such a syscall.
Quoted 11 lines
arch/nios2/kernel/sys_nios2.c line 37
Quoted 8 lines
arch/nios2/kernel/sys_nios2.c new file +8
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ;op is being ignored? You should remove it... or if (op) return
-EINVALif you want future extensions.
Yes, op argument is being ignored. Okay, will add the return -EINVAL if op is non-zero.
Thanks.
Regards
Ley Foon
Re: [PATCH 16/28] nios2: System calls handling
Quoted 26 lines · Ley Foon Tan
Quoted 5 lines · Pavel Machek
arch/nios2/include/uapi/asm/unistd.h line 25
Quoted 3 lines
arch/nios2/include/uapi/asm/unistd.h new file +3
-0+/* Additional Nios II specific syscalls. */ +#define __NR_cacheflush (__NR_arch_specific_syscall) +__SYSCALL (__NR_cacheflush, sys_cacheflush)I guess you should Cc: Michael Kerrisk on this one.
CC him this email.
Quoted 3 lines
Also... explanation why you need this syscall while other architectures live happily without it would be nice.
This syscall exist in nios2 port since old days and some users already used it for sometimes.
Like mentioned by Greet, 12 our of 28 architectures provide such a syscall.Quoted 11 lines
arch/nios2/kernel/sys_nios2.c line 37
Quoted 8 lines
arch/nios2/kernel/sys_nios2.c new file +8
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ;op is being ignored? You should remove it... or if (op) return
-EINVALif you want future extensions.
Quoted 2 lines
Yes, op argument is being ignored. Okay, will add the return
-EINVALif op is non-zero.
Be careful. If existing applications already use this and maybe pass a dummy value
to it you break them.
Signature · 2 lines
Thanks, //richard
Re: [PATCH 16/28] nios2: System calls handling
In reply to Ley Foon TanHi!
Quoted 5 lines
Quoted 2 lines
Also... explanation why you need this syscall while other architectures live happily without it would be nice.
This syscall exist in nios2 port since old days and some users already used it for sometimes.
Like mentioned by Greet, 12 our of 28 architectures provide such a syscall.
Would it make sense to create common code for this syscall?
Quoted 11 lines
Quoted 11 lines
arch/nios2/kernel/sys_nios2.c line 37
Quoted 8 lines
arch/nios2/kernel/sys_nios2.c new file +8
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ;op is being ignored? You should remove it... or if (op) return
-EINVALif you want future extensions.
Quoted 2 lines
Yes, op argument is being ignored. Okay, will add the return
-EINVALif op is non-zero.
Thanks!
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 16/28] nios2: System calls handling
In reply to Richard WeinbergerQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/nios2/kernel/sys_nios2.c line 37
Quoted 8 lines
arch/nios2/kernel/sys_nios2.c new file +8
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ;op is being ignored? You should remove it... or if (op) return
-EINVALif you want future extensions.
Quoted 6 lines
Quoted 2 lines
Yes, op argument is being ignored. Okay, will add the return
-EINVALif op is non-zero.Be careful. If existing applications already use this and maybe pass a dummy value
to it you break them.
Well.. of course, but passing ignored integer to syscall, that can be never used is beyond ugly. NAK-level ugly.
If it is so, you can never ever use the argument, and might as well remove it (depending on your calling convention, it should not break anything.)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 09/28] nios2: Page table management
In reply to Pavel MachekHi
Quoted 10 lines · Pavel Machek
Quoted 10 lines
arch/nios2/mm/pgtable.c new file +10
-0+static void pgd_init (pgd_t *pgd) +{ +unsigned long *p = (unsigned long *) pgd; +int i; + +for (i =0 ; i <USER_PTRS_PER_PGD ; i +=8 ) { + p[i +0 ] = (unsigned long ) invalid_pte_table; + p[i +1 ] = (unsigned long ) invalid_pte_table; + p[i +2 ] = (unsigned long ) invalid_pte_table; + p[i +3 ] = (unsigned long ) invalid_pte_table;
Quoted 8 lines
arch/nios2/mm/pgtable.c line 51
Quoted 5 lines
arch/nios2/mm/pgtable.c new file +5
-0+ p[i +4 ] = (unsigned long ) invalid_pte_table; + p[i +5 ] = (unsigned long ) invalid_pte_table; + p[i +6 ] = (unsigned long ) invalid_pte_table; + p[i +7 ] = (unsigned long ) invalid_pte_table; + }Umm. Manual loop unrolling. Does it really improve performance? Is the code hot enough to warrant the uglyness?
We can use the memset here because invalid_pte_table is full 32 bit value. BTW, arch for score and mips have the similar implementation as well.
Regards
Re: [PATCH 16/28] nios2: System calls handling
In reply to Pavel MachekQuoted 18 lines · Pavel Machek
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/nios2/kernel/sys_nios2.c line 37
Quoted 8 lines
arch/nios2/kernel/sys_nios2.c new file +8
-0+/* sys_cacheflush -- flush the processor cache. */ +asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, +unsigned int op) +{ +struct vm_area_struct *vma; + +if (len ==0 ) +return 0 ;op is being ignored? You should remove it... or if (op) return
-EINVALif you want future extensions.Quoted 6 lines
Quoted 2 lines
Yes, op argument is being ignored. Okay, will add the return
-EINVALif op is non-zero.Be careful. If existing applications already use this and maybe pass a dummy value
to it you break them.
Quoted 7 lines
Well.. of course, but passing ignored integer to syscall, that can be never used is beyond ugly. NAK-level ugly.
If it is so, you can never ever use the argument, and might as well remove it (depending on your calling convention, it should not break anything.)
I'm prefer to keep the calling convention here for future use and add the op checking here.
This prevent us to update toolchain if we plan to add in op option later.
Regards
Ley Foon
Hi Arnd and Peter Anvin,
Other than 64-bit time_t, clock_t and suseconds_t, can you confirm that we don't need to have 64 bit off_t? See detail in link below. I can submit the patches for 64-bit time changes (include/asm-generic/posix_types.h and other archs) if everyone is agreed on this.
Excerpt from https://lkml.org/lkml/2012/11/14/358 :
"Obviously, we want to use 64-bit off_t, but this is achieved already through loff_t, which is used in all places in the asm-generic ABI anyway (the syscalls using off_t are stripped out). I don't think we want to have the other ones set to 64 bit on ARC or Meta, although I'm not 100% sure about ino_t and nlink_t. "
Thanks.
Regards
Ley Foon
Quoted 26 lines · H. Peter Anvin
Quoted 9 lines · Ley Foon Tan
Quoted 8 lines · Arnd Bergmann
Quoted 2 lines · H. Peter Anvin
Did the generic headers ever get updated to match Linus' guidance that any new architecture ports should use a 64-bit
time_t?No, unfortunately not. With my rule that every architecture that gets added needs to clean up asm-generic some more, to make it easier to add the next one, we should probably do for nios2.
Quoted 6 lines
Quoted 1 line
Arnd
Can you give me the documentation on this new guidance and point me any architecture have implemented this?
Thanks.We implemented it in the x32 ABI for x86. In generic code this is keyed by
COMPAT_USE_64BIT_TIME, but in your case it isn't actually a matter of compat, so it should be easier.See this thread including the discussion about
time_t:https://lkml.org/lkml/2011/8/26/415
-hpa
Re: [PATCH 04/28] nios2: Exception handling
In reply to Ley Foon TanHi Ley Foon,
Review
Quoted 9 lines · Ley Foon Tan
(quoted diff) +9
-0+ + /* Get thread info pointer */ + movi r11, %lo(0xfffff000) + and r11, sp, r11 + ldw r11, TI_FLAGS(r11) + + /* If someone is ptrace:ing us, take the long way. */ + BTBNZ r11, r11, TIF_SYSCALL_TRACE, traced_system_call +
Are you sure this is correct? Have you tested this works correctly?
Last time I tested this, it caused the traced_system_call to be taken for every system call. I already reported and provided a patch a few months ago:
http://lists.rocketboards.org/pipermail/nios2-dev/2014-January/006968.html
Here's my proposed fix:
arch/nios2/kernel/entry.S +4 -7
@@ -204,13 +204,10 @@ ENTRY(handle_system_call) ldw r1, %lo(sys_call_table)(r1) beq r1, r0, ret_invsyscall - /* Get thread info pointer */ - movi r11, %lo(0xfffff000) - and r11, sp, r11 - ldw r11, TI_FLAGS(r11) - - /* If someone is ptrace:ing us, take the long way. */ - BTBNZ r11, r11, TIF_SYSCALL_TRACE, traced_system_call + /* Check if we are being traced */ + GET_THREAD_INFO r11 + ldw r11,TI_FLAGS(r11) + BTBNZ r11,r11,TIF_SYSCALL_TRACE,traced_system_call /* Execute the system call */ callr r1
Signature · 6 lines
1.9.1 -- Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Arnd Bergmann
maintainerQuoted 7 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,
Other than 64-bit
time_t,clock_tandsuseconds_t, can you confirm that we don't need to have 64 bitoff_t? See detail in link below. I can submit the patches for 64-bit time changes (include/asm-generic/posix_types.hand other archs) if everyone is agreed on this.
Yes.
Quoted 6 lines
Excerpt from https://lkml.org/lkml/2012/11/14/358 :
"Obviously, we want to use 64-bitoff_t, but this is achieved already throughloff_t, which is used in all places in the asm-generic ABI anyway (the syscalls usingoff_tare stripped out). I don't think we want to have the other ones set to 64 bit on ARC or Meta, although I'm not 100% sure aboutino_tandnlink_t. "
This is all still true. You should have no syscall using 'off_t', only loff_t.
I still don't know whether we would want 32 or 64 bit ino_t and nlink_t for new architectures. It seems it would gain very little, but have a noticeable overhead.
Arnd
Re: [PATCH 04/28] nios2: Exception handling
In reply to Ezequiel GarciaQuoted 24 lines · Ezequiel Garcia
Hi Ley Foon,
Are you sure this is correct? Have you tested this works correctly?
Last time I tested this, it caused the
traced_system_callto be taken for every system call. I already reported and provided a patch a few months ago:http://lists.rocketboards.org/pipermail/nios2-dev/2014-January/006968.html
Here's my proposed fix:
arch/nios2/kernel/entry.S +0
-4@@ -204,13 +204,10 @@ ENTRY(handle_system_call) ldw r1, %lo(sys_call_table)(r1) beq r1, r0, ret_invsyscall - /* Get thread info pointer */ - movi r11, %lo(0xfffff000) - and r11, sp, r11 - ldw r11, TI_FLAGS(r11)
arch/nios2/kernel/entry.S ENTRY(handle_system_call) · line 213
Quoted 10 lines
arch/nios2/kernel/entry.S +4
-3- - /* If someone is ptrace:ing us, take the long way. */ - BTBNZ r11, r11, TIF_SYSCALL_TRACE, traced_system_call + /* Check if we are being traced */ + GET_THREAD_INFO r11 + ldw r11,TI_FLAGS(r11) + BTBNZ r11,r11,TIF_SYSCALL_TRACE,traced_system_call /* Execute the system call */ callr r1
I think I missed out this in nios2-dev ML previously. I will take your fix. Thanks.
Regards
Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,
Other than 64-bit
time_t,clock_tandsuseconds_t, can you confirm that we don't need to have 64 bitoff_t? See detail in link below. I can submit the patches for 64-bit time changes (include/asm-generic/posix_types.hand other archs) if everyone is agreed on this.Yes.
Okay, will doing that.
Quoted 8 lines
Quoted 7 lines
Excerpt from https://lkml.org/lkml/2012/11/14/358 :
"Obviously, we want to use 64-bitoff_t, but this is achieved already throughloff_t, which is used in all places in the asm-generic ABI anyway (the syscalls usingoff_tare stripped out). I don't think we want to have the other ones set to 64 bit on ARC or Meta, although I'm not 100% sure aboutino_tandnlink_t. "
Quoted 6 lines
This is all still true. You should have no syscall using '
off_t', onlyloff_t.I still don't know whether we would want 32 or 64 bit
ino_tandnlink_tfor new architectures. It seems it would gain very little, but have a noticeable overhead.
Anyone have comment on this?
Chung-Lin (in CC list) is our nios2 toolchain maintainer. Do you have any comment for 32 or 64 bit ino_t and nlink_t?
We will update the toolchain to support 64-bit time_t, so we hope that any other toolchain change can happen in one time.
Thanks
Regards
Ley Foon
Re: [PATCH 28/28] Documentation: Add documentation for Nios2 architecture
In reply to Ley Foon TanQuoted 19 lines · Ley Foon Tan
Signed-off-by Ley Foon Tan <[email protected]>--- Documentation/nios2/README | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/nios2/READMEDocumentation/nios2/README new file +7
-0@@ -0,0 +1,23 @@ +Linux on the Nios II architecture +================================= + +This is a port of Linux to Nios II (nios2) processor. + +In order to compile for Nios II, you need a version of GCC with support for the generic +system call ABI. Please see this link for more information on how compiling and booting
Documentation/nios2/README line 17
Quoted 10 lines
Documentation/nios2/README new file +10
-0+software for the Nios II platform: +http://www.rocketboards.org/foswiki/Documentation/NiosIILinuxUserManual + +For reference, please see the following link: +http://www.altera.com/literature/lit-nio2.jsp + +What is Nios II? +================ +Nios II is a 32-bit embedded-processor architecture designed specifically for the +Altera family of FPGAs. In order to support Linux system, Nios II needs to configure
Minor nit: 'In order to support Linux, Nios II needs to be configured...'
Quoted 15 lines
Documentation/nios2/README new file +6
-0+with MMU and hardware multiplier enabled. + +Nios II ABI +=========== +Please refer to chapter "Application Binary Interface" in Nios II Processor Reference +Handbook.Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerRe: [PATCH 16/28] nios2: System calls handling
In reply to Ley Foon Tanarch/nios2/include/uapi/asm/unistd.h line 19
Quoted 3 lines · Ley Foon Tan
arch/nios2/include/uapi/asm/unistd.h new file +3
-0+ +#define sys_mmap2 sys_mmap_pgoff +
You use sys_mmap_pgoff here, but
arch/nios2/kernel/sys_nios2.c line 28
Quoted 9 lines
arch/nios2/kernel/sys_nios2.c new file +9
-0+asmlinkage long sys_mmap (unsigned long addr,unsigned long len, +unsigned long prot,unsigned long flags, +unsigned long fd,unsigned long offset) +{ +if (offset & ~PAGE_MASK ) +return -EINVAL ; + +return sys_mmap_pgoff (addr, len, prot, flags, fd, offset >>PAGE_SHIFT ); +}
define a separate sys_mmap() here. Doing the former should be enough. so you can just drop the sys_mmap definition.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 04/28] nios2: Exception handling
In reply to Ley Foon Tanarch/nios2/kernel/misaligned.c line 274
Quoted 8 lines · Ley Foon Tan
arch/nios2/kernel/misaligned.c new file +8
-0+static const struct file_operations misalign_fops = { + .open = proc_misaligned_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = proc_misaligned_write, +}; +#endif /* CONFIG_PROC_FS */
We really shouldn't be doing new architecture specific procfs files any more. I suggest you drop this one for now, and add back the functionality using perf or ftrace at a later point.
Arnd
Re: [PATCH 23/28] nios2: Nios2 registers
In reply to Ley Foon TanQuoted 60 lines · Ley Foon Tan
This file contains constants for the instruction macros, cpu registers, fields and bits.
Signed-off-by Ley Foon Tan <[email protected]>--- arch/nios2/include/asm/registers.h | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 arch/nios2/include/asm/registers.harch/nios2/include/asm/registers.h new file +46
-0@@ -0,0 +1,65 @@ +/* +* Copyright (C) 2011 Tobias Klauser <[email protected]> +* +* 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, see <http://www.gnu.org/licenses/>. +* +*/ + +#ifndef _ASM_NIOS2_REGISTERS_H +#define _ASM_NIOS2_REGISTERS_H + +/* control register numbers */ +#define CTL_STATUS 0 +#define CTL_ESTATUS 1 +#define CTL_BSTATUS 2 +#define CTL_IENABLE 3 +#define CTL_IPENDING 4 +#define CTL_CPUID 5 +#define CTL_RSV1 6 +#define CTL_EXCEPTION 7 +#define CTL_PTEADDR 8 +#define CTL_TLBACC 9 +#define CTL_TLBMISC 10 +#define CTL_RSV2 11 +#define CTL_BADADDR 12 +#define CTL_CONFIG 13 +#define CTL_MPUBASE 14 +#define CTL_MPUACC 15 + +/* access control registers using GCC builtins */ +#define RDCTL (r) __builtin_rdctl(r) +#define WRCTL (r, v) __builtin_wrctl(r, v) + +/* status register bits */ +#define STATUS_PIE (1 << 0)/* processor interrupt enable */ +#define STATUS_U (1 << 1)/* user mode */
arch/nios2/include/asm/registers.h line 56
Quoted 10 lines
arch/nios2/include/asm/registers.h new file +10
-0+#define STATUS_EH (1 << 2)/* Exception mode */ + +/* estatus register bits */ +#define ESTATUS_EPIE (1 << 0)/* processor interrupt enable */ +#define ESTATUS_EU (1 << 1)/* user mode */ +#define ESTATUS_EH (1 << 2)/* Exception mode */ + +/* tlbmisc register bits */ +#define TLBMISC_PID_SHIFT 4 +#define TLBMISC_PID_MASK ((1UL << cpuinfo.tlb_pid_num_bits) - 1)
You should probably #include <asm/cpuinfo.h> here since struct cpuinfo is used in the definition.
Quoted 17 lines
arch/nios2/include/asm/registers.h new file +9
-0+#define TLBMISC_WAY_MASK 0xf +#define TLBMISC_WAY_SHIFT 20 + +#define TLBMISC_PID (TLBMISC_PID_MASK << TLBMISC_PID_SHIFT)/* TLB PID */ +#define TLBMISC_WE (1 << 18)/* TLB write enable */ +#define TLBMISC_RD (1 << 19)/* TLB read */ +#define TLBMISC_WAY (TLBMISC_WAY_MASK << TLBMISC_WAY_SHIFT)/* TLB way */ + +#endif /* _ASM_NIOS2_REGISTERS_H */ Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerRe: [PATCH 19/28] nios2: Device tree support
In reply to Ley Foon TanQuoted 20 lines · Ley Foon Tan
arch/nios2/boot/dts/3c120_devboard.dts new file +14
-0@@ -0,0 +1,205 @@ +/* + * Copyright (C) 2013 Altera Corporation + * + * 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
arch/nios2/boot/dts/3c120_devboard.dts line 24
Quoted 10 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +10
-0+ * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * This file is generated by sopc2dts. + */ + +/dts-v1/; + +/ { + model = "ALTR,qsys_ghrd_3c120"; + compatible = "ALTR,qsys_ghrd_3c120";
You have a mix of "ALTR" and "altr" prefixes. The general recommendation is to use lower-case letters, which is also what is used on ARM socfpga, and what is documented in Documentation/devicetree/bindings/vendor-prefixes.txt for Altera.
arch/nios2/boot/dts/3c120_devboard.dts line 74
Quoted 11 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +11
-0+ sopc@0 { + device_type = "soc"; + ranges; + #address-cells = < 1 >; + #size-cells = < 1 >; + compatible = "ALTR,avalon", "simple-bus"; + bus-frequency = < 125000000 >; + + pb_cpu_to_io: bridge@0x8000000 { + compatible = "simple-bus"; + reg = < 0x08000000 0x00800000 >;
Are these all synthesized devices, or is there also some hardwired logic? It often makes sense to split out the reusable parts into a separate .dtsi file that gets included by every implementation.
arch/nios2/boot/dts/3c120_devboard.dts line 87
Quoted 13 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +13
-0+ #address-cells = < 1 >; + #size-cells = < 1 >; + ranges = < 0x00400000 0x08400000 0x00000020 + 0x00004D40 0x08004D40 0x00000008 + 0x00004D50 0x08004D50 0x00000008 + 0x00004000 0x08004000 0x00000400 + 0x00004400 0x08004400 0x00000040 + 0x00004800 0x08004800 0x00000040 + 0x00002000 0x08002000 0x00002000 + 0x00004C80 0x08004C80 0x00000020 + 0x00004CC0 0x08004CC0 0x00000010 + 0x00004CE0 0x08004CE0 0x00000010 + 0x00004D00 0x08004D00 0x00000010 >;
A few style comments:
- no whitespace in the after '<' or before '>
- put each entry into its own '<...>' group.
- lower-case characters for hex digits
- The ranges should reflect what the bus actually translates, which is typically not individual bytes but rather whole address ranges.
- sort numerically.
The above could look like
ranges = <0x00000000 0x08000000 0x00010000>, <0x00400000 0x08400000 0x00001000>;
arch/nios2/boot/dts/3c120_devboard.dts line 112
Quoted 13 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +12
-0+ timer_1ms: timer@0x400000 { + compatible = "ALTR,timer-1.0"; + + sysid: sysid@0x4d40 { + compatible = "ALTR,sysid-1.0"; + reg = < 0x00004D40 0x00000008 >; + jtag_uart: serial@0x4d50 { + compatible = "ALTR,juart-1.0"; + reg = < 0x00004D50 0x00000008 >; + + tse_mac: ethernet@0x4000 { + compatible = "ALTR,tse-1.0";
Does each one of these have a binding document inDocumentation/devicetree/bindings?
I've looked only at the tse binding, which you seem to be violating in a few places:
- compatible string is "ALTR,tse-1.0", not "altr,tse-1.0"
arch/nios2/boot/dts/3c120_devboard.dts line 117
Quoted 5 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +5
-0+ reg = < 0x00004000 0x00000400 + 0x00004400 0x00000040 + 0x00004800 0x00000040 + 0x00002000 0x00002000 >; + reg-names = "control_port", "rx_csr", "tx_csr", "s1";
- wrong order, missing "tx_desc" and "rx_desc" entries
arch/nios2/boot/dts/3c120_devboard.dts line 123
Quoted 3 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +3
-0+ rx-fifo-depth = < 8192 >; + tx-fifo-depth = < 8192 >; + address-bits = < 48 >;
address-bits is not documented
arch/nios2/boot/dts/3c120_devboard.dts line 127
Quoted 4 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +4
-0+ max-frame-size = < 1518 >; + local-mac-address = [ 02 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + ALTR,mii-id = < 0 >;
ALTR,mii-id is not documented, and required "phy-addr" is missing.
arch/nios2/boot/linked_dtb.S line 19
Quoted 8 lines
arch/nios2/boot/linked_dtb.S new file +3
-0+ */ +.section .dtb.init.rodata,"a" +.incbin "arch/nios2/boot/system.dtb"
Linking in the dtb file is really against the point of device trees. You should require boot loaders to pass the dtb seperately.
arch/nios2/boot/linked_dtb.S
Quoted 3 lines
arch/nios2/boot/linked_dtb.S new file +3
-0+ soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", NIOS2_ID_DEFAULT); + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", + NIOS2_REVISION_DEFAULT);
These are hardcoded constants. If there is no way to identify the hardware from looking at the registers, better don't fill these at all.
arch/nios2/boot/linked_dtb.S
Quoted 2 lines
arch/nios2/boot/linked_dtb.S new file +2
-0+ soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR_OR_NULL(soc_dev)) {
Never use IS_ERR_OR_NULL().
If an interface can return an error code, you should rely on never seeing NULL, or treating it as a valid pointer.
arch/nios2/boot/linked_dtb.S
Quoted 7 lines
arch/nios2/boot/linked_dtb.S new file +7
-0+static int __init nios2_device_probe(void) +{ + nios2_soc_device_init(); + + of_platform_bus_probe(NULL, altera_of_bus_ids, NULL); + return 0; +}
This function can get merged into nios2_soc_device_init.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 20/28] nios2: Time keeping
In reply to Ley Foon TanQuoted 7 lines · Ley Foon Tan
arch/nios2/kernel/time.c new file +7
-0+static inline unsigned long read_timersnapshot (void ) +{ +unsigned long count; + +outw (0 , timer_membase +ALTERA_TIMER_SNAPL_REG ); + count = + inw(timer_membase + ALTERA_TIMER_SNAPH_REG) << 16 |
arch/nios2/kernel/time.c line 58
Quoted 10 lines
arch/nios2/kernel/time.c new file +10
-0+inw (timer_membase +ALTERA_TIMER_SNAPL_REG ); + +return count; +} + +static inline void write_timerperiod (unsigned long period) +{ +outw (period, timer_membase +ALTERA_TIMER_PERIODL_REG ); +outw (period >>16 , timer_membase +ALTERA_TIMER_PERIODH_REG ); +}
It's wrong to use 'outw' if this device is not on an PC-style ISA bus, which I assume it is not. Since timer_membase is an __iomem pointer, I'm sure you want to use writew() instead.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 14/28] nios2: DMA mapping API
In reply to Ley Foon TanQuoted 15 lines · Ley Foon Tan
arch/nios2/include/asm/dma-mapping.h new file +14
-0+static inline int dma_supported (struct device *dev,u64 mask) +{ +/* we fall back to GFP_DMA when the mask isn't all 1s, +* so we can't guarantee allocations that must be +* within a tighter range than GFP_DMA. +*/ +if (mask <0x00ffffff ) +return 0 ; + +return 1 ; +} +void *dma_alloc_coherent (struct device *dev,size_t size, +dma_addr_t *dma_handle,gfp_t gfp) +{
arch/nios2/include/asm/dma-mapping.h
Quoted 10 lines
arch/nios2/include/asm/dma-mapping.h new file +10
-0+void *ret; + +/* ignore region specifiers */ + gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); + +/* optimized page clearing */ + gfp |= __GFP_ZERO; + +if (dev ==NULL || (dev->coherent_dma_mask <0xffffffff )) + gfp |=GFP_DMA ;
What is the significance of ZONE_DMA on this architecture?
Do you actually have DMA masters with a 0x00ffffff mask?
Arnd
Arnd Bergmann
maintainerRe: [PATCH 07/28] nios2: I/O Mapping
In reply to Ley Foon Tanarch/nios2/include/asm/io.h line 15
Quoted 4 lines · Ley Foon Tan
arch/nios2/include/asm/io.h new file +4
-0+ +#include <asm/pgtable-bits.h> + +#define IO_SPACE_LIMIT 0xffffffff
Please use 0xffff here, this should work for almost any PCI bus.
Quoted 6 lines
arch/nios2/include/asm/io.h new file +6
-0+ +#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE +# define __IO_USE_DUFFS +#endif + +#ifdef __IO_USE_DUFFS
arch/nios2/include/asm/io.h line 31
Quoted 10 lines
arch/nios2/include/asm/io.h new file +10
-0+ +/* Use "Duff's Device" to unroll the loops. */ +#define __IO_OUT_LOOP (a, b, l) \ + do { \ + if (l > 0) { \ + int _n = (l + 7) / 8; \ + switch (l % 8) { \ + case 0: \ + do { \ + *a = *b++; \
I would recommend just doing all of this in out-of-line implementations rather than macros and inline functions.
arch/nios2/include/asm/io.h line 168
Quoted 11 lines
arch/nios2/include/asm/io.h new file +11
-0+ +/* +* make the short names macros so specific devices +* can override them as required +*/ +#define inb (addr) readb(addr) +#define inw (addr) readw(addr) +#define inl (addr) readl(addr) +#define outb (x, addr) ((void) writeb(x, addr)) +#define outw (x, addr) ((void) writew(x, addr)) +#define outl (x, addr) ((void) writel(x, addr))
This makes no sense: the legacy PC I/O accessors take a completely different argument type: I would recommend to make both inline functions so you can ensure that readl() gets passed an __iomem pointer, while inl() gets an integer number.
Please see the asm-generic version for an example. You should also define a non-NULL PCI_IOBASE to which the PCI I/O space gets mapped.
arch/nios2/include/asm/io.h line 214
Quoted 2 lines
arch/nios2/include/asm/io.h new file +2
-0+#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt
Please drop these, and the CONFIG_VIRT_TO_BUS Kconfig option, and fix all drivers that rely on it.
arch/nios2/include/asm/io.h line 217
Quoted 2 lines
arch/nios2/include/asm/io.h new file +2
-0+#define ioport_map (port, nr) ioremap(port, nr) +#define ioport_unmap (port) iounmap(port)
Use this one instead:
#ifdef CONFIG_PCI
static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
{
return PCI_IOBASE + port;
}static inline void __iomem *ioport_unmap(void __iomem *) {
}
#endif
arch/nios2/include/asm/io.h line 225
Quoted 7 lines
arch/nios2/include/asm/io.h new file +7
-0+/* Macros used for smc91x.c driver */ +#define readsb (p, d, l) insb(p, d, l) +#define readsw (p, d, l) insw(p, d, l) +#define readsl (p, d, l) insl(p, d, l) +#define writesb (p, d, l) outsb(p, d, l) +#define writesw (p, d, l) outsw(p, d, l) +#define writesl (p, d, l) outsl(p, d, l)
These should of course not fall back to the PCI I/O space functions. You can do it the other way round.
Arnd
Re: [PATCH 06/28] nios2: Memory management
In reply to Ley Foon TanHi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +
How about something like this:
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
Otherwise, the PAGE_SIZE macro above produces some warnings, IIRC.
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Re: [PATCH 05/28] nios2: Traps exception handling
In reply to Ley Foon TanHello Ley Foon,
arch/nios2/kernel/traps.c line 134
Quoted 12 lines · Ley Foon Tan
arch/nios2/kernel/traps.c new file +12
-0+ +#ifndef CONFIG_ALIGNMENT_TRAP +/* Alignment exception handler */ +asmlinkage void handle_unaligned_c(struct pt_regs *fp, int cause) +{ +unsigned long addr =RDCTL (CTL_BADADDR ); + + cause >>=2 ; + fp->ea -=4 ; + +if (fixup_exception (fp)) +return ;
This will throw an undeclared error if you build with CONFIG_ALIGNMENT_TRAP=n.
You need to add the uaccess.h header, or implement some similar fix.
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Re: [PATCH 08/28] nios2: MMU Fault handling
In reply to Ley Foon TanHello Ley Foon,
arch/nios2/mm/fault.c line 153
Quoted 4 lines · Ley Foon Tan
arch/nios2/mm/fault.c new file +4
-0+ +bad_area_nosemaphore: +/* User mode accesses just cause a SIGSEGV */ +if (user_mode (regs)) {
I found that it's useful to add some printing here, just as ARM does. I carry this patch on my kernel:
+ printk(KERN_INFO "%s: unhandled page fault (%d) at 0x%08lx, cause %ld\n",
+ current->comm, SIGSEGV, address, cause);
+ show_regs(regs);
Do you think we could do something like it? Maybe with a compile time option?
Quoted 4 lines
arch/nios2/mm/fault.c new file +4
-0+_exception (SIGSEGV , regs, code, address); +return ; + } +
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Quoted 24 lines · Ley Foon Tan
Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,
Other than 64-bit
time_t,clock_tandsuseconds_t, can you confirm that we don't need to have 64 bitoff_t? See detail in link below. I can submit the patches for 64-bit time changes (include/asm-generic/posix_types.hand other archs) if everyone is agreed on this.Yes.
Okay, will doing that.
Quoted 11 lines
Quoted 7 lines
Excerpt from https://lkml.org/lkml/2012/11/14/358 :
"Obviously, we want to use 64-bitoff_t, but this is achieved already throughloff_t, which is used in all places in the asm-generic ABI anyway (the syscalls usingoff_tare stripped out). I don't think we want to have the other ones set to 64 bit on ARC or Meta, although I'm not 100% sure aboutino_tandnlink_t. "This is all still true. You should have no syscall using '
off_t', onlyloff_t.
Quoted 8 lines
Quoted 3 lines
I still don't know whether we would want 32 or 64 bit
ino_tandnlink_tfor new architectures. It seems it would gain very little, but have a noticeable overhead.Anyone have comment on this?
Chung-Lin (in CC list) is our nios2 toolchain maintainer. Do you have any comment for 32 or 64 bitino_tandnlink_t?
We will update the toolchain to support 64-bittime_t, so we hope that any other toolchain change can happen in one time.
For ino_t, 32-bit users of linux-generic glibc already use struct stat64, stat64(), etc. to align with 64-bit targets, so in terms of the glibc/kernel interface it doesn't matter much. The in-kernel usage of the ino_t type should be of more concern here.
nlink_t appears to be always defined as u32 in <linux/types.h>, not sure if changing it to arch-overridable is reasonable.
Chung-Lin
Re: [PATCH 06/28] nios2: Memory management
In reply to Ezequiel GarciaQuoted 13 lines · Ezequiel Garcia
Hi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +How about something like this:
Quoted 6 lines
/*
PAGE_SHIFTdetermines the page size */#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))Otherwise, the
PAGE_SIZEmacro above produces some warnings, IIRC.
AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC) would complain about something like the above, that's the reason I added an explicit value for PAGE_SIZE back then.
I assume with the new nios2 GCC this should no longer be necessary and Ezequiel's fix should be fine.
Re: [PATCH 06/28] nios2: Memory management
Quoted 19 lines · Tobias Klauser
Quoted 18 lines · Ezequiel Garcia
Hi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +How about something like this:
/*
PAGE_SHIFTdetermines the page size */#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
Quoted 6 lines
Quoted 1 line
Otherwise, the
PAGE_SIZEmacro above produces some warnings, IIRC.AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC) would complain about something like the above, that's the reason I added an explicit value for
PAGE_SIZEback then.
Other than being "pretty" the above fix is to remove a mismatch type warning. You can get rid of the warning in different ways:
ifdef __ASSEMBLY__
define PAGE_SIZE 4096
else
define PAGE_SIZE 4096UL
endif
Quoted 2 lines
I assume with the new nios2 GCC this should no longer be necessary and Ezequiel's fix should be fine.
Speaking of GCC... is there a libc available to test this kernel port? (which I assume uses the generic syscall ABI)
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Re: [PATCH 06/28] nios2: Memory management
Quoted 36 lines · Ezequiel Garcia
Quoted 19 lines · Tobias Klauser
Quoted 18 lines · Ezequiel Garcia
Hi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +How about something like this:
/*
PAGE_SHIFTdetermines the page size */#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))Quoted 6 lines
Quoted 1 line
Otherwise, the
PAGE_SIZEmacro above produces some warnings, IIRC.AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC) would complain about something like the above, that's the reason I added an explicit value for
PAGE_SIZEback then.Other than being "pretty" the above fix is to remove a mismatch type warning. You can get rid of the warning in different ways:
ifdef
__ASSEMBLY__
definePAGE_SIZE4096
else
definePAGE_SIZE4096UL
endif
Quoted 5 lines
Quoted 2 lines
I assume with the new nios2 GCC this should no longer be necessary and Ezequiel's fix should be fine.
Speaking of GCC... is there a libc available to test this kernel port? (which I assume uses the generic syscall ABI)
It's submitted to libc-alpha, also still review in progress.
Chung-Lin
Re: [PATCH 06/28] nios2: Memory management
In reply to Ezequiel GarciaQuoted 27 lines · Ezequiel Garcia
Quoted 19 lines · Tobias Klauser
Quoted 18 lines · Ezequiel Garcia
Hi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +How about something like this:
/*
PAGE_SHIFTdetermines the page size */#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))Quoted 6 lines
Quoted 1 line
Otherwise, the
PAGE_SIZEmacro above produces some warnings, IIRC.AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC) would complain about something like the above, that's the reason I added an explicit value for
PAGE_SIZEback then.
Quoted 8 lines
Other than being "pretty" the above fix is to remove a mismatch type warning. You can get rid of the warning in different ways:
ifdef
__ASSEMBLY__
definePAGE_SIZE4096
else
definePAGE_SIZE4096UL
endif
The usual way to do this is as follows:
#include <linux/const.h>
#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE-1))
_AC(1, UL) expands to 1 for assembler and 1UL for C code.
This is also what was suggested above.
Please follow this scheme for nios2 too.
Sam
Re: [PATCH 06/28] nios2: Memory management
In reply to Chung-Lin TangQuoted 37 lines · Chung-Lin Tang
Quoted 36 lines · Ezequiel Garcia
Quoted 19 lines · Tobias Klauser
Quoted 18 lines · Ezequiel Garcia
Hi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +How about something like this:
/*
PAGE_SHIFTdetermines the page size */#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))Quoted 6 lines
Quoted 1 line
Otherwise, the
PAGE_SIZEmacro above produces some warnings, IIRC.AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC) would complain about something like the above, that's the reason I added an explicit value for
PAGE_SIZEback then.Other than being "pretty" the above fix is to remove a mismatch type warning. You can get rid of the warning in different ways:
ifdef
__ASSEMBLY__
definePAGE_SIZE4096
else
definePAGE_SIZE4096UL
endif
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I assume with the new nios2 GCC this should no longer be necessary and Ezequiel's fix should be fine.
Speaking of GCC... is there a libc available to test this kernel port? (which I assume uses the generic syscall ABI)
It's submitted to libc-alpha, also still review in progress.
Do you plan to support uclibc?
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Re: [PATCH 06/28] nios2: Memory management
Quoted 41 lines · Ezequiel Garcia
Quoted 40 lines · Chung-Lin Tang
Quoted 39 lines · Ezequiel Garcia
Quoted 19 lines · Tobias Klauser
Quoted 18 lines · Ezequiel Garcia
Hi Ley Foon,
arch/nios2/include/asm/page.h line 28
Quoted 7 lines · Ley Foon Tan
arch/nios2/include/asm/page.h new file +7
-0+/* +* PAGE_SHIFT determines the page size +*/ +#define PAGE_SHIFT 12 +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +How about something like this:
/*
PAGE_SHIFTdetermines the page size */#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))Quoted 6 lines
Quoted 1 line
Otherwise, the
PAGE_SIZEmacro above produces some warnings, IIRC.AFAIR old nios2 GCC versions (the 4.1 version from Windriver, IIRC) would complain about something like the above, that's the reason I added an explicit value for
PAGE_SIZEback then.Other than being "pretty" the above fix is to remove a mismatch type warning. You can get rid of the warning in different ways:
ifdef
__ASSEMBLY__
definePAGE_SIZE4096
else
definePAGE_SIZE4096UL
endifQuoted 2 lines
I assume with the new nios2 GCC this should no longer be necessary and Ezequiel's fix should be fine.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Speaking of GCC... is there a libc available to test this kernel port? (which I assume uses the generic syscall ABI)
It's submitted to libc-alpha, also still review in progress.
Do you plan to support uclibc?
No, we (Mentor Graphics) are only doing glibc work at this point.
Chung-Lin
Re: [PATCH 04/28] nios2: Exception handling
In reply to Arnd BergmannQuoted 14 lines · Arnd Bergmann
arch/nios2/kernel/misaligned.c line 274
Quoted 8 lines · Ley Foon Tan
arch/nios2/kernel/misaligned.c new file +8
-0+static const struct file_operations misalign_fops = { + .open = proc_misaligned_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = proc_misaligned_write, +}; +#endif /* CONFIG_PROC_FS */ We really shouldn't be doing new architecture specific procfs files any more. I suggest you drop this one for now, and add back the functionality using perf or ftrace at a later point.
Quoted 1 line
Arnd
Okay, will remove this.
Thanks.
Ley Foon
Re: [PATCH 06/28] nios2: Memory management
In reply to Sam RavnborgQuoted 16 lines · Sam Ravnborg
Quoted 8 lines
Other than being "pretty" the above fix is to remove a mismatch type warning. You can get rid of the warning in different ways:
ifdef
__ASSEMBLY__
definePAGE_SIZE4096
else
definePAGE_SIZE4096UL
endifThe usual way to do this is as follows:
#include <linux/const.h>#define PAGE_SHIFT 12 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE-1))
Quoted 7 lines
_AC(1, UL)expands to 1 for assembler and 1UL for C code.This is also what was suggested above.
Please follow this scheme for nios2 too.
Sam
Sure, will change to this way.
Thanks.
Ley Foon
Re: [PATCH 20/28] nios2: Time keeping
In reply to Arnd BergmannQuoted 23 lines · Arnd Bergmann
Quoted 7 lines · Ley Foon Tan
arch/nios2/kernel/time.c new file +7
-0+static inline unsigned long read_timersnapshot (void ) +{ +unsigned long count; + +outw (0 , timer_membase +ALTERA_TIMER_SNAPL_REG ); + count = + inw(timer_membase + ALTERA_TIMER_SNAPH_REG) << 16 |arch/nios2/kernel/time.c line 58
Quoted 10 lines
arch/nios2/kernel/time.c new file +10
-0+inw (timer_membase +ALTERA_TIMER_SNAPL_REG ); + +return count; +} + +static inline void write_timerperiod (unsigned long period) +{ +outw (period, timer_membase +ALTERA_TIMER_PERIODL_REG ); +outw (period >>16 , timer_membase +ALTERA_TIMER_PERIODH_REG ); +}It's wrong to use 'outw' if this device is not on an PC-style ISA bus, which I assume it is not. Since
timer_membaseis an__iomempointer, I'm sure you want to usewritew()instead.
Quoted 1 line
Arnd
Sure, will change all outw() to writew() and inw() to readw().
Ley Foon
Re: [PATCH 19/28] nios2: Device tree support
In reply to Arnd BergmannQuoted 13 lines · Arnd Bergmann
arch/nios2/boot/dts/3c120_devboard.dts line 24
Quoted 7 lines · Ley Foon Tan
arch/nios2/boot/dts/3c120_devboard.dts +5
-0+/dts-v1/; + +/ { + model = "ALTR,qsys_ghrd_3c120"; + compatible = "ALTR,qsys_ghrd_3c120";You have a mix of "ALTR" and "altr" prefixes. The general recommendation is to use lower-case letters, which is also what is used on ARM socfpga, and what is documented in
Documentation/devicetree/bindings/vendor-prefixes.txtfor Altera.
Yes, the vendor prefix should be changed to lower case. FYI, this dts file is generated by our dts generator tool called sopc2dts. Our tool already aware of this requirement, but haven't support this yet. I can edit this file manually to change 'ALTR' to 'altr', but I will update nios2 code to match for both "ALTR" and "altr" for backward compatibility. "ALTR" will be deprecated later. Are you okay with this?
Quoted 13 lines
arch/nios2/boot/dts/3c120_devboard.dts line 74
Quoted 12 lines
arch/nios2/boot/dts/3c120_devboard.dts +11
-0+ sopc@0 { + device_type = "soc"; + ranges; + #address-cells = < 1 >; + #size-cells = < 1 >; + compatible = "ALTR,avalon", "simple-bus"; + bus-frequency = < 125000000 >; + + pb_cpu_to_io: bridge@0x8000000 { + compatible = "simple-bus"; + reg = < 0x08000000 0x00800000 >;
Quoted 3 lines
Are these all synthesized devices, or is there also some hardwired logic? It often makes sense to split out the reusable parts into a separate .dtsi file that gets included by every implementation.
All these are synthesized devices and the system hierarchy is also not fixed and it is depends on user hardware design. It is highly configurable.
So, we can't have a common .dtsi file.
Quoted 15 lines
Quoted 4 lines
arch/nios2/boot/dts/3c120_devboard.dts +3
-0+ #address-cells = < 1 >; + #size-cells = < 1 >; + ranges = < 0x00400000 0x08400000 0x00000020arch/nios2/boot/dts/3c120_devboard.dts line 87
Quoted 10 lines
arch/nios2/boot/dts/3c120_devboard.dts +10
-0+ 0x00004D40 0x08004D40 0x00000008 + 0x00004D50 0x08004D50 0x00000008 + 0x00004000 0x08004000 0x00000400 + 0x00004400 0x08004400 0x00000040 + 0x00004800 0x08004800 0x00000040 + 0x00002000 0x08002000 0x00002000 + 0x00004C80 0x08004C80 0x00000020 + 0x00004CC0 0x08004CC0 0x00000010 + 0x00004CE0 0x08004CE0 0x00000010 + 0x00004D00 0x08004D00 0x00000010 >;
Quoted 5 lines
A few style comments:
- no whitespace in the after '<' or before '>
- put each entry into its own '<...>' group.
- lower-case characters for hex digits
Okay, I will change this and I will feedback this to our dts generator tool team to support these format in future.
Quoted 3 lines
- The ranges should reflect what the bus actually translates, which is typically not individual bytes but rather whole address ranges.
The ranges here reflect the address range translate by each device and user can assign any base address they desired in our FPGA. The address ranges might not in continuous regions as well. So, we will keep this translation way.
Quoted 6 lines
- sort numerically.
The above could look like
ranges = <0x00000000 0x08000000 0x00010000>, <0x00400000 0x08400000 0x00001000>;
Okay, I will sort this.
Quoted 16 lines
Quoted 4 lines
arch/nios2/boot/dts/3c120_devboard.dts +3
-0+ timer_1ms: timer@0x400000 { + compatible = "ALTR,timer-1.0"; +arch/nios2/boot/dts/3c120_devboard.dts line 112
Quoted 10 lines
arch/nios2/boot/dts/3c120_devboard.dts +9
-0+ sysid: sysid@0x4d40 { + compatible = "ALTR,sysid-1.0"; + reg = < 0x00004D40 0x00000008 >; + jtag_uart: serial@0x4d50 { + compatible = "ALTR,juart-1.0"; + reg = < 0x00004D50 0x00000008 >; + + tse_mac: ethernet@0x4000 { + compatible = "ALTR,tse-1.0";
Quoted 2 lines
Does each one of these have a binding document in
Documentation/devicetree/bindings?
jtag_uart and tse drivers are upstreamed. They already have their own bindings doc:Documentation/devicetree/bindings/serial/altera_jtaguart.txt Documentation/devicetree/bindings/net/altera_tse.txt
I will add the binding doc for timer, but sysid driver is not in mainline kernel yet. I will remove sysid entry from this file.
Quoted 5 lines
I've looked only at the tse binding, which you seem to be violating in a few places:
- compatible string is "ALTR,tse-1.0", not "altr,tse-1.0"
I will change to "altr,tse-1.0".
Quoted 8 lines
arch/nios2/boot/dts/3c120_devboard.dts line 117
Quoted 6 lines
arch/nios2/boot/dts/3c120_devboard.dts +5
-0+ reg = < 0x00004000 0x00000400 + 0x00004400 0x00000040 + 0x00004800 0x00000040 + 0x00002000 0x00002000 >; + reg-names = "control_port", "rx_csr", "tx_csr", "s1";- wrong order, missing "
tx_desc" and "rx_desc" entries
FYI, TSE driver supports both SGDMA and MSGDMA soft IP and "tx_desc" and "rx_desc" entries are for MSGDMA (see below). But this 3c120 hardware design is using TSE + SGDMA. So, the expect entries are "control_port", "rx_csr", "tx_csr", "s1".
I can sort the entries order by their addresses.
Excerpt from Documentation/devicetree/bindings/net/altera_tse.txt
- reg-names: Should contain the reg names "control_port": MAC configuration space region
"tx_csr": xDMA Tx dispatcher control and status space region "tx_desc": MSGDMA Tx dispatcher descriptor space region "rx_csr" : xDMA Rx dispatcher control and status space region "rx_desc": MSGDMA Rx dispatcher descriptor space region "rx_resp": MSGDMA Rx dispatcher response space region "s1": SGDMA descriptor memory
Quoted 6 lines
arch/nios2/boot/dts/3c120_devboard.dts line 123
Quoted 4 lines
arch/nios2/boot/dts/3c120_devboard.dts +3
-0+ rx-fifo-depth = < 8192 >; + tx-fifo-depth = < 8192 >; + address-bits = < 48 >;address-bits is not documented
Will remove this.
Quoted 7 lines
arch/nios2/boot/dts/3c120_devboard.dts line 127
Quoted 5 lines
arch/nios2/boot/dts/3c120_devboard.dts +4
-0+ max-frame-size = < 1518 >; + local-mac-address = [ 02 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + ALTR,mii-id = < 0 >;ALTR,mii-id is not documented, and required "phy-addr" is missing.
Will remove ALTR,mii-id. "phy-addr" is not required if we provide "phy-handle".
Excerpt from Documentation/devicetree/bindings/net/altera_tse.txt:
- phy-addr: See ethernet.txt in the same directory. A configuration should include phy-handle or phy-addr.
Quoted 13 lines
arch/nios2/boot/linked_dtb.S line 19
Quoted 10 lines
arch/nios2/boot/linked_dtb.S new file +3
-0+ */ +.section .dtb.init.rodata,"a" +.incbin "arch/nios2/boot/system.dtb"Linking in the dtb file is really against the point of device trees. You should require boot loaders to pass the dtb seperately.
We do support pass the dtb from boot loaders. This is optional feature that allow user to linking in dtb into kernel image if CONFIG_DTB_SOURCE_BOOL is enabled. This is very useful for develpment stage/debugging stage, where we can download vmlinux image directly into SDRAM and boot without boot loader.
Noticed that other architectures have linking in dtd file as well, eg:
c6x and microblaze.
Quoted 8 lines
arch/nios2/boot/linked_dtb.S
Quoted 4 lines
arch/nios2/boot/linked_dtb.S new file +3
-0+ soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", NIOS2_ID_DEFAULT); + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", + NIOS2_REVISION_DEFAULT);These are hardcoded constants. If there is no way to identify the hardware from looking at the registers, better don't fill these at all.
Okay, I will leave them empty.
Quoted 8 lines
arch/nios2/boot/linked_dtb.S
Quoted 3 lines
arch/nios2/boot/linked_dtb.S new file +2
-0+ soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR_OR_NULL(soc_dev)) {Never use
IS_ERR_OR_NULL().If an interface can return an error code, you should rely on never seeing NULL, or treating it as a valid pointer.
Okay, will change it to IS_ERR().
Quoted 10 lines
arch/nios2/boot/linked_dtb.S
Quoted 8 lines
arch/nios2/boot/linked_dtb.S new file +7
-0+static int __init nios2_device_probe(void) +{ + nios2_soc_device_init(); + + of_platform_bus_probe(NULL, altera_of_bus_ids, NULL); + return 0; +}This function can get merged into
nios2_soc_device_init.
Okay, will merge nios2_device_probe() into nios2_soc_device_init().
Thanks.
Regards
Ley Foon
Re: [PATCH 23/28] nios2: Nios2 registers
In reply to Tobias KlauserHi Tobias
Quoted 14 lines · Tobias Klauser
arch/nios2/include/asm/registers.h line 56
Quoted 9 lines · Ley Foon Tan
arch/nios2/include/asm/registers.h new file +9
-0+ +/* estatus register bits */ +#define ESTATUS_EPIE (1 << 0)/* processor interrupt enable */ +#define ESTATUS_EU (1 << 1)/* user mode */ +#define ESTATUS_EH (1 << 2)/* Exception mode */ + +/* tlbmisc register bits */ +#define TLBMISC_PID_SHIFT 4 +#define TLBMISC_PID_MASK ((1UL << cpuinfo.tlb_pid_num_bits) - 1)You should probably #include <
asm/cpuinfo.h> here since struct cpuinfo is used in the definition.
Okay, but I think we should add #ifndef __ASSEMBLY__ at #include <asm/cpuinfo.h> and at line #define TLBMISC_PID_MASK. Assembly source file might include this file as well.
Quoted 12 lines
Quoted 12 lines
arch/nios2/include/asm/registers.h new file +9
-0+#define TLBMISC_WAY_MASK 0xf +#define TLBMISC_WAY_SHIFT 20 + +#define TLBMISC_PID (TLBMISC_PID_MASK << TLBMISC_PID_SHIFT)/* TLB PID */ +#define TLBMISC_WE (1 << 18)/* TLB write enable */ +#define TLBMISC_RD (1 << 19)/* TLB read */ +#define TLBMISC_WAY (TLBMISC_WAY_MASK << TLBMISC_WAY_SHIFT)/* TLB way */ + +#endif /* _ASM_NIOS2_REGISTERS_H */
Re: [PATCH 04/28] nios2: Exception handling
In reply to Ley Foon TanHi Ley,
Quoted 15 lines · Ley Foon Tan
Quoted 13 lines · Arnd Bergmann
arch/nios2/kernel/misaligned.c line 274
Quoted 8 lines · Ley Foon Tan
arch/nios2/kernel/misaligned.c new file +8
-0+static const struct file_operations misalign_fops = { + .open = proc_misaligned_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = proc_misaligned_write, +}; +#endif /* CONFIG_PROC_FS */ We really shouldn't be doing new architecture specific procfs files any more. I suggest you drop this one for now, and add back the functionality using perf or ftrace at a later point.
Quoted 1 line
Okay, will remove this.
MIPS and powerpc handle this through debugfs, cfr. arch/mips/kernel/unaligned.c and arch/powerpc/kernel/traps.c.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 06/28] nios2: Memory management
In reply to Sam RavnborgHi Sam,
Quoted 4 lines · Sam Ravnborg
#define
PAGE_SIZE(_AC(1, UL)<<PAGE_SHIFT)
#definePAGE_MASK(~(PAGE_SIZE-1))
_AC(1, UL)expands to 1 for assembler and 1UL for C code.
Ideally, PAGE_SIZE should be size_t, not unsigned long, avoiding issues like https://lkml.org/lkml/2014/4/13/78. But currently it's unsigned long everywhere, so nios2 should be consistent.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerRe: [PATCH 19/28] nios2: Device tree support
In reply to Ley Foon TanQuoted 14 lines · On Wednesday 23 April 2014 14:52:47 Ley Foon Tan wrote:
Quoted 13 lines · Arnd Bergmann
arch/nios2/boot/dts/3c120_devboard.dts line 24
Quoted 7 lines · Ley Foon Tan
arch/nios2/boot/dts/3c120_devboard.dts +5
-0+/dts-v1/; + +/ { + model = "ALTR,qsys_ghrd_3c120"; + compatible = "ALTR,qsys_ghrd_3c120";You have a mix of "ALTR" and "altr" prefixes. The general recommendation is to use lower-case letters, which is also what is used on ARM socfpga, and what is documented in
Documentation/devicetree/bindings/vendor-prefixes.txtfor Altera.
Quoted 7 lines
Yes, the vendor prefix should be changed to lower case. FYI, this dts file is generated by our dts generator tool called sopc2dts. Our tool already aware of this requirement, but haven't support this yet. I can edit this file manually to change 'ALTR' to 'altr', but I will update nios2 code to match for both "ALTR" and "altr" for backward compatibility. "ALTR" will be deprecated later. Are you okay with this?
You seem to have a large number of "ALTR" strings at the moment. I don't think it would be good to allow matching both variants everywhere, that would be a lot of extra code.
If it's only about the root compatible property, I have no objections, but I don't know if it will help you when all the other strings don't match.
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
arch/nios2/boot/dts/3c120_devboard.dts +11
-0+ sopc@0 { + device_type = "soc"; + ranges; + #address-cells = < 1 >; + #size-cells = < 1 >; + compatible = "ALTR,avalon", "simple-bus"; + bus-frequency = < 125000000 >; + + pb_cpu_to_io: bridge@0x8000000 { + compatible = "simple-bus"; + reg = < 0x08000000 0x00800000 >;
Quoted 7 lines
Quoted 3 lines
Are these all synthesized devices, or is there also some hardwired logic? It often makes sense to split out the reusable parts into a separate .dtsi file that gets included by every implementation.
All these are synthesized devices and the system hierarchy is also not fixed and it is depends on user hardware design. It is highly configurable.
So, we can't have a common .dtsi file.
Ok, I see.
Quoted 15 lines
Quoted 14 lines
Quoted 13 lines
arch/nios2/boot/dts/3c120_devboard.dts +13
-0+ #address-cells = < 1 >; + #size-cells = < 1 >; + ranges = < 0x00400000 0x08400000 0x00000020 + 0x00004D40 0x08004D40 0x00000008 + 0x00004D50 0x08004D50 0x00000008 + 0x00004000 0x08004000 0x00000400 + 0x00004400 0x08004400 0x00000040 + 0x00004800 0x08004800 0x00000040 + 0x00002000 0x08002000 0x00002000 + 0x00004C80 0x08004C80 0x00000020 + 0x00004CC0 0x08004CC0 0x00000010 + 0x00004CE0 0x08004CE0 0x00000010 + 0x00004D00 0x08004D00 0x00000010 >;
Quoted 7 lines
Quoted 3 lines
- The ranges should reflect what the bus actually translates, which is typically not individual bytes but rather whole address ranges.
The ranges here reflect the address range translate by each device and user can assign any base address they desired in our FPGA. The address ranges might not in continuous regions as well. So, we will keep this translation way.
If you can support any address, why not just have an empty 'ranges' property?
Quoted 17 lines
Quoted 15 lines
arch/nios2/boot/dts/3c120_devboard.dts line 112
Quoted 13 lines
arch/nios2/boot/dts/3c120_devboard.dts +12
-0+ timer_1ms: timer@0x400000 { + compatible = "ALTR,timer-1.0"; + + sysid: sysid@0x4d40 { + compatible = "ALTR,sysid-1.0"; + reg = < 0x00004D40 0x00000008 >; + jtag_uart: serial@0x4d50 { + compatible = "ALTR,juart-1.0"; + reg = < 0x00004D50 0x00000008 >; + + tse_mac: ethernet@0x4000 { + compatible = "ALTR,tse-1.0";Quoted 2 lines
Does each one of these have a binding document in
Documentation/devicetree/bindings?
Quoted 7 lines
jtag_uartand tse drivers are upstreamed. They already have their own bindings doc:Documentation/devicetree/bindings/serial/altera_jtaguart.txtDocumentation/devicetree/bindings/net/altera_tse.txtI will add the binding doc for timer, but sysid driver is not in mainline kernel yet. I will remove sysid entry from this file.
Ok. BTW, could the sysid be used for the soc device strings, or is that something else?
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
arch/nios2/boot/dts/3c120_devboard.dts +5
-0+ reg = < 0x00004000 0x00000400 + 0x00004400 0x00000040 + 0x00004800 0x00000040 + 0x00002000 0x00002000 >; + reg-names = "control_port", "rx_csr", "tx_csr", "s1";
Quoted 6 lines
Quoted 1 line
- wrong order, missing "
tx_desc" and "rx_desc" entriesFYI, TSE driver supports both SGDMA and MSGDMA soft IP and "
tx_desc" and "rx_desc" entries are for MSGDMA (see below). But this 3c120 hardware design is using TSE + SGDMA. So, the expect entries are "control_port", "rx_csr", "tx_csr", "s1".
I can sort the entries order by their addresses.
You can't reorder the registers, as they can be accessed by index in some OS, the strings are just annotations really.
Quoted 9 lines
Excerpt from
Documentation/devicetree/bindings/net/altera_tse.txt
- reg-names: Should contain the reg names "control_port": MAC configuration space region"tx_csr": xDMA Tx dispatcher control and status space region "tx_desc": MSGDMA Tx dispatcher descriptor space region "rx_csr" : xDMA Rx dispatcher control and status space region "rx_desc": MSGDMA Rx dispatcher descriptor space region "rx_resp": MSGDMA Rx dispatcher response space region "s1": SGDMA descriptor memory
The important part is
- reg: Address and length of the register set for the device. It contains the information of registers in the same order as described by reg-names.
You can either provide dummy entries for tx_desc, rx_desc and rx_resp, or change the binding to reflect the current usage, and provide two different lists depending on the compatible string.
Quoted 11 lines
Quoted 6 lines
arch/nios2/boot/dts/3c120_devboard.dts line 127
Quoted 4 lines
arch/nios2/boot/dts/3c120_devboard.dts +4
-0+ max-frame-size = < 1518 >; + local-mac-address = [ 02 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + ALTR,mii-id = < 0 >;ALTR,mii-id is not documented, and required "phy-addr" is missing.
Will remove ALTR,mii-id. "phy-addr" is not required if we provide "phy-handle".
Excerpt from
Documentation/devicetree/bindings/net/altera_tse.txt:
- phy-addr: See ethernet.txt in the same directory. A configuration should include phy-handle or phy-addr.
Ok.
Quoted 11 lines
Quoted 11 lines
arch/nios2/boot/linked_dtb.S line 19
Quoted 8 lines
arch/nios2/boot/linked_dtb.S new file +3
-0+ */ +.section .dtb.init.rodata,"a" +.incbin "arch/nios2/boot/system.dtb"Linking in the dtb file is really against the point of device trees. You should require boot loaders to pass the dtb seperately.
Quoted 7 lines
We do support pass the dtb from boot loaders. This is optional feature that allow user to linking in dtb into kernel image if
CONFIG_DTB_SOURCE_BOOLis enabled. This is very useful for develpment stage/debugging stage, where we can download vmlinux image directly into SDRAM and boot without boot loader.
Noticed that other architectures have linking in dtd file as well, eg:
c6x and microblaze.
Ok.
Arnd
Re: [PATCH 28/28] Documentation: Add documentation for Nios2 architecture
In reply to Tobias KlauserQuoted 6 lines · Tobias Klauser
Documentation/nios2/README line 17
Quoted 4 lines
Documentation/nios2/README new file +4
-0+What is Nios II? +================ +Nios II is a 32-bit embedded-processor architecture designed specifically for the +Altera family of FPGAs. In order to support Linux system, Nios II needs to configureMinor nit: 'In order to support Linux, Nios II needs to be configured...'
Noted.
Quoted 3 lines
Quoted 2 lines
+with MMU and hardware multiplier enabled.
Re: [PATCH 23/28] nios2: Nios2 registers
In reply to Ley Foon TanQuoted 18 lines · Ley Foon Tan
Hi Tobias
Quoted 14 lines · Tobias Klauser
arch/nios2/include/asm/registers.h line 56
Quoted 9 lines · Ley Foon Tan
arch/nios2/include/asm/registers.h new file +9
-0+ +/* estatus register bits */ +#define ESTATUS_EPIE (1 << 0)/* processor interrupt enable */ +#define ESTATUS_EU (1 << 1)/* user mode */ +#define ESTATUS_EH (1 << 2)/* Exception mode */ + +/* tlbmisc register bits */ +#define TLBMISC_PID_SHIFT 4 +#define TLBMISC_PID_MASK ((1UL << cpuinfo.tlb_pid_num_bits) - 1)You should probably #include <
asm/cpuinfo.h> here since struct cpuinfo is used in the definition.
Quoted 3 lines
Okay, but I think we should add #ifndef
__ASSEMBLY__at #include <asm/cpuinfo.h> and at line #defineTLBMISC_PID_MASK. Assembly source file might include this file as well.
Yes, makes sense.
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
arch/nios2/include/asm/registers.h new file +9
-0+#define TLBMISC_WAY_MASK 0xf +#define TLBMISC_WAY_SHIFT 20 + +#define TLBMISC_PID (TLBMISC_PID_MASK << TLBMISC_PID_SHIFT)/* TLB PID */ +#define TLBMISC_WE (1 << 18)/* TLB write enable */ +#define TLBMISC_RD (1 << 19)/* TLB read */ +#define TLBMISC_WAY (TLBMISC_WAY_MASK << TLBMISC_WAY_SHIFT)/* TLB way */ + +#endif /* _ASM_NIOS2_REGISTERS_H */
Re: [PATCH 19/28] nios2: Device tree support
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
Quoted 8 lines
Quoted 1 line
for Altera.
Yes, the vendor prefix should be changed to lower case. FYI, this dts file is generated by our dts generator tool called sopc2dts. Our tool already aware of this requirement, but haven't support this yet. I can edit this file manually to change 'ALTR' to 'altr', but I will update nios2 code to match for both "ALTR" and "altr" for backward compatibility. "ALTR" will be deprecated later. Are you okay with this?
Quoted 7 lines
You seem to have a large number of "ALTR" strings at the moment. I don't think it would be good to allow matching both variants everywhere, that would be a lot of extra code.
If it's only about the root compatible property, I have no objections, but I don't know if it will help you when all the other strings don't match.
ALTR is used on compatible and dts parameters, but these all are in arch/nios2. Drivers already can handle both ALTR and altr. I can write a helper function in arch/nios2 to match both ALTR and altr. I believe it shouldn't take a lot of extra code. What do you think?
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
arch/nios2/boot/dts/3c120_devboard.dts line 87
Quoted 11 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +11
-0+ ranges = < 0x00400000 0x08400000 0x00000020 + 0x00004D40 0x08004D40 0x00000008 + 0x00004D50 0x08004D50 0x00000008 + 0x00004000 0x08004000 0x00000400 + 0x00004400 0x08004400 0x00000040 + 0x00004800 0x08004800 0x00000040 + 0x00002000 0x08002000 0x00002000 + 0x00004C80 0x08004C80 0x00000020 + 0x00004CC0 0x08004CC0 0x00000010 + 0x00004CE0 0x08004CE0 0x00000010 + 0x00004D00 0x08004D00 0x00000010 >;- The ranges should reflect what the bus actually translates, which is typically not individual bytes but rather whole address ranges.
Quoted 7 lines
Quoted 4 lines
The ranges here reflect the address range translate by each device and user can assign any base address they desired in our FPGA. The address ranges might not in continuous regions as well. So, we will keep this translation way.
If you can support any address, why not just have an empty 'ranges' property?
We prefer not to add in any invalid address ranges here.
Quoted 6 lines
Quoted 3 lines
I will add the binding doc for timer, but sysid driver is not in mainline kernel yet. I will remove sysid entry from this file.
Ok. BTW, could the sysid be used for the soc device strings, or is that something else?
Initially, we have thought to use sysid here. But, sysid can be used by our ARM SoC device. For some reasons, we decided to make sysid as separate module and not tight to CPU.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/nios2/boot/dts/3c120_devboard.dts line 117
Quoted 6 lines
arch/nios2/boot/dts/3c120_devboard.dts new file +5
-0+ reg = < 0x00004000 0x00000400 + 0x00004400 0x00000040 + 0x00004800 0x00000040 + 0x00002000 0x00002000 >; + reg-names = "control_port", "rx_csr", "tx_csr", "s1";- wrong order, missing "
tx_desc" and "rx_desc" entries
Quoted 8 lines
Quoted 5 lines
FYI, TSE driver supports both SGDMA and MSGDMA soft IP and "
tx_desc" and "rx_desc" entries are for MSGDMA (see below). But this 3c120 hardware design is using TSE + SGDMA. So, the expect entries are "control_port", "rx_csr", "tx_csr", "s1".
I can sort the entries order by their addresses.You can't reorder the registers, as they can be accessed by index in some OS, the strings are just annotations really.
Okay, will keep the order.
Currently, the reg names and ordering are based on hardware information and dts generator tool generates this entry based on this hardware information. These shouldn't change unless hardware is changed.
Quoted 11 lines
Quoted 10 lines
Excerpt from
Documentation/devicetree/bindings/net/altera_tse.txt
- reg-names: Should contain the reg names "control_port": MAC configuration space region"tx_csr": xDMA Tx dispatcher control and status space region "tx_desc": MSGDMA Tx dispatcher descriptor space region "rx_csr" : xDMA Rx dispatcher control and status space region "rx_desc": MSGDMA Rx dispatcher descriptor space region "rx_resp": MSGDMA Rx dispatcher response space region "s1": SGDMA descriptor memory
Quoted 8 lines
The important part is
- reg: Address and length of the register set for the device. It contains the information of registers in the same order as described by reg-names.
You can either provide dummy entries for
tx_desc,rx_descandrx_resp, or change the binding to reflect the current usage, and provide two different lists depending on the compatible string.
We can update the binding doc to have separate lists depending on the compatible string.
Added our TSE driver maintainer in CC list.
Regards
Ley Foon
Re: [PATCH 05/28] nios2: Traps exception handling
In reply to Ezequiel GarciaQuoted 18 lines · Ezequiel Garcia
Hello Ley Foon,
arch/nios2/kernel/traps.c line 134
Quoted 12 lines · Ley Foon Tan
arch/nios2/kernel/traps.c new file +12
-0+ +#ifndef CONFIG_ALIGNMENT_TRAP +/* Alignment exception handler */ +asmlinkage void handle_unaligned_c(struct pt_regs *fp, int cause) +{ +unsigned long addr =RDCTL (CTL_BADADDR ); + + cause >>=2 ; + fp->ea -=4 ; + +if (fixup_exception (fp)) +return ;This will throw an undeclared error if you build with
CONFIG_ALIGNMENT_TRAP=n.
Quoted 1 line
You need to add the
uaccess.hheader, or implement some similar fix.
Okay, I will try with CONFIG_ALIGNMENT_TRAP=n and fix it.
Arnd Bergmann
maintainerRe: [PATCH 04/28] nios2: Exception handling
In reply to Geert UytterhoevenQuoted 16 lines · Geert Uytterhoeven
Quoted 15 lines · Ley Foon Tan
Quoted 13 lines · Arnd Bergmann
arch/nios2/kernel/misaligned.c line 274
Quoted 8 lines · Ley Foon Tan
arch/nios2/kernel/misaligned.c new file +8
-0+static const struct file_operations misalign_fops = { + .open = proc_misaligned_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = proc_misaligned_write, +}; +#endif /* CONFIG_PROC_FS */ We really shouldn't be doing new architecture specific procfs files any more. I suggest you drop this one for now, and add back the functionality using perf or ftrace at a later point.
Quoted 4 lines
Quoted 1 line
Okay, will remove this.
MIPS and powerpc handle this through debugfs, cfr.
arch/mips/kernel/unaligned.candarch/powerpc/kernel/traps.c.
Ah, right, that would work too. Being able to use perf from user space sounds more flexible though. It's certainly something that can be decided later.
Arnd
Quoted 4 lines · Ley Foon Tan
Quoted 3 lines · Arnd Bergmann
Quoted 3 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 2 lines
Quoted 2 lines
Hi Arnd and Peter Anvin,
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Other than 64-bit
time_t,clock_tandsuseconds_t, can you confirm that we don't need to have 64 bitoff_t? See detail in link below. I can submit the patches for 64-bit time changes (include/asm-generic/posix_types.hand other archs) if everyone is agreed on this.Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Thanks,
Chung-Lin
Quoted 15 lines · Chung-Lin Tang
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 7 lines
Quoted 7 lines
Hi Arnd and Peter Anvin,
Other than 64-bit
time_t,clock_tandsuseconds_t, can you confirm that we don't need to have 64 bitoff_t? See detail in link below. I can submit the patches for 64-bit time changes (include/asm-generic/posix_types.hand other archs) if everyone is agreed on this.
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit time_t, clock_t, and suseconds_t. And we agreed to a 64bit offset_t too.
On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Thanks,
Andrew
Quoted 4 lines
Thanks,
Chung-Lin
I think Linuxs said we should just fix POSIX on that front.
Quoted 43 lines · Andrew
Quoted 3 lines
On Apr 23, 2014, at 10:59 AM, "Chung-Lin Tang"
Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines · Ley Foon Tan
On Tue, Apr 22, 2014 at 6:56 PM, Arnd Bergmann <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 3 lines
Quoted 3 lines
Hi Arnd and Peter Anvin,
Other than 64-bit
time_t,clock_tandsuseconds_t, can youconfirm
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
that we don't need to have 64 bit
off_t? See detail in linkbelow.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I can submit the patches for 64-bit time changes (
include/asm-generic/posix_types.hand other archs) if everyoneis
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
agreed on this.
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status
of
Quoted 1 line
this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Thanks,
AndrewQuoted 4 lines
Thanks,
Chung-Lin
Signature · 1 line
Sent from my mobile phone. Please pardon brevity and lack of formatting.
Re: [PATCH 07/28] nios2: I/O Mapping
In reply to Arnd BergmannQuoted 8 lines · Arnd Bergmann
arch/nios2/include/asm/io.h line 15
Quoted 4 lines · Ley Foon Tan
arch/nios2/include/asm/io.h new file +4
-0+ +#include <asm/pgtable-bits.h> + +#define IO_SPACE_LIMIT 0xffffffffPlease use
0xffffhere, this should work for almost any PCI bus.
Ah, CONFIG_PCI is not enable in nios2. So, I think IO_SPACE_LIMIT should set to 0.
Quoted 5 lines
Quoted 5 lines
arch/nios2/include/asm/io.h new file +5
-0+ +/* Use "Duff's Device" to unroll the loops. */ +#define __IO_OUT_LOOP (a, b, l) \ + do { \ + if (l > 0) { \
Quoted 8 lines
arch/nios2/include/asm/io.h line 31
Quoted 5 lines
arch/nios2/include/asm/io.h new file +5
-0+int _n = (l +7 ) /8 ; \ +switch (l %8 ) { \ +case 0 : \ + do { \ + *a = *b++; \I would recommend just doing all of this in out-of-line implementations rather than macros and inline functions.
Okay. Will move the macros to out-of-line function.
Quoted 18 lines
arch/nios2/include/asm/io.h line 168
Quoted 12 lines
arch/nios2/include/asm/io.h new file +11
-0+ +/* +* make the short names macros so specific devices +* can override them as required +*/ +#define inb (addr) readb(addr) +#define inw (addr) readw(addr) +#define inl (addr) readl(addr) +#define outb (x, addr) ((void) writeb(x, addr)) +#define outw (x, addr) ((void) writew(x, addr)) +#define outl (x, addr) ((void) writel(x, addr))This makes no sense: the legacy PC I/O accessors take a completely different argument type: I would recommend to make both inline functions so you can ensure that
readl()gets passed an__iomempointer, whileinl()gets an integer number.
Quoted 2 lines
Please see the asm-generic version for an example. You should also define a non-NULL
PCI_IOBASEto which the PCI I/O space gets mapped.
I think these macros can be removed if PCI is not enabled in Nios2.
Quoted 6 lines
arch/nios2/include/asm/io.h line 214
Quoted 3 lines
arch/nios2/include/asm/io.h new file +2
-0+#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virtPlease drop these, and the
CONFIG_VIRT_TO_BUSKconfigoption, and fix all drivers that rely on it.
Okay. Will remove these.
Quoted 8 lines
arch/nios2/include/asm/io.h line 217
Quoted 3 lines
arch/nios2/include/asm/io.h new file +2
-0+#define ioport_map (port, nr) ioremap(port, nr) +#define ioport_unmap (port) iounmap(port)Use this one instead:
#ifdef
CONFIG_PCI
static inline void__iomem*ioport_map(unsigned long port, unsigned int nr)
Quoted 8 lines
{ return PCI_IOBASE + port; }static inline void
__iomem*ioport_unmap(void__iomem*) {
}
#endif
These also can be removed.
Quoted 11 lines
arch/nios2/include/asm/io.h line 225
Quoted 8 lines
arch/nios2/include/asm/io.h new file +7
-0+/* Macros used for smc91x.c driver */ +#define readsb (p, d, l) insb(p, d, l) +#define readsw (p, d, l) insw(p, d, l) +#define readsl (p, d, l) insl(p, d, l) +#define writesb (p, d, l) outsb(p, d, l) +#define writesw (p, d, l) outsw(p, d, l) +#define writesl (p, d, l) outsl(p, d, l)These should of course not fall back to the PCI I/O space functions. You can do it the other way round.
Okay, these will change to something like:
#define readsb(p, d, l) io_insb(p, d, l)
#define readsw(p, d, l) io_insw(p, d, l)
(etc)
Regards
Ley Foon
Re: [PATCH 04/28] nios2: Exception handling
In reply to Arnd BergmannQuoted 4 lines · Arnd Bergmann
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
We really shouldn't be doing new architecture specific procfs files any more. I suggest you drop this one for now, and add back the functionality using perf or ftrace at a later point.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Okay, will remove this.
MIPS and powerpc handle this through debugfs, cfr.
arch/mips/kernel/unaligned.candarch/powerpc/kernel/traps.c.Ah, right, that would work too. Being able to use perf from user space sounds more flexible though. It's certainly something that can be decided later.
Yes, we can add this back through debugfs or perf in later.
Regards
Ley Foon
Quoted 14 lines · Andrew
Quoted 14 lines
Quoted 14 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Hi Arnd and Peter Anvin,
Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Hmm, but that means for purely 32-bit architectures like nios2, which unlike x86_64 or arm64, never has a 64-bit mode, suseconds_t as a 64-bit type in the kernel is simply wasted.
Chung-Lin
Re: [PATCH 08/28] nios2: MMU Fault handling
In reply to Ezequiel GarciaQuoted 15 lines · Ezequiel Garcia
Hello Ley Foon,
arch/nios2/mm/fault.c line 153
Quoted 4 lines · Ley Foon Tan
arch/nios2/mm/fault.c new file +4
-0+ +bad_area_nosemaphore: +/* User mode accesses just cause a SIGSEGV */ +if (user_mode (regs)) {I found that it's useful to add some printing here, just as ARM does. I carry this patch on my kernel:
(quoted diff) +3
-0+ printk(KERN_INFO "%s: unhandled page fault (%d) at 0x%08lx, cause %ld\n", + current->comm, SIGSEGV, address, cause); + show_regs(regs);
Quoted 1 line
Do you think we could do something like it? Maybe with a compile time option?
Yes, this is useful debug message. I can add this. Prefer not to add new compile time option, I think this shouldn't happen frequently.
Quoted 5 lines
Quoted 5 lines
arch/nios2/mm/fault.c new file +4
-0+_exception (SIGSEGV , regs, code, address); +return ; + } +
Re: [PATCH 08/28] nios2: MMU Fault handling
In reply to Ezequiel GarciaQuoted 13 lines · Ezequiel Garcia
arch/nios2/mm/fault.c line 153
Quoted 4 lines · Ley Foon Tan
arch/nios2/mm/fault.c new file +4
-0+ +bad_area_nosemaphore: +/* User mode accesses just cause a SIGSEGV */ +if (user_mode (regs)) {I found that it's useful to add some printing here, just as ARM does. I carry this patch on my kernel:
(quoted diff) +3
-0+ printk(KERN_INFO "%s: unhandled page fault (%d) at 0x%08lx, cause %ld\n", + current->comm, SIGSEGV, address, cause); + show_regs(regs);
Quoted 1 line
Do you think we could do something like it? Maybe with a compile time option?
Can this easily be triggered from userspace? If yes, please use pr_info_ratelimited().
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerRe: [PATCH 07/28] nios2: I/O Mapping
In reply to Ley Foon TanQuoted 11 lines · On Thursday 24 April 2014 14:02:47 Ley Foon Tan wrote:
Quoted 8 lines · Arnd Bergmann
arch/nios2/include/asm/io.h line 15
Quoted 4 lines · Ley Foon Tan
arch/nios2/include/asm/io.h new file +4
-0+ +#include <asm/pgtable-bits.h> + +#define IO_SPACE_LIMIT 0xffffffffPlease use
0xffffhere, this should work for almost any PCI bus.Ah,
CONFIG_PCIis not enable in nios2. So, I thinkIO_SPACE_LIMITshould set to 0.
Yes, possibly with a comment added regarding PCI.
Quoted 16 lines
Quoted 16 lines
arch/nios2/include/asm/io.h line 168
Quoted 10 lines
arch/nios2/include/asm/io.h new file +10
-0+/* +* make the short names macros so specific devices +* can override them as required +*/ +#define inb (addr) readb(addr) +#define inw (addr) readw(addr) +#define inl (addr) readl(addr) +#define outb (x, addr) ((void) writeb(x, addr)) +#define outw (x, addr) ((void) writew(x, addr)) +#define outl (x, addr) ((void) writel(x, addr))This makes no sense: the legacy PC I/O accessors take a completely different argument type: I would recommend to make both inline functions so you can ensure that
readl()gets passed an__iomempointer, whileinl()gets an integer number.
Quoted 3 lines
Quoted 2 lines
Please see the asm-generic version for an example. You should also define a non-NULL
PCI_IOBASEto which the PCI I/O space gets mapped.I think these macros can be removed if PCI is not enabled in Nios2.
We have a bunch of ISA device drivers that use these interfaces but are not built conditionally through a Kconfig dependency. If you want 'allyesconfig' to build successfully, you have to provide some dummy implementation.
Quoted 11 lines
Quoted 11 lines
arch/nios2/include/asm/io.h line 217
Quoted 2 lines
arch/nios2/include/asm/io.h new file +2
-0+#define ioport_map (port, nr) ioremap(port, nr) +#define ioport_unmap (port) iounmap(port)Use this one instead:
#ifdef
CONFIG_PCI
static inline void__iomem*ioport_map(unsigned long port, unsigned int nr){ return PCI_IOBASE + port; }
Quoted 5 lines
Quoted 4 lines
static inline void
__iomem*ioport_unmap(void__iomem*) {
}
#endifThese also can be removed.
For this, there is a Kconfig symbol. If you don't provide ioport_map, you should set CONFIG_NO_IOPORT_MAP. Uwe Kleine-König has recently started some work in this area. Ideally we would also have a CONFIG_HAS_IOPORT option that is only set by architectures that actually implement inb/outb. Getting there still needs work, but any help is appreciated.
Arnd
Quoted 22 lines · Chung-Lin Tang
Quoted 21 lines · Andrew
Quoted 14 lines
Quoted 14 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Hi Arnd and Peter Anvin,
Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.
Quoted 7 lines
Quoted 1 line
On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.Chung-Lin
The more I think of this, the more I feel that suseconds_t should jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like a COMPAT_USE_32BIT_SUSECONDS case.
suseconds_t is for micro-seconds in struct timeval, 32-bit is more than enough.
Chung-Lin
Re: [PATCH 17/28] nios2: Signal handling support
In reply to Richard WeinbergerQuoted 11 lines · Richard Weinberger
arch/nios2/kernel/signal.c line 196
Quoted 9 lines
arch/nios2/kernel/signal.c new file +9
-0+ +/* Default to using normal stack. */ + usp = regs->sp; + +/* This is the X/Open sanctioned signal stack switching. */ +if ((ka->sa.sa_flags &SA_ONSTACK ) && (current->sas_ss_sp !=0 )) { +if (!on_sig_stack (usp)) + usp = current->sas_ss_sp + current->sas_ss_size; + }You can use
sigsp()here.
Okay.
Quoted 4 lines
Quoted 4 lines
arch/nios2/kernel/signal.c new file +4
-0+ +push_cache ((unsigned long ) &frame->retcode); + +/* Set up registers for signal handler */
Quoted 8 lines
arch/nios2/kernel/signal.c line 240
Quoted 6 lines
arch/nios2/kernel/signal.c new file +6
-0+ regs->sp = (unsigned long ) frame; + regs->r4 = (unsigned long ) (current_thread_info ()->exec_domain + &¤t_thread_info ()->exec_domain->signal_invmap + && sig <32 + ?current_thread_info ()->exec_domain->signal_invmap[sig] + : sig);Does nios2 really need signal translation and supports execution domains?
Nios2 have one default "default_exec_domain" only. So, we can change this to "regs->r4 = sig;".
BTW, most of the architectures have similar code.
Quoted 6 lines
arch/nios2/kernel/signal.c line 300
Quoted 6 lines
arch/nios2/kernel/signal.c new file +6
-0+ +/* +* Note that 'init' is a special process: it doesn't get signals it doesn't +* want to handle. Thus you cannot kill init even with a SIGKILL even by +* mistake. +*/
Will remove this.
Quoted 8 lines
arch/nios2/kernel/signal.c line 350
Quoted 5 lines
arch/nios2/kernel/signal.c new file +5
-0+ +asmlinkage void do_notify_resume(struct pt_regs *regs, sigset_t *oldset, +int in_syscall) +{ +pr_debug ("--> ENTERING %s\n" , __func__);Please remove such printk()s.
If you need to know which functions get called, use ftrace.
Okay, will remove this.
Regards
Ley Foon
Re: [PATCH 17/28] nios2: Signal handling support
Am 24.04.2014 12:01, schrieb Ley Foon Tan:
Quoted 13 lines
On Sun, Apr 20, 2014 at 3:29 AM, Richard Weinberger
Quoted 4 lines
Quoted 4 lines
arch/nios2/kernel/signal.c new file +4
-0+ +push_cache ((unsigned long ) &frame->retcode); + +/* Set up registers for signal handler */ Quoted 8 lines
arch/nios2/kernel/signal.c line 240
Quoted 6 lines
arch/nios2/kernel/signal.c new file +6
-0+ regs->sp = (unsigned long ) frame; + regs->r4 = (unsigned long ) (current_thread_info ()->exec_domain + &¤t_thread_info ()->exec_domain->signal_invmap + && sig <32 + ?current_thread_info ()->exec_domain->signal_invmap[sig] + : sig);Does nios2 really need signal translation and supports execution domains?
Quoted 2 lines
Nios2 have one default "
default_exec_domain" only. So, we can change this to "regs->r4= sig;".
Nice.
Quoted 1 line
BTW, most of the architectures have similar code.
Yep, because everyone is copy&pasting from each others without thinking. 8) There is already a cleanup going on: https://lkml.org/lkml/2014/3/2/198
Thanks,
//richard
Re: [PATCH 17/28] nios2: Signal handling support
In reply to Ley Foon TanQuoted 14 lines · Ley Foon Tan
Quoted 11 lines · Richard Weinberger
arch/nios2/kernel/signal.c line 196
Quoted 9 lines
arch/nios2/kernel/signal.c new file +9
-0+ +/* Default to using normal stack. */ + usp = regs->sp; + +/* This is the X/Open sanctioned signal stack switching. */ +if ((ka->sa.sa_flags &SA_ONSTACK ) && (current->sas_ss_sp !=0 )) { +if (!on_sig_stack (usp)) + usp = current->sas_ss_sp + current->sas_ss_size; + }You can use
sigsp()here.
Quoted 2 lines
Okay.
I just noticed that sigsp() have struct ksignal argument. We can use sigsp() for nios2 because it doesn't have struct ksignal.
unsigned long sigsp(unsigned long sp, struct ksignal *ksig);
Re: [PATCH 17/28] nios2: Signal handling support
Am 24.04.2014 12:13, schrieb Ley Foon Tan:
Quoted 15 lines · Ley Foon Tan
Quoted 14 lines
Quoted 11 lines · Richard Weinberger
arch/nios2/kernel/signal.c line 196
Quoted 9 lines
arch/nios2/kernel/signal.c new file +9
-0+ +/* Default to using normal stack. */ + usp = regs->sp; + +/* This is the X/Open sanctioned signal stack switching. */ +if ((ka->sa.sa_flags &SA_ONSTACK ) && (current->sas_ss_sp !=0 )) { +if (!on_sig_stack (usp)) + usp = current->sas_ss_sp + current->sas_ss_size; + }You can use
sigsp()here.
Quoted 6 lines
Quoted 2 lines
Okay.
I just noticed that
sigsp()have struct ksignal argument. We can usesigsp()for nios2 because it doesn't have struct ksignal.unsigned long
sigsp(unsigned long sp, struct ksignal *ksig);
Did you at look at the struct ksignal definition and the clean series I've pointed you to?
Thanks,
//richard
Re: [PATCH 17/28] nios2: Signal handling support
Quoted 10 lines · Richard Weinberger
Quoted 6 lines
Quoted 2 lines
Okay.
I just noticed that
sigsp()have struct ksignal argument. We can usesigsp()for nios2 because it doesn't have struct ksignal.unsigned long
sigsp(unsigned long sp, struct ksignal *ksig);Did you at look at the struct ksignal definition and the clean series I've pointed you to?
Not yet, this is the full set of patches? I only see partial..
https://lkml.org/lkml/2014/3/2/198
Re: [PATCH 17/28] nios2: Signal handling support
Am 24.04.2014 12:29, schrieb Ley Foon Tan:
Quoted 7 lines · Richard Weinberger
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Okay.
I just noticed that
sigsp()have struct ksignal argument. We can usesigsp()for nios2 because it doesn't have struct ksignal.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
unsigned long
sigsp(unsigned long sp, struct ksignal *ksig);Did you at look at the struct ksignal definition and the clean series I've pointed you to?
Not yet, this is the full set of patches? I only see partial..
https://lkml.org/lkml/2014/3/2/198
Maybe lkml.org misses a few but this does not matter. All you need to know is that using ksignal is easy. e.g. https://lkml.org/lkml/2014/3/2/162
Thanks,
//richard
Re: [PATCH 17/28] nios2: Signal handling support
Quoted 14 lines · Richard Weinberger
Am 24.04.2014 12:29, schrieb Ley Foon Tan:
Quoted 13 lines · Richard Weinberger
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
Okay.
I just noticed that
sigsp()have struct ksignal argument. We can usesigsp()for nios2 because it doesn't have struct ksignal.unsigned long
sigsp(unsigned long sp, struct ksignal *ksig);Did you at look at the struct ksignal definition and the clean series I've pointed you to?
Quoted 7 lines
Quoted 2 lines
Not yet, this is the full set of patches? I only see partial..
https://lkml.org/lkml/2014/3/2/198Maybe lkml.org misses a few but this does not matter. All you need to know is that using ksignal is easy. e.g. https://lkml.org/lkml/2014/3/2/162
Thanks. I am looking at your git tree
https://git.kernel.org/cgit/linux/kernel/git/rw/misc.git/log/?h=signal_v2
Are these patches already available in v3.15 rc?
I can update nios2 to use new implementation.
Regards
Ley Foon
Re: [PATCH 08/28] nios2: MMU Fault handling
In reply to Ley Foon TanQuoted 13 lines · Ley Foon Tan
Quoted 11 lines · Ezequiel Garcia
Hello Ley Foon,
arch/nios2/mm/fault.c line 153
Quoted 4 lines · Ley Foon Tan
arch/nios2/mm/fault.c new file +4
-0+ +bad_area_nosemaphore: +/* User mode accesses just cause a SIGSEGV */ +if (user_mode (regs)) {I found that it's useful to add some printing here, just as ARM does. I carry this patch on my kernel:
Quoted 8 lines
Quoted 5 lines
(quoted diff) +3
-0+ printk(KERN_INFO "%s: unhandled page fault (%d) at 0x%08lx, cause %ld\n", + current->comm, SIGSEGV, address, cause); + show_regs(regs);Do you think we could do something like it? Maybe with a compile time option?
Yes, this is useful debug message. I can add this. Prefer not to add new compile time option, I think this shouldn't happen frequently.
No, it shouldn't happen frequently. You can take a look at what ARM does. They use a DEBUG_USER compile-time option, much more complex than my silly proposal.
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Quoted 30 lines · Chung-Lin Tang
Quoted 29 lines · Chung-Lin Tang
Quoted 27 lines · Andrew
Quoted 14 lines
Quoted 14 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 7 lines
Quoted 7 lines
Hi Arnd and Peter Anvin,
Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Quoted 8 lines
Quoted 3 lines
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.The more I think of this, the more I feel that
suseconds_tshould jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like aCOMPAT_USE_32BIT_SUSECONDScase.
ILP32 mode should use LP64 syscalls as much as possible and that's the aim with arm64 as well (of course, we still have a few that wouldn't be possible and we route them via compat).
But here if time_t is 64-bit while susecconds_t is 32-bit, the compat code wouldn't help.
Signature · 1 line
Catalin
Re: [PATCH 07/28] nios2: I/O Mapping
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Thursday 24 April 2014 14:02:47 Ley Foon Tan wrote:
Quoted 3 lines
Quoted 1 line
+#define
IO_SPACE_LIMIT0xffffffffPlease use
0xffffhere, this should work for almost any PCI bus.Ah,
CONFIG_PCIis not enable in nios2. So, I thinkIO_SPACE_LIMITshould set to 0.Yes, possibly with a comment added regarding PCI.
Sure.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
arch/nios2/include/asm/io.h line 168
Quoted 11 lines
arch/nios2/include/asm/io.h new file +10
-0+/* +* make the short names macros so specific devices +* can override them as required +*/ +#define inb (addr) readb(addr) +#define inw (addr) readw(addr) +#define inl (addr) readl(addr) +#define outb (x, addr) ((void) writeb(x, addr)) +#define outw (x, addr) ((void) writew(x, addr)) +#define outl (x, addr) ((void) writel(x, addr))This makes no sense: the legacy PC I/O accessors take a completely different argument type: I would recommend to make both inline functions so you can ensure that
readl()gets passed an__iomempointer, whileinl()gets an integer number.
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Please see the asm-generic version for an example. You should also define a non-NULL
PCI_IOBASEto which the PCI I/O space gets mapped.I think these macros can be removed if PCI is not enabled in Nios2.
We have a bunch of ISA device drivers that use these interfaces but are not built conditionally through a
Kconfigdependency. If you want 'allyesconfig' to build successfully, you have to provide some dummy implementation.
Okay, will provide empty write and read with return 0 dummy implementation here.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
arch/nios2/include/asm/io.h line 217
Quoted 3 lines
arch/nios2/include/asm/io.h new file +2
-0+#define ioport_map (port, nr) ioremap(port, nr) +#define ioport_unmap (port) iounmap(port)Use this one instead:
#ifdef
CONFIG_PCI
static inline void__iomem*ioport_map(unsigned long port, unsigned int nr){ return PCI_IOBASE + port; }static inline void
__iomem*ioport_unmap(void__iomem*) {
}
#endif
Quoted 7 lines
Quoted 1 line
These also can be removed.
For this, there is a
Kconfigsymbol. If you don't provideioport_map, you should setCONFIG_NO_IOPORT_MAP. Uwe Kleine-König has recently started some work in this area. Ideally we would also have aCONFIG_HAS_IOPORToption that is only set by architectures that actually implement inb/outb. Getting there still needs work, but any help is appreciated.
Will set CONFIG_NO_IOPORT_MAP. I noticed that there is CONFIG_HAS_IOPORT_MAP, is it same as CONFIG_HAS_IOPORT you refer to? But, seem only arch/sh is using it.
Re: [PATCH 08/28] nios2: MMU Fault handling
In reply to Ezequiel GarciaQuoted 7 lines · Ezequiel Garcia
Quoted 7 lines
Quoted 7 lines
I found that it's useful to add some printing here, just as ARM does. I carry this patch on my kernel:
(quoted diff) +3
-0+ printk(KERN_INFO "%s: unhandled page fault (%d) at 0x%08lx, cause %ld\n", + current->comm, SIGSEGV, address, cause); + show_regs(regs);
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Do you think we could do something like it? Maybe with a compile time option?
Yes, this is useful debug message. I can add this. Prefer not to add new compile time option, I think this shouldn't happen frequently.
No, it shouldn't happen frequently. You can take a look at what ARM does. They use a
DEBUG_USERcompile-time option, much more complex than my silly proposal.
For now, we can print it always if this shouldn't happen frequently. Compile time option can be added later if we have more other debug stuff to print later.
Thanks.
Regard,
Ley Foon
Re: [PATCH 19/28] nios2: Device tree support
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
On Friday 18 April 2014, Ley Foon Tan wrote:
Are these all synthesized devices, or is there also some hardwired logic? It often makes sense to split out the reusable parts into a separate .dtsi file that gets included by every implementation.
In case you are not aware of this, devicetree files for Nios-II SoCs are produced through an automated tool calle sopc2dts:
http://www.alterawiki.com/wiki/Sopc2dts
http://git.rocketboards.org/sopc-tools.git/
You feed it with a sopcinfo file (AFAIK, Altera's specific format) and you obtain a full-fledged devicetree source file. Usually it works out-of-the-box, although I like to go over it and fix ranges, whitespaces, and do some cleaning.
So I'm wondering -given we have such superb tool- why would we want to include the devicetree source's in the kernel?
First, we'll be only supporting a *specific* configuration. Second, the dts is trivially easy to obtain.
The binding documentation should be enough specification, and there's no need for further reference or examples.
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Re: [PATCH 17/28] nios2: Signal handling support
In reply to Ley Foon TanAm 24.04.2014 12:46, schrieb Ley Foon Tan:
Quoted 18 lines · Richard Weinberger
Quoted 17 lines
Am 24.04.2014 12:29, schrieb Ley Foon Tan:
Quoted 15 lines · Richard Weinberger
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
Okay.
I just noticed that
sigsp()have struct ksignal argument. We can usesigsp()for nios2 because it doesn't have struct ksignal.unsigned long
sigsp(unsigned long sp, struct ksignal *ksig);Did you at look at the struct ksignal definition and the clean series I've pointed you to?
Not yet, this is the full set of patches? I only see partial..
https://lkml.org/lkml/2014/3/2/198
Quoted 7 lines
Quoted 4 lines
Maybe lkml.org misses a few but this does not matter. All you need to know is that using ksignal is easy. e.g. https://lkml.org/lkml/2014/3/2/162
Thanks. I am looking at your git tree
https://git.kernel.org/cgit/linux/kernel/git/rw/misc.git/log/?h=signal_v2
Are these patches already available in v3.15 rc?
Nope, I have to rebase them again.
But some archs have picked up the changes already.
Quoted 1 line
I can update nios2 to use new implementation.
Would be great. :)
Thanks,
//richard
Re: [PATCH 08/28] nios2: MMU Fault handling
In reply to Ley Foon TanQuoted 14 lines · Ley Foon Tan
Quoted 12 lines · Ezequiel Garcia
Quoted 11 lines
Quoted 8 lines
I found that it's useful to add some printing here, just as ARM does. I carry this patch on my kernel:
(quoted diff) +3
-0+ printk(KERN_INFO "%s: unhandled page fault (%d) at 0x%08lx, cause %ld\n", + current->comm, SIGSEGV, address, cause); + show_regs(regs);Do you think we could do something like it? Maybe with a compile time option?
Yes, this is useful debug message. I can add this. Prefer not to add new compile time option, I think this shouldn't happen frequently.
Quoted 7 lines
Quoted 3 lines
No, it shouldn't happen frequently. You can take a look at what ARM does. They use a
DEBUG_USERcompile-time option, much more complex than my silly proposal.For now, we can print it always if this shouldn't happen frequently. Compile time option can be added later if we have more other debug stuff to print later.
OK, sound sensible.
Signature · 3 lines
Ezequiel García, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
Re: [PATCH 16/28] nios2: System calls handling
In reply to Arnd BergmannQuoted 8 lines · Arnd Bergmann
arch/nios2/include/uapi/asm/unistd.h line 19
Quoted 3 lines · Ley Foon Tan
arch/nios2/include/uapi/asm/unistd.h new file +3
-0+ +#define sys_mmap2 sys_mmap_pgoff +You use
sys_mmap_pgoffhere, but
Quoted 12 lines
arch/nios2/kernel/sys_nios2.c line 28
Quoted 9 lines
arch/nios2/kernel/sys_nios2.c new file +9
-0+asmlinkage long sys_mmap (unsigned long addr,unsigned long len, +unsigned long prot,unsigned long flags, +unsigned long fd,unsigned long offset) +{ +if (offset & ~PAGE_MASK ) +return -EINVAL ; + +return sys_mmap_pgoff (addr, len, prot, flags, fd, offset >>PAGE_SHIFT ); +}define a separate
sys_mmap()here. Doing the former should be enough. so you can just drop thesys_mmapdefinition.
Okay, will drop the sys_mmap.
Thanks.
Regards
Ley Foon
Quoted 40 lines · Catalin Marinas
Quoted 30 lines · Chung-Lin Tang
Quoted 29 lines · Chung-Lin Tang
Quoted 27 lines · Andrew
Quoted 14 lines
Quoted 14 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Quoted 7 lines
Hi Arnd and Peter Anvin,
Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Quoted 8 lines
Quoted 3 lines
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.The more I think of this, the more I feel that
suseconds_tshould jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like aCOMPAT_USE_32BIT_SUSECONDScase.
Quoted 6 lines
ILP32 mode should use LP64 syscalls as much as possible and that's the aim with arm64 as well (of course, we still have a few that wouldn't be possible and we route them via compat).
But here if
time_tis 64-bit whilesusecconds_tis 32-bit, the compat code wouldn't help.
Why not? You can define the arm64 'struct compat_timeval' with suseconds_t as s32, and add the 32<-->64 case in the compat_get/put_timeval path, triggered when the process is ILP32 (test wrapped in the above hypothetical COMPAT_USE_32BIT_SUSECONDS macro). Similar to how x32 does COMPAT_USE_64BIT_TIME.
Chung-Lin
Quoted 49 lines · Chung-Lin Tang
Quoted 46 lines · Catalin Marinas
Quoted 31 lines · Chung-Lin Tang
Quoted 30 lines · Chung-Lin Tang
Quoted 28 lines · Andrew
Quoted 14 lines
Quoted 14 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,
Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Quoted 8 lines
Quoted 3 lines
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.The more I think of this, the more I feel that
suseconds_tshould jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like aCOMPAT_USE_32BIT_SUSECONDScase.ILP32 mode should use LP64 syscalls as much as possible and that's the aim with arm64 as well (of course, we still have a few that wouldn't be possible and we route them via compat).
Quoted 8 lines
Quoted 2 lines
But here if
time_tis 64-bit whilesusecconds_tis 32-bit, the compat code wouldn't help.Why not? You can define the arm64 'struct
compat_timeval' withsuseconds_tas s32, and add the 32<-->64 case in the compat_get/put_timeval path, triggered when the process is ILP32 (test wrapped in the above hypotheticalCOMPAT_USE_32BIT_SUSECONDSmacro). Similar to how x32 doesCOMPAT_USE_64BIT_TIME.
We would three timeval then. One for aarch32, one for lp64 and one for ilp32. We really don't want three. Two is already one too many in my mind after developing the ilp32 syscall abi.
Thanks,
Andrew
Quoted 7 lines
Chung-Lin
Quoted 58 lines · Andrew
Quoted 49 lines · Chung-Lin Tang
Quoted 46 lines · Catalin Marinas
Quoted 31 lines · Chung-Lin Tang
Quoted 30 lines · Chung-Lin Tang
Quoted 28 lines · Andrew
Quoted 14 lines
Quoted 14 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
Quoted 9 lines
On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Quoted 8 lines
Quoted 3 lines
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.The more I think of this, the more I feel that
suseconds_tshould jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like aCOMPAT_USE_32BIT_SUSECONDScase.ILP32 mode should use LP64 syscalls as much as possible and that's the aim with arm64 as well (of course, we still have a few that wouldn't be possible and we route them via compat).
Quoted 8 lines
Quoted 2 lines
But here if
time_tis 64-bit whilesusecconds_tis 32-bit, the compat code wouldn't help.Why not? You can define the arm64 'struct
compat_timeval' withsuseconds_tas s32, and add the 32<-->64 case in the compat_get/put_timeval path, triggered when the process is ILP32 (test wrapped in the above hypotheticalCOMPAT_USE_32BIT_SUSECONDSmacro). Similar to how x32 doesCOMPAT_USE_64BIT_TIME.
Quoted 4 lines
We would three timeval then. One for aarch32, one for lp64 and one for ilp32. We really don't want three. Two is already one too many in my mind after developing the ilp32 syscall abi.
Thanks,
Andrew
Okay I now see you're already doing that for 32-bit ARM.
Still, you would probably just need to have an arm64-ILP32 specific case to be careful about the last padding word upon kernel entry/exit. (accommodating the difference in sizeof(long)) Penalizing all architectures does not seem like the best solution.
Having suseconds_t as a strictly 64-bit C type in the kernel, while defined as <= long in user-space may cause other problems.
I'll try to explain a probable situation for Nios II. I'm not sure about other soft-cores, but nios2 is sort of uncommon in that the maximum alignment is 4-bytes (32-bits), even for doubles/long-longs.
So if time_t is 64-bits (which makes sense), then struct timeval, which is time_t+suseconds_t in userspace is 12-bytes/aligned-4 (unlike many archs where a 64-bit time_t will expand the size to 16-bytes, due to align-8)
If the kernel suseconds_t is forced to be 64-bits, then nios2 will have a 16-byte kernel timeval vs. 12-byte userspace timeval situation. Just this will require us to do something using compat_*, or weird hacks in glibc, which is unfair. Nios II has no "other-mode". We are just strictly ILP32, everywhere.
Of course, we can probably still at the end just use a Nios II specific posix_types.h header to override things, but I'm just stating this as a matter of which are the most reasonable default settings in the generic headers. Making pure ILP32 archs diverge from POSIX standards by default does not seem to be right.
Thanks,
Chung-Lin
Quoted 68 lines · Chung-Lin Tang
Quoted 60 lines · Andrew
Quoted 49 lines
Quoted 49 lines · Chung-Lin Tang
Quoted 33 lines · Catalin Marinas
Quoted 31 lines · Chung-Lin Tang
Quoted 29 lines · Chung-Lin Tang
Quoted 13 lines · Andrew
Quoted 13 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
Quoted 9 lines
On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Quoted 8 lines
Quoted 3 lines
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.The more I think of this, the more I feel that
suseconds_tshould jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like aCOMPAT_USE_32BIT_SUSECONDScase.ILP32 mode should use LP64 syscalls as much as possible and that's the aim with arm64 as well (of course, we still have a few that wouldn't be possible and we route them via compat).
Quoted 8 lines
Quoted 2 lines
But here if
time_tis 64-bit whilesusecconds_tis 32-bit, the compat code wouldn't help.Why not? You can define the arm64 'struct
compat_timeval' withsuseconds_tas s32, and add the 32<-->64 case in the compat_get/put_timeval path, triggered when the process is ILP32 (test wrapped in the above hypotheticalCOMPAT_USE_32BIT_SUSECONDSmacro). Similar to how x32 doesCOMPAT_USE_64BIT_TIME.Quoted 4 lines
We would three timeval then. One for aarch32, one for lp64 and one for ilp32. We really don't want three. Two is already one too many in my mind after developing the ilp32 syscall abi.
Thanks,
Andrew
Quoted 6 lines
Okay I now see you're already doing that for 32-bit ARM.
Still, you would probably just need to have an arm64-ILP32 specific case to be careful about the last padding word upon kernel entry/exit. (accommodating the difference in sizeof(long)) Penalizing all architectures does not seem like the best solution.
Considering the alignment of long long would be 64bits, the struct does not change sizes if suseconds_t is 32bits or 64bits.
Quoted 7 lines
Having
suseconds_tas a strictly 64-bit C type in the kernel, while defined as <= long in user-space may cause other problems.I'll try to explain a probable situation for Nios II. I'm not sure about other soft-cores, but nios2 is sort of uncommon in that the maximum alignment is 4-bytes (32-bits), even for doubles/long-longs.
Yes does that include even if users of aligned? If so that seems broken. Also yes nios ii is unstandard when it comes to alignment here.
Quoted 5 lines
So if
time_tis 64-bits (which makes sense), then struct timeval, which is time_t+suseconds_t in userspace is 12-bytes/aligned-4 (unlike many archs where a 64-bittime_twill expand the size to 16-bytes, due to align-8)
Unlike most other targets where the struct would 16bits no matter what.
Thanks,
Andrew
Quoted 16 lines
If the kernel
suseconds_tis forced to be 64-bits, then nios2 will have a 16-byte kernel timeval vs. 12-byte userspace timeval situation. Just this will require us to do something using compat_*, or weird hacks in glibc, which is unfair. Nios II has no "other-mode". We are just strictly ILP32, everywhere.Of course, we can probably still at the end just use a Nios II specific
posix_types.hheader to override things, but I'm just stating this as a matter of which are the most reasonable default settings in the generic headers. Making pure ILP32 archs diverge from POSIX standards by default does not seem to be right.Thanks,
Chung-Lin
Quoted 3 lines · Chung-Lin Tang
I'll try to explain a probable situation for Nios II. I'm not sure about other soft-cores, but nios2 is sort of uncommon in that the maximum alignment is 4-bytes (32-bits), even for doubles/long-longs.
FWIW, that's the same as on m32r. And on m68k it's 2 bytes.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 14/28] nios2: DMA mapping API
In reply to Arnd BergmannQuoted 30 lines · Arnd Bergmann
Quoted 15 lines · Ley Foon Tan
arch/nios2/include/asm/dma-mapping.h new file +14
-0+static inline int dma_supported (struct device *dev,u64 mask) +{ +/* we fall back to GFP_DMA when the mask isn't all 1s, +* so we can't guarantee allocations that must be +* within a tighter range than GFP_DMA. +*/ +if (mask <0x00ffffff ) +return 0 ; + +return 1 ; +} +void *dma_alloc_coherent (struct device *dev,size_t size, +dma_addr_t *dma_handle,gfp_t gfp) +{arch/nios2/include/asm/dma-mapping.h
Quoted 10 lines
arch/nios2/include/asm/dma-mapping.h new file +10
-0+void *ret; + +/* ignore region specifiers */ + gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); + +/* optimized page clearing */ + gfp |= __GFP_ZERO; + +if (dev ==NULL || (dev->coherent_dma_mask <0xffffffff )) + gfp |=GFP_DMA ;What is the significance of
ZONE_DMAon this architecture?
Quoted 1 line
Do you actually have DMA masters with a
0x00ffffffmask?
Actually, nios2 doesn't have DMA master with 0x00ffffff mask. I will change it to return 1, same as some other architectures implementation.
And the ZONE_DMA stuff will remove as well, it shouldn't have ZONE_DMA limitation.
Arnd Bergmann
maintainerRe: [PATCH 14/28] nios2: DMA mapping API
Quoted 5 lines · On Friday 25 April 2014 18:13:31 Ley Foon Tan wrote:
Actually, nios2 doesn't have DMA master with
0x00ffffffmask. I will change it to return 1, same as some other architectures implementation.
And theZONE_DMAstuff will remove as well, it shouldn't haveZONE_DMAlimitation.
Ok, excellent!
Arnd
Re: [PATCH 14/28] nios2: DMA mapping API
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Friday 25 April 2014 18:13:31 Ley Foon Tan wrote:
Actually, nios2 doesn't have DMA master with
0x00ffffffmask. I will change it to return 1, same as some other architectures implementation.
And theZONE_DMAstuff will remove as well, it shouldn't haveZONE_DMAlimitation.Ok, excellent!
Thanks. BTW, do you have any chance to review other patches? :)
Regards
Ley Foon
Quoted 78 lines · Andrew
Quoted 68 lines · Chung-Lin Tang
Quoted 60 lines · Andrew
Quoted 49 lines
Quoted 49 lines · Chung-Lin Tang
Quoted 33 lines · Catalin Marinas
Quoted 31 lines · Chung-Lin Tang
Quoted 29 lines · Chung-Lin Tang
Quoted 13 lines · Andrew
Quoted 13 lines · Chung-Lin Tang
Quoted 12 lines
Quoted 12 lines · Ley Foon Tan
Quoted 9 lines · Arnd Bergmann
On Tuesday 22 April 2014 18:37:11 Ley Foon Tan wrote:
Hi Arnd and Peter Anvin,Other than 64-bit time_t, clock_t and suseconds_t, can you confirm
that we don't need to have 64 bit off_t? See detail in link below.
I can submit the patches for 64-bit time changes
(include/asm-generic/posix_types.h and other archs) if everyone is
agreed on this.Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Yes.
Okay, will doing that.
I believe that arm64 ILP32 will also be affected. What is the status of this configuration? Has the glibc/kernel ABI been finalized?
Not yet. I am still working out the signal handling part. But we already agreed on 64bit
time_t,clock_t, andsuseconds_t. And we agreed to a 64bitoffset_ttoo.On a related note suseconds in the timespec in posix is defined to be long. So it would nice if the kernel ignores the upper 32bits so we (glibc developers) can fix this for new targets including x32 and arm64/ilp32.
Quoted 8 lines
Quoted 3 lines
Hmm, but that means for purely 32-bit architectures like nios2, which unlike
x86_64or arm64, never has a 64-bit mode,suseconds_tas a 64-bit type in the kernel is simply wasted.The more I think of this, the more I feel that
suseconds_tshould jsut be 'long', not strictly 64-bitified. An ILP32 sub-mode in a 64-bit kernel should be using compat_* code paths, something like aCOMPAT_USE_32BIT_SUSECONDScase.ILP32 mode should use LP64 syscalls as much as possible and that's the aim with arm64 as well (of course, we still have a few that wouldn't be possible and we route them via compat).
Quoted 8 lines
Quoted 2 lines
But here if
time_tis 64-bit whilesusecconds_tis 32-bit, the compat code wouldn't help.Why not? You can define the arm64 'struct
compat_timeval' withsuseconds_tas s32, and add the 32<-->64 case in the compat_get/put_timeval path, triggered when the process is ILP32 (test wrapped in the above hypotheticalCOMPAT_USE_32BIT_SUSECONDSmacro). Similar to how x32 doesCOMPAT_USE_64BIT_TIME.Quoted 4 lines
We would three timeval then. One for aarch32, one for lp64 and one for ilp32. We really don't want three. Two is already one too many in my mind after developing the ilp32 syscall abi.
Thanks,
AndrewQuoted 6 lines
Okay I now see you're already doing that for 32-bit ARM.
Still, you would probably just need to have an arm64-ILP32 specific case to be careful about the last padding word upon kernel entry/exit. (accommodating the difference in sizeof(long)) Penalizing all architectures does not seem like the best solution.
Considering the alignment of long long would be 64bits, the struct does not change sizes if
suseconds_tis 32bits or 64bits.Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Having
suseconds_tas a strictly 64-bit C type in the kernel, while defined as <= long in user-space may cause other problems.I'll try to explain a probable situation for Nios II. I'm not sure about other soft-cores, but nios2 is sort of uncommon in that the maximum alignment is 4-bytes (32-bits), even for doubles/long-longs.
Yes does that include even if users of aligned? If so that seems broken. Also yes nios ii is unstandard when it comes to alignment here.
You mean using '__attribute__((aligned(8)))'? Sure of course that enlarges the alignment as expected, but sprinkling that over glibc, or getting it into the main glibc bits/time.h header is probably not going to happen...
Thanks,
Chung-Lin
Quoted 28 lines
Quoted 5 lines
So if
time_tis 64-bits (which makes sense), then struct timeval, which is time_t+suseconds_t in userspace is 12-bytes/aligned-4 (unlike many archs where a 64-bittime_twill expand the size to 16-bytes, due to align-8)Unlike most other targets where the struct would 16bits no matter what.
Thanks,
AndrewQuoted 16 lines
If the kernel
suseconds_tis forced to be 64-bits, then nios2 will have a 16-byte kernel timeval vs. 12-byte userspace timeval situation. Just this will require us to do something using compat_*, or weird hacks in glibc, which is unfair. Nios II has no "other-mode". We are just strictly ILP32, everywhere.Of course, we can probably still at the end just use a Nios II specific
posix_types.hheader to override things, but I'm just stating this as a matter of which are the most reasonable default settings in the generic headers. Making pure ILP32 archs diverge from POSIX standards by default does not seem to be right.Thanks,
Chung-Lin
Re: [PATCH 25/28] nios2: ptrace support
In reply to Ley Foon TanDoes this support PTRACE_GETREGSET / PTRACE_SETREGSET ?
IMO, the kernel shouldn't accept ports without those anymore.
And IMHO, we shouldn't even allow new ports having PTRACE_GETREGS.
http://sourceware.org/ml/archer/2010-q3/msg00193.html
Signature · 1 line
Pedro Alves
Re: [PATCH 25/28] nios2: ptrace support
Quoted 8 lines · Pedro Alves
Does this support
PTRACE_GETREGSET/PTRACE_SETREGSET?IMO, the kernel shouldn't accept ports without those anymore.
And IMHO, we shouldn't even allow new ports having
PTRACE_GETREGS.
It doesn't support PTRACE_GETREGSET / PTRACE_SETREGSET now. We will look into this.
Regards
Ley Foon
Re: [PATCH 07/28] nios2: I/O Mapping
In reply to Ley Foon TanQuoted 26 lines · Ley Foon Tan
Quoted 8 lines · Arnd Bergmann
arch/nios2/include/asm/io.h line 15
Quoted 4 lines · Ley Foon Tan
arch/nios2/include/asm/io.h new file +4
-0+ +#include <asm/pgtable-bits.h> + +#define IO_SPACE_LIMIT 0xffffffffPlease use
0xffffhere, this should work for almost any PCI bus.Ah,
CONFIG_PCIis not enable in nios2. So, I thinkIO_SPACE_LIMITshould set to 0.Quoted 5 lines
Quoted 5 lines
arch/nios2/include/asm/io.h new file +5
-0+ +/* Use "Duff's Device" to unroll the loops. */ +#define __IO_OUT_LOOP (a, b, l) \ + do { \ + if (l > 0) { \Quoted 8 lines
arch/nios2/include/asm/io.h line 31
Quoted 5 lines
arch/nios2/include/asm/io.h new file +5
-0+int _n = (l +7 ) /8 ; \ +switch (l %8 ) { \ +case 0 : \ + do { \ + *a = *b++; \I would recommend just doing all of this in out-of-line implementations rather than macros and inline functions.
Quoted 1 line
Okay. Will move the macros to out-of-line function.
I'm start working on this and found that it is better to keep it as macros. This is because the input arguments "a" and "b" can be byte/short/int pointers. Otherwise, we need to have separate function calls for byte/short/int.
Regards
Ley Foon
Arnd Bergmann
maintainerRe: [PATCH 07/28] nios2: I/O Mapping
Quoted 27 lines · On Friday 02 May 2014 18:37:55 Ley Foon Tan wrote:
Quoted 26 lines · Ley Foon Tan
Quoted 8 lines · Arnd Bergmann
arch/nios2/include/asm/io.h line 15
Quoted 4 lines · Ley Foon Tan
arch/nios2/include/asm/io.h new file +4
-0+ +#include <asm/pgtable-bits.h> + +#define IO_SPACE_LIMIT 0xffffffffPlease use
0xffffhere, this should work for almost any PCI bus.Ah,
CONFIG_PCIis not enable in nios2. So, I thinkIO_SPACE_LIMITshould set to 0.Quoted 13 lines
arch/nios2/include/asm/io.h line 31
Quoted 10 lines
arch/nios2/include/asm/io.h new file +10
-0+ +/* Use "Duff's Device" to unroll the loops. */ +#define __IO_OUT_LOOP (a, b, l) \ + do { \ + if (l > 0) { \ + int _n = (l + 7) / 8; \ + switch (l % 8) { \ + case 0: \ + do { \ + *a = *b++; \I would recommend just doing all of this in out-of-line implementations rather than macros and inline functions.
Quoted 6 lines
Quoted 1 line
Okay. Will move the macros to out-of-line function.
I'm start working on this and found that it is better to keep it as macros. This is because the input arguments "a" and "b" can be byte/short/int pointers. Otherwise, we need to have separate function calls for byte/short/int.
But with the inline implementation, you have a separate instance for each caller, which seems more wasteful.
You can put the function into a "lib" file to make sure it doesn't get linked in if there are no callers though. And of course you can keep the macro in the file implementing it so you don't have to write the same code three times.
Arnd
Re: [PATCH 07/28] nios2: I/O Mapping
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
I would recommend just doing all of this in out-of-line implementations rather than macros and inline functions.
Okay. Will move the macros to out-of-line function.
I'm start working on this and found that it is better to keep it as macros. This is because the input arguments "a" and "b" can be byte/short/int pointers. Otherwise, we need to have separate function calls for byte/short/int.
Quoted 7 lines
But with the inline implementation, you have a separate instance for each caller, which seems more wasteful.
You can put the function into a "lib" file to make sure it doesn't get linked in if there are no callers though. And of course you can keep the macro in the file implementing it so you don't have to write the same code three times.
I think we need to link these functions always (and export symbol) because they might used by loadable module.
So, will keep these as macros and change the inline functions to out-of-line implementation.
Thanks.
Regards
Ley Foon