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 |
|
---|
29 | #include <abi/asmtool.h>
|
---|
30 | #include <arch/register.h>
|
---|
31 | #include <arch/mm/page.h>
|
---|
32 | #include <arch/mm/asid.h>
|
---|
33 | #include <mm/asid.h>
|
---|
34 |
|
---|
35 | #define RR_MASK (0xFFFFFFFF00000002)
|
---|
36 | #define RID_SHIFT 8
|
---|
37 | #define PS_SHIFT 2
|
---|
38 |
|
---|
39 | #define KERNEL_TRANSLATION_I 0x0010000000000661
|
---|
40 | #define KERNEL_TRANSLATION_D 0x0010000000000661
|
---|
41 |
|
---|
42 | .section K_TEXT_START, "ax"
|
---|
43 |
|
---|
44 | stack0:
|
---|
45 |
|
---|
46 | #
|
---|
47 | # Kernel entry point.
|
---|
48 | #
|
---|
49 | # This is where we are passed control from the boot code.
|
---|
50 | # Register contents:
|
---|
51 | #
|
---|
52 | # r2 Address of the boot code's bootinfo structure.
|
---|
53 | #
|
---|
54 | SYMBOL(kernel_image_start)
|
---|
55 | .auto
|
---|
56 |
|
---|
57 | mov psr.l = r0
|
---|
58 | srlz.i
|
---|
59 | srlz.d
|
---|
60 |
|
---|
61 | # Fill TR.i and TR.d using Region Register #VRN_KERNEL
|
---|
62 |
|
---|
63 | movl r8 = (VRN_KERNEL << VRN_SHIFT)
|
---|
64 | mov r9 = rr[r8]
|
---|
65 |
|
---|
66 | movl r10 = (RR_MASK)
|
---|
67 | and r9 = r10, r9
|
---|
68 | movl r10 = (((RID_KERNEL7) << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT))
|
---|
69 | or r9 = r10, r9
|
---|
70 |
|
---|
71 | mov rr[r8] = r9
|
---|
72 |
|
---|
73 | movl r8 = (VRN_KERNEL << VRN_SHIFT)
|
---|
74 | mov cr.ifa = r8
|
---|
75 |
|
---|
76 | mov r11 = cr.itir
|
---|
77 | movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT)
|
---|
78 | or r10 = r10, r11
|
---|
79 | mov cr.itir = r10
|
---|
80 |
|
---|
81 | movl r10 = (KERNEL_TRANSLATION_I)
|
---|
82 | itr.i itr[r0] = r10
|
---|
83 | movl r10 = (KERNEL_TRANSLATION_D)
|
---|
84 | itr.d dtr[r0] = r10
|
---|
85 |
|
---|
86 | # Initialize DCR
|
---|
87 |
|
---|
88 | movl r10 = (DCR_DM_MASK | DCR_DP_MASK | DCR_DK_MASK | DCR_DX_MASK | DCR_DR_MASK | DCR_DA_MASK | DCR_DD_MASK | DCR_LC_MASK)
|
---|
89 | mov r9 = cr.dcr
|
---|
90 | or r10 = r10, r9
|
---|
91 | mov cr.dcr = r10
|
---|
92 |
|
---|
93 | # Initialize PSR
|
---|
94 |
|
---|
95 | movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */
|
---|
96 | mov r9 = psr
|
---|
97 |
|
---|
98 | or r10 = r10, r9
|
---|
99 | mov cr.ipsr = r10
|
---|
100 | mov cr.ifs = r0
|
---|
101 | movl r8 = paging_start
|
---|
102 | mov cr.iip = r8
|
---|
103 | srlz.d
|
---|
104 | srlz.i
|
---|
105 |
|
---|
106 | .explicit
|
---|
107 |
|
---|
108 | /*
|
---|
109 | * Return From Interrupt is the only way to
|
---|
110 | * fill the upper half word of PSR.
|
---|
111 | */
|
---|
112 | rfi ;;
|
---|
113 |
|
---|
114 | paging_start:
|
---|
115 |
|
---|
116 | /*
|
---|
117 | * Now we are paging.
|
---|
118 | */
|
---|
119 |
|
---|
120 | #
|
---|
121 | # Set Interruption Vector Address
|
---|
122 | # (i.e. location of interruption vector table)
|
---|
123 | #
|
---|
124 | movl r8 = ivt ;;
|
---|
125 | mov cr.iva = r8
|
---|
126 | srlz.d ;;
|
---|
127 |
|
---|
128 |
|
---|
129 | # Switch to register bank 1
|
---|
130 | bsw.1
|
---|
131 |
|
---|
132 | # Initialize register stack
|
---|
133 | mov ar.rsc = r0
|
---|
134 | movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
|
---|
135 | mov ar.bspstore = r8
|
---|
136 | loadrs
|
---|
137 |
|
---|
138 | #
|
---|
139 | # Initialize memory stack to some sane value and allocate a scratch area
|
---|
140 | # on it.
|
---|
141 | #
|
---|
142 | movl sp = stack0 ;;
|
---|
143 | add sp = -16, sp
|
---|
144 |
|
---|
145 | # Initialize gp (Global Pointer) register
|
---|
146 | movl gp = __gp
|
---|
147 |
|
---|
148 | #
|
---|
149 | # Initialize bootinfo on BSP.
|
---|
150 | #
|
---|
151 | movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;
|
---|
152 | or r20 = r20, r2 ;;
|
---|
153 | addl r21 = @gprel(bootinfo), gp ;;
|
---|
154 | st8 [r21] = r20
|
---|
155 |
|
---|
156 | ssm (1 << 19) ;; /* Disable f32 - f127 */
|
---|
157 | srlz.i
|
---|
158 | srlz.d ;;
|
---|
159 |
|
---|
160 | br.call.sptk.many b0 = ia64_pre_main
|
---|
161 | 0:
|
---|
162 | br.call.sptk.many b0 = main_bsp
|
---|
163 | 0:
|
---|
164 | br 0b
|
---|