1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - MI
3 File: mi_swap.c
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-18#$
14 $Rev: 8573 $
15 $Author: okubata_ryoma $
16
17 *---------------------------------------------------------------------------*/
18
19 #include <nitro/types.h>
20 #include <nitro/mi/swap.h>
21
22
23 // MI_Swap* will be used for control common resource exclusively among processers
24 // or modules. Beside, it's used for realization spin lock system.
25 //
26 // notice: you cannot access main memory by byte unless via cache.
27 // so, use MI_SwapWord generally for accessing main memory ,not MI_SwapByte.
28
29
30 //---- This code will be compiled in ARM-Mode
31 #include <nitro/code32.h>
32
33 /*---------------------------------------------------------------------------*
34 Name: MI_SwapWord
35
36 Description: swap data and memory
37
38 Arguments: setData data to swap
39 destp memory address to swap
40
41 Returns: swapped memory data
42 *---------------------------------------------------------------------------*/
MI_SwapWord(register u32 setData,register vu32 * destp)43 asm u32 MI_SwapWord( register u32 setData, register vu32* destp )
44 {
45 swp r0, r0, [r1]
46 bx lr
47 }
48
49 /*---------------------------------------------------------------------------*
50 Name: MI_SwapByte
51
52 Description: swap data and memory
53
54 Arguments: setData data to swap
55 destp memory address to swap
56
57 Returns: swapped memory data
58 *---------------------------------------------------------------------------*/
MI_SwapByte(register u32 setData,register vu8 * destp)59 asm u8 MI_SwapByte( register u32 setData, register vu8* destp )
60 {
61 swpb r0, r0, [r1]
62 bx lr
63 }
64
65 //---- end limitation of ARM-Mode
66 #include <nitro/codereset.h>
67