OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [powerpc/] [shared/] [spr.h] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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.OARcorp.com/rtems/license.html.
14
 *
15
 * $Id: spr.h,v 1.2 2001-09-27 12:01:30 chris Exp $
16
 *
17
 */
18
 
19
 
20
#ifndef _PPC_SPR_H
21
#define _PPC_SPR_H
22
 
23
#include <libcpu/cpu.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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.