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

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

Do not compile unnecessary code when CONFIG_SMP is not configured on ia64.

  • Property mode set to 100644
File size: 6.0 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
34#define RR_MASK (0xFFFFFFFF00000002)
[666773c]35#define RID_SHIFT 8
36#define PS_SHIFT 2
[7208b6c]37
[666773c]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
[75eacab]51
[acee917]52#ifdef CONFIG_SMP
[666773c]53 # Identify self(CPU) in OS structures by ID / EID
[59e4864]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
[59e4864]64
[7208b6c]65 mov psr.l = r0
66 srlz.i
67 srlz.d
68
[481c520]69 # Fill TR.i and TR.d using Region Register #VRN_KERNEL
[5ac2e61]70
[15819e37]71 movl r8 = (VRN_KERNEL << VRN_SHIFT)
72 mov r9 = rr[r8]
[7208b6c]73
[15819e37]74 movl r10 = (RR_MASK)
75 and r9 = r10, r9
76 movl r10 = ((RID_KERNEL << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT))
77 or r9 = r10, r9
[7208b6c]78
[15819e37]79 mov rr[r8] = r9
80
81 movl r8 = (VRN_KERNEL << VRN_SHIFT)
82 mov cr.ifa = r8
[7208b6c]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
[7208b6c]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
[5ac2e61]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
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
[7208b6c]106
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
112
[666773c]113 # Setup mapping for fimware arrea (also SAPIC)
[7208b6c]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
[59e4864]121
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
127
[666773c]128 # Initialize PSR
[59e4864]129
[15819e37]130 movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */
131 mov r9 = psr
[666773c]132
[15819e37]133 or r10 = r10, r9
134 mov cr.ipsr = r10
135 mov cr.ifs = r0
136 movl r8 = paging_start
137 mov cr.iip = r8
[802bb95]138 srlz.d
[5ac2e61]139 srlz.i
[085434a]140
[481c520]141 .explicit
[666773c]142
[481c520]143 /*
[0e56eb1a]144 * Return From Interrupt is the only way to
145 * fill the upper half word of PSR.
[481c520]146 */
[acee917]147 rfi ;;
[085434a]148
[666773c]149
[085434a]150.global paging_start
151paging_start:
[481c520]152
153 /*
154 * Now we are paging.
155 */
156
[666773c]157 # Switch to register bank 1
[802bb95]158 bsw.1
[59e4864]159
[acee917]160#ifdef CONFIG_SMP
[666773c]161 # Am I BSP or AP?
[acee917]162 movl r20 = bsp_started ;;
163 ld8 r20 = [r20] ;;
164 cmp.eq p3, p2 = r20, r0 ;;
165#else
166 cmp.eq p3, p2 = r0, r0 ;; /* you are BSP */
167#endif /* CONFIG_SMP */
[7f1bfce]168
[666773c]169 # Initialize register stack
[7f1bfce]170 mov ar.rsc = r0
[15819e37]171 movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
[5ac2e61]172 mov ar.bspstore = r8
[7f1bfce]173 loadrs
[2a0047fc]174
[666773c]175 # Initialize memory stack to some sane value
[15819e37]176 movl r12 = stack0 ;;
177 add r12 = -16, r12 /* allocate a scratch area on the stack */
[00a44bc]178
[666773c]179 # Initialize gp (Global Pointer) register
[7a9364c]180 movl r20 = (VRN_KERNEL << VRN_SHIFT);;
181 or r20 = r20,r1;;
[b994a60]182 movl r1 = _hardcoded_load_address
[7a9364c]183
[481c520]184 /*
[59e4864]185 * Initialize hardcoded_* variables. Do only BSP
[481c520]186 */
[59e4864]187(p3) movl r14 = _hardcoded_ktext_size
188(p3) movl r15 = _hardcoded_kdata_size
189(p3) movl r16 = _hardcoded_load_address ;;
190(p3) addl r17 = @gprel(hardcoded_ktext_size), gp
191(p3) addl r18 = @gprel(hardcoded_kdata_size), gp
192(p3) addl r19 = @gprel(hardcoded_load_address), gp
193(p3) addl r21 = @gprel(bootinfo), gp
[ac5d02b]194 ;;
[59e4864]195(p3) st8 [r17] = r14
196(p3) st8 [r18] = r15
197(p3) st8 [r19] = r16
198(p3) st8 [r21] = r20
[5ac2e61]199
[15819e37]200 ssm (1 << 19) ;; /* Disable f32 - f127 */
201 srlz.i
202 srlz.d ;;
[41fa6f2]203
[acee917]204#ifdef CONFIG_SMP
[59e4864]205(p2) movl r18 = main_ap ;;
206(p2) mov b1 = r18 ;;
207(p2) br.call.sptk.many b0 = b1
208
[666773c]209 # Mark that BSP is on
[acee917]210 mov r20 = 1 ;;
211 movl r21 = bsp_started ;;
212 st8 [r21] = r20 ;;
213#endif
[59e4864]214
[6ecc8bce]215 br.call.sptk.many b0 = arch_pre_main
[41fa6f2]216
[15819e37]217 movl r18 = main_bsp ;;
218 mov b1 = r18 ;;
219 br.call.sptk.many b0 = b1
[5ac2e61]220
[2a0047fc]2210:
[47d78c6]222 br 0b
[59e4864]223
[acee917]224#ifdef CONFIG_SMP
225
226.align 4096
[59e4864]227kernel_image_ap_start:
228 .auto
[666773c]229
230 # Identify self(CPU) in OS structures by ID / EID
231
232 mov r9 = cr64
233 mov r10 = 1
234 movl r12 = 0xffffffff
235 movl r8 = cpu_by_id_eid_list
236 and r8 = r8, r12
237 shr r9 = r9, 16
238 add r8 = r8, r9
239 st1 [r8] = r10
[59e4864]240
[666773c]241 # Wait for wakeup synchro signal (#3 in cpu_by_id_eid_list)
[acee917]242
[59e4864]243kernel_image_ap_start_loop:
[666773c]244 movl r11 = kernel_image_ap_start_loop
245 and r11 = r11, r12
[59e4864]246 mov b1 = r11
247
[acee917]248 ld1 r20 = [r8] ;;
249 movl r21 = 3 ;;
250 cmp.eq p2, p3 = r20, r21 ;;
[666773c]251(p3) br.call.sptk.many b0 = b1
[59e4864]252
[666773c]253 movl r11 = kernel_image_start
254 and r11 = r11, r12
255 mov b1 = r11
[59e4864]256 br.call.sptk.many b0 = b1
257
258.align 16
259.global bsp_started
260bsp_started:
261.space 8
262
263.align 4096
264.global cpu_by_id_eid_list
265cpu_by_id_eid_list:
266.space 65536
267
[acee917]268#endif /* CONFIG_SMP */
Note: See TracBrowser for help on using the repository browser.