Rev 872 | Rev 893 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
35 | jermar | 1 | # |
2 | # Copyright (C) 2005 Jakub Jermar |
||
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 | # |
||
9 | # - Redistributions of source code must retain the above copyright |
||
10 | # notice, this list of conditions and the following disclaimer. |
||
11 | # - Redistributions in binary form must reproduce the above copyright |
||
12 | # notice, this list of conditions and the following disclaimer in the |
||
13 | # documentation and/or other materials provided with the distribution. |
||
14 | # - The name of the author may not be used to endorse or promote products |
||
15 | # derived from this software without specific prior written permission. |
||
16 | # |
||
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | # |
||
28 | |||
869 | vana | 29 | |
473 | jermar | 30 | #include <arch/register.h> |
869 | vana | 31 | #include <arch/mm/page.h> |
32 | #include <arch/mm/asid.h> |
||
33 | #include <mm/asid.h> |
||
473 | jermar | 34 | |
869 | vana | 35 | |
36 | #define RR_MASK (0xFFFFFFFF00000002) |
||
37 | #define RID_SHIFT 8 |
||
38 | #define PS_SHIFT 2 |
||
39 | |||
40 | |||
41 | #define KERNEL_TRANSLATION_I 0x0010000000000661 |
||
42 | #define KERNEL_TRANSLATION_D 0x0010000000000661 |
||
43 | |||
44 | |||
60 | jermar | 45 | .section K_TEXT_START |
46 | |||
35 | jermar | 47 | .global kernel_image_start |
48 | |||
37 | jermar | 49 | stack0: |
35 | jermar | 50 | kernel_image_start: |
81 | jermar | 51 | .auto |
412 | jermar | 52 | |
879 | vana | 53 | #Fill TR.i and TR.d using Region Register #VRN_KERNEL |
869 | vana | 54 | |
55 | movl r8=(VRN_KERNEL<<VRN_SHIFT) |
||
56 | mov r9=rr[r8] |
||
57 | movl r10=(RR_MASK) |
||
58 | and r9=r10,r9 |
||
59 | movl r10=((ASID2RID(ASID_KERNEL,VRN_KERNEL)<<RID_SHIFT)|(KERNEL_PAGE_WIDTH<<PS_SHIFT)) |
||
60 | or r9=r10,r9 |
||
61 | mov rr[r8]=r9 |
||
62 | |||
63 | |||
64 | movl r8=(VRN_KERNEL<<VRN_SHIFT) |
||
65 | mov cr.ifa=r8 |
||
66 | movl r10=(KERNEL_PAGE_WIDTH<<PS_SHIFT) |
||
67 | mov cr.itir=r10 |
||
68 | movl r10=(KERNEL_TRANSLATION_I) |
||
69 | itr.i itr[r0]=r10 |
||
70 | |||
71 | movl r10=(KERNEL_TRANSLATION_D) |
||
72 | itr.d dtr[r0]=r10 |
||
73 | |||
74 | |||
81 | jermar | 75 | # initialize PSR |
412 | jermar | 76 | mov psr.l = r0 |
77 | srlz.i |
||
78 | srlz.d |
||
869 | vana | 79 | movl r10=(PSR_DT_MASK|PSR_RT_MASK|PSR_IT_MASK|PSR_IC_MASK) /*Enable paging*/ |
80 | mov r9=psr |
||
81 | or r10=r10,r9 |
||
82 | mov cr.ipsr=r10 |
||
83 | mov cr.ifs=r0 |
||
84 | movl r8=paging_start |
||
85 | mov cr.iip=r8 |
||
473 | jermar | 86 | srlz.d |
869 | vana | 87 | srlz.i |
88 | .explicit |
||
879 | vana | 89 | |
90 | /*Return from interupt is only the way how to fill upper half word of PSR*/ |
||
869 | vana | 91 | {rfi;;} |
92 | {nop 0;;} |
||
93 | {nop 0;;} |
||
94 | {nop 0;;} |
||
95 | {nop 0;;} |
||
96 | {nop 0;;} |
||
97 | {nop 0;;} |
||
98 | {nop 0;;} |
||
99 | {nop 0;;} |
||
879 | vana | 100 | |
101 | .global paging_start |
||
102 | /*Now we are paging*/ |
||
103 | paging_start: |
||
869 | vana | 104 | {nop 0;;} |
105 | {nop 0;;} |
||
106 | {nop 0;;} |
||
107 | {nop 0;;} |
||
108 | {nop 0;;} |
||
109 | {nop 0;;} |
||
110 | {nop 0;;} |
||
111 | {nop 0;;} |
||
112 | |||
113 | .auto |
||
81 | jermar | 114 | |
473 | jermar | 115 | # switch to register bank 1 |
116 | bsw.1 |
||
117 | |||
74 | jermar | 118 | # initialize register stack |
81 | jermar | 119 | mov ar.rsc = r0 |
869 | vana | 120 | movl r8=(VRN_KERNEL<<VRN_SHIFT) |
121 | mov ar.bspstore = r8 |
||
81 | jermar | 122 | loadrs |
36 | jermar | 123 | |
81 | jermar | 124 | .explicit |
74 | jermar | 125 | # initialize memory stack to some sane value |
872 | vana | 126 | movl r12 = stack0;; |
869 | vana | 127 | |
81 | jermar | 128 | add r12 = - 16, r12 /* allocate a scratch area on the stack */ |
60 | jermar | 129 | |
74 | jermar | 130 | # initialize gp (Global Pointer) register |
869 | vana | 131 | movl r1 = _hardcoded_load_address ;; |
132 | |||
106 | jermar | 133 | |
74 | jermar | 134 | |
60 | jermar | 135 | # |
136 | # Initialize hardcoded_* variables. |
||
137 | # |
||
106 | jermar | 138 | movl r14 = _hardcoded_ktext_size |
139 | movl r15 = _hardcoded_kdata_size |
||
140 | movl r16 = _hardcoded_load_address |
||
141 | addl r17 = @gprel(hardcoded_ktext_size), gp |
||
142 | addl r18 = @gprel(hardcoded_kdata_size), gp |
||
143 | addl r19 = @gprel(hardcoded_load_address), gp |
||
144 | ;; |
||
870 | vana | 145 | st8 [r17] = r14 |
146 | st8 [r18] = r15 |
||
106 | jermar | 147 | st8 [r19] = r16 |
869 | vana | 148 | |
149 | |||
150 | .auto |
||
37 | jermar | 151 | |
869 | vana | 152 | movl r18=main_bsp |
153 | mov b1=r18 |
||
154 | br.call.sptk.many b0=b1 |
||
51 | jermar | 155 | |
869 | vana | 156 | |
36 | jermar | 157 | 0: |
39 | jermar | 158 | br 0b |