1ca54502bSMichal Simek/* 2ca54502bSMichal Simek * Low-level system-call handling, trap handlers and context-switching 3ca54502bSMichal Simek * 4ca54502bSMichal Simek * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 5ca54502bSMichal Simek * Copyright (C) 2008-2009 PetaLogix 6ca54502bSMichal Simek * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> 7ca54502bSMichal Simek * Copyright (C) 2001,2002 NEC Corporation 8ca54502bSMichal Simek * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org> 9ca54502bSMichal Simek * 10ca54502bSMichal Simek * This file is subject to the terms and conditions of the GNU General 11ca54502bSMichal Simek * Public License. See the file COPYING in the main directory of this 12ca54502bSMichal Simek * archive for more details. 13ca54502bSMichal Simek * 14ca54502bSMichal Simek * Written by Miles Bader <miles@gnu.org> 15ca54502bSMichal Simek * Heavily modified by John Williams for Microblaze 16ca54502bSMichal Simek */ 17ca54502bSMichal Simek 18ca54502bSMichal Simek#include <linux/sys.h> 19ca54502bSMichal Simek#include <linux/linkage.h> 20ca54502bSMichal Simek 21ca54502bSMichal Simek#include <asm/entry.h> 22ca54502bSMichal Simek#include <asm/current.h> 23ca54502bSMichal Simek#include <asm/processor.h> 24ca54502bSMichal Simek#include <asm/exceptions.h> 25ca54502bSMichal Simek#include <asm/asm-offsets.h> 26ca54502bSMichal Simek#include <asm/thread_info.h> 27ca54502bSMichal Simek 28ca54502bSMichal Simek#include <asm/page.h> 29ca54502bSMichal Simek#include <asm/unistd.h> 30ca54502bSMichal Simek 31ca54502bSMichal Simek#include <linux/errno.h> 32ca54502bSMichal Simek#include <asm/signal.h> 33ca54502bSMichal Simek 3411d51360SMichal Simek#undef DEBUG 3511d51360SMichal Simek 36ca54502bSMichal Simek/* The size of a state save frame. */ 37ca54502bSMichal Simek#define STATE_SAVE_SIZE (PT_SIZE + STATE_SAVE_ARG_SPACE) 38ca54502bSMichal Simek 39ca54502bSMichal Simek/* The offset of the struct pt_regs in a `state save frame' on the stack. */ 40ca54502bSMichal Simek#define PTO STATE_SAVE_ARG_SPACE /* 24 the space for args */ 41ca54502bSMichal Simek 42ca54502bSMichal Simek#define C_ENTRY(name) .globl name; .align 4; name 43ca54502bSMichal Simek 44ca54502bSMichal Simek/* 45ca54502bSMichal Simek * Various ways of setting and clearing BIP in flags reg. 46ca54502bSMichal Simek * This is mucky, but necessary using microblaze version that 47ca54502bSMichal Simek * allows msr ops to write to BIP 48ca54502bSMichal Simek */ 49ca54502bSMichal Simek#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 50ca54502bSMichal Simek .macro clear_bip 5166f7de86SMichal Simek msrclr r0, MSR_BIP 52ca54502bSMichal Simek nop 53ca54502bSMichal Simek .endm 54ca54502bSMichal Simek 55ca54502bSMichal Simek .macro set_bip 5666f7de86SMichal Simek msrset r0, MSR_BIP 57ca54502bSMichal Simek nop 58ca54502bSMichal Simek .endm 59ca54502bSMichal Simek 60ca54502bSMichal Simek .macro clear_eip 6166f7de86SMichal Simek msrclr r0, MSR_EIP 62ca54502bSMichal Simek nop 63ca54502bSMichal Simek .endm 64ca54502bSMichal Simek 65ca54502bSMichal Simek .macro set_ee 6666f7de86SMichal Simek msrset r0, MSR_EE 67ca54502bSMichal Simek nop 68ca54502bSMichal Simek .endm 69ca54502bSMichal Simek 70ca54502bSMichal Simek .macro disable_irq 7166f7de86SMichal Simek msrclr r0, MSR_IE 72ca54502bSMichal Simek nop 73ca54502bSMichal Simek .endm 74ca54502bSMichal Simek 75ca54502bSMichal Simek .macro enable_irq 7666f7de86SMichal Simek msrset r0, MSR_IE 77ca54502bSMichal Simek nop 78ca54502bSMichal Simek .endm 79ca54502bSMichal Simek 80ca54502bSMichal Simek .macro set_ums 8166f7de86SMichal Simek msrset r0, MSR_UMS 82ca54502bSMichal Simek nop 8366f7de86SMichal Simek msrclr r0, MSR_VMS 84ca54502bSMichal Simek nop 85ca54502bSMichal Simek .endm 86ca54502bSMichal Simek 87ca54502bSMichal Simek .macro set_vms 8866f7de86SMichal Simek msrclr r0, MSR_UMS 89ca54502bSMichal Simek nop 9066f7de86SMichal Simek msrset r0, MSR_VMS 91ca54502bSMichal Simek nop 92ca54502bSMichal Simek .endm 93ca54502bSMichal Simek 94b318067eSMichal Simek .macro clear_ums 9566f7de86SMichal Simek msrclr r0, MSR_UMS 96b318067eSMichal Simek nop 97b318067eSMichal Simek .endm 98b318067eSMichal Simek 99ca54502bSMichal Simek .macro clear_vms_ums 10066f7de86SMichal Simek msrclr r0, MSR_VMS | MSR_UMS 101ca54502bSMichal Simek nop 102ca54502bSMichal Simek .endm 103ca54502bSMichal Simek#else 104ca54502bSMichal Simek .macro clear_bip 105ca54502bSMichal Simek mfs r11, rmsr 106ca54502bSMichal Simek nop 107ca54502bSMichal Simek andi r11, r11, ~MSR_BIP 108ca54502bSMichal Simek mts rmsr, r11 109ca54502bSMichal Simek nop 110ca54502bSMichal Simek .endm 111ca54502bSMichal Simek 112ca54502bSMichal Simek .macro set_bip 113ca54502bSMichal Simek mfs r11, rmsr 114ca54502bSMichal Simek nop 115ca54502bSMichal Simek ori r11, r11, MSR_BIP 116ca54502bSMichal Simek mts rmsr, r11 117ca54502bSMichal Simek nop 118ca54502bSMichal Simek .endm 119ca54502bSMichal Simek 120ca54502bSMichal Simek .macro clear_eip 121ca54502bSMichal Simek mfs r11, rmsr 122ca54502bSMichal Simek nop 123ca54502bSMichal Simek andi r11, r11, ~MSR_EIP 124ca54502bSMichal Simek mts rmsr, r11 125ca54502bSMichal Simek nop 126ca54502bSMichal Simek .endm 127ca54502bSMichal Simek 128ca54502bSMichal Simek .macro set_ee 129ca54502bSMichal Simek mfs r11, rmsr 130ca54502bSMichal Simek nop 131ca54502bSMichal Simek ori r11, r11, MSR_EE 132ca54502bSMichal Simek mts rmsr, r11 133ca54502bSMichal Simek nop 134ca54502bSMichal Simek .endm 135ca54502bSMichal Simek 136ca54502bSMichal Simek .macro disable_irq 137ca54502bSMichal Simek mfs r11, rmsr 138ca54502bSMichal Simek nop 139ca54502bSMichal Simek andi r11, r11, ~MSR_IE 140ca54502bSMichal Simek mts rmsr, r11 141ca54502bSMichal Simek nop 142ca54502bSMichal Simek .endm 143ca54502bSMichal Simek 144ca54502bSMichal Simek .macro enable_irq 145ca54502bSMichal Simek mfs r11, rmsr 146ca54502bSMichal Simek nop 147ca54502bSMichal Simek ori r11, r11, MSR_IE 148ca54502bSMichal Simek mts rmsr, r11 149ca54502bSMichal Simek nop 150ca54502bSMichal Simek .endm 151ca54502bSMichal Simek 152ca54502bSMichal Simek .macro set_ums 153ca54502bSMichal Simek mfs r11, rmsr 154ca54502bSMichal Simek nop 155ca54502bSMichal Simek ori r11, r11, MSR_VMS 156ca54502bSMichal Simek andni r11, r11, MSR_UMS 157ca54502bSMichal Simek mts rmsr, r11 158ca54502bSMichal Simek nop 159ca54502bSMichal Simek .endm 160ca54502bSMichal Simek 161ca54502bSMichal Simek .macro set_vms 162ca54502bSMichal Simek mfs r11, rmsr 163ca54502bSMichal Simek nop 164ca54502bSMichal Simek ori r11, r11, MSR_VMS 165ca54502bSMichal Simek andni r11, r11, MSR_UMS 166ca54502bSMichal Simek mts rmsr, r11 167ca54502bSMichal Simek nop 168ca54502bSMichal Simek .endm 169ca54502bSMichal Simek 170b318067eSMichal Simek .macro clear_ums 171b318067eSMichal Simek mfs r11, rmsr 172b318067eSMichal Simek nop 173b318067eSMichal Simek andni r11, r11, MSR_UMS 174b318067eSMichal Simek mts rmsr,r11 175b318067eSMichal Simek nop 176b318067eSMichal Simek .endm 177b318067eSMichal Simek 178ca54502bSMichal Simek .macro clear_vms_ums 179ca54502bSMichal Simek mfs r11, rmsr 180ca54502bSMichal Simek nop 181ca54502bSMichal Simek andni r11, r11, (MSR_VMS|MSR_UMS) 182ca54502bSMichal Simek mts rmsr,r11 183ca54502bSMichal Simek nop 184ca54502bSMichal Simek .endm 185ca54502bSMichal Simek#endif 186ca54502bSMichal Simek 187ca54502bSMichal Simek/* Define how to call high-level functions. With MMU, virtual mode must be 188ca54502bSMichal Simek * enabled when calling the high-level function. Clobbers R11. 189ca54502bSMichal Simek * VM_ON, VM_OFF, DO_JUMP_BIPCLR, DO_CALL 190ca54502bSMichal Simek */ 191ca54502bSMichal Simek 192ca54502bSMichal Simek/* turn on virtual protected mode save */ 193ca54502bSMichal Simek#define VM_ON \ 194ca54502bSMichal Simek set_ums; \ 195ca54502bSMichal Simek rted r0, 2f; \ 196a4a94dbfSMichal Simek nop; \ 197a4a94dbfSMichal Simek2: 198ca54502bSMichal Simek 199ca54502bSMichal Simek/* turn off virtual protected mode save and user mode save*/ 200ca54502bSMichal Simek#define VM_OFF \ 201ca54502bSMichal Simek clear_vms_ums; \ 202ca54502bSMichal Simek rted r0, TOPHYS(1f); \ 203a4a94dbfSMichal Simek nop; \ 204a4a94dbfSMichal Simek1: 205ca54502bSMichal Simek 206ca54502bSMichal Simek#define SAVE_REGS \ 207ca54502bSMichal Simek swi r2, r1, PTO+PT_R2; /* Save SDA */ \ 20836f60954SMichal Simek swi r3, r1, PTO+PT_R3; \ 20936f60954SMichal Simek swi r4, r1, PTO+PT_R4; \ 210ca54502bSMichal Simek swi r5, r1, PTO+PT_R5; \ 211ca54502bSMichal Simek swi r6, r1, PTO+PT_R6; \ 212ca54502bSMichal Simek swi r7, r1, PTO+PT_R7; \ 213ca54502bSMichal Simek swi r8, r1, PTO+PT_R8; \ 214ca54502bSMichal Simek swi r9, r1, PTO+PT_R9; \ 215ca54502bSMichal Simek swi r10, r1, PTO+PT_R10; \ 216ca54502bSMichal Simek swi r11, r1, PTO+PT_R11; /* save clobbered regs after rval */\ 217ca54502bSMichal Simek swi r12, r1, PTO+PT_R12; \ 218ca54502bSMichal Simek swi r13, r1, PTO+PT_R13; /* Save SDA2 */ \ 219ca54502bSMichal Simek swi r14, r1, PTO+PT_PC; /* PC, before IRQ/trap */ \ 220ca54502bSMichal Simek swi r15, r1, PTO+PT_R15; /* Save LP */ \ 221ca54502bSMichal Simek swi r18, r1, PTO+PT_R18; /* Save asm scratch reg */ \ 222ca54502bSMichal Simek swi r19, r1, PTO+PT_R19; \ 223ca54502bSMichal Simek swi r20, r1, PTO+PT_R20; \ 224ca54502bSMichal Simek swi r21, r1, PTO+PT_R21; \ 225ca54502bSMichal Simek swi r22, r1, PTO+PT_R22; \ 226ca54502bSMichal Simek swi r23, r1, PTO+PT_R23; \ 227ca54502bSMichal Simek swi r24, r1, PTO+PT_R24; \ 228ca54502bSMichal Simek swi r25, r1, PTO+PT_R25; \ 229ca54502bSMichal Simek swi r26, r1, PTO+PT_R26; \ 230ca54502bSMichal Simek swi r27, r1, PTO+PT_R27; \ 231ca54502bSMichal Simek swi r28, r1, PTO+PT_R28; \ 232ca54502bSMichal Simek swi r29, r1, PTO+PT_R29; \ 233ca54502bSMichal Simek swi r30, r1, PTO+PT_R30; \ 234ca54502bSMichal Simek swi r31, r1, PTO+PT_R31; /* Save current task reg */ \ 235ca54502bSMichal Simek mfs r11, rmsr; /* save MSR */ \ 236ca54502bSMichal Simek nop; \ 237ca54502bSMichal Simek swi r11, r1, PTO+PT_MSR; 238ca54502bSMichal Simek 239ca54502bSMichal Simek#define RESTORE_REGS \ 240ca54502bSMichal Simek lwi r11, r1, PTO+PT_MSR; \ 241ca54502bSMichal Simek mts rmsr , r11; \ 242ca54502bSMichal Simek nop; \ 243ca54502bSMichal Simek lwi r2, r1, PTO+PT_R2; /* restore SDA */ \ 24436f60954SMichal Simek lwi r3, r1, PTO+PT_R3; \ 24536f60954SMichal Simek lwi r4, r1, PTO+PT_R4; \ 246ca54502bSMichal Simek lwi r5, r1, PTO+PT_R5; \ 247ca54502bSMichal Simek lwi r6, r1, PTO+PT_R6; \ 248ca54502bSMichal Simek lwi r7, r1, PTO+PT_R7; \ 249ca54502bSMichal Simek lwi r8, r1, PTO+PT_R8; \ 250ca54502bSMichal Simek lwi r9, r1, PTO+PT_R9; \ 251ca54502bSMichal Simek lwi r10, r1, PTO+PT_R10; \ 252ca54502bSMichal Simek lwi r11, r1, PTO+PT_R11; /* restore clobbered regs after rval */\ 253ca54502bSMichal Simek lwi r12, r1, PTO+PT_R12; \ 254ca54502bSMichal Simek lwi r13, r1, PTO+PT_R13; /* restore SDA2 */ \ 255ca54502bSMichal Simek lwi r14, r1, PTO+PT_PC; /* RESTORE_LINK PC, before IRQ/trap */\ 256ca54502bSMichal Simek lwi r15, r1, PTO+PT_R15; /* restore LP */ \ 257ca54502bSMichal Simek lwi r18, r1, PTO+PT_R18; /* restore asm scratch reg */ \ 258ca54502bSMichal Simek lwi r19, r1, PTO+PT_R19; \ 259ca54502bSMichal Simek lwi r20, r1, PTO+PT_R20; \ 260ca54502bSMichal Simek lwi r21, r1, PTO+PT_R21; \ 261ca54502bSMichal Simek lwi r22, r1, PTO+PT_R22; \ 262ca54502bSMichal Simek lwi r23, r1, PTO+PT_R23; \ 263ca54502bSMichal Simek lwi r24, r1, PTO+PT_R24; \ 264ca54502bSMichal Simek lwi r25, r1, PTO+PT_R25; \ 265ca54502bSMichal Simek lwi r26, r1, PTO+PT_R26; \ 266ca54502bSMichal Simek lwi r27, r1, PTO+PT_R27; \ 267ca54502bSMichal Simek lwi r28, r1, PTO+PT_R28; \ 268ca54502bSMichal Simek lwi r29, r1, PTO+PT_R29; \ 269ca54502bSMichal Simek lwi r30, r1, PTO+PT_R30; \ 270ca54502bSMichal Simek lwi r31, r1, PTO+PT_R31; /* Restore cur task reg */ 271ca54502bSMichal Simek 272*e5d2af2bSMichal Simek#define SAVE_STATE \ 273*e5d2af2bSMichal Simek swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* save stack */ \ 274*e5d2af2bSMichal Simek /* See if already in kernel mode.*/ \ 275*e5d2af2bSMichal Simek mfs r1, rmsr; \ 276*e5d2af2bSMichal Simek nop; \ 277*e5d2af2bSMichal Simek andi r1, r1, MSR_UMS; \ 278*e5d2af2bSMichal Simek bnei r1, 1f; \ 279*e5d2af2bSMichal Simek /* Kernel-mode state save. */ \ 280*e5d2af2bSMichal Simek /* Reload kernel stack-ptr. */ \ 281*e5d2af2bSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); \ 282*e5d2af2bSMichal Simek tophys(r1,r1); \ 283*e5d2af2bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */\ 284*e5d2af2bSMichal Simek SAVE_REGS \ 285*e5d2af2bSMichal Simek swi r1, r1, PTO+PT_MODE; \ 286*e5d2af2bSMichal Simek brid 2f; \ 287*e5d2af2bSMichal Simek nop; /* Fill delay slot */ \ 288*e5d2af2bSMichal Simek1: /* User-mode state save. */ \ 289*e5d2af2bSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */\ 290*e5d2af2bSMichal Simek tophys(r1,r1); \ 291*e5d2af2bSMichal Simek lwi r1, r1, TS_THREAD_INFO; /* get the thread info */ \ 292*e5d2af2bSMichal Simek addik r1, r1, THREAD_SIZE; /* calculate kernel stack pointer */\ 293*e5d2af2bSMichal Simek tophys(r1,r1); \ 294*e5d2af2bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */\ 295*e5d2af2bSMichal Simek SAVE_REGS \ 296*e5d2af2bSMichal Simek swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ \ 297*e5d2af2bSMichal Simek lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); \ 298*e5d2af2bSMichal Simek swi r11, r1, PTO+PT_R1; /* Store user SP. */ \ 299*e5d2af2bSMichal Simek /* MS: I am clearing UMS even in case when I come from kernel space */ \ 300*e5d2af2bSMichal Simek clear_ums; \ 301*e5d2af2bSMichal Simek2: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 302*e5d2af2bSMichal Simek 303ca54502bSMichal Simek.text 304ca54502bSMichal Simek 305ca54502bSMichal Simek/* 306ca54502bSMichal Simek * User trap. 307ca54502bSMichal Simek * 308ca54502bSMichal Simek * System calls are handled here. 309ca54502bSMichal Simek * 310ca54502bSMichal Simek * Syscall protocol: 311ca54502bSMichal Simek * Syscall number in r12, args in r5-r10 312ca54502bSMichal Simek * Return value in r3 313ca54502bSMichal Simek * 314ca54502bSMichal Simek * Trap entered via brki instruction, so BIP bit is set, and interrupts 315ca54502bSMichal Simek * are masked. This is nice, means we don't have to CLI before state save 316ca54502bSMichal Simek */ 317ca54502bSMichal SimekC_ENTRY(_user_exception): 318ca54502bSMichal Simek swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) /* save stack */ 319ca54502bSMichal Simek addi r14, r14, 4 /* return address is 4 byte after call */ 320ca54502bSMichal Simek 321653e447eSMichal Simek mfs r1, rmsr 3225c0d72b1SMichal Simek nop 323653e447eSMichal Simek andi r1, r1, MSR_UMS 324653e447eSMichal Simek bnei r1, 1f 3255c0d72b1SMichal Simek 3265c0d72b1SMichal Simek/* Kernel-mode state save - kernel execve */ 327653e447eSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/ 328653e447eSMichal Simek tophys(r1,r1); 329ca54502bSMichal Simek 330ca54502bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 331ca54502bSMichal Simek SAVE_REGS 332ca54502bSMichal Simek 33377f6d226SMichal Simek swi r1, r1, PTO + PT_MODE; /* pt_regs -> kernel mode */ 334ca54502bSMichal Simek brid 2f; 335ca54502bSMichal Simek nop; /* Fill delay slot */ 336ca54502bSMichal Simek 337ca54502bSMichal Simek/* User-mode state save. */ 338ca54502bSMichal Simek1: 339ca54502bSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */ 340ca54502bSMichal Simek tophys(r1,r1); 341ca54502bSMichal Simek lwi r1, r1, TS_THREAD_INFO; /* get stack from task_struct */ 342ca54502bSMichal Simek/* calculate kernel stack pointer from task struct 8k */ 343ca54502bSMichal Simek addik r1, r1, THREAD_SIZE; 344ca54502bSMichal Simek tophys(r1,r1); 345ca54502bSMichal Simek 346ca54502bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 347ca54502bSMichal Simek SAVE_REGS 348ca54502bSMichal Simek 349ca54502bSMichal Simek swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ 350ca54502bSMichal Simek lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 351ca54502bSMichal Simek swi r11, r1, PTO+PT_R1; /* Store user SP. */ 352b1d70c62SMichal Simek2: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 353ca54502bSMichal Simek /* Save away the syscall number. */ 354ca54502bSMichal Simek swi r12, r1, PTO+PT_R0; 355ca54502bSMichal Simek tovirt(r1,r1) 356ca54502bSMichal Simek 357ca54502bSMichal Simek/* where the trap should return need -8 to adjust for rtsd r15, 8*/ 358ca54502bSMichal Simek/* Jump to the appropriate function for the system call number in r12 359ca54502bSMichal Simek * (r12 is not preserved), or return an error if r12 is not valid. The LP 360ca54502bSMichal Simek * register should point to the location where 361ca54502bSMichal Simek * the called function should return. [note that MAKE_SYS_CALL uses label 1] */ 36223575483SMichal Simek 36323575483SMichal Simek # Step into virtual mode. 36423575483SMichal Simek set_vms; 36523575483SMichal Simek addik r11, r0, 3f 36623575483SMichal Simek rtid r11, 0 36723575483SMichal Simek nop 36823575483SMichal Simek3: 369b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO /* get thread info */ 37023575483SMichal Simek lwi r11, r11, TI_FLAGS /* get flags in thread info */ 37123575483SMichal Simek andi r11, r11, _TIF_WORK_SYSCALL_MASK 37223575483SMichal Simek beqi r11, 4f 37323575483SMichal Simek 37423575483SMichal Simek addik r3, r0, -ENOSYS 37523575483SMichal Simek swi r3, r1, PTO + PT_R3 37623575483SMichal Simek brlid r15, do_syscall_trace_enter 37723575483SMichal Simek addik r5, r1, PTO + PT_R0 37823575483SMichal Simek 37923575483SMichal Simek # do_syscall_trace_enter returns the new syscall nr. 38023575483SMichal Simek addk r12, r0, r3 38123575483SMichal Simek lwi r5, r1, PTO+PT_R5; 38223575483SMichal Simek lwi r6, r1, PTO+PT_R6; 38323575483SMichal Simek lwi r7, r1, PTO+PT_R7; 38423575483SMichal Simek lwi r8, r1, PTO+PT_R8; 38523575483SMichal Simek lwi r9, r1, PTO+PT_R9; 38623575483SMichal Simek lwi r10, r1, PTO+PT_R10; 38723575483SMichal Simek4: 38823575483SMichal Simek/* Jump to the appropriate function for the system call number in r12 38923575483SMichal Simek * (r12 is not preserved), or return an error if r12 is not valid. 39023575483SMichal Simek * The LP register should point to the location where the called function 39123575483SMichal Simek * should return. [note that MAKE_SYS_CALL uses label 1] */ 39223575483SMichal Simek /* See if the system call number is valid */ 393ca54502bSMichal Simek addi r11, r12, -__NR_syscalls; 39423575483SMichal Simek bgei r11,5f; 395ca54502bSMichal Simek /* Figure out which function to use for this system call. */ 396ca54502bSMichal Simek /* Note Microblaze barrel shift is optional, so don't rely on it */ 397ca54502bSMichal Simek add r12, r12, r12; /* convert num -> ptr */ 398ca54502bSMichal Simek add r12, r12, r12; 399ca54502bSMichal Simek 40011d51360SMichal Simek#ifdef DEBUG 401ca54502bSMichal Simek /* Trac syscalls and stored them to r0_ram */ 40223575483SMichal Simek lwi r3, r12, 0x400 + r0_ram 403ca54502bSMichal Simek addi r3, r3, 1 40423575483SMichal Simek swi r3, r12, 0x400 + r0_ram 40511d51360SMichal Simek#endif 406ca54502bSMichal Simek 40723575483SMichal Simek # Find and jump into the syscall handler. 40823575483SMichal Simek lwi r12, r12, sys_call_table 40923575483SMichal Simek /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 410b9ea77e2SMichal Simek addi r15, r0, ret_from_trap-8 41123575483SMichal Simek bra r12 41223575483SMichal Simek 413ca54502bSMichal Simek /* The syscall number is invalid, return an error. */ 41423575483SMichal Simek5: 415ca54502bSMichal Simek addi r3, r0, -ENOSYS; 416ca54502bSMichal Simek rtsd r15,8; /* looks like a normal subroutine return */ 417ca54502bSMichal Simek or r0, r0, r0 418ca54502bSMichal Simek 419ca54502bSMichal Simek 42023575483SMichal Simek/* Entry point used to return from a syscall/trap */ 421ca54502bSMichal Simek/* We re-enable BIP bit before state restore */ 422ca54502bSMichal SimekC_ENTRY(ret_from_trap): 423b1d70c62SMichal Simek swi r3, r1, PTO + PT_R3 424b1d70c62SMichal Simek swi r4, r1, PTO + PT_R4 425b1d70c62SMichal Simek 42636f60954SMichal Simek lwi r11, r1, PTO + PT_MODE; 42736f60954SMichal Simek/* See if returning to kernel mode, if so, skip resched &c. */ 42836f60954SMichal Simek bnei r11, 2f; 429ca54502bSMichal Simek /* We're returning to user mode, so check for various conditions that 430ca54502bSMichal Simek * trigger rescheduling. */ 431b1d70c62SMichal Simek /* FIXME: Restructure all these flag checks. */ 432b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ 43323575483SMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 43423575483SMichal Simek andi r11, r11, _TIF_WORK_SYSCALL_MASK 43523575483SMichal Simek beqi r11, 1f 43623575483SMichal Simek 43723575483SMichal Simek brlid r15, do_syscall_trace_leave 43823575483SMichal Simek addik r5, r1, PTO + PT_R0 43923575483SMichal Simek1: 44023575483SMichal Simek /* We're returning to user mode, so check for various conditions that 44123575483SMichal Simek * trigger rescheduling. */ 442b1d70c62SMichal Simek /* get thread info from current task */ 443b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; 444ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 445ca54502bSMichal Simek andi r11, r11, _TIF_NEED_RESCHED; 446ca54502bSMichal Simek beqi r11, 5f; 447ca54502bSMichal Simek 448ca54502bSMichal Simek bralid r15, schedule; /* Call scheduler */ 449ca54502bSMichal Simek nop; /* delay slot */ 450ca54502bSMichal Simek 451ca54502bSMichal Simek /* Maybe handle a signal */ 452b1d70c62SMichal Simek5: /* get thread info from current task*/ 453b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; 454ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 455ca54502bSMichal Simek andi r11, r11, _TIF_SIGPENDING; 456ca54502bSMichal Simek beqi r11, 1f; /* Signals to handle, handle them */ 457ca54502bSMichal Simek 458b9ea77e2SMichal Simek addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 459ca54502bSMichal Simek addi r7, r0, 1; /* Arg 3: int in_syscall */ 460ca54502bSMichal Simek bralid r15, do_signal; /* Handle any signals */ 461841d6e8cSMichal Simek add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 462b1d70c62SMichal Simek 463b1d70c62SMichal Simek/* Finally, return to user state. */ 46496014cc3SMichal Simek1: set_bip; /* Ints masked for state restore */ 4658633bebcSMichal Simek swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ 466ca54502bSMichal Simek VM_OFF; 467ca54502bSMichal Simek tophys(r1,r1); 468ca54502bSMichal Simek RESTORE_REGS; 469ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 470ca54502bSMichal Simek lwi r1, r1, PT_R1 - PT_SIZE;/* Restore user stack pointer. */ 471ca54502bSMichal Simek bri 6f; 472ca54502bSMichal Simek 473ca54502bSMichal Simek/* Return to kernel state. */ 47496014cc3SMichal Simek2: set_bip; /* Ints masked for state restore */ 47596014cc3SMichal Simek VM_OFF; 476ca54502bSMichal Simek tophys(r1,r1); 477ca54502bSMichal Simek RESTORE_REGS; 478ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 479ca54502bSMichal Simek tovirt(r1,r1); 480ca54502bSMichal Simek6: 481ca54502bSMichal SimekTRAP_return: /* Make global symbol for debugging */ 482ca54502bSMichal Simek rtbd r14, 0; /* Instructions to return from an IRQ */ 483ca54502bSMichal Simek nop; 484ca54502bSMichal Simek 485ca54502bSMichal Simek 486ca54502bSMichal Simek/* These syscalls need access to the struct pt_regs on the stack, so we 487ca54502bSMichal Simek implement them in assembly (they're basically all wrappers anyway). */ 488ca54502bSMichal Simek 489ca54502bSMichal SimekC_ENTRY(sys_fork_wrapper): 490ca54502bSMichal Simek addi r5, r0, SIGCHLD /* Arg 0: flags */ 491ca54502bSMichal Simek lwi r6, r1, PTO+PT_R1 /* Arg 1: child SP (use parent's) */ 492b9ea77e2SMichal Simek addik r7, r1, PTO /* Arg 2: parent context */ 493ca54502bSMichal Simek add r8. r0, r0 /* Arg 3: (unused) */ 494ca54502bSMichal Simek add r9, r0, r0; /* Arg 4: (unused) */ 495ca54502bSMichal Simek add r10, r0, r0; /* Arg 5: (unused) */ 496ca54502bSMichal Simek brid do_fork /* Do real work (tail-call) */ 497ca54502bSMichal Simek nop; 498ca54502bSMichal Simek 499ca54502bSMichal Simek/* This the initial entry point for a new child thread, with an appropriate 500ca54502bSMichal Simek stack in place that makes it look the the child is in the middle of an 501ca54502bSMichal Simek syscall. This function is actually `returned to' from switch_thread 502ca54502bSMichal Simek (copy_thread makes ret_from_fork the return address in each new thread's 503ca54502bSMichal Simek saved context). */ 504ca54502bSMichal SimekC_ENTRY(ret_from_fork): 505ca54502bSMichal Simek bralid r15, schedule_tail; /* ...which is schedule_tail's arg */ 506ca54502bSMichal Simek add r3, r5, r0; /* switch_thread returns the prev task */ 507ca54502bSMichal Simek /* ( in the delay slot ) */ 508ca54502bSMichal Simek add r3, r0, r0; /* Child's fork call should return 0. */ 509ca54502bSMichal Simek brid ret_from_trap; /* Do normal trap return */ 510ca54502bSMichal Simek nop; 511ca54502bSMichal Simek 512e513588fSArnd BergmannC_ENTRY(sys_vfork): 513e513588fSArnd Bergmann brid microblaze_vfork /* Do real work (tail-call) */ 514b9ea77e2SMichal Simek addik r5, r1, PTO 515ca54502bSMichal Simek 516e513588fSArnd BergmannC_ENTRY(sys_clone): 517ca54502bSMichal Simek bnei r6, 1f; /* See if child SP arg (arg 1) is 0. */ 518ca54502bSMichal Simek lwi r6, r1, PTO + PT_R1; /* If so, use paret's stack ptr */ 519b9ea77e2SMichal Simek1: addik r7, r1, PTO; /* Arg 2: parent context */ 520b9ea77e2SMichal Simek add r8, r0, r0; /* Arg 3: (unused) */ 521b9ea77e2SMichal Simek add r9, r0, r0; /* Arg 4: (unused) */ 522b9ea77e2SMichal Simek add r10, r0, r0; /* Arg 5: (unused) */ 523ca54502bSMichal Simek brid do_fork /* Do real work (tail-call) */ 524b9ea77e2SMichal Simek nop; 525ca54502bSMichal Simek 526e513588fSArnd BergmannC_ENTRY(sys_execve): 527b9ea77e2SMichal Simek addik r8, r1, PTO; /* add user context as 4th arg */ 528e513588fSArnd Bergmann brid microblaze_execve; /* Do real work (tail-call).*/ 529ca54502bSMichal Simek nop; 530ca54502bSMichal Simek 531ca54502bSMichal SimekC_ENTRY(sys_rt_sigreturn_wrapper): 532ca54502bSMichal Simek swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ 533ca54502bSMichal Simek swi r4, r1, PTO+PT_R4; 534b9ea77e2SMichal Simek addik r5, r1, PTO; /* add user context as 1st arg */ 535ca54502bSMichal Simek brlid r15, sys_rt_sigreturn /* Do real work */ 536ca54502bSMichal Simek nop; 537ca54502bSMichal Simek lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ 538ca54502bSMichal Simek lwi r4, r1, PTO+PT_R4; 539ca54502bSMichal Simek bri ret_from_trap /* fall through will not work here due to align */ 540ca54502bSMichal Simek nop; 541ca54502bSMichal Simek 542ca54502bSMichal Simek/* 543ca54502bSMichal Simek * HW EXCEPTION rutine start 544ca54502bSMichal Simek */ 545ca54502bSMichal SimekC_ENTRY(full_exception_trap): 546ca54502bSMichal Simek /* adjust exception address for privileged instruction 547ca54502bSMichal Simek * for finding where is it */ 548ca54502bSMichal Simek addik r17, r17, -4 549ca54502bSMichal Simek SAVE_STATE /* Save registers */ 55006a54604SMichal Simek /* PC, before IRQ/trap - this is one instruction above */ 55106a54604SMichal Simek swi r17, r1, PTO+PT_PC; 55206a54604SMichal Simek tovirt(r1,r1) 553ca54502bSMichal Simek /* FIXME this can be store directly in PT_ESR reg. 554ca54502bSMichal Simek * I tested it but there is a fault */ 555ca54502bSMichal Simek /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 556b9ea77e2SMichal Simek addik r15, r0, ret_from_exc - 8 557b9ea77e2SMichal Simek addik r5, r1, PTO /* parameter struct pt_regs * regs */ 558ca54502bSMichal Simek mfs r6, resr 559ca54502bSMichal Simek nop 560ca54502bSMichal Simek mfs r7, rfsr; /* save FSR */ 561ca54502bSMichal Simek nop 562131e4e97SMichal Simek mts rfsr, r0; /* Clear sticky fsr */ 563131e4e97SMichal Simek nop 564c318d483SMichal Simek rted r0, full_exception 565c318d483SMichal Simek nop 566ca54502bSMichal Simek 567ca54502bSMichal Simek/* 568ca54502bSMichal Simek * Unaligned data trap. 569ca54502bSMichal Simek * 570ca54502bSMichal Simek * Unaligned data trap last on 4k page is handled here. 571ca54502bSMichal Simek * 572ca54502bSMichal Simek * Trap entered via exception, so EE bit is set, and interrupts 573ca54502bSMichal Simek * are masked. This is nice, means we don't have to CLI before state save 574ca54502bSMichal Simek * 575ca54502bSMichal Simek * The assembler routine is in "arch/microblaze/kernel/hw_exception_handler.S" 576ca54502bSMichal Simek */ 577ca54502bSMichal SimekC_ENTRY(unaligned_data_trap): 5788b110d15SMichal Simek /* MS: I have to save r11 value and then restore it because 5798b110d15SMichal Simek * set_bit, clear_eip, set_ee use r11 as temp register if MSR 5808b110d15SMichal Simek * instructions are not used. We don't need to do if MSR instructions 5818b110d15SMichal Simek * are used and they use r0 instead of r11. 5828b110d15SMichal Simek * I am using ENTRY_SP which should be primary used only for stack 5838b110d15SMichal Simek * pointer saving. */ 5848b110d15SMichal Simek swi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 5858b110d15SMichal Simek set_bip; /* equalize initial state for all possible entries */ 5868b110d15SMichal Simek clear_eip; 5878b110d15SMichal Simek set_ee; 5888b110d15SMichal Simek lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 589ca54502bSMichal Simek SAVE_STATE /* Save registers.*/ 59006a54604SMichal Simek /* PC, before IRQ/trap - this is one instruction above */ 59106a54604SMichal Simek swi r17, r1, PTO+PT_PC; 59206a54604SMichal Simek tovirt(r1,r1) 593ca54502bSMichal Simek /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 594b9ea77e2SMichal Simek addik r15, r0, ret_from_exc-8 595ca54502bSMichal Simek mfs r3, resr /* ESR */ 596ca54502bSMichal Simek nop 597ca54502bSMichal Simek mfs r4, rear /* EAR */ 598ca54502bSMichal Simek nop 599c318d483SMichal Simek rtbd r0, _unaligned_data_exception 600b9ea77e2SMichal Simek addik r7, r1, PTO /* parameter struct pt_regs * regs */ 601ca54502bSMichal Simek 602ca54502bSMichal Simek/* 603ca54502bSMichal Simek * Page fault traps. 604ca54502bSMichal Simek * 605ca54502bSMichal Simek * If the real exception handler (from hw_exception_handler.S) didn't find 606ca54502bSMichal Simek * the mapping for the process, then we're thrown here to handle such situation. 607ca54502bSMichal Simek * 608ca54502bSMichal Simek * Trap entered via exceptions, so EE bit is set, and interrupts 609ca54502bSMichal Simek * are masked. This is nice, means we don't have to CLI before state save 610ca54502bSMichal Simek * 611ca54502bSMichal Simek * Build a standard exception frame for TLB Access errors. All TLB exceptions 612ca54502bSMichal Simek * will bail out to this point if they can't resolve the lightweight TLB fault. 613ca54502bSMichal Simek * 614ca54502bSMichal Simek * The C function called is in "arch/microblaze/mm/fault.c", declared as: 615ca54502bSMichal Simek * void do_page_fault(struct pt_regs *regs, 616ca54502bSMichal Simek * unsigned long address, 617ca54502bSMichal Simek * unsigned long error_code) 618ca54502bSMichal Simek */ 619ca54502bSMichal Simek/* data and intruction trap - which is choose is resolved int fault.c */ 620ca54502bSMichal SimekC_ENTRY(page_fault_data_trap): 621ca54502bSMichal Simek SAVE_STATE /* Save registers.*/ 62206a54604SMichal Simek /* PC, before IRQ/trap - this is one instruction above */ 62306a54604SMichal Simek swi r17, r1, PTO+PT_PC; 62406a54604SMichal Simek tovirt(r1,r1) 625ca54502bSMichal Simek /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 626b9ea77e2SMichal Simek addik r15, r0, ret_from_exc-8 627b9ea77e2SMichal Simek addik r5, r1, PTO /* parameter struct pt_regs * regs */ 628ca54502bSMichal Simek mfs r6, rear /* parameter unsigned long address */ 629ca54502bSMichal Simek nop 630ca54502bSMichal Simek mfs r7, resr /* parameter unsigned long error_code */ 631ca54502bSMichal Simek nop 632c318d483SMichal Simek rted r0, do_page_fault 633c318d483SMichal Simek nop 634ca54502bSMichal Simek 635ca54502bSMichal SimekC_ENTRY(page_fault_instr_trap): 636ca54502bSMichal Simek SAVE_STATE /* Save registers.*/ 63706a54604SMichal Simek /* PC, before IRQ/trap - this is one instruction above */ 63806a54604SMichal Simek swi r17, r1, PTO+PT_PC; 63906a54604SMichal Simek tovirt(r1,r1) 640ca54502bSMichal Simek /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 641b9ea77e2SMichal Simek addik r15, r0, ret_from_exc-8 642b9ea77e2SMichal Simek addik r5, r1, PTO /* parameter struct pt_regs * regs */ 643ca54502bSMichal Simek mfs r6, rear /* parameter unsigned long address */ 644ca54502bSMichal Simek nop 645c318d483SMichal Simek rted r0, do_page_fault 646ca54502bSMichal Simek ori r7, r0, 0 /* parameter unsigned long error_code */ 647ca54502bSMichal Simek 648ca54502bSMichal Simek/* Entry point used to return from an exception. */ 649ca54502bSMichal SimekC_ENTRY(ret_from_exc): 650ca54502bSMichal Simek lwi r11, r1, PTO + PT_MODE; 651ca54502bSMichal Simek bnei r11, 2f; /* See if returning to kernel mode, */ 652ca54502bSMichal Simek /* ... if so, skip resched &c. */ 653ca54502bSMichal Simek 654ca54502bSMichal Simek /* We're returning to user mode, so check for various conditions that 655ca54502bSMichal Simek trigger rescheduling. */ 656b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ 657ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 658ca54502bSMichal Simek andi r11, r11, _TIF_NEED_RESCHED; 659ca54502bSMichal Simek beqi r11, 5f; 660ca54502bSMichal Simek 661ca54502bSMichal Simek/* Call the scheduler before returning from a syscall/trap. */ 662ca54502bSMichal Simek bralid r15, schedule; /* Call scheduler */ 663ca54502bSMichal Simek nop; /* delay slot */ 664ca54502bSMichal Simek 665ca54502bSMichal Simek /* Maybe handle a signal */ 666b1d70c62SMichal Simek5: lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ 667ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 668ca54502bSMichal Simek andi r11, r11, _TIF_SIGPENDING; 669ca54502bSMichal Simek beqi r11, 1f; /* Signals to handle, handle them */ 670ca54502bSMichal Simek 671ca54502bSMichal Simek /* 672ca54502bSMichal Simek * Handle a signal return; Pending signals should be in r18. 673ca54502bSMichal Simek * 674ca54502bSMichal Simek * Not all registers are saved by the normal trap/interrupt entry 675ca54502bSMichal Simek * points (for instance, call-saved registers (because the normal 676ca54502bSMichal Simek * C-compiler calling sequence in the kernel makes sure they're 677ca54502bSMichal Simek * preserved), and call-clobbered registers in the case of 678ca54502bSMichal Simek * traps), but signal handlers may want to examine or change the 679ca54502bSMichal Simek * complete register state. Here we save anything not saved by 680ca54502bSMichal Simek * the normal entry sequence, so that it may be safely restored 68136f60954SMichal Simek * (in a possibly modified form) after do_signal returns. */ 682b9ea77e2SMichal Simek addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 683ca54502bSMichal Simek addi r7, r0, 0; /* Arg 3: int in_syscall */ 684ca54502bSMichal Simek bralid r15, do_signal; /* Handle any signals */ 685841d6e8cSMichal Simek add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 686ca54502bSMichal Simek 687ca54502bSMichal Simek/* Finally, return to user state. */ 68896014cc3SMichal Simek1: set_bip; /* Ints masked for state restore */ 6898633bebcSMichal Simek swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ 690ca54502bSMichal Simek VM_OFF; 691ca54502bSMichal Simek tophys(r1,r1); 692ca54502bSMichal Simek 693ca54502bSMichal Simek RESTORE_REGS; 694ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 695ca54502bSMichal Simek 696ca54502bSMichal Simek lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer. */ 697ca54502bSMichal Simek bri 6f; 698ca54502bSMichal Simek/* Return to kernel state. */ 69996014cc3SMichal Simek2: set_bip; /* Ints masked for state restore */ 70096014cc3SMichal Simek VM_OFF; 701ca54502bSMichal Simek tophys(r1,r1); 702ca54502bSMichal Simek RESTORE_REGS; 703ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 704ca54502bSMichal Simek 705ca54502bSMichal Simek tovirt(r1,r1); 706ca54502bSMichal Simek6: 707ca54502bSMichal SimekEXC_return: /* Make global symbol for debugging */ 708ca54502bSMichal Simek rtbd r14, 0; /* Instructions to return from an IRQ */ 709ca54502bSMichal Simek nop; 710ca54502bSMichal Simek 711ca54502bSMichal Simek/* 712ca54502bSMichal Simek * HW EXCEPTION rutine end 713ca54502bSMichal Simek */ 714ca54502bSMichal Simek 715ca54502bSMichal Simek/* 716ca54502bSMichal Simek * Hardware maskable interrupts. 717ca54502bSMichal Simek * 718ca54502bSMichal Simek * The stack-pointer (r1) should have already been saved to the memory 719ca54502bSMichal Simek * location PER_CPU(ENTRY_SP). 720ca54502bSMichal Simek */ 721ca54502bSMichal SimekC_ENTRY(_interrupt): 722ca54502bSMichal Simek/* MS: we are in physical address */ 723ca54502bSMichal Simek/* Save registers, switch to proper stack, convert SP to virtual.*/ 724ca54502bSMichal Simek swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) 725ca54502bSMichal Simek /* MS: See if already in kernel mode. */ 726653e447eSMichal Simek mfs r1, rmsr 7275c0d72b1SMichal Simek nop 728653e447eSMichal Simek andi r1, r1, MSR_UMS 729653e447eSMichal Simek bnei r1, 1f 730ca54502bSMichal Simek 731ca54502bSMichal Simek/* Kernel-mode state save. */ 732653e447eSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) 733653e447eSMichal Simek tophys(r1,r1); /* MS: I have in r1 physical address where stack is */ 734ca54502bSMichal Simek /* save registers */ 735ca54502bSMichal Simek/* MS: Make room on the stack -> activation record */ 736ca54502bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; 737ca54502bSMichal Simek SAVE_REGS 73877f6d226SMichal Simek swi r1, r1, PTO + PT_MODE; /* 0 - user mode, 1 - kernel mode */ 739ca54502bSMichal Simek brid 2f; 740ca54502bSMichal Simek nop; /* MS: Fill delay slot */ 741ca54502bSMichal Simek 742ca54502bSMichal Simek1: 743ca54502bSMichal Simek/* User-mode state save. */ 744ca54502bSMichal Simek /* MS: get the saved current */ 745ca54502bSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 746ca54502bSMichal Simek tophys(r1,r1); 747ca54502bSMichal Simek lwi r1, r1, TS_THREAD_INFO; 748ca54502bSMichal Simek addik r1, r1, THREAD_SIZE; 749ca54502bSMichal Simek tophys(r1,r1); 750ca54502bSMichal Simek /* save registers */ 751ca54502bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; 752ca54502bSMichal Simek SAVE_REGS 753ca54502bSMichal Simek /* calculate mode */ 754ca54502bSMichal Simek swi r0, r1, PTO + PT_MODE; 755ca54502bSMichal Simek lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 756ca54502bSMichal Simek swi r11, r1, PTO+PT_R1; 757ca54502bSMichal Simek2: 758b1d70c62SMichal Simek lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 759ca54502bSMichal Simek tovirt(r1,r1) 760b9ea77e2SMichal Simek addik r5, r1, PTO; 761ca54502bSMichal Simek set_vms; 762b9ea77e2SMichal Simek addik r11, r0, do_IRQ; 763b9ea77e2SMichal Simek addik r15, r0, irq_call; 764ca54502bSMichal Simekirq_call:rtbd r11, 0; 765ca54502bSMichal Simek nop; 766ca54502bSMichal Simek 767ca54502bSMichal Simek/* MS: we are in virtual mode */ 768ca54502bSMichal Simekret_from_irq: 769ca54502bSMichal Simek lwi r11, r1, PTO + PT_MODE; 770ca54502bSMichal Simek bnei r11, 2f; 771ca54502bSMichal Simek 772b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; 773ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* MS: get flags from thread info */ 774ca54502bSMichal Simek andi r11, r11, _TIF_NEED_RESCHED; 775ca54502bSMichal Simek beqi r11, 5f 776ca54502bSMichal Simek bralid r15, schedule; 777ca54502bSMichal Simek nop; /* delay slot */ 778ca54502bSMichal Simek 779ca54502bSMichal Simek /* Maybe handle a signal */ 780b1d70c62SMichal Simek5: lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* MS: get thread info */ 781ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 782ca54502bSMichal Simek andi r11, r11, _TIF_SIGPENDING; 783ca54502bSMichal Simek beqid r11, no_intr_resched 784ca54502bSMichal Simek/* Handle a signal return; Pending signals should be in r18. */ 785ca54502bSMichal Simek addi r7, r0, 0; /* Arg 3: int in_syscall */ 786b9ea77e2SMichal Simek addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 787ca54502bSMichal Simek bralid r15, do_signal; /* Handle any signals */ 788ca54502bSMichal Simek add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 789ca54502bSMichal Simek 790ca54502bSMichal Simek/* Finally, return to user state. */ 791ca54502bSMichal Simekno_intr_resched: 792ca54502bSMichal Simek /* Disable interrupts, we are now committed to the state restore */ 793ca54502bSMichal Simek disable_irq 7948633bebcSMichal Simek swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); 795ca54502bSMichal Simek VM_OFF; 796ca54502bSMichal Simek tophys(r1,r1); 797ca54502bSMichal Simek RESTORE_REGS 798ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ 799ca54502bSMichal Simek lwi r1, r1, PT_R1 - PT_SIZE; 800ca54502bSMichal Simek bri 6f; 801ca54502bSMichal Simek/* MS: Return to kernel state. */ 80277753790SMichal Simek2: 80377753790SMichal Simek#ifdef CONFIG_PREEMPT 804b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; 80577753790SMichal Simek /* MS: get preempt_count from thread info */ 80677753790SMichal Simek lwi r5, r11, TI_PREEMPT_COUNT; 80777753790SMichal Simek bgti r5, restore; 80877753790SMichal Simek 80977753790SMichal Simek lwi r5, r11, TI_FLAGS; /* get flags in thread info */ 81077753790SMichal Simek andi r5, r5, _TIF_NEED_RESCHED; 81177753790SMichal Simek beqi r5, restore /* if zero jump over */ 81277753790SMichal Simek 81377753790SMichal Simekpreempt: 81477753790SMichal Simek /* interrupts are off that's why I am calling preempt_chedule_irq */ 81577753790SMichal Simek bralid r15, preempt_schedule_irq 81677753790SMichal Simek nop 817b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ 81877753790SMichal Simek lwi r5, r11, TI_FLAGS; /* get flags in thread info */ 81977753790SMichal Simek andi r5, r5, _TIF_NEED_RESCHED; 82077753790SMichal Simek bnei r5, preempt /* if non zero jump to resched */ 82177753790SMichal Simekrestore: 82277753790SMichal Simek#endif 82377753790SMichal Simek VM_OFF /* MS: turn off MMU */ 824ca54502bSMichal Simek tophys(r1,r1) 825ca54502bSMichal Simek RESTORE_REGS 826ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ 827ca54502bSMichal Simek tovirt(r1,r1); 828ca54502bSMichal Simek6: 829ca54502bSMichal SimekIRQ_return: /* MS: Make global symbol for debugging */ 830ca54502bSMichal Simek rtid r14, 0 831ca54502bSMichal Simek nop 832ca54502bSMichal Simek 833ca54502bSMichal Simek/* 834ca54502bSMichal Simek * `Debug' trap 835ca54502bSMichal Simek * We enter dbtrap in "BIP" (breakpoint) mode. 836ca54502bSMichal Simek * So we exit the breakpoint mode with an 'rtbd' and proceed with the 837ca54502bSMichal Simek * original dbtrap. 838ca54502bSMichal Simek * however, wait to save state first 839ca54502bSMichal Simek */ 840ca54502bSMichal SimekC_ENTRY(_debug_exception): 841ca54502bSMichal Simek /* BIP bit is set on entry, no interrupts can occur */ 842ca54502bSMichal Simek swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) 843ca54502bSMichal Simek 844653e447eSMichal Simek mfs r1, rmsr 8455c0d72b1SMichal Simek nop 846653e447eSMichal Simek andi r1, r1, MSR_UMS 847653e447eSMichal Simek bnei r1, 1f 848ca54502bSMichal Simek /* Kernel-mode state save. */ 849653e447eSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/ 850653e447eSMichal Simek tophys(r1,r1); 851ca54502bSMichal Simek 852ca54502bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 853ca54502bSMichal Simek SAVE_REGS; 854ca54502bSMichal Simek 85577f6d226SMichal Simek swi r1, r1, PTO + PT_MODE; 856ca54502bSMichal Simek brid 2f; 857ca54502bSMichal Simek nop; /* Fill delay slot */ 858ca54502bSMichal Simek1: /* User-mode state save. */ 859ca54502bSMichal Simek lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */ 860ca54502bSMichal Simek tophys(r1,r1); 861ca54502bSMichal Simek lwi r1, r1, TS_THREAD_INFO; /* get the thread info */ 862ca54502bSMichal Simek addik r1, r1, THREAD_SIZE; /* calculate kernel stack pointer */ 863ca54502bSMichal Simek tophys(r1,r1); 864ca54502bSMichal Simek 865ca54502bSMichal Simek addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 866ca54502bSMichal Simek SAVE_REGS; 867ca54502bSMichal Simek 868ca54502bSMichal Simek swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ 869ca54502bSMichal Simek lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 870ca54502bSMichal Simek swi r11, r1, PTO+PT_R1; /* Store user SP. */ 871653e447eSMichal Simek2: 872ca54502bSMichal Simek tovirt(r1,r1) 873ca54502bSMichal Simek 87406b28640SMichal Simek set_vms; 875ca54502bSMichal Simek addi r5, r0, SIGTRAP /* send the trap signal */ 876ca54502bSMichal Simek add r6, r0, CURRENT_TASK; /* Get current task ptr into r11 */ 877ca54502bSMichal Simek addk r7, r0, r0 /* 3rd param zero */ 87806b28640SMichal Simekdbtrap_call: rtbd r0, send_sig; 879b9ea77e2SMichal Simek addik r15, r0, dbtrap_call; 880ca54502bSMichal Simek 881ca54502bSMichal Simek set_bip; /* Ints masked for state restore*/ 882ca54502bSMichal Simek lwi r11, r1, PTO + PT_MODE; 883ca54502bSMichal Simek bnei r11, 2f; 884ca54502bSMichal Simek 885ca54502bSMichal Simek /* Get current task ptr into r11 */ 886b1d70c62SMichal Simek lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ 887ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 888ca54502bSMichal Simek andi r11, r11, _TIF_NEED_RESCHED; 889ca54502bSMichal Simek beqi r11, 5f; 890ca54502bSMichal Simek 891ca54502bSMichal Simek/* Call the scheduler before returning from a syscall/trap. */ 892ca54502bSMichal Simek 893ca54502bSMichal Simek bralid r15, schedule; /* Call scheduler */ 894ca54502bSMichal Simek nop; /* delay slot */ 895ca54502bSMichal Simek /* XXX Is PT_DTRACE handling needed here? */ 896ca54502bSMichal Simek /* XXX m68knommu also checks TASK_STATE & TASK_COUNTER here. */ 897ca54502bSMichal Simek 898ca54502bSMichal Simek /* Maybe handle a signal */ 899b1d70c62SMichal Simek5: lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ 900ca54502bSMichal Simek lwi r11, r11, TI_FLAGS; /* get flags in thread info */ 901ca54502bSMichal Simek andi r11, r11, _TIF_SIGPENDING; 902ca54502bSMichal Simek beqi r11, 1f; /* Signals to handle, handle them */ 903ca54502bSMichal Simek 904ca54502bSMichal Simek/* Handle a signal return; Pending signals should be in r18. */ 905ca54502bSMichal Simek /* Not all registers are saved by the normal trap/interrupt entry 906ca54502bSMichal Simek points (for instance, call-saved registers (because the normal 907ca54502bSMichal Simek C-compiler calling sequence in the kernel makes sure they're 908ca54502bSMichal Simek preserved), and call-clobbered registers in the case of 909ca54502bSMichal Simek traps), but signal handlers may want to examine or change the 910ca54502bSMichal Simek complete register state. Here we save anything not saved by 911ca54502bSMichal Simek the normal entry sequence, so that it may be safely restored 912ca54502bSMichal Simek (in a possibly modified form) after do_signal returns. */ 913ca54502bSMichal Simek 914b9ea77e2SMichal Simek addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 915ca54502bSMichal Simek addi r7, r0, 0; /* Arg 3: int in_syscall */ 916ca54502bSMichal Simek bralid r15, do_signal; /* Handle any signals */ 917841d6e8cSMichal Simek add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 918ca54502bSMichal Simek 919ca54502bSMichal Simek 920ca54502bSMichal Simek/* Finally, return to user state. */ 9215c0d72b1SMichal Simek1: 9228633bebcSMichal Simek swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ 923ca54502bSMichal Simek VM_OFF; 924ca54502bSMichal Simek tophys(r1,r1); 925ca54502bSMichal Simek 926ca54502bSMichal Simek RESTORE_REGS 927ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 928ca54502bSMichal Simek 929ca54502bSMichal Simek 930ca54502bSMichal Simek lwi r1, r1, PT_R1 - PT_SIZE; 931ca54502bSMichal Simek /* Restore user stack pointer. */ 932ca54502bSMichal Simek bri 6f; 933ca54502bSMichal Simek 934ca54502bSMichal Simek/* Return to kernel state. */ 935ca54502bSMichal Simek2: VM_OFF; 936ca54502bSMichal Simek tophys(r1,r1); 937ca54502bSMichal Simek RESTORE_REGS 938ca54502bSMichal Simek addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 939ca54502bSMichal Simek 940ca54502bSMichal Simek tovirt(r1,r1); 941ca54502bSMichal Simek6: 942ca54502bSMichal SimekDBTRAP_return: /* Make global symbol for debugging */ 943ca54502bSMichal Simek rtbd r14, 0; /* Instructions to return from an IRQ */ 944ca54502bSMichal Simek nop; 945ca54502bSMichal Simek 946ca54502bSMichal Simek 947ca54502bSMichal Simek 948ca54502bSMichal SimekENTRY(_switch_to) 949ca54502bSMichal Simek /* prepare return value */ 950b1d70c62SMichal Simek addk r3, r0, CURRENT_TASK 951ca54502bSMichal Simek 952ca54502bSMichal Simek /* save registers in cpu_context */ 953ca54502bSMichal Simek /* use r11 and r12, volatile registers, as temp register */ 954ca54502bSMichal Simek /* give start of cpu_context for previous process */ 955ca54502bSMichal Simek addik r11, r5, TI_CPU_CONTEXT 956ca54502bSMichal Simek swi r1, r11, CC_R1 957ca54502bSMichal Simek swi r2, r11, CC_R2 958ca54502bSMichal Simek /* skip volatile registers. 959ca54502bSMichal Simek * they are saved on stack when we jumped to _switch_to() */ 960ca54502bSMichal Simek /* dedicated registers */ 961ca54502bSMichal Simek swi r13, r11, CC_R13 962ca54502bSMichal Simek swi r14, r11, CC_R14 963ca54502bSMichal Simek swi r15, r11, CC_R15 964ca54502bSMichal Simek swi r16, r11, CC_R16 965ca54502bSMichal Simek swi r17, r11, CC_R17 966ca54502bSMichal Simek swi r18, r11, CC_R18 967ca54502bSMichal Simek /* save non-volatile registers */ 968ca54502bSMichal Simek swi r19, r11, CC_R19 969ca54502bSMichal Simek swi r20, r11, CC_R20 970ca54502bSMichal Simek swi r21, r11, CC_R21 971ca54502bSMichal Simek swi r22, r11, CC_R22 972ca54502bSMichal Simek swi r23, r11, CC_R23 973ca54502bSMichal Simek swi r24, r11, CC_R24 974ca54502bSMichal Simek swi r25, r11, CC_R25 975ca54502bSMichal Simek swi r26, r11, CC_R26 976ca54502bSMichal Simek swi r27, r11, CC_R27 977ca54502bSMichal Simek swi r28, r11, CC_R28 978ca54502bSMichal Simek swi r29, r11, CC_R29 979ca54502bSMichal Simek swi r30, r11, CC_R30 980ca54502bSMichal Simek /* special purpose registers */ 981ca54502bSMichal Simek mfs r12, rmsr 982ca54502bSMichal Simek nop 983ca54502bSMichal Simek swi r12, r11, CC_MSR 984ca54502bSMichal Simek mfs r12, rear 985ca54502bSMichal Simek nop 986ca54502bSMichal Simek swi r12, r11, CC_EAR 987ca54502bSMichal Simek mfs r12, resr 988ca54502bSMichal Simek nop 989ca54502bSMichal Simek swi r12, r11, CC_ESR 990ca54502bSMichal Simek mfs r12, rfsr 991ca54502bSMichal Simek nop 992ca54502bSMichal Simek swi r12, r11, CC_FSR 993ca54502bSMichal Simek 994b1d70c62SMichal Simek /* update r31, the current-give me pointer to task which will be next */ 995b1d70c62SMichal Simek lwi CURRENT_TASK, r6, TI_TASK 996ca54502bSMichal Simek /* stored it to current_save too */ 997b1d70c62SMichal Simek swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE) 998ca54502bSMichal Simek 999ca54502bSMichal Simek /* get new process' cpu context and restore */ 1000ca54502bSMichal Simek /* give me start where start context of next task */ 1001ca54502bSMichal Simek addik r11, r6, TI_CPU_CONTEXT 1002ca54502bSMichal Simek 1003ca54502bSMichal Simek /* non-volatile registers */ 1004ca54502bSMichal Simek lwi r30, r11, CC_R30 1005ca54502bSMichal Simek lwi r29, r11, CC_R29 1006ca54502bSMichal Simek lwi r28, r11, CC_R28 1007ca54502bSMichal Simek lwi r27, r11, CC_R27 1008ca54502bSMichal Simek lwi r26, r11, CC_R26 1009ca54502bSMichal Simek lwi r25, r11, CC_R25 1010ca54502bSMichal Simek lwi r24, r11, CC_R24 1011ca54502bSMichal Simek lwi r23, r11, CC_R23 1012ca54502bSMichal Simek lwi r22, r11, CC_R22 1013ca54502bSMichal Simek lwi r21, r11, CC_R21 1014ca54502bSMichal Simek lwi r20, r11, CC_R20 1015ca54502bSMichal Simek lwi r19, r11, CC_R19 1016ca54502bSMichal Simek /* dedicated registers */ 1017ca54502bSMichal Simek lwi r18, r11, CC_R18 1018ca54502bSMichal Simek lwi r17, r11, CC_R17 1019ca54502bSMichal Simek lwi r16, r11, CC_R16 1020ca54502bSMichal Simek lwi r15, r11, CC_R15 1021ca54502bSMichal Simek lwi r14, r11, CC_R14 1022ca54502bSMichal Simek lwi r13, r11, CC_R13 1023ca54502bSMichal Simek /* skip volatile registers */ 1024ca54502bSMichal Simek lwi r2, r11, CC_R2 1025ca54502bSMichal Simek lwi r1, r11, CC_R1 1026ca54502bSMichal Simek 1027ca54502bSMichal Simek /* special purpose registers */ 1028ca54502bSMichal Simek lwi r12, r11, CC_FSR 1029ca54502bSMichal Simek mts rfsr, r12 1030ca54502bSMichal Simek nop 1031ca54502bSMichal Simek lwi r12, r11, CC_MSR 1032ca54502bSMichal Simek mts rmsr, r12 1033ca54502bSMichal Simek nop 1034ca54502bSMichal Simek 1035ca54502bSMichal Simek rtsd r15, 8 1036ca54502bSMichal Simek nop 1037ca54502bSMichal Simek 1038ca54502bSMichal SimekENTRY(_reset) 1039ca54502bSMichal Simek brai 0x70; /* Jump back to FS-boot */ 1040ca54502bSMichal Simek 1041ca54502bSMichal SimekENTRY(_break) 1042ca54502bSMichal Simek mfs r5, rmsr 1043ca54502bSMichal Simek nop 1044ca54502bSMichal Simek swi r5, r0, 0x250 + TOPHYS(r0_ram) 1045ca54502bSMichal Simek mfs r5, resr 1046ca54502bSMichal Simek nop 1047ca54502bSMichal Simek swi r5, r0, 0x254 + TOPHYS(r0_ram) 1048ca54502bSMichal Simek bri 0 1049ca54502bSMichal Simek 1050ca54502bSMichal Simek /* These are compiled and loaded into high memory, then 1051ca54502bSMichal Simek * copied into place in mach_early_setup */ 1052ca54502bSMichal Simek .section .init.ivt, "ax" 1053ca54502bSMichal Simek .org 0x0 1054ca54502bSMichal Simek /* this is very important - here is the reset vector */ 1055ca54502bSMichal Simek /* in current MMU branch you don't care what is here - it is 1056ca54502bSMichal Simek * used from bootloader site - but this is correct for FS-BOOT */ 1057ca54502bSMichal Simek brai 0x70 1058ca54502bSMichal Simek nop 1059ca54502bSMichal Simek brai TOPHYS(_user_exception); /* syscall handler */ 1060ca54502bSMichal Simek brai TOPHYS(_interrupt); /* Interrupt handler */ 1061ca54502bSMichal Simek brai TOPHYS(_break); /* nmi trap handler */ 1062ca54502bSMichal Simek brai TOPHYS(_hw_exception_handler); /* HW exception handler */ 1063ca54502bSMichal Simek 1064ca54502bSMichal Simek .org 0x60 1065ca54502bSMichal Simek brai TOPHYS(_debug_exception); /* debug trap handler*/ 1066ca54502bSMichal Simek 1067ca54502bSMichal Simek.section .rodata,"a" 1068ca54502bSMichal Simek#include "syscall_table.S" 1069ca54502bSMichal Simek 1070ca54502bSMichal Simeksyscall_table_size=(.-sys_call_table) 1071ca54502bSMichal Simek 1072ce3266c0SSteven J. Magnanitype_SYSCALL: 1073ce3266c0SSteven J. Magnani .ascii "SYSCALL\0" 1074ce3266c0SSteven J. Magnanitype_IRQ: 1075ce3266c0SSteven J. Magnani .ascii "IRQ\0" 1076ce3266c0SSteven J. Magnanitype_IRQ_PREEMPT: 1077ce3266c0SSteven J. Magnani .ascii "IRQ (PREEMPTED)\0" 1078ce3266c0SSteven J. Magnanitype_SYSCALL_PREEMPT: 1079ce3266c0SSteven J. Magnani .ascii " SYSCALL (PREEMPTED)\0" 1080ce3266c0SSteven J. Magnani 1081ce3266c0SSteven J. Magnani /* 1082ce3266c0SSteven J. Magnani * Trap decoding for stack unwinder 1083ce3266c0SSteven J. Magnani * Tuples are (start addr, end addr, string) 1084ce3266c0SSteven J. Magnani * If return address lies on [start addr, end addr], 1085ce3266c0SSteven J. Magnani * unwinder displays 'string' 1086ce3266c0SSteven J. Magnani */ 1087ce3266c0SSteven J. Magnani 1088ce3266c0SSteven J. Magnani .align 4 1089ce3266c0SSteven J. Magnani.global microblaze_trap_handlers 1090ce3266c0SSteven J. Magnanimicroblaze_trap_handlers: 1091ce3266c0SSteven J. Magnani /* Exact matches come first */ 1092ce3266c0SSteven J. Magnani .word ret_from_trap; .word ret_from_trap ; .word type_SYSCALL 1093ce3266c0SSteven J. Magnani .word ret_from_irq ; .word ret_from_irq ; .word type_IRQ 1094ce3266c0SSteven J. Magnani /* Fuzzy matches go here */ 1095ce3266c0SSteven J. Magnani .word ret_from_irq ; .word no_intr_resched ; .word type_IRQ_PREEMPT 1096ce3266c0SSteven J. Magnani .word ret_from_trap; .word TRAP_return ; .word type_SYSCALL_PREEMPT 1097ce3266c0SSteven J. Magnani /* End of table */ 1098ce3266c0SSteven J. Magnani .word 0 ; .word 0 ; .word 0 1099