hammer - Add memory use limit option for dedup runs
[dragonfly.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: src/sys/boot/sparc64/loader/locore.S,v 1.6 2002/05/29 05:49:58 jake Exp $
10  * $DragonFly: src/sys/boot/sparc64/loader/locore.S,v 1.1 2003/11/10 06:08:40 dillon Exp $
11  */
12
13 #define LOCORE
14
15 #include <machine/asi.h>
16 #include <machine/asm.h>
17 #include <machine/pstate.h>
18 #include <machine/smp.h>
19 #include <machine/upa.h>
20
21 #define PAGE_SIZE       8192
22 #define PAGE_SHIFT      13
23
24 #define SPOFF           2047
25 #define STACK_SIZE      (2 * PAGE_SIZE)
26
27 ENTRY(_start)
28         /* limit interrupts */
29         wrpr    %g0, 13, %pil
30
31         /*
32          * PSTATE: privileged, interrupts enabled, floating point
33          * unit enabled
34          */
35         wrpr    %g0, PSTATE_PRIV|PSTATE_IE|PSTATE_PEF, %pstate
36         wr      %g0, 0x4, %fprs
37
38         setx    stack + STACK_SIZE - SPOFF - CCFSZ, %l7, %l6
39         mov     %l6, %sp
40         call    main
41          mov    %o4, %o0
42         sir
43
44 /*
45  * %o0 input VA constant
46  * %o1 current iTLB offset
47  * %o2 current iTLB TTE tag
48  */
49 ENTRY(itlb_va_to_pa)
50         clr     %o1
51 0:      ldxa    [%o1] ASI_ITLB_TAG_READ_REG, %o2
52         cmp     %o2, %o0
53         bne,a   %xcc, 1f
54          nop
55         /* return PA of matching entry */
56         ldxa    [%o1] ASI_ITLB_DATA_ACCESS_REG, %o0
57         sllx    %o0, 23, %o0
58         srlx    %o0, PAGE_SHIFT+23, %o0
59         sllx    %o0, PAGE_SHIFT, %o0
60         retl
61          mov    %o0, %o1
62 1:      cmp     %o1, 63<<3
63         blu     %xcc, 0b
64          add    %o1, 8, %o1
65         clr     %o0
66         retl
67          not    %o0
68
69 ENTRY(dtlb_va_to_pa)
70         clr     %o1
71 0:      ldxa    [%o1] ASI_DTLB_TAG_READ_REG, %o2
72         cmp     %o2, %o0
73         bne,a   %xcc, 1f
74          nop
75         /* return PA of matching entry */
76         ldxa    [%o1] ASI_DTLB_DATA_ACCESS_REG, %o0
77         sllx    %o0, 23, %o0
78         srlx    %o0, PAGE_SHIFT+23, %o0
79         sllx    %o0, PAGE_SHIFT, %o0
80         retl
81          mov    %o0, %o1
82 1:      cmp     %o1, 63<<3
83         blu     %xcc, 0b
84          add    %o1, 8, %o1
85         clr     %o0
86         retl
87          not    %o0
88
89 /*
90  * %o0 = vpn
91  * %o1 = tte data
92  */
93 ENTRY(itlb_enter)
94         rdpr    %pstate, %o4
95         wrpr    %o4, PSTATE_IE, %pstate
96         mov     AA_IMMU_TAR, %o3
97         stxa    %o0, [%o3] ASI_IMMU
98         stxa    %o1, [%g0] ASI_ITLB_DATA_IN_REG
99         membar  #Sync
100         retl
101          wrpr   %o4, 0, %pstate
102
103 ENTRY(dtlb_enter)
104         rdpr    %pstate, %o4
105         wrpr    %o4, PSTATE_IE, %pstate
106         mov     AA_DMMU_TAR, %o3
107         stxa    %o0, [%o3] ASI_DMMU
108         stxa    %o1, [%g0] ASI_DTLB_DATA_IN_REG
109         membar  #Sync
110         retl
111          wrpr   %o4, 0, %pstate
112
113         .comm   stack, STACK_SIZE, 32
114         .comm   smp_stack, STACK_SIZE, 32