* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: bootload.s
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
.ident "@(#)bootload.s 1.2 07/05/03 SMI"
#include <sys/asm_linkage.h>
#define HDR_ACK (HDR_ADDR+8)
#define HDR_SUM (HDR_ACK+4)
#define HDR_TAG (HDR_SUM+2)
#define HDR_DATA (HDR_SIZE)
! support the SC->memory loader protocol
! to ACK a packet we write HDR_ACK = (TAG << 16 | SUM)
! when HDR_ACK returns to 0 we have more data.
! if HDR_ACK == -1 (32bits) then we are all finished
! if HDR_ACK < 0 then abort.
setx SRAM_ADDR + SRAM_SHARED_OFFSET, r_tmp0, r_sram ! SRAM base
set SRAM_BOOTLOAD_PKT_OFFSET, r_tmp1 ! bootload packet offset
add r_sram, r_tmp1, r_sram
set BOOTLOAD_READY, r_tmp0
stuw r_tmp0, [r_sram + HDR_ACK]
ldsw [r_sram + HDR_ACK], r_tmp0
cmp r_tmp0, BOOTLOAD_DONE
brz,pt r_tmp0, begin_copy
ldx [r_sram + HDR_ADDR], r_dest
HVABORT(-1, "MD download aborted by SP")
! accumulate header in checksum - only addr, tag and r_sum
ldx [r_sram + HDR_ADDR], r_tdat
lduh [r_sram + HDR_TAG], r_tmp0
lduh [r_sram + HDR_SUM], r_tmp1
add r_sram, HDR_DATA, r_src
! copy data to ram and accumulate in checksum
subcc r_bytes, 8, r_bytes
1: srl r_sum, 16, r_tmp0 ! get upper 16 bits
srl r_sum, 16, r_sum ! chuck upper 16 bits
srl r_tmp1, 16, r_tmp1 ! 0xffff
lduh [r_sram + HDR_TAG], r_tmp2
st r_tmp2, [r_sram + HDR_ACK]
* Wrapper around bootload, so it can be called from C.
* SPARC ABI requries only that g2,g3,g4 are preserved across
save %sp, -SA(MINFRAME), %sp
STRAND_PUSH(%g2, %g6, %g7)
STRAND_PUSH(%g3, %g6, %g7)
STRAND_PUSH(%g4, %g6, %g7)