POK(kernelpart)
psr.h
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
23 #ifndef __POK_SPARC_PSR_H__
24 #define __POK_SPARC_PSR_H__
25 
26 #define PSR_ET 0x20
27 #define PSR_PS 0x40
28 #define PSR_S 0x80
29 #define PSR_CWP_MASK 0x1F
30 #define PSR_PIL(pil) (((pil) & 0xF) << 8)
32 static inline unsigned int psr_get(void)
33 {
34  unsigned int psr;
35  asm volatile ("rd %%psr, %0\n"
36  : "=r" (psr)
37  : /* no inputs */
38  : "memory");
39 
40  return psr;
41 }
42 
43 static inline void psr_set(unsigned int new_psr)
44 {
45  asm volatile ("wr %0, 0x0, %%psr\n"
46  "nop\n"
47  "nop\n"
48  "nop\n"
49  : /* no outputs */
50  : "r" (new_psr)
51  : "memory", "cc");
52 }
53 
54 static inline void psr_enable_traps(void)
55 {
56  unsigned int psr = psr_get();
57  psr |= PSR_ET;
58  psr_set(psr);
59 }
60 
61 static inline void psr_disable_traps(void)
62 {
63  unsigned int psr = psr_get();
64  psr &= ~PSR_ET;
65  psr_set(psr);
66 }
67 
68 static inline void psr_disable_interupt(void)
69 {
70  unsigned int psr = psr_get();
71 
72  psr &= ~(0xF << 8);
73  psr_set(psr | PSR_PIL(0xF));
74 }
75 
76 static inline void psr_enable_interupt(void)
77 {
78  unsigned int psr = psr_get();
79 
80  psr &= ~(0xF << 8);
81  psr_set(psr | PSR_PIL(0x0));
82 }
83 
84 #endif