source: UsbWattMeter/trunk/asp_dcre/arch/rx630_msvc/prc_support.cpp@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-c++src
File size: 3.9 KB
Line 
1/*
2 * TOPPERS/ASP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
5 *
6 * Copyright (C) 2014 Cores Co., Ltd. Japan
7 *
8 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
9 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
10 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
11 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
12 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
13 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
14 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
15 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
16ƒƒ“ƒgi—˜—p
17 * ŽÒƒ}ƒjƒ…
18ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
19 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
20 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
21 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
22 * ‚ƁD
23 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
24ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
25ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
26 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
27 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
28 * •ñ‚·‚邱‚ƁD
29 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
30 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
31 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
32 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
33 * –Ɛӂ·‚邱‚ƁD
34 *
35 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
36 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
37 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
38 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
39 * ‚̐ӔC‚𕉂í‚È‚¢D
40 *
41 * @(#) $Id: prc_support.cpp 164 2016-03-07 11:33:50Z coas-nagasima $
42 */
43
44#include "StdAfx.h"
45#include "prc_insn.h"
46#include "WinKernel.h"
47
48#ifdef _DEBUG
49#define new DEBUG_NEW
50#undef THIS_FILE
51static char THIS_FILE[] = __FILE__;
52#endif
53
54// Šä‚h‚s‚q‚n‚mƒJ[ƒlƒ‹
55extern CKernel *g_Kernel;
56
57uint32_t psw = PSW_I_MASK;
58
59uint32_t current_psw(void)
60{
61 return psw;
62}
63
64void set_psw(uint32_t psw)
65{
66 uint32_t temp = ::psw ^ psw;
67
68 ::psw = psw;
69
70 if((temp & PSW_I_MASK) != 0) {
71 if((psw & PSW_I_MASK) != 0)
72 g_Kernel->LockCPU();
73 else
74 g_Kernel->UnlockCPU();
75 }
76}
77
78/*
79 * NMI‚ðœ‚­‚·‚ׂĂ̊„ž‚Ý‚Ì‹ÖŽ~
80 */
81void disint(void)
82{
83 g_Kernel->LockCPU();
84
85 psw |= PSW_I_MASK;
86}
87
88/*
89 * NMI‚ðœ‚­‚·‚ׂĂ̊„ž‚Ý‚Ì‹–‰Â
90 */
91void enaint(void)
92{
93 psw &= ~PSW_I_MASK;
94
95 g_Kernel->UnlockCPU();
96}
97
98/*
99 * Š„ž‚݃nƒ“ƒhƒ‰‚̐ݒè
100 */
101void x_define_inh(uint_t inhno, FP int_entry)
102{
103 g_Kernel->DefineInterruptHandler(inhno, int_entry);
104}
105
106void i_begin_int(INTNO intno)
107{
108 g_Kernel->BeginInt();
109}
110
111void i_end_int(INTNO intno)
112{
113 g_Kernel->EndInt();
114}
115
116bool starting = true;
117
118bool_t t_sense_lock()
119{
120 return g_Kernel->CurrentIsLocked();
121}
122
123bool_t i_sense_lock()
124{
125 return g_Kernel->IsLocked();
126}
127
128bool_t x_sense_lock()
129{
130 if(g_Kernel->InTaskContext())
131 return g_Kernel->CurrentIsLocked();
132 else
133 return g_Kernel->IsLocked();
134}
135
136/*
137 * ƒRƒ“ƒeƒLƒXƒg‚ÌŽQÆ
138 */
139bool_t sense_context(void)
140{
141 return !g_Kernel->InTaskContext() && !starting;
142}
143
144/*
145 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃Rƒ“ƒeƒLƒXƒg‚ÌŽQÆ
146 */
147bool_t exc_sense_context( void *p_excinf )
148{
149 return !g_Kernel->InTaskContext() && !starting;
150}
151
152/*
153 * ƒJ[ƒlƒ‹‹N“®Žžƒ^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ
154 */
155void _start_dispatch(void)
156{
157 starting = false;
158}
159
160/*
161 * ƒ^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ
162 */
163void dispatch(void)
164{
165 g_Kernel->Dispatch();
166}
167
168/*
169 * Œ»Ý‚̃Rƒ“ƒeƒLƒXƒg‚ðŽÌ‚ĂăfƒBƒXƒpƒbƒ`
170 */
171void _exit_and_dispatch(void)
172{
173 g_Kernel->ExitAndDispatch();
174}
175
176/*
177 * ƒJ[ƒlƒ‹‚̏I—¹ˆ—‚̌ďo‚µ
178 *
179 * ƒXƒ^ƒbƒN‚ð”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—p‚ɐ؂è‘Ö‚¦D
180 *
181 */
182void call_exit_kernel(void)
183{
184 g_Kernel->Terminate();
185}
186
187/*
188 * ƒ^ƒXƒN‹N“®ˆ—
189 *
190 */
191void start_r(void)
192{
193#if TIPM_LOCK != -15
194 lock_flag = false;
195#endif /* TIPM_LOCK != -15 */
196}
197
198extern "C" void Throw()
199{
200 throw std::exception();
201}
202
203extern "C" void trigger_cpu_exception( void )
204{
205 throw std::exception();
206}
Note: See TracBrowser for help on using the repository browser.