Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Running a Program on the Target Running with or without Paging Installing Hardware Interrupt Handlers Catching NULL Pointer Assignments Running without Run-Time System Configuration for Debug and Release Builds Loading DLLs through a File System Installable File System Using the MetaWINDOW Graphics Library Custom MP Floating Pointer Structure Compiling and Linking with On Time RTOS-32 |
Installable File SystemThis section is only relevant for applications which need to interface with a third-party file system or if you need to change the default file system configuration of RTTarget-32, RTFiles-32, or the SMB3 Client. RTTarget-32 can make its Win32 API emulation for file I/O functions available even for files it cannot handle. This is achieved through installable file I/O drivers. RTTarget-32 is shipped with drivers for console files, LPT files, and RAM files. For example, On Time's product RTFiles-32 adds a file I/O driver for files on devices with a FAT or ISO 9660 file system. A file system driver consists of structure RTFileSystemHandlers defined in Rttarget.h. Its first member must contain the size of the structure. The rest of the structure consists of function pointers which will handle the various file I/O operations. Functions which are not required or not applicable to a particular file system can be set to NULL. In this case, RTTarget-32 will simply return an appropriate error when such a function is called. Each file I/O function has a file name or a file handle as a parameter. RTTarget-32 uses this parameter to determine which file system (if several are installed) should handle the request. For file handles, it will simply pass the request to the file system which created the handle. For file names, two different criteria are used. First, the type of file is determined (e.g., disk file, console, communication device, etc.). For disk files, the desired drive letter is also determined. For each installed driver, RTTarget-32 knows which file types and which logical drives it can handle and will dispatch the call to the appropriate driver accordingly. The file system drivers do not deal with Win32 file handles. RTTarget-32 requires that functions CreateFile and FindFirstFile return unique 32-bit values which will be passed to subsequent handle-based functions. RTTarget-32 will automatically allocate true Win32 handles for such values, to be passed back to the application. All functions of the driver must otherwise behave just like the corresponding Win32 functions. This includes setting an appropriate error value using Win32 API SetLastError if the function fails. The CloseFile and FindClose functions of the driver do not use the Win32 __stdcall calling conventions, but RTTAPI (__cdecl) instead. The list of available file I/O drivers is retrieved from global variable RTFileSystemList: typedef const struct { ... // see Rttarget.h } RTFileSystemHandlers; typedef struct { DWORD Flags; DWORD Drives; DWORD PhysicalDisks; RTFileSystemHandlers * Handlers; int Reserved1, Reserved2; // initialize with zero } RTFileSystem; // file systems shipped with RTTarget-32. All are installed by default extern RTFileSystemHandlers RTConsoleFileSystem; extern RTFileSystemHandlers RTRAMFileSystem; extern RTFileSystemHandlers RTLPTFileSystem; extern RTFileSystem * RTFileSystemList[]; Applications can define their own file system configuration by declaring a customer RTFileSystemList[] array. The default file system installation is: static RTFileSystem Console = { RT_FS_CONSOLE, 0, 0, &RTConsoleFileSystem }; static RTFileSystem LPTFiles = { RT_FS_LPT_DEVICE, 0, 0, &RTLPTFileSystem }; static RTFileSystem RAMFiles = { RT_FS_FILE | RT_FS_IS_DEFAULT, 0x00000004, 0, &RTRAMFileSystem }; RTFileSystem * RTFileSystemList[] = { &Console, &LPTFiles, &RAMFiles, NULL }; This configuration assigns drive letter 'C' to the RAM File System, which holds the initial default directory. The console and printer file systems cannot handle logical drives. The Flags field for each RTFileSystem can have a combination of the values given below. It indicates which file types are supported: RT_FS_FILEStandard data files. RT_FS_CONSOLEConsole files CONIN$ and CONOUT$. RT_FS_DISK_DEVICEDevice files such as \\.\A: or \\.\PHYSICALDRIVE0. RT_FS_PIPEPipes such as \\.\pipe\name. RT_FS_MAILSLOTMailslots such as \\.\mailslot\name. RT_FS_NET_FILERemote network files such as \\servername\name. RT_FS_COM_DEVICECOM devices such as COM1 or \\.\COM1. RT_FS_LPT_DEVICELPT devices such as LPT1 or \\.\LPT1. RT_FS_IS_DEFAULTThis flag indicates that the initial default directory is held by this driver. The Drives field is used for file systems which support data files. Each bit set indicates a logical drive supported by this driver. Bit 0 corresponds to drive 'A', bit 1 corresponds to drive 'B', etc. RTTarget-32's file I/O emulation supports up to 32 logical drives. The PhysicalDisks field is used for file systems which support disk device files. Each bit set indicates a physical disk supported by this driver. Bit 0 corresponds to drive 'A', bit 1 corresponds to drive 'B', etc. RTTarget-32's file I/O emulation supports up to 32 physical disks.
|