📄 ramdrv.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/ramDrv.html - generated by refgen from ramDrv.c --> <title> ramDrv </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Libraries</i></a></p></blockquote><h1>ramDrv</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ramDrv</strong> - RAM disk driver </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./ramDrv.html#ramDrv">ramDrv</a></i>( )</b> - prepare a RAM disk driver for use (optional)<br><b><i><a href="./ramDrv.html#ramDevCreate">ramDevCreate</a></i>( )</b> - create a RAM disk device<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This driver emulates a disk driver, but actually keeps all data in memory.The memory location and size are specified when the "disk" is created.The RAM disk feature is useful when data must be preserved between boots ofVxWorks or when sharing data between CPUs.<p></blockquote><h4>USER-CALLABLE ROUTINES</h4><blockquote><p>Most of the routines in this driver are accessible only through the I/O system.Two routines, however, can be called directly by the user. The first, <b><i><a href="./ramDrv.html#ramDrv">ramDrv</a></i>( )</b>,provides no real function except to parallel the initialization function foundin true disk device drivers. A call to <b><i><a href="./ramDrv.html#ramDrv">ramDrv</a></i>( )</b> is not required to use the RAMdisk driver. However, the second routine, <b><i><a href="./ramDrv.html#ramDevCreate">ramDevCreate</a></i>( )</b>, must be called directly to create RAM disk devices.<p>Once the device has been created, it must be associated with a name andfile system (dosFs, rt11Fs, or rawFs). This is accomplished by passingthe value returned by <b><i><a href="./ramDrv.html#ramDevCreate">ramDevCreate</a></i>( )</b>, a pointer to a block devicestructure, to the file system's device initialization routine ormake-file-system routine. See the manual entry <b><i><a href="./ramDrv.html#ramDevCreate">ramDevCreate</a></i>( )</b> for amore detailed discussion.<p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>The RAM driver is called in response to <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> codes in the same manneras a normal disk driver. When the file system is unable to handle aspecific <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> request, it is passed to the <b><a href="./ramDrv.html#top">ramDrv</a></b> driver. Althoughthere is no physical device to be controlled, <b><a href="./ramDrv.html#top">ramDrv</a></b> does handle aFIODISKFORMAT request, which always returns OK. All other <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b>requests return an error and set the task's <b>errno</b> to S_ioLib_UNKNOWN_REQUEST.<p></blockquote><h4>INCLUDE FILE</h4><blockquote><p><b>ramDrv.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ramDrv.html#top">ramDrv</a></b>, <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>, <b><i><a href="./dosFsLib.html#dosFsMkfs">dosFsMkfs</a></i>( )</b>, <b><i><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a></i>( )</b>, <b><i><a href="./rt11FsLib.html#rt11FsMkfs">rt11FsMkfs</a></i>( )</b>, <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b>, <i>VxWorks Programmer's Guide: I/O System, Local File Systems</i><hr><a name="ramDrv"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>ramDrv</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>ramDrv</i>( )</strong> - prepare a RAM disk driver for use (optional)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS ramDrv (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine performs no real function, except to provide compatibilitywith earlier versions of <b><a href="./ramDrv.html#top">ramDrv</a></b> and to parallel the initializationfunction found in true disk device drivers. It also is used in<b>usrConfig.c</b> to link in the RAM disk driver when buildingVxWorks. Otherwise, there is no need to call this routine before usingthe RAM disk driver.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, always.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ramDrv.html#top">ramDrv</a></b><hr><a name="ramDevCreate"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>ramDevCreate</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>ramDevCreate</i>( )</strong> - create a RAM disk device</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>BLK_DEV *ramDevCreate ( char * ramAddr, /* where it is in memory (0 = malloc) */ int bytesPerBlk, /* number of bytes per block */ int blksPerTrack, /* number of blocks per track */ int nBlocks, /* number of blocks on this device */ int blkOffset /* no. of blks to skip at start of device */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a RAM disk device.<p>Memory for the RAM disk can be pre-allocated separately; if so, the<i>ramAddr</i> parameter should be the address of the pre-allocated devicememory. Or, memory can be automatically allocated with <b><i><a href="./memPartLib.html#malloc">malloc</a></i>( )</b> bysetting <i>ramAddr</i> to zero.<p>The <i>bytesPerBlk</i> parameter specifies the size of each logical blockon the RAM disk. If <i>bytesPerBlk</i> is zero, 512 is used.<p>The <i>blksPerTrack</i> parameter specifies the number of blocks on eachlogical track of the RAM disk. If <i>blksPerTrack</i> is zero, the count ofblocks per track is set to <i>nBlocks</i> (i.e., the disk is definedas having only one track).<p>The <i>nBlocks</i> parameter specifies the size of the disk, in blocks.If <i>nBlocks</i> is zero, a default size is used. The default is calculatedusing a total disk size of either 51,200 bytes or one-half of the sizeof the largest memory area available, whichever is less. This defaultdisk size is then divided by <i>bytesPerBlk</i> to determine the numberof blocks.<p>The <i>blkOffset</i> parameter specifies an offset, in blocks, from the startof the device to be used when writing or reading the RAM disk. Thisoffset is added to the block numbers passed by the file system duringdisk accesses. (VxWorks file systems always use block numbers beginningat zero for the start of a device.) This offset value is typically usefulonly if a specific address is given for <i>ramAddr</i>. Normally, <i>blkOffset</i>is 0.<p></blockquote><h4>FILE SYSTEMS</h4><blockquote><p><p>Once the device has been created, it must be associated with a name and afile system (dosFs, rt11Fs, or rawFs). This is accomplished using thefile system's device initialization routine or make-file-system routine,e.g., <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b> or <b><i><a href="./dosFsLib.html#dosFsMkfs">dosFsMkfs</a></i>( )</b>. The <b><i><a href="./ramDrv.html#ramDevCreate">ramDevCreate</a></i>( )</b> call returns apointer to a block device structure (<b>BLK_DEV</b>). This structure containsfields that describe the physical properties of a disk device and specifythe addresses of routines within the <b><a href="./ramDrv.html#top">ramDrv</a></b> driver. The <b>BLK_DEV</b> structureaddress must be passed to the desired file system (dosFs, rt11Fs or rawFs)via the file system's device initialization or make-file-system routine.Only then is a name and file system associated with the device, making itavailable for use.<p></blockquote><h4>EXAMPLE</h4><blockquote><p><p>In the following example, a 200-Kbyte RAM disk is created withautomatically allocated memory, 512-byte blocks, a single track, and noblock offset. The device is then initialized for use with dosFs and assignedthe name "DEV1:":<pre> BLK_DEV *pBlkDev; DOS_VOL_DESC *pVolDesc; pBlkDev = ramDevCreate (0, 512, 400, 400, 0); pVolDesc = dosFsMkfs ("DEV1:", pBlkDev);</pre>The <b><i><a href="./dosFsLib.html#dosFsMkfs">dosFsMkfs</a></i>( )</b> routine calls <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b> with default parameters andinitializes the file system on the disk by calling <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> with theFIODISKINIT function.<p>If the RAM disk memory already contains a disk image created elsewhere,the first argument to <b><i><a href="./ramDrv.html#ramDevCreate">ramDevCreate</a></i>( )</b> should be the address in memory, andthe formatting parameters -- <i>bytesPerBlk</i>, <i>blksPerTrack</i>, <i>nBlocks</i>, and<i>blkOffset</i> -- must be identical to those used when the image wascreated. For example:<pre> pBlkDev = ramDevCreate (0xc0000, 512, 400, 400, 0); pVolDesc = dosFsDevInit ("DEV1:", pBlkDev, NULL);</pre>In this case, <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b> must be used instead of <b><i><a href="./dosFsLib.html#dosFsMkfs">dosFsMkfs</a></i>( )</b>, becausethe file system already exists on the disk and should not bere-initialized. This procedure is useful if a RAM disk is to be createdat the same address used in a previous boot of VxWorks. The contents ofthe RAM disk will then be preserved.<p>These same procedures apply when creating a RAM disk with rt11Fs using<b><i><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a></i>( )</b> and <b><i><a href="./rt11FsLib.html#rt11FsMkfs">rt11FsMkfs</a></i>( )</b>, or creating a RAM disk with rawFs using<b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A pointer to a block device structure (<b>BLK_DEV</b>) or NULL if memory cannotbe allocated for the device structure or for the RAM disk.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ramDrv.html#top">ramDrv</a></b>, <b><i><a href="./dosFsLib.html#dosFsMkfs">dosFsMkfs</a></i>( )</b>, <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>, <b><i><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a></i>( )</b>, <b><i><a href="./rt11FsLib.html#rt11FsMkfs">rt11FsMkfs</a></i>( )</b>, <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -