Add support for pure microMIPS kernel.
Subsystems (2)
cover Add support for pure microMIPS kernel.
From: "Steven J. Hill" <[email protected]>
This set of patches is to support building a pure microMIPS kernel image using only instruction from the microMIPS ISA. The result is a kernel binary reduction of more than 20% and an increase in the speed of execution due to the smaller and faster instructions.
Steven J. Hill (9):
MIPS: Add microMIPS configuration option.
MIPS: Optimise core library functions for microMIPS.
MIPS: Add support for the M14KE core.
MIPS: Add microMIPS versions of breakpoints, BUG, etc.
MIPS: Add support for microMIPS instructions.
MIPS: Add support for microMIPS exception handling.
MIPS: Support microMIPS/MIPS16e handling of delay slots.
MIPS: Support microMIPS/MIPS16e unaligned accesses.
MIPS: Support microMIPS/MIPS16e floating point.
arch/mips/Kconfig | 10 + arch/mips/Makefile | 1 + arch/mips/configs/sead3micro_defconfig | 1757 ++++++++++++++++++++++++++++++++ arch/mips/include/asm/branch.h | 33 +- arch/mips/include/asm/break.h | 8 + arch/mips/include/asm/bug.h | 8 + arch/mips/include/asm/cpu-features.h | 3 + arch/mips/include/asm/cpu.h | 4 +- arch/mips/include/asm/dsp.h | 6 +- arch/mips/include/asm/fpu_emulator.h | 7 + arch/mips/include/asm/futex.h | 4 + arch/mips/include/asm/inst.h | 882 +++++++++++++++- arch/mips/include/asm/mipsregs.h | 359 +++---- arch/mips/include/asm/paccess.h | 2 + arch/mips/include/asm/page.h | 6 + arch/mips/include/asm/stackframe.h | 12 +- arch/mips/include/asm/uaccess.h | 14 +- arch/mips/kernel/branch.c | 183 +++- arch/mips/kernel/cpu-probe.c | 10 + arch/mips/kernel/genex.S | 82 +- arch/mips/kernel/proc.c | 27 +- arch/mips/kernel/process.c | 101 ++ arch/mips/kernel/ptrace.c | 4 + arch/mips/kernel/scall32-o32.S | 22 +- arch/mips/kernel/smtc-asm.S | 3 + arch/mips/kernel/traps.c | 377 ++++--- arch/mips/kernel/unaligned.c | 1496 +++++++++++++++++++++++---- arch/mips/lib/memcpy.S | 17 +- arch/mips/lib/memset.S | 90 +- arch/mips/lib/strlen_user.S | 13 +- arch/mips/lib/strncpy_user.S | 39 +- arch/mips/lib/strnlen_user.S | 24 +- arch/mips/math-emu/cp1emu.c | 766 ++++++++++++-- arch/mips/math-emu/dsemul.c | 40 +- arch/mips/mm/c-r4k.c | 1 + arch/mips/mm/fault.c | 2 + arch/mips/mm/page.c | 26 +- arch/mips/mm/tlbex.c | 23 + arch/mips/mm/uasm.c | 174 +++- arch/mips/mti-sead3/sead3-init.c | 57 +- arch/mips/oprofile/common.c | 1 + arch/mips/oprofile/op_model_mipsxx.c | 4 + 42 files changed, 5877 insertions(+), 821 deletions(-) create mode 100644 arch/mips/configs/sead3micro_defconfig
Signature · 1 line
1.7.9.6
PATCH 1/9 MIPS: Add microMIPS configuration option.
From: "Steven J. Hill" <[email protected]>
This adds the option to build the Linux kernel using only the microMIPS ISA. The resulting kernel binary is, at a minimum, 20% smaller than using the MIPS32R2 ISA.
--- arch/mips/Kconfig | 10 + arch/mips/Makefile | 1 + arch/mips/configs/sead3micro_defconfig | 1757 ++++++++++++++++++++++++++++++++ 3 files changed, 1768 insertions(+) create mode 100644 arch/mips/configs/sead3micro_defconfig
arch/mips/Kconfig +10 -0
@@ -2056,6 +2056,13 @@ config CPU_HAS_SMARTMIPS you don't know you probably don't have SmartMIPS and should say N here. +config CPU_MICROMIPS + depends on SYS_SUPPORTS_MICROMIPS + bool "Build kernel using microMIPS ISA" + help + When this option is enabled the kernel will be built using the + microMIPS ISA + config CPU_HAS_WB bool
@@ -2121,6 +2128,9 @@ config SYS_SUPPORTS_HIGHMEM config SYS_SUPPORTS_SMARTMIPS bool +config SYS_SUPPORTS_MICROMIPS + bool + config ARCH_FLATMEM_ENABLE def_bool y depends on !NUMA && !CPU_LOONGSON2
arch/mips/Makefile +1 -0
@@ -114,6 +114,7 @@ cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*e cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le)) cflags-$(CONFIG_CPU_HAS_SMARTMIPS) += $(call cc-option,-msmartmips) +cflags-$(CONFIG_CPU_MICROMIPS) += $(call cc-option,-mmicromips -mno-jals) cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ -fno-omit-frame-pointer
arch/mips/configs/sead3micro_defconfig new file +1757 -0
1,757 lines not on this page · raw message
Signature · 1 line
1.7.9.6
PATCH 2/9 MIPS: Optimise core library functions for microMIPS.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Optimise some of the core library functions to use microMIPS instructions for binary size reduction. When the microMIPS ISA is not being used, the library functions compiled to binary are identical.
--- arch/mips/include/asm/page.h | 6 +++ arch/mips/lib/memcpy.S | 17 ++++++-- arch/mips/lib/memset.S | 90 ++++++++++++++++++++++++++++++------------ arch/mips/lib/strlen_user.S | 13 ++++-- arch/mips/lib/strncpy_user.S | 39 +++++++++--------- arch/mips/lib/strnlen_user.S | 24 ++++++++--- arch/mips/mm/page.c | 26 ++++++------ 7 files changed, 147 insertions(+), 68 deletions(-)
arch/mips/include/asm/page.h +6 -0
@@ -45,6 +45,12 @@#define HUGETLB_PAGE_ORDER ({BUILD_BUG(); 0; })#endif /* CONFIG_HUGETLB_PAGE */ +/* +* Clear and copy array sizes for micro-assembly of clear_page/copy_page. +*/ +#define CLEAR_PAGE_ARRAY_SIZE 288 +#define COPY_PAGE_ARRAY_SIZE 1344 +#ifndef __ASSEMBLY__#include <linux/pfn.h>
arch/mips/lib/memcpy.S +13 -4
@@ -10,6 +10,7 @@ * Copyright (C) 2002 Broadcom, Inc. * memcpy/copy_user author: Mark Vandevoorde * Copyright (C) 2007 Maciej W. Rozycki + * Copyright (C) 2011 MIPS Technologies, Inc. * * Mnemonic names for arguments to memcpy/__copy_user */
@@ -21,16 +22,14 @@ * end of memory on some systems. It's also a seriously bad idea on non * dma-coherent systems. */ -#ifdef CONFIG_DMA_NONCOHERENT -#undef CONFIG_CPU_HAS_PREFETCH -#endif -#ifdef CONFIG_MIPS_MALTA +#if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_MIPS_MALTA) #undef CONFIG_CPU_HAS_PREFETCH #endif #include <asm/asm.h> #include <asm/asm-offsets.h> #include <asm/regdef.h> +#include <asm/page.h> #define dst a0 #define src a1
@@ -564,3 +563,13 @@ LEAF(__rmemcpy) /* a0=dst a1=src a2=len */ jr ra move a2, zero END(__rmemcpy) + +LEAF(clear_page) +1: j 1b /* Dummy, will be replaced. */ + .space CLEAR_PAGE_ARRAY_SIZE + END(clear_page) + +LEAF(copy_page) +1: j 1b /* Dummy, will be replaced. */ + .space COPY_PAGE_ARRAY_SIZE + END(copy_page)
arch/mips/lib/memset.S +64 -26
155 lines not on this page · raw message
arch/mips/lib/strlen_user.S +9 -4
@@ -3,8 +3,9 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle - * Copyright (c) 1999 Silicon Graphics, Inc. + * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle + * Copyright (C) 1999 Silicon Graphics, Inc. + * Copyright (C) 2011 MIPS Technologies, Inc. */ #include <asm/asm.h> #include <asm/asm-offsets.h>
@@ -28,9 +29,13 @@ LEAF(__strlen_user_asm) FEXPORT(__strlen_user_nocheck_asm) move v0, a0 -1: EX(lb, t0, (v0), .Lfault) +#ifdef CONFIG_CPU_MICROMIPS +1: EX(lbu16, v1, (v0), .Lfault) +#else +1: EX(lb, v1, (v0), .Lfault) +#endif PTR_ADDIU v0, 1 - bnez t0, 1b + bnez v1, 1b PTR_SUBU v0, a0 jr ra END(__strlen_user_asm)
arch/mips/lib/strncpy_user.S +21 -18
@@ -3,7 +3,8 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 1996, 1999 by Ralf Baechle + * Copyright (C) 1996, 1999 by Ralf Baechle + * Copyright (C) 2011 MIPS Technologies, Inc. */ #include <linux/errno.h> #include <asm/asm.h>
@@ -30,30 +31,32 @@ LEAF(__strncpy_from_user_asm) LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok? and v0, a1 +#ifdef CONFIG_CPU_MICROMIPS + bnezc v0, .Lfault +#else bnez v0, .Lfault +#endif FEXPORT(__strncpy_from_user_nocheck_asm) - move v0, zero - move v1, a1 .set noreorder -1: EX(lbu, t0, (v1), .Lfault) + move t0, zero + move v1, a1 +1: EX(lbu, v0, (v1), .Lfault) PTR_ADDIU v1, 1 R10KCBARRIER(0(ra)) - beqz t0, 2f - sb t0, (a0) - PTR_ADDIU v0, 1 - .set reorder - PTR_ADDIU a0, 1 - bne v0, a2, 1b -2: PTR_ADDU t0, a1, v0 - xor t0, a1 - bltz t0, .Lfault + beqz v0, 2f + sb v0, (a0) + PTR_ADDIU t0, 1 + bne t0, a2, 1b + PTR_ADDIU a0, 1 +2: PTR_ADDU v0, a1, t0 + xor v0, a1 + bltz v0, .Lfault + nop jr ra # return n + move v0, t0 END(__strncpy_from_user_asm) -.Lfault: li v0, -EFAULT +.Lfault: jr ra - - .section __ex_table,"a" - PTR 1b, .Lfault - .previous + li v0, -EFAULT
arch/mips/lib/strnlen_user.S +19 -5
@@ -5,6 +5,7 @@ * * Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle * Copyright (c) 1999 Silicon Graphics, Inc. + * Copyright (C) 2011 MIPS Technologies, Inc. */ #include <asm/asm.h> #include <asm/asm-offsets.h>
@@ -26,21 +27,34 @@ * the maximum is a tad hairier ... */ LEAF(__strnlen_user_asm) + .set noreorder LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok? and v0, a0 +#ifdef CONFIG_CPU_MICROMIPS + bnezc v0, .Lfault +#else bnez v0, .Lfault +#endif FEXPORT(__strnlen_user_nocheck_asm) - move v0, a0 PTR_ADDU a1, a0 # stop pointer + move v0, a0 1: beq v0, a1, 1f # limit reached? + nop EX(lb, t0, (v0), .Lfault) - PTR_ADDU v0, 1 +#ifdef CONFIG_CPU_MICROMIPS + addius5 v0, 1 + bnezc t0, 1b +1: jr ra + PTR_SUBU v0, a0 +#else bnez t0, 1b -1: PTR_SUBU v0, a0 - jr ra + PTR_ADDU v0, 1 +1: jr ra + PTR_SUBU v0, a0 +#endif END(__strnlen_user_asm) .Lfault: - move v0, zero jr ra + move v0, zero
arch/mips/mm/page.c +15 -11
@@ -6,6 +6,7 @@* Copyright (C) 2003, 04, 05 Ralf Baechle ([email protected]) * Copyright (C) 2007 Maciej W. Rozycki * Copyright (C) 2008 Thiemo Seufer +* Copyright (C) 2011 MIPS Technologies, Inc. */ #include <linux/init.h> #include <linux/kernel.h>
@@ -79,17 +80,12 @@ static struct uasm_reloc __cpuinitdata relocs[5];* R4600 v2.0: 0x060 bytes * With prefetching, 16 word strides 0x120 bytes */ - -static u32 clear_page_array[0x120 /4 ]; +u32 clear_page_array[CLEAR_PAGE_ARRAY_SIZE /4 ];#ifdef CONFIG_SIBYTE_DMA_PAGEOPS void clear_page_cpu (void *page) __attribute__((alias ("clear_page_array" ))); -#else -void clear_page (void *page) __attribute__((alias ("clear_page_array" )));#endif -EXPORT_SYMBOL (clear_page); -/* * Maximum sizes: *
@@ -98,17 +94,13 @@ EXPORT_SYMBOL(clear_page);* R4600 v2.0: 0x07c bytes * With prefetching, 16 word strides 0x540 bytes */ -static u32 copy_page_array[0x540 /4 ]; +u32 copy_page_array[COPY_PAGE_ARRAY_SIZE /4 ];#ifdef CONFIG_SIBYTE_DMA_PAGEOPS void copy_page_cpu (void *to,void *from) __attribute__((alias ("copy_page_array" ))); -#else -void copy_page (void *to,void *from) __attribute__((alias ("copy_page_array" )));#endif -EXPORT_SYMBOL (copy_page); -static int pref_bias_clear_store__cpuinitdata ;static int pref_bias_copy_load__cpuinitdata ;
@@ -368,6 +360,12 @@ void __cpuinit build_clear_page(void)for (i =0 ; i < (buf - clear_page_array); i++)pr_debug ("\t.word 0x%08x\n" , clear_page_array[i]);pr_debug ("\t.set pop\n" ); +#ifdef CONFIG_CPU_MICROMIPS +memcpy (((u8 *)clear_page) -1 , clear_page_array, +ARRAY_SIZE (clear_page_array) *4 ); +#else +memcpy (clear_page, clear_page_array,ARRAY_SIZE (clear_page_array) *4 ); +#endif }static void __cpuinit build_copy_load (u32 **buf,int reg,int off)
@@ -607,6 +605,12 @@ void __cpuinit build_copy_page(void)for (i =0 ; i < (buf - copy_page_array); i++)pr_debug ("\t.word 0x%08x\n" , copy_page_array[i]);pr_debug ("\t.set pop\n" ); +#ifdef CONFIG_CPU_MICROMIPS +memcpy (((u8 *)copy_page) -1 , copy_page_array, +ARRAY_SIZE (copy_page_array) *4 ); +#else +memcpy (copy_page, copy_page_array,ARRAY_SIZE (copy_page_array) *4 ); +#endif }#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
Signature · 1 line
1.7.9.6
PATCH 3/9 MIPS: Add support for the M14KE core.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
This patch depends on the M14K core support patch being applied first.
--- arch/mips/include/asm/cpu-features.h | 3 +++ arch/mips/include/asm/cpu.h | 4 +++- arch/mips/kernel/cpu-probe.c | 10 ++++++++++ arch/mips/mm/c-r4k.c | 1 + arch/mips/mm/tlbex.c | 2 ++ arch/mips/oprofile/common.c | 1 + arch/mips/oprofile/op_model_mipsxx.c | 4 ++++ 7 files changed, 24 insertions(+), 1 deletion(-)
arch/mips/include/asm/cpu-features.h +3 -0
@@ -98,6 +98,9 @@#ifndef kernel_uses_smartmips_rixi#define kernel_uses_smartmips_rixi 0#endif +#ifndef cpu_has_mmips +#define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS) +#endif #ifndef cpu_has_vtag_icache#define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)#endif
arch/mips/include/asm/cpu.h +3 -1
@@ -96,6 +96,7 @@#define PRID_IMP_1004K 0x9900#define PRID_IMP_1074K 0x9a00#define PRID_IMP_14K 0x9c00 +#define PRID_IMP_14KE 0x9e00/* * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
@@ -262,7 +263,7 @@ enum cpu_type_enum {*/ CPU_4KC ,CPU_4KEC ,CPU_4KSC ,CPU_24K ,CPU_34K ,CPU_1004K ,CPU_74K ,CPU_ALCHEMY ,CPU_PR4450 ,CPU_BMIPS32 ,CPU_BMIPS3300 ,CPU_BMIPS4350 , -CPU_BMIPS4380 ,CPU_BMIPS5000 ,CPU_JZRISC ,CPU_1074K ,CPU_14K , +CPU_BMIPS4380 ,CPU_BMIPS5000 ,CPU_JZRISC ,CPU_1074K ,CPU_14K ,CPU_14KE ,/* * MIPS64 class processors
@@ -319,6 +320,7 @@ enum cpu_type_enum {#define MIPS_CPU_VINT 0x00080000/* CPU supports MIPSR2 vectored interrupts */ #define MIPS_CPU_VEIC 0x00100000/* CPU supports MIPSR2 external interrupt controller mode */ #define MIPS_CPU_ULRI 0x00200000/* CPU has ULRI feature */ +#define MIPS_CPU_MICROMIPS 0x01000000/* CPU has microMIPS capability */ /* * CPU ASE encodings
arch/mips/kernel/cpu-probe.c +10 -0
@@ -201,6 +201,7 @@ void __init check_wait(void)break ;case CPU_14K : +case CPU_14KE :case CPU_24K :case CPU_34K :case CPU_1004K :
@@ -747,6 +748,11 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c) c->options |=MIPS_CPU_ULRI ;if (config3 &MIPS_CONF3_CTXTC ) c->options |=MIPS_CPU_CTXTC ; +if (config3 &MIPS_CONF3_ISA ) + c->options |=MIPS_CPU_MICROMIPS ; +#ifdef CONFIG_CPU_MICROMIPS +write_c0_config3 (read_c0_config3 () |MIPS_CONF3_ISA_OE ); +#endif return config3 &MIPS_CONF_M ; }
@@ -840,6 +846,10 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) c->cputype =CPU_14K ; __cpu_name[cpu] ="MIPS 14Kc" ;break ; +case PRID_IMP_14KE : + c->cputype =CPU_14KE ; + __cpu_name[cpu] ="MIPS 14KEc" ; +break ;case PRID_IMP_1004K : c->cputype =CPU_1004K ; __cpu_name[cpu] ="MIPS 1004Kc" ;
arch/mips/mm/c-r4k.c +1 -0
@@ -1074,6 +1074,7 @@ static void __cpuinit probe_pcache(void) bypass1074: ;case CPU_14K : +case CPU_14KE :case CPU_24K :case CPU_34K :case CPU_1004K :
arch/mips/mm/tlbex.c +2 -0
@@ -461,6 +461,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,if (cpu_has_mips_r2_exec_hazard) {switch (current_cpu_type ()) {case CPU_14K : +case CPU_14KE :case CPU_74K :case CPU_1074K :break ;
@@ -515,6 +516,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,case CPU_4KC :case CPU_4KEC :case CPU_14K : +case CPU_14KE :case CPU_SB1 :case CPU_SB1A :case CPU_4KSC :
arch/mips/oprofile/common.c +1 -0
@@ -79,6 +79,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)switch (current_cpu_type ()) {case CPU_5KC :case CPU_14K : +case CPU_14KE :case CPU_20KC :case CPU_24K :case CPU_25KF :
arch/mips/oprofile/op_model_mipsxx.c +4 -0
@@ -321,6 +321,10 @@ static int __init mipsxx_init(void) op_model_mipsxx_ops.cpu_type ="mips/14K" ;break ; +case CPU_14KE : + op_model_mipsxx_ops.cpu_type ="mips/14KE" ; +break ; +case CPU_20KC : op_model_mipsxx_ops.cpu_type ="mips/20K" ;break ;
Signature · 1 line
1.7.9.6
PATCH 4/9 MIPS: Add microMIPS versions of breakpoints, BUG, etc.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Add breakpoints, BUG() functions, DSP instruction masks, and debug messages for microMIPS. Also add '.insn' directive to a number of files that must assemble correctly when using the microMIPS or MIPS16e instruction sets.
--- arch/mips/include/asm/break.h | 8 ++++++++ arch/mips/include/asm/bug.h | 8 ++++++++ arch/mips/include/asm/dsp.h | 6 +++++- arch/mips/include/asm/futex.h | 4 ++++ arch/mips/include/asm/paccess.h | 2 ++ arch/mips/include/asm/uaccess.h | 14 ++++++++++++-- arch/mips/kernel/proc.c | 27 ++++++++++++++------------- arch/mips/kernel/ptrace.c | 4 ++++ arch/mips/mm/fault.c | 2 ++ 9 files changed, 59 insertions(+), 16 deletions(-)
arch/mips/include/asm/break.h +8 -0
@@ -27,6 +27,14 @@#define BRK_STACKOVERFLOW 9/* For Ada stackchecking */ #define BRK_NORLD 10/* No rld found - not used by Linux/MIPS */ #define _BRK_THREADBP 11/* For threads, user bp (used by debuggers) */ + +/* microMIPS definitions */ +#define MM_BRK_BUG 12/* Used by BUG() */ +#define MM_BRK_KDB 13/* Used in KDB_ENTER() */ +#define MM_BRK_MEMU 14/* Used by FPU emulator */ +#define MM_BRK_MULOVF 15/* Multiply overflow */ + +/* MIPS32/64 definitions */ #define BRK_BUG 512/* Used by BUG() */ #define BRK_KDB 513/* Used in KDB_ENTER() */ #define BRK_MEMU 514/* Used by FPU emulator */
arch/mips/include/asm/bug.h +8 -0
@@ -10,7 +10,11 @@static inline void __noreturn BUG (void ) { +#ifdef CONFIG_CPU_MICROMIPS + __asm__ __volatile__("break %0" : :"i" (MM_BRK_BUG )); +#else __asm__ __volatile__("break %0" : :"i" (BRK_BUG )); +#endif unreachable (); }
@@ -27,7 +31,11 @@ static inline void __BUG_ON(unsigned long condition)return ; } __asm__ __volatile__("tne $0, %0, %1" +#ifdef CONFIG_CPU_MICROMIPS + : :"r" (condition),"i" (MM_BRK_BUG )); +#else : : "r" (condition), "i" (BRK_BUG)); +#endif }#define BUG_ON (C ) __BUG_ON((unsigned long)(C))
arch/mips/include/asm/dsp.h +5 -1
@@ -10,13 +10,17 @@#ifndef _ASM_DSP_H#define _ASM_DSP_H -#include <asm/cpu.h> +#include <linux/cpu.h> #include <asm/cpu-features.h> #include <asm/hazards.h> #include <asm/mipsregs.h> #define DSP_DEFAULT 0x00000000 +#ifdef CONFIG_CPU_MICROMIPS +#define DSP_MASK 0x7f +#else #define DSP_MASK 0x3ff +#endif #define __enable_dsp_hazard () \ do { \
arch/mips/include/asm/futex.h +4 -0
@@ -31,6 +31,7 @@" beqzl $1, 1b \n" \ __WEAK_LLSC_MB \"3: \n" \ +" .insn \n" \" .set pop \n" \" .set mips0 \n" \" .section .fixup,\"ax\" \n" \
@@ -57,6 +58,7 @@" beqz $1, 1b \n" \ __WEAK_LLSC_MB \"3: \n" \ +" .insn \n" \" .set pop \n" \" .set mips0 \n" \" .section .fixup,\"ax\" \n" \
@@ -156,6 +158,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr," beqzl $1, 1b \n" __WEAK_LLSC_MB"3: \n" +" .insn \n" " .set pop \n" " .section .fixup,\"ax\" \n" "4: li %0, %6 \n"
@@ -183,6 +186,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr," beqz $1, 1b \n" __WEAK_LLSC_MB"3: \n" +" .insn \n" " .set pop \n" " .section .fixup,\"ax\" \n" "4: li %0, %6 \n"
arch/mips/include/asm/paccess.h +2 -0
@@ -56,6 +56,7 @@ struct __large_pstruct { unsigned long buf[100]; };"1:\t" insn"\t%1,%2\n\t" \"move\t%0,$0\n" \"2:\n\t" \ +".insn\n\t" \".section\t.fixup,\"ax\"\n" \"3:\tli\t%0,%3\n\t" \"move\t%1,$0\n\t" \
@@ -94,6 +95,7 @@ extern void __get_dbe_unknown(void);"1:\t" insn"\t%1,%2\n\t" \"move\t%0,$0\n" \"2:\n\t" \ +".insn\n\t" \".section\t.fixup,\"ax\"\n" \"3:\tli\t%0,%3\n\t" \"j\t2b\n\t" \
arch/mips/include/asm/uaccess.h +12 -2
@@ -261,6 +261,7 @@ do { \ __asm__ __volatile__( \"1: " insn" %1, %3 \n" \"2: \n" \ +" .insn \n" \" .section .fixup,\"ax\" \n" \"3: li %0, %4 \n" \ " j 2b \n" \
@@ -287,7 +288,9 @@ do { \ __asm__ __volatile__( \"1: lw %1, (%3) \n" \"2: lw %D1, 4(%3) \n" \ -"3: .section .fixup,\"ax\" \n" \ +"3: \n" \ +" .insn \n" \ +" .section .fixup,\"ax\" \n" \"4: li %0, %4 \n" \" move %1, $0 \n" \ " move %D1, $0 \n" \
@@ -355,6 +358,7 @@ do { \ __asm__ __volatile__( \"1: " insn" %z2, %3 # __put_user_asm\n" \"2: \n" \ +" .insn \n" \" .section .fixup,\"ax\" \n" \"3: li %0, %4 \n" \ " j 2b \n" \
@@ -373,6 +377,7 @@ do { \"1: sw %2, (%3) # __put_user_asm_ll32 \n" \"2: sw %D2, 4(%3) \n" \"3: \n" \ +" .insn \n" \" .section .fixup,\"ax\" \n" \"4: li %0, %4 \n" \" j 3b \n" \
@@ -524,6 +529,7 @@ do { \ __asm__ __volatile__( \"1: " insn" %1, %3 \n" \"2: \n" \ +" .insn \n" \" .section .fixup,\"ax\" \n" \"3: li %0, %4 \n" \ " j 2b \n" \
@@ -549,7 +555,9 @@ do { \"1: ulw %1, (%3) \n" \"2: ulw %D1, 4(%3) \n" \" move %0, $0 \n" \ -"3: .section .fixup,\"ax\" \n" \ +"3: \n" \ +" .insn \n" \ +" .section .fixup,\"ax\" \n" \"4: li %0, %4 \n" \" move %1, $0 \n" \" move %D1, $0 \n" \
@@ -616,6 +624,7 @@ do { \ __asm__ __volatile__( \"1: " insn" %z2, %3 # __put_user_unaligned_asm\n" \"2: \n" \ +" .insn \n" \" .section .fixup,\"ax\" \n" \"3: li %0, %4 \n" \ " j 2b \n" \
@@ -634,6 +643,7 @@ do { \"1: sw %2, (%3) # __put_user_unaligned_asm_ll32 \n" \"2: sw %D2, 4(%3) \n" \"3: \n" \ +" .insn \n" \" .section .fixup,\"ax\" \n" \"4: li %0, %4 \n" \" j 3b \n" \
arch/mips/kernel/proc.c +14 -13
@@ -41,29 +41,30 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_printf (m,"processor\t\t: %ld\n" , n);sprintf (fmt,"cpu model\t\t: %%s V%%d.%%d%s\n" , - cpu_data[n].options &MIPS_CPU_FPU ?" FPU V%d.%d" :"" ); + cpu_data[n].options &MIPS_CPU_FPU ?" FPU V%d.%d" :"" );seq_printf (m, fmt, __cpu_name[n], - (version >>4 ) &0x0f , version &0x0f , - (fp_vers >>4 ) &0x0f , fp_vers &0x0f ); + (version >>4 ) &0x0f , version &0x0f , + (fp_vers >>4 ) &0x0f , fp_vers &0x0f );seq_printf (m,"BogoMIPS\t\t: %u.%02u\n" , - cpu_data[n].udelay_val / (500000 /HZ ), - (cpu_data[n].udelay_val / (5000 /HZ )) %100 ); + cpu_data[n].udelay_val / (500000 /HZ ), + (cpu_data[n].udelay_val / (5000 /HZ )) %100 );seq_printf (m,"wait instruction\t: %s\n" , cpu_wait ?"yes" :"no" );seq_printf (m,"microsecond timers\t: %s\n" , - cpu_has_counter ?"yes" :"no" ); + cpu_has_counter ?"yes" :"no" );seq_printf (m,"tlb_entries\t\t: %d\n" , cpu_data[n].tlbsize);seq_printf (m,"extra interrupt vector\t: %s\n" , - cpu_has_divec ?"yes" :"no" ); + cpu_has_divec ?"yes" :"no" );seq_printf (m,"hardware watchpoint\t: %s" , - cpu_has_watch ?"yes, " :"no\n" ); + cpu_has_watch ?"yes, " :"no\n" );if (cpu_has_watch) {seq_printf (m,"count: %d, address/irw mask: [" , - cpu_data[n].watch_reg_count); + cpu_data[n].watch_reg_count);for (i =0 ; i < cpu_data[n].watch_reg_count; i++)seq_printf (m,"%s0x%04x" , i ?", " :"" , - cpu_data[n].watch_reg_masks[i]); + cpu_data[n].watch_reg_masks[i]);seq_printf (m,"]\n" ); } +seq_printf (m,"microMIPS\t\t: %s\n" , cpu_has_mmips ?"yes" :"no" ); seq_printf(m, "ASEs implemented\t:%s%s%s%s%s%s\n", cpu_has_mips16 ? " mips16" : "", cpu_has_mdmx ? " mdmx" : "",
@@ -73,13 +74,13 @@ static int show_cpuinfo(struct seq_file *m, void *v) cpu_has_mipsmt ?" mt" :"" );seq_printf (m,"shadow register sets\t: %d\n" , - cpu_data[n].srsets); + cpu_data[n].srsets);seq_printf (m,"kscratch registers\t: %d\n" , -hweight8 (cpu_data[n].kscratch_mask)); +hweight8 (cpu_data[n].kscratch_mask));seq_printf (m,"core\t\t\t: %d\n" , cpu_data[n].core);sprintf (fmt,"VCE%%c exceptions\t\t: %s\n" , - cpu_has_vce ?"%u" :"not available" ); + cpu_has_vce ?"%u" :"not available" );seq_printf (m, fmt,'D' , vced_count);seq_printf (m, fmt,'I' , vcei_count);seq_printf (m,"\n" );
arch/mips/kernel/ptrace.c +4 -0
@@ -364,6 +364,7 @@ long arch_ptrace(struct task_struct *child, long request,preempt_enable ();break ; } +#ifndef CONFIG_CPU_MICROMIPS case DSP_BASE ... DSP_BASE + 5: {dspreg_t *dregs;
@@ -384,6 +385,7 @@ long arch_ptrace(struct task_struct *child, long request, } tmp = child->thread.dsp.dspcontrol;break ; +#endif default : tmp =0 ; ret = -EIO ;
@@ -453,6 +455,7 @@ long arch_ptrace(struct task_struct *child, long request,case FPC_CSR : child->thread.fpu.fcr31 = data;break ; +#ifndef CONFIG_CPU_MICROMIPS case DSP_BASE ... DSP_BASE + 5: {dspreg_t *dregs;
@@ -472,6 +475,7 @@ long arch_ptrace(struct task_struct *child, long request, } child->thread.dsp.dspcontrol = data;break ; +#endif default :/* The rest are not allowed. */ ret = -EIO ;
arch/mips/mm/fault.c +2 -0
@@ -25,6 +25,7 @@#include <asm/uaccess.h> #include <asm/ptrace.h> #include <asm/highmem.h> /* For VMALLOC_END */ +#include <asm/tlbdebug.h> #include <linux/kdebug.h> /*
@@ -231,6 +232,7 @@ no_context:"virtual address %0*lx, epc == %0*lx, ra == %0*lx\n" ,raw_smp_processor_id (), field, address, field, regs->cp0_epc, field, regs->regs[31]); +dump_tlb_all ();die ("Oops" , regs); out_of_memory:
Signature · 1 line
1.7.9.6
PATCH 5/9 MIPS: Add support for microMIPS instructions.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
The MIPS micro-assembler needs to use microMIPS instructions when building all of the core exception handlers.
--- arch/mips/include/asm/inst.h | 882 +++++++++++++++++++++++++++++++++++--- arch/mips/include/asm/mipsregs.h | 359 +++++++--------- arch/mips/mm/uasm.c | 174 +++++++- 3 files changed, 1134 insertions(+), 281 deletions(-)
arch/mips/include/asm/inst.h +828 -54
@@ -5,8 +5,9 @@* License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 1996, 2000 by Ralf Baechle -* Copyright (C) 2006 by Thiemo Seufer +* Copyright (C) 1996, 2000 Ralf Baechle +* Copyright (C) 2006 Thiemo Seufer +* Copyright (C) 2011 MIPS Technologies, Inc. */ #ifndef _ASM_INST_H#define _ASM_INST_H
@@ -116,7 +117,7 @@ enum bcop_op {enum cop0_coi_func { tlbr_op =0x01 , tlbwi_op =0x02 , tlbwr_op =0x06 , tlbp_op =0x08 , - rfe_op =0x10 , eret_op =0x18 + rfe_op =0x10 , eret_op =0x18 , };/*
@@ -261,85 +262,523 @@ struct ma_format { /* FPU multipy and add format (MIPS IV) */ unsigned int fmt : 2; }; -struct b_format {/* BREAK and SYSCALL */ +struct b_format {/* BREAK and SYSCALL */ unsigned int opcode:6 ;unsigned int code:20 ;unsigned int func:6 ; }; +struct fb_format {/* FPU branch format */ +unsigned int opcode:6 ; +unsigned int bc:5 ; +unsigned int cc:3 ; +unsigned int flag:2 ; +unsigned int simmediate:16 ; +}; + +struct fp0_format {/* FPU multipy and add format (MIPS32) */ +unsigned int opcode:6 ; +unsigned int fmt:5 ; +unsigned int ft:5 ; +unsigned int fs:5 ; +unsigned int fd:5 ; +unsigned int func:6 ; +}; + +struct mm_fp0_format {/* FPU multipy and add format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int ft:5 ; +unsigned int fs:5 ; +unsigned int fd:5 ; +unsigned int fmt:3 ; +unsigned int op:2 ; +unsigned int func:6 ; +}; + +struct fp1_format {/* FPU mfc1 and cfc1 format (MIPS32) */ +unsigned int opcode:6 ; +unsigned int op:5 ; +unsigned int rt:5 ; +unsigned int fs:5 ; +unsigned int fd:5 ; +unsigned int func:6 ; +}; + +struct mm_fp1_format {/* FPU mfc1 and cfc1 format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int rt:5 ; +unsigned int fs:5 ; +unsigned int fmt:2 ; +unsigned int op:8 ; +unsigned int func:6 ; +}; + +struct mm_fp2_format {/* FPU movt and movf format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int cc:3 ; +unsigned int zero:2 ; +unsigned int fmt:2 ; +unsigned int op:3 ; +unsigned int func:6 ; +}; + +struct mm_fp3_format {/* FPU abs and neg format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int rt:5 ; +unsigned int fs:5 ; +unsigned int fmt:3 ; +unsigned int op:7 ; +unsigned int func:6 ; +}; + +struct mm_fp4_format {/* FPU c.cond format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int rt:5 ; +unsigned int fs:5 ; +unsigned int cc:3 ; +unsigned int fmt:3 ; +unsigned int cond:4 ; +unsigned int func:6 ; +}; + +struct mm_fp5_format {/* FPU lwxc1 and swxc1 format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int index:5 ; +unsigned int base:5 ; +unsigned int fd:5 ; +unsigned int op:5 ; +unsigned int func:6 ; +}; + +struct fp6_format {/* FPU madd and msub format (MIPS IV) */ +unsigned int opcode:6 ; +unsigned int fr:5 ; +unsigned int ft:5 ; +unsigned int fs:5 ; +unsigned int fd:5 ; +unsigned int func:6 ; +}; + +struct mm_fp6_format {/* FPU madd and msub format (micro_mips) */ +unsigned int opcode:6 ; +unsigned int ft:5 ; +unsigned int fs:5 ; +unsigned int fd:5 ; +unsigned int fr:5 ; +unsigned int func:6 ; +}; + +struct mm16b1_format {/* micro_mips 16-bit branch format */ +unsigned int opcode:6 ; +unsigned int rs:3 ; +signed int simmediate:7 ; +unsigned int duplicate:16 ;/* a copy of the instn */ +}; + +struct mm16b0_format {/* micro_mips 16-bit branch format */ +unsigned int opcode:6 ; +signed int simmediate:10 ; +unsigned int duplicate:16 ;/* a copy of the instn */ +}; + +struct mm_i_format {/* Immediate format (addi, lw, ...) */ +unsigned int opcode:6 ; +unsigned int rt:5 ; +unsigned int rs:5 ; +signed int simmediate:16 ; +}; + +/* MIPS16e */ + +struct rr { +unsigned int opcode:5 ; +unsigned int rx:3 ; +unsigned int nd:1 ; +unsigned int l:1 ; +unsigned int ra:1 ; +unsigned int func:5 ; +}; + +struct jal { +unsigned int opcode:5 ; +unsigned int x:1 ; +unsigned int imm20_16:5 ; +signed int imm25_21:5 ; +/* unsigned int imm20_15:0; here is only first 16bits in first HW */ +}; + +struct i64 { +unsigned int opcode:5 ; +unsigned int func:3 ; +unsigned int imm:8 ; +}; + +struct ri64 { +unsigned int opcode:5 ; +unsigned int func:3 ; +unsigned int ry:3 ; +unsigned int imm:5 ; +}; + +struct ri { +unsigned int opcode:5 ; +unsigned int rx:3 ; +unsigned int imm:8 ; +}; + +struct rri { +unsigned int opcode:5 ; +unsigned int rx:3 ; +unsigned int ry:3 ; +unsigned int imm:5 ; +}; + +struct i8 { +unsigned int opcode:5 ; +unsigned int func:3 ; +unsigned int imm:8 ; +}; + +struct mm_m_format { +unsigned int opcode:6 ; +unsigned int rd:5 ; +unsigned int base:5 ; +unsigned int func:4 ; +signed int simmediate:12 ; +}; + +struct mm_x_format { +unsigned int opcode:6 ; +unsigned int index:5 ; +unsigned int base:5 ; +unsigned int rd:5 ; +unsigned int func:11 ; +}; + +struct mm16_m_format { +unsigned int opcode:6 ; +unsigned int func:4 ; +unsigned int rlist:2 ; +unsigned int imm:4 ; +unsigned int duplicate:16 ;/* a copy of the instn */ +}; + +struct mm16_rb_format { +unsigned int opcode:6 ; +unsigned int rt:3 ; +unsigned int base:3 ; +signed int simmediate:4 ; +unsigned int duplicate:16 ;/* a copy of the instn */ +}; + +struct mm16_r5_format { +unsigned int opcode:6 ; +unsigned int rt:5 ; +signed int simmediate:5 ; +unsigned int duplicate:16 ;/* a copy of the instn */ +}; + +struct mm16_r3_format { +unsigned int opcode:6 ; +unsigned int rt:3 ; +signed int simmediate:7 ; +unsigned int duplicate:16 ;/* a copy of the instn */ +}; +#elif defined(__MIPSEL__) -struct j_format {/* Jump format */ -unsigned int target :26 ; -unsigned int opcode :6 ; +struct j_format {/* Jump format */ +unsigned int target:26 ; +unsigned int opcode:6 ; }; -struct i_format {/* Immediate format */ -signed int simmediate :16 ; -unsigned int rt :5 ; -unsigned int rs :5 ; -unsigned int opcode :6 ; +struct i_format {/* Immediate format */ +signed int simmediate:16 ; +unsigned int rt:5 ; +unsigned int rs:5 ; +unsigned int opcode:6 ; }; -struct u_format {/* Unsigned immediate format */ -unsigned int uimmediate :16 ; -unsigned int rt :5 ; -unsigned int rs :5 ; -unsigned int opcode :6 ; +struct u_format {/* Unsigned immediate format */ +unsigned int uimmediate:16 ; +unsigned int rt:5 ; +unsigned int rs:5 ; +unsigned int opcode:6 ; }; -struct c_format {/* Cache (>= R6000) format */ -unsigned int simmediate :16 ; -unsigned int cache :2 ; -unsigned int c_op :3 ; -unsigned int rs :5 ; -unsigned int opcode :6 ; +struct c_format {/* Cache (>= R6000) format */ +unsigned int simmediate:16 ; +unsigned int cache:2 ; +unsigned int c_op:3 ; +unsigned int rs:5 ; +unsigned int opcode:6 ; }; -struct r_format {/* Register format */ -unsigned int func :6 ; -unsigned int re :5 ; -unsigned int rd :5 ; -unsigned int rt :5 ; -unsigned int rs :5 ; -unsigned int opcode :6 ; +struct r_format {/* Register format */ +unsigned int func:6 ; +unsigned int re:5 ; +unsigned int rd:5 ; +unsigned int rt:5 ; +unsigned int rs:5 ; +unsigned int opcode:6 ; }; -struct p_format {/* Performance counter format (R10000) */ -unsigned int func :6 ; -unsigned int re :5 ; -unsigned int rd :5 ; -unsigned int rt :5 ; -unsigned int rs :5 ; -unsigned int opcode :6 ; +struct p_format {/* Performance counter format (R10000) */ +unsigned int func:6 ; +unsigned int re:5 ; +unsigned int rd:5 ; +unsigned int rt:5 ; +unsigned int rs:5 ; +unsigned int opcode:6 ; }; -struct f_format {/* FPU register format */ -unsigned int func :6 ; -unsigned int re :5 ; -unsigned int rd :5 ; -unsigned int rt :5 ; -unsigned int fmt :4 ; - unsigned int : 1; -unsigned int opcode :6 ; +struct f_format {/* FPU register format */ +unsigned int func:6 ; +unsigned int re:5 ; +unsigned int rd:5 ; +unsigned int rt:5 ; +unsigned int fmt:4 ; + unsigned int:1; +unsigned int opcode:6 ; }; -struct ma_format {/* FPU multipy and add format (MIPS IV) */ -unsigned int fmt :2 ; -unsigned int func :4 ; -unsigned int fd :5 ; -unsigned int fs :5 ; -unsigned int ft :5 ; -unsigned int fr :5 ; -unsigned int opcode :6 ; +struct ma_format {/* FPU multipy and add format (MIPS IV) */ +unsigned int fmt:2 ; +unsigned int func:4 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int ft:5 ; +unsigned int fr:5 ; +unsigned int opcode:6 ; }; -struct b_format {/* BREAK and SYSCALL */ +struct b_format {/* BREAK and SYSCALL */ unsigned int func:6 ;unsigned int code:20 ;unsigned int opcode:6 ; }; +struct fb_format {/* FPU branch format */ +unsigned int simmediate:16 ; +unsigned int flag:2 ; +unsigned int cc:3 ; +unsigned int bc:5 ; +unsigned int opcode:6 ; +}; + +struct fp0_format {/* FPU multipy and add format (MIPS32) */ +unsigned int func:6 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int ft:5 ; +unsigned int fmt:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp0_format {/* FPU multipy and add format (micro_mips) */ +unsigned int func:6 ; +unsigned int op:2 ; +unsigned int fmt:3 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int ft:5 ; +unsigned int opcode:6 ; +}; + +struct fp1_format {/* FPU mfc1 and cfc1 format (MIPS32) */ +unsigned int func:6 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int rt:5 ; +unsigned int op:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp1_format {/* FPU mfc1 and cfc1 format (micro_mips) */ +unsigned int func:6 ; +unsigned int op:8 ; +unsigned int fmt:2 ; +unsigned int fs:5 ; +unsigned int rt:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp2_format {/* FPU movt and movf format (micro_mips) */ +unsigned int func:6 ; +unsigned int op:3 ; +unsigned int fmt:2 ; +unsigned int zero:2 ; +unsigned int cc:3 ; +unsigned int fs:5 ; +unsigned int fd:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp3_format {/* FPU abs and neg format (micro_mips) */ +unsigned int func:6 ; +unsigned int op:7 ; +unsigned int fmt:3 ; +unsigned int fs:5 ; +unsigned int rt:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp4_format {/* FPU c.cond format (micro_mips) */ +unsigned int func:6 ; +unsigned int cond:4 ; +unsigned int fmt:3 ; +unsigned int cc:3 ; +unsigned int fs:5 ; +unsigned int rt:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp5_format {/* FPU lwxc1 and swxc1 format (micro_mips) */ +unsigned int func:6 ; +unsigned int op:5 ; +unsigned int fd:5 ; +unsigned int base:5 ; +unsigned int index:5 ; +unsigned int opcode:6 ; +}; + +struct fp6_format {/* FPU madd and msub format (MIPS IV) */ +unsigned int func:6 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int ft:5 ; +unsigned int fr:5 ; +unsigned int opcode:6 ; +}; + +struct mm_fp6_format {/* FPU madd and msub format (micro_mips) */ +unsigned int func:6 ; +unsigned int fr:5 ; +unsigned int fd:5 ; +unsigned int fs:5 ; +unsigned int ft:5 ; +unsigned int opcode:6 ; +}; + +struct mm16b1_format {/* micro_mips 16-bit branch format */ +unsigned int duplicate:16 ;/* a copy of the instn */ +signed int simmediate:7 ; +unsigned int rs:3 ; +unsigned int opcode:6 ; +}; + +struct mm16b0_format {/* micro_mips 16-bit branch format */ +unsigned int duplicate:16 ;/* a copy of the instn */ +signed int simmediate:10 ; +unsigned int opcode:6 ; +}; + +struct mm_i_format {/* Immediate format */ +signed int simmediate:16 ; +unsigned int rs:5 ; +unsigned int rt:5 ; +unsigned int opcode:6 ; +}; + +/* MIPS16e */ + +struct rr { +unsigned int func:5 ; +unsigned int ra:1 ; +unsigned int l:1 ; +unsigned int nd:1 ; +unsigned int rx:3 ; +unsigned int opcode:5 ; +}; + +struct jal { +/* unsigned int imm20_15:0; here is only first 16bits in first HW */ +signed int imm25_21:5 ; +unsigned int imm20_16:5 ; +unsigned int x:1 ; +unsigned int opcode:5 ; +}; + +struct i64 { +unsigned int imm:8 ; +unsigned int func:3 ; +unsigned int opcode:5 ; +}; + +struct ri64 { +unsigned int imm:5 ; +unsigned int ry:3 ; +unsigned int func:3 ; +unsigned int opcode:5 ; +}; + +struct ri { +unsigned int imm:8 ; +unsigned int rx:3 ; +unsigned int opcode:5 ; +}; + +struct rri { +unsigned int imm:5 ; +unsigned int ry:3 ; +unsigned int rx:3 ; +unsigned int opcode:5 ; +}; + +struct i8 { +unsigned int imm:8 ; +unsigned int func:3 ; +unsigned int opcode:5 ; +}; + +struct mm_m_format { +signed int simmediate:12 ; +unsigned int func:4 ; +unsigned int base:5 ; +unsigned int rd:5 ; +unsigned int opcode:6 ; +}; + +struct mm_x_format { +unsigned int func:11 ; +unsigned int rd:5 ; +unsigned int base:5 ; +unsigned int index:5 ; +unsigned int opcode:6 ; +}; + +struct mm16_m_format { +unsigned int duplicate:16 ;/* a copy of the instn */ +unsigned int imm:4 ; +unsigned int rlist:2 ; +unsigned int func:4 ; +unsigned int opcode:6 ; +}; + +struct mm16_rb_format { +unsigned int duplicate:16 ;/* a copy of the instn */ +signed int simmediate:4 ; +unsigned int base:3 ; +unsigned int rt:3 ; +unsigned int opcode:6 ; +}; + +struct mm16_r5_format { +unsigned int duplicate:16 ;/* a copy of the instn */ +signed int simmediate:5 ; +unsigned int rt:5 ; +unsigned int opcode:6 ; +}; + +struct mm16_r3_format { +unsigned int duplicate:16 ;/* a copy of the instn */ +signed int simmediate:7 ; +unsigned int rt:3 ; +unsigned int opcode:6 ; +}; +#else /* !defined (__MIPSEB__) && !defined (__MIPSEL__) */ #error "MIPS but neither __MIPSEL__ nor __MIPSEB__?"#endif
@@ -356,6 +795,26 @@ union mips_instruction {struct f_format f_format;struct ma_format ma_format;struct b_format b_format; +struct mm16b0_format mm16b0_format; +struct mm16b1_format mm16b1_format; +struct mm_i_format mm_i_format; +struct fb_format fb_format; +struct fp0_format fp0_format; +struct fp1_format fp1_format; +struct fp6_format fp6_format; +struct mm_fp0_format mm_fp0_format; +struct mm_fp1_format mm_fp1_format; +struct mm_fp2_format mm_fp2_format; +struct mm_fp3_format mm_fp3_format; +struct mm_fp4_format mm_fp4_format; +struct mm_fp5_format mm_fp5_format; +struct mm_fp6_format mm_fp6_format; +struct mm_m_format mm_m_format; +struct mm_x_format mm_x_format; +struct mm16_m_format mm16_m_format; +struct mm16_rb_format mm16_rb_format; +struct mm16_r3_format mm16_r3_format; +struct mm16_r5_format mm16_r5_format; };/* HACHACHAHCAHC ... */
@@ -418,4 +877,319 @@ union mips_instruction {typedef unsigned int mips_instruction ; +/* The following are for micro_mips mode */ +#define MM_16_OPCODE_SFT 10 +#define MM_NOP16 0x0c00 +#define MM_POOL32A_MINOR_MSK 0x3f +#define MM_POOL32A_MINOR_SFT 0x6 +#define MIPS32_COND_FC 0x30 + +/* +* Major opcodes; micro_mips mode. +*/ +enum mm_major_op { + mm_pool32a_op, mm_pool16a_op, mm_lbu16_op, mm_move16_op, + mm_addi32_op, mm_lbu32_op, mm_sb32_op, mm_lb32_op, + mm_pool32b_op, mm_pool16b_op, mm_lhu16_op, mm_andi16_op, + mm_addiu32_op, mm_lhu32_op, mm_sh32_op, mm_lh32_op, + mm_pool32i_op, mm_pool16c_op, mm_lwsp16_op, mm_pool16d_op, + mm_ori32_op, mm_pool32f_op, mm_reserved1_op, mm_reserved2_op, + mm_pool32c_op, mm_lwgp16_op, mm_lw16_op, mm_pool16e_op, + mm_xori32_op, mm_jals32_op, mm_addiupc_op, mm_reserved3_op, + mm_reserved4_op, mm_pool16f_op, mm_sb16_op, mm_beqz16_op, + mm_slti32_op, mm_beq32_op, mm_swc132_op, mm_lwc132_op, + mm_reserved5_op, mm_reserved6_op, mm_sh16_op, mm_bnez16_op, + mm_sltiu32_op, mm_bne32_op, mm_sdc132_op, mm_ldc132_op, + mm_reserved7_op, mm_reserved8_op, mm_swsp16_op, mm_b16_op, + mm_andi32_op, mm_j32_op, mm_sd32_op, mm_ld32_op, + mm_reserved11_op, mm_reserved12_op, mm_sw16_op, mm_li16_op, + mm_jalx32_op, mm_jal32_op, mm_sw32_op, mm_lw32_op, +}; + +/* +* POOL32I minor opcodes. +*/ +enum mm_32i_minor_op { + mm_bltz_op, mm_bltzal_op, mm_bgez_op, mm_bgezal_op, + mm_blez_op, mm_bnezc_op, mm_bgtz_op, mm_beqzc_op, + mm_tlti_op, mm_tgei_op, mm_tltiu_op, mm_tgeiu_op, + mm_tnei_op, mm_lui_op, mm_teqi_op, mm_reserved13_op, + mm_synci_op, mm_bltzals_op, mm_reserved14_op, mm_bgezals_op, + mm_bc2f_op, mm_bc2t_op, mm_reserved15_op, mm_reserved16_op, + mm_reserved17_op, mm_reserved18_op, mm_bposge64_op, mm_bposge32_op, + mm_bc1f_op, mm_bc1t_op, mm_reserved19_op, mm_reserved20_op, + mm_bc1any2f_op, mm_bc1any2t_op, mm_bc1any4f_op, mm_bc1any4t_op, +}; + +/* +* POOL32A minor opcodes. +*/ +enum mm_32a_minor_op { + mm_sll32_op =0x000 , + mm_ins_op =0x00c , + mm_ext_op =0x02c , + mm_pool32axf_op =0x03c , + mm_srl32_op =0x040 , + mm_sra_op =0x080 , + mm_rotr_op =0x0c0 , + mm_lwxs_op =0x118 , + mm_addu32_op =0x150 , + mm_subu32_op =0x1d0 , + mm_and_op =0x250 , + mm_or32_op =0x290 , + mm_xor32_op =0x310 , +}; + +/* +* POOL32B functions. +*/ +enum mm_32b_func { + mm_lwc2_func =0x0 , + mm_lwp_func =0x1 , + mm_ldc2_func =0x2 , + mm_ldp_func =0x4 , + mm_lwm32_func =0x5 , + mm_cache_func =0x6 , + mm_ldm_func =0x7 , + mm_swc2_func =0x8 , + mm_swp_func =0x9 , + mm_sdc2_func =0xa , + mm_sdp_func =0xc , + mm_swm32_func =0xd , + mm_sdm_func =0xf , +}; + +/* +* POOL32C functions. +*/ +enum mm_32c_func { + mm_pref_func =0x2 , + mm_ll_func =0x3 , + mm_swr_func =0x9 , + mm_sc_func =0xb , + mm_lwu_func =0xe , +}; + +/* +* POOL32AXF minor opcodes. +*/ +enum mm_32axf_minor_op { + mm_mfc0_op =0x003 , + mm_mtc0_op =0x00b , + mm_tlbp_op =0x00d , + mm_jalr_op =0x03c , + mm_tlbr_op =0x04d , + mm_jalrhb_op =0x07c , + mm_tlbwi_op =0x08d , + mm_tlbwr_op =0x0cd , + mm_jalrs_op =0x13c , + mm_jalrshb_op =0x17c , + mm_syscall_op =0x22d , + mm_eret_op =0x3cd , +}; + +/* +* POOL32F minor opcodes. +*/ +enum mm_32f_minor_op { + mm_32f_00_op =0x00 , + mm_32f_01_op =0x01 , + mm_32f_02_op =0x02 , + mm_32f_10_op =0x08 , + mm_32f_11_op =0x09 , + mm_32f_12_op =0x0a , + mm_32f_20_op =0x10 , + mm_32f_30_op =0x18 , + mm_32f_40_op =0x20 , + mm_32f_41_op =0x21 , + mm_32f_42_op =0x22 , + mm_32f_50_op =0x28 , + mm_32f_51_op =0x29 , + mm_32f_52_op =0x2a , + mm_32f_60_op =0x30 , + mm_32f_70_op =0x38 , + mm_32f_73_op =0x3b , + mm_32f_74_op =0x3c , +}; + +/* +* POOL32F secondary minor opcodes. +*/ +enum mm_32f_10_minor_op { + mm_lwxc1_op =0x1 , + mm_swxc1_op, + mm_ldxc1_op, + mm_sdxc1_op, + mm_luxc1_op, + mm_suxc1_op, +}; + +enum mm_32f_func { + mm_lwxc1_func =0x048 , + mm_swxc1_func =0x088 , + mm_ldxc1_func =0x0c8 , + mm_sdxc1_func =0x108 , +}; + +/* +* POOL32F secondary minor opcodes. +*/ +enum mm_32f_40_minor_op { + mm_fmovf_op, + mm_fmovt_op, +}; + +/* +* POOL32F secondary minor opcodes. +*/ +enum mm_32f_60_minor_op { + mm_fadd_op, + mm_fsub_op, + mm_fmul_op, + mm_fdiv_op, +}; + +/* +* POOL32F secondary minor opcodes. +*/ +enum mm_32f_70_minor_op { + mm_fmovn_op, + mm_fmovz_op, +}; + +/* +* POOL32F secondary minor opcodes (POOL32FXF). +*/ +enum mm_32f_73_minor_op { + mm_fmov0_op =0x01 , + mm_fcvtl_op =0x04 , + mm_movf0_op =0x05 , + mm_frsqrt_op =0x08 , + mm_ffloorl_op =0x0c , + mm_fabs0_op =0x0d , + mm_fcvtw_op =0x24 , + mm_movt0_op =0x25 , + mm_fsqrt_op =0x28 , + mm_ffloorw_op =0x2c , + mm_fneg0_op =0x2d , + mm_cfc1_op =0x40 , + mm_frecip_op =0x48 , + mm_fceill_op =0x4c , + mm_fcvtd0_op =0x4d , + mm_ctc1_op =0x60 , + mm_fceilw_op =0x6c , + mm_fcvts0_op =0x6d , + mm_mfc1_op =0x80 , + mm_fmov1_op =0x81 , + mm_movf1_op =0x85 , + mm_ftruncl_op =0x8c , + mm_fabs1_op =0x8d , + mm_mtc1_op =0xa0 , + mm_movt1_op =0xa5 , + mm_ftruncw_op =0xac , + mm_fneg1_op =0xad , + mm_froundl_op =0xcc , + mm_fcvtd1_op =0xcd , + mm_froundw_op =0xec , + mm_fcvts1_op =0xed , +}; + +/* +* POOL16C minor opcodes. +*/ +enum mm_16c_minor_op { + mm_lwm16_op =0x04 , + mm_swm16_op =0x05 , + mm_jr16_op =0x18 , + mm_jrc_op =0x1a , + mm_jalr16_op =0x1c , + mm_jalrs16_op =0x1e , +}; + +/* +* POOL16D minor opcodes. +*/ +enum mm_16d_minor_op { + mm_addius5_func, + mm_addiusp_func, +}; + +struct decoded_instn { +mips_instruction insn; +mips_instruction next_insn; +int pc_inc; +int next_pc_inc; +int micro_mips_mode; +}; + +/* recode table from MIPS16e register notation to GPR */ +extern int mips16e_reg2gpr[]; + +union mips16e_instruction { +unsigned int full:16 ; +struct rr rr; +struct jal jal; +struct i64 i64; +struct ri64 ri64; +struct ri ri; +struct rri rri; +struct i8 i8; +}; + +enum MIPS16e_ops { + MIPS16e_jal_op =003 , + MIPS16e_ld_op =007 , + MIPS16e_i8_op =014 , + MIPS16e_sd_op =017 , + MIPS16e_lb_op =020 , + MIPS16e_lh_op =021 , + MIPS16e_lwsp_op =022 , + MIPS16e_lw_op =023 , + MIPS16e_lbu_op =024 , + MIPS16e_lhu_op =025 , + MIPS16e_lwpc_op =026 , + MIPS16e_lwu_op =027 , + MIPS16e_sb_op =030 , + MIPS16e_sh_op =031 , + MIPS16e_swsp_op =032 , + MIPS16e_sw_op =033 , + MIPS16e_rr_op =035 , + MIPS16e_extend_op =036 , + MIPS16e_i64_op =037 , +}; + +enum MIPS16e_i64_func { + MIPS16e_ldsp_func, + MIPS16e_sdsp_func, + MIPS16e_sdrasp_func, + MIPS16e_dadjsp_func, + MIPS16e_ldpc_func, +}; + +enum MIPS16e_rr_func { + MIPS16e_jr_func, +}; + +enum MIPS6e_i8_func { + MIPS16e_swrasp_func =02 , +}; + +/* +* This functions returns 1 if the micro_mips instr is a 16 bit instr. +* Otherwise return 0. +*/ +#define MIPS_ISA_MODE 01 +#define is16mode (regs) (regs->cp0_epc & MIPS_ISA_MODE) + +static inline int mm_is16bit (u16 instr) +{ +/* take LS 3 bits */ +u16 opcode_low = (instr >>MM_16_OPCODE_SFT ) &0x7 ; + +if (opcode_low >=1 && opcode_low <=3 ) +return 1 ; +else +return 0 ; +} +#endif /* _ASM_INST_H */
arch/mips/include/asm/mipsregs.h +153 -206
490 lines not on this page · raw message
arch/mips/mm/uasm.c +153 -21
311 lines not on this page · raw message
Signature · 1 line
1.7.9.6
PATCH 6/9 MIPS: Add support for microMIPS exception handling.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
All exceptions must be taken in microMIPS mode, never in MIPS32R2 mode or the kernel falls apart. A few 'nop' instructions are used to maintain the correct alignment of microMIPS versions of the exception vectors.
--- arch/mips/include/asm/stackframe.h | 12 +- arch/mips/kernel/genex.S | 82 +++++--- arch/mips/kernel/scall32-o32.S | 22 ++- arch/mips/kernel/smtc-asm.S | 3 + arch/mips/kernel/traps.c | 377 +++++++++++++++++++++++++----------- arch/mips/mm/tlbex.c | 21 ++ arch/mips/mti-sead3/sead3-init.c | 57 +++++- 7 files changed, 424 insertions(+), 150 deletions(-)
arch/mips/include/asm/stackframe.h +6 -6
@@ -139,7 +139,7 @@ 1: move ra, k0 li k0, 3 mtc0 k0, $22 -#endif /* CONFIG_CPU_LOONGSON2F */ +#endif /* CONFIG_CPU_JUMP_WORKAROUNDS */ #if defined(CONFIG_32BIT ) || defined(KBUILD_64BIT_SYM32 ) lui k1, %hi(kernelsp) #else
@@ -189,6 +189,7 @@ LONG_S $0, PT_R0(sp) mfc0 v1, CP0_STATUS LONG_S $2, PT_R2(sp) + LONG_S v1, PT_STATUS(sp)#ifdef CONFIG_MIPS_MT_SMTC /* * Ideally, these instructions would be shuffled in
@@ -200,21 +201,20 @@ LONG_S k0, PT_TCSTATUS(sp)#endif /* CONFIG_MIPS_MT_SMTC */ LONG_S $4, PT_R4(sp) - LONG_S $5, PT_R5(sp) - LONG_S v1, PT_STATUS(sp) mfc0 v1, CP0_CAUSE - LONG_S $6, PT_R6(sp) - LONG_S $7, PT_R7(sp) + LONG_S $5, PT_R5(sp) LONG_S v1, PT_CAUSE(sp) + LONG_S $6, PT_R6(sp) MFC0 v1, CP0_EPC + LONG_S $7, PT_R7(sp)#ifdef CONFIG_64BIT LONG_S $8, PT_R8(sp) LONG_S $9, PT_R9(sp)#endif + LONG_S v1, PT_EPC(sp) LONG_S $25, PT_R25(sp) LONG_S $28, PT_R28(sp) LONG_S $31, PT_R31(sp) - LONG_S v1, PT_EPC(sp) ori $28, sp, _THREAD_MASK xori $28, _THREAD_MASK #ifdef CONFIG_CPU_CAVIUM_OCTEON
arch/mips/kernel/genex.S +60 -22
171 lines not on this page · raw message
arch/mips/kernel/scall32-o32.S +18 -4
@@ -143,15 +143,29 @@ stackargs: jr t1 addiu t1, 6f - 5f -2: lw t8, 28(t0) # argument #8 from usp -3: lw t7, 24(t0) # argument #7 from usp -4: lw t6, 20(t0) # argument #6 from usp -5: jr t1 +2: .insn + lw t8, 28(t0) # argument #8 from usp +3: .insn + lw t7, 24(t0) # argument #7 from usp +4: .insn + lw t6, 20(t0) # argument #6 from usp +5: .insn + jr t1 sw t5, 16(sp) # argument #5 to ksp +#ifdef CONFIG_CPU_MICROMIPS + ## FIXME: + sw t8, 28(sp) # argument #8 to ksp + nop + sw t7, 24(sp) # argument #7 to ksp + nop + sw t6, 20(sp) # argument #6 to ksp + nop +#else sw t8, 28(sp) # argument #8 to ksp sw t7, 24(sp) # argument #7 to ksp sw t6, 20(sp) # argument #6 to ksp +#endif 6: j stack_done # go back nop .set pop
arch/mips/kernel/smtc-asm.S +3 -0
@@ -49,6 +49,9 @@ CAN WE PROVE THAT WE WON'T DO THIS IF INTS DISABLED?? .text .align 5 FEXPORT(__smtc_ipi_vector) +#ifdef CONFIG_CPU_MICROMIPS + nop +#endif .set noat /* Disable thread scheduling to make Status update atomic */ DMT 27 # dmt k1
arch/mips/kernel/traps.c +263 -114
630 lines not on this page · raw message
arch/mips/mm/tlbex.c +21 -0
@@ -2021,6 +2021,13 @@ static void __cpuinit build_r4000_tlb_load_handler(void)uasm_l_nopage_tlbl (&l, p);build_restore_work_registers (&p); +#ifdef CONFIG_CPU_MICROMIPS +if ((unsigned long )tlb_do_page_fault_0 &1 ) { +uasm_i_lui (&p,K0 ,uasm_rel_hi ((long )tlb_do_page_fault_0)); +uasm_i_addiu (&p,K0 ,K0 ,uasm_rel_lo ((long )tlb_do_page_fault_0)); +uasm_i_jr (&p,K0 ); + } else +#endif uasm_i_j (&p, (unsigned long )tlb_do_page_fault_0 &0x0fffffff );uasm_i_nop (&p);
@@ -2068,6 +2075,13 @@ static void __cpuinit build_r4000_tlb_store_handler(void)uasm_l_nopage_tlbs (&l, p);build_restore_work_registers (&p); +#ifdef CONFIG_CPU_MICROMIPS +if ((unsigned long )tlb_do_page_fault_1 &1 ) { +uasm_i_lui (&p,K0 ,uasm_rel_hi ((long )tlb_do_page_fault_1)); +uasm_i_addiu (&p,K0 ,K0 ,uasm_rel_lo ((long )tlb_do_page_fault_1)); +uasm_i_jr (&p,K0 ); + } else +#endif uasm_i_j (&p, (unsigned long )tlb_do_page_fault_1 &0x0fffffff );uasm_i_nop (&p);
@@ -2116,6 +2130,13 @@ static void __cpuinit build_r4000_tlb_modify_handler(void)uasm_l_nopage_tlbm (&l, p);build_restore_work_registers (&p); +#ifdef CONFIG_CPU_MICROMIPS +if ((unsigned long )tlb_do_page_fault_1 &1 ) { +uasm_i_lui (&p,K0 ,uasm_rel_hi ((long )tlb_do_page_fault_1)); +uasm_i_addiu (&p,K0 ,K0 ,uasm_rel_lo ((long )tlb_do_page_fault_1)); +uasm_i_jr (&p,K0 ); + } else +#endif uasm_i_j (&p, (unsigned long )tlb_do_page_fault_1 &0x0fffffff );uasm_i_nop (&p);
arch/mips/mti-sead3/sead3-init.c +53 -4
97 lines not on this page · raw message
Signature · 1 line
1.7.9.6
PATCH 7/9 MIPS: Support microMIPS/MIPS16e handling of delay slots.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Add logic needed to properly calculate exceptions for delay slots when in microMIPS or MIPS16e mode.
--- arch/mips/include/asm/branch.h | 33 +++++++- arch/mips/kernel/branch.c | 183 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 213 insertions(+), 3 deletions(-)
arch/mips/include/asm/branch.h +32 -1
@@ -16,11 +16,16 @@ static inline int delay_slot(struct pt_regs *regs)return regs->cp0_cause &CAUSEF_BD ; } +extern int __isa_exception_epc (struct pt_regs *regs); +static inline unsigned long exception_epc (struct pt_regs *regs) { -if (!delay_slot (regs)) +if (likely (!delay_slot (regs)))return regs->cp0_epc; +if (is16mode (regs)) +return __isa_exception_epc (regs); +return regs->cp0_epc +4 ; }
@@ -29,9 +34,20 @@ static inline unsigned long exception_epc(struct pt_regs *regs)extern int __compute_return_epc (struct pt_regs *regs);extern int __compute_return_epc_for_insn (struct pt_regs *regs,union mips_instruction insn); +extern int __MIPS16e_compute_return_epc (struct pt_regs *regs); +extern int __microMIPS_compute_return_epc (struct pt_regs *regs); +/* only for MIPS32/64 but not 16bits variants */ static inline int compute_return_epc (struct pt_regs *regs) { +if (is16mode (regs)) { +if (cpu_has_mips16) +return __MIPS16e_compute_return_epc (regs); +if (cpu_has_mmips) +return __microMIPS_compute_return_epc (regs); +return regs->cp0_epc; + } +if (!delay_slot (regs)) { regs->cp0_epc +=4 ;return 0 ;
@@ -40,4 +56,19 @@ static inline int compute_return_epc(struct pt_regs *regs) return __compute_return_epc(regs); } +static inline int MIPS16e_compute_return_epc (struct pt_regs *regs, +union mips16e_instruction *inst) +{ +if (likely (!delay_slot (regs))) { +if (inst->ri.opcode == MIPS16e_extend_op) { + regs->cp0_epc +=4 ; +return 0 ; + } + regs->cp0_epc +=2 ; +return 0 ; + } + +return __MIPS16e_compute_return_epc (regs); +} +#endif /* _ASM_BRANCH_H */
arch/mips/kernel/branch.c +181 -2
209 lines not on this page · raw message
Signature · 1 line
1.7.9.6
PATCH 8/9 MIPS: Support microMIPS/MIPS16e unaligned accesses.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Add logic needed to properly handle unaligned accesses when in microMIPS or MIPS16e modes.
--- arch/mips/kernel/process.c | 101 +++ arch/mips/kernel/unaligned.c | 1496 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 1391 insertions(+), 206 deletions(-)
arch/mips/kernel/process.c +101 -0
@@ -7,6 +7,7 @@* Copyright (C) 2005, 2006 by Ralf Baechle ([email protected]) * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 2004 Thiemo Seufer +* Copyright (C) 2011 MIPS Technologies, Inc. */ #include <linux/errno.h> #include <linux/sched.h>
@@ -262,34 +263,115 @@ struct mips_frame_info {static inline int is_ra_save_ins (union mips_instruction *ip) { +#ifdef CONFIG_CPU_MICROMIPS +union mips_instruction mmi; + +/* +* swsp ra,offset +* swm16 reglist,offset(sp) +* swm32 reglist,offset(sp) +* sw32 ra,offset(sp) +* jradiussp - NOT SUPPORTED +* +* microMIPS is way more fun... +*/ +if (mm_is16bit (ip->halfword[0 ])) { + mmi.word = (ip->halfword[0 ] <<16 ); +return ((mmi.mm16_r5_format.opcode == mm_swsp16_op && + mmi.mm16_r5_format.rt ==31 ) || + (mmi.mm16_m_format.opcode == mm_pool16c_op && + mmi.mm16_m_format.func == mm_swm16_op)); + } +else { + mmi.halfword[0 ] = ip->halfword[1 ]; + mmi.halfword[1 ] = ip->halfword[0 ]; +return ((mmi.mm_m_format.opcode == mm_pool32b_op && + mmi.mm_m_format.rd >9 && + mmi.mm_m_format.base ==29 && + mmi.mm_m_format.func == mm_swm32_func) || + (mmi.i_format.opcode == mm_sw32_op && + mmi.i_format.rs ==29 && + mmi.i_format.rt ==31 )); + } +#else /* sw / sd $ra, offset($sp) */ return (ip->i_format.opcode == sw_op || ip->i_format.opcode == sd_op) && ip->i_format.rs ==29 && ip->i_format.rt ==31 ; +#endif }static inline int is_jal_jalr_jr_ins (union mips_instruction *ip) { +#ifdef CONFIG_CPU_MICROMIPS +/* +* jr16,jrc,jalr16,jalr16 +* jal +* jalr/jr,jalr.hb/jr.hb,jalrs,jalrs.hb +* jraddiusp - NOT SUPPORTED +* +* microMIPS is kind of more fun... +*/ +union mips_instruction mmi; + + mmi.word = (ip->halfword[0 ] <<16 ); + +if ((mmi.mm16_r5_format.opcode == mm_pool16c_op && + (mmi.mm16_r5_format.rt & mm_jr16_op) == mm_jr16_op) || + ip->j_format.opcode == mm_jal32_op) +return 1 ; +if (ip->r_format.opcode != mm_pool32a_op || + ip->r_format.func != mm_pool32axf_op) +return 0 ; +return (((ip->u_format.uimmediate >>6 ) & mm_jalr_op) == mm_jalr_op); +#else if (ip->j_format.opcode == jal_op)return 1 ;if (ip->r_format.opcode != spec_op)return 0 ;return ip->r_format.func == jalr_op || ip->r_format.func == jr_op; +#endif }static inline int is_sp_move_ins (union mips_instruction *ip) { +#ifdef CONFIG_CPU_MICROMIPS +/* +* addiusp -imm +* addius5 sp,-imm +* addiu32 sp,sp,-imm +* jradiussp - NOT SUPPORTED +* +* microMIPS is not more fun... +*/ +if (mm_is16bit (ip->halfword[0 ])) { +union mips_instruction mmi; + + mmi.word = (ip->halfword[0 ] <<16 ); +return ((mmi.mm16_r3_format.opcode == mm_pool16d_op && + mmi.mm16_r3_format.simmediate && mm_addiusp_func) || + (mmi.mm16_r5_format.opcode == mm_pool16d_op && + mmi.mm16_r5_format.rt ==29 )); + } +return (ip->mm_i_format.opcode == mm_addiu32_op && + ip->mm_i_format.rt ==29 && ip->mm_i_format.rs ==29 ); +#else /* addiu/daddiu sp,sp,-imm */ if (ip->i_format.rs !=29 || ip->i_format.rt !=29 )return 0 ;if (ip->i_format.opcode == addiu_op || ip->i_format.opcode == daddiu_op)return 1 ; +#endif return 0 ; }static int get_frame_info (struct mips_frame_info *info) { +#ifdef CONFIG_CPU_MICROMIPS +union mips_instruction *ip = (void *) (((char *) info->func) -1 ); +#else union mips_instruction *ip = info->func; +#endif unsigned max_insns = info->func_size /sizeof (union mips_instruction );unsigned i;
@@ -309,7 +391,26 @@ static int get_frame_info(struct mips_frame_info *info)break ;if (!info->frame_size) {if (is_sp_move_ins (ip)) + { +#ifdef CONFIG_CPU_MICROMIPS +if (mm_is16bit (ip->halfword[0 ])) + { +unsigned short tmp; + +if (ip->halfword[0 ] & mm_addiusp_func) + { + tmp = (((ip->halfword[0 ] >>1 ) &0x1ff ) <<2 ); + info->frame_size = -(signed short )(tmp | ((tmp &0x100 ) ?0xfe00 :0 )); + }else { + tmp = (ip->halfword[0 ] >>1 ); + info->frame_size = -(signed short )(tmp &0xf ); + } + ip = (void *) &ip->halfword[1 ]; + ip--; + } else +#endif info->frame_size = - ip->i_format.simmediate; + }continue ; }if (info->pc_offset ==-1 &&is_ra_save_ins (ip)) {
arch/mips/kernel/unaligned.c +1290 -206
1,621 lines not on this page · raw message
Signature · 1 line
1.7.9.6
PATCH 9/9 MIPS: Support microMIPS/MIPS16e floating point.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Add logic needed to do floating point emulation when in microMIPS or MIPS16e mode.
--- arch/mips/include/asm/fpu_emulator.h | 7 + arch/mips/math-emu/cp1emu.c | 766 ++++++++++++++++++++++++++++++---- arch/mips/math-emu/dsemul.c | 40 +- 3 files changed, 717 insertions(+), 96 deletions(-)
arch/mips/include/asm/fpu_emulator.h +7 -0
@@ -54,6 +54,12 @@ do { \extern int mips_dsemul (struct pt_regs *regs,mips_instruction ir,unsigned long cpc);extern int do_dsemulret (struct pt_regs *xcp); +extern int fpu_emulator_cop1Handler (struct pt_regs *xcp, +struct mips_fpu_struct *ctx,int has_fpu, +void *__user *fault_addr); +int process_fpemu_return (int sig,void __user *fault_addr); +int mm_isBranchInstr (struct pt_regs *regs,struct decoded_instn dec_insn, +unsigned long *contpc);/* * Instruction inserted following the badinst to further tag the sequence
@@ -64,5 +70,6 @@ extern int do_dsemulret(struct pt_regs *xcp);* Break instruction with special math emu break code set */ #define BREAK_MATH (0x0000000d | (BRK_MEMU << 16)) +#define MM_BREAK_MATH (0x00000007 | (MM_BRK_MEMU << 16))#endif /* _ASM_FPU_EMULATOR_H */
arch/mips/math-emu/cp1emu.c +677 -89
868 lines not on this page · raw message
arch/mips/math-emu/dsemul.c +33 -7
@@ -54,8 +54,15 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) extern asmlinkage void handle_dsemulret(void);struct emuframe __user *fr;int err; +int nop =0 ; -if (ir ==0 ) {/* a nop is easy */ +if (regs->cp0_epc &1 ) { +if ((ir >>16 ) ==MM_NOP16 ) + nop =1 ; + }else if (ir ==0 ) + nop =1 ; + +if (nop ==1 ) {/* a nop is easy */ regs->cp0_epc = cpc; regs->cp0_cause &= ~CAUSEF_BD ;return 0 ;
@@ -91,8 +98,17 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc)if (unlikely (!access_ok (VERIFY_WRITE , fr,sizeof (struct emuframe ))))return SIGBUS ; - err =__put_user (ir, &fr->emul); - err |=__put_user ((mips_instruction )BREAK_MATH , &fr->badinst); +if (regs->cp0_epc &1 ) { + err =__put_user (ir >>16 , (u16 __user *)(&fr->emul)); + err |=__put_user (ir &0xffff , (u16 __user *)((long )(&fr->emul) +2 )); + err |=__put_user (MM_BREAK_MATH >>16 , (u16 __user *)(&fr->badinst)); + err |=__put_user (MM_BREAK_MATH &0xffff , (u16 __user *)((long )(&fr->badinst) +2 )); + }else { + err =__put_user (ir, &fr->emul); + err |=__put_user ((mips_instruction )BREAK_MATH , &fr->badinst); + } + +/* NOTE: assume the 2nd instn is never executed => can leave as mips32 instr */ err |=__put_user ((mips_instruction )BD_COOKIE , &fr->cookie); err |=__put_user (cpc, &fr->epc);
@@ -101,7 +117,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc)return SIGBUS ; } - regs->cp0_epc = (unsigned long ) &fr->emul; + regs->cp0_epc = ((unsigned long ) &fr->emul) | (regs->cp0_epc &1 );flush_cache_sigtramp ((unsigned long )&fr->badinst);
@@ -114,9 +130,14 @@ int do_dsemulret(struct pt_regs *xcp)unsigned long epc;u32 insn, cookie;int err =0 ; +u32 break_math =BREAK_MATH ; +u16 instr[2 ]; + +if (xcp->cp0_epc &1 ) + break_math =MM_BREAK_MATH ; fr = (struct emuframe __user *) - (xcp->cp0_epc -sizeof (mips_instruction)); + ((xcp->cp0_epc & (~1 )) -sizeof (mips_instruction));/* * If we can't even access the area, something is very wrong, but we'll
@@ -131,10 +152,15 @@ int do_dsemulret(struct pt_regs *xcp)* - Is the instruction pointed to by the EPC an BREAK_MATH? * - Is the following memory word the BD_COOKIE? */ - err =__get_user (insn, &fr->badinst); +if (xcp->cp0_epc &1 ) { + err =__get_user (instr[0 ], (u16 __user *)(&fr->badinst)); + err |=__get_user (instr[1 ], (u16 __user *)((long )(&fr->badinst) +2 )); + insn = (instr[0 ] <<16 ) | instr[1 ]; + }else + err =__get_user (insn, &fr->badinst); err |=__get_user (cookie, &fr->cookie); -if (unlikely (err || (insn !=BREAK_MATH ) || (cookie !=BD_COOKIE ))) { +if (unlikely (err || (insn != break_math) || (cookie !=BD_COOKIE ))) {MIPS_FPU_EMU_INC_STATS (errors);return 0 ; }
Signature · 1 line
1.7.9.6
Re: [PATCH 2/9] MIPS: Optimise core library functions for microMIPS.
In reply to Steven J. HillQuoted 17 lines · Steven J. Hill
arch/mips/lib/memset.S +1
-8@@ -26,23 +35,36 @@ .previous .macro f_fill64 dst, offset, val, fixup - EX(LONG_S, \val, (\offset + 0 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 1 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 2 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 3 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 4 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 5 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 6 * LONGSIZE)(\dst), \fixup) - EX(LONG_S, \val, (\offset + 7 * LONGSIZE)(\dst), \fixup) +#ifdef CONFIG_CPU_MICROMIPS
arch/mips/lib/memset.S line 48
Quoted 10 lines
arch/mips/lib/memset.S +10
-0+ EX(swp, t8, (\offset + 0 * STORSIZE)(\dst), \fixup) + EX(swp, t8, (\offset + 1 * STORSIZE)(\dst), \fixup) + EX(swp, t8, (\offset + 2 * STORSIZE)(\dst), \fixup) + EX(swp, t8, (\offset + 3 * STORSIZE)(\dst), \fixup) +#if LONGSIZE == 4 + EX(swp, t8, (\offset + 4 * STORSIZE)(\dst), \fixup) + EX(swp, t8, (\offset + 5 * STORSIZE)(\dst), \fixup) + EX(swp, t8, (\offset + 6 * STORSIZE)(\dst), \fixup) + EX(swp, t8, (\offset + 7 * STORSIZE)(\dst), \fixup) +#endif
This looks bogus to me, either define LONG_SP to SWP or SDP (in
<asm/asm.h>) based on _MIPS_SZLONG or #error on LONGSIZE != 4. Also it would make sense to make this macro respect val in the microMIPS mode too, then an appropriate #define to a1/t8 elsewhere in this file will do. Otherwise it's pure obfuscation.
Quoted 10 lines
arch/mips/lib/strlen_user.S +1
-1@@ -28,9 +29,13 @@ LEAF(__strlen_user_asm) FEXPORT(__strlen_user_nocheck_asm) move v0, a0 -1: EX(lb, t0, (v0), .Lfault) +#ifdef CONFIG_CPU_MICROMIPS
arch/mips/lib/strlen_user.S LEAF(__strlen_user_asm) · line 41
Quoted 10 lines
arch/mips/lib/strlen_user.S +5
-1+1: EX(lbu16, v1, (v0), .Lfault) +#else +1: EX(lb, v1, (v0), .Lfault) +#endif PTR_ADDIU v0, 1 - bnez t0, 1b + bnez v1, 1b PTR_SUBU v0, a0 jr ra END(__strlen_user_asm)
Perhaps just LBU in all cases? You'll avoid the ugly #ifdef.
arch/mips/lib/strncpy_user.S line 38
Quoted 13 lines
arch/mips/lib/strncpy_user.S +4
-0@@ -30,30 +31,32 @@ LEAF(__strncpy_from_user_asm) LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok? and v0, a1 +#ifdef CONFIG_CPU_MICROMIPS + bnezc v0, .Lfault +#else bnez v0, .Lfault +#endif
You don't need this, .Lfault is surely within 126 bytes from here so GAS
will relax the branch to its 16-bit encoding which will give an equivalent result. Relaxing to compact branches is not supported by GAS at the moment.
Quoted 21 lines
arch/mips/lib/strncpy_user.S +5
-12FEXPORT(__strncpy_from_user_nocheck_asm) - move v0, zero - move v1, a1 .set noreorder -1: EX(lbu, t0, (v1), .Lfault) + move t0, zero + move v1, a1 +1: EX(lbu, v0, (v1), .Lfault) PTR_ADDIU v1, 1 R10KCBARRIER(0(ra)) - beqz t0, 2f - sb t0, (a0) - PTR_ADDIU v0, 1 - .set reorder - PTR_ADDIU a0, 1 - bne v0, a2, 1b -2: PTR_ADDU t0, a1, v0 - xor t0, a1 - bltz t0, .Lfault + beqz v0, 2f + sb v0, (a0)
arch/mips/lib/strncpy_user.S line 58
Quoted 10 lines
arch/mips/lib/strncpy_user.S +8
-0+ PTR_ADDIU t0, 1 + bne t0, a2, 1b + PTR_ADDIU a0, 1 +2: PTR_ADDU v0, a1, t0 + xor v0, a1 + bltz v0, .Lfault + nop jr ra # return n + move v0, t0 END(__strncpy_from_user_asm)
You don't need all of this, GAS will schedule these delay slots just fine
in the microMIPS mode.
arch/mips/lib/strncpy_user.S line 62
Quoted 8 lines
arch/mips/lib/strncpy_user.S +2
-5-.Lfault: li v0, -EFAULT +.Lfault: jr ra - - .section __ex_table,"a" - PTR 1b, .Lfault - .previous + li v0, -EFAULT
It looks like an independent bug fix -- submit separately?
Quoted 6 lines
arch/mips/lib/strnlen_user.S +0
-0@@ -26,21 +27,34 @@ * the maximum is a tad hairier ...
arch/mips/lib/strnlen_user.S line 37
Quoted 10 lines
arch/mips/lib/strnlen_user.S +5
-0*/ LEAF(__strnlen_user_asm) + .set noreorder LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok? and v0, a0 +#ifdef CONFIG_CPU_MICROMIPS + bnezc v0, .Lfault +#else bnez v0, .Lfault +#endif
Again you don't need this, see above.
Quoted 17 lines
arch/mips/lib/strnlen_user.S +8
-4FEXPORT(__strnlen_user_nocheck_asm) - move v0, a0 PTR_ADDU a1, a0 # stop pointer + move v0, a0 1: beq v0, a1, 1f # limit reached? + nop EX(lb, t0, (v0), .Lfault) - PTR_ADDU v0, 1 +#ifdef CONFIG_CPU_MICROMIPS + addius5 v0, 1 + bnezc t0, 1b +1: jr ra + PTR_SUBU v0, a0 +#else bnez t0, 1b -1: PTR_SUBU v0, a0 - jr ra
arch/mips/lib/strnlen_user.S line 60
Quoted 10 lines
arch/mips/lib/strnlen_user.S +5
-1+ PTR_ADDU v0, 1 +1: jr ra + PTR_SUBU v0, a0 +#endif END(__strnlen_user_asm) .Lfault: - move v0, zero jr ra + move v0, zero
You don't need all of this if you discard .set noreorder and let GAS
schedule the instructions and pick their optimal encodings itself.
Quoted 20 lines
arch/mips/mm/page.c +6
-0@@ -368,6 +360,12 @@ void __cpuinit build_clear_page(void)for (i =0 ; i < (buf - clear_page_array); i++)pr_debug ("\t.word 0x%08x\n" , clear_page_array[i]);pr_debug ("\t.set pop\n" ); +#ifdef CONFIG_CPU_MICROMIPS +memcpy (((u8 *)clear_page) -1 , clear_page_array, +ARRAY_SIZE (clear_page_array) *4 ); +#else +memcpy (clear_page, clear_page_array,ARRAY_SIZE (clear_page_array) *4 ); +#endif }static void __cpuinit build_copy_load (u32 **buf,int reg,int off)@@ -607,6 +605,12 @@ void __cpuinit build_copy_page(void)for (i =0 ; i < (buf - copy_page_array); i++)pr_debug ("\t.word 0x%08x\n" , copy_page_array[i]);
arch/mips/mm/page.c void __cpuinit build_copy_page(void) · line 616
Quoted 10 lines
arch/mips/mm/page.c +6
-0pr_debug ("\t.set pop\n" ); +#ifdef CONFIG_CPU_MICROMIPS +memcpy (((u8 *)copy_page) -1 , copy_page_array, +ARRAY_SIZE (copy_page_array) *4 ); +#else +memcpy (copy_page, copy_page_array,ARRAY_SIZE (copy_page_array) *4 ); +#endif }#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
I suggest that instead of the hacks above you arrange for an alias tocopy_page with the ISA bit clear. You won't need these changes then (and will get slightly better machine code).
Maciej