entry.S revision 1.1.2.2 1 1.1.2.2 bouyer /* $NetBSD: entry.S,v 1.1.2.2 2011/03/05 15:09:54 bouyer Exp $ */
2 1.1.2.2 bouyer /*
3 1.1.2.2 bouyer * Copyright (c) 2011 KIYOHARA Takashi
4 1.1.2.2 bouyer * All rights reserved.
5 1.1.2.2 bouyer *
6 1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
7 1.1.2.2 bouyer * modification, are permitted provided that the following conditions
8 1.1.2.2 bouyer * are met:
9 1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer.
11 1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.1.2.2 bouyer * documentation and/or other materials provided with the distribution.
14 1.1.2.2 bouyer *
15 1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.1.2.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 1.1.2.2 bouyer * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 1.1.2.2 bouyer * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 1.1.2.2 bouyer * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 1.1.2.2 bouyer * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 1.1.2.2 bouyer * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.1.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 1.1.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 1.1.2.2 bouyer * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1.2.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
26 1.1.2.2 bouyer */
27 1.1.2.2 bouyer
28 1.1.2.2 bouyer #include <sh3/asm.h>
29 1.1.2.2 bouyer #include <sh3/locore.h>
30 1.1.2.2 bouyer #include <sh3/mmu_sh3.h>
31 1.1.2.2 bouyer #include <sh3/mmu_sh4.h>
32 1.1.2.2 bouyer
33 1.1.2.2 bouyer #if defined(SH3) && defined(SH4)
34 1.1.2.2 bouyer #error "mmeye port don't support SH3,SH4 common kernel."
35 1.1.2.2 bouyer #elif defined(SH3)
36 1.1.2.2 bouyer #define RAM_BEGIN 0x8c000000 /* Area3 */
37 1.1.2.2 bouyer #define RAM_SIZE 0x01000000 /* 16M */
38 1.1.2.2 bouyer #elif defined(SH4)
39 1.1.2.2 bouyer #define RAM_BEGIN 0x88000000 /* Area2 */
40 1.1.2.2 bouyer #define RAM_SIZE 0x04000000 /* 64M */
41 1.1.2.2 bouyer #endif
42 1.1.2.2 bouyer
43 1.1.2.2 bouyer #define INIT_STACK (RAM_BEGIN + RAM_SIZE - 0x00001000)
44 1.1.2.2 bouyer
45 1.1.2.2 bouyer NENTRY(start)
46 1.1.2.2 bouyer /* Set SP to initial position */
47 1.1.2.2 bouyer mov.l XLtmpstk, r15
48 1.1.2.2 bouyer
49 1.1.2.2 bouyer __INTR_MASK(r0, r1)
50 1.1.2.2 bouyer
51 1.1.2.2 bouyer /* Set Register Bank to Bank 0 */
52 1.1.2.2 bouyer mov.l SR_init, r0
53 1.1.2.2 bouyer ldc r0, sr
54 1.1.2.2 bouyer
55 1.1.2.2 bouyer xor r0, r0
56 1.1.2.2 bouyer MOV (MMUCR, r2)
57 1.1.2.2 bouyer mov.l r0, @r2 /* MMU OFF */
58 1.1.2.2 bouyer
59 1.1.2.2 bouyer bra start1
60 1.1.2.2 bouyer nop
61 1.1.2.2 bouyer .align 2
62 1.1.2.2 bouyer SR_init: .long 0x500000F0
63 1.1.2.2 bouyer REG_SYMBOL(MMUCR)
64 1.1.2.2 bouyer start1:
65 1.1.2.2 bouyer
66 1.1.2.2 bouyer #if defined(SH4)
67 1.1.2.2 bouyer /* Copy boot image from _LOADADDR to ___start */
68 1.1.2.2 bouyer mov.l _LOADADDR, r1
69 1.1.2.2 bouyer mov.l ___end, r0
70 1.1.2.2 bouyer mov.l ___start, r3
71 1.1.2.2 bouyer sub r3, r0
72 1.1.2.2 bouyer add #4, r0 /* size of bytes to be copied */
73 1.1.2.2 bouyer shlr2 r0 /* number of long word */
74 1.1.2.2 bouyer 1:
75 1.1.2.2 bouyer mov.l @r1+, r4
76 1.1.2.2 bouyer mov.l r4, @r3
77 1.1.2.2 bouyer add #4, r3
78 1.1.2.2 bouyer dt r0 /* decrement and Test */
79 1.1.2.2 bouyer bf 1b
80 1.1.2.2 bouyer /* boot image copy end */
81 1.1.2.2 bouyer #endif
82 1.1.2.2 bouyer
83 1.1.2.2 bouyer mov.l XLmain, r0
84 1.1.2.2 bouyer jmp @r0 /* jump to main() */
85 1.1.2.2 bouyer nop
86 1.1.2.2 bouyer
87 1.1.2.2 bouyer .align 2
88 1.1.2.2 bouyer
89 1.1.2.2 bouyer _LOADADDR: .long 0x88010000 /* loaded here by 1st loader. */
90 1.1.2.2 bouyer ___start: .long start
91 1.1.2.2 bouyer ___end: .long _end
92 1.1.2.2 bouyer XLtmpstk: .long INIT_STACK
93 1.1.2.2 bouyer XLmain: .long _C_LABEL(main)
94