14726dd60SMichal Simek /* SPDX-License-Identifier: GPL-2.0 */ 2c4df4bc1SMichal Simek /* 3c4df4bc1SMichal Simek * Preliminary support for HW exception handing for Microblaze 4c4df4bc1SMichal Simek * 517f3324cSMichal Simek * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 617f3324cSMichal Simek * Copyright (C) 2008-2009 PetaLogix 7c4df4bc1SMichal Simek * Copyright (C) 2005 John Williams <jwilliams@itee.uq.edu.au> 8c4df4bc1SMichal Simek */ 9c4df4bc1SMichal Simek 10c4df4bc1SMichal Simek #ifndef _ASM_MICROBLAZE_EXCEPTIONS_H 11c4df4bc1SMichal Simek #define _ASM_MICROBLAZE_EXCEPTIONS_H 12c4df4bc1SMichal Simek 13c4df4bc1SMichal Simek #ifdef __KERNEL__ 14c4df4bc1SMichal Simek #ifndef __ASSEMBLY__ 15c4df4bc1SMichal Simek 16c4df4bc1SMichal Simek /* Macros to enable and disable HW exceptions in the MSR */ 17c4df4bc1SMichal Simek /* Define MSR enable bit for HW exceptions */ 18c4df4bc1SMichal Simek #define HWEX_MSR_BIT (1 << 8) 19c4df4bc1SMichal Simek 20c4df4bc1SMichal Simek #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 21c4df4bc1SMichal Simek #define __enable_hw_exceptions() \ 22c4df4bc1SMichal Simek __asm__ __volatile__ (" msrset r0, %0; \ 23c4df4bc1SMichal Simek nop;" \ 24c4df4bc1SMichal Simek : \ 25c4df4bc1SMichal Simek : "i" (HWEX_MSR_BIT) \ 26c4df4bc1SMichal Simek : "memory") 27c4df4bc1SMichal Simek 28c4df4bc1SMichal Simek #define __disable_hw_exceptions() \ 29c4df4bc1SMichal Simek __asm__ __volatile__ (" msrclr r0, %0; \ 30c4df4bc1SMichal Simek nop;" \ 31c4df4bc1SMichal Simek : \ 32c4df4bc1SMichal Simek : "i" (HWEX_MSR_BIT) \ 33c4df4bc1SMichal Simek : "memory") 34c4df4bc1SMichal Simek #else /* !CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 35c4df4bc1SMichal Simek #define __enable_hw_exceptions() \ 36c4df4bc1SMichal Simek __asm__ __volatile__ (" \ 37c4df4bc1SMichal Simek mfs r12, rmsr; \ 38c4df4bc1SMichal Simek nop; \ 39c4df4bc1SMichal Simek ori r12, r12, %0; \ 40c4df4bc1SMichal Simek mts rmsr, r12; \ 41c4df4bc1SMichal Simek nop;" \ 42c4df4bc1SMichal Simek : \ 43c4df4bc1SMichal Simek : "i" (HWEX_MSR_BIT) \ 44c4df4bc1SMichal Simek : "memory", "r12") 45c4df4bc1SMichal Simek 46c4df4bc1SMichal Simek #define __disable_hw_exceptions() \ 47c4df4bc1SMichal Simek __asm__ __volatile__ (" \ 48c4df4bc1SMichal Simek mfs r12, rmsr; \ 49c4df4bc1SMichal Simek nop; \ 50c4df4bc1SMichal Simek andi r12, r12, ~%0; \ 51c4df4bc1SMichal Simek mts rmsr, r12; \ 52c4df4bc1SMichal Simek nop;" \ 53c4df4bc1SMichal Simek : \ 54c4df4bc1SMichal Simek : "i" (HWEX_MSR_BIT) \ 55c4df4bc1SMichal Simek : "memory", "r12") 56c4df4bc1SMichal Simek #endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 57c4df4bc1SMichal Simek 58c4df4bc1SMichal Simek asmlinkage void full_exception(struct pt_regs *regs, unsigned int type, 59c4df4bc1SMichal Simek int fsr, int addr); 60c4df4bc1SMichal Simek 61f699980bSMichal Simek asmlinkage void sw_exception(struct pt_regs *regs); 625213a9c3SMichal Simek void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig); 63f699980bSMichal Simek 64ce0b755fSMichal Simek void die(const char *str, struct pt_regs *fp, long err); 65ce0b755fSMichal Simek void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr); 66ce0b755fSMichal Simek 67c4df4bc1SMichal Simek #endif /*__ASSEMBLY__ */ 68c4df4bc1SMichal Simek #endif /* __KERNEL__ */ 69c4df4bc1SMichal Simek #endif /* _ASM_MICROBLAZE_EXCEPTIONS_H */ 70