Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: kernel_handler.s | |
5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
7 | * | |
8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; version 2 of the License. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | * For the avoidance of doubt, and except that if any non-GPL license | |
24 | * choice is available it will apply instead, Sun elects to use only | |
25 | * the General Public License version 2 (GPLv2) at this time for any | |
26 | * software where a choice of GPL license versions is made | |
27 | * available with the language indicating that GPLv2 or any later version | |
28 | * may be used, or where a choice of which version of the GPL is applied is | |
29 | * otherwise unspecified. | |
30 | * | |
31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
32 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
33 | * have any questions. | |
34 | * | |
35 | * | |
36 | * ========== Copyright Header End ============================================ | |
37 | */ | |
38 | .global kernel_syscall | |
39 | kernel_syscall: | |
40 | ! save globals | |
41 | stx %g1, [%g7+8] | |
42 | stx %g2, [%g7+16] | |
43 | stx %g3, [%g7+24] | |
44 | stx %g4, [%g7+32] | |
45 | stx %g5, [%g7+40] | |
46 | stx %g6, [%g7+48] | |
47 | ||
48 | setx syscall_jmptab, %g1, %g2 | |
49 | sllx %o1, 3, %g1 | |
50 | add %g2, %g1, %g2 ! %g2 = ptr into jump table based on call # | |
51 | ldx [%g2], %g1 | |
52 | jmp %g1 | |
53 | ||
54 | kernel_sysret: | |
55 | ! restore globals | |
56 | ldx [%g7+8], %g1 | |
57 | ldx [%g7+16], %g2 | |
58 | ldx [%g7+24], %g3 | |
59 | ldx [%g7+32], %g4 | |
60 | ldx [%g7+40], %g5 | |
61 | ldx [%g7+48], %g6 | |
62 | ||
63 | ta T_SYSRET | |
64 | nop | |
65 | ||
66 | ! %o2 = size in bytes | |
67 | ! %o3 = alignment in bytes (has to be power of 2) | |
68 | ! %o4 = returned pointer | |
69 | kernel_memalign: | |
70 | setx heapptr, %g1, %g2 | |
71 | ldx [%g2], %g1 ! %g1 = heapptr | |
72 | mov %o3, %g3 | |
73 | sub %g3, 1, %g3 ! alignment mask | |
74 | and %g3, %g1, %g4 | |
75 | brz %g4, align_done | |
76 | not %g3 | |
77 | and %g3, %g1, %g1 | |
78 | add %g1, %o3, %g1 | |
79 | align_done: | |
80 | mov %g1, %o4 | |
81 | add %g1, %o2, %g1 | |
82 | ba kernel_sysret | |
83 | stx %g1, [%g2] | |
84 | ||
85 | kernel_printhex: | |
86 | ba kernel_sysret ! $ EV trig_pc_d(1,expr(@VA(.KERNEL.kernel_printhex), 16, 16)) -> printhex("diagprinthex", %o2) | |
87 | nop | |
88 | ||
89 | kernel_printdec: | |
90 | ba kernel_sysret ! $ EV trig_pc_d(1,expr(@VA(.KERNEL.kernel_printdec), 16, 16)) -> printdec("diagprintdec", %o2) | |
91 | nop | |
92 | ||
93 | .data | |
94 | syscall_jmptab: | |
95 | .xword 0x0000000000000000 | |
96 | .xword kernel_memalign | |
97 | .xword kernel_printhex | |
98 | .xword kernel_printdec | |
99 | ||
100 | heapptr: | |
101 | .xword 0x0000000000000000 | |
102 | ||
103 | .global start_label_list | |
104 | start_label_list: | |
105 | #if defined(USER_PAGE_CUSTOM_MAP) || !defined(USER_TEXT_MT_MAP) | |
106 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
107 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
108 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
109 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
110 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
111 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
112 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
113 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
114 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
115 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
116 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
117 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
118 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
119 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
120 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
121 | .xword USER_START_LABEL, USER_START_LABEL, USER_START_LABEL, USER_START_LABEL | |
122 | #else | |
123 | changequote([, ])dnl | |
124 | foreachbit([i], 64, M4_user_data_mask, [ | |
125 | .xword [main]i | |
126 | ])dnl | |
127 | changequote(`,')dnl' | |
128 | #endif | |
129 | ||
130 | .align 512 | |
131 | user_globals: | |
132 | ||
133 | #ifndef USER_HEAP_SIZE | |
134 | #define USER_HEAP_SIZE 0x2000 | |
135 | #endif | |
136 | ||
137 | #ifndef USER_PAGE_CUSTOM_MAP | |
138 | SECTION .USER_HEAP DATA_VA=USER_HEAP_DATA_VA | |
139 | changequote([, ])dnl | |
140 | forloop([i], 0, 7, [ | |
141 | ifdef([part_]i[_used],[ | |
142 | attr_data { | |
143 | Name = .USER_HEAP, | |
144 | RA = USER_HEAP_DATA_RA, | |
145 | PA = ra2pa2(USER_HEAP_DATA_RA,i), | |
146 | #ifndef USE_N1_TSB_NAMES | |
147 | [part_]i[_ctx_nonzero_tsb_config_0], | |
148 | #else | |
149 | [part_]i[_d_ctx_nonzero_ps0_tsb], | |
150 | #endif | |
151 | TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0, TTE_IE=0, | |
152 | TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, TTE_L=0, TTE_CP=1, TTE_CV=0, | |
153 | TTE_E=0, TTE_P=0, TTE_W=1 | |
154 | } | |
155 | ||
156 | .data | |
157 | .global user_heap_start | |
158 | user_heap_start: | |
159 | .skip (USER_HEAP_SIZE-0x4) | |
160 | .word 0x0 | |
161 | .end | |
162 | ])dnl | |
163 | ])dnl | |
164 | changequote(`,')dnl' | |
165 | #endif |