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

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

Use an explicitly defined and mutually agreed GP value wrt. ia64 kernel and ld.

  • Property mode set to 100644
File size: 4.6 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:
[fe7abd0]49
50#
51# Kernel entry point.
52#
53# This is where we are passed control from the boot code.
54# Register contents:
55#
56# r2 Address of the boot code's bootinfo structure.
57#
[30ef8ce]58kernel_image_start:
[7f1bfce]59 .auto
[5bda2f3e]60
[7208b6c]61 mov psr.l = r0
62 srlz.i
63 srlz.d
[5bda2f3e]64
[481c520]65 # Fill TR.i and TR.d using Region Register #VRN_KERNEL
[5bda2f3e]66
[15819e37]67 movl r8 = (VRN_KERNEL << VRN_SHIFT)
68 mov r9 = rr[r8]
[5bda2f3e]69
[15819e37]70 movl r10 = (RR_MASK)
71 and r9 = r10, r9
[d9ee2ea]72 movl r10 = (((RID_KERNEL7) << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT))
[5bda2f3e]73 or r9 = r10, r9
74
[15819e37]75 mov rr[r8] = r9
[5bda2f3e]76
[15819e37]77 movl r8 = (VRN_KERNEL << VRN_SHIFT)
78 mov cr.ifa = r8
[5bda2f3e]79
[acee917]80 mov r11 = cr.itir
81 movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT)
82 or r10 = r10, r11
83 mov cr.itir = r10
[5bda2f3e]84
[15819e37]85 movl r10 = (KERNEL_TRANSLATION_I)
86 itr.i itr[r0] = r10
87 movl r10 = (KERNEL_TRANSLATION_D)
88 itr.d dtr[r0] = r10
[5bda2f3e]89
[7208b6c]90 movl r7 = 1
91 movl r8 = (VRN_KERNEL << VRN_SHIFT) | VIO_OFFSET
92 mov cr.ifa = r8
93 movl r10 = (KERNEL_TRANSLATION_VIO)
94 itr.d dtr[r7] = r10
[5bda2f3e]95
[acee917]96 mov r11 = cr.itir
97 movl r10 = ~0xfc
98 and r10 = r10, r11
99 movl r11 = (IO_PAGE_WIDTH << PS_SHIFT)
100 or r10 = r10, r11
101 mov cr.itir = r10
[5bda2f3e]102
[7208b6c]103 movl r7 = 2
104 movl r8 = (VRN_KERNEL << VRN_SHIFT) | IO_OFFSET
105 mov cr.ifa = r8
106 movl r10 = (KERNEL_TRANSLATION_IO)
107 itr.d dtr[r7] = r10
[5bda2f3e]108
109 # Setup mapping for firmware area (also SAPIC)
110
[acee917]111 mov r11 = cr.itir
112 movl r10 = ~0xfc
113 and r10 = r10, r11
114 movl r11 = (FW_PAGE_WIDTH << PS_SHIFT)
115 or r10 = r10, r11
116 mov cr.itir = r10
[5bda2f3e]117
[59e4864]118 movl r7 = 3
119 movl r8 = (VRN_KERNEL << VRN_SHIFT) | FW_OFFSET
120 mov cr.ifa = r8
121 movl r10 = (KERNEL_TRANSLATION_FW)
122 itr.d dtr[r7] = r10
[5bda2f3e]123
[93d66ef]124 # Initialize DSR
125
126 movl r10 = (DCR_DP_MASK | DCR_DK_MASK | DCR_DX_MASK | DCR_DR_MASK | DCR_DA_MASK | DCR_DD_MASK | DCR_LC_MASK)
127 mov r9 = cr.dcr
128 or r10 = r10, r9
129 mov cr.dcr = r10
130
[666773c]131 # Initialize PSR
[5bda2f3e]132
[15819e37]133 movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */
134 mov r9 = psr
[5bda2f3e]135
[15819e37]136 or r10 = r10, r9
137 mov cr.ipsr = r10
138 mov cr.ifs = r0
139 movl r8 = paging_start
140 mov cr.iip = r8
[802bb95]141 srlz.d
[5ac2e61]142 srlz.i
[5bda2f3e]143
[481c520]144 .explicit
[5bda2f3e]145
[481c520]146 /*
[0e56eb1a]147 * Return From Interrupt is the only way to
148 * fill the upper half word of PSR.
[481c520]149 */
[acee917]150 rfi ;;
[085434a]151
152.global paging_start
153paging_start:
[5bda2f3e]154
[481c520]155 /*
156 * Now we are paging.
157 */
[5bda2f3e]158
[666773c]159 # Switch to register bank 1
[802bb95]160 bsw.1
[5bda2f3e]161
[666773c]162 # Initialize register stack
[7f1bfce]163 mov ar.rsc = r0
[15819e37]164 movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
[5ac2e61]165 mov ar.bspstore = r8
[7f1bfce]166 loadrs
[5bda2f3e]167
[7f0e7b6]168 #
169 # Initialize memory stack to some sane value and allocate a scratch are
170 # on it.
171 #
172 movl sp = stack0 ;;
173 add sp = -16, sp
[5bda2f3e]174
[666773c]175 # Initialize gp (Global Pointer) register
[18ba2e4f]176 movl gp = __gp
[7a9364c]177
[18ba2e4f]178 #
[fe7abd0]179 # Initialize bootinfo on BSP.
180 #
181 movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;
182 or r20 = r20, r2 ;;
[e5c1186]183 addl r21 = @gprel(bootinfo), gp ;;
184 st8 [r21] = r20
[5bda2f3e]185
[15819e37]186 ssm (1 << 19) ;; /* Disable f32 - f127 */
187 srlz.i
188 srlz.d ;;
[5bda2f3e]189
[6ecc8bce]190 br.call.sptk.many b0 = arch_pre_main
[fae1647]1910:
192 br.call.sptk.many b0 = main_bsp
[2a0047fc]1930:
[47d78c6]194 br 0b
Note: See TracBrowser for help on using the repository browser.