\ ========== Copyright Header Begin ==========================================
\ Hypervisor Software File: dropin.fth
\ 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 ============================================
id: @(#)dropin.fth 1.29 01/04/06
copyright: Copyright 1992-2001 Sun Microsystems, Inc. All Rights Reserved
\ Drop-in driver support.
\ Drop-in drivers are stored in otherwise-unused PROM, usually near the
\ end of the CPU PROM, after the main firmware image.
\ The layout is as follows:
\ Module image (n bytes) The module itself
\ Module name (16 bytes) Null-terminated string
\ Reserved (4 bytes) reserved for future extension - must be 0
\ Checksum (4 bytes) 32-bit sum of image bytes
\ Image size (4 bytes) size in bytes of image
\ Magic Number (4 bytes) "OBMD"
\ Sync bytes (1-3 bytes) Enough 0x01 bytes to align the Magic Number
\ Currently The "Module name" must be one of :
\ cpu-devices- cpu-devices+
\ Search and execution order can be either one of :
\ 1. cpu-devices- 1. cpu-devices-
\ 2. cpu-devices+ 2. cpu-devices+
\ 3. nvramrc- 3. nvramrc-
\ (A). The search and execution order will be as specified in (A)
\ If at least one of the following two statements is true.
\ a) NVRAMRC is empty or use-nvramrc? NVRAM parameter is false
\ b) NVRAMRC does not contain the sequence:
\ (B). The search and execution order will be as specified in (B)
\ If both of the following two statements are true
\ a) NVRAMRC contains the following sequence:
\ b) NVRAM parameter use-nvramrc? is true
: difield \ name ( offset -- offset' )
create over c, + does> c@ di-header +
/l difield di-exp \ Reserved
: direct-open-drop-in ( -- 0 )
di-level 0= if map-drop-in is di-base then
: direct-close-drop-in ( -- )
di-level 1- dup 0= if ( level )
di-base unmap-drop-in 0 to di-base
0 max is di-level ( level )
: check-di-magic ( addr -- header flag? )
di-magic l@ h# 4f424d44 =
: another-dropin? ( header -- false | header' true )
di-base -1 = if false exit then
di-header if di-image di-size l@ + else di-base then ( adr )
check-di-magic dup 0= if nip then
tail-chain: execute-buffer ( adr len -- ) \ Try machine code
2dup 4 min " CODE" $= if ( adr len )
drop 4 + 0 swap call 2drop exit
: (dropin>data) ( -- data,len ) di-image di-size l@ ;
defer dropin>data ' (dropin>data) is dropin>data
defer release-di-data ' 2drop is release-di-data
\ Executes all drop-in packages whose names match the argument
: direct-do-drop-in ( name-adr,len -- )
2>r ( ) ( r: name-adr,len )
direct-open-drop-in ( header )
begin another-dropin? while ( header )
\ We go to a fair amount of extra trouble to keep the name
\ and the current header address on the return stack, in
\ case a drop-in messes up the data stack.
2r@ rot >r ( name-adr,len ) ( r: name-adr,len header)
di-name cscount $= if ( ) ( r: name-adr,len header)
'execute-buffer catch if 2drop then ( )
then ( ) ( r: name-adr,len header)
r> ( header ) ( r: name-adr,len )
repeat ( ) ( r: name-adr,len )
direct-close-drop-in ( ) ( r: name-adr,len )
; ' direct-do-drop-in is do-drop-in
\ After calling this routine, it is the responsibility of the
\ caller to execute "free-drop-in" after it is finished using
\ the located drop-in package. Failing to do so can result in
: direct-find-drop-in ( name-adr,len -- false | drop-in-adr,len true )
direct-open-drop-in ( name-adr,len header )
begin another-dropin? while ( name-adr,len header )
2 pick 2 pick ( name-adr,len header name-adr,len )
di-name cscount $= if ( name-adr,len header )
dropin>data true ( virtual size true )
; ' direct-find-drop-in is find-drop-in
: direct-free-drop-in ( adr len -- )
; ' direct-free-drop-in is free-drop-in
di-name cscount tuck type d# 17 swap - spaces
di-size l@ d# 11 u.r di-exp l@ d# 11 push-hex .r pop-base
." Name Length Expansion Checksum" cr
direct-open-drop-in ( header )
begin another-dropin? while ( header )