v2.4.10.4 -> v2.4.10.5
[linux-flexiantxendom0-3.2.10.git] / arch / sparc64 / kernel / head.S
1 /* $Id: head.S,v 1.82 2001/10/04 23:37:04 davem Exp $
2  * head.S: Initial boot code for the Sparc64 port of Linux.
3  *
4  * Copyright (C) 1996,1997 David S. Miller (davem@caip.rutgers.edu)
5  * Copyright (C) 1996 David Sitsky (David.Sitsky@anu.edu.au)
6  * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7  * Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx)
8  */
9
10 #include <linux/config.h>
11 #include <linux/version.h>
12 #include <linux/errno.h>
13 #include <asm/asm_offsets.h>
14 #include <asm/asi.h>
15 #include <asm/pstate.h>
16 #include <asm/ptrace.h>
17 #include <asm/spitfire.h>
18 #include <asm/page.h>
19 #include <asm/pgtable.h>
20 #include <asm/errno.h>
21 #include <asm/signal.h>
22 #include <asm/processor.h>
23 #include <asm/lsu.h>
24 #include <asm/dcr.h>
25 #include <asm/dcu.h>
26 #include <asm/head.h>
27 #include <asm/ttable.h>
28         
29 /* This section from from _start to sparc64_boot_end should fit into
30  * 0x0000.0000.0040.4000 to 0x0000.0000.0040.8000 and will be sharing space
31  * with bootup_user_stack, which is from 0x0000.0000.0040.4000 to
32  * 0x0000.0000.0040.6000 and empty_bad_page, which is from
33  * 0x0000.0000.0040.6000 to 0x0000.0000.0040.8000. 
34  */
35
36         .text
37         .globl  start, _start, stext, _stext
38 _start:
39 start:
40 _stext:
41 stext:
42 bootup_user_stack:
43 ! 0x0000000000404000
44         b       sparc64_boot
45          flushw                                 /* Flush register file.      */
46
47 /* This stuff has to be in sync with SILO and other potential boot loaders
48  * Fields should be kept upward compatible and whenever any change is made,
49  * HdrS version should be incremented.
50  */
51         .global root_flags, ram_flags, root_dev
52         .global sparc_ramdisk_image, sparc_ramdisk_size
53         .globl  silo_args
54
55         .ascii  "HdrS"
56         .word   LINUX_VERSION_CODE
57         .half   0x0203          /* HdrS version */
58 root_flags:
59         .half   1
60 root_dev:
61         .half   0
62 ram_flags:
63         .half   0
64 sparc_ramdisk_image:
65         .word   0
66 sparc_ramdisk_size:
67         .word   0
68         .xword  reboot_command
69         .xword  bootstr_len
70         .word   _end
71
72         /* We must be careful, 32-bit OpenBOOT will get confused if it
73          * tries to save away a register window to a 64-bit kernel
74          * stack address.  Flush all windows, disable interrupts,
75          * remap if necessary, jump onto kernel trap table, then kernel
76          * stack, or else we die.
77          *
78          * PROM entry point is on %o4
79          */
80 sparc64_boot:
81         rdpr    %ver, %g1
82         sethi   %hi(0x003e0014), %g5
83         srlx    %g1, 32, %g1
84         or      %g5, %lo(0x003e0014), %g5
85         cmp     %g1, %g5
86         bne,pt  %icc, spitfire_boot
87          nop
88
89 cheetah_boot:
90         mov     DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1
91         wr      %g1, %asr18
92
93         sethi   %uhi(DCU_ME | DCU_RE | /*DCU_PE |*/ DCU_HPE | DCU_SPE | DCU_SL | DCU_WE), %g5
94         or      %g5, %ulo(DCU_ME | DCU_RE | /*DCU_PE |*/ DCU_HPE | DCU_SPE | DCU_SL | DCU_WE), %g5
95         sllx    %g5, 32, %g5
96         or      %g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5
97         stxa    %g5, [%g0] ASI_DCU_CONTROL_REG
98         membar  #Sync
99
100         mov     TSB_EXTENSION_P, %g3
101         stxa    %g0, [%g3] ASI_DMMU
102         stxa    %g0, [%g3] ASI_IMMU
103         membar  #Sync
104
105         mov     TSB_EXTENSION_S, %g3
106         stxa    %g0, [%g3] ASI_DMMU
107         membar  #Sync
108
109         mov     TSB_EXTENSION_N, %g3
110         stxa    %g0, [%g3] ASI_DMMU
111         stxa    %g0, [%g3] ASI_IMMU
112         membar  #Sync
113
114         wrpr    %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate
115         wr      %g0, 0, %fprs
116
117         /* Just like for Spitfire, we probe itlb-2 for a mapping which
118          * matches our current %pc.  We take the physical address in
119          * that mapping and use it to make our own.
120          */
121
122         /* %g5 holds the tlb data */
123         sethi   %uhi(_PAGE_VALID | _PAGE_SZ4MB), %g5
124         sllx    %g5, 32, %g5
125         or      %g5, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W | _PAGE_G), %g5
126
127         /* Put PADDR tlb data mask into %g3. */
128         sethi   %uhi(_PAGE_PADDR), %g3
129         or      %g3, %ulo(_PAGE_PADDR), %g3
130         sllx    %g3, 32, %g3
131         sethi   %hi(_PAGE_PADDR), %g7
132         or      %g7, %lo(_PAGE_PADDR), %g7
133         or      %g3, %g7, %g3
134
135         set     2 << 16, %l0            /* TLB entry walker. */
136         set     0x1fff, %l2             /* Page mask. */
137         rd      %pc, %l3
138         andn    %l3, %l2, %g2           /* vaddr comparator */
139
140 1:      ldxa    [%l0] ASI_ITLB_TAG_READ, %g1
141         membar  #Sync
142         andn    %g1, %l2, %g1
143         cmp     %g1, %g2
144         be,pn   %xcc, cheetah_got_tlbentry
145          nop
146         and     %l0, (127 << 3), %g1
147         cmp     %g1, (127 << 3)
148         blu,pt  %xcc, 1b
149          add    %l0, (1 << 3), %l0
150
151 cheetah_got_tlbentry:
152         ldxa    [%l0] ASI_ITLB_DATA_ACCESS, %g1
153         membar  #Sync
154         and     %g1, %g3, %g1
155         sub     %g1, %g2, %g1
156         or      %g5, %g1, %g5
157
158         /* Clear out any KERNBASE area entries. */
159         set     2 << 16, %l0
160         sethi   %hi(KERNBASE), %g3
161         sethi   %hi(KERNBASE<<1), %g7
162         mov     TLB_TAG_ACCESS, %l7
163
164         /* First, check ITLB */
165 1:      ldxa    [%l0] ASI_ITLB_TAG_READ, %g1
166         membar  #Sync
167         andn    %g1, %l2, %g1
168         cmp     %g1, %g3
169         blu,pn  %xcc, 2f
170          cmp    %g1, %g7
171         bgeu,pn %xcc, 2f
172          nop
173         stxa    %g0, [%l7] ASI_IMMU
174         membar  #Sync
175         stxa    %g0, [%l0] ASI_ITLB_DATA_ACCESS
176         membar  #Sync
177
178 2:      and     %l0, (127 << 3), %g1
179         cmp     %g1, (127 << 3)
180         blu,pt  %xcc, 1b
181          add    %l0, (1 << 3), %l0
182
183         /* Next, check DTLB */
184         set     2 << 16, %l0
185 1:      ldxa    [%l0] ASI_DTLB_TAG_READ, %g1
186         membar  #Sync
187         andn    %g1, %l2, %g1
188         cmp     %g1, %g3
189         blu,pn  %xcc, 2f
190          cmp    %g1, %g7
191         bgeu,pn %xcc, 2f
192          nop
193         stxa    %g0, [%l7] ASI_DMMU
194         membar  #Sync
195         stxa    %g0, [%l0] ASI_DTLB_DATA_ACCESS
196         membar  #Sync
197         
198 2:      and     %l0, (511 << 3), %g1
199         cmp     %g1, (511 << 3)
200         blu,pt  %xcc, 1b
201          add    %l0, (1 << 3), %l0
202
203         /* Now lock the TTE we created into ITLB-0 and DTLB-0,
204          * entry 15.
205          */
206         sethi   %hi(KERNBASE), %g3
207         set     (0 << 16) | (15 << 3), %g7
208         stxa    %g3, [%l7] ASI_DMMU
209         membar  #Sync
210         stxa    %g5, [%g7] ASI_DTLB_DATA_ACCESS
211         membar  #Sync
212         stxa    %g3, [%l7] ASI_IMMU
213         membar  #Sync
214         stxa    %g5, [%g7] ASI_ITLB_DATA_ACCESS
215         membar  #Sync
216         flush   %g3
217         membar  #Sync
218         ba,pt   %xcc, 1f
219          nop
220
221 1:      set     sun4u_init, %g2
222         jmpl    %g2 + %g0, %g0
223          nop
224
225 spitfire_boot:
226         /* Typically PROM has already enabled both MMU's and both on-chip
227          * caches, but we do it here anyway just to be paranoid.
228          */
229         mov     (LSU_CONTROL_IC|LSU_CONTROL_DC|LSU_CONTROL_IM|LSU_CONTROL_DM), %g1
230         stxa    %g1, [%g0] ASI_LSU_CONTROL
231         membar  #Sync
232
233         /*
234          * Make sure we are in privileged mode, have address masking,
235          * using the ordinary globals and have enabled floating
236          * point.
237          *
238          * Again, typically PROM has left %pil at 13 or similar, and
239          * (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE) in %pstate.
240          */
241         wrpr    %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate
242         wr      %g0, 0, %fprs
243
244 spitfire_create_mappings:
245         /* %g5 holds the tlb data */
246         sethi   %uhi(_PAGE_VALID | _PAGE_SZ4MB), %g5
247         sllx    %g5, 32, %g5
248         or      %g5, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W | _PAGE_G), %g5
249
250         /* Base of physical memory cannot reliably be assumed to be
251          * at 0x0!  Figure out where it happens to be. -DaveM
252          */
253
254         /* Put PADDR tlb data mask into %g3. */
255         sethi   %uhi(_PAGE_PADDR_SF), %g3
256         or      %g3, %ulo(_PAGE_PADDR_SF), %g3
257         sllx    %g3, 32, %g3
258         sethi   %hi(_PAGE_PADDR_SF), %g7
259         or      %g7, %lo(_PAGE_PADDR_SF), %g7
260         or      %g3, %g7, %g3
261
262         /* Walk through entire ITLB, looking for entry which maps
263          * our %pc currently, stick PADDR from there into %g5 tlb data.
264          */
265         clr     %l0                     /* TLB entry walker. */
266         set     0x1fff, %l2             /* Page mask. */
267         rd      %pc, %l3
268         andn    %l3, %l2, %g2           /* vaddr comparator */
269 1:
270         /* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */
271         ldxa    [%l0] ASI_ITLB_TAG_READ, %g1
272         nop
273         nop
274         nop
275         andn    %g1, %l2, %g1           /* Get vaddr */
276         cmp     %g1, %g2
277         be,a,pn %xcc, spitfire_got_tlbentry
278          ldxa   [%l0] ASI_ITLB_DATA_ACCESS, %g1
279         cmp     %l0, (63 << 3)
280         blu,pt  %xcc, 1b
281          add    %l0, (1 << 3), %l0
282
283 spitfire_got_tlbentry:
284         /* Nops here again, perhaps Cheetah/Blackbird are better behaved... */
285         nop
286         nop
287         nop
288         and     %g1, %g3, %g1           /* Mask to just get paddr bits.       */
289         sub     %g1, %g2, %g1           /* Get rid of %pc offset to get base. */
290
291         /* NOTE: We hold on to %g1 paddr base as we need it below to lock
292          * NOTE: the PROM cif code into the TLB.
293          */
294
295         or      %g5, %g1, %g5           /* Or it into TAG being built.        */
296
297         clr     %l0                     /* TLB entry walker. */
298         sethi   %hi(KERNBASE), %g3      /* 4M lower limit */
299         sethi   %hi(KERNBASE<<1), %g7   /* 8M upper limit */
300         mov     TLB_TAG_ACCESS, %l7
301 1:
302         /* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */
303         ldxa    [%l0] ASI_ITLB_TAG_READ, %g1
304         nop
305         nop
306         nop
307         andn    %g1, %l2, %g1           /* Get vaddr */
308         cmp     %g1, %g3
309         blu,pn  %xcc, 2f
310          cmp    %g1, %g7
311         bgeu,pn %xcc, 2f
312          nop
313         stxa    %g0, [%l7] ASI_IMMU
314         stxa    %g0, [%l0] ASI_ITLB_DATA_ACCESS
315         membar  #Sync
316 2:
317         cmp     %l0, (63 << 3)
318         blu,pt  %xcc, 1b
319          add    %l0, (1 << 3), %l0
320
321         nop; nop; nop
322
323         clr     %l0                     /* TLB entry walker. */
324 1:
325         /* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */
326         ldxa    [%l0] ASI_DTLB_TAG_READ, %g1
327         nop
328         nop
329         nop
330         andn    %g1, %l2, %g1           /* Get vaddr */
331         cmp     %g1, %g3
332         blu,pn  %xcc, 2f
333          cmp    %g1, %g7
334         bgeu,pn %xcc, 2f
335          nop
336         stxa    %g0, [%l7] ASI_DMMU
337         stxa    %g0, [%l0] ASI_DTLB_DATA_ACCESS
338         membar  #Sync
339 2:
340         cmp     %l0, (63 << 3)
341         blu,pt  %xcc, 1b
342          add    %l0, (1 << 3), %l0
343
344         nop; nop; nop
345
346
347         /* PROM never puts any TLB entries into the MMU with the lock bit
348          * set.  So we gladly use tlb entry 63 for KERNBASE.
349          */
350
351         sethi   %hi(KERNBASE), %g3
352         mov     (63 << 3), %g7
353         stxa    %g3, [%l7] ASI_DMMU             /* KERNBASE into TLB TAG        */
354         stxa    %g5, [%g7] ASI_DTLB_DATA_ACCESS /* TTE into TLB DATA            */
355         membar  #Sync
356         stxa    %g3, [%l7] ASI_IMMU             /* KERNBASE into TLB TAG        */
357         stxa    %g5, [%g7] ASI_ITLB_DATA_ACCESS /* TTE into TLB DATA            */
358         membar  #Sync
359         flush   %g3
360         membar  #Sync
361         ba,pt   %xcc, 1f
362          nop
363 1:
364         set     sun4u_init, %g2
365         jmpl    %g2 + %g0, %g0
366          nop
367
368 sun4u_init:
369         /* Set ctx 0 */
370         mov     PRIMARY_CONTEXT, %g7
371         stxa    %g0, [%g7] ASI_DMMU
372         membar  #Sync
373
374         mov     SECONDARY_CONTEXT, %g7
375         stxa    %g0, [%g7] ASI_DMMU
376         membar  #Sync
377
378         sethi   %uhi(PAGE_OFFSET), %g4
379         sllx    %g4, 32, %g4
380
381         /* We are now safely (we hope) in Nucleus context (0), rewrite
382          * the KERNBASE TTE's so they no longer have the global bit set.
383          * Don't forget to setup TAG_ACCESS first 8-)
384          */
385         mov     TLB_TAG_ACCESS, %g2
386         stxa    %g3, [%g2] ASI_IMMU
387         stxa    %g3, [%g2] ASI_DMMU
388         membar  #Sync
389
390         rdpr    %ver, %g1
391         sethi   %hi(0x003e0014), %g5
392         srlx    %g1, 32, %g1
393         or      %g5, %lo(0x003e0014), %g5
394         cmp     %g1, %g5
395         bne,pt  %icc, spitfire_tlb_fixup
396          nop
397
398 cheetah_tlb_fixup:
399         set     (0 << 16) | (15 << 3), %g7
400         ldxa    [%g7] ASI_ITLB_DATA_ACCESS, %g1
401         andn    %g1, (_PAGE_G), %g1
402         stxa    %g1, [%g7] ASI_ITLB_DATA_ACCESS
403         membar  #Sync
404
405         ldxa    [%g7] ASI_DTLB_DATA_ACCESS, %g1
406         andn    %g1, (_PAGE_G), %g1
407         stxa    %g1, [%g7] ASI_DTLB_DATA_ACCESS
408         membar  #Sync
409
410         /* Kill instruction prefetch queues. */
411         flush   %g3
412         membar  #Sync
413
414         /* Set TLB type to cheetah. */
415         mov     1, %g2
416         sethi   %hi(tlb_type), %g5
417         stw     %g2, [%g5 + %lo(tlb_type)]
418
419         /* Patch copy/page operations to cheetah optimized versions. */
420         call    cheetah_patch_copyops
421          nop
422         call    cheetah_patch_pgcopyops
423          nop
424
425         ba,pt   %xcc, tlb_fixup_done
426          nop
427
428 spitfire_tlb_fixup:
429         mov     (63 << 3), %g7
430         ldxa    [%g7] ASI_ITLB_DATA_ACCESS, %g1
431         andn    %g1, (_PAGE_G), %g1
432         stxa    %g1, [%g7] ASI_ITLB_DATA_ACCESS
433         membar  #Sync
434
435         ldxa    [%g7] ASI_DTLB_DATA_ACCESS, %g1
436         andn    %g1, (_PAGE_G), %g1
437         stxa    %g1, [%g7] ASI_DTLB_DATA_ACCESS
438         membar  #Sync
439
440         /* Kill instruction prefetch queues. */
441         flush   %g3
442         membar  #Sync
443
444         /* Set TLB type to spitfire. */
445         mov     0, %g2
446         sethi   %hi(tlb_type), %g5
447         stw     %g2, [%g5 + %lo(tlb_type)]
448
449 tlb_fixup_done:
450         sethi   %hi(init_task_union), %g6
451         or      %g6, %lo(init_task_union), %g6
452         mov     %sp, %l6
453         mov     %o4, %l7
454
455 #if 0   /* We don't do it like this anymore, but for historical hack value
456          * I leave this snippet here to show how crazy we can be sometimes. 8-)
457          */
458
459         /* Setup "Linux Current Register", thanks Sun 8-) */
460         wr      %g0, 0x1, %pcr
461
462         /* Blackbird errata workaround.  See commentary in
463          * smp.c:smp_percpu_timer_interrupt() for more
464          * information.
465          */
466         ba,pt   %xcc, 99f
467          nop
468         .align  64
469 99:     wr      %g6, %g0, %pic
470         rd      %pic, %g0
471 #endif
472
473         wr      %g0, ASI_P, %asi
474         mov     1, %g5
475         sllx    %g5, THREAD_SHIFT, %g5
476         sub     %g5, (REGWIN_SZ + STACK_BIAS), %g5
477         add     %g6, %g5, %sp
478         mov     0, %fp
479
480         wrpr    %g0, 0, %wstate
481         wrpr    %g0, 0x0, %tl
482
483         /* Clear the bss */
484         sethi   %hi(__bss_start), %o0
485         or      %o0, %lo(__bss_start), %o0
486         sethi   %hi(_end), %o1
487         or      %o1, %lo(_end), %o1
488         call    __bzero
489          sub    %o1, %o0, %o1
490
491         mov     %l6, %o1                        ! OpenPROM stack
492         call    prom_init
493          mov    %l7, %o0                        ! OpenPROM cif handler
494
495         /* Off we go.... */
496         call    start_kernel
497          nop
498         /* Not reached... */
499
500 /* IMPORTANT NOTE: Whenever making changes here, check
501  * trampoline.S as well. -jj */
502         .globl  setup_tba
503 setup_tba:      /* i0 = is_starfire */
504         save    %sp, -160, %sp
505
506         rdpr    %tba, %g7
507         sethi   %hi(prom_tba), %o1
508         or      %o1, %lo(prom_tba), %o1
509         stx     %g7, [%o1]
510
511         /* Setup "Linux" globals 8-) */
512         rdpr    %pstate, %o1
513         mov     %g6, %o2
514         wrpr    %o1, (PSTATE_AG|PSTATE_IE), %pstate
515         sethi   %hi(sparc64_ttable_tl0), %g5
516         wrpr    %g5, %tba
517         mov     %o2, %g6
518
519         /* Set up MMU globals */
520         wrpr    %o1, (PSTATE_MG|PSTATE_IE), %pstate
521
522         /* Set fixed globals used by dTLB miss handler. */
523 #define KERN_HIGHBITS           ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
524 #define KERN_LOWBITS            (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
525
526 #define VPTE_BASE_SPITFIRE      0xfffffffe00000000
527 #if 1
528 #define VPTE_BASE_CHEETAH       VPTE_BASE_SPITFIRE
529 #else
530 #define VPTE_BASE_CHEETAH       0xffe0000000000000
531 #endif
532
533         mov     TSB_REG, %g1
534         stxa    %g0, [%g1] ASI_DMMU
535         membar  #Sync
536         mov     TLB_SFSR, %g1
537         sethi   %uhi(KERN_HIGHBITS), %g2
538         or      %g2, %ulo(KERN_HIGHBITS), %g2
539         sllx    %g2, 32, %g2
540         or      %g2, KERN_LOWBITS, %g2
541
542         rdpr            %ver, %g3
543         sethi           %hi(0x003e0014), %g7
544         srlx            %g3, 32, %g3
545         or              %g7, %lo(0x003e0014), %g7
546         cmp             %g3, %g7
547         bne,pt          %icc, 1f
548          nop
549
550         sethi           %uhi(VPTE_BASE_CHEETAH), %g3
551         or              %g3, %ulo(VPTE_BASE_CHEETAH), %g3
552         ba,pt           %xcc, 2f
553          sllx           %g3, 32, %g3
554 1:
555         sethi           %uhi(VPTE_BASE_SPITFIRE), %g3
556         or              %g3, %ulo(VPTE_BASE_SPITFIRE), %g3
557         sllx            %g3, 32, %g3
558
559 2:
560         clr     %g7
561 #undef KERN_HIGHBITS
562 #undef KERN_LOWBITS
563 #undef VPTE_BASE_SPITFIRE
564 #undef VPTE_BASE_CHEETAH
565
566         /* Setup Interrupt globals */
567         wrpr    %o1, (PSTATE_IG|PSTATE_IE), %pstate
568 #ifndef CONFIG_SMP
569         sethi   %hi(__up_workvec), %g5
570         or      %g5, %lo(__up_workvec), %g6
571 #else
572         /* By definition of where we are, this is boot_cpu. */
573         brz,pt  %i0, not_starfire
574          sethi  %hi(0x1fff4000), %g1
575         or      %g1, %lo(0x1fff4000), %g1
576         sllx    %g1, 12, %g1
577         or      %g1, 0xd0, %g1
578         lduwa   [%g1] ASI_PHYS_BYPASS_EC_E, %g1
579         b,pt    %xcc, set_worklist
580          nop
581
582 not_starfire:
583         rdpr            %ver, %g1
584         sethi           %hi(0x003e0014), %g5
585         srlx            %g1, 32, %g1
586         or              %g7, %lo(0x003e0014), %g5
587         cmp             %g1, %g5
588         bne,pt          %icc, not_cheetah
589          nop
590
591         ldxa            [%g0] ASI_SAFARI_CONFIG, %g1
592         srlx            %g1, 17, %g1
593         ba,pt           %xcc, set_worklist
594          and            %g1, 0x3ff, %g1         ! 10bit Safari Agent ID
595
596 not_cheetah:
597         ldxa    [%g0] ASI_UPA_CONFIG, %g1
598         srlx    %g1, 17, %g1
599         and     %g1, 0x1f, %g1
600
601         /* In theory this is: &(cpu_data[boot_cpu_id].irq_worklists[0]) */
602 set_worklist:
603         sethi   %hi(cpu_data), %g5
604         or      %g5, %lo(cpu_data), %g5
605         sllx    %g1, 7, %g1
606         add     %g5, %g1, %g5
607         add     %g5, 64, %g6
608 #endif
609
610         /* Kill PROM timer */
611         wr      %g0, 0, %tick_cmpr
612
613         rdpr            %ver, %g1
614         sethi           %hi(0x003e0014), %g5
615         srlx            %g1, 32, %g1
616         or              %g7, %lo(0x003e0014), %g5
617         cmp             %g1, %g5
618         bne,pt          %icc, 1f
619          nop
620
621         /* Disable STICK_INT interrupts. */
622         sethi           %hi(0x80000000), %g1
623         sllx            %g1, 32, %g1
624         wr              %g1, %asr25
625
626         /* Ok, we're done setting up all the state our trap mechanims needs,
627          * now get back into normal globals and let the PROM know what is up.
628          */
629 1:
630         wrpr    %g0, %g0, %wstate
631         wrpr    %o1, PSTATE_IE, %pstate
632
633         sethi   %hi(sparc64_ttable_tl0), %g5
634         call    prom_set_trap_table
635          mov    %g5, %o0
636
637         rdpr    %pstate, %o1
638         or      %o1, PSTATE_IE, %o1
639         wrpr    %o1, 0, %pstate
640
641         ret
642          restore
643
644 /*
645  * The following skips make sure the trap table in ttable.S is aligned
646  * on a 32K boundary as required by the v9 specs for TBA register.
647  */
648 sparc64_boot_end:
649         .skip   0x2000 + _start - sparc64_boot_end
650 bootup_user_stack_end:
651         .skip   0x2000
652
653 #ifdef CONFIG_SBUS
654 /* This is just a hack to fool make depend config.h discovering
655    strategy: As the .S files below need config.h, but
656    make depend does not find it for them, we include config.h
657    in head.S */
658 #endif
659
660 ! 0x0000000000408000
661
662 #include "ttable.S"
663 #include "systbls.S"
664
665         .align  1024
666         .globl  swapper_pg_dir
667 swapper_pg_dir:
668         .word   0
669
670 #include "etrap.S"
671 #include "rtrap.S"
672 #include "winfixup.S"
673 #include "entry.S"
674
675         /* This is just anal retentiveness on my part... */
676         .align  16384
677
678         .data
679         .align  8
680         .globl  prom_tba
681 prom_tba:       .xword  0
682         .section        ".fixup",#alloc,#execinstr
683         .globl  __ret_efault
684 __ret_efault:
685         ret
686          restore %g0, -EFAULT, %o0
687