crtgbaxport2.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright (C) 2004 by egnite Software GmbH. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. *
  32. */
  33. /*
  34. * $Log$
  35. * Revision 1.3 2005/07/26 16:19:40 haraldkipp
  36. * Run Nut/OS in user mode.
  37. *
  38. * Revision 1.2 2004/11/08 18:10:45 haraldkipp
  39. * Interrupt handling removed.
  40. *
  41. * Revision 1.1 2004/10/17 15:14:21 haraldkipp
  42. * Added Nintendo Game Boy Advance with Xport 2.0 from Charmed Labs.
  43. *
  44. */
  45. .section .text,"ax"
  46. .global _reset
  47. _reset:
  48. /*
  49. * Nintendo ROM Header
  50. */
  51. rom_header:
  52. b rom_header_end
  53. /*
  54. * 156 bytes compressed bitmap of Nintendo logo. The BIOS
  55. * will compare this with an internal copy and lock the
  56. * GBA if they differ.
  57. */
  58. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x04..0x0F */
  59. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x10..0x1F */
  60. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x20..0x2F */
  61. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x30..0x3F */
  62. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x40..0x4F */
  63. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x50..0x5F */
  64. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x60..0x6F */
  65. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x70..0x7F */
  66. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x80..0x8F */
  67. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0x90..0x9B */
  68. .byte 0 /* If bits 2 and 7 are set, enables BIOS FIQ/Undef handler. */
  69. .byte 0 /* Bits 0 and 1 are used for the cartridge key. */
  70. .byte 0
  71. .byte 0
  72. /* Game title, 12 uppercase characters. */
  73. .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  74. /* 4 characters game code. */
  75. .byte 0, 0, 0, 0x00
  76. /* 2 characters maker code, "01" for Nintendo. */
  77. .byte 0x30, 0x31
  78. /* Fixed value, must be 0x96. */
  79. .byte 0x96
  80. /* Main unit code, 0 for GBA. */
  81. .byte 0x00
  82. /* Device type, used by the debugging handler. */
  83. .byte 0x00
  84. /* 7 bytes reserved area. */
  85. .byte 0, 0, 0, 0, 0, 0, 0
  86. /* Software version, usually zero. */
  87. .byte 0x00
  88. /* Header checksum. */
  89. .byte 0xF0
  90. /* 2 byte checksum. */
  91. .byte 0, 0
  92. /*
  93. * Multiboot Header
  94. */
  95. rom_header_end:
  96. b _start
  97. /*
  98. * Boot method, set by the BIOS:
  99. * - 1 = joybus mode
  100. * - 2 = normal mode
  101. * - 3 = multiboot mode
  102. */
  103. .byte 0
  104. /*
  105. * Slave ID, set to 1..3 by the BIOS in multiboot mode.
  106. * In normal mode this is set to 1.
  107. */
  108. .byte 0
  109. /* Reserved area of 26 bytes. */
  110. .byte 0
  111. .byte 0
  112. .word 0
  113. .word 0
  114. .word 0
  115. .word 0
  116. .word 0
  117. .word 0
  118. .extern main
  119. .arm
  120. .align
  121. .global _start
  122. _start:
  123. /* Switch to IRQ mode and set IRQ stack pointer. */
  124. mov r0, #0x12
  125. msr cpsr, r0
  126. ldr sp, =__sp_irq
  127. /* Switch to user mode and set user stack pointer. */
  128. mov r0, #0x10
  129. msr cpsr, r0
  130. ldr sp, =__sp_usr
  131. /* Enter Thumb mode */
  132. adr r0, _enter_thumb + 1
  133. bx r0
  134. .thumb
  135. _enter_thumb:
  136. /* Initialize data segment. */
  137. ldr r1, =__rom_data_start
  138. ldr r2, =__ram_data_start
  139. ldr r4, =__ram_data_end
  140. sub r3, r4, r2
  141. beq enter_main
  142. copy_data:
  143. ldmia r1!, {r0}
  144. stmia r2!, {r0}
  145. sub r3, #4
  146. bne copy_data
  147. enter_main:
  148. ldr r0, =NutInit
  149. bx r0
  150. exit_loop:
  151. b exit_loop
  152. .end