/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __M68K_ENTRY_H2#define __M68K_ENTRY_H34#include <asm/setup.h>5#include <asm/page.h>6#ifdef __ASSEMBLER__7#include <asm/thread_info.h>8#endif910/*11* Stack layout in 'ret_from_exception':12*13* This allows access to the syscall arguments in registers d1-d514*15* 0(sp) - d116* 4(sp) - d217* 8(sp) - d318* C(sp) - d419* 10(sp) - d520* 14(sp) - a021* 18(sp) - a122* 1C(sp) - a223* 20(sp) - d024* 24(sp) - orig_d025* 28(sp) - stack adjustment26* 2C(sp) - [ sr ] [ format & vector ]27* 2E(sp) - [ pc-hiword ] [ sr ]28* 30(sp) - [ pc-loword ] [ pc-hiword ]29* 32(sp) - [ format & vector ] [ pc-loword ]30* ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^31* M68K COLDFIRE32*/3334/* the following macro is used when enabling interrupts */35#if defined(MACH_ATARI_ONLY)36/* block out HSYNC = ipl 2 on the atari */37#define ALLOWINT (~0x500)38#else39/* portable version */40#define ALLOWINT (~0x700)41#endif /* machine compilation types */4243#ifdef __ASSEMBLER__44/*45* This defines the normal kernel pt-regs layout.46*47* regs a3-a6 and d6-d7 are preserved by C code48* the kernel doesn't mess with usp unless it needs to49*/50#define SWITCH_STACK_SIZE (6*4+4) /* includes return address */5152#ifdef CONFIG_COLDFIRE53#ifdef CONFIG_COLDFIRE_SW_A754/*55* This is made a little more tricky on older ColdFires. There is no56* separate supervisor and user stack pointers. Need to artificially57* construct a usp in software... When doing this we need to disable58* interrupts, otherwise bad things will happen.59*/60.globl sw_usp61.globl sw_ksp6263.macro SAVE_ALL_SYS64move #0x2700,%sr /* disable intrs */65btst #5,%sp@(2) /* from user? */66bnes 6f /* no, skip */67movel %sp,sw_usp /* save user sp */68addql #8,sw_usp /* remove exception */69movel sw_ksp,%sp /* kernel sp */70subql #8,%sp /* room for exception */71clrl %sp@- /* stkadj */72movel %d0,%sp@- /* orig d0 */73movel %d0,%sp@- /* d0 */74lea %sp@(-32),%sp /* space for 8 regs */75moveml %d1-%d5/%a0-%a2,%sp@76movel sw_usp,%a0 /* get usp */77movel %a0@-,%sp@(PT_OFF_PC) /* copy exception program counter */78movel %a0@-,%sp@(PT_OFF_FORMATVEC)/*copy exception format/vector/sr */79bra 7f806:81clrl %sp@- /* stkadj */82movel %d0,%sp@- /* orig d0 */83movel %d0,%sp@- /* d0 */84lea %sp@(-32),%sp /* space for 8 regs */85moveml %d1-%d5/%a0-%a2,%sp@867:87.endm8889.macro SAVE_ALL_INT90SAVE_ALL_SYS91moveq #-1,%d0 /* not system call entry */92movel %d0,%sp@(PT_OFF_ORIG_D0)93.endm9495.macro RESTORE_USER96move #0x2700,%sr /* disable intrs */97movel sw_usp,%a0 /* get usp */98movel %sp@(PT_OFF_PC),%a0@- /* copy exception program counter */99movel %sp@(PT_OFF_FORMATVEC),%a0@-/*copy exception format/vector/sr */100moveml %sp@,%d1-%d5/%a0-%a2101lea %sp@(32),%sp /* space for 8 regs */102movel %sp@+,%d0103addql #4,%sp /* orig d0 */104addl %sp@+,%sp /* stkadj */105addql #8,%sp /* remove exception */106movel %sp,sw_ksp /* save ksp */107subql #8,sw_usp /* set exception */108movel sw_usp,%sp /* restore usp */109rte110.endm111112.macro RDUSP113movel sw_usp,%a3114.endm115116.macro WRUSP117movel %a3,sw_usp118.endm119120#else /* !CONFIG_COLDFIRE_SW_A7 */121/*122* Modern ColdFire parts have separate supervisor and user stack123* pointers. Simple load and restore macros for this case.124*/125.macro SAVE_ALL_SYS126move #0x2700,%sr /* disable intrs */127clrl %sp@- /* stkadj */128movel %d0,%sp@- /* orig d0 */129movel %d0,%sp@- /* d0 */130lea %sp@(-32),%sp /* space for 8 regs */131moveml %d1-%d5/%a0-%a2,%sp@132.endm133134.macro SAVE_ALL_INT135move #0x2700,%sr /* disable intrs */136clrl %sp@- /* stkadj */137pea -1:w /* orig d0 */138movel %d0,%sp@- /* d0 */139lea %sp@(-32),%sp /* space for 8 regs */140moveml %d1-%d5/%a0-%a2,%sp@141.endm142143.macro RESTORE_USER144moveml %sp@,%d1-%d5/%a0-%a2145lea %sp@(32),%sp /* space for 8 regs */146movel %sp@+,%d0147addql #4,%sp /* orig d0 */148addl %sp@+,%sp /* stkadj */149rte150.endm151152.macro RDUSP153/*move %usp,%a3*/154.word 0x4e6b155.endm156157.macro WRUSP158/*move %a3,%usp*/159.word 0x4e63160.endm161162#endif /* !CONFIG_COLDFIRE_SW_A7 */163164.macro SAVE_SWITCH_STACK165lea %sp@(-24),%sp /* 6 regs */166moveml %a3-%a6/%d6-%d7,%sp@167.endm168169.macro RESTORE_SWITCH_STACK170moveml %sp@,%a3-%a6/%d6-%d7171lea %sp@(24),%sp /* 6 regs */172.endm173174#else /* !CONFIG_COLDFIRE */175176/*177* All other types of m68k parts (68000, 680x0, CPU32) have the same178* entry and exit code.179*/180181/*182* a -1 in the orig_d0 field signifies183* that the stack frame is NOT for syscall184*/185.macro SAVE_ALL_INT186clrl %sp@- /* stk_adj */187pea -1:w /* orig d0 */188movel %d0,%sp@- /* d0 */189moveml %d1-%d5/%a0-%a2,%sp@-190.endm191192.macro SAVE_ALL_SYS193clrl %sp@- /* stk_adj */194movel %d0,%sp@- /* orig d0 */195movel %d0,%sp@- /* d0 */196moveml %d1-%d5/%a0-%a2,%sp@-197.endm198199.macro RESTORE_ALL200moveml %sp@+,%a0-%a2/%d1-%d5201movel %sp@+,%d0202addql #4,%sp /* orig d0 */203addl %sp@+,%sp /* stk adj */204rte205.endm206207208.macro SAVE_SWITCH_STACK209moveml %a3-%a6/%d6-%d7,%sp@-210.endm211212.macro RESTORE_SWITCH_STACK213moveml %sp@+,%a3-%a6/%d6-%d7214.endm215216#endif /* !CONFIG_COLDFIRE */217218/*219* Register %a2 is reserved and set to current task on MMU enabled systems.220* Non-MMU systems do not reserve %a2 in this way, and this definition is221* not used for them.222*/223#ifdef CONFIG_MMU224225#define curptr a2226227#define GET_CURRENT(tmp) get_current tmp228.macro get_current reg=%d0229movel %sp,\reg230andl #-THREAD_SIZE,\reg231movel \reg,%curptr232movel %curptr@,%curptr233.endm234235#else236237#define GET_CURRENT(tmp)238239#endif /* CONFIG_MMU */240241#else /* C source */242243#define STR(X) STR1(X)244#define STR1(X) #X245246#define SAVE_ALL_INT \247"clrl %%sp@-;" /* stk_adj */ \248"pea -1:w;" /* orig d0 = -1 */ \249"movel %%d0,%%sp@-;" /* d0 */ \250"moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"251252#define GET_CURRENT(tmp) \253"movel %%sp,"#tmp"\n\t" \254"andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \255"movel "#tmp",%%a2\n\t" \256"movel %%a2@,%%a2"257258#endif259260#endif /* __M68K_ENTRY_H */261262263