|
| 1 | +# NVMe2K - NVMe Driver for Windows 2000 |
| 2 | + |
| 3 | +A NVMe (Non-Volatile Memory Express) storage controller driver for Windows 2000, targeting both x86 and Alpha AXP platforms. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +NVMe2K is a SCSI miniport driver that provides NVMe device support for Windows 2000. It uses the ScsiPort framework to integrate NVMe solid-state drives with the Windows 2000 storage stack. |
| 8 | + |
| 9 | +### Why? |
| 10 | + |
| 11 | +It seemed like a good idea at first. |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Full NVMe 1.0 specification support** |
| 16 | + - Single I/O queue pair (scalable architecture) |
| 17 | + - Admin queue for device management |
| 18 | + - PRP (Physical Region Page) based data transfers |
| 19 | + - Up to 2MB transfer sizes via PRP lists |
| 20 | + |
| 21 | +- **SCSI Translation Layer** |
| 22 | + - Translates SCSI commands to NVMe commands |
| 23 | + - Tagged command queuing support |
| 24 | + - Ordered queue tag support with automatic flush |
| 25 | + - READ/WRITE/FLUSH/INQUIRY/READ_CAPACITY commands |
| 26 | + |
| 27 | +- **Advanced Features** |
| 28 | + - SMP-safe with configurable locking (`NVME2K_USE_*_LOCK` defines) |
| 29 | + - Custom atomic operations for x86 and Alpha AXP |
| 30 | + - Proper alignment for Alpha 64-bit pointers |
| 31 | + - Non-tagged request serialization |
| 32 | + - Queue depth management and statistics |
| 33 | + |
| 34 | +- **Multi-Platform Support** |
| 35 | + - x86 (Pentium and later) |
| 36 | + - Alpha AXP (DEC Alpha workstations/servers) |
| 37 | + |
| 38 | +## Architecture |
| 39 | + |
| 40 | +``` |
| 41 | +Application Layer |
| 42 | + ↓ |
| 43 | + SCSI Disk Driver |
| 44 | + ↓ |
| 45 | + ScsiPort.sys |
| 46 | + ↓ |
| 47 | + nvme2k.sys ← This driver |
| 48 | + ↓ |
| 49 | + NVMe Controller (PCI) |
| 50 | +``` |
| 51 | + |
| 52 | +### Key Components |
| 53 | + |
| 54 | +- **atomic.h** - Platform-specific atomic operations (x86 inline asm, Alpha LL/SC) |
| 55 | +- **nvme2k.c** - Main driver logic, SCSI translation, NVMe command handling |
| 56 | +- **nvme2k.h** - Data structures, constants, NVMe register definitions |
| 57 | +- **nvme2k.inf** - Multi-platform installation file |
| 58 | + |
| 59 | +## Building |
| 60 | + |
| 61 | +### Requirements |
| 62 | + |
| 63 | +- **Windows 2000 DDK** |
| 64 | + - Final version (5.00.2195.1) for x86 |
| 65 | + - RC1 version for Alpha AXP |
| 66 | + |
| 67 | +- **Visual C++ 6.0** |
| 68 | + - x86 compiler for x86 builds |
| 69 | + - Alpha AXP compiler for Alpha builds |
| 70 | + |
| 71 | +### Build Instructions |
| 72 | + |
| 73 | +#### For x86: |
| 74 | + |
| 75 | +```cmd |
| 76 | +REM Set up build environment |
| 77 | +cd C:\NTDDK\bin |
| 78 | +setenv.bat free REM or 'checked' for debug build |
| 79 | +
|
| 80 | +REM Navigate to driver directory |
| 81 | +cd <path-to-nvme2k> |
| 82 | +
|
| 83 | +REM Build |
| 84 | +build -cZ |
| 85 | +``` |
| 86 | + |
| 87 | +Output: `obj\i386\nvme2k.sys` |
| 88 | + |
| 89 | +#### For Alpha AXP: |
| 90 | + |
| 91 | +```cmd |
| 92 | +REM Set up build environment for Alpha |
| 93 | +cd C:\NTDDK\bin |
| 94 | +setenv.bat free alpha REM or 'checked' for debug build |
| 95 | +
|
| 96 | +REM Navigate to driver directory |
| 97 | +cd <path-to-nvme2k> |
| 98 | +
|
| 99 | +REM Build |
| 100 | +build -cZ |
| 101 | +``` |
| 102 | + |
| 103 | +Output: `obj\alpha\nvme2k.sys` |
| 104 | + |
| 105 | +### Build Options |
| 106 | + |
| 107 | +Edit `nvme2k.h` to configure: |
| 108 | + |
| 109 | +```c |
| 110 | +#define NVME2K_DBG // Enable debug logging |
| 111 | +// #define NVME2K_DBG_CMD // Extra verbose command logging |
| 112 | + |
| 113 | +// Locking control (comment out to disable) |
| 114 | +#define NVME2K_USE_INTERRUPT_LOCK // Serialize HwInterrupt on SMP |
| 115 | +#define NVME2K_USE_SUBMISSION_LOCK // Serialize command submission |
| 116 | +#define NVME2K_USE_COMPLETION_LOCK // Serialize completion processing |
| 117 | +``` |
| 118 | + |
| 119 | +## Installation |
| 120 | + |
| 121 | +### Creating Installation Media |
| 122 | + |
| 123 | +Create the following directory structure: |
| 124 | + |
| 125 | +``` |
| 126 | +DriverDisk\ |
| 127 | +├── nvme2k.inf |
| 128 | +├── i386\ |
| 129 | +│ └── nvme2k.sys (x86 binary) |
| 130 | +└── alpha\ |
| 131 | + └── nvme2k.sys (Alpha AXP binary) |
| 132 | +``` |
| 133 | + |
| 134 | +### Installing |
| 135 | + |
| 136 | +1. Copy driver files to installation media |
| 137 | +2. Boot Windows 2000 |
| 138 | +3. Use Device Manager or Add Hardware Wizard |
| 139 | +4. Point to the driver location when prompted |
| 140 | +5. Select "NVMe Storage Controller (Windows 2000)" |
| 141 | + |
| 142 | +**Note:** The driver requires NVMe devices to be visible on the PCI bus with class code `01-08-02` (Mass Storage - Non-Volatile Memory - NVMe). |
| 143 | + |
| 144 | +## Configuration |
| 145 | + |
| 146 | +The driver supports registry-based configuration via the INF file: |
| 147 | + |
| 148 | +- **MaximumSGList** (Default: 512) - Maximum scatter-gather list entries |
| 149 | +- **NumberOfRequests** (Default: 64) - Queue depth |
| 150 | +- **MaxQueueDepth** (Default: 64) - Tagged command queue depth |
| 151 | + |
| 152 | +## Debugging |
| 153 | + |
| 154 | +Enable checked (debug) builds and use WinDbg with the Windows 2000 kernel debugger: |
| 155 | + |
| 156 | +``` |
| 157 | +!scsiport.miniport <DeviceExtension> |
| 158 | +!devobj <DeviceObject> |
| 159 | +``` |
| 160 | + |
| 161 | +Debug messages are output via `ScsiDebugPrint()` and visible in checked builds. |
| 162 | + |
| 163 | +## Known Limitations |
| 164 | + |
| 165 | +- Single I/O queue pair (no multi-queue support) |
| 166 | +- No MSI/MSI-X interrupt support (uses legacy INTx) |
| 167 | +- Maximum 10 concurrent large transfers (PRP list pool limitation) |
| 168 | +- No namespace management (assumes namespace 1) |
| 169 | +- No power management features |
| 170 | +- Tested primarily in virtualized environments and Windows 2000 RC2 on Alpha |
| 171 | + |
| 172 | +## Technical Notes |
| 173 | + |
| 174 | +### Synchronization Model |
| 175 | + |
| 176 | +The driver uses multiple synchronization strategies: |
| 177 | + |
| 178 | +1. **InterruptLock** - Prevents concurrent ISR execution on SMP systems |
| 179 | +2. **SubmissionLock** - Protects submission queue tail pointer |
| 180 | +3. **CompletionLock** - Serializes completion queue processing |
| 181 | +4. **NonTaggedInFlight** - Ensures only one non-tagged request at a time |
| 182 | + |
| 183 | +All locks can be disabled via `#define` for performance testing. |
| 184 | + |
| 185 | +### Memory Allocation |
| 186 | + |
| 187 | +- **Uncached Extension** - 64KB for queues and PRP lists (DMA-accessible) |
| 188 | +- **Admin Queue** - 4KB submission + 4KB completion (power-of-2 sized) |
| 189 | +- **I/O Queue** - 4KB submission + 4KB completion (power-of-2 sized) |
| 190 | +- **PRP List Pool** - 40KB (10 pages) for scatter-gather |
| 191 | + |
| 192 | +### Command ID Encoding |
| 193 | + |
| 194 | +``` |
| 195 | +Bit 15: Non-tagged flag (1 = non-tagged, 0 = tagged) |
| 196 | +Bit 14: Ordered flush flag (for ORDERED queue tags) |
| 197 | +Bits 0-13: QueueTag (tagged) or sequence number (non-tagged) |
| 198 | +``` |
| 199 | + |
| 200 | +## License |
| 201 | + |
| 202 | +This project is licensed under the **3-Clause BSD License**. See the [LICENSE](LICENSE) file for the full license text. |
| 203 | + |
| 204 | +**USE AT YOUR OWN RISK.** This driver is experimental and may cause data loss, system instability, or hardware damage. Not recommended for production use. |
| 205 | + |
| 206 | +### Summary |
| 207 | + |
| 208 | +- ✅ Free to use, modify, and distribute |
| 209 | +- ✅ Commercial use permitted |
| 210 | +- ✅ Modification and redistribution allowed |
| 211 | +- ⚠️ No warranty provided |
| 212 | +- ⚠️ Use at your own risk |
| 213 | + |
| 214 | +## Contributing |
| 215 | + |
| 216 | +Feel free to submit issues or pull requests. Areas of interest: |
| 217 | + |
| 218 | +- Multi-queue support |
| 219 | +- MSI-X interrupt support |
| 220 | +- Power management |
| 221 | +- Additional SCSI command translations |
| 222 | +- Performance optimizations |
| 223 | + |
| 224 | +## Acknowledgments |
| 225 | + |
| 226 | +- NVMe specification authors |
| 227 | +- Windows 2000 DDK documentation |
| 228 | +- Alpha AXP architecture documentation |
| 229 | +- Everyone who thought this was a terrible idea (you were right) |
| 230 | + |
| 231 | +--- |
| 232 | + |
| 233 | +**Disclaimer:** This is an unofficial, community-developed driver. Not affiliated with Microsoft, Intel, or the NVMe standards body. |
0 commit comments