1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - MI - include
3 File: memory.h
4
5 Copyright 2003-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2008-09-17#$
14 $Rev: 8556 $
15 $Author: okubata_ryoma $
16
17 *---------------------------------------------------------------------------*/
18
19 #ifndef NITRO_MI_MEMORY_H_
20 #define NITRO_MI_MEMORY_H_
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #include <nitro/misc.h>
27 #include <nitro/types.h>
28
29
30 //======================================================================
31 void MIi_CpuClear16(u16 data, void *destp, u32 size);
32 void MIi_CpuCopy16(const void *srcp, void *destp, u32 size);
33 void MIi_CpuSend16(const void *srcp, volatile void *destp, u32 size);
34 void MIi_CpuRecv16(volatile const void *srcp, void *destp, u32 size);
35 void MIi_CpuPipe16(volatile const void *srcp, volatile void *destp, u32 size);
36 void MIi_CpuMove16(const void *src, void *dest, u32 size);
37 void* MIi_CpuFind16(const void *src, u16 data, u32 size);
38 int MIi_CpuComp16(const void *mem1, const void *mem2, u32 size);
39
40 void MIi_CpuClear32(u32 data, void *destp, u32 size);
41 void MIi_CpuCopy32(const void *srcp, void *destp, u32 size);
42 void MIi_CpuSend32(const void *srcp, volatile void *destp, u32 size);
43 void MIi_CpuRecv32(volatile const void *srcp, void *destp, u32 size);
44 void MIi_CpuPipe32(volatile const void *srcp, volatile void *destp, u32 size);
45 void MIi_CpuMove32(const void *src, void *dest, u32 size);
46 void* MIi_CpuFind32(const void *src, u32 data, u32 size);
47 int MIi_CpuComp32(const void *mem1, const void *mem2, u32 size);
48
49 void MIi_CpuClearFast(u32 data, void *destp, u32 size);
50 void MIi_CpuCopyFast(const void *srcp, void *destp, u32 size);
51 void MIi_CpuSendFast(const void *srcp, volatile void *destp, u32 size);
52 void MIi_CpuRecvFast(volatile const void *srcp, void *destp, u32 size);
53 void MIi_CpuMoveFast(const void *src, void *dest, u32 size);
54
55
56 //================================================================================
57 // 32 bit version
58 //================================================================================
59 /*---------------------------------------------------------------------------*
60 Name: MI_CpuFill32
61
62 Description: fill memory with specified data. (32 bit version)
63
64 Arguments: dest : destination address to fill data, must be in 4 byte alignment
65 data : data to fill
66 size : size (byte), must be in 4 byte alignment
67
68 Returns: None
69 *---------------------------------------------------------------------------*/
MI_CpuFill32(void * dest,u32 data,u32 size)70 static inline void MI_CpuFill32(void *dest, u32 data, u32 size)
71 {
72 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
73 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
74
75 MIi_CpuClear32(data, dest, size);
76 }
77
78 /*---------------------------------------------------------------------------*
79 Name: MI_CpuCopy32
80
81 Description: copy memory data (32 bit version)
82
83 Arguments: src : source address, must be in 4 byte alignment
84 dest : destination address, must be in 4 byte alignment
85 size : size (byte), must be in 4 byte alignment
86
87 Returns: None
88 *---------------------------------------------------------------------------*/
MI_CpuCopy32(const void * src,void * dest,u32 size)89 static inline void MI_CpuCopy32(const void *src, void *dest, u32 size)
90 {
91 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
92 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
93 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
94
95 MIi_CpuCopy32(src, dest, size);
96 }
97
98 /*---------------------------------------------------------------------------*
99 Name: MI_CpuClear32
100
101 Description: fill memory with 0 (32 bit version)
102
103 Arguments: dest : destination address, must be in 4 byte alignment
104 size : size (byte), must be in 4 byte alignment
105
106 Returns: None
107 *---------------------------------------------------------------------------*/
MI_CpuClear32(void * dest,u32 size)108 static inline void MI_CpuClear32(void *dest, u32 size)
109 {
110 MI_CpuFill32(dest, 0, size);
111 }
112
113 /*---------------------------------------------------------------------------*
114 Name: MI_CpuSend32
115
116 Description: write some data to fixed address (32 bit version)
117
118 Arguments: src : source address, must be in 4 byte alignment
119 dest : destination address, must be in 4 byte alignment
120 size : size (byte), must be in 4 byte alignment
121
122 Returns: None
123 *---------------------------------------------------------------------------*/
MI_CpuSend32(const void * src,volatile void * dest,u32 size)124 static inline void MI_CpuSend32(const void *src, volatile void *dest, u32 size)
125 {
126 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
127 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
128 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
129
130 MIi_CpuSend32(src, dest, size);
131 }
132
133 /*---------------------------------------------------------------------------*
134 Name: MI_CpuRecv32
135
136 Description: receive u32 data from fixed address
137 32bit version
138
139 Arguments: src : source address. not incremented
140 dest : data buffer to receive
141 size : size (byte)
142
143 Returns: None
144 *---------------------------------------------------------------------------*/
MI_CpuRecv32(volatile const void * src,void * dest,u32 size)145 static inline void MI_CpuRecv32(volatile const void *src, void *dest, u32 size)
146 {
147 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
148 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
149 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
150
151 MIi_CpuRecv32(src, dest, size);
152 }
153
154 /*---------------------------------------------------------------------------*
155 Name: MI_CpuPipe32
156
157 Description: pipe data from fixed address to fixed address.
158 32bit version
159
160 Arguments: src : source address. not incremented
161 dest : destination address. not incremented
162 size : size (byte)
163
164 Returns: None
165 *---------------------------------------------------------------------------*/
MI_CpuPipe32(volatile const void * src,volatile void * dest,u32 size)166 static inline void MI_CpuPipe32(volatile const void *src, volatile void *dest, u32 size)
167 {
168 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
169 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
170 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
171
172 MIi_CpuPipe32(src, dest, size);
173 }
174
175 /*---------------------------------------------------------------------------*
176 Name: MI_CpuMove32
177
178 Description: move memory data (32 bit version)
179
180 Arguments: src : source address, must be in 4 byte alignment
181 dest : destination address, must be in 4 byte alignment
182 size : size (byte), must be in 4 byte alignment
183
184 Returns: None
185 *---------------------------------------------------------------------------*/
MI_CpuMove32(const void * src,void * dest,u32 size)186 static inline void MI_CpuMove32(const void *src, void *dest, u32 size)
187 {
188 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
189 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
190 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
191
192 MIi_CpuMove32(src, dest, size);
193 }
194
195 /*---------------------------------------------------------------------------*
196 Name: MI_CpuFind32
197
198 Description: find memory data (32 bit version)
199
200 Arguments: src : source address, must be in 4 byte alignment
201 data : target data
202 size : size (byte), must be in 4 byte alignment
203
204 Returns: pointer to found data or NULL.
205 *---------------------------------------------------------------------------*/
MI_CpuFind32(const void * src,u32 data,u32 size)206 static inline void* MI_CpuFind32(const void *src, u32 data, u32 size)
207 {
208 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
209 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
210
211 return MIi_CpuFind32(src, data, size);
212 }
213
214 /*---------------------------------------------------------------------------*
215 Name: MI_CpuComp32
216
217 Description: compare memory data (32 bit version)
218
219 Arguments: mem1 : target address 1, must be in 4 byte alignment
220 mem2 : target address 2, must be in 4 byte alignment
221 size : size (byte), must be in 4 byte alignment
222
223 Returns: < 0 : mem1 smaller than mem2
224 = 0 : mem1 equals mem2
225 > 0 : mem1 larger than mem2
226 *---------------------------------------------------------------------------*/
MI_CpuComp32(const void * mem1,const void * mem2,u32 size)227 static inline int MI_CpuComp32(const void *mem1, const void *mem2, u32 size)
228 {
229 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
230 SDK_ASSERTMSG(((u32)mem1 & 3) == 0, "target address 1 must be in 4-byte alignment");
231 SDK_ASSERTMSG(((u32)mem2 & 3) == 0, "target address 2 must be in 4-byte alignment");
232
233 return MIi_CpuComp32(mem1, mem2, size);
234 }
235
236 //================================================================================
237 // 16 bit version
238 //================================================================================
239 /*---------------------------------------------------------------------------*
240 Name: MI_CpuFill16
241
242 Description: fill memory with specified data. (16 bit version)
243
244 Arguments: dest : destination address to fill data, must be in 2 byte alignment
245 data : data to fill
246 size : size (byte), must be in 2 byte alignment
247
248 Returns: None
249 *---------------------------------------------------------------------------*/
MI_CpuFill16(void * dest,u16 data,u32 size)250 static inline void MI_CpuFill16(void *dest, u16 data, u32 size)
251 {
252 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
253 SDK_ASSERTMSG(((u32)dest & 1) == 0, "source address must be in 2-byte alignment");
254
255 MIi_CpuClear16(data, dest, size);
256 }
257
258 /*---------------------------------------------------------------------------*
259 Name: MI_CpuCopy16
260
261 Description: copy memory data (16 bit version)
262
263 Arguments: src : source address, must be in 2 byte alignment
264 dest : destination address, must be in 2 byte alignment
265 size : size (byte), must be in 2 byte alignment
266
267 Returns: None
268 *---------------------------------------------------------------------------*/
MI_CpuCopy16(const void * src,void * dest,u32 size)269 static inline void MI_CpuCopy16(const void *src, void *dest, u32 size)
270 {
271 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
272 SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
273 SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
274
275 MIi_CpuCopy16(src, dest, size);
276 }
277
278 /*---------------------------------------------------------------------------*
279 Name: MI_CpuClear16
280
281 Description: fill memory with 0 (16 bit version)
282
283 Arguments: dest : destination address, must be in 2 byte alignment
284 size : size (byte), must be in 2 byte alignment
285
286 Returns: None
287 *---------------------------------------------------------------------------*/
MI_CpuClear16(void * dest,u32 size)288 static inline void MI_CpuClear16(void *dest, u32 size)
289 {
290 MI_CpuFill16(dest, 0, size);
291 }
292
293 /*---------------------------------------------------------------------------*
294 Name: MI_CpuSend16
295
296 Description: write some data to fixed address (16 bit version)
297
298 Arguments: src : source address, must be in 2 byte alignment
299 dest : destination address, must be in 4 byte alignment
300 size : size (byte), must be in 2 byte alignment
301
302 Returns: None
303 *---------------------------------------------------------------------------*/
MI_CpuSend16(const void * src,volatile void * dest,u32 size)304 static inline void MI_CpuSend16(const void *src, volatile void *dest, u32 size)
305 {
306 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
307 SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
308 SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
309
310 MIi_CpuSend16(src, dest, size);
311 }
312
313 /*---------------------------------------------------------------------------*
314 Name: MI_CpuRecv16
315
316 Description: receive u16 data from fixed address
317 16bit version
318
319 Arguments: src : source address. not incremented
320 dest : data buffer to receive
321 size : size (byte)
322
323 Returns: None
324 *---------------------------------------------------------------------------*/
MI_CpuRecv16(volatile const void * src,void * dest,u32 size)325 static inline void MI_CpuRecv16(volatile const void *src, void *dest, u32 size)
326 {
327 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
328 SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
329 SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
330
331 MIi_CpuRecv16(src, dest, size);
332 }
333
334 /*---------------------------------------------------------------------------*
335 Name: MI_CpuRecv16
336
337 Description: pipe data from fixed address to fixed address.
338 16bit version
339
340 Arguments: src : source address. not incremented
341 dest : destination address. not incremented
342 size : size (byte)
343
344 Returns: None
345 *---------------------------------------------------------------------------*/
MI_CpuPipe16(volatile const void * src,volatile void * dest,u32 size)346 static inline void MI_CpuPipe16(volatile const void *src, volatile void *dest, u32 size)
347 {
348 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
349 SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
350 SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
351
352 MIi_CpuPipe16(src, dest, size);
353 }
354
355 /*---------------------------------------------------------------------------*
356 Name: MI_CpuMove16
357
358 Description: move memory data (16 bit version)
359
360 Arguments: src : source address, must be in 2 byte alignment
361 dest : destination address, must be in 2 byte alignment
362 size : size (byte), must be in 2 byte alignment
363
364 Returns: None
365 *---------------------------------------------------------------------------*/
MI_CpuMove16(const void * src,void * dest,u32 size)366 static inline void MI_CpuMove16(const void *src, void *dest, u32 size)
367 {
368 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
369 SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
370 SDK_ASSERTMSG(((u32)dest & 1) == 0, "destination address must be in 2-byte alignment");
371
372 MIi_CpuMove16(src, dest, size);
373 }
374
375 /*---------------------------------------------------------------------------*
376 Name: MI_CpuFind16
377
378 Description: find memory data (16 bit version)
379
380 Arguments: src : source address, must be in 2 byte alignment
381 data : target data
382 size : size (byte), must be in 2 byte alignment
383
384 Returns: pointer to found data or NULL.
385 *---------------------------------------------------------------------------*/
MI_CpuFind16(const void * src,u16 data,u32 size)386 static inline void* MI_CpuFind16(const void *src, u16 data, u32 size)
387 {
388 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
389 SDK_ASSERTMSG(((u32)src & 1) == 0, "source address must be in 2-byte alignment");
390
391 return MIi_CpuFind16(src, data, size);
392 }
393
394 /*---------------------------------------------------------------------------*
395 Name: MI_CpuComp16
396
397 Description: compare memory data (16 bit version)
398
399 Arguments: mem1 : target address 1, must be in 2 byte alignment
400 mem2 : target address 2, must be in 2 byte alignment
401 size : size (byte), must be in 2 byte alignment
402
403 Returns: < 0 : mem1 smaller than mem2
404 = 0 : mem1 equals mem2
405 > 0 : mem1 larger than mem2
406 *---------------------------------------------------------------------------*/
MI_CpuComp16(const void * mem1,const void * mem2,u32 size)407 static inline int MI_CpuComp16(const void *mem1, const void *mem2, u32 size)
408 {
409 SDK_ASSERTMSG((size & 1) == 0, "size & 1 must be 0");
410 SDK_ASSERTMSG(((u32)mem1 & 1) == 0, "target address 1 must be in 2-byte alignment");
411 SDK_ASSERTMSG(((u32)mem2 & 1) == 0, "target address 2 must be in 2-byte alignment");
412
413 return MIi_CpuComp16(mem1, mem2, size);
414 }
415
416 //================================================================================
417 // 32 byte unit version
418 //================================================================================
419 /*---------------------------------------------------------------------------*
420 Name: MI_CpuFillFast
421
422 Description: fill memory with specified data quickly. (32 byte unit version)
423
424 Arguments: dest : destination address to fill data
425 data : data to fill
426 size : size (byte), must be in 4 byte alignment
427
428 Returns: None
429 *---------------------------------------------------------------------------*/
MI_CpuFillFast(void * dest,u32 data,u32 size)430 static inline void MI_CpuFillFast(void *dest, u32 data, u32 size)
431 {
432 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
433 SDK_ASSERTMSG(((u32)dest & 3) == 0, "source address must be in 4-byte alignment");
434
435 MIi_CpuClearFast(data, dest, size);
436 }
437
438 /*---------------------------------------------------------------------------*
439 Name: MI_CpuCopyFast
440
441 Description: copy memory data quickly (32 byte unit version)
442
443 Arguments: src : source address, must be in 4 byte alignment
444 dest : destination address, must be in 4 byte alignment
445 size : size (byte), must be in 4 byte alignment
446
447 Returns: None
448 *---------------------------------------------------------------------------*/
MI_CpuCopyFast(const void * src,void * dest,u32 size)449 static inline void MI_CpuCopyFast(const void *src, void *dest, u32 size)
450 {
451 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
452 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
453 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
454
455 MIi_CpuCopyFast(src, dest, size);
456 }
457
458 /*---------------------------------------------------------------------------*
459 Name: MI_CpuClearFast
460
461 Description: fill memory with 0 quickly (32 byte unit version)
462
463 Arguments: dest : destination address, must be in 4 byte alignment
464 size : size (byte), must be in 4-byte alignment
465
466 Returns: None
467 *---------------------------------------------------------------------------*/
MI_CpuClearFast(void * dest,u32 size)468 static inline void MI_CpuClearFast(void *dest, u32 size)
469 {
470 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
471 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
472
473 MI_CpuFillFast(dest, 0, size);
474 }
475 /*---------------------------------------------------------------------------*
476 Name: MI_CpuSendFast
477
478 Description: move memory data (32 byte unit version)
479
480 Arguments: src : data stream to send
481 dest : destination address, not incremented
482 size : size (byte)
483
484 Returns: None
485 *---------------------------------------------------------------------------*/
MI_CpuSendFast(register const void * src,register volatile void * dest,register u32 size)486 static inline void MI_CpuSendFast( register const void *src, register volatile void *dest, register u32 size )
487 {
488 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
489 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
490 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
491
492 MIi_CpuSendFast(src, dest, size);
493 }
494
495 /*---------------------------------------------------------------------------*
496 Name: MI_CpuRecvFast
497
498 Description: move memory data (32 byte unit version)
499
500 Arguments: src : source address. not incremented
501 dest : data buffer to receive
502 size : size (byte)
503
504 Returns: None
505 *---------------------------------------------------------------------------*/
MI_CpuRecvFast(volatile const void * src,register void * dest,register u32 size)506 static inline void MI_CpuRecvFast(volatile const void *src, register void *dest, register u32 size)
507 {
508 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
509 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
510 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
511
512 MIi_CpuRecvFast(src, dest, size);
513 }
514
515 /*---------------------------------------------------------------------------*
516 Name: MI_CpuMoveFast
517
518 Description: move memory data (32 byte unit version)
519
520 Arguments: src : source address, must be in 4 byte alignment
521 dest : destination address, must be in 4 byte alignment
522 size : size (byte), must be in 4 byte alignment
523
524 Returns: None
525 *---------------------------------------------------------------------------*/
MI_CpuMoveFast(const void * src,void * dest,u32 size)526 static inline void MI_CpuMoveFast(const void *src, void *dest, u32 size)
527 {
528 SDK_ASSERTMSG((size & 3) == 0, "size & 3 must be 0");
529 SDK_ASSERTMSG(((u32)src & 3) == 0, "source address must be in 4-byte alignment");
530 SDK_ASSERTMSG(((u32)dest & 3) == 0, "destination address must be in 4-byte alignment");
531
532 MIi_CpuMoveFast(src, dest, size);
533 }
534
535
536 //================================================================================
537 // 8 bit version
538 //================================================================================
539 /*---------------------------------------------------------------------------*
540 Name: MI_CpuFill8
541
542 Description: fill memory with specified data. (8 bit version)
543
544 Arguments: dest : destination address to fill data, no limitation for alignment
545 data : data to fill
546 size : size (byte), no limitation for alignment
547
548 Returns: None
549 *---------------------------------------------------------------------------*/
550 void MI_CpuFill8(void *dest, u8 data, u32 size);
551
552 /*---------------------------------------------------------------------------*
553 Name: MI_CpuCopy8
554
555 Description: copy memory data (8 bit version)
556
557 Arguments: src : source address, no limitation for alignment
558 dest : destination address, no limitation for alignment
559 size : size (byte), no limitation for alignment
560
561 Returns: None
562 *---------------------------------------------------------------------------*/
563 void MI_CpuCopy8(const void *src, void *dest, u32 size);
564
565 /*---------------------------------------------------------------------------*
566 Name: MI_CpuFind8
567
568 Description: find memory data (8 bit version)
569
570 Arguments: src : source address, no limitation for alignment
571 data : target data
572 size : size (byte), no limitation for alignment
573
574 Returns: pointer to found data or NULL.
575 *---------------------------------------------------------------------------*/
576 void* MI_CpuFind8(const void *src, u8 data, u32 size);
577
578 /*---------------------------------------------------------------------------*
579 Name: MI_CpuComp8
580
581 Description: compare memory data (8 bit version)
582
583 Arguments: mem1 : target address 1, no limitation for alignment
584 mem2 : target address 2, no limitation for alignment
585 size : size (byte), no limitation for alignment
586
587 Returns: < 0 : mem1 smaller than mem2
588 = 0 : mem1 equals mem2
589 > 0 : mem1 larger than mem2
590 *---------------------------------------------------------------------------*/
591 int MI_CpuComp8(const void *mem1, const void *mem2, u32 size);
592
593 /*---------------------------------------------------------------------------*
594 Name: MI_CpuClear8
595
596 Description: fill memory with 0 (8 bit version)
597
598 Arguments: dest : destination address, no limitation for alignment
599 size : size (byte), no limitation for alignment
600
601 Returns: None
602 *---------------------------------------------------------------------------*/
MI_CpuClear8(void * dest,u32 size)603 static inline void MI_CpuClear8(void *dest, u32 size)
604 {
605 MI_CpuFill8(dest, 0, size);
606 }
607
608 //================================================================================
609 // 32 bit version
610 //================================================================================
611 /*---------------------------------------------------------------------------*
612 Name: MI_ReadWord
613
614 Description: read 32 bit data from specified address
615
616 Arguments: adrs : address to read
617
618 Returns: data which is read
619 *---------------------------------------------------------------------------*/
620 #ifndef SDK_ASM
621 #define MI_ReadWord( adrs ) (*(vu32 *)(adrs))
622 #endif
623
624 /*---------------------------------------------------------------------------*
625 Name: MI_WriteWord
626
627 Description: write 32 bit data to specified adress
628
629 Arguments: adrs : address to write
630 val : data to write
631
632 Returns: None
633 *---------------------------------------------------------------------------*/
634 #ifndef SDK_ASM
635 #define MI_WriteWord( adrs, val ) do { (*(vu32 *)(adrs)) = (u32)(val); } while(0)
636 #endif
637
638
639 //================================================================================
640 // mixed version
641 //================================================================================
642
643 /*---------------------------------------------------------------------------*
644 Name: MI_CpuFill
645
646 Description: fill memory with specified data. (mixed version)
647
648 Arguments: dest : destination address to fill data, no limitation for alignment
649 data : data to fill
650 size : size (byte), no limitation for alignment
651
652 Returns: None
653 *---------------------------------------------------------------------------*/
654 void MI_CpuFill(void *dest, u8 data, u32 size);
655
656 /*---------------------------------------------------------------------------*
657 Name: MI_CpuCopy
658
659 Description: copy memory data (mixed version)
660
661 Arguments: src : source address, no limitation for alignment
662 dest : destination address, no limitation for alignment
663 size : size (byte), no limitation for alignment
664
665 Returns: None
666 *---------------------------------------------------------------------------*/
667 void MI_CpuCopy(const void *srcp, void *destp, u32 size);
668
669 /*---------------------------------------------------------------------------*
670 Name: MI_CpuMove
671
672 Description: move memory data (mixed version)
673
674 Arguments: src : source address, must be in 4 byte alignment
675 dest : destination address, must be in 4 byte alignment
676 size : size (byte), must be in 4 byte alignment
677
678 Returns: None
679 *---------------------------------------------------------------------------*/
680 void MI_CpuMove(const void *srcp, void *destp, u32 size);
681
682 /*---------------------------------------------------------------------------*
683 Name: MI_CpuClear
684
685 Description: fill memory with 0 (mixed version)
686
687 Arguments: dest : destination address, no limitation for alignment
688 size : size (byte), no limitation for alignment
689
690 Returns: None
691 *---------------------------------------------------------------------------*/
MI_CpuClear(void * dest,u32 size)692 static inline void MI_CpuClear(void *dest, u32 size)
693 {
694 MI_CpuFill(dest, 0, size);
695 }
696
697 //================================================================================
698 // the following functions are prepared for SDK private use.
699 // don't use in application thoughtlessly
700 //================================================================================
701 void MI_Copy16B(register const void *pSrc, register void *pDest);
702 void MI_Copy32B(register const void *pSrc, register void *pDest);
703 void MI_Copy36B(register const void *pSrc, register void *pDest);
704 void MI_Copy48B(register const void *pSrc, register void *pDest);
705 void MI_Copy64B(register const void *pSrc, register void *pDest);
706 void MI_Copy128B(register const void *pSrc, register void *pDest);
707
708 void MI_Zero32B(register void *pDest);
709 void MI_Zero36B(register void *pDest);
710 void MI_Zero48B(register void *pDest);
711 void MI_Zero64B(register void *pDest);
712
713 #ifdef __cplusplus
714 } /* extern "C" */
715 #endif
716
717 /* NITRO_MI_MEMORY_H_ */
718 #endif
719