Drivers for 64-bit Windows
The 64-bit version of Windows is designed to let developers use a single source-code base for both Win32-based and Win64-based applications - and to a large extent - for 32-bit and 64-bit Windows drivers.
Key considerations of 64-bit Windows for driver development include the following:
Three classes of new data types:
- Fixed-precision integer types
- Pointer-precision integer types
- Specific-precision pointer types
64-bit compiler
Perform direct memory access (DMA)
Adding 64-bit addressing support to a driver can significantly improve overall system performance. In 64-bit Windows, device drivers that perform DMA but do not support 64-bit addressing are double-buffered, which results in lower relative performance. Although double-buffering usually has a relatively small impact (single percentage points) on 8-GB systems, this impact is noticeable for I/O-intensive tasks, such as database activity. As the amount of physical memory increases, this negative performance impact increases as well.
Support 32-bit I/O in 64-bit drivers
If a device driver uses the DMA routines in Windows 2000 correctly, the driver's DMA code should work without modification on 64-bit Windows.
Microsoft provides guidelines on the Web and in the Windows DDK to help developers with porting drivers to 64-bit Windows. Application developers should see the guidelines that are provided in the Microsoft Platform SDK.
Driver Porting Issues Checklist
- Use:
- Win64-safe data types
- Proper format specifiers in Printf and Wsprintf
- PtrToLong and PtrToUlong to truncate pointers
- FIELD_OFFSET macro
- TYPE_ALIGNMENT macro
- Be Careful:
- When performing unsigned and signed operations
- When using hexadecimal constants and unsigned values
- With NOT operations
- When computing buffer sizes with polymorphic interfaces
- When calling functions that have pointer OUT parameters
- To know your address space
- To remember that 0xFFFFFFFF is not the same as -1
- To examine all data-structure pointer usage
- To watch for data-type changes in Public Kernel Structures
- When using structure packing directives
- Avoid:
- Using computed or hard-coded pointer offsets
- Using hard-coded pointer or handle values
- Using different packing levels in the same header file
- Do not cast pointers to int, long, ULONG, or DWORD
Related topics
Getting Ready for 64-bit Windows