introduce a stable NTL_DDK driver ABI to replace direct HAL_API and kernel-header access in drivers, add code/kernel/io_ddk.c and code/public/ntlite/ddk/ headers, change DriverEntry to take (const NTL_DDK*, NTL_DRIVER_INIT*), update kmain to build the DDK once via IoInitializeDdk/IoGetDdk and hand it to both boot and runtime drivers, downgrade code/public/ntlite/ddi/io_driver.h to a legacy I/O model header pulling from ntlite/ddk instead of kernel internals, move code/third_party/lwip into code/drivers/net/lwip/third_party, fix up lwip_sources.txt and build.c include paths to match, split build.c's single CFLAGS macro into COMMON/KERNEL/USER/BOOT/DRIVER cflags.
This commit is contained in:
1 parent
08329516ba
commit
485a6bbfe7
385 files changed
+1822
-1079
No files matched your search
Binary file not shown.
+28
-20
@@ -5,7 +5,12 @@
|
||||
|
||||
// Compiler and linker flags stay in macros so they can be used in file-scope aggregate initializers.
|
||||
// MSVC C rejects initializing a static object from another object, even when the source object is const.
|
||||
#define CFLAGS_LITERAL "/nologo /W3 /WX /Od /GS- /Gs999999 /Gz /Gy /EHsc- /GR- /Oi- /Z7 /std:c17 /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /Icode\\public /Icode\\common\\include /Icode\\kernel\\include"
|
||||
// Drivers and user binaries do not inherit kernel include paths so private dependencies fail at compile time.
|
||||
#define COMMON_CFLAGS_LITERAL "/nologo /W3 /WX /Od /GS- /Gs999999 /Gz /Gy /EHsc- /GR- /Oi- /Z7 /std:c17 /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /Icode\\public /Icode\\common\\include"
|
||||
#define KERNEL_CFLAGS_LITERAL COMMON_CFLAGS_LITERAL " /Icode\\kernel\\include"
|
||||
#define DRIVER_CFLAGS_LITERAL COMMON_CFLAGS_LITERAL
|
||||
#define USER_CFLAGS_LITERAL COMMON_CFLAGS_LITERAL
|
||||
#define BOOT_CFLAGS_LITERAL KERNEL_CFLAGS_LITERAL
|
||||
#define USER_HEAP_OBJS_LITERAL "obj\\runtime\\user_heap.obj obj\\runtime\\user_heap_exports.obj"
|
||||
#define NATIVE_RUNTIME_OBJS_LITERAL "obj\\runtime\\native_exception.obj obj\\runtime\\native_start.obj"
|
||||
#define NATIVE_EXE_LIBS_LITERAL "bin\\syscall.lib obj\\libc.obj " USER_HEAP_OBJS_LITERAL " " NATIVE_RUNTIME_OBJS_LITERAL
|
||||
@@ -13,11 +18,14 @@
|
||||
#define WIN32_EXE_LIBS_LITERAL "bin\\win32.lib bin\\syscall.lib obj\\libc.obj obj\\runtime\\native_start.obj"
|
||||
#define POSIX_EXE_LIBS_LITERAL "bin\\posix.lib bin\\syscall.lib obj\\libc.obj obj\\runtime\\posix_start.obj obj\\runtime\\native_exception.obj"
|
||||
#define NATIVE_EXE_ENTRY_LITERAL "/ENTRY:NtlNativeStart"
|
||||
#define LWIP_CFLAGS_LITERAL CFLAGS_LITERAL " /Icode\\drivers\\net\\lwip\\include /Icode\\third_party\\lwip\\src\\include /wd4005 /wd4100 /wd4103 /wd4127 /wd4244 /wd4267 /wd4706"
|
||||
#define LWIP_CFLAGS_LITERAL DRIVER_CFLAGS_LITERAL " /Icode\\drivers\\net\\lwip\\include /Icode\\drivers\\net\\lwip\\third_party\\lwip\\src\\include /wd4005 /wd4100 /wd4103 /wd4127 /wd4244 /wd4267 /wd4706"
|
||||
#define LFLAGS_LITERAL "/nologo /NODEFAULTLIB /DEBUG"
|
||||
|
||||
const char *CFLAGS = CFLAGS_LITERAL;
|
||||
const char *LWIP_CFLAGS = LWIP_CFLAGS_LITERAL;
|
||||
const char *CommonCflags = COMMON_CFLAGS_LITERAL;
|
||||
const char *KernelCflags = KERNEL_CFLAGS_LITERAL;
|
||||
const char *UserCflags = USER_CFLAGS_LITERAL;
|
||||
const char *BootCflags = BOOT_CFLAGS_LITERAL;
|
||||
const char *LwipCflags = LWIP_CFLAGS_LITERAL;
|
||||
const char *LFLAGS = LFLAGS_LITERAL;
|
||||
|
||||
typedef struct Driver_Target {
|
||||
@@ -28,12 +36,12 @@ typedef struct Driver_Target {
|
||||
const char *libs;
|
||||
} Driver_Target;
|
||||
|
||||
#define DRIVER_TARGET(name_, obj_dir_, sources_) { (name_), (obj_dir_), (sources_), CFLAGS_LITERAL, "" }
|
||||
#define DRIVER_TARGET_LIBS(name_, obj_dir_, sources_, libs_) { (name_), (obj_dir_), (sources_), CFLAGS_LITERAL, (libs_) }
|
||||
#define DRIVER_TARGET(name_, obj_dir_, sources_) { (name_), (obj_dir_), (sources_), DRIVER_CFLAGS_LITERAL, "" }
|
||||
#define DRIVER_TARGET_LIBS(name_, obj_dir_, sources_, libs_) { (name_), (obj_dir_), (sources_), DRIVER_CFLAGS_LITERAL, (libs_) }
|
||||
#define DRIVER_TARGET_FLAGS(name_, obj_dir_, sources_, cflags_) { (name_), (obj_dir_), (sources_), (cflags_), "" }
|
||||
|
||||
static const Driver_Target PCI_BUS_DRIVER =
|
||||
DRIVER_TARGET_FLAGS("pci", "obj\\drivers\\pci", "code\\drivers\\bus\\pci\\pci.c", CFLAGS_LITERAL " /DPCI_SYS_BUILD");
|
||||
DRIVER_TARGET_FLAGS("pci", "obj\\drivers\\pci", "code\\drivers\\bus\\pci\\pci.c", DRIVER_CFLAGS_LITERAL " /DPCI_SYS_BUILD");
|
||||
|
||||
static const Driver_Target STANDALONE_DRIVERS[] = {
|
||||
DRIVER_TARGET("ps2", "obj\\drivers\\ps2", "code\\drivers\\input\\ps2\\ps2.c code\\drivers\\input\\ps2\\ps2_i8042.c"),
|
||||
@@ -170,27 +178,27 @@ int main(int argc, char **argv) {
|
||||
"ml64 /nologo /c /Foobj\\syscall\\stubs.obj code\\user\\syscall\\syscall_stubs.asm",
|
||||
"for %f in (code\\boot\\uefi\\*.asm) do ml64 /nologo /c /Fo\"obj\\boot\\%~nf.obj\" \"%f\"",
|
||||
|
||||
nob_temp_sprintf("cl %s /MP /c /Foobj\\ code\\common\\printf.c code\\common\\ini_parser.c", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /MP /c /Foobj\\ code\\common\\printf.c code\\common\\ini_parser.c", CommonCflags),
|
||||
"cl /nologo /c /Foobj\\libc.obj code\\common\\libc.c",
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\user_heap.obj code\\user\\runtime\\heap.c", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\user_heap_exports.obj code\\user\\runtime\\heap_exports.c", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\native_exception.obj code\\user\\runtime\\native_exception.c", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\native_start.obj code\\user\\runtime\\native_start.c", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\posix_start.obj code\\user\\runtime\\posix_start.c", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\user_heap.obj code\\user\\runtime\\heap.c", UserCflags),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\user_heap_exports.obj code\\user\\runtime\\heap_exports.c", UserCflags),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\native_exception.obj code\\user\\runtime\\native_exception.c", UserCflags),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\native_start.obj code\\user\\runtime\\native_start.c", UserCflags),
|
||||
nob_temp_sprintf("cl %s /c /Foobj\\runtime\\posix_start.obj code\\user\\runtime\\posix_start.c", UserCflags),
|
||||
|
||||
// Bootloader.
|
||||
nob_temp_sprintf("cl %s /MP /c /Icode\\boot\\uefi\\include /Foobj\\boot\\ code\\boot\\uefi\\*.c && link %s /FORCE:MULTIPLE /SUBSYSTEM:EFI_APPLICATION /ENTRY:UefiMain /OUT:bin\\bootx64.efi obj\\libc.obj obj\\ini_parser.obj code\\boot\\uefi\\efilib.lib obj\\boot\\*.obj", CFLAGS, LFLAGS),
|
||||
nob_temp_sprintf("cl %s /MP /c /Icode\\boot\\uefi\\include /Foobj\\boot\\ code\\boot\\uefi\\*.c && link %s /FORCE:MULTIPLE /SUBSYSTEM:EFI_APPLICATION /ENTRY:UefiMain /OUT:bin\\bootx64.efi obj\\libc.obj obj\\ini_parser.obj code\\boot\\uefi\\efilib.lib obj\\boot\\*.obj", BootCflags, LFLAGS),
|
||||
|
||||
// HAL.
|
||||
nob_temp_sprintf("cl %s /MP /c /Foobj\\hal\\ code\\kernel\\hal\\*.c && link %s /DLL /OUT:bin\\hal.dll /ENTRY:HalInitialize /IGNORE:4216 obj\\printf.obj obj\\libc.obj obj\\hal\\*.obj", CFLAGS, LFLAGS),
|
||||
nob_temp_sprintf("cl %s /MP /c /Foobj\\hal\\ code\\kernel\\hal\\*.c && link %s /DLL /OUT:bin\\hal.dll /ENTRY:HalInitialize /IGNORE:4216 obj\\printf.obj obj\\libc.obj obj\\hal\\*.obj", KernelCflags, LFLAGS),
|
||||
|
||||
// Kernel.
|
||||
nob_temp_sprintf("cl %s /DKE_DISPLAY_BUILD /MP /c /Foobj\\kernel\\ code\\kernel\\*.c && link %s /SUBSYSTEM:NATIVE /ENTRY:KernelMain /OUT:bin\\kernel.exe bin\\hal.lib obj\\ini_parser.obj obj\\printf.obj obj\\libc.obj obj\\kernel\\*.obj", CFLAGS, LFLAGS),
|
||||
nob_temp_sprintf("cl %s /DKE_DISPLAY_BUILD /MP /c /Foobj\\kernel\\ code\\kernel\\*.c && link %s /SUBSYSTEM:NATIVE /ENTRY:KernelMain /OUT:bin\\kernel.exe bin\\hal.lib obj\\ini_parser.obj obj\\printf.obj obj\\libc.obj obj\\kernel\\*.obj", KernelCflags, LFLAGS),
|
||||
|
||||
// Subsystem DLLs.
|
||||
"link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\syscall.dll obj\\syscall\\stubs.obj",
|
||||
nob_temp_sprintf("cl %s /DUSER_HEAP_EXPORTS /DNTL_EXCEPTION_EXPORTS /MP /c /Foobj\\win32\\ code\\user\\runtime\\heap.c code\\user\\runtime\\heap_exports.c code\\user\\runtime\\native_exception.c code\\user\\personalities\\win32\\*.c && link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\win32.dll bin\\syscall.lib obj\\libc.obj obj\\win32\\*.obj", CFLAGS),
|
||||
nob_temp_sprintf("cl %s /DUSER_HEAP_EXPORTS /MP /c /Foobj\\posix\\ code\\user\\runtime\\heap.c code\\user\\runtime\\heap_exports.c code\\user\\personalities\\posix\\*.c && link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\posix.dll bin\\syscall.lib obj\\libc.obj obj\\posix\\*.obj", CFLAGS)
|
||||
nob_temp_sprintf("cl %s /DUSER_HEAP_EXPORTS /DNTL_EXCEPTION_EXPORTS /MP /c /Foobj\\win32\\ code\\user\\runtime\\heap.c code\\user\\runtime\\heap_exports.c code\\user\\runtime\\native_exception.c code\\user\\personalities\\win32\\*.c && link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\win32.dll bin\\syscall.lib obj\\libc.obj obj\\win32\\*.obj", UserCflags),
|
||||
nob_temp_sprintf("cl %s /DUSER_HEAP_EXPORTS /MP /c /Foobj\\posix\\ code\\user\\runtime\\heap.c code\\user\\runtime\\heap_exports.c code\\user\\personalities\\posix\\*.c && link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\posix.dll bin\\syscall.lib obj\\libc.obj obj\\posix\\*.obj", UserCflags)
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < NOB_ARRAY_LEN(core_tasks); i++) {
|
||||
@@ -235,7 +243,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
nob_sb_append_null(&lwip_files);
|
||||
nob_da_append(&procs, run_async(nob_temp_sprintf("cl %s /MP /c /Foobj\\lwip\\ %s && link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\lwip.sys /ENTRY:DriverEntry bin\\hal.lib bin\\kernel.lib obj\\libc.obj obj\\lwip\\*.obj", LWIP_CFLAGS, lwip_files.items)));
|
||||
nob_da_append(&procs, run_async(nob_temp_sprintf("cl %s /MP /c /Foobj\\lwip\\ %s && link /nologo /SUBSYSTEM:NATIVE /NODEFAULTLIB /DLL /OUT:bin\\lwip.sys /ENTRY:DriverEntry bin\\hal.lib bin\\kernel.lib obj\\libc.obj obj\\lwip\\*.obj", LwipCflags, lwip_files.items)));
|
||||
}
|
||||
|
||||
// Queue Subsystem Applications.
|
||||
@@ -296,7 +304,7 @@ int main(int argc, char **argv) {
|
||||
for (size_t i = 0; i < NOB_ARRAY_LEN(apps); i++) {
|
||||
const char *cmd = nob_temp_sprintf(
|
||||
"cl %s /MP /c /Foobj\\%s\\ code\\user\\%s\\*.c && link %s /SUBSYSTEM:NATIVE %s /OUT:bin\\%s.exe /PDB:bin\\%s.pdb %s obj\\%s\\*.obj",
|
||||
CFLAGS, apps[i][2], apps[i][0], LFLAGS, apps[i][3], apps[i][2], apps[i][2], apps[i][1], apps[i][2]
|
||||
UserCflags, apps[i][2], apps[i][0], LFLAGS, apps[i][3], apps[i][2], apps[i][2], apps[i][1], apps[i][2]
|
||||
);
|
||||
nob_da_append(&procs, run_async(cmd));
|
||||
}
|
||||
|
||||
+28
-31
@@ -8,17 +8,12 @@
|
||||
#include <string.h>
|
||||
#include <common/printf.h>
|
||||
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_irp.h>
|
||||
#include <kernel/ke_irq.h>
|
||||
#include <kernel/hal/hal_apic.h>
|
||||
|
||||
int _fltused; // MSVC floating-point helper anchor required by printf.obj
|
||||
|
||||
static const HAL_API* gHal;
|
||||
static const NTL_DDK* gDdk;
|
||||
static DRIVER_OBJECT gPciDriver;
|
||||
static uint32_t gPciDeviceCount;
|
||||
|
||||
@@ -38,7 +33,7 @@ static uint64_t PciAlignUp64(uint64_t value, uint64_t alignment) {
|
||||
|
||||
// Implements the default Mmio Flags operation.
|
||||
static uint64_t PciDefaultMmioFlags(void) {
|
||||
return PAGE_PRESENT | PAGE_WRITE | PAGE_WRITETHROUGH | PAGE_NOCACHE | PAGE_NX;
|
||||
return NTL_DDK_PAGE_PRESENT | NTL_DDK_PAGE_WRITE | NTL_DDK_PAGE_WRITETHROUGH | NTL_DDK_PAGE_NOCACHE | NTL_DDK_PAGE_NX;
|
||||
}
|
||||
|
||||
// Creates mmio Va.
|
||||
@@ -46,8 +41,8 @@ static KSTATUS PciAllocateMmioVa(uint64_t length, uintptr_t* outVa) {
|
||||
if (!outVa || !length)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
uint64_t alignedLength = PciAlignUp64(length, PAGE_SIZE);
|
||||
uintptr_t va = (uintptr_t)PciAlignUp64((uint64_t)gPciMmioNext, PAGE_SIZE);
|
||||
uint64_t alignedLength = PciAlignUp64(length, NTL_DDK_PAGE_SIZE);
|
||||
uintptr_t va = (uintptr_t)PciAlignUp64((uint64_t)gPciMmioNext, NTL_DDK_PAGE_SIZE);
|
||||
if (va < PCI_MMIO_VA_BASE || va >= PCI_MMIO_VA_LIMIT)
|
||||
return NTLSTATUS_NO_MEMORY;
|
||||
if (alignedLength > (uint64_t)(PCI_MMIO_VA_LIMIT - va))
|
||||
@@ -70,14 +65,14 @@ static bool PciIsPdo(DEVICE_OBJECT* pdo, PCI_PDO_EXTENSION** outExt) {
|
||||
|
||||
// Implements the raw Read32 operation.
|
||||
static uint32_t PciRawRead32(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t offset) {
|
||||
if (!gHal || offset > 0xFCu) return 0xFFFFFFFFu;
|
||||
return gHal->Pci.Read32(0, bus, dev, fn, offset & 0xFCu);
|
||||
if (!gDdk || !gDdk->Platform || !gDdk->Platform->PciRead32 || offset > 0xFCu) return 0xFFFFFFFFu;
|
||||
return gDdk->Platform->PciRead32(0, bus, dev, fn, offset & 0xFCu);
|
||||
}
|
||||
|
||||
// Implements the raw Write32 operation.
|
||||
static void PciRawWrite32(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t offset, uint32_t value) {
|
||||
if (!gHal || offset > 0xFCu) return;
|
||||
gHal->Pci.Write32(0, bus, dev, fn, offset & 0xFCu, value);
|
||||
if (!gDdk || !gDdk->Platform || !gDdk->Platform->PciWrite32 || offset > 0xFCu) return;
|
||||
gDdk->Platform->PciWrite32(0, bus, dev, fn, offset & 0xFCu, value);
|
||||
}
|
||||
|
||||
// Implements the raw Read8 operation.
|
||||
@@ -391,7 +386,7 @@ static KSTATUS PciCreatePdo(uint8_t bus, uint8_t dev, uint8_t fn) {
|
||||
}
|
||||
|
||||
gPciDeviceCount++;
|
||||
DbgPrint("pci: %v ven=%04x dev=%04x class=%02x%02x%02x irq=%u\n",
|
||||
gDdk->Debug->Print("pci: %v ven=%04x dev=%04x class=%02x%02x%02x irq=%u\n",
|
||||
pdo->Name,
|
||||
info.VendorId,
|
||||
info.DeviceId,
|
||||
@@ -416,7 +411,7 @@ static void PciEnumerateBus(void) {
|
||||
for (uint8_t fn = 0; fn < fnLimit; fn++) {
|
||||
KSTATUS st = PciCreatePdo((uint8_t)bus, (uint8_t)dev, fn);
|
||||
if (!KSUCCESS(st) && st != NTLSTATUS_NOT_FOUND) {
|
||||
DbgPrint("pci: failed to create PDO for %02x:%02x.%u st=0x%x\n",
|
||||
gDdk->Debug->Print("pci: failed to create PDO for %02x:%02x.%u st=0x%x\n",
|
||||
bus, dev, fn, st);
|
||||
}
|
||||
}
|
||||
@@ -529,19 +524,19 @@ __declspec(dllexport) KSTATUS PciMapBar(DEVICE_OBJECT* pdo, uint8_t index, uint6
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
uint64_t flags = pageFlags ? pageFlags : PciDefaultMmioFlags();
|
||||
flags |= PAGE_PRESENT;
|
||||
flags |= NTL_DDK_PAGE_PRESENT;
|
||||
|
||||
uint64_t physBase = bar.Base & ~(uint64_t)(PAGE_SIZE - 1u);
|
||||
uint64_t physBase = bar.Base & ~(uint64_t)(NTL_DDK_PAGE_SIZE - 1u);
|
||||
uint64_t physOffset = bar.Base - physBase;
|
||||
uint64_t mapLength = PciAlignUp64(physOffset + bar.Length, PAGE_SIZE);
|
||||
uint64_t mapLength = PciAlignUp64(physOffset + bar.Length, NTL_DDK_PAGE_SIZE);
|
||||
|
||||
uintptr_t virtBase = 0;
|
||||
st = PciAllocateMmioVa(mapLength, &virtBase);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
|
||||
for (uint64_t off = 0; off < mapLength; off += PAGE_SIZE) {
|
||||
st = MmPteMapPage(virtBase + (uintptr_t)off, physBase + off, flags, MmPteMapFailIfPresent);
|
||||
for (uint64_t off = 0; off < mapLength; off += NTL_DDK_PAGE_SIZE) {
|
||||
st = gDdk->Memory->MapPage(virtBase + (uintptr_t)off, physBase + off, flags, NtlDdkMapFailIfPresent);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
}
|
||||
@@ -616,10 +611,11 @@ __declspec(dllexport) KSTATUS PciEnableMsi(DEVICE_OBJECT* pdo, uint8_t irqSlot)
|
||||
if (!cap)
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
|
||||
uint32_t bspLapic = HalGetBspLapicId();
|
||||
if (!HalApicUsingX2Apic() && bspLapic >= 256u)
|
||||
uint32_t bspLapic = gDdk->Platform->GetBspLapicId();
|
||||
uint8_t x2Apic = gDdk->Platform->IsX2ApicEnabled();
|
||||
if (!x2Apic && bspLapic >= 256u)
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
if (HalApicUsingX2Apic() && bspLapic >= 256u) {
|
||||
if (x2Apic && bspLapic >= 256u) {
|
||||
// Extended x2APIC MSI destinations need interrupt-remapping awareness.
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -655,7 +651,7 @@ __declspec(dllexport) KSTATUS PciEnableMsi(DEVICE_OBJECT* pdo, uint8_t irqSlot)
|
||||
cmd |= PCI_COMMAND_INTX_DISABLE;
|
||||
PciRawWrite16(bus, dev, fn, PCI_REG_COMMAND_STATUS, cmd);
|
||||
|
||||
DbgPrint("pci: MSI enabled %02x:%02x.%u cap=0x%02x vector=0x%02x irqslot=%u dest=%u %s\n",
|
||||
gDdk->Debug->Print("pci: MSI enabled %02x:%02x.%u cap=0x%02x vector=0x%02x irqslot=%u dest=%u %s\n",
|
||||
bus, dev, fn, cap, vector, irqSlot, bspLapic, is64 ? "64-bit" : "32-bit");
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
@@ -670,7 +666,7 @@ __declspec(dllexport) KSTATUS PciEnableMsiAuto(DEVICE_OBJECT* pdo, uint8_t* outI
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
|
||||
uint8_t irq = 0xFFu;
|
||||
KSTATUS st = KeIrqAllocateMsiVector(&irq);
|
||||
KSTATUS st = gDdk->Interrupt->AllocateMsiVector(&irq);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
|
||||
@@ -683,9 +679,10 @@ __declspec(dllexport) KSTATUS PciEnableMsiAuto(DEVICE_OBJECT* pdo, uint8_t* outI
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
if (!hal) return NTLSTATUS_INVALID_PARAMETER;
|
||||
gHal = hal;
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)init;
|
||||
if (!ddk || !ddk->Debug || !ddk->Interrupt || !ddk->Memory || !ddk->Platform) return NTLSTATUS_INVALID_PARAMETER;
|
||||
gDdk = ddk;
|
||||
gPciDeviceCount = 0;
|
||||
|
||||
IoInitializeDriverObject(&gPciDriver, SYS_SV_LITERAL("pci"));
|
||||
@@ -694,8 +691,8 @@ KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
KSTATUS st = IoRegisterDriverObject(&gPciDriver);
|
||||
if (!KSUCCESS(st)) return st;
|
||||
|
||||
DbgPrint("pci: DriverEntry ABI=%u\n", PciDriverAbiVersion());
|
||||
gDdk->Debug->Print("pci: DriverEntry ABI=%u\n", PciDriverAbiVersion());
|
||||
PciEnumerateBus();
|
||||
DbgPrint("pci: enumeration complete, devices=%u\n", gPciDeviceCount);
|
||||
gDdk->Debug->Print("pci: enumeration complete, devices=%u\n", gPciDeviceCount);
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "usb.h"
|
||||
|
||||
DRIVER_OBJECT gXhciDriver;
|
||||
const HAL_API* gUsbHal;
|
||||
const NTL_DDK* gUsbDdk;
|
||||
|
||||
static const IO_DEVICE_ID gXhciIds[] = {
|
||||
{ IoBusPci, { "PCI\\CC_0C0330", sizeof("PCI\\CC_0C0330") - 1 } },
|
||||
@@ -35,10 +35,11 @@ static KSTATUS UsbInitializeXhciDriver(void) {
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
if (!hal) return NTLSTATUS_INVALID_PARAMETER;
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)init;
|
||||
if (!ddk || !ddk->Memory || !ddk->Memory->PhysToVirt || !ddk->Timer) return NTLSTATUS_INVALID_PARAMETER;
|
||||
DbgPrint("usb: driver loading\n");
|
||||
gUsbHal = hal;
|
||||
gUsbDdk = ddk;
|
||||
|
||||
KSTATUS st = UsbInitializeBusModel();
|
||||
if (!KSUCCESS(st)) {
|
||||
|
||||
+14
-16
@@ -8,21 +8,19 @@
|
||||
#include <string.h>
|
||||
#include <intrin.h>
|
||||
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddi/input_device.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <ntlite/ddi/pci.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_irq.h>
|
||||
#include <kernel/ke_dpc.h>
|
||||
#include <kernel/ke_irp.h>
|
||||
#include <kernel/ke_spinlock.h>
|
||||
#include <kernel/ke_semaphore.h>
|
||||
#include <kernel/ke_thread.h>
|
||||
#include <kernel/mm_phys.h>
|
||||
#include <kernel/mm_pfn.h>
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/interrupt.h>
|
||||
#include <ntlite/ddk/dpc.h>
|
||||
#include <ntlite/ddk/irp.h>
|
||||
#include <ntlite/ddk/sync.h>
|
||||
#include <ntlite/ddk/semaphore.h>
|
||||
#include <ntlite/ddk/thread.h>
|
||||
#include <ntlite/ddk/memory.h>
|
||||
|
||||
#ifndef USB_DEBUG_VERBOSE
|
||||
#define USB_DEBUG_VERBOSE 0
|
||||
@@ -761,7 +759,7 @@ typedef struct XHCI_WAIT_TARGET {
|
||||
|
||||
typedef struct XHCI_CONTROLLER {
|
||||
uint32_t Magic;
|
||||
const HAL_API* Hal;
|
||||
const NTL_DDK* Ddk;
|
||||
DEVICE_OBJECT* Fdo;
|
||||
DEVICE_OBJECT* Pdo;
|
||||
DEVICE_OBJECT* LowerDevice;
|
||||
@@ -837,7 +835,7 @@ extern DRIVER_OBJECT gUsbCompositeDriver;
|
||||
extern DRIVER_OBJECT gUsbHidDriver;
|
||||
extern DRIVER_OBJECT gUsbHubDriver;
|
||||
extern DRIVER_OBJECT gXhciDriver;
|
||||
extern const HAL_API* gUsbHal;
|
||||
extern const NTL_DDK* gUsbDdk;
|
||||
|
||||
KSTATUS UsbInitializeBusModel(void);
|
||||
KSTATUS UsbInitializeCompositeDriver(void);
|
||||
@@ -881,9 +879,9 @@ uint32_t XhciRead32(volatile uint8_t* base, uint32_t reg);
|
||||
void XhciWrite32(volatile uint8_t* base, uint32_t reg, uint32_t value);
|
||||
uint64_t XhciRead64(volatile uint8_t* base, uint32_t reg);
|
||||
void XhciWrite64(volatile uint8_t* base, uint32_t reg, uint64_t value);
|
||||
void UsbDelayUs(const HAL_API* hal, uint32_t us);
|
||||
bool UsbWaitSet32(const HAL_API* hal, volatile uint8_t* base, uint32_t reg, uint32_t mask, uint32_t timeoutUs);
|
||||
bool UsbWaitClear32(const HAL_API* hal, volatile uint8_t* base, uint32_t reg, uint32_t mask, uint32_t timeoutUs);
|
||||
void UsbDelayUs(const NTL_DDK* ddk, uint32_t us);
|
||||
bool UsbWaitSet32(const NTL_DDK* ddk, volatile uint8_t* base, uint32_t reg, uint32_t mask, uint32_t timeoutUs);
|
||||
bool UsbWaitClear32(const NTL_DDK* ddk, volatile uint8_t* base, uint32_t reg, uint32_t mask, uint32_t timeoutUs);
|
||||
void* UsbDmaAllocPages(XHCI_CONTROLLER* xhci, size_t pages, PHYSICAL_ADDRESS* outPhys);
|
||||
uint16_t XhciScratchpadCount(uint32_t hcs2);
|
||||
uint32_t XhciTrbType(const XHCI_TRB* trb);
|
||||
|
||||
@@ -87,7 +87,7 @@ static KSTATUS UsbHubEnumerateRootPortWithRetries(USB_HUB_EXTENSION* hub,
|
||||
|
||||
DbgPrint("usb-hub: root port %u enumeration attempt %u failed st=0x%x; retrying\n",
|
||||
port, attempt, last);
|
||||
UsbDelayUs(xhci->Hal, 50000);
|
||||
UsbDelayUs(xhci->Ddk, 50000);
|
||||
}
|
||||
|
||||
if (UsbHubRootPortConnected(xhci, port)) {
|
||||
@@ -346,7 +346,7 @@ static KSTATUS UsbHubResetExternalPort(USB_HUB_EXTENSION* hub, uint8_t port, uin
|
||||
USB_HUB_PORT_STATUS ps;
|
||||
memset(&ps, 0, sizeof(ps));
|
||||
for (uint32_t i = 0; i < 500u; i++) {
|
||||
UsbDelayUs(((XHCI_CONTROLLER*)hub->Hcd->ControllerContext)->Hal, 1000u);
|
||||
UsbDelayUs(((XHCI_CONTROLLER*)hub->Hcd->ControllerContext)->Ddk, 1000u);
|
||||
st = UsbHubGetPortStatus(hub, port, &ps);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
@@ -416,7 +416,7 @@ static void UsbHubHandleExternalPortChange(USB_HUB_EXTENSION* hub, uint8_t port)
|
||||
|
||||
hub->ChildSlot[port] = USB_HUB_PORT_ENUMERATING;
|
||||
hub->ChildPortState[port] = UsbHubPortConnectedDebounce;
|
||||
UsbDelayUs(((XHCI_CONTROLLER*)hub->Hcd->ControllerContext)->Hal, 30000u);
|
||||
UsbDelayUs(((XHCI_CONTROLLER*)hub->Hcd->ControllerContext)->Ddk, 30000u);
|
||||
|
||||
uint8_t speed = 0;
|
||||
hub->ChildPortState[port] = UsbHubPortResetting;
|
||||
@@ -504,7 +504,7 @@ static void UsbHubHandleRootPortChange(USB_HUB_EXTENSION* hub, uint8_t port) {
|
||||
hub->RootPortSlot[port] = USB_HUB_PORT_ENUMERATING;
|
||||
hub->RootPortState[port] = UsbHubPortConnectedDebounce;
|
||||
|
||||
UsbDelayUs(xhci->Hal, 30000);
|
||||
UsbDelayUs(xhci->Ddk, 30000);
|
||||
portsc = XhciRead32(xhci->Op, XhciPortReg(port));
|
||||
if (!(portsc & XHCI_PORTSC_CCS)) {
|
||||
UsbHubClearRootPortFailure(hub, port);
|
||||
@@ -806,7 +806,7 @@ static KSTATUS UsbHubStartExternalDevice(DEVICE_OBJECT* device, USB_HUB_EXTENSIO
|
||||
|
||||
for (uint8_t port = 1; port <= hub->PortCount; port++)
|
||||
(void)UsbHubSetPortFeature(hub, port, USB_HUB_PORT_FEAT_POWER);
|
||||
UsbDelayUs(((XHCI_CONTROLLER*)hub->Hcd->ControllerContext)->Hal,
|
||||
UsbDelayUs(((XHCI_CONTROLLER*)hub->Hcd->ControllerContext)->Ddk,
|
||||
(uint32_t)hub->PowerOnToPowerGoodMs * 1000u);
|
||||
|
||||
st = KeSemaphoreCreate(0, 0x7fffffff, &hub->WorkerSemaphore);
|
||||
|
||||
@@ -223,7 +223,7 @@ KSTATUS UsbStorageTestUnitReady(USB_STORAGE_EXTENSION* storage) {
|
||||
|
||||
last = st;
|
||||
(void)UsbStorageRequestSense(storage);
|
||||
UsbDelayUs(xhci->Hal, 10000u);
|
||||
UsbDelayUs(xhci->Ddk, 10000u);
|
||||
}
|
||||
|
||||
return last;
|
||||
@@ -302,7 +302,7 @@ void UsbStorageAcquireIo(USB_STORAGE_EXTENSION* storage) {
|
||||
if (!storage) return;
|
||||
XHCI_CONTROLLER* xhci = storage->Device ? (XHCI_CONTROLLER*)storage->Device->Hcd->ControllerContext : (XHCI_CONTROLLER*)0;
|
||||
while (_InterlockedCompareExchange(&storage->IoBusy, 1, 0) != 0) {
|
||||
if (xhci) UsbDelayUs(xhci->Hal, 10);
|
||||
if (xhci) UsbDelayUs(xhci->Ddk, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,27 +48,27 @@ void XhciWrite64(volatile uint8_t* base, uint32_t reg, uint64_t value) {
|
||||
}
|
||||
|
||||
// Implements the delay Us operation.
|
||||
void UsbDelayUs(const HAL_API* hal, uint32_t us) {
|
||||
if (hal && hal->Timer.Stall) hal->Timer.Stall(us);
|
||||
void UsbDelayUs(const NTL_DDK* ddk, uint32_t us) {
|
||||
if (ddk && ddk->Timer && ddk->Timer->Stall) ddk->Timer->Stall(us);
|
||||
else {
|
||||
for (uint32_t i = 0; i < us * 32u; i++) _mm_pause();
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbWaitSet32(const HAL_API* hal, volatile uint8_t* base, uint32_t reg,
|
||||
bool UsbWaitSet32(const NTL_DDK* ddk, volatile uint8_t* base, uint32_t reg,
|
||||
uint32_t mask, uint32_t timeoutUs) {
|
||||
for (uint32_t i = 0; i < timeoutUs; i++) {
|
||||
if ((XhciRead32(base, reg) & mask) == mask) return true;
|
||||
UsbDelayUs(hal, 1);
|
||||
UsbDelayUs(ddk, 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UsbWaitClear32(const HAL_API* hal, volatile uint8_t* base, uint32_t reg,
|
||||
bool UsbWaitClear32(const NTL_DDK* ddk, volatile uint8_t* base, uint32_t reg,
|
||||
uint32_t mask, uint32_t timeoutUs) {
|
||||
for (uint32_t i = 0; i < timeoutUs; i++) {
|
||||
if ((XhciRead32(base, reg) & mask) == 0) return true;
|
||||
UsbDelayUs(hal, 1);
|
||||
UsbDelayUs(ddk, 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void* UsbDmaAllocPages(XHCI_CONTROLLER* xhci, size_t pages,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* virt = xhci->Hal->PhysToVirt(phys);
|
||||
void* virt = xhci->Ddk->Memory->PhysToVirt(phys);
|
||||
memset(virt, 0, pages * (size_t)PAGE_SIZE);
|
||||
*outPhys = phys;
|
||||
return virt;
|
||||
@@ -312,7 +312,7 @@ void XhciPowerRootPorts(XHCI_CONTROLLER* xhci) {
|
||||
}
|
||||
|
||||
if (powered) {
|
||||
UsbDelayUs(xhci->Hal, 20000u);
|
||||
UsbDelayUs(xhci->Ddk, 20000u);
|
||||
DbgPrint("usb: xHCI powered %u previously-off root port(s)\n", powered);
|
||||
}
|
||||
}
|
||||
@@ -518,7 +518,7 @@ KSTATUS XhciWaitForArmedTarget(XHCI_CONTROLLER* xhci, XHCI_WAIT_TARGET* target,
|
||||
KeInsertQueueDpc(&xhci->EventDpc, (void*)0, (void*)0);
|
||||
}
|
||||
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
|
||||
XhciUnregisterWaitTarget(xhci, target);
|
||||
@@ -612,7 +612,7 @@ KSTATUS XhciBiosHandoff(XHCI_CONTROLLER* xhci) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
if (!ok) {
|
||||
DbgPrint("usb: xHCI BIOS handoff timed out; continuing anyway\n");
|
||||
@@ -635,7 +635,7 @@ KSTATUS XhciStopAndReset(XHCI_CONTROLLER* xhci) {
|
||||
uint32_t cmd = XhciRead32(xhci->Op, XHCI_OP_USBCMD);
|
||||
if (cmd & XHCI_USBCMD_RS) {
|
||||
XhciWrite32(xhci->Op, XHCI_OP_USBCMD, cmd & ~XHCI_USBCMD_RS);
|
||||
if (!UsbWaitSet32(xhci->Hal, xhci->Op, XHCI_OP_USBSTS,
|
||||
if (!UsbWaitSet32(xhci->Ddk, xhci->Op, XHCI_OP_USBSTS,
|
||||
XHCI_USBSTS_HCH, 1000000u)) {
|
||||
DbgPrint("usb: xHCI stop timeout usbsts=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBSTS));
|
||||
@@ -644,14 +644,14 @@ KSTATUS XhciStopAndReset(XHCI_CONTROLLER* xhci) {
|
||||
}
|
||||
|
||||
XhciWrite32(xhci->Op, XHCI_OP_USBCMD, XHCI_USBCMD_HCRST);
|
||||
if (!UsbWaitClear32(xhci->Hal, xhci->Op, XHCI_OP_USBCMD,
|
||||
if (!UsbWaitClear32(xhci->Ddk, xhci->Op, XHCI_OP_USBCMD,
|
||||
XHCI_USBCMD_HCRST, 1000000u)) {
|
||||
DbgPrint("usb: xHCI reset timeout usbcmd=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBCMD));
|
||||
return NTLSTATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
if (!UsbWaitClear32(xhci->Hal, xhci->Op, XHCI_OP_USBSTS,
|
||||
if (!UsbWaitClear32(xhci->Ddk, xhci->Op, XHCI_OP_USBSTS,
|
||||
XHCI_USBSTS_CNR, 1000000u)) {
|
||||
DbgPrint("usb: xHCI controller-not-ready timeout usbsts=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBSTS));
|
||||
@@ -932,7 +932,7 @@ KSTATUS XhciStart(XHCI_CONTROLLER* xhci) {
|
||||
cmd |= XHCI_USBCMD_RS;
|
||||
XhciWrite32(xhci->Op, XHCI_OP_USBCMD, cmd);
|
||||
|
||||
if (!UsbWaitClear32(xhci->Hal, xhci->Op, XHCI_OP_USBSTS,
|
||||
if (!UsbWaitClear32(xhci->Ddk, xhci->Op, XHCI_OP_USBSTS,
|
||||
XHCI_USBSTS_HCH, 1000000u)) {
|
||||
DbgPrint("usb: xHCI start timeout usbsts=%08x\n",
|
||||
XhciRead32(xhci->Op, XHCI_OP_USBSTS));
|
||||
@@ -1004,7 +1004,7 @@ KSTATUS XhciResetPort(XHCI_CONTROLLER* xhci, uint8_t port, uint8_t* outSpeed) {
|
||||
break;
|
||||
}
|
||||
XhciDrainEventRingLocked(xhci, NULL);
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
|
||||
XhciClearPortChanges(xhci, port);
|
||||
@@ -1033,7 +1033,7 @@ KSTATUS XhciResetPort(XHCI_CONTROLLER* xhci, uint8_t port, uint8_t* outSpeed) {
|
||||
break;
|
||||
}
|
||||
XhciDrainEventRingLocked(xhci, NULL);
|
||||
UsbDelayUs(xhci->Hal, 1);
|
||||
UsbDelayUs(xhci->Ddk, 1);
|
||||
}
|
||||
|
||||
if (!resetDone) {
|
||||
@@ -2076,7 +2076,7 @@ KSTATUS XhciAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObject
|
||||
XHCI_CONTROLLER* xhci = (XHCI_CONTROLLER*)fdo->DeviceExtension;
|
||||
memset(xhci, 0, sizeof(*xhci));
|
||||
xhci->Magic = XHCI_CONTROLLER_MAGIC;
|
||||
xhci->Hal = gUsbHal;
|
||||
xhci->Ddk = gUsbDdk;
|
||||
xhci->Fdo = fdo;
|
||||
xhci->Pdo = physicalDeviceObject;
|
||||
xhci->Irq = 0xFFu;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "vmwaresvga.h"
|
||||
|
||||
const HAL_API* gVmwSvgaHal;
|
||||
const NTL_DDK* gVmwSvgaDdk;
|
||||
|
||||
static DRIVER_OBJECT gVmwSvgaDriver;
|
||||
|
||||
@@ -1436,12 +1436,13 @@ KSTATUS VmwSvgaAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObj
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
if (!hal)
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)init;
|
||||
if (!ddk)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DbgPrint("VMWSVGA: driver loading...\n");
|
||||
gVmwSvgaHal = hal;
|
||||
gVmwSvgaDdk = ddk;
|
||||
|
||||
memset(&gVmwSvgaDriver, 0, sizeof(gVmwSvgaDriver));
|
||||
IoInitializeDriverObject(&gVmwSvgaDriver, SYS_SV_LITERAL("vmwaresvga"));
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#include <intrin.h>
|
||||
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <ntlite/ddi/pci.h>
|
||||
#include <ntlite/ddi/display.h>
|
||||
#include <kernel/ke_display.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <kernel/display_cursor.h>
|
||||
#include <ntlite/ddk/display.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/memory.h>
|
||||
#include <ntlite/ddk/display_cursor.h>
|
||||
|
||||
#define VMWSVGA_VENDOR_VMWARE 0x15ADu
|
||||
#define VMWSVGA_DEVICE_SVGA2 0x0405u
|
||||
@@ -210,7 +210,7 @@ typedef struct VMWSVGA_DEVICE {
|
||||
DISPLAY_DEVICE DisplayDevice;
|
||||
} VMWSVGA_DEVICE;
|
||||
|
||||
extern const HAL_API* gVmwSvgaHal;
|
||||
extern const NTL_DDK* gVmwSvgaDdk;
|
||||
|
||||
KSTATUS VmwSvgaAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObject);
|
||||
KSTATUS VmwSvgaDispatchPnp(DEVICE_OBJECT* device, IRP* irp);
|
||||
@@ -3429,12 +3429,12 @@ static void Fat32DiskChange(uint8_t driveIndex,
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API *hal) {
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
DbgPrint("FAT32: Init\n");
|
||||
if (!hal) return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (!ddk) return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
FatCacheInvalidate();
|
||||
(void)hal;
|
||||
(void)init;
|
||||
gMountedCount = 0;
|
||||
memset(gDiskScanned, 0, sizeof(gDiskScanned));
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <kernel/io_file.h>
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_irp.h>
|
||||
#include <kernel/ke_semaphore.h>
|
||||
#include <kernel/ke_thread.h>
|
||||
#include <kernel/ke_sched.h>
|
||||
#include <kernel/ke_time.h>
|
||||
#include <kernel/ke_mutex.h>
|
||||
#include <kernel/ke_irql.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddk/file.h>
|
||||
#include <ntlite/ddk/memory.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/irp.h>
|
||||
#include <ntlite/ddk/semaphore.h>
|
||||
#include <ntlite/ddk/thread.h>
|
||||
#include <ntlite/ddk/scheduler.h>
|
||||
#include <ntlite/ddk/time.h>
|
||||
#include <ntlite/ddk/mutex.h>
|
||||
#include <ntlite/ddk/irql.h>
|
||||
|
||||
typedef struct FAT32_VOL_S FAT32_VOL;
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <kernel/io_file.h>
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_list.h>
|
||||
#include <kernel/ke_spinlock.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddk/file.h>
|
||||
#include <ntlite/ddk/memory.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/list.h>
|
||||
#include <ntlite/ddk/sync.h>
|
||||
|
||||
#define NTFS_MAX_VOLUMES 8u
|
||||
#define NTFS_MAX_PARTITIONS_PER_DISK 32u
|
||||
@@ -1690,10 +1690,10 @@ static void NtfsDiskChange(uint8_t driveIndex, DEVICE_OBJECT* device, IO_DEVICE_
|
||||
}
|
||||
}
|
||||
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
DbgPrint("NTFS: Init\n");
|
||||
if (!hal) return NTLSTATUS_INVALID_PARAMETER;
|
||||
(void)hal;
|
||||
if (!ddk) return NTLSTATUS_INVALID_PARAMETER;
|
||||
(void)init;
|
||||
memset(gVolumes, 0, sizeof(gVolumes));
|
||||
memset(gFilesystems, 0, sizeof(gFilesystems));
|
||||
memset(gVolumeMounted, 0, sizeof(gVolumeMounted));
|
||||
|
||||
@@ -282,8 +282,9 @@ static void Ps2MouseInitialize(void) {
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
(void)hal;
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)ddk;
|
||||
(void)init;
|
||||
|
||||
uint32_t keyboardId = 0, mouseId = 0;
|
||||
KeInputRegisterDevice("ps2-keyboard", 0, &keyboardId);
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <intrin.h>
|
||||
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddi/input_device.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_irq.h>
|
||||
#include <kernel/ke_dpc.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/interrupt.h>
|
||||
#include <ntlite/ddk/dpc.h>
|
||||
|
||||
#define PS2_DATA 0x60u
|
||||
#define PS2_STAT 0x64u
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include <intrin.h>
|
||||
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/ddi/input_device.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_dpc.h>
|
||||
#include <kernel/ke_irq.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/dpc.h>
|
||||
#include <ntlite/ddk/interrupt.h>
|
||||
|
||||
#define SERIAL_COM1_BASE 0x3F8u
|
||||
#define SERIAL_COM1_IRQ 4u
|
||||
@@ -319,8 +319,9 @@ static void SerialInitializeCom1(void) {
|
||||
}
|
||||
|
||||
// DriverEntry registers COM1 as an input source.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
(void)hal;
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)ddk;
|
||||
(void)init;
|
||||
|
||||
uint32_t deviceId = 0;
|
||||
KSTATUS st = KeInputRegisterDevice("serial-com1", 0, &deviceId);
|
||||
|
||||
@@ -13,10 +13,10 @@ The core kernel owns only:
|
||||
Build notes:
|
||||
|
||||
- Do not use lwIP CMake.
|
||||
- `build.bat` compiles the sources listed in `drivers/lwip/lwip_sources.txt`.
|
||||
- `build.bat` compiles the sources listed in `drivers/net/lwip/lwip_sources.txt`.
|
||||
- Include directories:
|
||||
- `code/drivers/lwip/include`
|
||||
- `code/third_party/lwip/src/include`
|
||||
- `code/drivers/net/lwip/include`
|
||||
- `code/drivers/net/lwip/third_party/lwip/src/include`
|
||||
|
||||
Load order:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
# Add these lwIP 2.2.1 files to the lwip.sys driver build.
|
||||
# Include directories required:
|
||||
# code/drivers/net/lwip/include
|
||||
# code/third_party/lwip/src/include
|
||||
# code/drivers/net/lwip/third_party/lwip/src/include
|
||||
# Port glue
|
||||
drivers/net/lwip/lwip_sys_arch.c
|
||||
drivers/net/lwip/lwip_stack.c
|
||||
|
||||
# lwIP core
|
||||
third_party/lwip/src/core/init.c
|
||||
third_party/lwip/src/core/def.c
|
||||
third_party/lwip/src/core/dns.c
|
||||
third_party/lwip/src/core/inet_chksum.c
|
||||
third_party/lwip/src/core/ip.c
|
||||
third_party/lwip/src/core/mem.c
|
||||
third_party/lwip/src/core/memp.c
|
||||
third_party/lwip/src/core/netif.c
|
||||
third_party/lwip/src/core/pbuf.c
|
||||
third_party/lwip/src/core/raw.c
|
||||
third_party/lwip/src/core/stats.c
|
||||
third_party/lwip/src/core/sys.c
|
||||
third_party/lwip/src/core/altcp.c
|
||||
third_party/lwip/src/core/altcp_alloc.c
|
||||
third_party/lwip/src/core/altcp_tcp.c
|
||||
third_party/lwip/src/core/tcp.c
|
||||
third_party/lwip/src/core/tcp_in.c
|
||||
third_party/lwip/src/core/tcp_out.c
|
||||
third_party/lwip/src/core/timeouts.c
|
||||
third_party/lwip/src/core/udp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/init.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/def.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/dns.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/inet_chksum.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ip.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/mem.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/memp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/netif.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/pbuf.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/raw.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/stats.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/sys.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/altcp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/altcp_alloc.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/altcp_tcp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/tcp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/tcp_in.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/tcp_out.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/timeouts.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/udp.c
|
||||
|
||||
# IPv4
|
||||
third_party/lwip/src/core/ipv4/acd.c
|
||||
third_party/lwip/src/core/ipv4/autoip.c
|
||||
third_party/lwip/src/core/ipv4/dhcp.c
|
||||
third_party/lwip/src/core/ipv4/etharp.c
|
||||
third_party/lwip/src/core/ipv4/icmp.c
|
||||
third_party/lwip/src/core/ipv4/igmp.c
|
||||
third_party/lwip/src/core/ipv4/ip4_frag.c
|
||||
third_party/lwip/src/core/ipv4/ip4.c
|
||||
third_party/lwip/src/core/ipv4/ip4_addr.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/acd.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/autoip.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/dhcp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/etharp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/icmp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/igmp.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/ip4_frag.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/ip4.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv4/ip4_addr.c
|
||||
|
||||
|
||||
# IPv6
|
||||
third_party/lwip/src/core/ipv6/dhcp6.c
|
||||
third_party/lwip/src/core/ipv6/ethip6.c
|
||||
third_party/lwip/src/core/ipv6/icmp6.c
|
||||
third_party/lwip/src/core/ipv6/inet6.c
|
||||
third_party/lwip/src/core/ipv6/ip6_frag.c
|
||||
third_party/lwip/src/core/ipv6/ip6.c
|
||||
third_party/lwip/src/core/ipv6/ip6_addr.c
|
||||
third_party/lwip/src/core/ipv6/mld6.c
|
||||
third_party/lwip/src/core/ipv6/nd6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/dhcp6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/ethip6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/icmp6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/inet6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/ip6_frag.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/ip6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/ip6_addr.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/mld6.c
|
||||
drivers/net/lwip/third_party/lwip/src/core/ipv6/nd6.c
|
||||
|
||||
# netconn/socket API
|
||||
third_party/lwip/src/api/api_lib.c
|
||||
third_party/lwip/src/api/api_msg.c
|
||||
third_party/lwip/src/api/err.c
|
||||
third_party/lwip/src/api/netbuf.c
|
||||
third_party/lwip/src/api/tcpip.c
|
||||
drivers/net/lwip/third_party/lwip/src/api/api_lib.c
|
||||
drivers/net/lwip/third_party/lwip/src/api/api_msg.c
|
||||
drivers/net/lwip/third_party/lwip/src/api/err.c
|
||||
drivers/net/lwip/third_party/lwip/src/api/netbuf.c
|
||||
drivers/net/lwip/third_party/lwip/src/api/tcpip.c
|
||||
|
||||
# Ethernet netif helper
|
||||
third_party/lwip/src/netif/ethernet.c
|
||||
drivers/net/lwip/third_party/lwip/src/netif/ethernet.c
|
||||
@@ -5,15 +5,15 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/ddi/io_driver.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_sched.h>
|
||||
#include <kernel/ke_settings.h>
|
||||
#include <kernel/ke_semaphore.h>
|
||||
#include <kernel/ob_object.h>
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/scheduler.h>
|
||||
#include <ntlite/ddk/settings.h>
|
||||
#include <ntlite/ddk/semaphore.h>
|
||||
#include <ntlite/ddk/object.h>
|
||||
#include <ntlite/ddk/memory.h>
|
||||
#include <ntlite/ddi/net_device.h>
|
||||
#include <ntlite/ddi/net_stack.h>
|
||||
|
||||
@@ -100,6 +100,7 @@ typedef struct LWIP_PROVIDER_SOCKET {
|
||||
|
||||
static LWIP_BINDING* gBindings[LWIP_MAX_NETIFS];
|
||||
static volatile int gLwipInitialized = 0;
|
||||
static const NTL_DDK* gLwipDdk;
|
||||
|
||||
static KSTATUS LwipProviderAttachDevice(NET_DEVICE* device);
|
||||
static KSTATUS LwipProviderReceiveFrame(NET_DEVICE* device, const void* frame, size_t length);
|
||||
@@ -753,14 +754,23 @@ static void LwipInitDone(void* arg) {
|
||||
KeSignalSemaphore(sem);
|
||||
}
|
||||
|
||||
// Delays the current provider thread through the DDK scheduler table.
|
||||
static KSTATUS LwipDelayThread(uint64_t milliseconds) {
|
||||
if (!gLwipDdk || !gLwipDdk->Scheduler || !gLwipDdk->Scheduler->DelayThread)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
return gLwipDdk->Scheduler->DelayThread(milliseconds);
|
||||
}
|
||||
|
||||
// Implements the stack Initialize operation.
|
||||
static KSTATUS LwipStackInitialize(const HAL_API* hal) {
|
||||
static KSTATUS LwipStackInitialize(const NTL_DDK* ddk) {
|
||||
if (gLwipInitialized)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
if (!hal || !hal->Timer.QueryTicks)
|
||||
if (!ddk || !ddk->Timer || !ddk->Timer->QueryTicks ||
|
||||
!ddk->Scheduler || !ddk->Scheduler->DelayThread)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
LwipPortSetTimerQuery(hal->Timer.QueryTicks);
|
||||
gLwipDdk = ddk;
|
||||
LwipPortSetTimerQuery(ddk->Timer->QueryTicks);
|
||||
|
||||
SEMAPHORE* done = 0;
|
||||
KSTATUS st = KeSemaphoreCreate(0, 1, &done);
|
||||
@@ -1148,7 +1158,7 @@ static KSTATUS LwipProviderConnect(void* socket, const SYS_SOCKET_ADDRESS_K* add
|
||||
}
|
||||
|
||||
LwipSocketUnlock(s);
|
||||
(void)KeDelayThread(LWIP_PROVIDER_CANCEL_POLL_MS);
|
||||
(void)LwipDelayThread(LWIP_PROVIDER_CANCEL_POLL_MS);
|
||||
st = LwipSocketLock(s);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
@@ -1716,7 +1726,8 @@ static KSTATUS LwipDispatchInternalDeviceControl(DEVICE_OBJECT* device, IRP* irp
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)init;
|
||||
DbgPrint("lwIP: driver loading...\n");
|
||||
|
||||
LWIP_NETIF_CONFIG defaultConfig;
|
||||
@@ -1727,7 +1738,7 @@ KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
return st;
|
||||
}
|
||||
|
||||
st = LwipStackInitialize(hal);
|
||||
st = LwipStackInitialize(ddk);
|
||||
if (!KSUCCESS(st)) {
|
||||
DbgPrint("lwIP: initialization failed: 0x%x\n", st);
|
||||
return st;
|
||||
|
||||
@@ -5,19 +5,19 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <intrin.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <ntlite/ddk/ddk.h>
|
||||
#include <lwip/opt.h>
|
||||
#include <lwip/sys.h>
|
||||
#include <lwip/err.h>
|
||||
|
||||
#include <kernel/mm_virt.h>
|
||||
#include <kernel/ob_object.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_sched.h>
|
||||
#include <kernel/ke_thread.h>
|
||||
#include <kernel/ke_semaphore.h>
|
||||
#include <kernel/ke_spinlock.h>
|
||||
#include <kernel/ke_irql.h>
|
||||
#include <ntlite/ddk/memory.h>
|
||||
#include <ntlite/ddk/object.h>
|
||||
#include <ntlite/ddk/debug.h>
|
||||
#include <ntlite/ddk/scheduler.h>
|
||||
#include <ntlite/ddk/thread.h>
|
||||
#include <ntlite/ddk/semaphore.h>
|
||||
#include <ntlite/ddk/sync.h>
|
||||
#include <ntlite/ddk/irql.h>
|
||||
|
||||
#define LWIP_PORT_MBOX_DEFAULT_SIZE 128u
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
Vendored
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
Vendored
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 385 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user