replace ad hoc driver loading with a proper driver manager, new DDK, new PnP manager with device matching, asynchronous startup, resource ownership and removal, add shared PCI capability helpers, replace typed, rigid services with a proper service manager, implement proper system shutdown and restart, shutting down unloads drivers and shuts down services, add simple power button, remove heavyweight boot self-tests and SMP stress runs, add monotonic timestamps to kernel debug output, fruitless USB and PS/2 fixes, make test builds opt in.
This commit is contained in:
1 parent
c0ad63c27f
commit
d36f19509c
160 files changed
+6563
-7366
No files matched your search
@@ -0,0 +1,34 @@
|
||||
// Pure DDK support library routines; no kernel or module-wide state.
|
||||
|
||||
#include <ntlite/ddk/pci_caps.h>
|
||||
|
||||
KSTATUS NtlPciFindCapability(const NTL_PCI_CONFIG_READER* reader,
|
||||
uint8_t firstOffset,
|
||||
uint8_t capabilityId,
|
||||
uint8_t* outOffset) {
|
||||
if (!reader || !reader->Read32 || !outOffset || !capabilityId)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
*outOffset = 0;
|
||||
uint8_t current = firstOffset;
|
||||
uint64_t visited = 0;
|
||||
|
||||
while (current) {
|
||||
if (current < 0x40u || (current & 3u) != 0u)
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
uint64_t bit = 1ull << (current / 4u - 16u);
|
||||
if (visited & bit)
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
visited |= bit;
|
||||
|
||||
uint32_t header = reader->Read32(reader->Context, current);
|
||||
if ((uint8_t)header == capabilityId) {
|
||||
*outOffset = current;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
current = (uint8_t)((header >> 8) & 0xFCu);
|
||||
}
|
||||
|
||||
return NTLSTATUS_NOT_FOUND;
|
||||
}
|
||||
Reference in new issue
Block a user