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