[BACK]Return to head.S CVS log [TXT][DIR] Up to [local] / prex / boot / arm / gba

Annotation of prex/boot/arm/gba/head.S, Revision 1.1

1.1     ! nbrk        1: /*-
        !             2:  * Copyright (c) 2005, Kohsuke Ohtani
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms, with or without
        !             6:  * modification, are permitted provided that the following conditions
        !             7:  * are met:
        !             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 author nor the names of any co-contributors
        !            14:  *    may be used to endorse or promote products derived from this software
        !            15:  *    without specific prior written permission.
        !            16:  *
        !            17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            18:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            19:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            20:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
        !            21:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            22:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            23:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            25:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            26:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            27:  * SUCH DAMAGE.
        !            28:  */
        !            29:
        !            30: /*
        !            31:  * head.S - low level platform support
        !            32:  *
        !            33:  * This file contains the code from crt0.S which is released under
        !            34:  * public domain by Jeff Frohwein.
        !            35:  */
        !            36:
        !            37: /*-
        !            38:  * Memory usage:
        !            39:  *
        !            40:  * 0x02000000 - 0x0203ffff : EWRAM (256K)
        !            41:  * 0x03000000 - 0x03007fff : IWRAM (32K)
        !            42:  * 0x04000000 - 0x040003ff : I/O Register (1K)
        !            43:  * 0x05000000 - 0x050003ff : Palette RAM (1K)
        !            44:  * 0x06000000 - 0x06017fff : VRAM (96K)
        !            45:  *
        !            46:  * Note:
        !            47:  * 0x03007f00 - 0x03007fff is reserved by GBA BIOS.
        !            48:  */
        !            49:
        !            50: #include <conf/config.h>
        !            51: #include <platform.h>
        !            52:
        !            53: #define ENTRY(x) .global x; .align; x##:
        !            54:
        !            55:        .section ".text","ax"
        !            56:        .code 32
        !            57: /*
        !            58:  * Kernel start point
        !            59:  */
        !            60: ENTRY(boot_entry)
        !            61:        b       rom_header_end
        !            62:
        !            63:        /*
        !            64:         * GBA ROM header
        !            65:         */
        !            66:
        !            67:        /* Nintendo Logo Character Data (8000004h) */
        !            68:        .fill   156,1,0
        !            69:
        !            70:        /* Game Title (80000A0h) */
        !            71:        .byte   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
        !            72:        .byte   0x00,0x00,0x00,0x00
        !            73:
        !            74:        /* Game Code (80000ACh) */
        !            75:        .byte   0x00,0x00,0x00,0x00
        !            76:
        !            77:        /* Maker Code (80000B0h) */
        !            78:        .byte   0x30,0x31
        !            79:
        !            80:        /* Fixed Value (80000B2h) */
        !            81:        .byte   0x96
        !            82:
        !            83:        /* Main Unit Code (80000B3h) */
        !            84:        .byte   0x00
        !            85:
        !            86:        /* Device Type (80000B4h) */
        !            87:        .byte   0x00
        !            88:
        !            89:        /* Unused Data (7Byte) (80000B5h) */
        !            90:        .byte   0x00,0x00,0x00,0x00,0x00,0x00,0x00
        !            91:
        !            92:        /* Software Version No (80000BCh) */
        !            93:        .byte   0x00
        !            94:
        !            95:        /* Complement Check (80000BDh) */
        !            96:        .byte   0xf0
        !            97:
        !            98:        /* Checksum (80000BEh) */
        !            99:        .byte   0x00,0x00
        !           100:
        !           101:        .align
        !           102:        .code 32
        !           103:
        !           104: rom_header_end:
        !           105:        b       start_vector
        !           106:
        !           107:        .global __boot_method, __slave_number
        !           108:
        !           109: __boot_method:
        !           110:        .byte   0       /* boot method (0=ROM boot, 3=Multiplay boot) */
        !           111: __slave_number:
        !           112:        .byte   0       /* slave # (1=slave#1, 2=slave#2, 3=slave#3) */
        !           113:
        !           114:        .byte   0
        !           115:        .byte   0
        !           116:        .word   0
        !           117:        .word   0
        !           118:        .word   0
        !           119:        .word   0
        !           120:        .word   0
        !           121:        .word   0
        !           122:
        !           123:        .align
        !           124:        .code 32
        !           125: stack_end:     .word   BOOT_STACK+0xf00
        !           126:
        !           127: start_vector:
        !           128:        mov     r0, #0xd3               /* Enter SVC mode, Disable IRQ,FIQ */
        !           129:        msr     cpsr_c, r0
        !           130:        ldr     sp, stack_end
        !           131:
        !           132:        adr     r0, thumb_mode + 1
        !           133:        bx      r0
        !           134:        .code 16
        !           135: thumb_mode:
        !           136:
        !           137: /*
        !           138:  * Relocate the loader code
        !           139:  */
        !           140:        mov     r3, #0x40
        !           141:        lsl     r3, #7      /* r3 = 0x2000 (8K) */
        !           142:        mov     r2, #3
        !           143:        lsl     r2, #24     /* r2 = 0x3000000 */
        !           144:        lsl     r1, r3, #14 /* r1 = 0x8000000 */
        !           145:
        !           146: copy_loop:
        !           147:        ldmia   r1!, {r0}
        !           148:        stmia   r2!, {r0}
        !           149:        sub     r3, #4
        !           150:        bne     copy_loop
        !           151:
        !           152:        ldr     r0, =loader_main
        !           153:        bx      r0              /* Change to ARM mode */
        !           154:
        !           155:        .code 32
        !           156:
        !           157: /*
        !           158:  * Start kernel
        !           159:  */
        !           160: ENTRY(start_kernel)
        !           161:        bx      r0
        !           162:
        !           163: /*
        !           164:  * Put one character to Visual Boy Advance (VBA) emulator console.
        !           165:  *
        !           166:  * Important:
        !           167:  * This BIOS call is not supported by actual GBA BIOS. So, you must
        !           168:  * disable this function when you run it on actual GBA H/W.
        !           169:  * Otherwise, it will hang.
        !           170:  */
        !           171: putbuf:
        !           172:        .long   0
        !           173:
        !           174: ENTRY(putchar)
        !           175: #if defined(DEBUG) && defined(CONFIG_DIAG_VBA)
        !           176:        ldr     r1, =putbuf
        !           177:        str     r0, [r1]
        !           178:        mov     r0, r1
        !           179:        swi     $0xff0000
        !           180: #endif
        !           181:        mov     pc, lr
        !           182: /*
        !           183:  * Panic handler
        !           184:  */
        !           185: ENTRY(machine_panic)
        !           186: stop:
        !           187:        b       stop
        !           188:
        !           189:        .section .tail,"ax"
        !           190: dummy:
        !           191:        .byte   0xff
        !           192:
        !           193: .end

CVSweb