Path: blob/master/arch/m32r/include/asm/assembler.h
10818 views
#ifndef _ASM_M32R_ASSEMBLER_H1#define _ASM_M32R_ASSEMBLER_H23/*4* linux/asm-m32r/assembler.h5*6* Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>7*8* This file contains M32R architecture specific macro definitions.9*/1011#include <linux/stringify.h>1213#undef __STR1415#ifdef __ASSEMBLY__16#define __STR(x) x17#else18#define __STR(x) __stringify(x)19#endif2021#ifdef CONFIG_SMP22#define M32R_LOCK __STR(lock)23#define M32R_UNLOCK __STR(unlock)24#else25#define M32R_LOCK __STR(ld)26#define M32R_UNLOCK __STR(st)27#endif2829#ifdef __ASSEMBLY__30#undef ENTRY31#define ENTRY(name) ENTRY_M name32.macro ENTRY_M name33.global \name34ALIGN35\name:36.endm37#endif383940/**41* LDIMM - load immediate value42* STI - enable interruption43* CLI - disable interruption44*/4546#ifdef __ASSEMBLY__4748#define LDIMM(reg,x) LDIMM reg x49.macro LDIMM reg x50seth \reg, #high(\x)51or3 \reg, \reg, #low(\x)52.endm5354#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))55#define ENABLE_INTERRUPTS(reg) ENABLE_INTERRUPTS reg56.macro ENABLE_INTERRUPTS reg57setpsw #0x40 -> nop58; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).59.endm6061#define DISABLE_INTERRUPTS(reg) DISABLE_INTERRUPTS reg62.macro DISABLE_INTERRUPTS reg63clrpsw #0x40 -> nop64; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).65.endm66#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */67#define ENABLE_INTERRUPTS(reg) ENABLE_INTERRUPTS reg68.macro ENABLE_INTERRUPTS reg69mvfc \reg, psw70or3 \reg, \reg, #0x004071mvtc \reg, psw72.endm7374#define DISABLE_INTERRUPTS(reg) DISABLE_INTERRUPTS reg75.macro DISABLE_INTERRUPTS reg76mvfc \reg, psw77and3 \reg, \reg, #0xffbf78mvtc \reg, psw79.endm80#endif /* CONFIG_CHIP_M32102 */8182.macro SAVE_ALL83push r0 ; orig_r084push sp ; spi (r15)85push lr ; r1486push r1387mvfc r13, cr3 ; spu88push r1389mvfc r13, bbpc90push r1391mvfc r13, bbpsw92push r1393mvfc r13, bpc94push r1395mvfc r13, psw96push r1397#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)98mvfaclo r13, a199push r13100mvfachi r13, a1101push r13102mvfaclo r13, a0103push r13104mvfachi r13, a0105push r13106#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)107mvfaclo r13108push r13109mvfachi r13110push r13111ldi r13, #0112push r13 ; dummy push acc1h113push r13 ; dummy push acc1l114#else115#error unknown isa configuration116#endif117ldi r13, #-1118push r13 ; syscall_nr (default: -1)119push r12120push r11121push r10122push r9123push r8124push r7125push r3126push r2127push r1128push r0129addi sp, #-4 ; room for implicit pt_regs parameter130push r6131push r5132push r4133.endm134135.macro RESTORE_ALL136pop r4137pop r5138pop r6139addi sp, #4140pop r0141pop r1142pop r2143pop r3144pop r7145pop r8146pop r9147pop r10148pop r11149pop r12150addi r15, #4 ; Skip syscall number151#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)152pop r13153mvtachi r13, a0154pop r13155mvtaclo r13, a0156pop r13157mvtachi r13, a1158pop r13159mvtaclo r13, a1160#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)161pop r13 ; dummy pop acc1h162pop r13 ; dummy pop acc1l163pop r13164mvtachi r13165pop r13166mvtaclo r13167#else168#error unknown isa configuration169#endif170pop r14171mvtc r14, psw172pop r14173mvtc r14, bpc174addi sp, #8 ; Skip bbpsw, bbpc175pop r14176mvtc r14, cr3 ; spu177pop r13178pop lr ; r14179pop sp ; spi (r15)180addi sp, #4 ; Skip orig_r0181.fillinsn1821: rte183.section .fixup,"ax"1842: bl do_exit185.previous186.section __ex_table,"a"187ALIGN188.long 1b, 2b189.previous190.endm191192#define GET_CURRENT(reg) get_current reg193.macro get_current reg194ldi \reg, #-8192195and \reg, sp196.endm197198#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))199.macro SWITCH_TO_KERNEL_STACK200; switch to kernel stack (spi)201clrpsw #0x80 -> nop202.endm203#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */204.macro SWITCH_TO_KERNEL_STACK205push r0 ; save r0 for working206mvfc r0, psw207and3 r0, r0, #0x00ff7f208mvtc r0, psw209slli r0, #16210bltz r0, 1f ; check BSM-bit211;212;; called from kernel context: previous stack = spi213pop r0 ; retrieve r0214bra 2f215.fillinsn2161:217;; called from user context: previous stack = spu218mvfc r0, cr3 ; spu219addi r0, #4220mvtc r0, cr3 ; spu221ld r0, @(-4,r0) ; retrieve r0222.fillinsn2232:224.endm225#endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */226227#endif /* __ASSEMBLY__ */228229#endif /* _ASM_M32R_ASSEMBLER_H */230231232