source: mainline/kernel/arch/ia64/src/start.S@ 19b5929

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 19b5929 was 19b5929, checked in by Jakub Jermar <jakub@…>, 16 years ago

Define the hardcoded_* variables in the ia64 linker script.

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[30ef8ce]1#
[df4ed85]2# Copyright (c) 2005 Jakub Jermar
[30ef8ce]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
[802bb95]29#include <arch/register.h>
[5ac2e61]30#include <arch/mm/page.h>
31#include <arch/mm/asid.h>
32#include <mm/asid.h>
33
[5bda2f3e]34#define RR_MASK (0xFFFFFFFF00000002)
35#define RID_SHIFT 8
36#define PS_SHIFT 2
[7208b6c]37
[5bda2f3e]38#define KERNEL_TRANSLATION_I 0x0010000000000661
39#define KERNEL_TRANSLATION_D 0x0010000000000661
40#define KERNEL_TRANSLATION_VIO 0x0010000000000671
41#define KERNEL_TRANSLATION_IO 0x00100FFFFC000671
42#define KERNEL_TRANSLATION_FW 0x00100000F0000671
[5ac2e61]43
[9faddb3]44.section K_TEXT_START, "ax"
[00a44bc]45
[30ef8ce]46.global kernel_image_start
47
[2217ac3]48stack0:
[30ef8ce]49kernel_image_start:
[7f1bfce]50 .auto
[5bda2f3e]51
[acee917]52#ifdef CONFIG_SMP
[666773c]53 # Identify self(CPU) in OS structures by ID / EID
[5bda2f3e]54
[666773c]55 mov r9 = cr64
56 mov r10 = 1
57 movl r12 = 0xffffffff
58 movl r8 = cpu_by_id_eid_list
59 and r8 = r8, r12
60 shr r9 = r9, 16
61 add r8 = r8, r9
62 st1 [r8] = r10
[acee917]63#endif
[5bda2f3e]64
[7208b6c]65 mov psr.l = r0
66 srlz.i
67 srlz.d
[5bda2f3e]68
[481c520]69 # Fill TR.i and TR.d using Region Register #VRN_KERNEL
[5bda2f3e]70
[15819e37]71 movl r8 = (VRN_KERNEL << VRN_SHIFT)
72 mov r9 = rr[r8]
[5bda2f3e]73
[15819e37]74 movl r10 = (RR_MASK)
75 and r9 = r10, r9
76 movl r10 = ((RID_KERNEL << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT))
[5bda2f3e]77 or r9 = r10, r9
78
[15819e37]79 mov rr[r8] = r9
[5bda2f3e]80
[15819e37]81 movl r8 = (VRN_KERNEL << VRN_SHIFT)
82 mov cr.ifa = r8
[5bda2f3e]83
[acee917]84 mov r11 = cr.itir
85 movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT)
86 or r10 = r10, r11
87 mov cr.itir = r10
[5bda2f3e]88
[15819e37]89 movl r10 = (KERNEL_TRANSLATION_I)
90 itr.i itr[r0] = r10
91 movl r10 = (KERNEL_TRANSLATION_D)
92 itr.d dtr[r0] = r10
[5bda2f3e]93
[7208b6c]94 movl r7 = 1
95 movl r8 = (VRN_KERNEL << VRN_SHIFT) | VIO_OFFSET
96 mov cr.ifa = r8
97 movl r10 = (KERNEL_TRANSLATION_VIO)
98 itr.d dtr[r7] = r10
[5bda2f3e]99
[acee917]100 mov r11 = cr.itir
101 movl r10 = ~0xfc
102 and r10 = r10, r11
103 movl r11 = (IO_PAGE_WIDTH << PS_SHIFT)
104 or r10 = r10, r11
105 mov cr.itir = r10
[5bda2f3e]106
[7208b6c]107 movl r7 = 2
108 movl r8 = (VRN_KERNEL << VRN_SHIFT) | IO_OFFSET
109 mov cr.ifa = r8
110 movl r10 = (KERNEL_TRANSLATION_IO)
111 itr.d dtr[r7] = r10
[5bda2f3e]112
113 # Setup mapping for firmware area (also SAPIC)
114
[acee917]115 mov r11 = cr.itir
116 movl r10 = ~0xfc
117 and r10 = r10, r11
118 movl r11 = (FW_PAGE_WIDTH << PS_SHIFT)
119 or r10 = r10, r11
120 mov cr.itir = r10
[5bda2f3e]121
[59e4864]122 movl r7 = 3
123 movl r8 = (VRN_KERNEL << VRN_SHIFT) | FW_OFFSET
124 mov cr.ifa = r8
125 movl r10 = (KERNEL_TRANSLATION_FW)
126 itr.d dtr[r7] = r10
[5bda2f3e]127
[93d66ef]128 # Initialize DSR
129
130 movl r10 = (DCR_DP_MASK | DCR_DK_MASK | DCR_DX_MASK | DCR_DR_MASK | DCR_DA_MASK | DCR_DD_MASK | DCR_LC_MASK)
131 mov r9 = cr.dcr
132 or r10 = r10, r9
133 mov cr.dcr = r10
134
[666773c]135 # Initialize PSR
[5bda2f3e]136
[15819e37]137 movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */
138 mov r9 = psr
[5bda2f3e]139
[15819e37]140 or r10 = r10, r9
141 mov cr.ipsr = r10
142 mov cr.ifs = r0
143 movl r8 = paging_start
144 mov cr.iip = r8
[802bb95]145 srlz.d
[5ac2e61]146 srlz.i
[5bda2f3e]147
[481c520]148 .explicit
[5bda2f3e]149
[481c520]150 /*
[0e56eb1a]151 * Return From Interrupt is the only way to
152 * fill the upper half word of PSR.
[481c520]153 */
[acee917]154 rfi ;;
[085434a]155
156.global paging_start
157paging_start:
[5bda2f3e]158
[481c520]159 /*
160 * Now we are paging.
161 */
[5bda2f3e]162
[666773c]163 # Switch to register bank 1
[802bb95]164 bsw.1
[5bda2f3e]165
[acee917]166#ifdef CONFIG_SMP
[666773c]167 # Am I BSP or AP?
[acee917]168 movl r20 = bsp_started ;;
169 ld8 r20 = [r20] ;;
170 cmp.eq p3, p2 = r20, r0 ;;
171#else
[5bda2f3e]172 cmp.eq p3, p2 = r0, r0 ;; /* you are BSP */
173#endif /* CONFIG_SMP */
[7f1bfce]174
[666773c]175 # Initialize register stack
[7f1bfce]176 mov ar.rsc = r0
[15819e37]177 movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
[5ac2e61]178 mov ar.bspstore = r8
[7f1bfce]179 loadrs
[5bda2f3e]180
[666773c]181 # Initialize memory stack to some sane value
[15819e37]182 movl r12 = stack0 ;;
[5bda2f3e]183 add r12 = -16, r12 /* allocate a scratch area on the stack */
184
[666773c]185 # Initialize gp (Global Pointer) register
[5bda2f3e]186 movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;
187 or r20 = r20, r1 ;;
[19b5929]188 movl r1 = kernel_image_start
[7a9364c]189
[481c520]190 /*
[19b5929]191 * Initialize bootinfo on BSP.
[481c520]192 */
[19b5929]193(p3) addl r21 = @gprel(bootinfo), gp ;;
[59e4864]194(p3) st8 [r21] = r20
[5bda2f3e]195
[15819e37]196 ssm (1 << 19) ;; /* Disable f32 - f127 */
197 srlz.i
198 srlz.d ;;
[5bda2f3e]199
[acee917]200#ifdef CONFIG_SMP
[59e4864]201(p2) movl r18 = main_ap ;;
[5bda2f3e]202(p2) mov b1 = r18 ;;
[59e4864]203(p2) br.call.sptk.many b0 = b1
[5bda2f3e]204
[666773c]205 # Mark that BSP is on
[5bda2f3e]206
[acee917]207 mov r20 = 1 ;;
208 movl r21 = bsp_started ;;
209 st8 [r21] = r20 ;;
210#endif
[5bda2f3e]211
[6ecc8bce]212 br.call.sptk.many b0 = arch_pre_main
[5bda2f3e]213
[15819e37]214 movl r18 = main_bsp ;;
215 mov b1 = r18 ;;
216 br.call.sptk.many b0 = b1
[5ac2e61]217
[2a0047fc]2180:
[47d78c6]219 br 0b
[59e4864]220
[acee917]221#ifdef CONFIG_SMP
222
223.align 4096
[59e4864]224kernel_image_ap_start:
225 .auto
[5bda2f3e]226
[666773c]227 # Identify self(CPU) in OS structures by ID / EID
[5bda2f3e]228
[666773c]229 mov r9 = cr64
230 mov r10 = 1
231 movl r12 = 0xffffffff
232 movl r8 = cpu_by_id_eid_list
233 and r8 = r8, r12
234 shr r9 = r9, 16
235 add r8 = r8, r9
236 st1 [r8] = r10
[59e4864]237
[666773c]238 # Wait for wakeup synchro signal (#3 in cpu_by_id_eid_list)
[5bda2f3e]239
[59e4864]240kernel_image_ap_start_loop:
[666773c]241 movl r11 = kernel_image_ap_start_loop
242 and r11 = r11, r12
[5bda2f3e]243 mov b1 = r11
244
245 ld1 r20 = [r8]
246 movl r21 = 3
247 cmp.eq p2, p3 = r20, r21
[666773c]248(p3) br.call.sptk.many b0 = b1
[5bda2f3e]249
[666773c]250 movl r11 = kernel_image_start
251 and r11 = r11, r12
[5bda2f3e]252 mov b1 = r11
[59e4864]253 br.call.sptk.many b0 = b1
254
255.align 16
256.global bsp_started
257bsp_started:
[5bda2f3e]258 .space 8
[59e4864]259
260.align 4096
261.global cpu_by_id_eid_list
262cpu_by_id_eid_list:
[5bda2f3e]263 .space 65536
[59e4864]264
[5bda2f3e]265#endif /* CONFIG_SMP */
Note: See TracBrowser for help on using the repository browser.