1 | /*
|
---|
2 | * TOPPERS/ASP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Advanced Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | * Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
|
---|
9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
10 | * Copyright (C) 2008-2010 by Witz Corporation, JAPAN
|
---|
11 | *
|
---|
12 | * ä¸è¨èä½æ¨©è
|
---|
13 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
14 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
15 | * å¤ã»åé
|
---|
16 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
21 | * ç¨ã§ããå½¢ã§åé
|
---|
22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
24 | * è
|
---|
25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
30 | * ã¨ï¼
|
---|
31 | * (a) åé
|
---|
32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
34 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
35 | * (b) åé
|
---|
36 | å¸ã®å½¢æ
|
---|
37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
38 | * å ±åãããã¨ï¼
|
---|
39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
40 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
42 | 責ãããã¨ï¼
|
---|
43 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
44 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
45 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
46 | * å
|
---|
47 | 責ãããã¨ï¼
|
---|
48 | *
|
---|
49 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
50 | ã
|
---|
51 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
52 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
53 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
54 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
55 | *
|
---|
56 | * @(#) $Id: prc_insn.h 388 2019-05-22 11:25:18Z coas-nagasima $
|
---|
57 | */
|
---|
58 |
|
---|
59 | /*
|
---|
60 | * ããã»ããµã®ç¹æ®å½ä»¤ã®ã¤ã³ã©ã¤ã³é¢æ°å®ç¾©ï¼RX630ç¨ï¼
|
---|
61 | */
|
---|
62 |
|
---|
63 | #ifndef TOPPERS_PRC_INSN_H
|
---|
64 | #define TOPPERS_PRC_INSN_H
|
---|
65 |
|
---|
66 | #ifndef TOPPERS_MACRO_ONLY
|
---|
67 |
|
---|
68 | static uint32_t current_psw( void );
|
---|
69 | static void set_psw( uint32_t psw );
|
---|
70 | Inline uint32_t current_ipl( void );
|
---|
71 | Inline void set_ipl( uint32_t ipl );
|
---|
72 | static void disint( void );
|
---|
73 | static void enaint( void );
|
---|
74 | static uint16_t rev_endian_uint16( uint16_t data );
|
---|
75 | static uint32_t rev_endian_uint32( uint32_t data );
|
---|
76 |
|
---|
77 | /*
|
---|
78 | * Iãã©ã°, IPLãåå¾ããããã®ãã¯ãå®ç¾©
|
---|
79 | */
|
---|
80 | #define PSW_I_MASK ( 0x00010000UL )
|
---|
81 | #define PSW_IPL_MASK ( 0x0F000000UL )
|
---|
82 |
|
---|
83 | #else /* TOPPERS_MACRO_ONLY */
|
---|
84 |
|
---|
85 | /*
|
---|
86 | * Iãã©ã°, IPLãåå¾ããããã®ãã¯ãå®ç¾©
|
---|
87 | */
|
---|
88 | #define PSW_I_MASK ( 0x00010000 )
|
---|
89 | #define PSW_IPL_MASK ( 0x0F000000 )
|
---|
90 |
|
---|
91 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
92 |
|
---|
93 | #ifndef TOPPERS_MACRO_ONLY
|
---|
94 |
|
---|
95 | /*
|
---|
96 | * ããã»ããµã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿(PSW)ã®ç¾å¨å¤ã®èªåºã
|
---|
97 | */
|
---|
98 | static uint32_t
|
---|
99 | current_psw( void )
|
---|
100 | {
|
---|
101 | uint32_t psw;
|
---|
102 | Asm("mvfc psw, %0" : "=r"(psw));
|
---|
103 | return psw;
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * ããã»ããµã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿(PSW)ã¸è¨å®
|
---|
109 | */
|
---|
110 | static void
|
---|
111 | set_psw( uint32_t psw )
|
---|
112 | {
|
---|
113 | Asm("mvtc %0, psw" :: "r"(psw));
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * IPLã®ç¾å¨å¤ã®èªåºã
|
---|
119 | */
|
---|
120 | Inline uint32_t
|
---|
121 | current_ipl( void )
|
---|
122 | {
|
---|
123 | return ( uint32_t )( current_psw() & PSW_IPL_MASK );
|
---|
124 | }
|
---|
125 |
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * IPLã¸è¨å®
|
---|
129 | */
|
---|
130 | Inline void
|
---|
131 | set_ipl( uint32_t ipl )
|
---|
132 | {
|
---|
133 | set_psw( ( current_psw() & ( ~PSW_IPL_MASK ) ) | ipl );
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | /*
|
---|
138 | * NMIãé¤ããã¹ã¦ã®å²è¾¼ã¿ã®ç¦æ¢
|
---|
139 | */
|
---|
140 | static void
|
---|
141 | disint( void )
|
---|
142 | {
|
---|
143 | Asm("clrpsw i");
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 | /*
|
---|
148 | * NMIãé¤ããã¹ã¦ã®å²è¾¼ã¿ã®è¨±å¯
|
---|
149 | */
|
---|
150 | static void
|
---|
151 | enaint( void )
|
---|
152 | {
|
---|
153 | Asm("setpsw i");
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * ã¨ã³ãã£ã¢ã³å¤æ 16bit
|
---|
159 | */
|
---|
160 | static uint16_t
|
---|
161 | rev_endian_uint16( uint16_t data )
|
---|
162 | {
|
---|
163 | Asm("revw %0, %1" : "=r"(data) : "r"(data));
|
---|
164 | return data;
|
---|
165 | }
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * ã¨ã³ãã£ã¢ã³å¤æ 32bit
|
---|
169 | */
|
---|
170 | static uint32_t
|
---|
171 | rev_endian_uint32( uint32_t data )
|
---|
172 | {
|
---|
173 | Asm("revl %0, %1" : "=r"(data) : "r"(data));
|
---|
174 | return data;
|
---|
175 | }
|
---|
176 |
|
---|
177 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
178 |
|
---|
179 | #endif /* TOPPERS_PRC_INSN_H */
|
---|