~ubuntu-branches/ubuntu/intrepid/xen-3.3/intrepid-updates

« back to all changes in this revision

Viewing changes to extras/mini-os/arch/ia64/ia64.S

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2008-08-14 10:28:57 UTC
  • Revision ID: james.westby@ubuntu.com-20080814102857-a832fn5gowurz5do
Tags: upstream-3.3.0
ImportĀ upstreamĀ versionĀ 3.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2007 Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
 
3
 *
 
4
 *****************************************************************************
 
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
 * of this software and associated documentation files (the "Software"), to
 
7
 * deal in the Software without restriction, including without limitation the
 
8
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 
9
 * sell copies of the Software, and to permit persons to whom the Software is
 
10
 * furnished to do so, subject to the following conditions:
 
11
 * 
 
12
 * The above copyright notice and this permission notice shall be included in
 
13
 * all copies or substantial portions of the Software.
 
14
 * 
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 
21
 * DEALINGS IN THE SOFTWARE.
 
22
 */
 
23
 
 
24
 
 
25
 
 
26
#include "asm.h"
 
27
#include "page.h"
 
28
#include "ia64_cpu.h"
 
29
#include "ia64_fpu.h"
 
30
#include "privop.h"
 
31
#include "offsets.h"
 
32
 
 
33
 
 
34
 
 
35
        /*
 
36
         * Allocate kernel stack area.
 
37
         * This is used for stack pointer (goes down from kstack+PAGE_SIZE) and
 
38
         * RSE (goes up from kstack).
 
39
         */
 
40
        .section .data.start,"aw"
 
41
        .global kstack
 
42
        .align  PAGE_SIZE
 
43
kstack: .space KSTACK_PAGES * PAGE_SIZE
 
44
 
 
45
        .text
 
46
 
 
47
        /*
 
48
         * Start the kernel.
 
49
         * r28 points to the address of the boot parameter area, given
 
50
         * from the bootloader.
 
51
         * Execution reaches here in physical mode.
 
52
         */
 
53
ENTRY(_start)
 
54
        .prologue
 
55
        .save rp, r0            // terminate unwind chain with a NULL rp
 
56
        .body
 
57
 
 
58
        alloc   loc0=ar.pfs,0,1,1,0
 
59
 
 
60
        rsm psr.i | psr.ic
 
61
        ;;
 
62
        srlz.i
 
63
        ;;
 
64
 
 
65
        /*
 
66
         * Initialize mini-os region registers:
 
67
         * Currently only region registers 5 and 7 are used for addressing.
 
68
         * rr[5] : virtual kernel address space
 
69
         * rr[7] : directly mapped physically addresses.
 
70
         */
 
71
        movl    r2=0<<IA64_RR_IDX_POS
 
72
        movl    r3=1<<IA64_RR_IDX_POS
 
73
        ;;
 
74
        mov     rr[r2]=r0
 
75
        mov     rr[r3]=r0
 
76
        ;;
 
77
        movl    r2=2<<IA64_RR_IDX_POS
 
78
        movl    r3=3<<IA64_RR_IDX_POS
 
79
        ;;
 
80
        mov     rr[r2]=r0
 
81
        mov     rr[r3]=r0
 
82
        ;;
 
83
        movl    r2=4<<IA64_RR_IDX_POS
 
84
        movl    r3=6<<IA64_RR_IDX_POS
 
85
        ;;
 
86
        mov     rr[r2]=r0
 
87
        mov     rr[r3]=r0
 
88
        ;;
 
89
        // Wired memory for kernel data and text.
 
90
        movl    r2=IA64_RR_VAL(KERNEL_TR_PAGE_SIZE,0)
 
91
        movl    r3=5<<IA64_RR_IDX_POS           // region 5
 
92
        ;;
 
93
        mov     rr[r3]=r2
 
94
        ;;
 
95
        /*
 
96
         * Region 7 addresses are only for directly mapped physically
 
97
         * addresses.
 
98
         */
 
99
        movl    r2=IA64_RR_VAL(PTE_PS_16K,0)
 
100
        movl    r3=7<<IA64_RR_IDX_POS           // region 7
 
101
        ;;
 
102
        mov     rr[r3]=r2
 
103
        ;;
 
104
        /*
 
105
         * Setup protection keys for region 5 and 7.
 
106
         */
 
107
        mov     r2=(IA64_KEY_REG5 << IA64_PKR_KEY) | IA64_PKR_VALID
 
108
        mov     r3=(IA64_KEY_REG7 << IA64_PKR_KEY) | IA64_PKR_VALID
 
109
        mov     r14=0x1
 
110
        ;;
 
111
        mov     pkr[r0]=r2      /* Region 5 */
 
112
        mov     pkr[r14]=r3     /* Region 7 */
 
113
        ;;
 
114
        /*
 
115
         * Now pin mappings into the TLB for kernel text and data
 
116
         */
 
117
        mov     r18=(KERNEL_TR_PAGE_SIZE<<IA64_ITIR_PS)| \
 
