1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_MemoryUtil.cpp
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #include "precompiled.h"
19 
20 #include <nw/gfx/gfx_MemoryUtil.h>
21 
22 namespace nw
23 {
24 namespace gfx
25 {
26 namespace internal
27 {
28 
29 #include <nn/hw/ARM/code32.h>
30 
31 asm void
copy_asm_declarations()32 copy_asm_declarations()
33 {
34     MACRO
35     COPY8WORD
36     LDM r1!,{r2-r5}
37     PLD [r1, #0x40]
38     LDM r1!,{r9-r12}
39     STM r0!,{r2-r5}
40     STM r0!,{r9-r12}
41     MEND
42 
43     MACRO
44     COPY6WORD
45     LDM r1!,{r2-r5}
46     LDM r1!,{r11-r12}
47     STM r0!,{r2-r5}
48     STM r0!,{r11-r12}
49     MEND
50 
51     MACRO
52     COPY4WORD
53     LDM r1!,{r2-r3}
54     LDM r1!,{r11-r12}
55     STM r0!,{r2-r3}
56     STM r0!,{r11-r12}
57     MEND
58 
59     MACRO
60     COPY2WORD
61     LDM r1!,{r2}
62     LDM r1!,{r3}
63     STM r0!,{r2}
64     STM r0!,{r3}
65     MEND
66 
67     MACRO
68     COPYNWORD $val
69     PUSH {r4-r5,r9-r11}
70 
71     LCLA count
72 count SETA $val
73     WHILE count >= 8
74 count SETA count-8
75     COPY8WORD
76     WEND
77 
78     IF count == 2
79         COPY2WORD
80     ELSE
81       IF count == 4
82           COPY4WORD
83       ELSE
84           IF count == 6
85               COPY6WORD
86           ENDIF
87       ENDIF
88     ENDIF
89 
90     POP {r4-r5,r9-r11}
91     BX          lr
92     MEND
93 }
94 
95 #define DECL_SUB(size) \
96 asm u32* FastWordCopyAsm_##size(u32* /*dst*/, u32* /*src*/) \
97 { \
98     COPYNWORD size \
99 }
100 
101 DECL_SUB(2)
102 DECL_SUB(4)
103 DECL_SUB(6)
104 DECL_SUB(8)
105 DECL_SUB(10)
106 DECL_SUB(12)
107 DECL_SUB(14)
108 DECL_SUB(16)
109 DECL_SUB(18)
110 DECL_SUB(20)
111 DECL_SUB(22)
112 DECL_SUB(24)
113 DECL_SUB(26)
114 DECL_SUB(28)
115 DECL_SUB(30)
116 DECL_SUB(32)
117 DECL_SUB(34)
118 DECL_SUB(36)
119 DECL_SUB(38)
120 DECL_SUB(78)
121 
122 #undef DECL_SUB
123 
124 #include <nn/hw/ARM/codereset.h>
125 
126 } // namespace internal
127 } // namespace gfx
128 } // namespace nw
129