source: rtems/c/src/lib/libcpu/powerpc/shared/include/spr.h @ d3d9ef37

4.104.114.84.95
Last change on this file since d3d9ef37 was a859df85, checked in by Ralf Corsepius <ralf.corsepius@…>, on Feb 13, 2005 at 5:00:15 AM

New header guards.

  • Property mode set to 100644
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 _LIBCPU_SPR_H
21#define _LIBCPU_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) \
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("mfsrin %0,%1" : "=r" (val): "r" (va));
70        return val;
71} 
72
73static 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.