source: mainline/boot/arch/sparc64/src/asm.S@ b9c229b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b9c229b was b9c229b, checked in by Jakub Jermar <jakub@…>, 14 years ago

Allocate an ABI-compliant stack frame.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[b7b5f83]1#
[df4ed85]2# Copyright (c) 2006 Martin Decky
[4872160]3# Copyright (c) 2006 Jakub Jermar
[b7b5f83]4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# - Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# - Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
15# - The name of the author may not be used to endorse or promote products
16# derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
[4872160]30#include <arch/arch.h>
31
32#define ICACHE_SIZE 8192
33#define ICACHE_LINE_SIZE 32
34#define ICACHE_SET_BIT (1 << 13)
35#define ASI_ICACHE_TAG 0x67
[2e672fd]36
[e731b0d]37.register %g2, #scratch
38.register %g3, #scratch
[4872160]39.register %g6, #scratch
40.register %g7, #scratch
[da349da0]41
[4872160]42.global start
[b7b5f83]43.global halt
44.global jump_to_kernel
45
[4872160]46.section BOOTSTRAP, "ax"
47
48start:
49 ba %xcc, 1f
50 nop
51
52/*
53 * This header forces SILO to load the image at 0x4000.
54 * More precisely, SILO will think this is an old version of Linux.
55 */
56.ascii "HdrS"
57.word 0
58.half 0
59.half 0
60.half 0
61.half 0
62.word 0
63.word 0
64
65.align 8
661:
67 ! Disable interrupts and disable address masking.
68
69 wrpr %g0, PSTATE_PRIV_BIT, %pstate
70
71 wrpr %g0, NWINDOWS - 2, %cansave ! Set maximum saveable windows
72 wrpr %g0, 0, %canrestore ! Get rid of windows we will never need again
73 wrpr %g0, 0, %otherwin ! Make sure the window state is consistent
74 wrpr %g0, NWINDOWS - 1, %cleanwin ! Prevent needless clean_window traps for kernel
75
76 set initial_stack, %sp
77 add %sp, -STACK_BIAS, %sp
78
79 set ofw_cif, %l0
80
81 ! Initialize OpenFirmware
82
83 call ofw_init
84 stx %o4, [%l0]
85
86 ba %xcc, bootstrap
87 nop
88
89.align STACK_ALIGNMENT
90 .space STACK_SIZE
91initial_stack:
92 .space STACK_WINDOW_SAVE_AREA_SIZE
93
94.text
95
[b7b5f83]96halt:
[a1a83e5e]97 ba %xcc, halt
[b7b5f83]98 nop
[c82950a]99
[b7b5f83]100jump_to_kernel:
[0af4f9e]101 /*
[4872160]102 * Guarantee cache coherence:
[1eb154f]103 * 1. Make sure that the code we have moved has drained to main memory.
104 * 2. Invalidate I-cache.
105 * 3. Flush instruction pipeline.
[965dc18]106 */
[e731b0d]107
[965dc18]108 /*
109 * US3 processors have a write-invalidate cache, so explicitly
110 * invalidating it is not required. Whether to invalidate I-cache
[4872160]111 * or not is decided according to the value of the 3rd argument
112 * (subarch).
[965dc18]113 */
[b97b348]114 cmp %o2, SUBARCH_US3
[a1a83e5e]115 be %xcc, 1f
[965dc18]116 nop
[e731b0d]117
118 0:
119 call icache_flush
120 nop
[4872160]121
[e731b0d]122 1:
123 membar #StoreStore
[965dc18]124
125 /*
126 * Flush the instruction pipeline.
127 */
[e731b0d]128 flush %i7
129
[4872160]130 ! Jump to kernel
[b97b348]131 jmp %o3
[94d614e]132 nop
[2e672fd]133
[1eb154f]134# Flush I-cache
135icache_flush:
[e731b0d]136 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1
137 stxa %g0, [%g1] ASI_ICACHE_TAG
138
139 0:
140 membar #Sync
141 subcc %g1, ICACHE_LINE_SIZE, %g1
142 bnz,pt %xcc, 0b
143
144 stxa %g0, [%g1] ASI_ICACHE_TAG
145 membar #Sync
[1eb154f]146 retl
[4872160]147
[1eb154f]148 ! SF Erratum #51
[4872160]149
[1eb154f]150 nop
[e731b0d]151
[2e672fd]152.global ofw
153ofw:
[b9c229b]154 save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
[2e672fd]155 set ofw_cif, %l0
156 ldx [%l0], %l0
[e731b0d]157
[4872160]158 rdpr %pstate, %l1
159 and %l1, ~PSTATE_AM_BIT, %l2
160 wrpr %l2, 0, %pstate
[e731b0d]161
[2e672fd]162 jmpl %l0, %o7
163 mov %i0, %o0
[e731b0d]164
[2e672fd]165 wrpr %l1, 0, %pstate
[e731b0d]166
[2e672fd]167 ret
168 restore %o0, 0, %o0
Note: See TracBrowser for help on using the repository browser.