RTEMS 7.0-rc1
Loading...
Searching...
No Matches
spr.h
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
3/*
4 * spr.h -- Access to special purpose registers.
5 *
6 * Copyright (C) 1998 Gabriel Paubert, paubert@iram.es
7 *
8 * Modified to compile in RTEMS development environment
9 * by Eric Valette
10 *
11 * Copyright (c) 1998 Eric Valette <eric.valette@free.fr>
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license/LICENSE.
16 *
17 */
18
19
20#ifndef _LIBCPU_SPR_H
21#define _LIBCPU_SPR_H
22
24
25#define __MFSPR(reg, val) \
26 __asm__ __volatile__("mfspr %0,"#reg : "=r" (val))
27
28#define __MTSPR(val, reg) \
29 __asm__ __volatile__("mtspr "#reg",%0" : : "r" (val))
30
31
32#define SPR_RW(reg) \
33static inline unsigned long _read_##reg(void) \
34{\
35 unsigned long val;\
36 __MFSPR(reg, val);\
37 return val;\
38}\
39static inline void _write_##reg(unsigned long val)\
40{\
41 __MTSPR(val,reg);\
42 return;\
43}
44
45#define SPR_RO(reg) \
46static inline unsigned long _read_##reg(void) \
47{\
48 unsigned long val;\
49 __MFSPR(reg,val);\
50 return val;\
51}
52
53static inline unsigned long _read_MSR(void)
54{
55 unsigned long val;
56 __asm__ volatile("mfmsr %0" : "=r" (val));
57 return val;
58}
59
60static inline void _write_MSR(unsigned long val)
61{
62 __asm__ volatile("mtmsr %0" : : "r" (val));
63 return;
64}
65
66static inline unsigned long _read_SR(void * va)
67{
68 unsigned long val;
69 __asm__ volatile (
70 ".machine \"push\"\n"
71 ".machine \"any\"\n"
72 "mfsrin %0,%1\n"
73 ".machine \"pop\"" :
74 "=r" (val) :
75 "r" (va)
76 );
77 return val;
78}
79
80static inline void _write_SR(unsigned long val, void * va)
81{
82 __asm__ volatile (
83 ".machine \"push\"\n"
84 ".machine \"any\"\n"
85 "mtsrin %0,%1\n"
86 ".machine \"pop\"" : :
87 "r" (val) , "r" (va) :
88 "memory"
89 );
90 return;
91}
92
93
94#endif