1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94
95 ///////////////////////////////////////////////////////////////////////////////////////////////////
96 ///
97 /// file MsOS.c
98 /// @brief MStar OS Wrapper
99 /// @author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101
102
103 // #if defined (MSOS_TYPE_NOS)
104
105 //-------------------------------------------------------------------------------------------------
106 // Include Files
107 //-------------------------------------------------------------------------------------------------
108 #include "MsCommon.h"
109 #include "MsOS.h"
110 #include "asmCPU.h"
111 #include "drvIRQ.h"
112 #include "string.h"
113 #include "halCHIP.h"
114 #include "halMMIO.h"
115 #include "MsVersion.h"
116 #include "halMPool.h"
117
118 #ifdef CONFIG_UTOPIA_FRAMEWORK
119 #include "utopia.h"
120 #endif
121
122 //-------------------------------------------------------------------------------------------------
123 // Local Defines
124 //------------------------------------------------------------------------------------------------
125 // Switch tasks every 1 ms.
126 #define TASK_TIME_SLICE (TICK_PER_ONE_MS)
127
128 // Combine 3-B prefix with s32ID = MSOS_ID_PREFIX | s32Id
129 // to avoid the kernel object being used before initialzed.
130 #define MSOS_ID_PREFIX 0x76540000
131 #define MSOS_ID_PREFIX_MASK 0xFFFF0000
132 #define MSOS_ID_MASK 0x0000FFFF //~MSOS_ID_PREFIX_MASK
133
134 //-------------------------------------------------------------------------------------------------
135 // Macros
136 //-------------------------------------------------------------------------------------------------
137
138
139 //-------------------------------------------------------------------------------------------------
140 // Global Variables
141 //-------------------------------------------------------------------------------------------------
142
143
144 //-------------------------------------------------------------------------------------------------
145 // Local Variables
146 //-------------------------------------------------------------------------------------------------
147 //
148 // Variable-size Memory pool
149 //
150 //
151
152 //
153 // Task Management
154 //
155
156 //
157 // Mutex
158 //
159
160 //
161 // Semaphore
162 //
163
164 //
165 // Event Group
166 //
167
168 //
169 // Queue
170 //
171
172 //
173 // Timer
174 //
175
176 //
177 // Interrupt
178 //
179 #if 0 //move to mscommon.h
180 //cached/unchched segment
181 #define CACHED_BASE ((void *)0x00000000)
182 #define UNCACHED_BASE ((void *)0x80000000)
183
184 #define CACHED_SIZE ((void *)0x20000000)
185 #define UNCACHED_SIZE ((void *)0x20000000)
186 // 0xA0000000~0xA000FFFF belongs to RIU
187 // 0xA1000000~ belongs to SPI
188
189 //cached/unchched segment
190 #define KSEG0_BASE CACHED_BASE
191 #define KSEG1_BASE UNCACHED_BASE
192 #define KSEG0_SIZE CACHED_SIZE
193 #define KSEG1_SIZE UNCACHED_SIZE
194
195 //cached <-> uncached
196 #define KSEG02KSEG1(addr) ((void *)((U32)(addr)|0x80000000))
197 #define KSEG12KSEG0(addr) ((void *)((U32)(addr)&~0x80000000))
198
199 //virtual <-> physical
200 #define VA2PA(addr) ((void *)(((U32)addr) & 0x1fffffff))
201 #define PA2KSEG0(addr) ((void *)(((U32)addr) | 0x00000000))
202 #define PA2KSEG1(addr) ((void *)(((U32)addr) | 0x80000000))
203 #endif
204 //MS_U32<->MS_U16
205 #define LOU16(u32Val) ( (MS_U16)(u32Val) )
206 #define HIU16(u32Val) ( (MS_U16)((u32Val) >> 16) )
207 #define CATU32(u16HiVal, u16LoVal) ( (MS_U32)(u16HiVal)<<16 | (MS_U32)(u16LoVal) )
208
209 //MS_U16<->MS_U8
210 #define LOU8(u16Val) ( (MS_U8)(u16Val) )
211 #define HIU8(u16Val) ( (MS_U8)((u16Val) >> 8) )
212
213 extern void mhal_dcache_flush(MS_U32 u32Base, MS_U32 u32Size);
214
215 #if defined(CHIP_A2) || \
216 defined(CHIP_T12) || \
217 defined(CHIP_T8) || \
218 defined(CHIP_J2) || \
219 defined(CHIP_T11) || \
220 defined(CHIP_A5) || \
221 defined(CHIP_A5P) || \
222 defined(CHIP_A3) || \
223 defined(CHIP_K2) || \
224 defined(CHIP_EDISON)
225 extern void mhal_L2Cache_Flush(void);
226 extern void mhal_L2Cache_Read(void);
227 #endif
228
229 extern int mhal_interrupt_disable(void);
230 extern void mhal_interrupt_enable(void);
231 extern void mhal_interrupt_restore(int old);
232 extern void mhal_interrupt_mask_all(void);
233 extern void mhal_interrupt_mask(MHAL_INTERRUPT_TYPE intr_num);
234 extern void mhal_interrupt_unmask(MHAL_INTERRUPT_TYPE intr_num);
235 extern void mhal_interrupt_lock(void);
236 extern void mhal_interrupt_unlock(void);
237 extern void mhal_interrupt_attach(MHAL_INTERRUPT_TYPE intr_num, mhal_isr_t isr, MS_U32 dat);
238 extern void mhal_interrupt_detach(MHAL_INTERRUPT_TYPE intr_num);
239 extern void mhal_exception_attach(MHAL_EXCEPTION_TYPE expt_num, mhal_isr_t isr, MS_U32 data);
240 extern void mhal_exception_detach(MHAL_EXCEPTION_TYPE expt_num);
241 extern void mhal_init_mmu(void);
242
243 //-------------------------------------------------------------------------------------------------
244 // Local Function Prototypes
245 //-------------------------------------------------------------------------------------------------
246
247 extern void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, unsigned long entryhi, unsigned long pagemask);
248
249 static MSIF_Version _drv_msos_version = {
250 .DDI = { MSOS_DRV_VERSION },
251 };
252 ////////////////////////////////////////////////////////////////////////////////
253 /// @brief \b Function \b Name: MDrv_MSOS_GetLibVer
254 /// @brief \b Function \b Description: Show the MSOS driver version
255 /// @param ppVersion \b Out: Library version string
256 /// @return \b Result
257 ////////////////////////////////////////////////////////////////////////////////
MDrv_MSOS_GetLibVer(const MSIF_Version ** ppVersion)258 MS_BOOL MDrv_MSOS_GetLibVer(const MSIF_Version **ppVersion)
259 {
260 if (!ppVersion)
261 return FALSE;
262
263 *ppVersion = &_drv_msos_version;
264 return TRUE;
265 }
266 //-------------------------------------------------------------------------------------------------
267 /// Initialize MsOS
268 /// @return TRUE : succeed
269 /// @return FALSE : fail
270 //-------------------------------------------------------------------------------------------------
MsOS_Init(void)271 MS_BOOL MsOS_Init (void)
272 {
273 #if (!defined(CHIP_T2) && !defined(CHIP_JANUS) && !defined(CHIP_U3) && !defined(CHIP_MARIA10) && !defined(CHIP_K1) && !defined(CHIP_KELTIC) && !defined(CHIP_KAPPA) && !defined(CHIP_KENYA) && !defined(CHIP_MACAW12) && !defined(CHIP_EDEN) && !defined(CHIP_EULER))
274
275 #if(defined(MCU_MIPS_34K) || defined(MCU_MIPS_74K) || defined(MCU_MIPS_1004K))
276
277 #if defined(CHIP_T9) || \
278 defined(CHIP_T13) || \
279 defined(CHIP_A1) || \
280 defined(CHIP_A6) || \
281 defined(CHIP_A7) || \
282 defined(CHIP_EMERALD) || \
283 defined(CHIP_EAGLE) || \
284 defined(CHIP_EIFFEL) || \
285 defined(CHIP_NUGGET) || \
286 defined(CHIP_NIKON) || \
287 defined(CHIP_MILAN)
288
289 unsigned long entrylo0_miu1 = ((0x60000000 >> 12) << 6) | (0<<3) | (1<< 2) | (1<< 1) | (1<< 0); // cacheable
290 unsigned long entrylo1_miu1 = ((0x60000000 >> 12) << 6) | (2<<3) | (1<< 2) | (1<< 1) | (1<< 0); // un-cacheable or 0x7
291
292 //MIU1 (0MB - 256MB)
293 add_wired_entry(entrylo0_miu1, entrylo1_miu1, MIU1_CACHEABLE_START , 0x1fffe000);
294
295 #elif defined(CHIP_KERES) || defined(CHIP_KIRIN) || defined(CHIP_KRIS)
296 unsigned long entrylo0 = ((0x50000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
297 unsigned long entrylo1 = ((0x50000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
298 //MIU0 (256MB - 512MB)
299 add_wired_entry(entrylo0, entrylo1, 0xC0000000, 0x1fffe000); // PageMask[28:13]=0x1fffe000(256MB max size)
300
301 #elif defined(CHIP_A2) || \
302 defined(CHIP_T12) || \
303 defined(CHIP_T8) || \
304 defined(CHIP_J2) || \
305 defined(CHIP_T11) || \
306 defined(CHIP_A5) || \
307 defined(CHIP_A5P) || \
308 defined(CHIP_A3) || \
309 defined(CHIP_K2) || \
310 defined(CHIP_AMETHYST) || \
311 defined(CHIP_AGATE) || \
312 defined(CHIP_EDISON) || \
313 defined(CHIP_EINSTEIN) || \
314 defined(CHIP_NAPOLI) || \
315 defined(CHIP_EINSTEIN3) || \
316 defined(CHIP_MONACO) || \
317 defined(CHIP_CLIPPERS) || \
318 defined(CHIP_MUNICH)
319
320 //MIU0
321 unsigned long entrylo0 = ((0x50000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
322 unsigned long entrylo1 = ((0x50000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
323
324 //MIU1
325 unsigned long entrylo0_miu1_lo256mb = ((0x60000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
326 unsigned long entrylo1_miu1_lo256mb = ((0x60000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
327 unsigned long entrylo0_miu1_hi256mb = ((0x70000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
328 unsigned long entrylo1_miu1_hi256mb = ((0x70000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
329
330 //MIU0 (256MB - 512MB)
331 add_wired_entry(entrylo0, entrylo1, 0xC0000000, 0x1fffe000); // PageMask[28:13]=0x1fffe000(256MB max size)
332
333 //MIU1 (0MB - 256MB)
334 add_wired_entry(entrylo0_miu1_lo256mb, entrylo1_miu1_lo256mb, 0x00000000, 0x1fffe000);
335
336 //MIU1 (256MB - 512MB)
337 add_wired_entry(entrylo0_miu1_hi256mb, entrylo1_miu1_hi256mb, 0x20000000, 0x1fffe000);
338 #else
339 unsigned long entrylo0 = ((0x40000000>> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1<< 0); // cacheable
340 unsigned long entrylo1 = ((0x40000000>> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1<< 0); // un-cacheable or 0x7
341 add_wired_entry(entrylo0, entrylo1, MIU1_CACHEABLE_START , 0x1fffe000);
342 #endif
343 #endif
344
345 #if (defined(__arm__) || defined (__aarch64__))
346 mhal_init_mmu();
347 #endif
348
349 #endif
350
351 #if (defined(__arm__) || defined (__aarch64__))
352 extern void ProcessTimer0Isr(void);
353 #else
354 extern void ProcessTimer0Isr( MHAL_SavedRegisters *pHalReg, MS_U32 vector );
355 #endif
356
357 MsOS_CPU_AttachInterrupt( E_INTERRUPT_TICK_TIMER, ProcessTimer0Isr, 0 );
358 MAsm_CPU_TimerInit();
359 MDrv_IRQ_Init();
360
361 #ifdef CONFIG_UTOPIA_FRAMEWORK
362 #if defined(CONFIG_MBOOT) || defined(CONFIG_CHAKRA2) || defined(CONFIG_PUMABOOT)
363 UtopiaInit();
364 #endif
365 #endif
366
367 return true;
368 }
369 #ifdef CONFIG_MBOOT
MsOS_Init_str(void)370 MS_BOOL MsOS_Init_str (void)
371 {
372 #if (!defined(CHIP_T2) && !defined(CHIP_JANUS) && !defined(CHIP_U3) && !defined(CHIP_MARIA10) && !defined(CHIP_K1) && !defined(CHIP_KELTIC) && !defined(CHIP_KAPPA) && !defined(CHIP_KENYA) && !defined(CHIP_MACAW12) && !defined(CHIP_EDEN) && !defined(CHIP_EULER))
373
374 #if(defined(MCU_MIPS_34K) || defined(MCU_MIPS_74K) || defined(MCU_MIPS_1004K))
375
376 #if defined(CHIP_T9) || \
377 defined(CHIP_T13) || \
378 defined(CHIP_A1) || \
379 defined(CHIP_A6) || \
380 defined(CHIP_A7) || \
381 defined(CHIP_EMERALD) || \
382 defined(CHIP_EAGLE) || \
383 defined(CHIP_EIFFEL) || \
384 defined(CHIP_NUGGET) || \
385 defined(CHIP_NIKON) || \
386 defined(CHIP_MILAN)
387
388 unsigned long entrylo0_miu1 = ((0x60000000 >> 12) << 6) | (0<<3) | (1<< 2) | (1<< 1) | (1<< 0); // cacheable
389 unsigned long entrylo1_miu1 = ((0x60000000 >> 12) << 6) | (2<<3) | (1<< 2) | (1<< 1) | (1<< 0); // un-cacheable or 0x7
390
391 //MIU1 (0MB - 256MB)
392 add_wired_entry(entrylo0_miu1, entrylo1_miu1, MIU1_CACHEABLE_START , 0x1fffe000);
393
394 #elif defined(CHIP_KERES) || defined(CHIP_KIRIN) || defined(CHIP_KRIS)
395 unsigned long entrylo0 = ((0x50000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
396 unsigned long entrylo1 = ((0x50000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
397 //MIU0 (256MB - 512MB)
398 add_wired_entry(entrylo0, entrylo1, 0xC0000000, 0x1fffe000); // PageMask[28:13]=0x1fffe000(256MB max size)
399
400 #elif defined(CHIP_A2) || \
401 defined(CHIP_T12) || \
402 defined(CHIP_T8) || \
403 defined(CHIP_J2) || \
404 defined(CHIP_T11) || \
405 defined(CHIP_A5) || \
406 defined(CHIP_A5P) || \
407 defined(CHIP_A3) || \
408 defined(CHIP_K2) || \
409 defined(CHIP_AMETHYST) || \
410 defined(CHIP_AGATE) || \
411 defined(CHIP_EDISON) || \
412 defined(CHIP_EINSTEIN) || \
413 defined(CHIP_NAPOLI) || \
414 defined(CHIP_EINSTEIN3) || \
415 defined(CHIP_MONACO) || \
416 defined(CHIP_CLIPPERS) || \
417 defined(CHIP_MUNICH)
418 //MIU0
419 unsigned long entrylo0 = ((0x50000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
420 unsigned long entrylo1 = ((0x50000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
421
422 //MIU1
423 unsigned long entrylo0_miu1_lo256mb = ((0x60000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
424 unsigned long entrylo1_miu1_lo256mb = ((0x60000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
425 unsigned long entrylo0_miu1_hi256mb = ((0x70000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
426 unsigned long entrylo1_miu1_hi256mb = ((0x70000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
427
428 //MIU0 (256MB - 512MB)
429 add_wired_entry(entrylo0, entrylo1, 0xC0000000, 0x1fffe000); // PageMask[28:13]=0x1fffe000(256MB max size)
430
431 //MIU1 (0MB - 256MB)
432 add_wired_entry(entrylo0_miu1_lo256mb, entrylo1_miu1_lo256mb, 0x00000000, 0x1fffe000);
433
434 //MIU1 (256MB - 512MB)
435 add_wired_entry(entrylo0_miu1_hi256mb, entrylo1_miu1_hi256mb, 0x20000000, 0x1fffe000);
436 #else
437 unsigned long entrylo0 = ((0x40000000>> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1<< 0); // cacheable
438 unsigned long entrylo1 = ((0x40000000>> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1<< 0); // un-cacheable or 0x7
439 add_wired_entry(entrylo0, entrylo1, MIU1_CACHEABLE_START , 0x1fffe000);
440 #endif
441 #endif
442
443 #if (defined(__arm__) || defined (__aarch64__))
444 mhal_init_mmu();
445 #endif
446
447 #endif
448
449 #if (defined(__arm__) || defined (__aarch64__))
450 extern void ProcessTimer0Isr(void);
451 #else
452 extern void ProcessTimer0Isr( MHAL_SavedRegisters *pHalReg, MS_U32 vector );
453 #endif
454
455 MsOS_CPU_AttachInterrupt( E_INTERRUPT_TICK_TIMER, ProcessTimer0Isr, 0 );
456 MAsm_CPU_TimerInit();
457 MDrv_IRQ_Init();
458
459 #ifdef CONFIG_UTOPIA_FRAMEWORK
460 #ifdef CONFIG_MBOOT
461 UtopiaInit_str();
462 #endif
463 #endif
464
465 return true;
466 }
467 #endif
468
469 #ifdef CONFIG_MBOOT
MsOS_Init_Fastboot(void)470 MS_BOOL MsOS_Init_Fastboot (void)
471 {
472 #if (!defined(CHIP_T2) && !defined(CHIP_JANUS) && !defined(CHIP_U3) && !defined(CHIP_MARIA10) && !defined(CHIP_K1) && !defined(CHIP_KELTIC) && !defined(CHIP_KAPPA) && !defined(CHIP_KENYA) && !defined(CHIP_MACAW12) && !defined(CHIP_EDEN) && !defined(CHIP_EULER))
473
474 #if(defined(MCU_MIPS_34K) || defined(MCU_MIPS_74K) || defined(MCU_MIPS_1004K))
475
476 #if defined(CHIP_T9) || \
477 defined(CHIP_T13) || \
478 defined(CHIP_A1) || \
479 defined(CHIP_A6) || \
480 defined(CHIP_A7) || \
481 defined(CHIP_EMERALD) || \
482 defined(CHIP_EAGLE) || \
483 defined(CHIP_EIFFEL) || \
484 defined(CHIP_NUGGET) || \
485 defined(CHIP_NIKON) || \
486 defined(CHIP_MILAN)
487
488 unsigned long entrylo0_miu1 = ((0x60000000 >> 12) << 6) | (0<<3) | (1<< 2) | (1<< 1) | (1<< 0); // cacheable
489 unsigned long entrylo1_miu1 = ((0x60000000 >> 12) << 6) | (2<<3) | (1<< 2) | (1<< 1) | (1<< 0); // un-cacheable or 0x7
490
491 //MIU1 (0MB - 256MB)
492 add_wired_entry(entrylo0_miu1, entrylo1_miu1, MIU1_CACHEABLE_START , 0x1fffe000);
493
494 #elif defined(CHIP_KERES) || defined(CHIP_KIRIN) || defined(CHIP_KRIS)
495
496 unsigned long entrylo0 = ((0x50000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
497 unsigned long entrylo1 = ((0x50000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
498 //MIU0 (256MB - 512MB)
499 add_wired_entry(entrylo0, entrylo1, 0xC0000000, 0x1fffe000); // PageMask[28:13]=0x1fffe000(256MB max size)
500
501 #elif defined(CHIP_A2) || \
502 defined(CHIP_T12) || \
503 defined(CHIP_T8) || \
504 defined(CHIP_J2) || \
505 defined(CHIP_T11) || \
506 defined(CHIP_A5) || \
507 defined(CHIP_A5P) || \
508 defined(CHIP_A3) || \
509 defined(CHIP_K2) || \
510 defined(CHIP_AMETHYST) || \
511 defined(CHIP_AGATE) || \
512 defined(CHIP_EDISON) || \
513 defined(CHIP_EINSTEIN) || \
514 defined(CHIP_NAPOLI) || \
515 defined(CHIP_EINSTEIN3) || \
516 defined(CHIP_MONACO) || \
517 defined(CHIP_CLIPPERS) || \
518 defined(CHIP_MUNICH)
519 //MIU0
520 unsigned long entrylo0 = ((0x50000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
521 unsigned long entrylo1 = ((0x50000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
522
523 //MIU1
524 unsigned long entrylo0_miu1_lo256mb = ((0x60000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
525 unsigned long entrylo1_miu1_lo256mb = ((0x60000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
526 unsigned long entrylo0_miu1_hi256mb = ((0x70000000 >> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // cacheable
527 unsigned long entrylo1_miu1_hi256mb = ((0x70000000 >> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1 << 0); // un-cacheable or 0x7
528
529 //MIU0 (256MB - 512MB)
530 add_wired_entry(entrylo0, entrylo1, 0xC0000000, 0x1fffe000); // PageMask[28:13]=0x1fffe000(256MB max size)
531
532 //MIU1 (0MB - 256MB)
533 add_wired_entry(entrylo0_miu1_lo256mb, entrylo1_miu1_lo256mb, 0x00000000, 0x1fffe000);
534
535 //MIU1 (256MB - 512MB)
536 add_wired_entry(entrylo0_miu1_hi256mb, entrylo1_miu1_hi256mb, 0x20000000, 0x1fffe000);
537 #else
538 unsigned long entrylo0 = ((0x40000000>> 12) << 6) | (0 << 3) | (1 << 2) | (1 << 1) | (1<< 0); // cacheable
539 unsigned long entrylo1 = ((0x40000000>> 12) << 6) | (2 << 3) | (1 << 2) | (1 << 1) | (1<< 0); // un-cacheable or 0x7
540 add_wired_entry(entrylo0, entrylo1, MIU1_CACHEABLE_START , 0x1fffe000);
541 #endif
542 #endif
543
544 #if (defined(__arm__))
545 mhal_init_mmu();
546 #endif
547
548 #endif
549
550 #if (defined(__arm__))
551 extern void ProcessTimer0Isr(void);
552 #else
553 extern void ProcessTimer0Isr( MHAL_SavedRegisters *pHalReg, MS_U32 vector );
554 #endif
555
556 MsOS_CPU_AttachInterrupt( E_INTERRUPT_TICK_TIMER, ProcessTimer0Isr, 0 );
557 MAsm_CPU_TimerInit();
558 MDrv_IRQ_Init();
559
560 #ifdef CONFIG_UTOPIA_FRAMEWORK
561 #ifdef CONFIG_MBOOT
562 // In fastboot, utopia init is not necessary
563 //UtopiaInit();
564 #endif
565 #endif
566
567 return true;
568 }
569 #endif
570 //
571 // Memory management
572 //
573 //-------------------------------------------------------------------------------------------------
574 /// Create a variable-size memory pool dynamically
575 /// @param u32PoolSize \b IN: pool size in bytes
576 /// @param u32MinAllocation \b IN: not used
577 /// @param pPoolAddr \b IN: starting address for the memory pool
578 /// @param eAttribute \b IN: only E_MSOS_FIFO - suspended in FIFO order
579 /// @param pPoolName \b IN: not used
580 /// @return >=0 : assigned memory pool ID
581 /// @return < 0 : fail
582 //-------------------------------------------------------------------------------------------------
MsOS_CreateMemoryPool(MS_U32 u32PoolSize,MS_U32 u32MinAllocation,void * pPoolAddr,MsOSAttribute eAttribute,char * pPoolName)583 MS_S32 MsOS_CreateMemoryPool (MS_U32 u32PoolSize,
584 MS_U32 u32MinAllocation,
585 void *pPoolAddr,
586 MsOSAttribute eAttribute,
587 char *pPoolName)
588 {
589 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
590 return -1;
591 }
592
593 //-------------------------------------------------------------------------------------------------
594 /// Delete a variable-size memory pool
595 /// @param s32PoolId \b IN: pool ID
596 /// @return TRUE : succeed
597 /// @return FALSE : fail
598 //-------------------------------------------------------------------------------------------------
MsOS_DeleteMemoryPool(MS_S32 s32PoolId)599 MS_BOOL MsOS_DeleteMemoryPool (MS_S32 s32PoolId)
600 {
601 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
602 return FALSE;
603 }
604
605 //-------------------------------------------------------------------------------------------------
606 /// Get the information of a variable-size memory pool
607 /// @param s32PoolId \b IN: memory pool ID
608 /// @param pPoolAddr \b OUT: holding the starting address for the memory pool
609 /// @param pu32PoolSize \b OUT: holding the total size of the memory pool
610 /// @param pu32FreeSize \b OUT: holding the available free size of the memory pool
611 /// @param pu32LargestFreeBlockSize \b OUT: holding the size of the largest free block
612 /// @return TRUE : succeed
613 /// @return FALSE : the pool has not been created
614 //-------------------------------------------------------------------------------------------------
MsOS_InfoMemoryPool(MS_S32 s32PoolId,void ** pPoolAddr,MS_U32 * pu32PoolSize,MS_U32 * pu32FreeSize,MS_U32 * pu32LargestFreeBlockSize)615 MS_BOOL MsOS_InfoMemoryPool (MS_S32 s32PoolId,
616 void **pPoolAddr,
617 MS_U32 *pu32PoolSize,
618 MS_U32 *pu32FreeSize,
619 MS_U32 *pu32LargestFreeBlockSize)
620 {
621 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
622 return FALSE;
623 }
624
625 extern unsigned char __heap[];
626 extern unsigned char __heap_end[];
627 //-------------------------------------------------------------------------------------------------
628 /// Allocate a memory block with 16-Byte aligned starting address from the variable-size memory pool
629 /// @param u32Size \b IN: request size
630 /// @param s32PoolId \b IN: memory pool ID
631 /// @return NULL : not enough available memory
632 /// @return Otherwise : pointer to the allocated memory block
633 //-------------------------------------------------------------------------------------------------
MsOS_AllocateMemory(MS_U32 u32Size,MS_S32 s32PoolId)634 void * MsOS_AllocateMemory (MS_U32 u32Size, MS_S32 s32PoolId)
635 {
636 #if 1
637 // UNUSED(s32PoolId);
638 void *ptr = malloc(u32Size);
639 // printf("\nMsOS_AllocateMemory: ptr = 0x%x\n",ptr);
640 if(ptr == NULL)
641 {
642 printf("\nMsOS_AllocateMemory will return NULL --> u32Size: 0x%x (heap, heap_end) = (0x%08x, 0x%08x)\n", (int)u32Size, (int)__heap, (int)__heap_end);
643 //show_mem_info();
644 }
645
646 //clear Dcache data
647 MsOS_Dcache_Flush((MS_U32)ptr,u32Size);
648
649 //clear OCP data
650 MsOS_FlushMemory();
651
652 #endif
653 #if 0
654 extern void *sbrk(unsigned int size);
655 void *ptr = sbrk(u32Size);
656 printf("ptr=%x\n", ptr);
657 if(ptr == NULL)
658 {
659 printf("\nMsOS_AllocateMemory will return NULL --> u32Size: 0x%x\n", u32Size);
660 }
661 #endif
662 return ptr;
663 }
664
665 //-------------------------------------------------------------------------------------------------
666 /// Free a memory block from the variable-size memory pool
667 /// @param pAddress \b IN: pointer to previously allocated memory block
668 /// @param s32PoolId \b IN: memory pool ID
669 /// @return TRUE : succeed
670 /// @return FALSE : fail
671 //-------------------------------------------------------------------------------------------------
MsOS_FreeMemory(void * pAddress,MS_S32 s32PoolId)672 MS_BOOL MsOS_FreeMemory (void *pAddress, MS_S32 s32PoolId)
673 {
674 //do nothing:
675 // printf("MsOS Free=%lx\n",pAddress);
676 // UNUSED(s32PoolId);
677 free(pAddress);
678 return TRUE;
679 }
680
681
682 //-------------------------------------------------------------------------------------------------
683 /// Reallocate a block of memory with 4-byte aligned start address from the variable-size memory pool
684 /// @param pOrgAddress \b IN: points to the beginning of the original memory block
685 /// @param u32NewSize \b IN: size of new memory block
686 /// @param s32PoolId \b IN: memory pool ID
687 /// @return NULL : not enough available memory to expand the block or u32NewSize == 0 && pOrgAddress != NULL
688 /// @return Otherwise : pointer to the reallocated (and possibly moved) memory block
689 // @note reference realloc in malloc.cxx
690 //-------------------------------------------------------------------------------------------------
MsOS_ReallocateMemory(void * pOrgAddress,MS_U32 u32NewSize,MS_S32 s32PoolId)691 void * MsOS_ReallocateMemory (void *pOrgAddress, MS_U32 u32NewSize, MS_S32 s32PoolId)
692 {
693 //printf("\n**************[%s] --> u32Size: 0x%x , addr: 0x%x\n",__FUNCTION__, (unsigned int)u32NewSize,(unsigned int)pOrgAddress);
694 return realloc(pOrgAddress, u32NewSize);
695 }
696
697 //-------------------------------------------------------------------------------------------------
698 /// Create a fixed-size memory pool dynamically
699 /// @param u32PoolSize \b IN: pool size in bytes
700 /// @param u32BlockSize \b IN: fixed block size for each allocated block in the pool
701 /// @param pPoolAddr \b IN: starting address for the memory pool
702 /// @param eAttribute \b IN: only E_MSOS_FIFO - suspended in FIFO order
703 /// @param pPoolName \b IN: not used
704 /// @return >=0 : assigned memory pool ID
705 /// @return < 0 : fail
706 //-------------------------------------------------------------------------------------------------
MsOS_CreateFixSizeMemoryPool(MS_U32 u32PoolSize,MS_U32 u32BlockSize,void * pPoolAddr,MsOSAttribute eAttribute,char * pPoolName)707 MS_S32 MsOS_CreateFixSizeMemoryPool (MS_U32 u32PoolSize,
708 MS_U32 u32BlockSize,
709 void *pPoolAddr,
710 MsOSAttribute eAttribute,
711 char *pPoolName)
712 {
713 return -1;
714 }
715
716 //-------------------------------------------------------------------------------------------------
717 /// Delete a fixed-size memory pool
718 /// @param s32PoolId \b IN: pool ID
719 /// @return TRUE : succeed
720 /// @return FALSE : fail
721 //-------------------------------------------------------------------------------------------------
MsOS_DeleteFixSizeMemoryPool(MS_S32 s32PoolId)722 MS_BOOL MsOS_DeleteFixSizeMemoryPool (MS_S32 s32PoolId)
723 {
724 return FALSE;
725 }
726
727 //-------------------------------------------------------------------------------------------------
728 /// Get the information of a fixed-size memory pool
729 /// @param s32PoolId \b IN: memory pool ID
730 /// @param pPoolAddr \b OUT: holding the starting address for the memory pool
731 /// @param pu32PoolSize \b OUT: holding the total size of the memory pool
732 /// @param pu32FreeSize \b OUT: holding the available free size of the memory pool
733 /// @param pu32LargestFreeBlockSize \b OUT: holding the size of the largest free block
734 /// @return TRUE : succeed
735 /// @return FALSE : the pool has not been created
736 //-------------------------------------------------------------------------------------------------
MsOS_InfoFixSizeMemoryPool(MS_S32 s32PoolId,void ** pPoolAddr,MS_U32 * pu32PoolSize,MS_U32 * pu32FreeSize,MS_U32 * pu32LargestFreeBlockSize)737 MS_BOOL MsOS_InfoFixSizeMemoryPool (MS_S32 s32PoolId,
738 void **pPoolAddr,
739 MS_U32 *pu32PoolSize,
740 MS_U32 *pu32FreeSize,
741 MS_U32 *pu32LargestFreeBlockSize)
742 {
743 return FALSE;
744 }
745
746 //-------------------------------------------------------------------------------------------------
747 /// Allocate a memory block from the fixed-size memory pool
748 /// @param s32PoolId \b IN: memory pool ID
749 /// @return NULL : not enough available memory
750 /// @return Otherwise : pointer to the allocated memory block
751 /// @note watch out for alignment if u32BlockSize is not a multiple of 4
752 //-------------------------------------------------------------------------------------------------
MsOS_AllocateFixSizeMemory(MS_S32 s32PoolId)753 void * MsOS_AllocateFixSizeMemory (MS_S32 s32PoolId)
754 {
755 return NULL;
756 }
757
758 //-------------------------------------------------------------------------------------------------
759 /// Free a memory block from the fixed-size memory pool
760 /// @param pAddress \b IN: pointer to previously allocated memory block
761 /// @param s32PoolId \b IN: memory pool ID
762 /// @return TRUE : succeed
763 /// @return FALSE : fail
764 //-------------------------------------------------------------------------------------------------
MsOS_FreeFixSizeMemory(void * pAddress,MS_S32 s32PoolId)765 MS_BOOL MsOS_FreeFixSizeMemory (void *pAddress, MS_S32 s32PoolId)
766 {
767 return FALSE;
768 }
769
770
771 //
772 // Task
773 //
774 //-------------------------------------------------------------------------------------------------
775 /// Create a task
776 /// @param pTaskEntry \b IN: task entry point
777 /// @param u32TaskEntryData \b IN: task entry data: a pointer to some static data, or a
778 /// small integer, or NULL if the task does not require any additional data.
779 /// @param eTaskPriority \b IN: task priority
780 /// @param bAutoStart \b IN: start immediately or later
781 /// @param pStackBase \b IN: task stack
782 /// @param u32StackSize \b IN: stack size
783 /// @param pTaskName \b IN: task name
784 /// @return >=0 : assigned Task ID
785 /// @return < 0 : fail
786 //-------------------------------------------------------------------------------------------------
MsOS_CreateTask(TaskEntry pTaskEntry,MS_VIRT u32TaskEntryData,TaskPriority eTaskPriority,MS_BOOL bAutoStart,void * pStackBase,MS_U32 u32StackSize,char * pTaskName)787 MS_S32 MsOS_CreateTask (TaskEntry pTaskEntry,
788 MS_VIRT u32TaskEntryData,
789 TaskPriority eTaskPriority,
790 MS_BOOL bAutoStart,
791 void *pStackBase,
792 MS_U32 u32StackSize,
793 char *pTaskName)
794 {
795 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
796 return -1;
797 }
798
799 //-------------------------------------------------------------------------------------------------
800 /// Delete a previously created task
801 /// @param s32TaskId \b IN: task ID
802 /// @return TRUE : succeed
803 /// @return FALSE : fail
804 //-------------------------------------------------------------------------------------------------
MsOS_DeleteTask(MS_S32 s32TaskId)805 MS_BOOL MsOS_DeleteTask (MS_S32 s32TaskId)
806 {
807 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
808 return FALSE;
809 }
810
811 //-------------------------------------------------------------------------------------------------
812 /// Yield the execution right to ready tasks with "the same" priority
813 /// @return None
814 //-------------------------------------------------------------------------------------------------
MsOS_YieldTask(void)815 void MsOS_YieldTask (void)
816 {
817 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
818 }
819
820 //-------------------------------------------------------------------------------------------------
821 /// Suspend the calling task for u32Ms milliseconds
822 /// @param u32Ms \b IN: delay 1 ~ MSOS_WAIT_FOREVER ms
823 /// @return None
824 /// @note Not allowed in interrupt context; otherwise, exception will occur.
825 //-------------------------------------------------------------------------------------------------
MsOS_DelayTask(MS_U32 u32Ms)826 void MsOS_DelayTask (MS_U32 u32Ms)
827 {
828 #if 1
829 MS_U32 delay_start_time;
830 if ( u32Ms < 10 )
831 u32Ms++;
832 delay_start_time = MsOS_GetSystemTime();
833 while ( (MsOS_GetSystemTime() - delay_start_time) < u32Ms );
834 #else
835 MsOS_DelayTaskUs(u32Ms*1000);
836 #endif
837 }
838
839 //-------------------------------------------------------------------------------------------------
840 /// Delay for u32Us microseconds
841 /// @param u32Us \b IN: delay 0 ~ 999 us
842 /// @return None
843 /// @note implemented by "busy waiting". Plz call MsOS_DelayTask directly for ms-order delay
844 //-------------------------------------------------------------------------------------------------
MsOS_DelayTaskUs(MS_U32 u32Us)845 void MsOS_DelayTaskUs (MS_U32 u32Us)
846 {
847 MAsm_CPU_DelayUs(u32Us);
848 }
849
850 //-------------------------------------------------------------------------------------------------
851 /// Delay Poll for u32Us microseconds
852 /// @param u32Us \b IN: delay 0 ~ 999 us
853 /// @return None
854 /// @note implemented by "busy waiting". Plz call MsOS_DelayTask directly for ms-order delay
855 //-------------------------------------------------------------------------------------------------
MsOS_DelayTaskUs_Poll(MS_U32 u32Us)856 void MsOS_DelayTaskUs_Poll(MS_U32 u32Us)
857 {
858 MsOS_DelayTaskUs(u32Us);
859 }
860
861 //-------------------------------------------------------------------------------------------------
862 /// Resume the specified suspended task
863 /// @param s32TaskId \b IN: Task ID
864 /// @return TRUE : succeed
865 /// @return FALSE : fail
866 /// @note This API is not supported in Linux
867 //-------------------------------------------------------------------------------------------------
MsOS_ResumeTask(MS_S32 s32TaskId)868 MS_BOOL MsOS_ResumeTask (MS_S32 s32TaskId)
869 {
870 return FALSE;
871 }
872
873 //-------------------------------------------------------------------------------------------------
874 /// Suspend the specified task
875 /// @param s32TaskId \b IN: Task ID
876 /// @return TRUE : succeed
877 /// @return FALSE : fail
878 /// @note This API is not supported in Linux
879 //-------------------------------------------------------------------------------------------------
MsOS_SuspendTask(MS_S32 s32TaskId)880 MS_BOOL MsOS_SuspendTask (MS_S32 s32TaskId)
881 {
882 return FALSE;
883 }
884
885 //-------------------------------------------------------------------------------------------------
886 /// Get a task information
887 /// @param s32TaskId \b IN: task ID
888 /// @param peTaskPriority \b OUT: ptr to task priority
889 /// @param pStackBase \b OUT: ptr to stack base
890 /// @param pu32StackSize \b OUT: ptr to stack size
891 /// @param pTaskName \b OUT: ptr to task name
892 /// @return TRUE : succeed
893 /// @return FALSE : the task has not been created
894 //-------------------------------------------------------------------------------------------------
MsOS_InfoTask(MS_S32 s32TaskId,TaskPriority * peTaskPriority,void * pStackBase,MS_U32 * pu32StackSize,MS_U32 * pu32StackUsed,char * pTaskName)895 MS_BOOL MsOS_InfoTask (MS_S32 s32TaskId,
896 TaskPriority *peTaskPriority,
897 void* pStackBase,
898 MS_U32* pu32StackSize,
899 MS_U32* pu32StackUsed,
900 char *pTaskName)
901 {
902 return FALSE;
903 }
904
905 //-------------------------------------------------------------------------------------------------
906 /// Get all task ID
907 /// @param ps32TaskIdList \b IN/OUT: the memory for the all task ID
908 /// @return number of task created
909 //-------------------------------------------------------------------------------------------------
MsOS_InfoTaskList(MS_S32 * ps32TaskIdList)910 MS_U32 MsOS_InfoTaskList (MS_S32* ps32TaskIdList)
911 {
912 return 0;
913 }
914
915
916 //-------------------------------------------------------------------------------------------------
917 /// Get current task ID
918 /// @return >=0 : current task ID
919 /// @return <0 : fail
920 //-------------------------------------------------------------------------------------------------
MsOS_InfoTaskID(void)921 MS_S32 MsOS_InfoTaskID (void)
922 {
923 return -1;
924 }
925 //-------------------------------------------------------------------------------------------------
926 /// Get thread ID of current thread/process in Linux(Kernel)
927 /// @return : current thread ID
928 //-------------------------------------------------------------------------------------------------
MsOS_GetOSThreadID(void)929 MS_S32 MsOS_GetOSThreadID (void)
930 {
931 return MsOS_InfoTaskID();
932 }
933
934
935 //
936 // Mutex
937 //
938 //-------------------------------------------------------------------------------------------------
939 /// Create a mutex in the unlocked state
940 /// @param eAttribute \b IN: E_MSOS_FIFO: suspended in FIFO order
941 /// @param pMutexName \b IN: mutex name
942 /// @return >=0 : assigned mutex Id
943 /// @return <0 : fail
944 /// @note A mutex has the concept of an owner, whereas a semaphore does not.
945 /// A mutex provides priority inheritance protocol against proiorty inversion, whereas a binary semaphore does not.
946 //-------------------------------------------------------------------------------------------------
MsOS_CreateMutex(MsOSAttribute eAttribute,char * pMutexName,MS_U32 u32Flag)947 MS_S32 MsOS_CreateMutex ( MsOSAttribute eAttribute, char *pMutexName, MS_U32 u32Flag)
948 {
949 return 1;
950 }
951
952 //-------------------------------------------------------------------------------------------------
953 /// Delete the specified mutex
954 /// @param s32MutexId \b IN: mutex ID
955 /// @return TRUE : succeed
956 /// @return FALSE : fail
957 /// @note It is important that the mutex be in the unlocked state when it is
958 /// destroyed, or else the behavior is undefined.
959 //-------------------------------------------------------------------------------------------------
MsOS_DeleteMutex(MS_S32 s32MutexId)960 MS_BOOL MsOS_DeleteMutex (MS_S32 s32MutexId)
961 {
962 return TRUE;
963 }
964
965 //-------------------------------------------------------------------------------------------------
966 /// Attempt to lock a mutex
967 /// @param s32MutexId \b IN: mutex ID
968 /// @param u32WaitMs \b IN: 0 ~ MSOS_WAIT_FOREVER: suspend time (ms) if the mutex is locked
969 /// @return TRUE : succeed
970 /// @return FALSE : fail
971 //-------------------------------------------------------------------------------------------------
MsOS_ObtainMutex(MS_S32 s32MutexId,MS_U32 u32WaitMs)972 MS_BOOL MsOS_ObtainMutex (MS_S32 s32MutexId, MS_U32 u32WaitMs)
973 {
974 return TRUE;
975 }
976
977 //-------------------------------------------------------------------------------------------------
978 /// Attempt to unlock a mutex
979 /// @param s32MutexId \b IN: mutex ID
980 /// @return TRUE : succeed
981 /// @return FALSE : fail
982 /// @note Only the owner thread of the mutex can unlock it.
983 //-------------------------------------------------------------------------------------------------
MsOS_ReleaseMutex(MS_S32 s32MutexId)984 MS_BOOL MsOS_ReleaseMutex (MS_S32 s32MutexId)
985 {
986 return TRUE;
987 }
988
989 //-------------------------------------------------------------------------------------------------
990 // Get a mutex informaton
991 // @param s32MutexId \b IN: mutex ID
992 // @param peAttribute \b OUT: ptr to suspended mode: E_MSOS_FIFO / E_MSOS_PRIORITY
993 // @param pMutexName \b OUT: ptr to mutex name
994 // @return TRUE : succeed
995 // @return FALSE : the mutex has not been created.
996 //-------------------------------------------------------------------------------------------------
MsOS_InfoMutex(MS_S32 s32MutexId,MsOSAttribute * peAttribute,char * pMutexName)997 MS_BOOL MsOS_InfoMutex (MS_S32 s32MutexId, MsOSAttribute *peAttribute, char *pMutexName)
998 {
999 return TRUE;
1000 }
1001
1002 //
1003 // Semaphore
1004 //
1005 //-------------------------------------------------------------------------------------------------
1006 /// Create a semaphore
1007 /// @param u32InitCnt \b IN: initial semaphore value
1008 /// @param eAttribute \b IN: E_MSOS_FIFO suspended in FIFO order
1009 /// @param pSemaphoreName \b IN: semaphore name
1010 /// @return >=0 : assigned Semaphore Id
1011 /// @return <0 : fail
1012 /// @note A semaphore does not have the concept of an owner; it is possible for one thread to lock a
1013 /// binary semaphore and another thread to unlock it.
1014 //-------------------------------------------------------------------------------------------------
MsOS_CreateSemaphore(MS_U32 u32InitCnt,MsOSAttribute eAttribute,char * pSemaphoreName)1015 MS_S32 MsOS_CreateSemaphore (MS_U32 u32InitCnt,
1016 MsOSAttribute eAttribute,
1017 char *pSemaphoreName)
1018 {
1019 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1020 return -1;
1021 }
1022
1023 //-------------------------------------------------------------------------------------------------
1024 /// Delete the specified semaphore
1025 /// @param s32SemaphoreId \b IN: semaphore ID
1026 /// @return TRUE : succeed
1027 /// @return FALSE : fail
1028 /// @note It is important that there are not any threads waiting on the semaphore
1029 /// when this function is called or the behavior is undefined.
1030 //-------------------------------------------------------------------------------------------------
MsOS_DeleteSemaphore(MS_S32 s32SemaphoreId)1031 MS_BOOL MsOS_DeleteSemaphore (MS_S32 s32SemaphoreId)
1032 {
1033 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1034 return FALSE;
1035 }
1036
1037 //-------------------------------------------------------------------------------------------------
1038 /// Attempt to decrement a semaphore count
1039 /// @param s32SemaphoreId \b IN: semaphore ID
1040 /// @param u32WaitMs \b IN: 0 ~ MSOS_WAIT_FOREVER: suspend time (ms) if the semaphore count = 0
1041 /// @return TRUE : succeed
1042 /// @return FALSE : fail
1043 //-------------------------------------------------------------------------------------------------
MsOS_ObtainSemaphore(MS_S32 s32SemaphoreId,MS_U32 u32WaitMs)1044 MS_BOOL MsOS_ObtainSemaphore (MS_S32 s32SemaphoreId, MS_U32 u32WaitMs)
1045 {
1046 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1047 return FALSE;
1048 }
1049
1050 //-------------------------------------------------------------------------------------------------
1051 /// Increase a semaphore count
1052 /// @param s32SemaphoreId \b IN: semaphore ID
1053 /// @return TRUE : succeed
1054 /// @return FALSE : fail
1055 /// @note It's possible for any thread to increase the semaphore count
1056 //-------------------------------------------------------------------------------------------------
MsOS_ReleaseSemaphore(MS_S32 s32SemaphoreId)1057 MS_BOOL MsOS_ReleaseSemaphore (MS_S32 s32SemaphoreId)
1058 {
1059 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1060 return FALSE;
1061 }
1062
1063 //-------------------------------------------------------------------------------------------------
1064 // Get a semaphore informaton
1065 // @param s32SemaphoreId \b IN: semaphore ID
1066 // @param pu32InitCnt \b OUT: ptr to initial semaphore value
1067 // @param peAttribute \b OUT: ptr to suspended mode: E_MSOS_FIFO / E_MSOS_PRIORITY
1068 // @param pSemaphoreName \b OUT: ptr to semaphore name
1069 // @return TRUE : succeed
1070 // @return FALSE : the semaphore has not been created.
1071 //-------------------------------------------------------------------------------------------------
MsOS_InfoSemaphore(MS_S32 s32SemaphoreId,MS_U32 * pu32InitCnt,MsOSAttribute * peAttribute,char * pSemaphoreName)1072 MS_BOOL MsOS_InfoSemaphore (MS_S32 s32SemaphoreId, MS_U32 *pu32InitCnt, MsOSAttribute *peAttribute, char *pSemaphoreName)
1073 {
1074 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1075 return FALSE;
1076 }
1077
1078
1079 //
1080 // Event management
1081 //
1082 //-------------------------------------------------------------------------------------------------
1083 /// Create an event group
1084 /// @param pEventName \b IN: event group name
1085 /// @return >=0 : assigned Event Id
1086 /// @return <0 : fail
1087 //-------------------------------------------------------------------------------------------------
MsOS_CreateEventGroup(char * pEventName)1088 MS_S32 MsOS_CreateEventGroup (char *pEventName)
1089 {
1090 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1091 return -1;
1092 }
1093
1094 //-------------------------------------------------------------------------------------------------
1095 /// Delete the event group
1096 /// @param s32EventGroupId \b IN: event group ID
1097 /// @return TRUE : succeed
1098 /// @return FALSE : fail, sb is waiting for the event flag
1099 /// @note event group that are being waited on must not be deleted
1100 //-------------------------------------------------------------------------------------------------
MsOS_DeleteEventGroup(MS_S32 s32EventGroupId)1101 MS_BOOL MsOS_DeleteEventGroup (MS_S32 s32EventGroupId)
1102 {
1103 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1104 return FALSE;
1105 }
1106
1107 //-------------------------------------------------------------------------------------------------
1108 /// Set the event flag (bitwise OR w/ current value) in the specified event group
1109 /// @param s32EventGroupId \b IN: event group ID
1110 /// @param u32EventFlag \b IN: event flag value
1111 /// @return TRUE : succeed
1112 /// @return FALSE : fail
1113 //-------------------------------------------------------------------------------------------------
MsOS_SetEvent(MS_S32 s32EventGroupId,MS_U32 u32EventFlag)1114 MS_BOOL MsOS_SetEvent (MS_S32 s32EventGroupId, MS_U32 u32EventFlag)
1115 {
1116 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1117 return FALSE;
1118 }
1119
1120 //-------------------------------------------------------------------------------------------------
1121 /// Clear the specified event flag (bitwise XOR operation) in the specified event group
1122 /// @param s32EventGroupId \b IN: event group ID
1123 /// @param u32EventFlag \b IN: event flag value
1124 /// @returnTRUE : succeed
1125 /// @return FALSE : fail
1126 //-------------------------------------------------------------------------------------------------
MsOS_ClearEvent(MS_S32 s32EventGroupId,MS_U32 u32EventFlag)1127 MS_BOOL MsOS_ClearEvent (MS_S32 s32EventGroupId, MS_U32 u32EventFlag)
1128 {
1129 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1130 return FALSE;
1131 }
1132
1133 //-------------------------------------------------------------------------------------------------
1134 /// Wait for the specified event flag combination from the event group
1135 /// @param s32EventGroupId \b IN: event group ID
1136 /// @param u32WaitEventFlag \b IN: wait event flag value
1137 /// @param pu32RetrievedEventFlag \b OUT: retrieved event flag value
1138 /// @param eWaitMode \b IN: E_AND/E_OR/E_AND_CLEAR/E_OR_CLEAR
1139 /// @param u32WaitMs \b IN: 0 ~ MSOS_WAIT_FOREVER: suspend time (ms) if the event is not ready
1140 /// @return TRUE : succeed
1141 /// @return FALSE : fail
1142 //-------------------------------------------------------------------------------------------------
MsOS_WaitEvent(MS_S32 s32EventGroupId,MS_U32 u32WaitEventFlag,MS_U32 * pu32RetrievedEventFlag,EventWaitMode eWaitMode,MS_U32 u32WaitMs)1143 MS_BOOL MsOS_WaitEvent (MS_S32 s32EventGroupId,
1144 MS_U32 u32WaitEventFlag,
1145 MS_U32 *pu32RetrievedEventFlag,
1146 EventWaitMode eWaitMode,
1147 MS_U32 u32WaitMs)
1148 {
1149 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1150 return FALSE;
1151 }
1152
1153 //
1154 // Timer management
1155 //
1156 //-------------------------------------------------------------------------------------------------
1157 /// Create a Timer
1158 /// @param pTimerCb \b IN: timer callback function
1159 /// @param u32FirstTimeMs \b IN: first ms for timer expiration
1160 /// @param u32PeriodTimeMs \b IN: periodic ms for timer expiration after first expiration
1161 /// 0: one shot timer
1162 /// @param bStartTimer \b IN: TRUE: activates the timer after it is created
1163 /// FALSE: leaves the timer disabled after it is created
1164 /// @param pTimerName \b IN: Timer name (not used by eCos)
1165 /// @return >=0 : assigned Timer ID
1166 /// <0 : fail
1167 //-------------------------------------------------------------------------------------------------
MsOS_CreateTimer(TimerCb pTimerCb,MS_U32 u32FirstTimeMs,MS_U32 u32PeriodTimeMs,MS_BOOL bStartTimer,char * pTimerName)1168 MS_S32 MsOS_CreateTimer (TimerCb pTimerCb,
1169 MS_U32 u32FirstTimeMs,
1170 MS_U32 u32PeriodTimeMs,
1171 MS_BOOL bStartTimer,
1172 char *pTimerName)
1173 {
1174 MS_S32 s32TimerId;
1175
1176 extern MS_S32 Timer_IRQ_Register(void *ptCb);
1177 extern void Timer_Period_Register(MS_U32 periodCb, MS_S32 s32TimerId_set);
1178 extern void Timer_Start_set(MS_BOOL bStartTimer_set, MS_S32 s32TimerId_set);
1179 extern void Timer_firsttime_interval(MS_U32 firsttime_interval, MS_S32 s32TimerId_set);
1180
1181 s32TimerId=Timer_IRQ_Register(pTimerCb);
1182 Timer_Period_Register(u32PeriodTimeMs,s32TimerId);
1183 Timer_Start_set(bStartTimer,s32TimerId);
1184 Timer_firsttime_interval(u32FirstTimeMs, s32TimerId);
1185
1186 return s32TimerId;
1187 }
1188
1189 //-------------------------------------------------------------------------------------------------
1190 /// Delete the Timer
1191 /// @param s32TimerId \b IN: Timer ID
1192 /// @return TRUE : succeed
1193 /// @return FALSE : fail
1194 //-------------------------------------------------------------------------------------------------
MsOS_DeleteTimer(MS_S32 s32TimerId)1195 MS_BOOL MsOS_DeleteTimer (MS_S32 s32TimerId)
1196 {
1197 extern void Timer_IRQ_Delete(MS_S32 timer_ld);
1198 extern void Timer_Period_Register(MS_U32 periodCb, MS_S32 s32TimerId_set);
1199 extern void Timer_Start_set(MS_BOOL bStartTimer_set, MS_S32 s32TimerId_set);
1200 extern void Timer_firsttime_interval(MS_U32 firsttime_interval, MS_S32 s32TimerId_set);
1201
1202 Timer_IRQ_Delete(s32TimerId);
1203 Timer_Period_Register(1,s32TimerId);
1204 Timer_Start_set(FALSE,s32TimerId);
1205 Timer_firsttime_interval(0, s32TimerId);
1206 return TRUE;
1207 }
1208
1209 //-------------------------------------------------------------------------------------------------
1210 /// Start the Timer
1211 /// @param s32TimerId \b IN: Timer ID
1212 /// @return TRUE : succeed
1213 /// @return FALSE : fail
1214 //-------------------------------------------------------------------------------------------------
MsOS_StartTimer(MS_S32 s32TimerId)1215 MS_BOOL MsOS_StartTimer (MS_S32 s32TimerId)
1216 {
1217 extern void Timer_Start_set(MS_BOOL bStartTimer_set, MS_S32 s32TimerId_set);
1218 Timer_Start_set(TRUE,s32TimerId);
1219 return TRUE;
1220 }
1221
1222 //-------------------------------------------------------------------------------------------------
1223 /// Stop the Timer
1224 /// @param s32TimerId \b IN: Timer ID
1225 /// @return TRUE : succeed
1226 /// @return FALSE : fail
1227 /// @note MsOS_StopTimer then MsOS_StartTimer => The timer will trigger at the same relative
1228 /// intervals that it would have if it had not been disabled.
1229 //-------------------------------------------------------------------------------------------------
MsOS_StopTimer(MS_S32 s32TimerId)1230 MS_BOOL MsOS_StopTimer (MS_S32 s32TimerId)
1231 {
1232 extern void Timer_Start_set(MS_BOOL bStartTimer_set, MS_S32 s32TimerId_set);
1233 Timer_Start_set(FALSE,s32TimerId);
1234 return TRUE;
1235 }
1236
1237 //-------------------------------------------------------------------------------------------------
1238 /// Reset a Timer & reset the expiration periods
1239 /// @param s32TimerId \b IN: Timer ID
1240 /// @param u32FirstTimeMs \b IN: first ms for timer expiration
1241 /// @param u32PeriodTimeMs \b IN: periodic ms for timer expiration after first expiration
1242 /// 0: one shot timer
1243 /// @param bStartTimer \b IN: TRUE: activates the timer after it is created
1244 /// FALSE: leaves the timer disabled after it is created
1245 /// @return TRUE : succeed
1246 /// @return FALSE : fail
1247 //-------------------------------------------------------------------------------------------------
MsOS_ResetTimer(MS_S32 s32TimerId,MS_U32 u32FirstTimeMs,MS_U32 u32PeriodTimeMs,MS_BOOL bStartTimer)1248 MS_BOOL MsOS_ResetTimer (MS_S32 s32TimerId,
1249 MS_U32 u32FirstTimeMs,
1250 MS_U32 u32PeriodTimeMs,
1251 MS_BOOL bStartTimer)
1252 {
1253 extern void Timer_Period_Register(MS_U32 periodCb, MS_S32 s32TimerId_set);
1254 extern void Timer_Start_set(MS_BOOL bStartTimer_set, MS_S32 s32TimerId_set);
1255 extern void Timer_firsttime_interval(MS_U32 firsttime_interval, MS_S32 s32TimerId_set);
1256
1257 Timer_Period_Register(u32PeriodTimeMs,s32TimerId);
1258 Timer_Start_set(bStartTimer,s32TimerId);
1259 Timer_firsttime_interval(u32FirstTimeMs, s32TimerId);
1260
1261 return TRUE;
1262 }
1263
1264
1265 //
1266 // System time
1267 //
1268 //-------------------------------------------------------------------------------------------------
1269 /// Get current system time in ms
1270 /// @return system time in ms
1271 //-------------------------------------------------------------------------------------------------
MsOS_GetSystemTime(void)1272 MS_U32 MsOS_GetSystemTime (void) // 1ms/systime
1273 {
1274 MS_U32 systime;
1275 systime = MAsm_GetSystemTime();
1276 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1277 return systime;
1278 }
1279 //-------------------------------------------------------------------------------------------------
1280 ///[OBSOLETE]
1281 /// Time difference between current time and task time
1282 /// @return system time diff in ms
1283 //-------------------------------------------------------------------------------------------------
MsOS_Timer_DiffTimeFromNow(MS_U32 u32TaskTimer)1284 MS_U32 MsOS_Timer_DiffTimeFromNow(MS_U32 u32TaskTimer) //unit = ms
1285 {
1286 return (MsOS_GetSystemTime() - u32TaskTimer);
1287 }
1288 //-------------------------------------------------------------------------------------------------
1289 ///[OBSOLETE]
1290 /// Time difference between setting time and task time
1291 /// @return system time diff in ms
1292 //-------------------------------------------------------------------------------------------------
MsOS_Timer_DiffTime(MS_U32 u32Timer,MS_U32 u32TaskTimer)1293 MS_U32 MsOS_Timer_DiffTime(MS_U32 u32Timer, MS_U32 u32TaskTimer) //unit = ms
1294 {
1295 // simple minus is enough, because max(timer_counter) == max(u32)
1296 return (u32Timer - u32TaskTimer);
1297 }
1298 //
1299 // Queue
1300 //
1301 //-------------------------------------------------------------------------------------------------
1302 /// Create a Queue
1303 /// @param pStartAddr \b IN: It is useless now, can pass NULL.
1304 /// @param u32QueueSize \b IN: queue size (byte unit) : now fixed as
1305 /// CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE * u32MessageSize
1306 /// @param eMessageType \b IN: E_MSG_FIXED_SIZE / E_MSG_VAR_SIZE
1307 /// @param u32MessageSize \b IN: message size (byte unit) for E_MSG_FIXED_SIZE
1308 /// max message size (byte unit) for E_MSG_VAR_SIZE
1309 /// @param eAttribute \b IN: E_MSOS_FIFO suspended in FIFO order
1310 /// @param pQueueName \b IN: queue name
1311 /// @return assigned message queue ID
1312 /// @return < 0 - fail
1313 //-------------------------------------------------------------------------------------------------
MsOS_CreateQueue(void * pStartAddr,MS_U32 u32QueueSize,MessageType eMessageType,MS_U32 u32MessageSize,MsOSAttribute eAttribute,char * pQueueName)1314 MS_S32 MsOS_CreateQueue (void *pStartAddr,
1315 MS_U32 u32QueueSize,
1316 MessageType eMessageType,
1317 MS_U32 u32MessageSize,
1318 MsOSAttribute eAttribute,
1319 char *pQueueName)
1320 {
1321 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1322 return -1;
1323 }
1324
1325 //-------------------------------------------------------------------------------------------------
1326 /// Delete the Queue
1327 /// @param s32QueueId \b IN: Queue ID
1328 /// @return TRUE : succeed
1329 /// @return FALSE : fail
1330 /// @note It is important that there are not any threads blocked on the queue
1331 /// when this function is called or the behavior is undefined.
1332 //-------------------------------------------------------------------------------------------------
MsOS_DeleteQueue(MS_S32 s32QueueId)1333 MS_BOOL MsOS_DeleteQueue (MS_S32 s32QueueId)
1334 {
1335 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1336 return FALSE;
1337 }
1338
1339 //-------------------------------------------------------------------------------------------------
1340 /// Send a message to the end of the specified queue
1341 /// @param s32QueueId \b IN: Queue ID
1342 /// @param pu8Message \b IN: ptr to msg to send. NULL ptr is not allowed
1343 /// @param u32Size \b IN: msg size (byte)
1344 /// @param u32WaitMs \b IN: 0 ~ MSOS_WAIT_FOREVER: suspend time (ms) if the queue is full
1345 /// @return TRUE : succeed
1346 /// @return FALSE : fail
1347 //-------------------------------------------------------------------------------------------------
MsOS_SendToQueue(MS_S32 s32QueueId,MS_U8 * pu8Message,MS_U32 u32Size,MS_U32 u32WaitMs)1348 MS_BOOL MsOS_SendToQueue (MS_S32 s32QueueId, MS_U8 *pu8Message, MS_U32 u32Size, MS_U32 u32WaitMs)
1349 {
1350 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1351 return FALSE;
1352 }
1353
1354 //-------------------------------------------------------------------------------------------------
1355 /// Receive a message from the specified queue
1356 /// @param s32QueueId \b IN: Queue ID
1357 /// @param pu8Message \b OUT: msg destination
1358 /// @param u32IntendedSize \b IN: intended msg size (byte unit) to receive:
1359 /// @param pu32ActualSize \b OUT: actual msg size (byte unit) received
1360 /// @param u32WaitMs \b IN: 0 ~ MSOS_WAIT_FOREVER: suspend time (ms) if the queue is empty
1361 /// @return TRUE : succeed
1362 /// @return FALSE : fail
1363 //-------------------------------------------------------------------------------------------------
MsOS_RecvFromQueue(MS_S32 s32QueueId,MS_U8 * pu8Message,MS_U32 u32IntendedSize,MS_U32 * pu32ActualSize,MS_U32 u32WaitMs)1364 MS_BOOL MsOS_RecvFromQueue (MS_S32 s32QueueId, MS_U8 *pu8Message, MS_U32 u32IntendedSize, MS_U32 *pu32ActualSize, MS_U32 u32WaitMs)
1365 {
1366 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1367 return FALSE;
1368 }
1369
1370 //-------------------------------------------------------------------------------------------------
1371 /// Receive a message from the specified queue
1372 /// @param s32QueueId \b IN: Queue ID
1373 /// @param pu8Message \b OUT: msg destination
1374 /// @param u32IntendedSize \b IN: intended msg size (byte unit) to receive:
1375 /// @param pu32ActualSize \b OUT: actual msg size (byte unit) received
1376 /// @return TRUE : succeed
1377 /// @return FALSE : fail
1378 //-------------------------------------------------------------------------------------------------
MsOS_PeekFromQueue(MS_S32 s32QueueId,MS_U8 * pu8Message,MS_U32 u32IntendedSize,MS_U32 * pu32ActualSize)1379 MS_BOOL MsOS_PeekFromQueue (MS_S32 s32QueueId, MS_U8 *pu8Message, MS_U32 u32IntendedSize, MS_U32 *pu32ActualSize)
1380 {
1381 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1382 return FALSE;
1383 }
1384
1385 //-------------------------------------------------------------------------------------------------
1386 // Get a Queue information
1387 // @param s32QueueId \b IN: Queue ID
1388 // @param pu32QueueSize \b OUT: ptr to queue size (DW)
1389 // @param pu32MessageSize \b OUT: ptr to message size (DW)
1390 // @param peAttribute \b OUT: ptr to suspended mode: E_MSOS_FIFO / E_MSOS_PRIORITY
1391 // @param pQueueName \b OUT: ptr to Queue name
1392 // @return TRUE : succeed
1393 // @return FALSE : the Queue has not been created
1394 //-------------------------------------------------------------------------------------------------
MsOS_InfoQueue(MS_S32 s32QueueId,MS_U32 * pu32QueueSize,MS_U32 * pu32MessageSize,MsOSAttribute * peAttribute,char * pQueueName)1395 MS_BOOL MsOS_InfoQueue ( MS_S32 s32QueueId, MS_U32 *pu32QueueSize, MS_U32 *pu32MessageSize,
1396 MsOSAttribute *peAttribute, char *pQueueName)
1397 {
1398 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1399 return FALSE;
1400 }
1401
1402 //
1403 // Interrupt management
1404 //
1405 //-------------------------------------------------------------------------------------------------
1406 /// Attach the interrupt callback function to interrupt #
1407 /// @param eIntNum \b IN: Interrupt number in enumerator InterruptNum
1408 /// @param pIntCb \b IN: Interrupt callback function
1409 /// @return TRUE : succeed
1410 /// @return FALSE : fail
1411 //-------------------------------------------------------------------------------------------------
MsOS_AttachInterrupt(InterruptNum eIntNum,InterruptCb pIntCb)1412 MS_BOOL MsOS_AttachInterrupt (InterruptNum eIntNum, InterruptCb pIntCb)
1413 {
1414 MDrv_IRQ_Attach(eIntNum, pIntCb);
1415 // mdrv_irq_attach(eIntNum, (mhal_isr_t)pIntCb, 0);
1416 return TRUE;
1417 }
1418
1419 //-------------------------------------------------------------------------------------------------
1420 /// Detach the interrupt callback function from interrupt #
1421 /// @param eIntNum \b IN: Interrupt number in enumerator InterruptNum
1422 /// @return TRUE : succeed
1423 /// @return FALSE : fail
1424 //-------------------------------------------------------------------------------------------------
MsOS_DetachInterrupt(InterruptNum eIntNum)1425 MS_BOOL MsOS_DetachInterrupt (InterruptNum eIntNum)
1426 {
1427 MDrv_IRQ_Detech(eIntNum);
1428 // mdrv_irq_detech(eIntNum);
1429 return TRUE;
1430 }
1431
1432 //-------------------------------------------------------------------------------------------------
1433 /// Enable (unmask) the interrupt #
1434 /// @param eIntNum \b IN: Interrupt number in enumerator InterruptNum
1435 /// @return TRUE : succeed
1436 /// @return FALSE : fail
1437 //-------------------------------------------------------------------------------------------------
MsOS_EnableInterrupt(InterruptNum eIntNum)1438 MS_BOOL MsOS_EnableInterrupt (InterruptNum eIntNum)
1439 {
1440 MDrv_IRQ_UnMask(eIntNum);
1441 // mdrv_irq_unmask(eIntNum);
1442 return TRUE;
1443 }
1444
1445 //-------------------------------------------------------------------------------------------------
1446 /// Disable (mask) the interrupt #
1447 /// @param eIntNum \b IN: Interrupt number in enumerator InterruptNum
1448 /// @return TRUE : succeed
1449 //-------------------------------------------------------------------------------------------------
MsOS_DisableInterrupt(InterruptNum eIntNum)1450 MS_BOOL MsOS_DisableInterrupt (InterruptNum eIntNum)
1451 {
1452 MDrv_IRQ_Mask(eIntNum);
1453 // mdrv_irq_mask(eIntNum);
1454 return TRUE;
1455 }
1456
1457 //-------------------------------------------------------------------------------------------------
1458 /// Disable all interrupts (including timer interrupt), the scheduler is disabled.
1459 /// @return Interrupt register value before all interrupts disable
1460 //-------------------------------------------------------------------------------------------------
MsOS_DisableAllInterrupts(void)1461 MS_U32 MsOS_DisableAllInterrupts(void)
1462 {
1463 MDrv_IRQ_MaskAll();
1464 // mdrv_irq_maskall();
1465 return 0x12345678;
1466 }
1467
1468 //-------------------------------------------------------------------------------------------------
1469 /// Restore the interrupts from last MsOS_DisableAllInterrupts.
1470 /// @param u32OldInterrupts \b IN: Interrupt register value from @ref MsOS_DisableAllInterrupts
1471 /// @return TRUE : succeed
1472 //-------------------------------------------------------------------------------------------------
MsOS_RestoreAllInterrupts(MS_U32 u32OldInterrupts)1473 MS_BOOL MsOS_RestoreAllInterrupts(MS_U32 u32OldInterrupts)
1474 {
1475 MDrv_IRQ_Restore();
1476 // mdrv_irq_restore();
1477 return TRUE;
1478 }
1479
1480 //-------------------------------------------------------------------------------------------------
1481 /// Enable all CPU interrupts.
1482 /// @return TRUE : succeed
1483 //-------------------------------------------------------------------------------------------------
MsOS_EnableAllInterrupts(void)1484 MS_BOOL MsOS_EnableAllInterrupts(void)
1485 {
1486 MDrv_IRQ_UnMaskAll();
1487 // mdrv_irq_unmask_all();
1488 return TRUE;
1489 }
1490
1491 //-------------------------------------------------------------------------------------------------
1492 /// In Interuupt Context or not
1493 /// @return TRUE : Yes
1494 /// @return FALSE : No
1495 //-------------------------------------------------------------------------------------------------
MsOS_In_Interrupt(void)1496 MS_BOOL MsOS_In_Interrupt (void)
1497 {
1498 return MDrv_IRQ_InISR();
1499 // return mdrv_irq_inisr();
1500 // return FALSE;
1501 }
1502
1503 //-------------------------------------------------------------------------------------------------
1504 /// Write back if dirty & Invalidate the cache lines in the given range
1505 /// @param u32Start \b IN: start address (must be 16-B aligned and in cacheable area)
1506 /// @param u32Size \b IN: size (must be 16-B aligned)
1507 /// @return TRUE : succeed
1508 /// @return FALSE : fail due to invalide parameter
1509 //-------------------------------------------------------------------------------------------------
MsOS_Dcache_Flush(MS_VIRT u32Start,MS_SIZE u32Size)1510 MS_BOOL MsOS_Dcache_Flush( MS_VIRT u32Start, MS_SIZE u32Size )
1511 {
1512 mhal_dcache_flush(u32Start, u32Size);
1513 return TRUE;
1514 }
1515
1516 #if defined(CHIP_A2) || \
1517 defined(CHIP_T12) || \
1518 defined(CHIP_T8) || \
1519 defined(CHIP_J2) || \
1520 defined(CHIP_T11) || \
1521 defined(CHIP_A5) || \
1522 defined(CHIP_A5P) || \
1523 defined(CHIP_A3) || \
1524 defined(CHIP_K2) || \
1525 defined(CHIP_EDISON)
MsOS_L2Cache_Flush(void)1526 MS_BOOL MsOS_L2Cache_Flush(void)
1527 {
1528 mhal_L2Cache_Flush();
1529 return TRUE;
1530 }
1531
MsOS_L2Cache_Read(void)1532 MS_BOOL MsOS_L2Cache_Read(void)
1533 {
1534 mhal_L2Cache_Read();
1535 return TRUE;
1536 }
1537 #endif
1538
1539 //-------------------------------------------------------------------------------------------------
1540 /// Invalidate the cache lines in the given range
1541 /// @param u32Start \b IN: start address (must be 16-B aligned and in cacheable area)
1542 /// @param u32Size \b IN: size (must be 16-B aligned)
1543 /// @return TRUE : succeed
1544 /// @return FALSE : fail due to invalide parameter
1545 //-------------------------------------------------------------------------------------------------
MsOS_Dcache_Invalidate(MS_VIRT u32Start,MS_SIZE u32Size)1546 MS_BOOL MsOS_Dcache_Invalidate( MS_VIRT u32Start, MS_SIZE u32Size )
1547 {
1548
1549 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1550 return FALSE;
1551 }
1552
1553 //-------------------------------------------------------------------------------------------------
1554 /// Write back if dirty the cache lines in the given range
1555 /// @param u32Start \b IN: start address (must be 16-B aligned and in cacheable area)
1556 /// @param u32Size \b IN: size (must be 16-B aligned)
1557 /// @return TRUE : succeed
1558 /// @return FALSE : fail due to invalide parameter
1559 //-------------------------------------------------------------------------------------------------
MsOS_Dcache_Writeback(MS_VIRT u32Start,MS_SIZE u32Size)1560 MS_BOOL MsOS_Dcache_Writeback( MS_VIRT u32Start, MS_SIZE u32Size )
1561 {
1562 //printf("[%s][%d] %s is not supported\n", __FUNCTION__, __LINE__, __FUNCTION__);
1563 return FALSE;
1564 }
1565
MsOS_VA2PA(MS_VIRT addr)1566 MS_PHY MsOS_VA2PA(MS_VIRT addr)
1567 {
1568 return (MS_PHY)HAL_MsOS_MPool_VA2PA(addr);
1569 }
1570
1571 extern MS_VIRT _MPool_PA2VA(MS_PHY pAddrPhys, MS_BOOL bNonCache);
MsOS_PA2KSEG0(MS_PHY addr)1572 MS_VIRT MsOS_PA2KSEG0(MS_PHY addr)
1573 {
1574 MS_VIRT pVirtAddr = _MPool_PA2VA(addr, FALSE);
1575 if(!pVirtAddr)
1576 pVirtAddr = (MS_VIRT)HAL_MsOS_MPool_PA2KSEG0(addr);
1577 return pVirtAddr;
1578 }
1579
MsOS_PA2KSEG1(MS_PHY addr)1580 MS_VIRT MsOS_PA2KSEG1(MS_PHY addr)
1581 {
1582 MS_VIRT pVirtAddr = _MPool_PA2VA(addr, TRUE);
1583 if(!pVirtAddr)
1584 pVirtAddr = (MS_VIRT)HAL_MsOS_MPool_PA2KSEG1(addr);
1585 return pVirtAddr;
1586 }
1587
1588 /* FIXME: patch for monaco bring up */
1589 #define SHM_SIZE (2 * 1024 * 1024)
1590 #define MAX_CLIENT_NUM 320
1591 typedef struct
1592 {
1593 MS_U8 u8ClientName[MAX_CLIENT_NAME_LENGTH+ 1];
1594 MS_U32 u32Offset;
1595 MS_U32 u32Size;
1596 MS_U8 u8ClientId; // 0 means "never used"
1597 MS_U8 u8RefCnt;
1598 MS_U8 u8Dummy[2];
1599 } MsOS_SHM_Context;
1600
1601 typedef struct
1602 {
1603 MS_U32 u32MaxClientNum;
1604 MS_U32 u32ClientNum;
1605 MS_U32 u32ShmSize;
1606 MS_U32 u32Offset;
1607 MsOS_SHM_Context context[MAX_CLIENT_NUM];
1608 } MsOS_SHM_Hdr;
1609
1610 static int _shm_id = -1;
1611 static MS_U8 *_pu8ShareMem = NULL;
1612 static MsOS_SHM_Hdr _ShmHdr; // dummy storage
1613
1614 // Share memory operation
1615 // MS_BOOL MsOS_SHM_Init(MS_U32 u32ShmSize)
MsOS_SHM_Init(void)1616 MS_BOOL MsOS_SHM_Init(void)
1617 {
1618 MS_BOOL bInit = FALSE;
1619 MS_U32 u32ShmSize;
1620
1621 if (-1 != _shm_id)
1622 {
1623 return FALSE;
1624 }
1625
1626 u32ShmSize = SHM_SIZE;
1627 u32ShmSize += sizeof(MsOS_SHM_Hdr);
1628 u32ShmSize += ((1<< 12)- 1);
1629 u32ShmSize = (u32ShmSize>> 12)<< 12; // make it 4KBytes alignment
1630
1631 if (NULL == (_pu8ShareMem = (MS_U8*)malloc(u32ShmSize)))
1632 {
1633 printf("[%s][%d] fail, ask for 0x%X mem_size\n", __FUNCTION__, __LINE__, (unsigned int)u32ShmSize);
1634 return FALSE;
1635 }
1636 bInit = TRUE;
1637 if (bInit)
1638 {
1639 #if 0
1640 MsOS_SHM_Hdr* pHdr;
1641
1642 // printf("[%s][%d] Clear share memory header\n", __FUNCTION__, __LINE__);
1643 memset(_pu8ShareMem, 0, sizeof(MsOS_SHM_Hdr));
1644 pHdr = (MsOS_SHM_Hdr*) _pu8ShareMem;
1645
1646 pHdr->u32MaxClientNum = MAX_CLIENT_NUM;
1647 pHdr->u32ClientNum = 0;
1648 pHdr->u32ShmSize = u32ShmSize;
1649 pHdr->u32Offset = (sizeof(MsOS_SHM_Hdr)+3)&~3;
1650 #else
1651 memset(&_ShmHdr, 0, sizeof(_ShmHdr)); // dummy storage
1652 _ShmHdr.u32MaxClientNum = MAX_CLIENT_NUM;
1653 _ShmHdr.u32ClientNum = 0;
1654 _ShmHdr.u32ShmSize = u32ShmSize;
1655 _ShmHdr.u32Offset = (sizeof(MsOS_SHM_Hdr)+7)&~7;
1656 memcpy(_pu8ShareMem, &_ShmHdr, sizeof(_ShmHdr));
1657 #endif
1658 }
1659 return TRUE;
1660 }
1661
1662 // Share memory operation
MsOS_SHM_GetId(MS_U8 * pu8ClientName,MS_U32 u32BufSize,MS_U32 * pu32ShmId,MS_VIRT * pu32Addr,MS_U32 * pu32BufSize,MS_U32 u32Flag)1663 MS_BOOL MsOS_SHM_GetId(MS_U8* pu8ClientName, MS_U32 u32BufSize, MS_U32* pu32ShmId, MS_VIRT* pu32Addr, MS_U32* pu32BufSize, MS_U32 u32Flag)
1664 {
1665 MsOS_SHM_Context* pContext = NULL;
1666 MsOS_SHM_Context* pClient = NULL;
1667 MS_U32 i;
1668 MS_U32 u32CopyLen;
1669
1670 if (!_pu8ShareMem)
1671 {
1672 printf("[%s][%d] MsOS_SHM_Init should be invoked first\n", __FUNCTION__, __LINE__);
1673 return FALSE;
1674 }
1675
1676 memcpy(&_ShmHdr, _pu8ShareMem, sizeof(_ShmHdr));
1677 pContext = (MsOS_SHM_Context*)_ShmHdr.context;
1678 for (i= 0; i< MAX_CLIENT_NUM; i++, pContext++)
1679 {
1680 if (0 == pContext->u8ClientId)
1681 {
1682 continue;
1683 }
1684 if (0== strcmp((const char*)pContext->u8ClientName, (const char*)pu8ClientName))
1685 {
1686 pClient = pContext;
1687 if (u32BufSize != pClient->u32Size)
1688 {
1689 printf("[%s][%d] MsOS_SHM_GetId: inconsistent buffer size with other process\n", __FUNCTION__, __LINE__);
1690 }
1691 break;
1692 }
1693 }
1694 if ((NULL == pClient) && (MSOS_SHM_CREATE == u32Flag))
1695 {
1696 pContext = (MsOS_SHM_Context*)_ShmHdr.context;
1697 for (i= 0; i< MAX_CLIENT_NUM; i++, pContext++)
1698 {
1699 if (pContext->u8ClientId)
1700 {
1701 continue;
1702 }
1703 if ((_ShmHdr.u32Offset + u32BufSize)> _ShmHdr.u32ShmSize)
1704 {
1705 printf("[%s][%d] MsOS_SHM_GetId: shared memory buffer overflow\n", __FUNCTION__, __LINE__);
1706 return FALSE;
1707 }
1708 _ShmHdr.u32ClientNum++;
1709 pClient = pContext;
1710 u32CopyLen = MIN((int)strlen((const char*)pu8ClientName), MAX_CLIENT_NAME_LENGTH);
1711 strncpy((char*)pClient->u8ClientName, (const char*)pu8ClientName, u32CopyLen);
1712 pClient->u32Size = u32BufSize;
1713 pClient->u8ClientId = i + 1;
1714 pClient->u8RefCnt = 0;
1715 pClient->u32Offset = _ShmHdr.u32Offset;
1716 _ShmHdr.u32Offset += (u32BufSize+7)&~7;
1717 memcpy(_pu8ShareMem, &_ShmHdr, sizeof(_ShmHdr));
1718 break;
1719 }
1720 }
1721 if (NULL == pClient)
1722 {
1723 if(MSOS_SHM_QUERY != u32Flag)
1724 {
1725 printf("[%s][%d] MsOS_SHM_Init: Unable to get available share memeory\n", __FUNCTION__, __LINE__);
1726 }
1727 else
1728 {
1729 //printf("[%s][%d] MsOS_SHM_Init: Unable to query share memeory[%s]\n", __FUNCTION__, __LINE__, (char *)pu8ClientName);
1730 }
1731 return FALSE;
1732 }
1733
1734 *pu32ShmId = pClient->u8ClientId;
1735 *pu32BufSize = pClient->u32Size;
1736 *pu32Addr = (MS_VIRT)_pu8ShareMem + pClient->u32Offset;
1737 return TRUE;
1738 }
1739
1740 //-------------------------------------------------------------------------------------------------
1741 /// Disable the CPU interrupt
1742 /// @return Interrupt register value before all interrupts disable
1743 //-------------------------------------------------------------------------------------------------
MsOS_CPU_DisableInterrupt(void)1744 MS_U32 MsOS_CPU_DisableInterrupt (void)
1745 {
1746 return mhal_interrupt_disable();
1747 }
1748
1749 //-------------------------------------------------------------------------------------------------
1750 /// Enable the CPU interrupt
1751 /// @return TRUE : succeed
1752 //-------------------------------------------------------------------------------------------------
MsOS_CPU_EnableInterrupt(void)1753 MS_BOOL MsOS_CPU_EnableInterrupt (void)
1754 {
1755 mhal_interrupt_enable();
1756 return TRUE;
1757 }
1758
1759 //-------------------------------------------------------------------------------------------------
1760 /// Restore the CPU interrupt from last MsOS_CPU_DisableInterrupts.
1761 /// @param u32OldInterrupts \b IN: Interrupt register value from @ref MsOS_CPU_DisableInterrupts
1762 /// @return TRUE : succeed
1763 //-------------------------------------------------------------------------------------------------
MsOS_CPU_RestoreInterrupt(MS_U32 u32OldInterrupts)1764 MS_BOOL MsOS_CPU_RestoreInterrupt (MS_U32 u32OldInterrupts)
1765 {
1766 mhal_interrupt_restore(u32OldInterrupts);
1767 return TRUE;
1768 }
1769
1770 //-------------------------------------------------------------------------------------------------
1771 /// Mask all the CPU interrupt
1772 /// @return TRUE : succeed
1773 //-------------------------------------------------------------------------------------------------
MsOS_CPU_MaskAllInterrupt(void)1774 MS_BOOL MsOS_CPU_MaskAllInterrupt (void)
1775 {
1776 mhal_interrupt_mask_all();
1777 return TRUE;
1778 }
1779
1780 //-------------------------------------------------------------------------------------------------
1781 /// Mask the CPU interrupt
1782 /// @param intr_num \b IN: Interrupt number in enumerator MHAL_INTERRUPT_TYPE
1783 /// @return TRUE : succeed
1784 //-------------------------------------------------------------------------------------------------
MsOS_CPU_MaskInterrupt(MHAL_INTERRUPT_TYPE intr_num)1785 MS_BOOL MsOS_CPU_MaskInterrupt (MHAL_INTERRUPT_TYPE intr_num)
1786 {
1787 mhal_interrupt_mask(intr_num);
1788 return TRUE;
1789 }
1790
1791 //-------------------------------------------------------------------------------------------------
1792 /// UnMask the CPU interrupt
1793 /// @param intr_num \b IN: Interrupt number in enumerator MHAL_INTERRUPT_TYPE
1794 /// @return TRUE : succeed
1795 //-------------------------------------------------------------------------------------------------
MsOS_CPU_UnMaskInterrupt(MHAL_INTERRUPT_TYPE intr_num)1796 MS_BOOL MsOS_CPU_UnMaskInterrupt (MHAL_INTERRUPT_TYPE intr_num)
1797 {
1798 mhal_interrupt_unmask(intr_num);
1799 return TRUE;
1800 }
1801
1802 //-------------------------------------------------------------------------------------------------
1803 /// Lock the CPU interrupt
1804 /// @return TRUE : succeed
1805 //-------------------------------------------------------------------------------------------------
MsOS_CPU_LockInterrupt(void)1806 MS_BOOL MsOS_CPU_LockInterrupt (void)
1807 {
1808 mhal_interrupt_lock();
1809 return TRUE;
1810 }
1811
1812 //-------------------------------------------------------------------------------------------------
1813 /// UnLock the CPU interrupt
1814 /// @return TRUE : succeed
1815 //-------------------------------------------------------------------------------------------------
MsOS_CPU_UnLockInterrupt(void)1816 MS_BOOL MsOS_CPU_UnLockInterrupt (void)
1817 {
1818 mhal_interrupt_unlock();
1819 return TRUE;
1820 }
1821
1822 //-------------------------------------------------------------------------------------------------
1823 /// Attach the CPU interrupt callback function to interrupt #
1824 /// @param eIntNum \b IN: Interrupt number in enumerator InterruptNum
1825 /// @param pIntCb \b IN: Interrupt callback function
1826 /// @param dat \b IN: Data
1827 /// @return TRUE : succeed
1828 //-------------------------------------------------------------------------------------------------
MsOS_CPU_AttachInterrupt(MHAL_INTERRUPT_TYPE intr_num,mhal_isr_t isr,MS_U32 dat)1829 MS_BOOL MsOS_CPU_AttachInterrupt (MHAL_INTERRUPT_TYPE intr_num, mhal_isr_t isr, MS_U32 dat)
1830 {
1831 mhal_interrupt_attach(intr_num, isr, dat);
1832 return TRUE;
1833 }
1834
1835 //-------------------------------------------------------------------------------------------------
1836 /// Detach the CPU interrupt callback function to interrupt #
1837 /// @param eIntNum \b IN: Interrupt number in enumerator InterruptNum
1838 /// @param pIntCb \b IN: Interrupt callback function
1839 /// @param dat \b IN: Data
1840 /// @return TRUE : succeed
1841 //-------------------------------------------------------------------------------------------------
MsOS_CPU_DetachInterrupt(MHAL_INTERRUPT_TYPE intr_num)1842 MS_BOOL MsOS_CPU_DetachInterrupt (MHAL_INTERRUPT_TYPE intr_num)
1843 {
1844 mhal_interrupt_detach(intr_num);
1845 return TRUE;
1846 }
1847
1848 //-------------------------------------------------------------------------------------------------
1849 /// Attach the CPU exception callback function to interrupt #
1850 /// @param eIntNum \b IN: Exception number in enumerator InterruptNum
1851 /// @param pIntCb \b IN: Exception callback function
1852 /// @param dat \b IN: Data
1853 /// @return TRUE : succeed
1854 //-------------------------------------------------------------------------------------------------
MsOS_CPU_AttachException(MHAL_EXCEPTION_TYPE expt_num,mhal_isr_t isr,MS_U32 dat)1855 MS_BOOL MsOS_CPU_AttachException (MHAL_EXCEPTION_TYPE expt_num, mhal_isr_t isr, MS_U32 dat)
1856 {
1857 mhal_exception_attach(expt_num, isr, dat);
1858 return TRUE;
1859 }
1860
1861 //-------------------------------------------------------------------------------------------------
1862 /// Detach the CPU exception callback function to interrupt #
1863 /// @param eIntNum \b IN: Exception number in enumerator InterruptNum
1864 /// @param pIntCb \b IN: Exception callback function
1865 /// @param dat \b IN: Data
1866 /// @return TRUE : succeed
1867 //-------------------------------------------------------------------------------------------------
MsOS_CPU_DetachExceptiont(MHAL_EXCEPTION_TYPE expt_num)1868 MS_BOOL MsOS_CPU_DetachExceptiont (MHAL_EXCEPTION_TYPE expt_num)
1869 {
1870 mhal_exception_detach(expt_num);
1871 return TRUE;
1872 }
1873 //-------------------------------------------------------------------------------------------------
1874 /// Set EBASE
1875 /// @param u32Addr \b IN: MIPS Code Start Address
1876 /// @return TRUE : succeed
1877 //-------------------------------------------------------------------------------------------------
MsOS_CPU_SetEBASE(MS_U32 u32Addr)1878 MS_BOOL MsOS_CPU_SetEBASE (MS_U32 u32Addr)
1879 {
1880 MAsm_CPU_SetEBASE(u32Addr);
1881 return TRUE;
1882 }
1883 //-------------------------------------------------------------------------------------------------
1884 /// Sync data in EC-Brigde
1885 /// @return TRUE : succeed
1886 /// @return FALSE : fail
1887 //-------------------------------------------------------------------------------------------------
MsOS_Sync(void)1888 void MsOS_Sync(void)
1889 {
1890 MAsm_CPU_Sync();
1891 }
1892
1893
MsOS_FlushMemory(void)1894 void MsOS_FlushMemory(void)
1895 {
1896 HAL_MMIO_FlushMemory();
1897 }
1898
MsOS_ReadMemory(void)1899 void MsOS_ReadMemory(void)
1900 {
1901 HAL_MMIO_ReadMemory();
1902 }
1903
MsOS_GetKattribute(char * pAttr)1904 MS_U32 MsOS_GetKattribute(char *pAttr)
1905 {
1906 //This is for linux feature only, do nothing here;
1907 return 0;
1908 }
1909 // #endif
1910