source: trunk/packages/xen-3.1/xen-3.1/extras/mini-os/arch/ia64/ia64.S @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 4.8 KB
Line 
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
43kstack: .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         */
53ENTRY(_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        /*
106         * Now pin mappings into the TLB for kernel text and data
107         */
108        mov     r18=KERNEL_TR_PAGE_SIZE<<2
109        movl    r17=KERNEL_START
110        ;;
111        mov     cr.itir=r18
112        mov     cr.ifa=r17
113        mov     r16=IA64_TR_KERNEL
114        mov     r3=ip
115        movl    r18=PTE_KERNEL_ATTR
116        ;;
117        dep     r2=0,r3,0,KERNEL_TR_PAGE_SIZE
118        ;;
119        or      r18=r2,r18
120        ;;
121        srlz.i
122        ;;
123        itr.i   itr[r16]=r18
124        ;;
125        itr.d   dtr[r16]=r18
126        ;;
127        srlz.i
128
129        /*  Switch into virtual mode */
130        movl    r16=STARTUP_PSR
131        ;;
132        mov     cr.ipsr=r16
133        movl    r17=1f
134        ;;
135        mov     cr.iip=r17
136        mov     cr.ifs=r0
137        ;;
138        rfi
139        ;;
1401:      /* now we are in virtual mode */
141
142        movl    r3=ia64_trap_table
143        ;;
144        mov     cr.iva=r3
145        ;;
146
147        movl    r2=IA64_FPSR_DEFAULT
148        movl    r3=IA64_DCR_DEFAULT
149        ;;
150        srlz.i
151        movl    gp=__gp
152
153        mov     ar.fpsr=r2
154        mov     cr.dcr=r3
155        ;;
156        movl    r2=kstack
157        movl    r5=KSTACK_PAGES * PAGE_SIZE - 16
158        mov     ar.rsc=0        // place RSE in enforced lazy mode
159        ;;
160        loadrs                  // clear the dirty partition
161        ;;
162        mov     ar.bspstore=r2  // establish the new RSE stack
163        add     sp=r2,r5
164        ;;
165        mov     ar.rsc=IA64_RSE_EAGER   // place RSE in eager mode
166
167        ;;
168        movl    r2=ia64_boot_paramP
169        mov     r3=7            // make address virtual region 7.
170        ;;
171        dep     r28=r3,r28,61,3
172        ;;
173                                // save the address of the boot param area
174                                // passed by the bootloader
175        st8     [r2]=r28
176        ;;
177
178        /* Set xsi base. I use here XSI_BASE. */
179#define FW_HYPERCALL_SET_SHARED_INFO_VA                 0x600
180        mov r2=FW_HYPERCALL_SET_SHARED_INFO_VA
181        movl r28=XSI_BASE
182        ;;
183        break 0x1000
184        ;;
185        /*
186         * I set up here the pointer to the global start_info structure.
187         * This structure will be initialized in arch_init().
188         */
189        movl    out0=start_info_union
190                // Prepare out0 - the pointer to start_info_t.
191        movl    r14=XSI_BASE
192        ;;
193        add     r15=START_INFO_PFN,r14  // add offset to XSI_BASE
194        ;;
195        START_INFO_PFN_ld       r14=[r15]       // load the start_info_pfn
196        add     r16=7, r0
197        ;;
198#if defined(BIG_ENDIAN)
199        mux1    r14=r14,@rev            // swap because mini-os is in BE
200#endif
201        ;;
202        shl     r15=r14,PAGE_SHIFT_XEN_16K      // pfn << PAGE_SHIFT_XEN_16K
203        shl     r16=r16,IA64_RR_IDX_POS         // (7<<IA64_RR_IDX_POS)
204        ;;
205        or      out0=r16, r15                   // make a region 7 address
206        ;;
207
208        br.call.sptk.many rp=start_kernel
209        ;;
210        add     r2=3,r0
211        ;;
212        ld8     r3=[r2]
213        ;;
214
215self:   hint @pause
216        br.sptk.many self               // endless loop
217END(_start)
218
219
220ENTRY(do_nop)
221        nop     0x01
222        add     r15=1,r15
223        br.ret.sptk.many rp
224END(do_nop)
Note: See TracBrowser for help on using the repository browser.