1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_MemoryUtil.cpp
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  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   $Revision: 23207 $
14  *---------------------------------------------------------------------------*/
15 
16 #include "precompiled.h"
17 
18 #include <nw/gfx/gfx_MemoryUtil.h>
19 
20 namespace nw
21 {
22 namespace gfx
23 {
24 namespace internal
25 {
26 
27 #include <nn/hw/ARM/code32.h>
28 
29 asm void
copy_asm_declarations()30 copy_asm_declarations()
31 {
32     MACRO
33     COPY8WORD
34     LDM r1!,{r2-r5}
35     PLD [r1, #0x40]
36     LDM r1!,{r9-r12}
37     STM r0!,{r2-r5}
38     STM r0!,{r9-r12}
39     MEND
40 
41     MACRO
42     COPY6WORD
43     LDM r1!,{r2-r5}
44     LDM r1!,{r11-r12}
45     STM r0!,{r2-r5}
46     STM r0!,{r11-r12}
47     MEND
48 
49     MACRO
50     COPY4WORD
51     LDM r1!,{r2-r3}
52     LDM r1!,{r11-r12}
53     STM r0!,{r2-r3}
54     STM r0!,{r11-r12}
55     MEND
56 
57     MACRO
58     COPY2WORD
59     LDM r1!,{r2}
60     LDM r1!,{r3}
61     STM r0!,{r2}
62     STM r0!,{r3}
63     MEND
64 
65     MACRO
66     COPYNWORD $val
67     PUSH {r4-r5,r9-r11}
68 
69     LCLA count
70 count SETA $val
71     WHILE count >= 8
72 count SETA count-8
73     COPY8WORD
74     WEND
75 
76     IF count == 2
77         COPY2WORD
78     ELSE
79       IF count == 4
80           COPY4WORD
81       ELSE
82           IF count == 6
83               COPY6WORD
84           ENDIF
85       ENDIF
86     ENDIF
87 
88     POP {r4-r5,r9-r11}
89     BX          lr
90     MEND
91 }
92 
93 #define DECL_SUB(size) \
94 asm u32* FastWordCopyAsm_##size(u32* /*dst*/, u32* /*src*/) \
95 { \
96     COPYNWORD size \
97 }
98 
99 DECL_SUB(2)
100 DECL_SUB(4)
101 DECL_SUB(6)
102 DECL_SUB(8)
103 DECL_SUB(10)
104 DECL_SUB(12)
105 DECL_SUB(14)
106 DECL_SUB(16)
107 DECL_SUB(18)
108 DECL_SUB(20)
109 DECL_SUB(22)
110 DECL_SUB(24)
111 DECL_SUB(26)
112 DECL_SUB(28)
113 DECL_SUB(30)
114 DECL_SUB(32)
115 DECL_SUB(34)
116 DECL_SUB(36)
117 DECL_SUB(38)
118 DECL_SUB(78)
119 
120 #undef DECL_SUB
121 
122 #include <nn/hw/ARM/codereset.h>
123 
124 } // namespace internal
125 } // namespace gfx
126 } // namespace nw
127