118
                        (IA64_KEY_REG5<<IA64_ITIR_KEY)
 
119
        movl    r17=KERNEL_START
 
120
        ;;
 
121
        mov     cr.itir=r18
 
122
        mov     cr.ifa=r17
 
123
        mov     r16=IA64_TR_KERNEL
 
124
        mov     r3=ip
 
125
        movl    r18=PTE_KERNEL_ATTR
 
126
        ;;
 
127
        dep     r2=0,r3,0,KERNEL_TR_PAGE_SIZE
 
128
        ;;
 
129
        or      r18=r2,r18
 
130
        ;;
 
131
        srlz.i
 
132
        ;;
 
133
        itr.i   itr[r16]=r18
 
134
        ;;
 
135
        itr.d   dtr[r16]=r18
 
136
        ;;
 
137
        srlz.i
 
138
 
 
139
        /*  Switch into virtual mode */
 
140
        movl    r16=STARTUP_PSR
 
141
        ;;
 
142
        mov     cr.ipsr=r16
 
143
        movl    r17=1f
 
144
        ;;
 
145
        mov     cr.iip=r17
 
146
        mov     cr.ifs=r0
 
147
        ;;
 
148
        rfi
 
149
        ;;
 
150
1:      /* now we are in virtual mode */
 
151
 
 
152
        movl    r3=ia64_trap_table
 
153
        ;;
 
154
        mov     cr.iva=r3
 
155
        ;;
 
156
 
 
157
        movl    r2=IA64_FPSR_DEFAULT
 
158
        movl    r3=IA64_DCR_DEFAULT
 
159
        ;;
 
160
        srlz.i
 
161
        movl    gp=__gp
 
162
 
 
163
        mov     ar.fpsr=r2
 
164
        mov     cr.dcr=r3
 
165
        ;;
 
166
        movl    r2=kstack
 
167
        movl    r5=KSTACK_PAGES * PAGE_SIZE - 16
 
168
        mov     ar.rsc=0        // place RSE in enforced lazy mode
 
169
        ;;
 
170
        loadrs                  // clear the dirty partition
 
171
        ;;
 
172
        mov     ar.bspstore=r2  // establish the new RSE stack
 
173
        add     sp=r2,r5
 
174
        ;;
 
175
        mov     ar.rsc=IA64_RSE_EAGER   // place RSE in eager mode
 
176
 
 
177
        ;;
 
178
        movl    r2=ia64_boot_paramP
 
179
        mov     r3=7            // make address virtual region 7.
 
180
        ;;
 
181
        dep     r28=r3,r28,61,3
 
182
        ;;
 
183
                                // save the address of the boot param area
 
184
                                // passed by the bootloader
 
185
        st8     [r2]=r28
 
186
        ;;
 
187
 
 
188
        /* Set xsi base. I use here XSI_BASE. */
 
189
#define FW_HYPERCALL_SET_SHARED_INFO_VA                 0x600
 
190
        mov r2=FW_HYPERCALL_SET_SHARED_INFO_VA
 
191
        movl r28=XSI_BASE
 
192
        ;;
 
193
        break 0x1000
 
194
        ;;
 
195
        /*
 
196
         * I set up here the pointer to the global start_info structure.
 
197
         * This structure will be initialized in arch_init().
 
198
         */
 
199
        movl    out0=start_info_union
 
200
                // Prepare out0 - the pointer to start_info_t.
 
201
        movl    r14=XSI_BASE
 
202
        ;;
 
203
        add     r15=START_INFO_PFN,r14  // add offset to XSI_BASE
 
204
        ;;
 
205
        START_INFO_PFN_ld       r14=[r15]       // load the start_info_pfn
 
206
        add     r16=7, r0
 
207
        ;;
 
208
#if defined(BIG_ENDIAN)
 
209
        mux1    r14=r14,@rev            // swap because mini-os is in BE
 
210
#endif
 
211
        ;;
 
212
        shl     r15=r14,PAGE_SHIFT_XEN_16K      // pfn << PAGE_SHIFT_XEN_16K
 
213
        shl     r16=r16,IA64_RR_IDX_POS         // (7<<IA64_RR_IDX_POS)
 
214
        ;;
 
215
        or      out0=r16, r15                   // make a region 7 address
 
216
        ;;
 
217
        ssm     psr.i | psr.ic
 
218
        ;;
 
219
        srlz.i
 
220
        ;;
 
221
        br.call.sptk.many rp=start_kernel
 
222
        ;;
 
223
        add     r2=3,r0
 
224
        ;;
 
225
        ld8     r3=[r2]
 
226
        ;;
 
227
 
 
228
self:   hint @pause
 
229
        br.sptk.many self               // endless loop
 
230
END(_start)
 
231
 
 
232
 
 
233
ENTRY(do_nop)
 
234
        nop     0x01
 
235
        add     r15=1,r15
 
236
        br.ret.sptk.many rp
 
237
END(do_nop)