/* * drivers/amlogic/debug/irqflags_debug_arm64.h * * Copyright (C) 2017 Amlogic, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * */ #ifndef __ASM_IRQFLAGS_DEBUG_ARM64_H #define __ASM_IRQFLAGS_DEBUG_ARM64_H #ifdef __KERNEL__ /* * CPU interrupt mask handling. */ #include static inline unsigned long arch_local_irq_save(void) { unsigned long flags; asm volatile( "mrs %0, daif // arch_local_irq_save\n" "msr daifset, #2" : "=r" (flags) : : "memory"); irq_trace_start(flags); return flags; } static inline void arch_local_irq_enable(void) { irq_trace_stop(0); asm volatile( "msr daifclr, #2 // arch_local_irq_enable" : : : "memory"); } static inline void arch_local_irq_disable(void) { #if 0 asm volatile( "msr daifset, #2 // arch_local_irq_disable" : : : "memory"); #endif arch_local_irq_save(); } #define local_fiq_enable() asm("msr daifclr, #1" : : : "memory") #define local_fiq_disable() asm("msr daifset, #1" : : : "memory") #define local_async_enable() asm("msr daifclr, #4" : : : "memory") #define local_async_disable() asm("msr daifset, #4" : : : "memory") /* * Save the current interrupt enable state. */ static inline unsigned long arch_local_save_flags(void) { unsigned long flags; asm volatile( "mrs %0, daif // arch_local_save_flags" : "=r" (flags) : : "memory"); return flags; } /* * restore saved IRQ state */ static inline void arch_local_irq_restore(unsigned long flags) { irq_trace_stop(flags); asm volatile( "msr daif, %0 // arch_local_irq_restore" : : "r" (flags) : "memory"); } static inline int arch_irqs_disabled_flags(unsigned long flags) { return flags & PSR_I_BIT; } /* * save and restore debug state */ #define local_dbg_save(flags) \ do { \ typecheck(unsigned long, flags); \ asm volatile( \ "mrs %0, daif // local_dbg_save\n" \ "msr daifset, #8" \ : "=r" (flags) : : "memory"); \ } while (0) #define local_dbg_restore(flags) \ do { \ typecheck(unsigned long, flags); \ asm volatile( \ "msr daif, %0 // local_dbg_restore\n" \ : : "r" (flags) : "memory"); \ } while (0) #endif #endif