162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Preliminary support for HW exception handing for Microblaze 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 662306a36Sopenharmony_ci * Copyright (C) 2008-2009 PetaLogix 762306a36Sopenharmony_ci * Copyright (C) 2005 John Williams <jwilliams@itee.uq.edu.au> 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _ASM_MICROBLAZE_EXCEPTIONS_H 1162306a36Sopenharmony_ci#define _ASM_MICROBLAZE_EXCEPTIONS_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#ifdef __KERNEL__ 1462306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* Macros to enable and disable HW exceptions in the MSR */ 1762306a36Sopenharmony_ci/* Define MSR enable bit for HW exceptions */ 1862306a36Sopenharmony_ci#define HWEX_MSR_BIT (1 << 8) 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 2162306a36Sopenharmony_ci#define __enable_hw_exceptions() \ 2262306a36Sopenharmony_ci __asm__ __volatile__ (" msrset r0, %0; \ 2362306a36Sopenharmony_ci nop;" \ 2462306a36Sopenharmony_ci : \ 2562306a36Sopenharmony_ci : "i" (HWEX_MSR_BIT) \ 2662306a36Sopenharmony_ci : "memory") 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define __disable_hw_exceptions() \ 2962306a36Sopenharmony_ci __asm__ __volatile__ (" msrclr r0, %0; \ 3062306a36Sopenharmony_ci nop;" \ 3162306a36Sopenharmony_ci : \ 3262306a36Sopenharmony_ci : "i" (HWEX_MSR_BIT) \ 3362306a36Sopenharmony_ci : "memory") 3462306a36Sopenharmony_ci#else /* !CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 3562306a36Sopenharmony_ci#define __enable_hw_exceptions() \ 3662306a36Sopenharmony_ci __asm__ __volatile__ (" \ 3762306a36Sopenharmony_ci mfs r12, rmsr; \ 3862306a36Sopenharmony_ci nop; \ 3962306a36Sopenharmony_ci ori r12, r12, %0; \ 4062306a36Sopenharmony_ci mts rmsr, r12; \ 4162306a36Sopenharmony_ci nop;" \ 4262306a36Sopenharmony_ci : \ 4362306a36Sopenharmony_ci : "i" (HWEX_MSR_BIT) \ 4462306a36Sopenharmony_ci : "memory", "r12") 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define __disable_hw_exceptions() \ 4762306a36Sopenharmony_ci __asm__ __volatile__ (" \ 4862306a36Sopenharmony_ci mfs r12, rmsr; \ 4962306a36Sopenharmony_ci nop; \ 5062306a36Sopenharmony_ci andi r12, r12, ~%0; \ 5162306a36Sopenharmony_ci mts rmsr, r12; \ 5262306a36Sopenharmony_ci nop;" \ 5362306a36Sopenharmony_ci : \ 5462306a36Sopenharmony_ci : "i" (HWEX_MSR_BIT) \ 5562306a36Sopenharmony_ci : "memory", "r12") 5662306a36Sopenharmony_ci#endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ciasmlinkage void full_exception(struct pt_regs *regs, unsigned int type, 5962306a36Sopenharmony_ci int fsr, int addr); 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ciasmlinkage void sw_exception(struct pt_regs *regs); 6262306a36Sopenharmony_civoid bad_page_fault(struct pt_regs *regs, unsigned long address, int sig); 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_civoid die(const char *str, struct pt_regs *fp, long err); 6562306a36Sopenharmony_civoid _exception(int signr, struct pt_regs *regs, int code, unsigned long addr); 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#endif /*__ASSEMBLY__ */ 6862306a36Sopenharmony_ci#endif /* __KERNEL__ */ 6962306a36Sopenharmony_ci#endif /* _ASM_MICROBLAZE_EXCEPTIONS_H */ 70