1 | /*
|
---|
2 | * TOPPERS/JSP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Just Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | *
|
---|
9 | * ä¸è¨è使¨©è
|
---|
10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
11 | * ã«ãã£ã¦å
|
---|
12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
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 | ã
|
---|
46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | * @(#) $Id: devicemanagerCP.h,v 1.5 2003/12/24 07:40:42 takayuki Exp $
|
---|
51 | */
|
---|
52 |
|
---|
53 | #ifndef _ATLDEVICEMANAGERCP_H_
|
---|
54 | #define _ATLDEVICEMANAGERCP_H_
|
---|
55 |
|
---|
56 | template <class T>
|
---|
57 | class CProxy_IKernelEvents : public IConnectionPointImpl<T, &IID__IKernelEvents, CComDynamicUnkArray>
|
---|
58 | {
|
---|
59 | //Warning this class may be recreated by the wizard.
|
---|
60 | public:
|
---|
61 | HRESULT Fire_OnInterruptRequest(ULONG inhno)
|
---|
62 | {
|
---|
63 | HRESULT ret;
|
---|
64 | T* pT = static_cast<T*>(this);
|
---|
65 | int nConnectionIndex;
|
---|
66 | int nConnections = m_vec.GetSize();
|
---|
67 |
|
---|
68 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
69 | {
|
---|
70 | pT->Lock();
|
---|
71 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
72 | pT->Unlock();
|
---|
73 | _IKernelEvents* p_IKernelEvents = reinterpret_cast<_IKernelEvents*>(sp.p);
|
---|
74 | if (p_IKernelEvents != NULL)
|
---|
75 | ret = p_IKernelEvents->OnInterruptRequest(inhno);
|
---|
76 | } return ret;
|
---|
77 |
|
---|
78 | }
|
---|
79 | };
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 | template <class T>
|
---|
85 | class CProxy_IDeviceEvents : public IConnectionPointImpl<T, &IID__IDeviceEvents, CComDynamicUnkArray>
|
---|
86 | {
|
---|
87 | //Warning this class may be recreated by the wizard.
|
---|
88 | public:
|
---|
89 | HRESULT Fire_OnRead(LONG address, LONG sz, unsigned char * data)
|
---|
90 | {
|
---|
91 | HRESULT ret;
|
---|
92 | T* pT = static_cast<T*>(this);
|
---|
93 | int nConnectionIndex;
|
---|
94 | int nConnections = m_vec.GetSize();
|
---|
95 |
|
---|
96 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
97 | {
|
---|
98 | pT->Lock();
|
---|
99 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
100 | pT->Unlock();
|
---|
101 | _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
|
---|
102 | if (p_IDeviceEvents != NULL)
|
---|
103 | ret = p_IDeviceEvents->OnRead(address, sz, data);
|
---|
104 | } return ret;
|
---|
105 |
|
---|
106 | }
|
---|
107 | HRESULT Fire_OnWrite(LONG address, LONG sz, unsigned char * data)
|
---|
108 | {
|
---|
109 | HRESULT ret;
|
---|
110 | T* pT = static_cast<T*>(this);
|
---|
111 | int nConnectionIndex;
|
---|
112 | int nConnections = m_vec.GetSize();
|
---|
113 |
|
---|
114 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
115 | {
|
---|
116 | pT->Lock();
|
---|
117 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
118 | pT->Unlock();
|
---|
119 | _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
|
---|
120 | if (p_IDeviceEvents != NULL)
|
---|
121 | ret = p_IDeviceEvents->OnWrite(address, sz,data);
|
---|
122 | } return ret;
|
---|
123 |
|
---|
124 | }
|
---|
125 | HRESULT Fire_OnKernelStart()
|
---|
126 | {
|
---|
127 | HRESULT ret;
|
---|
128 | T* pT = static_cast<T*>(this);
|
---|
129 | int nConnectionIndex;
|
---|
130 | int nConnections = m_vec.GetSize();
|
---|
131 |
|
---|
132 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
133 | {
|
---|
134 | pT->Lock();
|
---|
135 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
136 | pT->Unlock();
|
---|
137 | _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
|
---|
138 | if (p_IDeviceEvents != NULL)
|
---|
139 | ret = p_IDeviceEvents->OnKernelStart();
|
---|
140 | } return ret;
|
---|
141 |
|
---|
142 | }
|
---|
143 | HRESULT Fire_OnKernelExit()
|
---|
144 | {
|
---|
145 | HRESULT ret;
|
---|
146 | T* pT = static_cast<T*>(this);
|
---|
147 | int nConnectionIndex;
|
---|
148 | int nConnections = m_vec.GetSize();
|
---|
149 |
|
---|
150 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
151 | {
|
---|
152 | pT->Lock();
|
---|
153 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
154 | pT->Unlock();
|
---|
155 | _IDeviceEvents* p_IDeviceEvents = reinterpret_cast<_IDeviceEvents*>(sp.p);
|
---|
156 | if (p_IDeviceEvents != NULL)
|
---|
157 | ret = p_IDeviceEvents->OnKernelExit();
|
---|
158 | } return ret;
|
---|
159 |
|
---|
160 | }
|
---|
161 | };
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 |
|
---|
166 | template <class T>
|
---|
167 | class CProxy_IInformationEvents : public IConnectionPointImpl<T, &IID__IInformationEvents, CComDynamicUnkArray>
|
---|
168 | {
|
---|
169 | //Warning this class may be recreated by the wizard.
|
---|
170 | public:
|
---|
171 | HRESULT Fire_OnDeviceChanged(SHORT reason, LONG devid, LONG extra = 0)
|
---|
172 | {
|
---|
173 | HRESULT ret;
|
---|
174 | T* pT = static_cast<T*>(this);
|
---|
175 | int nConnectionIndex;
|
---|
176 | int nConnections = m_vec.GetSize();
|
---|
177 |
|
---|
178 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
179 | {
|
---|
180 | pT->Lock();
|
---|
181 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
182 | pT->Unlock();
|
---|
183 | _IInformationEvents* p_IInformationEvents = reinterpret_cast<_IInformationEvents*>(sp.p);
|
---|
184 | if (p_IInformationEvents != NULL)
|
---|
185 | ret = p_IInformationEvents->OnDeviceChanged(reason, devid, extra);
|
---|
186 | } return ret;
|
---|
187 |
|
---|
188 | }
|
---|
189 | HRESULT Fire_OnKernelChanged(SHORT reason)
|
---|
190 | {
|
---|
191 | HRESULT ret;
|
---|
192 | T* pT = static_cast<T*>(this);
|
---|
193 | int nConnectionIndex;
|
---|
194 | int nConnections = m_vec.GetSize();
|
---|
195 |
|
---|
196 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
197 | {
|
---|
198 | pT->Lock();
|
---|
199 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
200 | pT->Unlock();
|
---|
201 | _IInformationEvents* p_IInformationEvents = reinterpret_cast<_IInformationEvents*>(sp.p);
|
---|
202 | if (p_IInformationEvents != NULL)
|
---|
203 | ret = p_IInformationEvents->OnKernelChanged(reason);
|
---|
204 | } return ret;
|
---|
205 |
|
---|
206 | }
|
---|
207 | };
|
---|
208 |
|
---|
209 |
|
---|
210 | template <class T>
|
---|
211 | class CProxy_IKernelLogEvents : public IConnectionPointImpl<T, &IID__IKernelLogEvents, CComDynamicUnkArray>
|
---|
212 | {
|
---|
213 | public:
|
---|
214 | bool onKernelStart_Performed;
|
---|
215 |
|
---|
216 | CProxy_IKernelLogEvents(void) : onKernelStart_Performed(false) {};
|
---|
217 |
|
---|
218 | //Warning this class may be recreated by the wizard.
|
---|
219 | public:
|
---|
220 | HRESULT Fire_OnKernelStart()
|
---|
221 | {
|
---|
222 | HRESULT ret;
|
---|
223 | T* pT = static_cast<T*>(this);
|
---|
224 | int nConnectionIndex;
|
---|
225 | int nConnections = m_vec.GetSize();
|
---|
226 |
|
---|
227 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
228 | {
|
---|
229 | pT->Lock();
|
---|
230 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
231 | pT->Unlock();
|
---|
232 | _IKernelLogEvents* p_IKernelLogEvents = reinterpret_cast<_IKernelLogEvents*>(sp.p);
|
---|
233 | if (p_IKernelLogEvents != NULL)
|
---|
234 | {
|
---|
235 | if((ret = p_IKernelLogEvents->OnKernelStart()) == S_OK)
|
---|
236 | onKernelStart_Performed = true;
|
---|
237 | }
|
---|
238 | }
|
---|
239 | return ret;
|
---|
240 | }
|
---|
241 |
|
---|
242 | HRESULT Fire_OnKernelExit()
|
---|
243 | {
|
---|
244 | HRESULT ret;
|
---|
245 | T* pT = static_cast<T*>(this);
|
---|
246 | int nConnectionIndex;
|
---|
247 | int nConnections = m_vec.GetSize();
|
---|
248 |
|
---|
249 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
250 | {
|
---|
251 | pT->Lock();
|
---|
252 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
253 | pT->Unlock();
|
---|
254 | _IKernelLogEvents* p_IKernelLogEvents = reinterpret_cast<_IKernelLogEvents*>(sp.p);
|
---|
255 | if (p_IKernelLogEvents != NULL)
|
---|
256 | ret = p_IKernelLogEvents->OnKernelExit();
|
---|
257 | }
|
---|
258 | onKernelStart_Performed = false;
|
---|
259 | return ret;
|
---|
260 | }
|
---|
261 |
|
---|
262 | HRESULT Fire_OnLogEvent(LONG sz, unsigned char * data)
|
---|
263 | {
|
---|
264 | HRESULT ret;
|
---|
265 | T* pT = static_cast<T*>(this);
|
---|
266 | int nConnectionIndex;
|
---|
267 | int nConnections = m_vec.GetSize();
|
---|
268 |
|
---|
269 | for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
|
---|
270 | {
|
---|
271 | pT->Lock();
|
---|
272 | CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
|
---|
273 | pT->Unlock();
|
---|
274 | _IKernelLogEvents* p_IKernelLogEvents = reinterpret_cast<_IKernelLogEvents*>(sp.p);
|
---|
275 | if (p_IKernelLogEvents != NULL)
|
---|
276 | {
|
---|
277 | if(!onKernelStart_Performed)
|
---|
278 | p_IKernelLogEvents->OnKernelStart();
|
---|
279 | ret = p_IKernelLogEvents->OnLogEvent(sz, data);
|
---|
280 | }
|
---|
281 | }
|
---|
282 | if(nConnectionIndex != 0)
|
---|
283 | onKernelStart_Performed = true;
|
---|
284 | return ret;
|
---|
285 | }
|
---|
286 | };
|
---|
287 | #endif
|
---|