Add support for pure microMIPS kernel.
v99 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 instructions from the microMIPS ISA. The result is a kernel binary size reduction of more than 20% and an increase in the speed of execution due to the smaller and faster instructions.
Douglas Leung (1):
MIPS: microMIPS: Add vdso support.
Steven J. Hill (12):
MIPS: microMIPS: Add support for microMIPS instructions.
MIPS: Whitespace clean-ups after microMIPS additions.
MIPS: microMIPS: Floating point support for 16-bit instructions.
MIPS: microMIPS: Add support for exception handling.
MIPS: microMIPS: Support handling of delay slots.
MIPS: microMIPS: Add unaligned access support.
MIPS: microMIPS: Add configuration option for microMIPS kernel.
MIPS: microMIPS: Work-around for assembler bug.
MIPS: microMIPS: Optimise 'memset' core library function.
MIPS: microMIPS: Optimise 'strncpy' core library function.
MIPS: microMIPS: Optimise 'strlen' core library function.
MIPS: microMIPS: Optimise 'strnlen' core library function.
arch/mips/Kconfig | 11 + arch/mips/Makefile | 1 + arch/mips/configs/sead3micro_defconfig | 125 +++ arch/mips/include/asm/asm.h | 2 + arch/mips/include/asm/branch.h | 33 +- arch/mips/include/asm/fpu_emulator.h | 7 + arch/mips/include/asm/inst.h | 858 +++++++++++++++++- arch/mips/include/asm/mipsregs.h | 41 +- 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 | 3 + arch/mips/kernel/genex.S | 74 +- arch/mips/kernel/proc.c | 5 + arch/mips/kernel/process.c | 101 +++ arch/mips/kernel/scall32-o32.S | 9 + arch/mips/kernel/signal.c | 6 + arch/mips/kernel/smtc-asm.S | 3 + arch/mips/kernel/traps.c | 296 +++++-- arch/mips/kernel/unaligned.c | 1496 +++++++++++++++++++++++++++----- arch/mips/lib/memset.S | 84 +- arch/mips/lib/strlen_user.S | 9 +- arch/mips/lib/strncpy_user.S | 28 +- arch/mips/lib/strnlen_user.S | 2 +- arch/mips/math-emu/cp1emu.c | 766 ++++++++++++++-- arch/mips/math-emu/dsemul.c | 40 +- arch/mips/mm/tlbex.c | 21 + arch/mips/mm/uasm-micromips.c | 194 +++++ arch/mips/mm/uasm-mips.c | 178 ++++ arch/mips/mm/uasm.c | 211 +---- arch/mips/mti-sead3/sead3-init.c | 48 + 31 files changed, 4159 insertions(+), 702 deletions(-) create mode 100644 arch/mips/configs/sead3micro_defconfig create mode 100644 arch/mips/mm/uasm-micromips.c create mode 100644 arch/mips/mm/uasm-mips.c
Signature · 1 line
1.7.9.5
PATCH v99 1/13 MIPS: microMIPS: Add support for microMIPS instructions.
From: "Steven J. Hill" <[email protected]>
--- arch/mips/include/asm/inst.h | 771 +++++++++++++++++++++++++++++++++++++++++ arch/mips/mm/uasm-micromips.c | 194 +++++++++++ arch/mips/mm/uasm-mips.c | 178 ++++++++++ arch/mips/mm/uasm.c | 211 ++--------- 4 files changed, 1177 insertions(+), 177 deletions(-) create mode 100644 arch/mips/mm/uasm-micromips.c create mode 100644 arch/mips/mm/uasm-mips.c
arch/mips/include/asm/inst.h +771 -0
@@ -7,6 +7,7 @@* * Copyright (C) 1996, 2000 by Ralf Baechle * Copyright (C) 2006 by Thiemo Seufer +* Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. */ #ifndef _ASM_INST_H#define _ASM_INST_H
@@ -267,6 +268,225 @@ struct b_format { /* BREAK and SYSCALL */ 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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 {/* microMIPS 16-bit branch format */ +unsigned int opcode:6 ; +unsigned int rs:3 ; +signed int simmediate:7 ; +unsigned int duplicate:16 ;/* a copy of the instr */ +}; + +struct mm16b0_format {/* microMIPS 16-bit branch format */ +unsigned int opcode:6 ; +signed int simmediate:10 ; +unsigned int duplicate:16 ;/* a copy of the instr */ +}; + +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 instr */ +}; + +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 instr */ +}; + +struct mm16_r5_format { +unsigned int opcode:6 ; +unsigned int rt:5 ; +signed int simmediate:5 ; +unsigned int duplicate:16 ;/* a copy of the instr */ +}; + +struct mm16_r3_format { +unsigned int opcode:6 ; +unsigned int rt:3 ; +signed int simmediate:7 ; +unsigned int duplicate:16 ;/* a copy of the instr */ +}; +#elif defined(__MIPSEL__) struct j_format { /* Jump format */
@@ -340,6 +560,225 @@ struct b_format { /* BREAK and SYSCALL */ 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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 (microMIPS) */ +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 {/* microMIPS 16-bit branch format */ +unsigned int duplicate:16 ;/* a copy of the instr */ +signed int simmediate:7 ; +unsigned int rs:3 ; +unsigned int opcode:6 ; +}; + +struct mm16b0_format {/* microMIPS 16-bit branch format */ +unsigned int duplicate:16 ;/* a copy of the instr */ +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 instr */ +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 instr */ +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 instr */ +signed int simmediate:5 ; +unsigned int rt:5 ; +unsigned int opcode:6 ; +}; + +struct mm16_r3_format { +unsigned int duplicate:16 ;/* a copy of the instr */ +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,316 @@ union mips_instruction {typedef unsigned int mips_instruction ; +/* The following are for microMIPS 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; microMIPS 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; +}; + +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 microMIPS 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/mm/uasm-micromips.c new file +194 -0
194 lines not on this page · raw message
arch/mips/mm/uasm-mips.c new file +178 -0
178 lines not on this page · raw message
arch/mips/mm/uasm.c +34 -177
297 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v99,01/13] MIPS: microMIPS: Add support for microMIPS instructions.
arch/mips/include/asm/inst.h struct b_format { /* BREAK and SYSCALL */ · line 277
Quoted 11 lines · Steven J. Hill
arch/mips/include/asm/inst.h +7
-0@@ -267,6 +268,225 @@ struct b_format { /* BREAK and SYSCALL */ 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 ; +};
Some random thoughts/nitpicks on this section:
The microMIPS patch nearly quadruples the number of instruction formats in the mips_instruction union, so it might be worth considering questions like:
1) Is this the optimal way to represent this information, or have we reached a point where it is worth adding more complex "infrastructure" that would support a more compact instruction definition format?
2) Is there a better way to handle the LE/BE bitfield problem, than to duplicate each of the 28+ structs?
On the nitpick front:
3) After "struct NAME_format {", are tabs or spaces used to offset the comment? Seems like a mix. (The original code isn't entirely consistent either, but this could be an opportunity to tidy it up.)
4) Spaces around ':' in e.g. "opcode:6" would be more consistent with "most" of the other entries in inst.h
5) Should "FPU multipy" be "FPU multiply"?
6) The names of the special MIPS16e structs (rr, jal, i64, ri*) are a little terse and may create a conflict someday. If you don't want to use "INSTR_format" for specific instruction names, you could use something like "INSTR_instr" instead.
arch/mips/include/asm/inst.h struct b_format { /* BREAK and SYSCALL */ · line 409
Quoted 6 lines
arch/mips/include/asm/inst.h +6
-0+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 */
I'm assuming this meant to say: "there are only 16 bits in the first halfword"?
It might be clearer to just leave a comment like:
+ signed int imm25_21:5;
+ /* the subsequent [or previous] halfword contains imm15_0 */
arch/mips/include/asm/inst.h union mips_instruction { · line 1175
Quoted 2 lines
arch/mips/include/asm/inst.h +2
-0+/* +* This functions returns 1 if the microMIPS instr is a 16 bit instr.
Suggest "This function returns"
arch/mips/include/asm/inst.h union mips_instruction { · line 1181
Quoted 6 lines
arch/mips/include/asm/inst.h +6
-0+* Otherwise return 0. +*/ +#define MIPS_ISA_MODE 01 +#define is16mode (regs) (regs->cp0_epc & MIPS_ISA_MODE) + +static inline int mm_is16bit (u16 instr)
Does the comment refer to the is16mode() macro, or to mm_is16bit()?
Does is16mode(), which tests EPC during exception handling, belong in the uasm header file?
You might want to indicate that the value passed into mm_is16bit() is either a complete 16-bit MM (microMIPS) instruction, or the most significant halfword of a 32-bit MM instruction. i.e. it isn't necessarily a complete instruction
arch/mips/mm/uasm-micromips.c line 40
Quoted 6 lines
arch/mips/mm/uasm-micromips.c new file +6
-0+ { insn_bltzl, 0, 0 }, + { insn_bne, M(mm_bne32_op, 0, 0, 0, 0, 0), RT | RS | BIMM }, + { insn_cache, M(mm_pool32b_op, 0, 0, mm_cache_func, 0, 0), RT | RS | SIMM }, + { insn_daddu, 0, 0 }, + { insn_daddiu, 0, 0 }, + { insn_dmfc0, 0, 0 },
Do the "{ insn_X, 0, 0 }" entries indicate that these instructions (which were defined in MIPS mode) are unsupported in MM mode?
arch/mips/mm/uasm-micromips.c line 96
Quoted 3 lines
arch/mips/mm/uasm-micromips.c new file +3
-0+static inline __uasminit u32 build_bimm(s32 arg) +{ +if (arg >0xffff || arg <-0x10000 )
"if(" triggers a checkpatch violation (there are a few others too).
Review struct b_format { /* BREAK and SYSCALL */ · line 301
Quoted 1 line
(quoted diff) +1
-0+ printk(KERN_WARNING "Micro-assembler field overflow\n");
Consider pr_warning()
arch/mips/mm/uasm-micromips.c line 108
Quoted 4 lines
arch/mips/mm/uasm-micromips.c new file +4
-0+static inline __uasminit u32 build_jimm(u32 arg) +{ +if ((arg & ~(JIMM_MASK <<1 )) -1 ) +printk (KERN_WARNING "Micro-assembler field overflow\n" );
This expression evaluates to -1 (i.e. print a warning) for small values of arg, like 0 or 4.
Would something like this work?
arg >>= 1;
if (arg & ~JIMM_MASK)
pr_warning("Micro-assembler field overflow\n");return arg & JIMM_MASK;
arch/mips/mm/uasm-micromips.c line 117
Quoted 5 lines
arch/mips/mm/uasm-micromips.c new file +5
-0+/* +* The order of opcode arguments is implicitly left to right, +* starting with RS and ending with FUNC or IMM. +*/ +static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
There are a lot of similarities between the MM and MIPS versions of these functions. Likewise for build_bimm() and build_jimm(), which only differ because the shifts/ranges are not the same. Is there a way to make better reuse of the code?
arch/mips/mm/uasm-micromips.c line 171
Quoted 5 lines
arch/mips/mm/uasm-micromips.c new file +5
-0+#ifdef CONFIG_CPU_LITTLE_ENDIAN + **buf = ((op &0xffff ) <<16 ) | (op >>16 ); +#else + **buf = op; +#endif
If the MM instruction stream can consist of either 16-bit or 32-bit instructions, shouldn't this be a "u16 **" pointer?
And if it is, does that make the LE/BE test unnecessary?
arch/mips/mm/uasm-mips.c
Quoted 5 lines
arch/mips/mm/uasm-mips.c new file +0
-0
It would be good to have a separate commit that JUST splits uasm.c out into uasm-mips.c (no other changes). The commit message would ideally explain the rationale.
Quoted 7 lines
+/*
+ * 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) 2012 MIPS Technologies, Inc. All rights reserved.
+ */
Suggest leaving the original uasm.c authors' copyright info in the uasm-mips.c header.
arch/mips/mm/uasm-mips.c
Quoted 5 lines
arch/mips/mm/uasm-mips.c new file +5
-0+#ifdef CONFIG_CPU_MICROMIPS +#define RS_SH 16 +#define RT_SH 21 +#define SCIMM_MASK 0x3ff +#define SCIMM_SH 16
Can these be defined in a single place?
arch/mips/mm/uasm-mips.c
Quoted 3 lines
arch/mips/mm/uasm-mips.c new file +2
-1-WARN (arg & ~RS_MASK ,KERN_WARNING "Micro-assembler field overflow\n" ); +if (arg & ~RS_MASK ) +printk (KERN_WARNING "Micro-assembler RS field overflow\n" );
Since this looks unrelated to MM support, it might be best to put it in a separate commit. What is the benefit of changing WARN() to printk()?
Also, if printk() absolutely must be used, it might make sense to consolidate the uasm warning prints into a single non-inlined function, so that if somebody sees an overflow message and wants to debug the problem, they can set one breakpoint instead of 10+ breakpoints. WARN() may have helped indicate the source of the failure but printk() won't.
arch/mips/mm/uasm-mips.c
Quoted 3 lines
arch/mips/mm/uasm-mips.c new file +2
-1-WARN (arg & ~RT_MASK ,KERN_WARNING "Micro-assembler field overflow\n" ); +if (arg & ~RT_MASK ) +printk (KERN_WARNING "Micro-assembler RT field overflow\n" );
FWIW, using a unique string for each error case means the compiler can no longer point all of these printk's to a single copy of the same string...
arch/mips/mm/uasm-mips.c
Quoted 5 lines
arch/mips/mm/uasm-mips.c new file +5
-0+#ifdef CONFIG_CPU_MICROMIPS +#include "uasm-micromips.c" +#else +#include "uasm-mips.c" +#endif
There's an awful lot of potential reuse between these two configurations and I'm not sure if it makes sense to split them this way.
If possible it would be good if we didn't have to enable CONFIG_CPU_MICROMIPS to know that the MM code compiles.
Re: [PATCH v99,01/13] MIPS: microMIPS: Add support for microMIPS instructions.
Quoted 6 lines · Kevin Cernekee
Some random thoughts/nitpicks on this section:
The microMIPS patch nearly quadruples the number of instruction formats in the
mips_instructionunion, so it might be worth considering questions like:
Quoted 6 lines
1) Is this the optimal way to represent this information, or have we reached a point where it is worth adding more complex "infrastructure" that would support a more compact instruction definition format?
2) Is there a better way to handle the LE/BE bitfield problem, than to duplicate each of the 28+ structs?
Something based on #defines, for example. Back in the dark ages I figured bitfields would be nicer way to represent instruction formats. Against the warning words of I think Kevin Kissel I went for the bitfields and this would be a good opportunity to change direction.
Ralf
RE: [PATCH v99,01/13] MIPS: microMIPS: Add support for microMIPS instructions.
Quoted 8 lines
Quoted 8 lines
The microMIPS patch nearly quadruples the number of instruction formats in the
mips_instructionunion, so it might be worth considering questions like:1) Is this the optimal way to represent this information, or have we reached a point where it is worth adding more complex "infrastructure" that would support a more compact instruction definition format?
Quoted 8 lines
Quoted 2 lines
2) Is there a better way to handle the LE/BE bitfield problem, than to duplicate each of the 28+ structs?
Something based on #defines, for example. Back in the dark ages I figured bitfields would be nicer way to represent instruction formats. Against the warning words of I think Kevin Kissel I went for the bitfields and this would be a good opportunity to change direction.
Oh sure, why not. I mean I've only rewritten this patch at least 10 times. What's one more time? :) If one or all of you would expound on what your design ideas are, that would be great. Again, not to sound like a scratched CD, but I am still shooting for this code to get into 3.9, so please reply soon. Thanks.
-Steve
PATCH v99 2/13 MIPS: Whitespace clean-ups after microMIPS additions.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Clean-up tabs, spaces, macros, etc. after adding in microMIPS instructions for the micro-assembler.
--- arch/mips/include/asm/inst.h | 134 +++++++++++++++++++------------------- arch/mips/include/asm/mipsregs.h | 40 +++++++----- arch/mips/kernel/proc.c | 1 + arch/mips/kernel/traps.c | 4 +- 4 files changed, 92 insertions(+), 87 deletions(-)
arch/mips/include/asm/inst.h +67 -67
@@ -262,7 +262,7 @@ struct ma_format { /* FPU multiply 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 ;
@@ -276,7 +276,7 @@ struct fb_format { /* FPU branch format */ unsigned int simmediate:16; }; -struct fp0_format {/* FPU multipy and add format (MIPS32) */ +struct fp0_format {/* FPU multipy and add format (MIPS32) */ unsigned int opcode:6 ;unsigned int fmt:5 ;unsigned int ft:5 ;
@@ -285,7 +285,7 @@ struct fp0_format { /* FPU multipy and add format (MIPS32) */ unsigned int func:6; }; -struct mm_fp0_format {/* FPU multipy and add format (microMIPS) */ +struct mm_fp0_format {/* FPU multipy and add format (microMIPS) */ unsigned int opcode:6 ;unsigned int ft:5 ;unsigned int fs:5 ;
@@ -295,7 +295,7 @@ struct mm_fp0_format { /* FPU multipy and add format (microMIPS) */ unsigned int func:6; }; -struct fp1_format {/* FPU mfc1 and cfc1 format (MIPS32) */ +struct fp1_format {/* FPU mfc1 and cfc1 format (MIPS32) */ unsigned int opcode:6 ;unsigned int op:5 ;unsigned int rt:5 ;
@@ -304,7 +304,7 @@ struct fp1_format { /* FPU mfc1 and cfc1 format (MIPS32) */ unsigned int func:6; }; -struct mm_fp1_format {/* FPU mfc1 and cfc1 format (microMIPS) */ +struct mm_fp1_format {/* FPU mfc1 and cfc1 format (microMIPS) */ unsigned int opcode:6 ;unsigned int rt:5 ;unsigned int fs:5 ;
@@ -313,7 +313,7 @@ struct mm_fp1_format { /* FPU mfc1 and cfc1 format (microMIPS) */ unsigned int func:6; }; -struct mm_fp2_format {/* FPU movt and movf format (microMIPS) */ +struct mm_fp2_format {/* FPU movt and movf format (microMIPS) */ unsigned int opcode:6 ;unsigned int fd:5 ;unsigned int fs:5 ;
@@ -324,7 +324,7 @@ struct mm_fp2_format { /* FPU movt and movf format (microMIPS) */ unsigned int func:6; }; -struct mm_fp3_format {/* FPU abs and neg format (microMIPS) */ +struct mm_fp3_format {/* FPU abs and neg format (microMIPS) */ unsigned int opcode:6 ;unsigned int rt:5 ;unsigned int fs:5 ;
@@ -333,7 +333,7 @@ struct mm_fp3_format { /* FPU abs and neg format (microMIPS) */ unsigned int func:6; }; -struct mm_fp4_format {/* FPU c.cond format (microMIPS) */ +struct mm_fp4_format {/* FPU c.cond format (microMIPS) */ unsigned int opcode:6 ;unsigned int rt:5 ;unsigned int fs:5 ;
@@ -343,7 +343,7 @@ struct mm_fp4_format { /* FPU c.cond format (microMIPS) */ unsigned int func:6; }; -struct mm_fp5_format {/* FPU lwxc1 and swxc1 format (microMIPS) */ +struct mm_fp5_format {/* FPU lwxc1 and swxc1 format (microMIPS) */ unsigned int opcode:6 ;unsigned int index:5 ;unsigned int base:5 ;
@@ -370,20 +370,20 @@ struct mm_fp6_format { /* FPU madd and msub format (microMIPS) */ unsigned int func:6; }; -struct mm16b1_format {/* microMIPS 16-bit branch format */ +struct mm16b1_format {/* microMIPS 16-bit branch format */ unsigned int opcode:6 ;unsigned int rs:3 ;signed int simmediate:7 ;unsigned int duplicate:16 ;/* a copy of the instr */ }; -struct mm16b0_format {/* microMIPS 16-bit branch format */ +struct mm16b0_format {/* microMIPS 16-bit branch format */ unsigned int opcode:6 ;signed int simmediate:10 ;unsigned int duplicate:16 ;/* a copy of the instr */ }; -struct mm_i_format {/* Immediate format (addi, lw, ...) */ +struct mm_i_format {/* Immediate format (addi, lw, ...) */ unsigned int opcode:6 ;unsigned int rt:5 ;unsigned int rs:5 ;
@@ -495,72 +495,72 @@ struct j_format { /* Jump format */ };struct i_format {/* Immediate format */ -signed int simmediate :16 ; -unsigned int rt :5 ; -unsigned int rs :5 ; -unsigned int opcode :6 ; +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 ; +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 ; +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 ; +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 ; +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 ; +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 multiply 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 */ +struct fb_format {/* FPU branch format */ unsigned int simmediate:16 ;unsigned int flag:2 ;unsigned int cc:3 ;
@@ -568,7 +568,7 @@ struct fb_format { /* FPU branch format */ unsigned int opcode:6; }; -struct fp0_format {/* FPU multipy and add format (MIPS32) */ +struct fp0_format {/* FPU multipy and add format (MIPS32) */ unsigned int func:6 ;unsigned int fd:5 ;unsigned int fs:5 ;
@@ -577,7 +577,7 @@ struct fp0_format { /* FPU multipy and add format (MIPS32) */ unsigned int opcode:6; }; -struct mm_fp0_format {/* FPU multipy and add format (microMIPS) */ +struct mm_fp0_format {/* FPU multipy and add format (microMIPS) */ unsigned int func:6 ;unsigned int op:2 ;unsigned int fmt:3 ;
@@ -587,7 +587,7 @@ struct mm_fp0_format { /* FPU multipy and add format (microMIPS) */ unsigned int opcode:6; }; -struct fp1_format {/* FPU mfc1 and cfc1 format (MIPS32) */ +struct fp1_format {/* FPU mfc1 and cfc1 format (MIPS32) */ unsigned int func:6 ;unsigned int fd:5 ;unsigned int fs:5 ;
@@ -596,7 +596,7 @@ struct fp1_format { /* FPU mfc1 and cfc1 format (MIPS32) */ unsigned int opcode:6; }; -struct mm_fp1_format {/* FPU mfc1 and cfc1 format (microMIPS) */ +struct mm_fp1_format {/* FPU mfc1 and cfc1 format (microMIPS) */ unsigned int func:6 ;unsigned int op:8 ;unsigned int fmt:2 ;
@@ -605,7 +605,7 @@ struct mm_fp1_format { /* FPU mfc1 and cfc1 format (microMIPS) */ unsigned int opcode:6; }; -struct mm_fp2_format {/* FPU movt and movf format (microMIPS) */ +struct mm_fp2_format {/* FPU movt and movf format (microMIPS) */ unsigned int func:6 ;unsigned int op:3 ;unsigned int fmt:2 ;
@@ -616,7 +616,7 @@ struct mm_fp2_format { /* FPU movt and movf format (microMIPS) */ unsigned int opcode:6; }; -struct mm_fp3_format {/* FPU abs and neg format (microMIPS) */ +struct mm_fp3_format {/* FPU abs and neg format (microMIPS) */ unsigned int func:6 ;unsigned int op:7 ;unsigned int fmt:3 ;
@@ -625,7 +625,7 @@ struct mm_fp3_format { /* FPU abs and neg format (microMIPS) */ unsigned int opcode:6; }; -struct mm_fp4_format {/* FPU c.cond format (microMIPS) */ +struct mm_fp4_format {/* FPU c.cond format (microMIPS) */ unsigned int func:6 ;unsigned int cond:4 ;unsigned int fmt:3 ;
@@ -635,7 +635,7 @@ struct mm_fp4_format { /* FPU c.cond format (microMIPS) */ unsigned int opcode:6; }; -struct mm_fp5_format {/* FPU lwxc1 and swxc1 format (microMIPS) */ +struct mm_fp5_format {/* FPU lwxc1 and swxc1 format (microMIPS) */ unsigned int func:6 ;unsigned int op:5 ;unsigned int fd:5 ;
@@ -644,7 +644,7 @@ struct mm_fp5_format { /* FPU lwxc1 and swxc1 format (microMIPS) */ unsigned int opcode:6; }; -struct fp6_format {/* FPU madd and msub format (MIPS IV) */ +struct fp6_format {/* FPU madd and msub format (MIPS IV) */ unsigned int func:6 ;unsigned int fd:5 ;unsigned int fs:5 ;
@@ -653,7 +653,7 @@ struct fp6_format { /* FPU madd and msub format (MIPS IV) */ unsigned int opcode:6; }; -struct mm_fp6_format {/* FPU madd and msub format (microMIPS) */ +struct mm_fp6_format {/* FPU madd and msub format (microMIPS) */ unsigned int func:6 ;unsigned int fr:5 ;unsigned int fd:5 ;
@@ -662,20 +662,20 @@ struct mm_fp6_format { /* FPU madd and msub format (microMIPS) */ unsigned int opcode:6; }; -struct mm16b1_format {/* microMIPS 16-bit branch format */ +struct mm16b1_format {/* microMIPS 16-bit branch format */ unsigned int duplicate:16 ;/* a copy of the instr */ signed int simmediate:7 ;unsigned int rs:3 ;unsigned int opcode:6 ; }; -struct mm16b0_format {/* microMIPS 16-bit branch format */ +struct mm16b0_format {/* microMIPS 16-bit branch format */ unsigned int duplicate:16 ;/* a copy of the instr */ signed int simmediate:10 ;unsigned int opcode:6 ; }; -struct mm_i_format {/* Immediate format */ +struct mm_i_format {/* Immediate format */ signed int simmediate:16 ;unsigned int rs:5 ;unsigned int rt:5 ;
arch/mips/include/asm/mipsregs.h +22 -18
@@ -1151,17 +1151,21 @@ do { \/* * Macros to access the floating point coprocessor control registers */ -#define read_32bit_cp1_register (source) \ -({ int __res; \ - __asm__ __volatile__( \ - ".set\tpush\n\t" \ - ".set\treorder\n\t" \ -/* gas fails to assemble cfc1 for some archs (octeon).*/ \ -".set\tmips1\n\t" \ - "cfc1\t%0,"STR(source)"\n\t" \ - ".set\tpop" \ - : "=r" (__res)); \ - __res;}) +#define read_32bit_cp1_register (source) \ +({ \ + int __res; \ + \ + __asm__ __volatile__( \ + " .set push \n" \ + " .set reorder \n" \ + " # gas fails to assemble cfc1 for some archs, \n" \ + " # like Octeon. \n" \ + " .set mips1 \n" \ + " cfc1 %0,"STR(source)" \n" \ + " .set pop \n" \ + : "=r" (__res)); \ + __res; \ +})#ifdef HAVE_AS_DSP #define rddsp (mask) \
@@ -1298,12 +1302,12 @@ do { \unsigned int __res; \ \ __asm__ __volatile__( \ -" .set push \n" \ -" .set noat \n" \ -" # rddsp $1, %x1 \n" \ -" .word 0x7c000cb8 | (%x1 << 16) \n" \ -" move %0, $1 \n" \ -" .set pop \n" \ +" .set push \n" \ +" .set noat \n" \ +" # rddsp $1, %x1 \n" \ +" .word 0x7c000cb8 | (%x1 << 16) \n" \ +" move %0, $1 \n" \ +" .set pop \n" \ :"=r" (__res) \ :"i" (mask)); \ __res; \
@@ -1318,7 +1322,7 @@ do { \ " # wrdsp $1, %x1 \n" \ " .word 0x7c2004f8 | (%x1 << 11) \n" \ " .set pop \n" \ - : \ + : \ : "r" (val), "i" (mask)); \ }while (0 )
arch/mips/kernel/proc.c +1 -0
@@ -73,6 +73,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)if (cpu_has_dsp)seq_printf (m,"%s" ," dsp" );if (cpu_has_dsp2)seq_printf (m,"%s" ," dsp2" );if (cpu_has_mipsmt)seq_printf (m,"%s" ," mt" ); +if (cpu_has_mmips)seq_printf (m,"%s" ," micromips" );seq_printf (m,"\n" ); seq_printf(m, "shadow register sets\t: %d\n",
arch/mips/kernel/traps.c +2 -2
@@ -514,7 +514,7 @@ static inline int simulate_ll(struct pt_regs *regs, unsigned int opcode) offset >>=16 ; vaddr = (unsigned long __user *) - ((unsigned long )(regs->regs[(opcode &BASE ) >>21 ]) + offset); + ((unsigned long )(regs->regs[(opcode &BASE ) >>21 ]) + offset);if ((unsigned long )vaddr &3 )return SIGBUS ;
@@ -554,7 +554,7 @@ static inline int simulate_sc(struct pt_regs *regs, unsigned int opcode) offset >>=16 ; vaddr = (unsigned long __user *) - ((unsigned long )(regs->regs[(opcode &BASE ) >>21 ]) + offset); + ((unsigned long )(regs->regs[(opcode &BASE ) >>21 ]) + offset); reg = (opcode &RT ) >>16 ;if ((unsigned long )vaddr &3 )
Signature · 1 line
1.7.9.5
Re: [PATCH v99,02/13] MIPS: Whitespace clean-ups after microMIPS additions.
Quoted 4 lines · Steven J. Hill
From: "Steven J. Hill" <[email protected]>
Clean-up tabs, spaces, macros, etc. after adding in microMIPS instructions for the micro-assembler.
My personal preference would be to fix up the whitespace in the existing code first, then make the new (MM) code follow the convention from the get-go.
Review
Quoted 2 lines
(quoted diff) +1
-1-struct fp0_format { /* FPU multipy and add format (MIPS32) */ +struct fp0_format { /* FPU multipy and add format (MIPS32) */
"multiply"
arch/mips/kernel/proc.c static int show_cpuinfo(struct seq_file *m, void *v) · line 77
Quoted 8 lines
arch/mips/kernel/proc.c +1
-0@@ -73,6 +73,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)if (cpu_has_dsp)seq_printf (m,"%s" ," dsp" );if (cpu_has_dsp2)seq_printf (m,"%s" ," dsp2" );if (cpu_has_mipsmt)seq_printf (m,"%s" ," mt" ); +if (cpu_has_mmips)seq_printf (m,"%s" ," micromips" );seq_printf (m,"\n" );
This should probably go into a different commit.
PATCH v99 3/13 MIPS: microMIPS: Floating point support for 16-bit instructions.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Add logic needed to do floating point emulation when in microMIPS or MIPS16e modes.
--- arch/mips/include/asm/fpu_emulator.h | 7 + arch/mips/kernel/traps.c | 2 +- arch/mips/math-emu/cp1emu.c | 766 ++++++++++++++++++++++++++++++---- arch/mips/math-emu/dsemul.c | 40 +- 4 files changed, 718 insertions(+), 97 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/kernel/traps.c +1 -1
@@ -671,7 +671,7 @@ asmlinkage void do_ov(struct pt_regs *regs)force_sig_info (SIGFPE , &info, current); } -static int process_fpemu_return (int sig,void __user *fault_addr) +int process_fpemu_return (int sig,void __user *fault_addr) {if (sig ==SIGSEGV || sig ==SIGBUS ) {struct siginfo si = {0 };
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.5
PATCH v99 4/13 MIPS: microMIPS: Add support for 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/mipsregs.h | 1 + arch/mips/include/asm/stackframe.h | 12 +- arch/mips/kernel/cpu-probe.c | 3 + arch/mips/kernel/genex.S | 74 ++++++--- arch/mips/kernel/scall32-o32.S | 9 ++ arch/mips/kernel/smtc-asm.S | 3 + arch/mips/kernel/traps.c | 290 ++++++++++++++++++++++++++---------- arch/mips/mm/tlbex.c | 21 +++ arch/mips/mti-sead3/sead3-init.c | 48 ++++++ 9 files changed, 354 insertions(+), 107 deletions(-)
arch/mips/include/asm/mipsregs.h +1 -0
@@ -596,6 +596,7 @@#define MIPS_CONF3_RXI (_ULCAST_(1) << 12)#define MIPS_CONF3_ULRI (_ULCAST_(1) << 13)#define MIPS_CONF3_ISA (_ULCAST_(3) << 14) +#define MIPS_CONF3_ISA_OE (_ULCAST_(1) << 16)#define MIPS_CONF4_MMUSIZEEXT (_ULCAST_(255) << 0)#define MIPS_CONF4_MMUEXTDEF (_ULCAST_(3) << 14)
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/cpu-probe.c +3 -0
@@ -442,6 +442,9 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c) c->options |=MIPS_CPU_ULRI ;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 ; }
arch/mips/kernel/genex.S +55 -19
146 lines not on this page · raw message
arch/mips/kernel/scall32-o32.S +9 -0
@@ -138,9 +138,18 @@ stackargs: 5: jr t1 sw t5, 16(sp) # argument #5 to ksp +#ifdef CONFIG_CPU_MICROMIPS 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 +208 -82
477 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 +48 -0
62 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v99 5/13 MIPS: microMIPS: Support 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 modes.
--- arch/mips/include/asm/branch.h | 33 +++++++- arch/mips/include/asm/inst.h | 3 + arch/mips/kernel/branch.c | 183 +++++++++++++++++++++++++++++++++++++++- arch/mips/kernel/unaligned.c | 3 + 4 files changed, 219 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/include/asm/inst.h +3 -0
@@ -1122,6 +1122,9 @@ struct decoded_instn {int micro_mips_mode; }; +/* Recode table from MIPS16e register notation to GPR. */ +extern const int mips16e_reg2gpr[]; +union mips16e_instruction {unsigned int full:16 ;struct rr rr;
arch/mips/kernel/branch.c +181 -2
209 lines not on this page · raw message
arch/mips/kernel/unaligned.c +3 -0
@@ -102,6 +102,9 @@ static u32 unaligned_action;#endif extern void show_registers (struct pt_regs *regs); +/* Recode table from MIPS16e register notation to GPR. */ +const int mips16e_reg2gpr[] = {16 ,17 ,2 ,3 ,4 ,5 ,6 ,7 }; +static void emulate_load_store_insn (struct pt_regs *regs,void __user *addr,unsigned int __user *pc) {
Signature · 1 line
1.7.9.5
PATCH v99 6/13 MIPS: microMIPS: Add unaligned access support.
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 | 1493 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 1388 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) 2012 MIPS Technologies, Inc. All rights reserved. */ #include <linux/errno.h> #include <linux/sched.h>
@@ -260,34 +261,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;
@@ -307,7 +389,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 +1287 -206
1,618 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v99 7/13 MIPS: microMIPS: Add vdso support.
In reply to Steven J. HillFrom: Douglas Leung <[email protected]>
Support vdso in microMIPS mode.
--- arch/mips/kernel/signal.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/mips/kernel/signal.c +6 -0
@@ -35,6 +35,7 @@#include <asm/war.h> #include <asm/vdso.h> #include <asm/dsp.h> +#include <asm/inst.h> #include "signal-common.h"
@@ -518,7 +519,12 @@ static void handle_signal(unsigned long sig, siginfo_t *info,sigset_t *oldset =sigmask_to_save ();int ret;struct mips_abi *abi = current->thread.abi; +#ifdef CONFIG_CPU_MICROMIPS +void *vdso = (void *) + ((unsigned int )current->mm->context.vdso |MIPS_ISA_MODE ); +#else void *vdso = current->mm->context.vdso; +#endif if (regs->regs[0 ]) {switch (regs->regs[2 ]) {
Signature · 1 line
1.7.9.5
PATCH v99 8/13 MIPS: microMIPS: Add configuration option for microMIPS kernel.
In reply to Steven J. HillFrom: "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 | 11 +++ arch/mips/Makefile | 1 + arch/mips/configs/sead3micro_defconfig | 125 ++++++++++++++++++++++++++++++++ arch/mips/kernel/proc.c | 4 + 4 files changed, 141 insertions(+) create mode 100644 arch/mips/configs/sead3micro_defconfig
arch/mips/Kconfig +11 -0
@@ -350,6 +350,7 @@ config MIPS_SEAD3 select SYS_SUPPORTS_BIG_ENDIAN select SYS_SUPPORTS_LITTLE_ENDIAN select SYS_SUPPORTS_SMARTMIPS + select SYS_SUPPORTS_MICROMIPS select USB_ARCH_HAS_EHCI select USB_EHCI_BIG_ENDIAN_DESC select USB_EHCI_BIG_ENDIAN_MMIO
@@ -2087,6 +2088,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
@@ -2149,6 +2157,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 +125 -0
125 lines not on this page · raw message
arch/mips/kernel/proc.c +4 -0
@@ -76,6 +76,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)if (cpu_has_mmips)seq_printf (m,"%s" ," micromips" );seq_printf (m,"\n" ); +if (cpu_has_mmips) { +seq_printf (m,"micromips kernel\t: %s\n" , + (read_c0_config3 () &MIPS_CONF3_ISA_OE ) ?"yes" :"no" ); + }seq_printf (m,"shadow register sets\t: %d\n" , cpu_data[n].srsets); seq_printf(m, "kscratch registers\t: %d\n",
Signature · 1 line
1.7.9.5
PATCH v99 9/13 MIPS: microMIPS: Work-around for assembler bug.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
When building a microMIPS instructions only kernel, the linker complains about ISA mode switches in the .fixup section. We explicitly add the .insn assembler directive to address this.
--- arch/mips/include/asm/uaccess.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
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" \
Signature · 1 line
1.7.9.5
PATCH v99 10/13 MIPS: microMIPS: Optimise 'memset' core library function.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Optimise 'memset' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
--- arch/mips/include/asm/asm.h | 2 ++ arch/mips/lib/memset.S | 84 +++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 30 deletions(-)
arch/mips/include/asm/asm.h +2 -0
@@ -296,6 +296,7 @@ symbol = value#define LONG_SUBU subu#define LONG_L lw#define LONG_S sw +#define LONG_SP swp#define LONG_SLL sll#define LONG_SLLV sllv#define LONG_SRL srl
@@ -318,6 +319,7 @@ symbol = value#define LONG_SUBU dsubu#define LONG_L ld#define LONG_S sd +#define LONG_SP sdp#define LONG_SLL dsll#define LONG_SLLV dsllv#define LONG_SRL dsrl
arch/mips/lib/memset.S +54 -30
150 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v99 11/13 MIPS: microMIPS: Optimise 'strncpy' core library function.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Optimise 'strncpy' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
--- arch/mips/lib/strncpy_user.S | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
arch/mips/lib/strncpy_user.S +15 -13
@@ -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>
@@ -33,22 +34,23 @@ LEAF(__strncpy_from_user_asm) bnez v0, .Lfault 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
Signature · 1 line
1.7.9.5
Re: [PATCH v99,11/13] MIPS: microMIPS: Optimise 'strncpy' core library function.
Quoted 5 lines · Steven J. Hill
From: "Steven J. Hill" <[email protected]>
Optimise 'strncpy' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
This is an untrue statement. Why mislead us by saying the original binary code is obtained?
You don't really explain how the change helps optimization either.
Quoted 21 lines
Signed-off-by Steven J. Hill <[email protected]>--- arch/mips/lib/strncpy_user.S | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)arch/mips/lib/strncpy_user.S +2
-1@@ -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>
arch/mips/lib/strncpy_user.S LEAF(__strncpy_from_user_asm) · line 40
Quoted 10 lines
arch/mips/lib/strncpy_user.S +3
-3@@ -33,22 +34,23 @@ LEAF(__strncpy_from_user_asm) bnez v0, .Lfault 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)
Look at these changes. v0 and t0 are not the same thing. the binary is being changed.
Quoted 26 lines
arch/mips/lib/strncpy_user.S +10
-9PTR_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
Re: [PATCH v99,11/13] MIPS: microMIPS: Optimise 'strncpy' core library function.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 10 lines · David Daney
Quoted 5 lines · Steven J. Hill
From: "Steven J. Hill" <[email protected]>
Optimise 'strncpy' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
This is an untrue statement. Why mislead us by saying the original binary code is obtained?
I you are building a classic MIPS kernel, the instructions generated will be the same even with this patch. The changes only make a difference when building a pure microMIPS kernel.
Quoted 2 lines
You don't really explain how the change helps optimization either.
The exercise is left to the reader. Build a microMIPS kernel yourself and figure it out.
- -Steve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlGJxBcACgkQgyK5H2Ic36c4hQCeLGI8MI2rr6KgOv7G15lnBdok bbcAoKY+BvVyTCzG033Bc+pJ07xCtGMq
=xJmM
-----END PGP SIGNATURE-----
Re: [PATCH v99,11/13] MIPS: microMIPS: Optimise 'strncpy' core library function.
Quoted 11 lines · Steven J. Hill
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 7 lines · David Daney
Quoted 5 lines · Steven J. Hill
From: "Steven J. Hill" <[email protected]>
Optimise 'strncpy' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
Quoted 6 lines
Quoted 3 lines
This is an untrue statement. Why mislead us by saying the original binary code is obtained?
I you are building a classic MIPS kernel, the instructions generated will be the same even with this patch. The changes only make a difference when building a pure microMIPS kernel.
You are wrong:
strncpy_user.o.after.dis renamed from strncpy_user.o.before.dis +19 -20
@@ -1,5 +1,5 @@ -strncpy_user.o.before: file format elf64-tradbigmips +strncpy_user.o.after: file format elf64-tradbigmips Disassembly of section .text:
@@ -7,27 +7,26 @@ 0000000000000000 <__strncpy_from_user_asm>: 0: df820028 ld v0,40(gp) 4: 00451024 and v0,v0,a1 - 8: 14400011 bnez v0,50 <__strncpy_from_user_nocheck_asm+0x40> + 8: 14400010 bnez v0,4c <__strncpy_from_user_nocheck_asm+0x3c> c: 00000000 nop 0000000000000010 <__strncpy_from_user_nocheck_asm>: - 10: 0000102d move v0,zero + 10: 0000602d move t0,zero 14: 00a0182d move v1,a1 - 18: 906c0000 lbu t0,0(v1) + 18: 90620000 lbu v0,0(v1) 1c: 64630001 daddiu v1,v1,1 - 20: 11800005 beqz t0,38 <__strncpy_from_user_nocheck_asm+0x28> - 24: a08c0000 sb t0,0(a0) - 28: 64420001 daddiu v0,v0,1 - 2c: 64840001 daddiu a0,a0,1 - 30: 1446fff9 bne v0,a2,18 <__strncpy_from_user_nocheck_asm+0x8> - 34: 00000000 nop - 38: 00a2602d daddu t0,a1,v0 - 3c: 01856026 xor t0,t0,a1 - 40: 05800003 bltz t0,50 <__strncpy_from_user_nocheck_asm+0x40> - 44: 00000000 nop - 48: 03e00008 jr ra - 4c: 00000000 nop - 50: 2402fff2 li v0,-14 - 54: 03e00008 jr ra - 58: 00000000 nop - 5c: 00000000 nop + 20: 10400004 beqz v0,34 <__strncpy_from_user_nocheck_asm+0x24> + 24: a0820000 sb v0,0(a0) + 28: 658c0001 daddiu t0,t0,1 + 2c: 1586fffa bne t0,a2,18 <__strncpy_from_user_nocheck_asm+0x8> + 30: 64840001 daddiu a0,a0,1 + 34: 00ac102d daddu v0,a1,t0 + 38: 00451026 xor v0,v0,a1 + 3c: 04400003 bltz v0,4c <__strncpy_from_user_nocheck_asm+0x3c> + 40: 00000000 nop + 44: 03e00008 jr ra + 48: 0180102d move v0,t0 + 4c: 2402fff2 li v0,-14 + 50: 03e00008 jr ra + 54: 00000000 nop + ...
They are different, and you said they would be the same.
I am fine if you want to change things. Just don't say that your patch makes no change when it in fact does.
Quoted 5 lines
Quoted 3 lines
You don't really explain how the change helps optimization either.
The exercise is left to the reader. Build a microMIPS kernel yourself and figure it out.
This isn't some sort of programming text book. Your job in the change log (and the mailing list) isn't to force us to learn by doing a lot of independent analysis of the code. Instead I would prefer a concise explanation of why the change is beneficial.
You are dumping a lot of new code into the kernel. That is fine, but you could consider making the process easier by improving the quality of the changelogs that accompany it.
David Daney
Quoted 13 lines
- -Steve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/iEYEARECAAYFAlGJxBcACgkQgyK5H2Ic36c4hQCeLGI8MI2rr6KgOv7G15lnBdok bbcAoKY+BvVyTCzG033Bc+pJ07xCtGMq
=xJmM
-----END PGP SIGNATURE-----
Re: [PATCH v99,11/13] MIPS: microMIPS: Optimise 'strncpy' core library function.
Quoted 5 lines · David Daney
Quoted 4 lines
Quoted 2 lines
You don't really explain how the change helps optimization either.
The exercise is left to the reader. Build a microMIPS kernel yourself and figure it out.
Quoted 8 lines
This isn't some sort of programming text book. Your job in the change log (and the mailing list) isn't to force us to learn by doing a lot of independent analysis of the code. Instead I would prefer a concise explanation of why the change is beneficial.
You are dumping a lot of new code into the kernel. That is fine, but you could consider making the process easier by improving the quality of the changelogs that accompany it.
I concur, it's the contributor's responsibility to make the reviewers'
work as easy as possible and to convince them that the change offered is both technically correct and desired for inclusion.
Maciej
PATCH v99 12/13 MIPS: microMIPS: Optimise 'strlen' core library function.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Optimise 'strlen' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
--- arch/mips/lib/strlen_user.S | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/mips/lib/strlen_user.S +5 -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,9 @@ LEAF(__strlen_user_asm) FEXPORT(__strlen_user_nocheck_asm) move v0, a0 -1: EX(lb, t0, (v0), .Lfault) +1: EX(lbu, v1, (v0), .Lfault) PTR_ADDIU v0, 1 - bnez t0, 1b + bnez v1, 1b PTR_SUBU v0, a0 jr ra END(__strlen_user_asm)
Signature · 1 line
1.7.9.5
PATCH v99 13/13 MIPS: microMIPS: Optimise 'strnlen' core library function.
In reply to Steven J. HillFrom: "Steven J. Hill" <[email protected]>
Optimise 'strnlen' to use microMIPS instructions and/or optimisations for binary size reduction. When the microMIPS ISA is not being used, the library function compiles to the original binary code.
--- arch/mips/lib/strnlen_user.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/lib/strnlen_user.S +1 -1
@@ -35,7 +35,7 @@ FEXPORT(__strnlen_user_nocheck_asm) PTR_ADDU a1, a0 # stop pointer 1: beq v0, a1, 1f # limit reached? EX(lb, t0, (v0), .Lfault) - PTR_ADDU v0, 1 + PTR_ADDIU v0, 1 bnez t0, 1b 1: PTR_SUBU v0, a0 jr ra
Signature · 1 line
1.7.9.5