]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/boot/sparc64/loader/locore.S
This commit was generated by cvs2svn to compensate for changes in r178481,
[FreeBSD/FreeBSD.git] / sys / boot / sparc64 / loader / locore.S
1 /*-
2  * Initial implementation:
3  * Copyright (c) 2001 Robert Drehmel
4  * All rights reserved.
5  *
6  * As long as the above copyright statement and this notice remain
7  * unchanged, you can do what ever you want with this file. 
8  *
9  * $FreeBSD$
10  */
11
12 #define LOCORE
13
14 #include <machine/asi.h>
15 #include <machine/asm.h>
16 #include <machine/pstate.h>
17 #include <machine/smp.h>
18 #include <machine/upa.h>
19
20 #define PAGE_SIZE       8192
21 #define PAGE_SHIFT      13
22
23 #define SPOFF           2047
24 #define STACK_SIZE      (2 * PAGE_SIZE)
25
26 ENTRY(_start)
27         /* limit interrupts */
28         wrpr    %g0, 13, %pil
29
30         /*
31          * PSTATE: privileged, interrupts enabled, floating point
32          * unit enabled
33          */
34         wrpr    %g0, PSTATE_PRIV|PSTATE_IE|PSTATE_PEF, %pstate
35         wr      %g0, 0x4, %fprs
36
37         setx    stack + STACK_SIZE - SPOFF - CCFSZ, %l7, %l6
38         mov     %l6, %sp
39         call    main
40          mov    %o4, %o0
41         sir
42
43 /*
44  * %o0 input VA constant
45  * %o1 current iTLB offset
46  * %o2 current iTLB TTE tag
47  */
48 ENTRY(itlb_va_to_pa)
49         clr     %o1
50 0:      ldxa    [%o1] ASI_ITLB_TAG_READ_REG, %o2
51         cmp     %o2, %o0
52         bne,a   %xcc, 1f
53          nop
54         /* return PA of matching entry */
55         ldxa    [%o1] ASI_ITLB_DATA_ACCESS_REG, %o0
56         sllx    %o0, 23, %o0
57         srlx    %o0, PAGE_SHIFT+23, %o0
58         sllx    %o0, PAGE_SHIFT, %o0
59         retl
60          mov    %o0, %o1
61 1:      cmp     %o1, 63<<3
62         blu     %xcc, 0b
63          add    %o1, 8, %o1
64         clr     %o0
65         retl
66          not    %o0
67
68 ENTRY(dtlb_va_to_pa)
69         clr     %o1
70 0:      ldxa    [%o1] ASI_DTLB_TAG_READ_REG, %o2
71         cmp     %o2, %o0
72         bne,a   %xcc, 1f
73          nop
74         /* return PA of matching entry */
75         ldxa    [%o1] ASI_DTLB_DATA_ACCESS_REG, %o0
76         sllx    %o0, 23, %o0
77         srlx    %o0, PAGE_SHIFT+23, %o0
78         sllx    %o0, PAGE_SHIFT, %o0
79         retl
80          mov    %o0, %o1
81 1:      cmp     %o1, 63<<3
82         blu     %xcc, 0b
83          add    %o1, 8, %o1
84         clr     %o0
85         retl
86          not    %o0
87
88 /*
89  * %o0 = vpn
90  * %o1 = tte data
91  */
92 ENTRY(itlb_enter)
93         rdpr    %pstate, %o4
94         wrpr    %o4, PSTATE_IE, %pstate
95         mov     AA_IMMU_TAR, %o3
96         stxa    %o0, [%o3] ASI_IMMU
97         stxa    %o1, [%g0] ASI_ITLB_DATA_IN_REG
98         membar  #Sync
99         retl
100          wrpr   %o4, 0, %pstate
101
102 ENTRY(dtlb_enter)
103         rdpr    %pstate, %o4
104         wrpr    %o4, PSTATE_IE, %pstate
105         mov     AA_DMMU_TAR, %o3
106         stxa    %o0, [%o3] ASI_DMMU
107         stxa    %o1, [%g0] ASI_DTLB_DATA_IN_REG
108         membar  #Sync
109         retl
110          wrpr   %o4, 0, %pstate
111
112         .comm   stack, STACK_SIZE, 32
113         .comm   smp_stack, STACK_SIZE, 32