xref: /titanic_50/usr/src/psm/stand/bootblks/common/rd.fth (revision 448bf8594153765bb5fce82a8888e01e3f6c3bad)
1\
2\ CDDL HEADER START
3\
4\ The contents of this file are subject to the terms of the
5\ Common Development and Distribution License (the "License").
6\ You may not use this file except in compliance with the License.
7\
8\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9\ or http://www.opensolaris.org/os/licensing.
10\ See the License for the specific language governing permissions
11\ and limitations under the License.
12\
13\ When distributing Covered Code, include this CDDL HEADER in each
14\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15\ If applicable, add the following below this CDDL HEADER, with the
16\ fields enclosed by brackets "[]" replaced with your own identifying
17\ information: Portions Copyright [yyyy] [name of copyright owner]
18\
19\ CDDL HEADER END
20\
21\
22\ ident	"%Z%%M%	%I%	%E% SMI"
23\ Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24\ Use is subject to license terms.
25\
26
27id: %Z%%M%	%I%	%E% SMI
28purpose: simplified ramdisk driver
29copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
30
31headerless
32
33" block"          device-type
34" SUNW,ramdisk"   encode-string " compatible" property
35
360 instance value current-offset
37
380 value ramdisk-base-va
390 value ramdisk-size
400 value alloc-size
41
42: set-props
43   ramdisk-size     encode-int  " size"        property
44   ramdisk-base-va  encode-int  " address"     property
45   alloc-size       encode-int  " alloc-size"  property
46;
47set-props
48
49: current-va  ( -- adr )  ramdisk-base-va current-offset +  ;
50
51external
52
53: open  ( -- okay? )
54   true
55;
56
57: close  ( -- )
58;
59
60: seek  ( off.low off.high -- error? )
61   drop  dup  ramdisk-size  >  if
62      drop true  exit         ( failed )
63   then
64   to current-offset  false   ( succeeded )
65;
66
67: read  ( addr len -- actual-len )
68   dup  current-offset  +            ( addr len new-off )
69   dup  ramdisk-size  >  if
70      ramdisk-size -  -              ( addr len' )
71      ramdisk-size                   ( addr len new-off )
72   then  -rot                        ( new-off addr len )
73   tuck  current-va  -rot  move      ( new-off len )
74   swap  to current-offset           ( len )
75;
76
77: create ( base size alloc-sz -- )
78   to alloc-size
79   to ramdisk-size
80   to ramdisk-base-va
81   set-props
82;
83
84