1 | /*
|
---|
2 | * TOPPERS/SSP Kernel
|
---|
3 | * Smallest Set Profile Kernel
|
---|
4 | *
|
---|
5 | * Copyright (C) 2013-2015 by Embedded and Real-Time Systems Laboratory
|
---|
6 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
7 | * Copyright (C) 2018,2019 by Naoki Saito
|
---|
8 | * Nagoya Municipal Industrial Research Institute, JAPAN
|
---|
9 | *
|
---|
10 | * ä¸è¨èä½æ¨©è
|
---|
11 | ã¯ï¼ä»¥ä¸ã®(1)ã(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
12 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
13 | * å¤ã»åé
|
---|
14 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
15 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
16 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
17 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
18 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
19 | * ç¨ã§ããå½¢ã§åé
|
---|
20 | å¸ããå ´åã«ã¯ï¼åé
|
---|
21 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
22 | * è
|
---|
23 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
24 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
25 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
26 | * ç¨ã§ããªãå½¢ã§åé
|
---|
27 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
28 | * ã¨ï¼
|
---|
29 | * (a) åé
|
---|
30 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
31 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
32 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
33 | * (b) åé
|
---|
34 | å¸ã®å½¢æ
|
---|
35 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
36 | * å ±åãããã¨ï¼
|
---|
37 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
38 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
39 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
40 | 責ãããã¨ï¼
|
---|
41 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
42 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
43 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
44 | * å
|
---|
45 | 責ãããã¨ï¼
|
---|
46 | *
|
---|
47 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
48 | ã
|
---|
49 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
50 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
51 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
52 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
53 | *
|
---|
54 | * $Id: core_timer.h 384 2019-04-16 11:01:09Z nmir-saito $
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * ã¿ã¤ããã©ã¤ãï¼Generic Timerï¼
|
---|
59 | */
|
---|
60 |
|
---|
61 | #ifndef TOPPERS_CORE_TIMER_H
|
---|
62 | #define TOPPERS_CORE_TIMER_H
|
---|
63 |
|
---|
64 | #include <sil.h>
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * ã¿ã¤ãå²è¾¼ã¿ãã³ãã©ç»é²ã®ããã®å®æ°
|
---|
68 | */
|
---|
69 |
|
---|
70 | #define INTNO_TIMER TINTNO_CNTPNS /* å²è¾¼ã¿çªå· */
|
---|
71 | #define INHNO_TIMER INTNO_TIMER /* å²è¾¼ã¿ãã³ãã©çªå· */
|
---|
72 |
|
---|
73 | #ifndef INTPRI_TIMER
|
---|
74 | #define INTPRI_TIMER (-3) /* å²è¾¼ã¿åªå
|
---|
75 | 度 */
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #ifndef INTATR_TIMER
|
---|
79 | #define INTATR_TIMER TA_NULL /* å²è¾¼ã¿å±æ§ */
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * å¶å¾¡ã¬ã¸ã¹ã¿ã®ãããå®ç¾©
|
---|
84 | */
|
---|
85 | #define CNTP_CTL_ENABLE (1 << 0)
|
---|
86 | #define CNTP_CTL_MASK (1 << 1)
|
---|
87 | #define CNTP_CTL_ISTATUS (1 << 2)
|
---|
88 |
|
---|
89 |
|
---|
90 | #ifndef TOPPERS_MACRO_ONLY
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * ç©çã¿ã¤ãã®å¶å¾¡ã¬ã¸ã¹ã¿ããã®èªã¿åºã
|
---|
94 | */
|
---|
95 | Inline uint32_t
|
---|
96 | clock_read_ctrl(void) {
|
---|
97 | uint32_t cntv_ctrl;
|
---|
98 |
|
---|
99 | Asm ("mrs %0, cntp_ctl_el0"
|
---|
100 | : "=r"(cntv_ctrl) :: "memory");
|
---|
101 |
|
---|
102 | return cntv_ctrl;
|
---|
103 | }
|
---|
104 |
|
---|
105 | /*
|
---|
106 | * ç©çã¿ã¤ãã®å¶å¾¡ã¬ã¸ã¹ã¿ã¸ã®æ¸ãè¾¼ã¿
|
---|
107 | */
|
---|
108 | Inline void
|
---|
109 | clock_write_ctrl(uint32_t cntv_ctrl) {
|
---|
110 |
|
---|
111 | Asm ("msr cntp_ctl_el0, %0"
|
---|
112 | :: "r"(cntv_ctrl) : "memory");
|
---|
113 | }
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * ç©çã¿ã¤ã(ããªã¼ã«ã¦ã³ã¿)ã®ã«ã¦ã³ãå¤ã®èªã¿åºã
|
---|
117 | */
|
---|
118 | Inline uint64_t
|
---|
119 | clock_read_counter(void){
|
---|
120 | uint64_t cval;
|
---|
121 |
|
---|
122 | Asm ("mrs %0, cntpct_el0" : "=r" (cval):: "memory");
|
---|
123 |
|
---|
124 | return cval;
|
---|
125 | }
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * ç©çã¿ã¤ãå¤ã®èªã¿åºã
|
---|
129 | */
|
---|
130 | Inline uint32_t
|
---|
131 | clock_read_tval(void){
|
---|
132 | uint32_t cntp_tval;
|
---|
133 |
|
---|
134 | Asm ("mrs %0, cntp_tval_el0; isb;" : "=r"(cntp_tval)
|
---|
135 | :: "memory");
|
---|
136 | return cntp_tval;
|
---|
137 | }
|
---|
138 |
|
---|
139 | /*
|
---|
140 | * ç©çã¿ã¤ãå¤ã®æ¸ãè¾¼ã¿
|
---|
141 | */
|
---|
142 | Inline void
|
---|
143 | clock_write_tval(uint32_t cntv_tval){
|
---|
144 |
|
---|
145 | Asm ("msr cntp_tval_el0, %0" :: "r"(cntv_tval): "memory");
|
---|
146 | }
|
---|
147 |
|
---|
148 | /*
|
---|
149 | * ã¿ã¤ãã®æ¯è¼å¤ã®èªã¿åºã
|
---|
150 | */
|
---|
151 | Inline uint64_t
|
---|
152 | clock_read_cval(void){
|
---|
153 | uint64_t cntp_cval;
|
---|
154 |
|
---|
155 | Asm ("mrs %0, cntp_cval_el0" : "=r"(cntp_cval)
|
---|
156 | :: "memory");
|
---|
157 | return cntp_cval;
|
---|
158 | }
|
---|
159 |
|
---|
160 | /*
|
---|
161 | * ã¿ã¤ãã®æ¯è¼å¤ã®æ¸ãè¾¼ã¿
|
---|
162 | */
|
---|
163 | Inline void
|
---|
164 | clock_write_cval(uint64_t cntp_cval){
|
---|
165 |
|
---|
166 | Asm ("msr cntp_cval_el0, %0" :: "r"(cntp_cval): "memory");
|
---|
167 | }
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * ã·ã¹ãã ã«ã¦ã³ã¿ã®ã¯ããã¯å¨æ³¢æ°ã®åå¾
|
---|
171 | */
|
---|
172 | Inline uint32_t
|
---|
173 | get_timer_freq(void) {
|
---|
174 | uint32_t freq_hz;
|
---|
175 |
|
---|
176 | Asm ("mrs %0, cntfrq_el0" : "=r"(freq_hz) :: "memory");
|
---|
177 | return freq_hz;
|
---|
178 | }
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * ã¿ã¤ãã®èµ·åå¦ç
|
---|
182 | *
|
---|
183 | * ã¿ã¤ããåæåãï¼å¨æçãªã¿ã¤ãå²è¾¼ã¿è¦æ±ãçºçãããï¼
|
---|
184 | */
|
---|
185 | extern void target_timer_initialize(intptr_t exinf);
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * ã¿ã¤ãã®åæ¢å¦ç
|
---|
189 | */
|
---|
190 | extern void target_timer_terminate(intptr_t exinf);
|
---|
191 |
|
---|
192 | /*
|
---|
193 | * ã¿ã¤ãå²è¾¼ã¿ãã³ãã©
|
---|
194 | */
|
---|
195 | extern void target_timer_handler(void);
|
---|
196 |
|
---|
197 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
198 | #endif /* TOPPERS_PRC_TIMER_H */
|
---|