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