📄 memdrv.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/memDrv.html - generated by refgen from memDrv.c --> <title> memDrv </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>memDrv</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>memDrv</strong> - pseudo memory device driver </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./memDrv.html#memDrv">memDrv</a></i>( )</b> - install a memory driver<br><b><i><a href="./memDrv.html#memDevCreate">memDevCreate</a></i>( )</b> - create a memory device<br><b><i><a href="./memDrv.html#memDevCreateDir">memDevCreateDir</a></i>( )</b> - create a memory device for multiple files<br><b><i><a href="./memDrv.html#memDevDelete">memDevDelete</a></i>( )</b> - delete a memory device<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This driver allows the I/O system to access memory directly as apseudo-I/O device. Memory location and size are specified when thedevice is created. This feature is useful when data must be preservedbetween boots of VxWorks or when sharing data between CPUs.<p>Additionally, it can be used to build some files into a VxWorks binaryimage (having first converted them to data arrays in C source files,using a utility such as memdrvbuild), and then mount them in thefilesystem; this is a simple way of delivering some non-changing fileswith VxWorks. For example, a system with an integrated web server mayuse this technique to build some HTML and associated content filesinto VxWorks.<p><b><a href="./memDrv.html#top">memDrv</a></b> can be used to simply provide a high-level method of readingand writing bytes in absolute memory locations through I/O calls. Itcan also be used to implement a simple, essentially read-onlyfilesystem (exsisting files can be rewritten within their existingsizes); directory searches and a limited set of IOCTL calls (including<b><i><a href="./dirLib.html#stat">stat</a></i>( )</b>) are supported.<p></blockquote><h4>USER-CALLABLE ROUTINES</h4><blockquote><p>Most of the routines in this driver are accessible only through theI/O system. Four routines, however, can be called directly: <b><i><a href="./memDrv.html#memDrv">memDrv</a></i>( )</b>to initialize the driver, <b><i><a href="./memDrv.html#memDevCreate">memDevCreate</a></i>( )</b> and <b><i><a href="./memDrv.html#memDevCreateDir">memDevCreateDir</a></i>( )</b> tocreate devices, and <b><i><a href="./memDrv.html#memDevDelete">memDevDelete</a></i>( )</b> to delete devices.<p>Before using the driver, it must be initialized by calling <b><i><a href="./memDrv.html#memDrv">memDrv</a></i>( )</b>.This routine should be called only once, before any reads, writes, or<b><i><a href="./memDrv.html#memDevCreate">memDevCreate</a></i>( )</b> calls. It may be called from <b><i><a href="./usrConfig.html#usrRoot">usrRoot</a></i>( )</b> in <b>usrConfig.c</b>or at some later point.<p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>The dosFs file system supports the following <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> functions. Thefunctions listed are defined in the header <b>ioLib.h</b>. Unless statedotherwise, the file descriptor used for these functions may be any filedescriptor which is opened to a file or directory on the volume or to the volume itself.<p><dl><dt>FIOGETFL<dd>Copies to <i>flags</i> the open mode flags of the file (<b>O_RDONLY</b>,<b>O_WRONLY</b>, <b>O_RDWR</b>):<pre> int flags; status = ioctl (fd, FIOGETFL, &flags);</pre><dt>FIOSEEK<dd>Sets the current byte offset in the file to the position specified by<i>newOffset</i>:<pre> status = ioctl (fd, FIOSEEK, newOffset);</pre>The FIOSEEK offset is always relative to the beginning of the file. Theoffset, if any, given at open time by using pseudo-file name is overridden.<p><dt>FIOWHERE<dd>Returns the current byte position in the file. This is the byte offset ofthe next byte to be read or written. It takes no additional argument:<pre> position = ioctl (fd, FIOWHERE, 0);</pre><dt>FIONREAD<dd>Copies to <i>unreadCount</i> the number of unread bytes in the file:<pre> int unreadCount; status = ioctl (fd, FIONREAD, &unreadCount);</pre><dt>FIOREADDIR<dd>Reads the next directory entry. The argument <i>dirStruct</i> is a DIRdirectory descriptor. Normally, the <b><i><a href="./dirLib.html#readdir">readdir</a></i>( )</b> routine is used to read adirectory, rather than using the FIOREADDIR function directly. See dirLib.<pre> DIR dirStruct; fd = open ("directory", O_RDONLY); status = ioctl (fd, FIOREADDIR, &dirStruct);</pre><dt>FIOFSTATGET<dd>Gets file status information (directory entry data). The argument<i>statStruct</i> is a pointer to a stat structure that is filled with datadescribing the specified file. File inode numbers, user and groupIDs, and times are not supported (returned as 0).<p>Normally, the <b><i><a href="./dirLib.html#stat">stat</a></i>( )</b> or <b><i><a href="./dirLib.html#fstat">fstat</a></i>( )</b> routine is used to obtain fileinformation, rather than using the FIOFSTATGET function directly. SeedirLib.<pre> struct stat statStruct; fd = open ("file", O_RDONLY); status = ioctl (fd, FIOFSTATGET, &statStruct);</pre></dl><p>Any other <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> function codes will return error status.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memDrv.html#top">memDrv</a></b>, <i>VxWorks Programmer's Guide: I/O System</i><hr><a name="memDrv"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>memDrv</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>memDrv</i>( )</strong> - install a memory driver</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memDrv (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes the memory driver. It must be called first,before any other routine in the driver.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the I/O system cannot install the driver.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memDrv.html#top">memDrv</a></b><hr><a name="memDevCreate"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>memDevCreate</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>memDevCreate</i>( )</strong> - create a memory device</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memDevCreate ( char * name, /* device name */ char * base, /* where to start in memory */ int length /* number of bytes */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a memory device containing a single file.Memory for the device is simply an absolute memory locationbeginning at <i>base</i>. The <i>length</i> parameter indicates the size ofmemory.<p>For example, to create the device "/mem/cpu0/", a device for accessingthe entire memory of the local processor, the proper call would be:<pre> memDevCreate ("/mem/cpu0/", 0, sysMemTop())</pre>The device is created with the specified name, start location, and size.<p>To open a file descriptor to the memory, use <b><i><a href="./ioLib.html#open">open</a></i>( )</b>. Specify apseudo-file name of the byte offset desired, or open the "raw" file at thebeginning and specify a position to seek to. For example, the followingcall to <b><i><a href="./ioLib.html#open">open</a></i>( )</b> allows memory to be read starting at decimal offset 1000.<pre> -> fd = open ("/mem/cpu0/1000", O_RDONLY, 0)</pre>Pseudo-file name offsets are scanned with "%d".<p></blockquote><h4>CAVEAT</h4><blockquote><p>The FIOSEEK operation overrides the offset given via the pseudo-file nameat open time.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>Consider a system configured with two CPUs in the backplane and a separatedual-ported memory board, each with 1 megabyte of memory. The first CPUis mapped at VMEbus address 0x00400000 (4 Meg.), the second at busaddress 0x00800000 (8 Meg.), the dual-ported memory board at 0x00c00000(12 Meg.). Three devices can be created on each CPU as follows. Onprocessor 0:<pre> -> memDevCreate ("/mem/local/", 0, sysMemTop()) ... -> memDevCreate ("/mem/cpu1/", 0x00800000, 0x00100000) ... -> memDevCreate ("/mem/share/", 0x00c00000, 0x00100000)</pre>On processor 1:<pre> -> memDevCreate ("/mem/local/", 0, sysMemTop()) ... -> memDevCreate ("/mem/cpu0/", 0x00400000, 0x00100000) ... -> memDevCreate ("/mem/share/", 0x00c00000, 0x00100000)</pre>Processor 0 has a local disk. Data or an object module needs to bepassed from processor 0 to processor 1. To accomplish this, processor 0first calls:<pre> -> copy </disk1/module.o >/mem/share/0</pre>Processor 1 can then be given the load command:<pre> -> ld </mem/share/0</pre></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if memory is insufficient or the I/O system cannot add<br> the device.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_ioLib_NO_DRIVER</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memDrv.html#top">memDrv</a></b><hr><a name="memDevCreateDir"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>memDevCreateDir</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>memDevCreateDir</i>( )</strong> - create a memory device for multiple files</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memDevCreateDir ( char * name, /* device name */ MEM_DRV_DIRENTRY * files, /* array of dir. entries - not copied */ int numFiles /* number of entries */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a memory device for a collection of filesorganised into directories. The given array of directory entryrecords describes a number of files, some of which may be directories,represented by their own directory entry arrays. The structure maybe arbitrarily deep. This effectively allows a filesystem tobe created and installed in VxWorks, for essentially read-only use.The filesystem structure can be created on the host using thememdrvbuild utility.<p>Note that the array supplied is not copied; a reference to it iskept. This array should not be modified after being passed tomemDevCreateDir.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if memory is insufficient or the I/O system cannot<br> add the device.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_ioLib_NO_DRIVER</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memDrv.html#top">memDrv</a></b><hr><a name="memDevDelete"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>memDevDelete</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>memDevDelete</i>( )</strong> - delete a memory device</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memDevDelete ( char * name /* device name */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine deletes a memory device containing a single file or acollection of files. The device is deleted with it own name.<p>For example, to delete the device created by memDevCreate ("/mem/cpu0/", 0,<b><i><a href="./sysLib.html#sysMemTop">sysMemTop</a></i>( )</b>), the proper call would be:<pre> memDevDelete ("/mem/cpu0/");</pre> </blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the device doesn't exist.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memDrv.html#top">memDrv</a></b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -