Annotation of q_a/samples/ddk/ramdisk/ramdisk.h, revision 1.1

1.1     ! root        1: /*++
        !             2: 
        !             3: Copyright (c) 1993  Microsoft Corporation
        !             4: 
        !             5: Module Name:
        !             6: 
        !             7:     ramdisk.h
        !             8: 
        !             9: Abstract:
        !            10: 
        !            11:     This file includes data declarations for the Ram Disk driver for NT.
        !            12: 
        !            13: Author:
        !            14: 
        !            15:     Robert Nelson (RobertN) 10-Mar-1993.
        !            16: 
        !            17: Environment:
        !            18: 
        !            19:     Kernel mode only.
        !            20: 
        !            21: Notes:
        !            22: 
        !            23: Revision History:
        !            24: 
        !            25: --*/
        !            26: 
        !            27: 
        !            28: #define        DEFAULT_DISK_SIZE           (1024*1024)     // 1 MB
        !            29: #define        DEFAULT_ROOT_DIR_ENTRIES    512
        !            30: #define        DEFAULT_SECTORS_PER_CLUSTER 2
        !            31: 
        !            32: typedef struct  _RAM_DISK_EXTENSION {
        !            33:     PDEVICE_OBJECT  DeviceObject;
        !            34:     PUCHAR          DiskImage;
        !            35:     ULONG           DiskLength;
        !            36:     ULONG           NumberOfCylinders;
        !            37:     ULONG           TracksPerCylinder;
        !            38:     ULONG           SectorsPerTrack;
        !            39:     ULONG           BytesPerSector;
        !            40:     UNICODE_STRING  Win32NameString;
        !            41: }   RAMDISK_EXTENSION, *PRAMDISK_EXTENSION;
        !            42: 
        !            43: #define RAMDISK_MEDIA_TYPE      0xF8
        !            44: #define DIR_ENTRIES_PER_SECTOR  16
        !            45: #define WIN32_PATH              L"\\DosDevices\\"
        !            46: 
        !            47: #if DBG
        !            48: #define RAMDBUGCHECK            ((ULONG)0x80000000)
        !            49: #define RAMDDIAG1               ((ULONG)0x00000001)
        !            50: #define RAMDDIAG2               ((ULONG)0x00000002)
        !            51: #define RAMDERRORS              ((ULONG)0x00000004)
        !            52: 
        !            53: #define RamDiskDump(LEVEL, STRING) \
        !            54:         do { \
        !            55:             if (RamDiskDebugLevel & LEVEL) { \
        !            56:                 DbgPrint STRING; \
        !            57:             } \
        !            58:             if (LEVEL == RAMDBUGCHECK) { \
        !            59:                 ASSERT(FALSE); \
        !            60:             } \
        !            61:         } while (0)
        !            62: #else
        !            63: #define RamDiskDump(LEVEL,STRING) do {NOTHING;} while (0)
        !            64: #endif
        !            65: 
        !            66: #pragma pack(1)
        !            67: 
        !            68: typedef struct  _BOOT_SECTOR
        !            69: {
        !            70:     UCHAR       bsJump[3];          // x86 jmp instruction, checked by FS
        !            71:     CCHAR       bsOemName[8];       // OEM name of formatter
        !            72:     USHORT      bsBytesPerSec;      // Bytes per Sector
        !            73:     UCHAR       bsSecPerClus;       // Sectors per Cluster
        !            74:     USHORT      bsResSectors;       // Reserved Sectors
        !            75:     UCHAR       bsFATs;             // Number of FATs - we always use 1
        !            76:     USHORT      bsRootDirEnts;      // Number of Root Dir Entries
        !            77:     USHORT      bsSectors;          // Number of Sectors
        !            78:     UCHAR       bsMedia;            // Media type - we use RAMDISK_MEDIA_TYPE
        !            79:     USHORT      bsFATsecs;          // Number of FAT sectors
        !            80:     USHORT      bsSecPerTrack;      // Sectors per Track - we use 32
        !            81:     USHORT      bsHeads;            // Number of Heads - we use 2
        !            82:     ULONG       bsHiddenSecs;       // Hidden Sectors - we set to 0
        !            83:     ULONG       bsHugeSectors;      // Number of Sectors if > 32 MB size
        !            84:     UCHAR       bsDriveNumber;      // Drive Number - not used
        !            85:     UCHAR       bsReserved1;        // Reserved
        !            86:     UCHAR       bsBootSignature;    // New Format Boot Signature - 0x29
        !            87:     ULONG       bsVolumeID;         // VolumeID - set to 0x12345678
        !            88:     CCHAR       bsLabel[11];        // Label - set to RamDisk
        !            89:     CCHAR       bsFileSystemType[8];// File System Type - FAT12 or FAT16
        !            90:     CCHAR       bsReserved2[448];   // Reserved
        !            91:     UCHAR       bsSig2[2];          // Originial Boot Signature - 0x55, 0xAA
        !            92: }   BOOT_SECTOR, *PBOOT_SECTOR;
        !            93: 
        !            94: typedef struct  _DIR_ENTRY
        !            95: {
        !            96:     UCHAR       deName[8];          // File Name
        !            97:     UCHAR       deExtension[3];     // File Extension
        !            98:     UCHAR       deAttributes;       // File Attributes
        !            99:     UCHAR       deReserved;         // Reserved
        !           100:     USHORT      deTime;             // File Time
        !           101:     USHORT      deDate;             // File Date
        !           102:     USHORT      deStartCluster;     // First Cluster of file
        !           103:     ULONG       deFileSize;         // File Length
        !           104: }   DIR_ENTRY, *PDIR_ENTRY;
        !           105: 
        !           106: #pragma pack()
        !           107: 
        !           108: //
        !           109: // Directory Entry Attributes
        !           110: //
        !           111: 
        !           112: #define DIR_ATTR_READONLY   0x01
        !           113: #define DIR_ATTR_HIDDEN     0x02
        !           114: #define DIR_ATTR_SYSTEM     0x04
        !           115: #define DIR_ATTR_VOLUME     0x08
        !           116: #define DIR_ATTR_DIRECTORY  0x10
        !           117: #define DIR_ATTR_ARCHIVE    0x20
        !           118: 
        !           119: int
        !           120: sprintf(char *s, const char *format, ...);
        !           121: 
        !           122: //
        !           123: // Device driver routine declarations.
        !           124: //
        !           125: 
        !           126: NTSTATUS
        !           127: DriverEntry(
        !           128:     IN OUT PDRIVER_OBJECT   DriverObject,
        !           129:     IN PUNICODE_STRING      RegistryPath
        !           130:     );
        !           131: 
        !           132: NTSTATUS
        !           133: RamDiskInitializeDisk(
        !           134:     IN PDRIVER_OBJECT       DriverObject,
        !           135:     IN PUNICODE_STRING      ParamPath
        !           136:     );
        !           137: 
        !           138: void
        !           139: RamDiskFormatFat(
        !           140:     IN PRAMDISK_EXTENSION   DiskExtension,
        !           141:     IN PUNICODE_STRING      ParamPath
        !           142:     );
        !           143: 
        !           144: NTSTATUS
        !           145: RamDiskCreateClose(
        !           146:     IN PDEVICE_OBJECT       DeviceObject,
        !           147:     IN PIRP                 Irp
        !           148:     );
        !           149: 
        !           150: NTSTATUS
        !           151: RamDiskDeviceControl(
        !           152:     IN PDEVICE_OBJECT       DeviceObject,
        !           153:     IN PIRP                 Irp
        !           154:     );
        !           155: 
        !           156: NTSTATUS
        !           157: RamDiskReadWrite(
        !           158:     IN PDEVICE_OBJECT       DeviceObject,
        !           159:     IN PIRP                 Irp
        !           160:     );
        !           161: 
        !           162: VOID
        !           163: RamDiskUnloadDriver(
        !           164:     IN PDRIVER_OBJECT       DriverObject
        !           165:     );

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.