1*0Sstevel@tonic-gate/* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate/* 23*0Sstevel@tonic-gate * Copyright (c) 1986-1997, Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate/* 30*0Sstevel@tonic-gate * standalone startup code for sun4u LP64 secondary booters. 31*0Sstevel@tonic-gate */ 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate#include <sys/asm_linkage.h> 34*0Sstevel@tonic-gate#include <sys/privregs.h> 35*0Sstevel@tonic-gate#include <sys/stack.h> 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate#if defined(lint) 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate/*ARGSUSED*/ 40*0Sstevel@tonic-gatevoid 41*0Sstevel@tonic-gate_start(void *a, ...) 42*0Sstevel@tonic-gate{} 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate#else 45*0Sstevel@tonic-gate .seg ".text" 46*0Sstevel@tonic-gate .align 8 47*0Sstevel@tonic-gate .global end 48*0Sstevel@tonic-gate .global edata 49*0Sstevel@tonic-gate .global main 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate .seg ".bss" 52*0Sstevel@tonic-gate .align 8 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate_local_p1275cif: 55*0Sstevel@tonic-gate .skip 8 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate! 58*0Sstevel@tonic-gate! Create a stack just below _start. 59*0Sstevel@tonic-gate! 60*0Sstevel@tonic-gate#define STACK_SIZE 0x14000 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate .skip STACK_SIZE 63*0Sstevel@tonic-gate.ebootstack: ! end --top-- of boot stack 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate! 66*0Sstevel@tonic-gate! Enter here for all disk/secondary booters loaded by a bootblk program or 67*0Sstevel@tonic-gate! inetboot loaded by OBP. 68*0Sstevel@tonic-gate! Careful: don't touch %o4 until the save, since it contains the 69*0Sstevel@tonic-gate! address of the IEEE 1275 SPARC v9 CIF handler; the linkage to the prom. 70*0Sstevel@tonic-gate! 71*0Sstevel@tonic-gate .seg ".text" 72*0Sstevel@tonic-gate .global prom_exit_to_mon 73*0Sstevel@tonic-gate .type prom_exit_to_mon, #function 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate ENTRY(_start) 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate ! 78*0Sstevel@tonic-gate ! The stacks in bss now; use the stack we came in on (prom is supposed 79*0Sstevel@tonic-gate ! to call us with a minimum of an 8k stack, bzero bss (and thus our 80*0Sstevel@tonic-gate ! new stack), then switch to the new stack. Do all this without losing 81*0Sstevel@tonic-gate ! track of the p1275cif address cached in %o4. 82*0Sstevel@tonic-gate ! 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate ! 87*0Sstevel@tonic-gate ! Zero the bss [edata to end] 88*0Sstevel@tonic-gate ! 89*0Sstevel@tonic-gate setn edata, %g1, %o0 90*0Sstevel@tonic-gate setn end, %g1, %i2 91*0Sstevel@tonic-gate call bzero 92*0Sstevel@tonic-gate sub %i2, %o0, %o1 ! size 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate restore %g0, %g0, %g0 ! Trivial restore 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate ! 97*0Sstevel@tonic-gate ! Switch to our new stack. 98*0Sstevel@tonic-gate ! 99*0Sstevel@tonic-gate setn (.ebootstack - STACK_BIAS), %g1, %o1 100*0Sstevel@tonic-gate save %o1, -SA(MINFRAME), %sp 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate ! 103*0Sstevel@tonic-gate ! Set supervisor mode, interrupt level >= 13, traps enabled 104*0Sstevel@tonic-gate ! We don't set PSTATE_AM even though all our addresses are under 4G. 105*0Sstevel@tonic-gate ! 106*0Sstevel@tonic-gate wrpr %g0, PSTATE_PEF+PSTATE_PRIV+PSTATE_IE, %pstate 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate sethi %hi(_local_p1275cif), %o1 109*0Sstevel@tonic-gate stx %i4, [%o1 + %lo(_local_p1275cif)] 110*0Sstevel@tonic-gate call main ! main(prom-cookie) 111*0Sstevel@tonic-gate mov %i4, %o0 ! SPARCV9/CIF 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate ! print stupid error message here! 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate call prom_enter_mon ! can't happen .. :-) 116*0Sstevel@tonic-gate nop 117*0Sstevel@tonic-gate SET_SIZE(_start) 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate#endif /* lint */ 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate#if defined(lint) 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate/* ARGSUSED */ 124*0Sstevel@tonic-gatevoid 125*0Sstevel@tonic-gateexitto(int (*entrypoint)(void *romvec, void *dvec, void *bootops, 126*0Sstevel@tonic-gate void *bootvec)) 127*0Sstevel@tonic-gate{} 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate/* ARGSUSED */ 130*0Sstevel@tonic-gatevoid 131*0Sstevel@tonic-gateexitto64(int (*entrypoint)(void *romvec, void *dvec, void *bootops, 132*0Sstevel@tonic-gate void *bootvec), void *bootvec) 133*0Sstevel@tonic-gate{} 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate#else /* lint */ 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate ENTRY(exitto) 138*0Sstevel@tonic-gate ! 139*0Sstevel@tonic-gate ! Setup args for client. 140*0Sstevel@tonic-gate ! 141*0Sstevel@tonic-gate ! 32 bit frame, 64 bit sized 142*0Sstevel@tonic-gate sub %g0, SA(MINFRAME) - STACK_BIAS, %g1 143*0Sstevel@tonic-gate save %sp, %g1, %sp 144*0Sstevel@tonic-gate sethi %hi(_local_p1275cif), %o0 ! 1275 CIF handler for callee. 145*0Sstevel@tonic-gate ldx [%o0 + %lo(_local_p1275cif)], %o0 146*0Sstevel@tonic-gate clr %o1 ! boot passes no dvec 147*0Sstevel@tonic-gate setn bootops, %g1, %o2 148*0Sstevel@tonic-gate sethi %hi(elfbootvec), %o3 ! pass elf bootstrap vector 149*0Sstevel@tonic-gate ldx [%o3 + %lo(elfbootvec)], %o3 150*0Sstevel@tonic-gate rdpr %pstate, %l1 ! Get the present pstate value 151*0Sstevel@tonic-gate wrpr %l1, PSTATE_AM, %pstate ! Set PSTATE_AM = 1 152*0Sstevel@tonic-gate jmpl %i0, %o7 ! call thru register to the standalone 153*0Sstevel@tonic-gate mov %o0, %o4 ! 1210378: Pass cif in both %o0 & %o4 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate ! eek - we returned -- switch back to a 64-bit frame 156*0Sstevel@tonic-gate ! then panic in a slightly informative way. 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate restore %g0, %g0, %g0 159*0Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp 160*0Sstevel@tonic-gate sethi %hi(.msg), %o0 161*0Sstevel@tonic-gate call prom_panic 162*0Sstevel@tonic-gate or %o0, %lo(.msg), %o0 163*0Sstevel@tonic-gate.msg: .asciz "exitto returned from client program" 164*0Sstevel@tonic-gate SET_SIZE(exitto) 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate ENTRY(exitto64) 167*0Sstevel@tonic-gate ! 168*0Sstevel@tonic-gate ! Setup args for client. 169*0Sstevel@tonic-gate ! 170*0Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp 171*0Sstevel@tonic-gate sethi %hi(_local_p1275cif), %o0 ! 1275 CIF handler for callee. 172*0Sstevel@tonic-gate ldx [%o0 + %lo(_local_p1275cif)], %o0 173*0Sstevel@tonic-gate mov %i1, %o3 ! bootvec 174*0Sstevel@tonic-gate clr %o1 ! boot passes no dvec 175*0Sstevel@tonic-gate setn bootops, %g1, %o2 176*0Sstevel@tonic-gate jmpl %i0, %o7 ! call thru register to the standalone 177*0Sstevel@tonic-gate mov %o0, %o4 ! 1210378: Pass cif in both %o0 & %o4 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate ! eek - we returned -- panic in a slightly informative way. 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate sethi %hi(.msg64), %o0 182*0Sstevel@tonic-gate call prom_panic 183*0Sstevel@tonic-gate or %o0, %lo(.msg64), %o0 184*0Sstevel@tonic-gate.msg64: .asciz "exitto64 returned from client program" 185*0Sstevel@tonic-gate SET_SIZE(exitto64) 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate#endif /* lint */ 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate#if defined(lint) 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate/* 192*0Sstevel@tonic-gate * The interface for our 64-bit client program 193*0Sstevel@tonic-gate * calling the 64-bit romvec OBP. 194*0Sstevel@tonic-gate */ 195*0Sstevel@tonic-gate 196*0Sstevel@tonic-gate#include <sys/promif.h> 197*0Sstevel@tonic-gate#include <sys/prom_isa.h> 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate/* ARGSUSED */ 200*0Sstevel@tonic-gateint 201*0Sstevel@tonic-gateclient_handler(void *cif_handler, void *arg_array) 202*0Sstevel@tonic-gate{ return (0); } 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate#else /* lint */ 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate ENTRY(client_handler) 207*0Sstevel@tonic-gate mov %o7, %g1 208*0Sstevel@tonic-gate mov %o0, %g5 209*0Sstevel@tonic-gate mov %o1, %o0 210*0Sstevel@tonic-gate jmp %g5 211*0Sstevel@tonic-gate mov %g1, %o7 212*0Sstevel@tonic-gate SET_SIZE(client_handler) 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate#endif /* lint */ 215