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.
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.
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]
22 \ ident "%Z%%M% %I% %E% SMI"
23 \ Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 \ Use is subject to license terms.
27 id: %Z%%M% %I% %E% SMI
28 purpose: simplified ramdisk driver
29 copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
34 " SUNW,ramdisk" encode-string " compatible" property
36 0 instance value current-offset
38 0 value ramdisk-base-va
43 ramdisk-size encode-int " size" property
44 ramdisk-base-va encode-int " address" property
45 alloc-size encode-int " alloc-size" property
49 : current-va ( -- adr ) ramdisk-base-va current-offset + ;
60 : seek ( off.low off.high -- error? )
61 drop dup ramdisk-size > if
62 drop true exit ( failed )
64 to current-offset false ( succeeded )
67 : read ( addr len -- actual-len )
68 dup current-offset + ( addr len new-off )
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 )
77 : create ( base size alloc-sz -- )