Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
0003  *
0004  * A call to __dcc_getchar() or __dcc_putchar() is typically followed by
0005  * a call to __dcc_getstatus().  We want to make sure that the CPU does
0006  * not speculative read the DCC status before executing the read or write
0007  * instruction.  That's what the ISBs are for.
0008  *
0009  * The 'volatile' ensures that the compiler does not cache the status bits,
0010  * and instead reads the DCC register every time.
0011  */
0012 #ifndef __ASM_DCC_H
0013 #define __ASM_DCC_H
0014 
0015 #include <asm/barrier.h>
0016 #include <asm/sysreg.h>
0017 
0018 static inline u32 __dcc_getstatus(void)
0019 {
0020     return read_sysreg(mdccsr_el0);
0021 }
0022 
0023 static inline char __dcc_getchar(void)
0024 {
0025     char c = read_sysreg(dbgdtrrx_el0);
0026     isb();
0027 
0028     return c;
0029 }
0030 
0031 static inline void __dcc_putchar(char c)
0032 {
0033     /*
0034      * The typecast is to make absolutely certain that 'c' is
0035      * zero-extended.
0036      */
0037     write_sysreg((unsigned char)c, dbgdtrtx_el0);
0038     isb();
0039 }
0040 
0041 #endif