source:
rtems/c/src/lib/libcpu/powerpc/shared/include/spr.h
@
73b5bd5d
Last change on this file since 73b5bd5d was 21e1c44, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:53:10 | |
---|---|
|
|
File size: 1.5 KB |
Line | |
---|---|
1 | /* |
2 | * spr.h -- Access to special purpose registers. |
3 | * |
4 | * Copyright (C) 1998 Gabriel Paubert, paubert@iram.es |
5 | * |
6 | * Modified to compile in RTEMS development environment |
7 | * by Eric Valette |
8 | * |
9 | * Copyright (C) 1999 Eric Valette. valette@crf.canon.fr |
10 | * |
11 | * The license and distribution terms for this file may be |
12 | * found in found in the file LICENSE in this distribution or at |
13 | * http://www.rtems.com/license/LICENSE. |
14 | * |
15 | * $Id$ |
16 | * |
17 | */ |
18 | |
19 | |
20 | #ifndef _PPC_SPR_H |
21 | #define _PPC_SPR_H |
22 | |
23 | #include <rtems/powerpc/registers.h> |
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) \ |
33 | static inline unsigned long _read_##reg(void) \ |
34 | {\ |
35 | unsigned long val;\ |
36 | __MFSPR(reg, val);\ |
37 | return val;\ |
38 | }\ |
39 | static inline void _write_##reg(unsigned long val)\ |
40 | {\ |
41 | __MTSPR(val,reg);\ |
42 | return;\ |
43 | } |
44 | |
45 | #define SPR_RO(reg) \ |
46 | static inline unsigned long _read_##reg(void) \ |
47 | {\ |
48 | unsigned long val;\ |
49 | __MFSPR(reg,val);\ |
50 | return val;\ |
51 | } |
52 | |
53 | static inline unsigned long _read_MSR(void) |
54 | { |
55 | unsigned long val; |
56 | asm volatile("mfmsr %0" : "=r" (val)); |
57 | return val; |
58 | } |
59 | |
60 | static inline void _write_MSR(unsigned long val) |
61 | { |
62 | asm volatile("mtmsr %0" : : "r" (val)); |
63 | return; |
64 | } |
65 | |
66 | static inline unsigned long _read_SR(void * va) |
67 | { |
68 | unsigned long val; |
69 | asm volatile("mfsrin %0,%1" : "=r" (val): "r" (va)); |
70 | return val; |
71 | } |
72 | |
73 | static inline void _write_SR(unsigned long val, void * va) |
74 | { |
75 | asm volatile("mtsrin %0,%1" : : "r"(val), "r" (va): "memory"); |
76 | return; |
77 | } |
78 | |
79 | |
80 | #endif |
Note: See TracBrowser
for help on using the repository browser.