1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - MI
3 File: mi_byteAccess.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 #include <nitro/misc.h>
19 #include <nitro/mi/byteAccess.h>
20
21 /*---------------------------------------------------------------------------*
22 Name: MI_ReadByte
23
24 Description: read bytedata
25
26 Arguments: address ... address to read bytedata
27
28 Returns: byte data
29 *---------------------------------------------------------------------------*/
30 #ifdef SDK_TEG
MI_ReadByte(const void * address)31 u8 MI_ReadByte(const void *address)
32 {
33 if ((u32)address & 1)
34 {
35 return (u8)(*(u16 *)((u32)address & ~1) >> 8);
36 }
37 else
38 {
39 return (u8)(*(u16 *)address & 0xff);
40 }
41 }
42 #endif
43
44 /*---------------------------------------------------------------------------*
45 Name: MI_WriteByte
46
47 Description: write bytedata
48
49 Arguments: address ... address to write bytedata
50
51 Returns: None.
52 *---------------------------------------------------------------------------*/
53 #ifdef SDK_TEG
MI_WriteByte(void * address,u8 value)54 void MI_WriteByte(void *address, u8 value)
55 {
56 u16 val = *(u16 *)((u32)address & ~1);
57
58 if ((u32)address & 1)
59 {
60 *(u16 *)((u32)address & ~1) = (u16)(((value & 0xff) << 8) | (val & 0xff));
61 }
62 else
63 {
64 *(u16 *)((u32)address & ~1) = (u16)((val & 0xff00) | (value & 0xff));
65 }
66 }
67 #endif
68