mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 12:40:33 +00:00
Merge my current work done on the kd++ branch:
- FreeLdr is able now to load personalized Kernel Debugger Transport DLLs by reading at the kernel command line and interpreting the /DEBUGPORT=xxx entry (--> loads KDxxx.DLL dll in \SystemRoot\System32\). Therefore we can not only load the "default" kdcom.dll, but also 3rd-party ones such as kdbazis.dll from VirtualKD (from revision 58902). - The GCC-compiled-only version of kdcom, containing legacy COM code, was removed and put directly along KDBG. It remains only a stub / template for future kdcom-like dlls. The MSVC-version remains untouched. - Make those functions ^ use directly the CPORTLIB library. svn path=/trunk/; revision=58974
This commit is contained in:
commit
91ef640fe5
27 changed files with 876 additions and 440 deletions
|
@ -1568,7 +1568,7 @@ LoadBootDeviceDriver(VOID)
|
||||||
ULONG ImportTableSize;
|
ULONG ImportTableSize;
|
||||||
PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE;
|
PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE;
|
||||||
CHAR NtBootDdPath[MAX_PATH];
|
CHAR NtBootDdPath[MAX_PATH];
|
||||||
PVOID ImageBase;
|
PVOID ImageBase = NULL;
|
||||||
ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath);
|
ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath);
|
||||||
BOOLEAN Status;
|
BOOLEAN Status;
|
||||||
|
|
||||||
|
|
|
@ -255,11 +255,12 @@ WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WinLdrLoadImage loads the specified image from the file (it doesn't
|
/*
|
||||||
perform any additional operations on the filename, just directly
|
* WinLdrLoadImage loads the specified image from the file (it doesn't
|
||||||
calls the file I/O routines), and relocates it so that it's ready
|
* perform any additional operations on the filename, just directly
|
||||||
to be used when paging is enabled.
|
* calls the file I/O routines), and relocates it so that it's ready
|
||||||
Addressing mode: physical
|
* to be used when paging is enabled.
|
||||||
|
* Addressing mode: physical
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
WinLdrLoadImage(IN PCHAR FileName,
|
WinLdrLoadImage(IN PCHAR FileName,
|
||||||
|
@ -430,7 +431,6 @@ WinLdrLoadImage(IN PCHAR FileName,
|
||||||
if (Status != ESUCCESS)
|
if (Status != ESUCCESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
||||||
/* Relocate the image, if it needs it */
|
/* Relocate the image, if it needs it */
|
||||||
if (NtHeaders->OptionalHeader.ImageBase != (ULONG_PTR)VirtualBase)
|
if (NtHeaders->OptionalHeader.ImageBase != (ULONG_PTR)VirtualBase)
|
||||||
{
|
{
|
||||||
|
@ -756,7 +756,7 @@ WinLdrpLoadAndScanReferencedDll(PLIST_ENTRY ModuleListHead,
|
||||||
{
|
{
|
||||||
CHAR FullDllName[256];
|
CHAR FullDllName[256];
|
||||||
BOOLEAN Status;
|
BOOLEAN Status;
|
||||||
PVOID BasePA;
|
PVOID BasePA = NULL;
|
||||||
|
|
||||||
/* Prepare the full path to the file to be loaded */
|
/* Prepare the full path to the file to be loaded */
|
||||||
strcpy(FullDllName, DirectoryPath);
|
strcpy(FullDllName, DirectoryPath);
|
||||||
|
@ -781,7 +781,7 @@ WinLdrpLoadAndScanReferencedDll(PLIST_ENTRY ModuleListHead,
|
||||||
DataTableEntry);
|
DataTableEntry);
|
||||||
if (!Status)
|
if (!Status)
|
||||||
{
|
{
|
||||||
ERR("WinLdrAllocateDataTableEntry() failed with Status=0x%X\n", Status);
|
ERR("WinLdrAllocateDataTableEntry() failed\n");
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,7 +791,7 @@ WinLdrpLoadAndScanReferencedDll(PLIST_ENTRY ModuleListHead,
|
||||||
Status = WinLdrScanImportDescriptorTable(ModuleListHead, DirectoryPath, *DataTableEntry);
|
Status = WinLdrScanImportDescriptorTable(ModuleListHead, DirectoryPath, *DataTableEntry);
|
||||||
if (!Status)
|
if (!Status)
|
||||||
{
|
{
|
||||||
ERR("WinLdrScanImportDescriptorTable() failed with Status=0x%X\n", Status);
|
ERR("WinLdrScanImportDescriptorTable() failed\n");
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
|
WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
|
||||||
LPSTR BootPath,
|
LPCSTR BootPath,
|
||||||
PUNICODE_STRING FilePath,
|
PUNICODE_STRING FilePath,
|
||||||
ULONG Flags,
|
ULONG Flags,
|
||||||
PLDR_DATA_TABLE_ENTRY *DriverDTE)
|
PLDR_DATA_TABLE_ENTRY *DriverDTE)
|
||||||
|
@ -237,7 +237,7 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
|
||||||
CHAR DllName[1024];
|
CHAR DllName[1024];
|
||||||
PCHAR DriverNamePos;
|
PCHAR DriverNamePos;
|
||||||
BOOLEAN Status;
|
BOOLEAN Status;
|
||||||
PVOID DriverBase;
|
PVOID DriverBase = NULL;
|
||||||
|
|
||||||
// Separate the path to file name and directory path
|
// Separate the path to file name and directory path
|
||||||
_snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
|
_snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
|
||||||
|
@ -259,7 +259,6 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
|
||||||
|
|
||||||
TRACE("DriverPath: %s, DllName: %s, LPB\n", DriverPath, DllName);
|
TRACE("DriverPath: %s, DllName: %s, LPB\n", DriverPath, DllName);
|
||||||
|
|
||||||
|
|
||||||
// Check if driver is already loaded
|
// Check if driver is already loaded
|
||||||
Status = WinLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
|
Status = WinLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
|
||||||
if (Status)
|
if (Status)
|
||||||
|
@ -299,7 +298,7 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
LPSTR BootPath)
|
LPCSTR BootPath)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY NextBd;
|
PLIST_ENTRY NextBd;
|
||||||
PBOOT_DRIVER_LIST_ENTRY BootDriver;
|
PBOOT_DRIVER_LIST_ENTRY BootDriver;
|
||||||
|
@ -318,8 +317,11 @@ WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
// Paths are relative (FIXME: Are they always relative?)
|
// Paths are relative (FIXME: Are they always relative?)
|
||||||
|
|
||||||
// Load it
|
// Load it
|
||||||
Status = WinLdrLoadDeviceDriver(&LoaderBlock->LoadOrderListHead, BootPath, &BootDriver->FilePath,
|
Status = WinLdrLoadDeviceDriver(&LoaderBlock->LoadOrderListHead,
|
||||||
0, &BootDriver->LdrEntry);
|
BootPath,
|
||||||
|
&BootDriver->FilePath,
|
||||||
|
0,
|
||||||
|
&BootDriver->LdrEntry);
|
||||||
|
|
||||||
// If loading failed - cry loudly
|
// If loading failed - cry loudly
|
||||||
//FIXME: Maybe remove it from the list and try to continue?
|
//FIXME: Maybe remove it from the list and try to continue?
|
||||||
|
@ -340,7 +342,9 @@ WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
|
PVOID
|
||||||
|
WinLdrLoadModule(PCSTR ModuleName,
|
||||||
|
ULONG *Size,
|
||||||
TYPE_OF_MEMORY MemoryType)
|
TYPE_OF_MEMORY MemoryType)
|
||||||
{
|
{
|
||||||
ULONG FileId;
|
ULONG FileId;
|
||||||
|
@ -398,7 +402,6 @@ PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
|
||||||
return PhysicalBase;
|
return PhysicalBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
USHORT
|
USHORT
|
||||||
WinLdrDetectVersion()
|
WinLdrDetectVersion()
|
||||||
{
|
{
|
||||||
|
@ -420,19 +423,20 @@ WinLdrDetectVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
PVOID
|
BOOLEAN
|
||||||
LoadModule(
|
LoadModule(
|
||||||
PLOADER_PARAMETER_BLOCK LoaderBlock,
|
PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
PCCH Path,
|
PCCH Path,
|
||||||
PCCH File,
|
PCCH File,
|
||||||
TYPE_OF_MEMORY MemoryType,
|
TYPE_OF_MEMORY MemoryType,
|
||||||
PLDR_DATA_TABLE_ENTRY *Dte,
|
PLDR_DATA_TABLE_ENTRY *Dte,
|
||||||
|
BOOLEAN IsKdTransportDll,
|
||||||
ULONG Percentage)
|
ULONG Percentage)
|
||||||
{
|
{
|
||||||
|
BOOLEAN Status;
|
||||||
CHAR FullFileName[MAX_PATH];
|
CHAR FullFileName[MAX_PATH];
|
||||||
CHAR ProgressString[256];
|
CHAR ProgressString[256];
|
||||||
NTSTATUS Status;
|
PVOID BaseAdress = NULL;
|
||||||
PVOID BaseAdress;
|
|
||||||
|
|
||||||
UiDrawBackdrop();
|
UiDrawBackdrop();
|
||||||
sprintf(ProgressString, "Loading %s...", File);
|
sprintf(ProgressString, "Loading %s...", File);
|
||||||
|
@ -443,15 +447,146 @@ LoadModule(
|
||||||
strcat(FullFileName, File);
|
strcat(FullFileName, File);
|
||||||
|
|
||||||
Status = WinLdrLoadImage(FullFileName, MemoryType, &BaseAdress);
|
Status = WinLdrLoadImage(FullFileName, MemoryType, &BaseAdress);
|
||||||
TRACE("%s loaded with status %d at %p\n",
|
if (!Status)
|
||||||
File, Status, BaseAdress);
|
{
|
||||||
|
TRACE("Loading %s failed\n", File);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
TRACE("%s loaded successfully at %p\n", File, BaseAdress);
|
||||||
|
|
||||||
strcpy(FullFileName, "WINDOWS\\SYSTEM32\\");
|
strcpy(FullFileName, "WINDOWS\\SYSTEM32\\");
|
||||||
strcat(FullFileName, File);
|
strcat(FullFileName, File);
|
||||||
WinLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead, File,
|
/*
|
||||||
FullFileName, BaseAdress, Dte);
|
* Cheat about the base DLL name if we are loading
|
||||||
|
* the Kernel Debugger Transport DLL, to make the
|
||||||
|
* PE loader happy.
|
||||||
|
*/
|
||||||
|
Status = WinLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
|
||||||
|
(IsKdTransportDll ? "KDCOM.DLL" : File),
|
||||||
|
FullFileName,
|
||||||
|
BaseAdress,
|
||||||
|
Dte);
|
||||||
|
|
||||||
return BaseAdress;
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOLEAN
|
||||||
|
LoadWindowsCore(IN USHORT OperatingSystemVersion,
|
||||||
|
IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
|
IN LPCSTR BootOptions,
|
||||||
|
IN LPCSTR BootPath,
|
||||||
|
IN OUT PLDR_DATA_TABLE_ENTRY* KernelDTE)
|
||||||
|
{
|
||||||
|
BOOLEAN Status;
|
||||||
|
CHAR DirPath[MAX_PATH];
|
||||||
|
CHAR KdTransportDllName[MAX_PATH];
|
||||||
|
PLDR_DATA_TABLE_ENTRY HalDTE, KdComDTE = NULL;
|
||||||
|
|
||||||
|
if (!KernelDTE) return FALSE;
|
||||||
|
|
||||||
|
/* Load the Kernel */
|
||||||
|
LoadModule(LoaderBlock, BootPath, "NTOSKRNL.EXE", LoaderSystemCode, KernelDTE, FALSE, 30);
|
||||||
|
|
||||||
|
/* Load the HAL */
|
||||||
|
LoadModule(LoaderBlock, BootPath, "HAL.DLL", LoaderHalCode, &HalDTE, FALSE, 45);
|
||||||
|
|
||||||
|
/* Load the Kernel Debugger Transport DLL */
|
||||||
|
if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* According to http://www.nynaeve.net/?p=173 :
|
||||||
|
* "[...] Another enhancement that could be done Microsoft-side would be
|
||||||
|
* a better interface for replacing KD transport modules. Right now, due
|
||||||
|
* to the fact that ntoskrnl is static linked to KDCOM.DLL, the OS loader
|
||||||
|
* has a hardcoded hack that interprets the KD type in the OS loader options,
|
||||||
|
* loads one of the (hardcoded filenames) "kdcom.dll", "kd1394.dll", or
|
||||||
|
* "kdusb2.dll" modules, and inserts them into the loaded module list under
|
||||||
|
* the name "kdcom.dll". [...]"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This loop replaces a dumb call to strstr(..., "DEBUGPORT=").
|
||||||
|
* Indeed I want it to be case-insensitive to allow "debugport="
|
||||||
|
* or "DeBuGpOrT=" or... , and I don't want it to match malformed
|
||||||
|
* command-line options, such as:
|
||||||
|
*
|
||||||
|
* "...foo DEBUGPORT=xxx bar..."
|
||||||
|
* "...foo/DEBUGPORT=xxx bar..."
|
||||||
|
* "...foo/DEBUGPORT=bar..."
|
||||||
|
*
|
||||||
|
* i.e. the "DEBUGPORT=" switch must start with a slash and be separated
|
||||||
|
* from the rest by whitespace, unless it begins the command-line, e.g.:
|
||||||
|
*
|
||||||
|
* "/DEBUGPORT=COM1 foo...bar..."
|
||||||
|
* "...foo /DEBUGPORT=USB bar..."
|
||||||
|
* or:
|
||||||
|
* "...foo /DEBUGPORT= bar..."
|
||||||
|
* (in that case, we default the port to COM).
|
||||||
|
*/
|
||||||
|
while (BootOptions)
|
||||||
|
{
|
||||||
|
/* Skip possible initial whitespace */
|
||||||
|
BootOptions += strspn(BootOptions, " \t");
|
||||||
|
|
||||||
|
/* Check whether a new commutator starts and it is the DEBUGPORT one */
|
||||||
|
if (*BootOptions != '/' || _strnicmp(++BootOptions, "DEBUGPORT=", 10) != 0)
|
||||||
|
{
|
||||||
|
/* Search for another whitespace */
|
||||||
|
BootOptions = strpbrk(BootOptions, " \t");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We found the DEBUGPORT commutator. Move to the port name. */
|
||||||
|
BootOptions += 10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BootOptions)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We have found the DEBUGPORT commutator. Parse the port name.
|
||||||
|
* Format: /DEBUGPORT=COM1 or /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log or /DEBUGPORT=FOO
|
||||||
|
* If we only have /DEBUGPORT= (i.e. without any port name), defaults it to "COM".
|
||||||
|
*/
|
||||||
|
strcpy(KdTransportDllName, "KD");
|
||||||
|
if (_strnicmp(BootOptions, "COM", 3) == 0 && '0' <= BootOptions[3] && BootOptions[3] <= '9')
|
||||||
|
{
|
||||||
|
strncat(KdTransportDllName, BootOptions, 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t i = strcspn(BootOptions, " \t:"); /* Skip valid separators: whitespace or colon */
|
||||||
|
if (i == 0)
|
||||||
|
strcat(KdTransportDllName, "COM");
|
||||||
|
else
|
||||||
|
strncat(KdTransportDllName, BootOptions, i);
|
||||||
|
}
|
||||||
|
strcat(KdTransportDllName, ".DLL");
|
||||||
|
_strupr(KdTransportDllName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the transport DLL. Specify it to LoadModule so that it can
|
||||||
|
* change the base DLL name of the loaded transport DLL to the default
|
||||||
|
* "KDCOM.DLL" name, to make the PE loader happy.
|
||||||
|
*/
|
||||||
|
LoadModule(LoaderBlock, BootPath, KdTransportDllName, LoaderSystemCode, &KdComDTE, TRUE, 60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
|
||||||
|
strcpy(DirPath, BootPath);
|
||||||
|
strcat(DirPath, "system32\\");
|
||||||
|
Status = WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
|
||||||
|
Status &= WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
|
||||||
|
if (KdComDTE)
|
||||||
|
{
|
||||||
|
Status &= WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdComDTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -496,7 +631,7 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
|
||||||
strcat(BootPath, FileName);
|
strcat(BootPath, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append a backslash */
|
/* Append a backslash */
|
||||||
if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\')
|
if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\')
|
||||||
strcat(BootPath, "\\");
|
strcat(BootPath, "\\");
|
||||||
|
|
||||||
|
@ -547,13 +682,13 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
|
||||||
UiDrawBackdrop();
|
UiDrawBackdrop();
|
||||||
UiDrawProgressBarCenter(15, 100, "Loading system hive...");
|
UiDrawProgressBarCenter(15, 100, "Loading system hive...");
|
||||||
Status = WinLdrInitSystemHive(LoaderBlock, BootPath);
|
Status = WinLdrInitSystemHive(LoaderBlock, BootPath);
|
||||||
TRACE("SYSTEM hive loaded with status %d\n", Status);
|
TRACE("SYSTEM hive %s\n", (Status ? "loaded" : "not loaded"));
|
||||||
|
|
||||||
/* Load NLS data, OEM font, and prepare boot drivers list */
|
/* Load NLS data, OEM font, and prepare boot drivers list */
|
||||||
Status = WinLdrScanSystemHive(LoaderBlock, BootPath);
|
Status = WinLdrScanSystemHive(LoaderBlock, BootPath);
|
||||||
TRACE("SYSTEM hive scanned with status %d\n", Status);
|
TRACE("SYSTEM hive %s\n", (Status ? "scanned" : "not scanned"));
|
||||||
|
|
||||||
|
|
||||||
|
/* Finish loading */
|
||||||
LoadAndBootWindowsCommon(OperatingSystemVersion,
|
LoadAndBootWindowsCommon(OperatingSystemVersion,
|
||||||
LoaderBlock,
|
LoaderBlock,
|
||||||
BootOptions,
|
BootOptions,
|
||||||
|
@ -571,8 +706,7 @@ LoadAndBootWindowsCommon(
|
||||||
{
|
{
|
||||||
PLOADER_PARAMETER_BLOCK LoaderBlockVA;
|
PLOADER_PARAMETER_BLOCK LoaderBlockVA;
|
||||||
BOOLEAN Status;
|
BOOLEAN Status;
|
||||||
CHAR FileName[MAX_PATH];
|
PLDR_DATA_TABLE_ENTRY KernelDTE;
|
||||||
PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL;
|
|
||||||
KERNEL_ENTRY_POINT KiSystemStartup;
|
KERNEL_ENTRY_POINT KiSystemStartup;
|
||||||
LPCSTR SystemRoot;
|
LPCSTR SystemRoot;
|
||||||
TRACE("LoadAndBootWindowsCommon()\n");
|
TRACE("LoadAndBootWindowsCommon()\n");
|
||||||
|
@ -586,40 +720,30 @@ LoadAndBootWindowsCommon(
|
||||||
if (OperatingSystemVersion == 0)
|
if (OperatingSystemVersion == 0)
|
||||||
OperatingSystemVersion = WinLdrDetectVersion();
|
OperatingSystemVersion = WinLdrDetectVersion();
|
||||||
|
|
||||||
/* Load kernel */
|
/* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
|
||||||
LoadModule(LoaderBlock, BootPath, "NTOSKRNL.EXE", LoaderSystemCode, &KernelDTE, 30);
|
Status = LoadWindowsCore(OperatingSystemVersion,
|
||||||
|
LoaderBlock,
|
||||||
/* Load HAL */
|
BootOptions,
|
||||||
LoadModule(LoaderBlock, BootPath, "HAL.DLL", LoaderHalCode, &HalDTE, 45);
|
BootPath,
|
||||||
|
&KernelDTE);
|
||||||
/* Load kernel-debugger support dll */
|
|
||||||
if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
|
|
||||||
{
|
|
||||||
LoadModule(LoaderBlock, BootPath, "KDCOM.DLL", LoaderSystemCode, &KdComDTE, 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load all referenced DLLs for kernel, HAL and kdcom.dll */
|
|
||||||
strcpy(FileName, BootPath);
|
|
||||||
strcat(FileName, "system32\\");
|
|
||||||
Status = WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, FileName, KernelDTE);
|
|
||||||
Status &= WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, FileName, HalDTE);
|
|
||||||
if (KdComDTE)
|
|
||||||
Status &= WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, FileName, KdComDTE);
|
|
||||||
|
|
||||||
if (!Status)
|
if (!Status)
|
||||||
{
|
{
|
||||||
UiMessageBox("Error loading imported dll.");
|
UiMessageBox("Error loading NTOS core.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load boot drivers */
|
/* Load boot drivers */
|
||||||
UiDrawBackdrop();
|
UiDrawBackdrop();
|
||||||
UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
|
UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
|
||||||
Status = WinLdrLoadBootDrivers(LoaderBlock, (PCHAR)BootPath);
|
Status = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
|
||||||
TRACE("Boot drivers loaded with status %d\n", Status);
|
TRACE("Boot drivers loaded with status %d\n", Status);
|
||||||
|
|
||||||
/* Initialize Phase 1 - no drivers loading anymore */
|
/* Initialize Phase 1 - no drivers loading anymore */
|
||||||
WinLdrInitializePhase1(LoaderBlock, BootOptions, SystemRoot, BootPath, OperatingSystemVersion);
|
WinLdrInitializePhase1(LoaderBlock,
|
||||||
|
BootOptions,
|
||||||
|
SystemRoot,
|
||||||
|
BootPath,
|
||||||
|
OperatingSystemVersion);
|
||||||
|
|
||||||
/* Save entry-point pointer and Loader block VAs */
|
/* Save entry-point pointer and Loader block VAs */
|
||||||
KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint;
|
KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint;
|
||||||
|
@ -722,5 +846,3 @@ WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
NextBd = ArcDisk->ListEntry.Flink;
|
NextBd = ArcDisk->ListEntry.Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,10 @@ add_subdirectory(beep)
|
||||||
add_subdirectory(bootvid)
|
add_subdirectory(bootvid)
|
||||||
|
|
||||||
if(_WINKD_)
|
if(_WINKD_)
|
||||||
add_subdirectory(kddll)
|
|
||||||
else()
|
|
||||||
add_subdirectory(kdcom)
|
add_subdirectory(kdcom)
|
||||||
|
else()
|
||||||
|
add_subdirectory(kdrosdbg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(nmidebug)
|
add_subdirectory(nmidebug)
|
||||||
add_subdirectory(null)
|
add_subdirectory(null)
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
|
|
||||||
spec2def(kdcom.dll kdcom.spec ADD_IMPORTLIB)
|
spec2def(kdcom.dll kdcom.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
if(ARCH STREQUAL "i386")
|
add_library(kdcom SHARED
|
||||||
list(APPEND SOURCE i386/kdbg.c)
|
kdcom.c
|
||||||
elseif(ARCH STREQUAL "amd64")
|
kddll.c
|
||||||
list(APPEND SOURCE i386/kdbg.c)
|
kdserial.c
|
||||||
elseif(ARCH STREQUAL "arm")
|
|
||||||
list(APPEND SOURCE arm/kdbg.c)
|
|
||||||
endif(ARCH STREQUAL "i386")
|
|
||||||
list(APPEND SOURCE
|
|
||||||
kdcom.rc
|
kdcom.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/kdcom.def)
|
${CMAKE_CURRENT_BINARY_DIR}/kdcom.def)
|
||||||
|
|
||||||
add_library(kdcom SHARED ${SOURCE})
|
|
||||||
|
|
||||||
set_entrypoint(kdcom 0)
|
set_entrypoint(kdcom 0)
|
||||||
set_subsystem(kdcom native)
|
set_subsystem(kdcom native)
|
||||||
set_image_base(kdcom 0x00010000)
|
set_image_base(kdcom 0x00010000)
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#define DEFAULT_BAUD_RATE 19200
|
#define DEFAULT_BAUD_RATE 19200
|
||||||
|
|
||||||
|
|
||||||
#if defined(_M_IX86) || defined(_M_AMD64)
|
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||||
const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
||||||
#elif defined(_M_PPC)
|
#elif defined(_M_PPC)
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#define REACTOS_VERSION_DLL
|
#define REACTOS_VERSION_DLL
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS KDBG COM Library"
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Kernel Debugger COM Extension DLL"
|
||||||
#define REACTOS_STR_INTERNAL_NAME "kdcom"
|
#define REACTOS_STR_INTERNAL_NAME "kdcom"
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "kdcom.dll"
|
#define REACTOS_STR_ORIGINAL_FILENAME "kdcom.dll"
|
||||||
#include <reactos/version.rc>
|
#include <reactos/version.rc>
|
||||||
|
|
|
@ -1,21 +1,8 @@
|
||||||
; Old KD
|
@ stdcall KdD0Transition()
|
||||||
@ stdcall KdPortGetByte(ptr)
|
@ stdcall KdD3Transition()
|
||||||
@ stdcall KdPortGetByteEx(ptr ptr)
|
|
||||||
@ stdcall KdPortInitialize(ptr long long)
|
|
||||||
@ stdcall KdPortInitializeEx(ptr long long)
|
|
||||||
@ stdcall KdPortPollByte(ptr)
|
|
||||||
@ stdcall KdPortPollByteEx(ptr ptr)
|
|
||||||
@ stdcall KdPortPutByte(long)
|
|
||||||
@ stdcall KdPortPutByteEx(ptr long)
|
|
||||||
@ stdcall KdPortRestore()
|
|
||||||
@ stdcall KdPortSave()
|
|
||||||
@ stdcall KdPortDisableInterrupts()
|
|
||||||
@ stdcall KdPortEnableInterrupts()
|
|
||||||
|
|
||||||
; New KD
|
|
||||||
@ stdcall KdDebuggerInitialize0(ptr)
|
@ stdcall KdDebuggerInitialize0(ptr)
|
||||||
@ stdcall KdDebuggerInitialize1(ptr)
|
@ stdcall KdDebuggerInitialize1(ptr)
|
||||||
@ stdcall KdSave(long)
|
|
||||||
@ stdcall KdRestore(long)
|
|
||||||
@ stdcall KdReceivePacket(long ptr ptr ptr ptr)
|
@ stdcall KdReceivePacket(long ptr ptr ptr ptr)
|
||||||
|
@ stdcall KdRestore(long)
|
||||||
|
@ stdcall KdSave(long)
|
||||||
@ stdcall KdSendPacket(long ptr ptr ptr)
|
@ stdcall KdSendPacket(long ptr ptr ptr)
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
@ stdcall KdD0Transition()
|
|
||||||
@ stdcall KdD3Transition()
|
|
||||||
@ stdcall KdDebuggerInitialize0(ptr)
|
|
||||||
@ stdcall KdDebuggerInitialize1(ptr)
|
|
||||||
@ stdcall KdReceivePacket(long ptr ptr ptr ptr)
|
|
||||||
@ stdcall KdRestore(long)
|
|
||||||
@ stdcall KdSave(long)
|
|
||||||
@ stdcall KdSendPacket(long ptr ptr ptr)
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
spec2def(kdcom.dll kdcom.spec ADD_IMPORTLIB)
|
spec2def(kdcom.dll kdrosdbg.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
add_library(kdcom SHARED
|
list(APPEND SOURCE
|
||||||
kdcom.c
|
kdrosdbg.c
|
||||||
kddll.c
|
kdrosdbg.rc
|
||||||
kdserial.c
|
|
||||||
kdcom.rc
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/kdcom.def)
|
${CMAKE_CURRENT_BINARY_DIR}/kdcom.def)
|
||||||
|
|
||||||
|
add_library(kdcom SHARED ${SOURCE})
|
||||||
|
|
||||||
set_entrypoint(kdcom 0)
|
set_entrypoint(kdcom 0)
|
||||||
set_subsystem(kdcom native)
|
set_subsystem(kdcom native)
|
||||||
set_image_base(kdcom 0x00010000)
|
set_image_base(kdcom 0x00010000)
|
116
reactos/drivers/base/kdrosdbg/kdrosdbg.c
Normal file
116
reactos/drivers/base/kdrosdbg/kdrosdbg.c
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: drivers/base/kdcom/kdbg.c
|
||||||
|
* PURPOSE: Serial i/o functions for the kernel debugger.
|
||||||
|
* PROGRAMMER: Alex Ionescu
|
||||||
|
* Hervé Poussineau
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#define NOEXTAPI
|
||||||
|
#include <ntifs.h>
|
||||||
|
#include <halfuncs.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <arc/arc.h>
|
||||||
|
#include <windbgkd.h>
|
||||||
|
#include <kddll.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdDebuggerInitialize0(
|
||||||
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdDebuggerInitialize1(
|
||||||
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdD0Transition(VOID)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdD3Transition(VOID)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdSave(
|
||||||
|
IN BOOLEAN SleepTransition)
|
||||||
|
{
|
||||||
|
/* Nothing to do on COM ports */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdRestore(
|
||||||
|
IN BOOLEAN SleepTransition)
|
||||||
|
{
|
||||||
|
/* Nothing to do on COM ports */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
KdSendPacket(
|
||||||
|
IN ULONG PacketType,
|
||||||
|
IN PSTRING MessageHeader,
|
||||||
|
IN PSTRING MessageData,
|
||||||
|
IN OUT PKD_CONTEXT Context)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
KDSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdReceivePacket(
|
||||||
|
IN ULONG PacketType,
|
||||||
|
OUT PSTRING MessageHeader,
|
||||||
|
OUT PSTRING MessageData,
|
||||||
|
OUT PULONG DataLength,
|
||||||
|
IN OUT PKD_CONTEXT Context)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#define REACTOS_VERSION_DLL
|
#define REACTOS_VERSION_DLL
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Kernel Debugger COM Extension DLL"
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS KDBG COM Library"
|
||||||
#define REACTOS_STR_INTERNAL_NAME "kdcom"
|
#define REACTOS_STR_INTERNAL_NAME "kdcom"
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "kdcom.dll"
|
#define REACTOS_STR_ORIGINAL_FILENAME "kdcom.dll"
|
||||||
#include <reactos/version.rc>
|
#include <reactos/version.rc>
|
|
@ -363,6 +363,7 @@ endif()
|
||||||
if(NOT _WINKD_)
|
if(NOT _WINKD_)
|
||||||
if(ARCH STREQUAL "i386")
|
if(ARCH STREQUAL "i386")
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
|
kd/i386/kdbg.c
|
||||||
kd/i386/kdmemsup.c
|
kd/i386/kdmemsup.c
|
||||||
kd/wrappers/gdbstub.c)
|
kd/wrappers/gdbstub.c)
|
||||||
if(KDBG)
|
if(KDBG)
|
||||||
|
@ -372,6 +373,7 @@ if(NOT _WINKD_)
|
||||||
elseif(ARCH STREQUAL "amd64")
|
elseif(ARCH STREQUAL "amd64")
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
kd/amd64/kd.c
|
kd/amd64/kd.c
|
||||||
|
kd/i386/kdbg.c # Use the x86 file
|
||||||
kd/amd64/kdmemsup.c)
|
kd/amd64/kdmemsup.c)
|
||||||
if(KDBG)
|
if(KDBG)
|
||||||
list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
|
list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
|
||||||
|
@ -379,6 +381,8 @@ if(NOT _WINKD_)
|
||||||
kdbg/amd64/i386-dis.c
|
kdbg/amd64/i386-dis.c
|
||||||
kdbg/amd64/kdb.c)
|
kdbg/amd64/kdb.c)
|
||||||
endif()
|
endif()
|
||||||
|
elseif(ARCH STREQUAL "arm")
|
||||||
|
list(APPEND SOURCE kd/arm/kdbg.c)
|
||||||
elseif(ARCH STREQUAL "powerpc")
|
elseif(ARCH STREQUAL "powerpc")
|
||||||
list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
|
list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cportlib/cportlib.h>
|
||||||
|
|
||||||
#ifdef _M_PPC
|
#ifdef _M_PPC
|
||||||
#define KdDebuggerEnabled _KdDebuggerEnabled
|
#define KdDebuggerEnabled _KdDebuggerEnabled
|
||||||
#define KdDebuggerNotPresent _KdDebuggerNotPresent
|
#define KdDebuggerNotPresent _KdDebuggerNotPresent
|
||||||
|
@ -8,58 +10,31 @@
|
||||||
//
|
//
|
||||||
// Kernel Debugger Port Definition
|
// Kernel Debugger Port Definition
|
||||||
//
|
//
|
||||||
typedef struct _KD_PORT_INFORMATION
|
|
||||||
{
|
|
||||||
ULONG ComPort;
|
|
||||||
ULONG BaudRate;
|
|
||||||
ULONG BaseAddress;
|
|
||||||
} KD_PORT_INFORMATION, *PKD_PORT_INFORMATION;
|
|
||||||
|
|
||||||
struct _KD_DISPATCH_TABLE;
|
struct _KD_DISPATCH_TABLE;
|
||||||
extern KD_PORT_INFORMATION GdbPortInfo;
|
extern CPPORT GdbPortInfo;
|
||||||
extern BOOLEAN _KdDebuggerEnabled;
|
extern BOOLEAN _KdDebuggerEnabled;
|
||||||
extern BOOLEAN _KdDebuggerNotPresent;
|
extern BOOLEAN _KdDebuggerNotPresent;
|
||||||
extern BOOLEAN KdBreakAfterSymbolLoad;
|
extern BOOLEAN KdBreakAfterSymbolLoad;
|
||||||
extern BOOLEAN KdPitchDebugger;
|
extern BOOLEAN KdPitchDebugger;
|
||||||
extern BOOLEAN KdIgnoreUmExceptions;
|
extern BOOLEAN KdIgnoreUmExceptions;
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
KdPortInitialize(
|
|
||||||
PKD_PORT_INFORMATION PortInformation,
|
|
||||||
ULONG Unknown1,
|
|
||||||
ULONG Unknown2
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
KdPortInitializeEx(
|
KdPortInitializeEx(
|
||||||
PKD_PORT_INFORMATION PortInformation,
|
PCPPORT PortInformation,
|
||||||
ULONG Unknown1,
|
ULONG ComPortNumber
|
||||||
ULONG Unknown2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
KdPortGetByte(
|
|
||||||
PUCHAR ByteReceived);
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
KdPortGetByteEx(
|
KdPortGetByteEx(
|
||||||
PKD_PORT_INFORMATION PortInformation,
|
PCPPORT PortInformation,
|
||||||
PUCHAR ByteReceived);
|
PUCHAR ByteReceived);
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
KdPortPutByte(
|
|
||||||
UCHAR ByteToSend
|
|
||||||
);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdPortPutByteEx(
|
KdPortPutByteEx(
|
||||||
PKD_PORT_INFORMATION PortInformation,
|
PCPPORT PortInformation,
|
||||||
UCHAR ByteToSend
|
UCHAR ByteToSend
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -359,7 +334,8 @@ extern ULONG KdpPortIrq;
|
||||||
extern ULONG KdpPort;
|
extern ULONG KdpPort;
|
||||||
|
|
||||||
/* Port Information for the Serial Native Mode */
|
/* Port Information for the Serial Native Mode */
|
||||||
extern KD_PORT_INFORMATION SerialPortInfo;
|
extern ULONG SerialPortNumber;
|
||||||
|
extern CPPORT SerialPortInfo;
|
||||||
|
|
||||||
/* Init Functions for Native Providers */
|
/* Init Functions for Native Providers */
|
||||||
extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
|
extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
|
||||||
|
|
|
@ -95,10 +95,6 @@
|
||||||
#define TAG_VPB ' BPV'
|
#define TAG_VPB ' BPV'
|
||||||
#define TAG_SYSB 'BSYS'
|
#define TAG_SYSB 'BSYS'
|
||||||
|
|
||||||
/* formerly located in kdbg/kdb_symbols.c */
|
|
||||||
#define TAG_KDBS 'SBDK'
|
|
||||||
#define TAG_KDBG 'GBDK'
|
|
||||||
|
|
||||||
/* formerly located in ldr/loader.c */
|
/* formerly located in ldr/loader.c */
|
||||||
#define TAG_DRIVER_MEM 'MVRD' /* drvm */
|
#define TAG_DRIVER_MEM 'MVRD' /* drvm */
|
||||||
#define TAG_MODULE_OBJECT 'omlk' /* klmo - kernel ldr module object */
|
#define TAG_MODULE_OBJECT 'omlk' /* klmo - kernel ldr module object */
|
||||||
|
|
112
reactos/ntoskrnl/kd/arm/kdbg.c
Normal file
112
reactos/ntoskrnl/kd/arm/kdbg.c
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Kernel
|
||||||
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
||||||
|
* FILE: drivers/base/kdcom/arm/kdbg.c
|
||||||
|
* PURPOSE: Serial Port Kernel Debugging Transport Library
|
||||||
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
|
#include <ntoskrnl.h>
|
||||||
|
#include <arm/peripherals/pl011.h>
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
|
CPPORT DefaultPort = {0, 0, 0};
|
||||||
|
|
||||||
|
//
|
||||||
|
// We need to build this in the configuration root and use KeFindConfigurationEntry
|
||||||
|
// to recover it later.
|
||||||
|
//
|
||||||
|
#define HACK 24000000
|
||||||
|
|
||||||
|
/* REACTOS FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdDebuggerInitialize1(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
KdPortInitializeEx(IN PCPPORT PortInformation,
|
||||||
|
IN ULONG ComPortNumber)
|
||||||
|
{
|
||||||
|
ULONG Divider, Remainder, Fraction;
|
||||||
|
ULONG Baudrate = PortInformation->BaudRate;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate baudrate clock divider and remainder
|
||||||
|
//
|
||||||
|
Divider = HACK / (16 * Baudrate);
|
||||||
|
Remainder = HACK % (16 * Baudrate);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate the fractional part
|
||||||
|
//
|
||||||
|
Fraction = (8 * Remainder / Baudrate) >> 1;
|
||||||
|
Fraction += (8 * Remainder / Baudrate) & 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Disable interrupts
|
||||||
|
//
|
||||||
|
WRITE_REGISTER_ULONG(UART_PL011_CR, 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the baud rate
|
||||||
|
//
|
||||||
|
WRITE_REGISTER_ULONG(UART_PL011_IBRD, Divider);
|
||||||
|
WRITE_REGISTER_ULONG(UART_PL011_FBRD, Fraction);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set 8 bits for data, 1 stop bit, no parity, FIFO enabled
|
||||||
|
//
|
||||||
|
WRITE_REGISTER_ULONG(UART_PL011_LCRH,
|
||||||
|
UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clear and enable FIFO
|
||||||
|
//
|
||||||
|
WRITE_REGISTER_ULONG(UART_PL011_CR,
|
||||||
|
UART_PL011_CR_UARTEN |
|
||||||
|
UART_PL011_CR_TXE |
|
||||||
|
UART_PL011_CR_RXE);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done
|
||||||
|
//
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
KdPortGetByteEx(IN PCPPORT PortInformation,
|
||||||
|
OUT PUCHAR ByteReceived)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
while (TRUE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
KdPortPutByteEx(IN PCPPORT PortInformation,
|
||||||
|
IN UCHAR ByteToSend)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Wait for ready
|
||||||
|
//
|
||||||
|
while ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_TXFF) != 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the character
|
||||||
|
//
|
||||||
|
WRITE_REGISTER_ULONG(UART_PL01x_DR, ByteToSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
151
reactos/ntoskrnl/kd/i386/kdbg.c
Normal file
151
reactos/ntoskrnl/kd/i386/kdbg.c
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: drivers/base/kdcom/kdbg.c
|
||||||
|
* PURPOSE: Serial i/o functions for the kernel debugger.
|
||||||
|
* PROGRAMMER: Alex Ionescu
|
||||||
|
* Hervé Poussineau
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ntoskrnl.h>
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define DEFAULT_BAUD_RATE 19200
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||||
|
const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
||||||
|
#elif defined(_M_PPC)
|
||||||
|
const ULONG BaseArray[] = {0, 0x800003F8};
|
||||||
|
#elif defined(_M_MIPS)
|
||||||
|
const ULONG BaseArray[] = {0, 0x80006000, 0x80007000};
|
||||||
|
#elif defined(_M_ARM)
|
||||||
|
const ULONG BaseArray[] = {0, 0xF1012000};
|
||||||
|
#else
|
||||||
|
#error Unknown architecture
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* STATIC VARIABLES ***********************************************************/
|
||||||
|
|
||||||
|
// static CPPORT DefaultPort = {0, 0, 0};
|
||||||
|
|
||||||
|
/* The COM port must only be initialized once! */
|
||||||
|
// static BOOLEAN PortInitialized = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
/* REACTOS FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KdDebuggerInitialize1(
|
||||||
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
KdPortInitializeEx(
|
||||||
|
IN PCPPORT PortInformation,
|
||||||
|
IN ULONG ComPortNumber)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
CHAR buffer[80];
|
||||||
|
|
||||||
|
#if 0 // Deactivated because never used in fact (was in KdPortInitialize but we use KdPortInitializeEx)
|
||||||
|
/*
|
||||||
|
* Find the port if needed
|
||||||
|
*/
|
||||||
|
SIZE_T i;
|
||||||
|
|
||||||
|
if (!PortInitialized)
|
||||||
|
{
|
||||||
|
DefaultPort.BaudRate = PortInformation->BaudRate;
|
||||||
|
|
||||||
|
if (ComPortNumber == 0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Start enumerating COM ports from the last one to the first one,
|
||||||
|
* and break when we find a valid port.
|
||||||
|
* If we reach the first element of the list, the invalid COM port,
|
||||||
|
* then it means that no valid port was found.
|
||||||
|
*/
|
||||||
|
for (i = sizeof(BaseArray) / sizeof(BaseArray[0]) - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (CpDoesPortExist(UlongToPtr(BaseArray[i])))
|
||||||
|
{
|
||||||
|
PortInformation->Address = DefaultPort.Address = BaseArray[i];
|
||||||
|
ComPortNumber = (ULONG)i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ComPortNumber == 0)
|
||||||
|
{
|
||||||
|
sprintf(buffer,
|
||||||
|
"\nKernel Debugger: No COM port found!\n\n");
|
||||||
|
HalDisplayString(buffer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PortInitialized = TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the port
|
||||||
|
*/
|
||||||
|
Status = CpInitialize(PortInformation,
|
||||||
|
(ComPortNumber == 0 ? PortInformation->Address
|
||||||
|
: UlongToPtr(BaseArray[ComPortNumber])),
|
||||||
|
(PortInformation->BaudRate == 0 ? DEFAULT_BAUD_RATE
|
||||||
|
: PortInformation->BaudRate));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
sprintf(buffer,
|
||||||
|
"\nKernel Debugger: Serial port not found!\n\n");
|
||||||
|
HalDisplayString(buffer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
/* Print message to blue screen */
|
||||||
|
sprintf(buffer,
|
||||||
|
"\nKernel Debugger: Serial port found: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
|
||||||
|
ComPortNumber,
|
||||||
|
PortInformation->Address,
|
||||||
|
PortInformation->BaudRate);
|
||||||
|
HalDisplayString(buffer);
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Set global info */
|
||||||
|
KdComPortInUse = DefaultPort.Address;
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
KdPortGetByteEx(
|
||||||
|
IN PCPPORT PortInformation,
|
||||||
|
OUT PUCHAR ByteReceived)
|
||||||
|
{
|
||||||
|
return (CpGetByte(PortInformation, ByteReceived, FALSE) == CP_GET_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
KdPortPutByteEx(
|
||||||
|
IN PCPPORT PortInformation,
|
||||||
|
IN UCHAR ByteToSend)
|
||||||
|
{
|
||||||
|
CpPutByte(PortInformation, ByteToSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
/* VARIABLES ***************************************************************/
|
/* VARIABLES ***************************************************************/
|
||||||
|
|
||||||
KD_PORT_INFORMATION PortInfo = {DEFAULT_DEBUG_PORT, DEFAULT_DEBUG_BAUD_RATE, 0};
|
ULONG PortNumber = DEFAULT_DEBUG_PORT;
|
||||||
|
CPPORT PortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0};
|
||||||
ULONG KdpPortIrq;
|
ULONG KdpPortIrq;
|
||||||
#ifdef AUTO_ENABLE_BOCHS
|
#ifdef AUTO_ENABLE_BOCHS
|
||||||
KDP_DEBUG_MODE KdpDebugMode = {{{.Bochs=TRUE}}};
|
KDP_DEBUG_MODE KdpDebugMode = {{{.Bochs=TRUE}}};
|
||||||
|
@ -68,7 +69,7 @@ KdpGetDebugMode(PCHAR Currentp2)
|
||||||
KdpDebugMode.Serial = TRUE;
|
KdpDebugMode.Serial = TRUE;
|
||||||
|
|
||||||
/* Set the port to use */
|
/* Set the port to use */
|
||||||
SerialPortInfo.ComPort = Value;
|
SerialPortNumber = Value;
|
||||||
KdpPort = Value;
|
KdpPort = Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,8 +79,8 @@ KdpGetDebugMode(PCHAR Currentp2)
|
||||||
if (Value)
|
if (Value)
|
||||||
{
|
{
|
||||||
KdpDebugMode.Serial = TRUE;
|
KdpDebugMode.Serial = TRUE;
|
||||||
SerialPortInfo.BaseAddress = Value;
|
SerialPortInfo.Address = UlongToPtr(Value);
|
||||||
SerialPortInfo.ComPort = 0;
|
SerialPortNumber = 0;
|
||||||
KdpPort = 0;
|
KdpPort = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ HANDLE KdpLogFileHandle;
|
||||||
ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log");
|
ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log");
|
||||||
|
|
||||||
KSPIN_LOCK KdpSerialSpinLock;
|
KSPIN_LOCK KdpSerialSpinLock;
|
||||||
KD_PORT_INFORMATION SerialPortInfo = { DEFAULT_DEBUG_PORT, DEFAULT_DEBUG_BAUD_RATE, 0 };
|
ULONG SerialPortNumber = DEFAULT_DEBUG_PORT;
|
||||||
|
CPPORT SerialPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0};
|
||||||
|
|
||||||
/* Current Port in use. FIXME: Do we support more then one? */
|
/* Current Port in use. FIXME: Do we support more then one? */
|
||||||
ULONG KdpPort;
|
ULONG KdpPort;
|
||||||
|
@ -358,12 +359,12 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
|
||||||
DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint;
|
DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint;
|
||||||
|
|
||||||
/* Initialize the Port */
|
/* Initialize the Port */
|
||||||
if (!KdPortInitializeEx(&SerialPortInfo, 0, 0))
|
if (!KdPortInitializeEx(&SerialPortInfo, SerialPortNumber))
|
||||||
{
|
{
|
||||||
KdpDebugMode.Serial = FALSE;
|
KdpDebugMode.Serial = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
KdComPortInUse = (PUCHAR)(ULONG_PTR)SerialPortInfo.BaseAddress;
|
KdComPortInUse = SerialPortInfo.Address;
|
||||||
|
|
||||||
/* Initialize spinlock */
|
/* Initialize spinlock */
|
||||||
KeInitializeSpinLock(&KdpSerialSpinLock);
|
KeInitializeSpinLock(&KdpSerialSpinLock);
|
||||||
|
|
|
@ -44,7 +44,8 @@ static FAST_MUTEX GspLock;
|
||||||
extern LIST_ENTRY PsActiveProcessHead;
|
extern LIST_ENTRY PsActiveProcessHead;
|
||||||
|
|
||||||
/* FIXME hardcoded for COM2, 115200 baud */
|
/* FIXME hardcoded for COM2, 115200 baud */
|
||||||
KD_PORT_INFORMATION GdbPortInfo = { 2, 115200, 0 };
|
ULONG GdbPortNumber = DEFAULT_DEBUG_PORT;
|
||||||
|
CPPORT GdbPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0};
|
||||||
|
|
||||||
static CHAR GspInBuffer[1000];
|
static CHAR GspInBuffer[1000];
|
||||||
static CHAR GspOutBuffer[1000];
|
static CHAR GspOutBuffer[1000];
|
||||||
|
@ -126,9 +127,7 @@ GdbGetChar(VOID)
|
||||||
{
|
{
|
||||||
UCHAR Value;
|
UCHAR Value;
|
||||||
|
|
||||||
while (!KdPortGetByteEx(&GdbPortInfo, &Value))
|
while (!KdPortGetByteEx(&GdbPortInfo, &Value)) ;
|
||||||
;
|
|
||||||
|
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,8 +144,7 @@ GspGetPacket()
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
/* wait around for the start character, ignore all other characters */
|
/* wait around for the start character, ignore all other characters */
|
||||||
while ((ch = GdbGetChar()) != '$')
|
while ((ch = GdbGetChar()) != '$') ;
|
||||||
;
|
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
Checksum = 0;
|
Checksum = 0;
|
||||||
|
@ -784,7 +782,6 @@ GspQuery(PCHAR Request)
|
||||||
}
|
}
|
||||||
else if (strncmp(Request, "Rcmd,", 5) == 0)
|
else if (strncmp(Request, "Rcmd,", 5) == 0)
|
||||||
{
|
{
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,12 +940,14 @@ GspFindSwBreakpoint(ULONG_PTR Address, PULONG PIndex)
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
|
|
||||||
for (Index = 0; Index < GspSwBreakpointCount; Index++)
|
for (Index = 0; Index < GspSwBreakpointCount; Index++)
|
||||||
|
{
|
||||||
if (GspSwBreakpoints[Index].Address == Address)
|
if (GspSwBreakpoints[Index].Address == Address)
|
||||||
{
|
{
|
||||||
if (PIndex)
|
if (PIndex)
|
||||||
*PIndex = Index;
|
*PIndex = Index;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1569,7 +1568,7 @@ KdpGdbStubInit(PKD_DISPATCH_TABLE WrapperTable, ULONG BootPhase)
|
||||||
WrapperTable->KdpExceptionRoutine = KdpGdbEnterDebuggerException;
|
WrapperTable->KdpExceptionRoutine = KdpGdbEnterDebuggerException;
|
||||||
|
|
||||||
/* Initialize the Port */
|
/* Initialize the Port */
|
||||||
KdPortInitializeEx(&GdbPortInfo, 0, 0);
|
KdPortInitializeEx(&GdbPortInfo, GdbPortNumber);
|
||||||
}
|
}
|
||||||
else if (BootPhase == 1)
|
else if (BootPhase == 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,12 +88,8 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
|
|
||||||
/* at least NUMREGBYTES*2 are needed for register packets */
|
|
||||||
#define BUFMAX 1000
|
|
||||||
|
|
||||||
static BOOLEAN GspInitialized;
|
static BOOLEAN GspInitialized;
|
||||||
|
|
||||||
static BOOLEAN GspRemoteDebug;
|
static BOOLEAN GspRemoteDebug;
|
||||||
|
|
||||||
static CONST CHAR HexChars[]="0123456789abcdef";
|
static CONST CHAR HexChars[]="0123456789abcdef";
|
||||||
|
@ -107,7 +103,14 @@ static FAST_MUTEX GspLock;
|
||||||
extern LIST_ENTRY PsActiveProcessHead;
|
extern LIST_ENTRY PsActiveProcessHead;
|
||||||
|
|
||||||
/* FIXME hardcoded for COM2, 115200 baud */
|
/* FIXME hardcoded for COM2, 115200 baud */
|
||||||
KD_PORT_INFORMATION GdbPortInfo = { 2, 115200, 0 };
|
ULONG GdbPortNumber = DEFAULT_DEBUG_PORT;
|
||||||
|
CPPORT GdbPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0};
|
||||||
|
|
||||||
|
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
|
||||||
|
/* at least NUMREGBYTES*2 are needed for register packets */
|
||||||
|
#define BUFMAX 1000
|
||||||
|
static CHAR GspInBuffer[BUFMAX];
|
||||||
|
static CHAR GspOutBuffer[BUFMAX];
|
||||||
|
|
||||||
/* Number of Registers. */
|
/* Number of Registers. */
|
||||||
#define NUMREGS 16
|
#define NUMREGS 16
|
||||||
|
@ -149,24 +152,17 @@ LONG
|
||||||
HexValue(CHAR ch)
|
HexValue(CHAR ch)
|
||||||
{
|
{
|
||||||
if ((ch >= '0') && (ch <= '9'))
|
if ((ch >= '0') && (ch <= '9'))
|
||||||
{
|
|
||||||
return (ch - '0');
|
return (ch - '0');
|
||||||
}
|
|
||||||
if ((ch >= 'a') && (ch <= 'f'))
|
if ((ch >= 'a') && (ch <= 'f'))
|
||||||
{
|
|
||||||
return (ch - 'a' + 10);
|
return (ch - 'a' + 10);
|
||||||
}
|
|
||||||
if ((ch >= 'A') && (ch <= 'F'))
|
if ((ch >= 'A') && (ch <= 'F'))
|
||||||
{
|
|
||||||
return (ch - 'A' + 10);
|
return (ch - 'A' + 10);
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CHAR GspInBuffer[BUFMAX];
|
|
||||||
static CHAR GspOutBuffer[BUFMAX];
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
GdbPutChar(UCHAR Value)
|
GdbPutChar(UCHAR Value)
|
||||||
{
|
{
|
||||||
|
@ -178,9 +174,7 @@ GdbGetChar(VOID)
|
||||||
{
|
{
|
||||||
UCHAR Value;
|
UCHAR Value;
|
||||||
|
|
||||||
while (!KdPortGetByteEx(&GdbPortInfo, &Value))
|
while (!KdPortGetByteEx(&GdbPortInfo, &Value)) ;
|
||||||
;
|
|
||||||
|
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +192,7 @@ GspGetPacket()
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
/* wait around for the start character, ignore all other characters */
|
/* wait around for the start character, ignore all other characters */
|
||||||
while ((ch = GdbGetChar ()) != '$')
|
while ((ch = GdbGetChar ()) != '$') ;
|
||||||
;
|
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
Checksum = 0;
|
Checksum = 0;
|
||||||
|
@ -211,13 +204,11 @@ GspGetPacket()
|
||||||
{
|
{
|
||||||
ch = GdbGetChar();
|
ch = GdbGetChar();
|
||||||
if (ch == '$')
|
if (ch == '$')
|
||||||
{
|
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
|
||||||
if (ch == '#')
|
if (ch == '#')
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
Checksum = Checksum + ch;
|
Checksum = Checksum + ch;
|
||||||
Buffer[Count] = ch;
|
Buffer[Count] = ch;
|
||||||
Count = Count + 1;
|
Count = Count + 1;
|
||||||
|
@ -238,7 +229,6 @@ GspGetPacket()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GdbPutChar('+'); /* successful transfer */
|
GdbPutChar('+'); /* successful transfer */
|
||||||
|
|
||||||
return &Buffer[0];
|
return &Buffer[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,6 +313,20 @@ GspReadMemSafe(PCHAR Address)
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CHAR
|
||||||
|
GspWriteMemSafeGetContent(PVOID Context, ULONG Offset)
|
||||||
|
{
|
||||||
|
ASSERT(0 == Offset);
|
||||||
|
return *((PCHAR) Context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
GspWriteMemSafe(PCHAR Address,
|
||||||
|
CHAR Ch)
|
||||||
|
{
|
||||||
|
GspWriteMem(Address, 1, TRUE, GspWriteMemSafeGetContent, &Ch);
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert the memory pointed to by Address into hex, placing result in Buffer */
|
/* Convert the memory pointed to by Address into hex, placing result in Buffer */
|
||||||
/* Return a pointer to the last char put in Buffer (null) */
|
/* Return a pointer to the last char put in Buffer (null) */
|
||||||
/* If MayFault is TRUE, then we should set GspMemoryError in response to
|
/* If MayFault is TRUE, then we should set GspMemoryError in response to
|
||||||
|
@ -342,10 +346,8 @@ GspMem2Hex(PCHAR Address,
|
||||||
{
|
{
|
||||||
ch = GspReadMemSafe(Address);
|
ch = GspReadMemSafe(Address);
|
||||||
if (GspMemoryError)
|
if (GspMemoryError)
|
||||||
{
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch = *Address;
|
ch = *Address;
|
||||||
|
@ -398,25 +400,22 @@ GspWriteMem(PCHAR Address,
|
||||||
ch = (*GetContent)(Context, Current - Address);
|
ch = (*GetContent)(Context, Current - Address);
|
||||||
|
|
||||||
if (MayFault)
|
if (MayFault)
|
||||||
{
|
|
||||||
GspAccessLocation = Current;
|
GspAccessLocation = Current;
|
||||||
}
|
|
||||||
*Current = ch;
|
*Current = ch;
|
||||||
|
|
||||||
if (MayFault)
|
if (MayFault)
|
||||||
{
|
|
||||||
GspAccessLocation = NULL;
|
GspAccessLocation = NULL;
|
||||||
}
|
|
||||||
Current++;
|
Current++;
|
||||||
}
|
}
|
||||||
if (MayFault)
|
if (MayFault)
|
||||||
{
|
{
|
||||||
MmSetPageProtect(NULL, Page, OldProt);
|
MmSetPageProtect(NULL, Page, OldProt);
|
||||||
if (GspMemoryError)
|
if (GspMemoryError)
|
||||||
{
|
|
||||||
return Current - Address;
|
return Current - Address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return Current - Address;
|
return Current - Address;
|
||||||
}
|
}
|
||||||
|
@ -437,25 +436,9 @@ GspHex2Mem(PCHAR Buffer,
|
||||||
BOOLEAN MayFault)
|
BOOLEAN MayFault)
|
||||||
{
|
{
|
||||||
Count = GspWriteMem(Address, Count, MayFault, GspHex2MemGetContent, Buffer);
|
Count = GspWriteMem(Address, Count, MayFault, GspHex2MemGetContent, Buffer);
|
||||||
|
|
||||||
return Buffer + 2 * Count;
|
return Buffer + 2 * Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CHAR
|
|
||||||
GspWriteMemSafeGetContent(PVOID Context, ULONG Offset)
|
|
||||||
{
|
|
||||||
ASSERT(0 == Offset);
|
|
||||||
|
|
||||||
return *((PCHAR) Context);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
GspWriteMemSafe(PCHAR Address,
|
|
||||||
CHAR Ch)
|
|
||||||
{
|
|
||||||
GspWriteMem(Address, 1, TRUE, GspWriteMemSafeGetContent, &Ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* This function takes the 386 exception vector and attempts to
|
/* This function takes the 386 exception vector and attempts to
|
||||||
translate this number into a unix compatible signal value */
|
translate this number into a unix compatible signal value */
|
||||||
|
@ -469,22 +452,27 @@ GspComputeSignal(NTSTATUS ExceptionCode)
|
||||||
case STATUS_INTEGER_DIVIDE_BY_ZERO:
|
case STATUS_INTEGER_DIVIDE_BY_ZERO:
|
||||||
SigVal = 8; /* divide by zero */
|
SigVal = 8; /* divide by zero */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATUS_SINGLE_STEP:
|
case STATUS_SINGLE_STEP:
|
||||||
case STATUS_BREAKPOINT:
|
case STATUS_BREAKPOINT:
|
||||||
SigVal = 5; /* breakpoint */
|
SigVal = 5; /* breakpoint */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATUS_INTEGER_OVERFLOW:
|
case STATUS_INTEGER_OVERFLOW:
|
||||||
case STATUS_ARRAY_BOUNDS_EXCEEDED:
|
case STATUS_ARRAY_BOUNDS_EXCEEDED:
|
||||||
SigVal = 16; /* bound instruction */
|
SigVal = 16; /* bound instruction */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATUS_ILLEGAL_INSTRUCTION:
|
case STATUS_ILLEGAL_INSTRUCTION:
|
||||||
SigVal = 4; /* Invalid opcode */
|
SigVal = 4; /* Invalid opcode */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATUS_STACK_OVERFLOW:
|
case STATUS_STACK_OVERFLOW:
|
||||||
case STATUS_DATATYPE_MISALIGNMENT:
|
case STATUS_DATATYPE_MISALIGNMENT:
|
||||||
case STATUS_ACCESS_VIOLATION:
|
case STATUS_ACCESS_VIOLATION:
|
||||||
SigVal = 11; /* access violation */
|
SigVal = 11; /* access violation */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SigVal = 7; /* "software generated" */
|
SigVal = 7; /* "software generated" */
|
||||||
}
|
}
|
||||||
|
@ -1640,15 +1628,11 @@ GspBreakIn(PKINTERRUPT Interrupt,
|
||||||
while (KdPortGetByteEx(&GdbPortInfo, &Value))
|
while (KdPortGetByteEx(&GdbPortInfo, &Value))
|
||||||
{
|
{
|
||||||
if (Value == 0x03)
|
if (Value == 0x03)
|
||||||
{
|
|
||||||
DoBreakIn = TRUE;
|
DoBreakIn = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!DoBreakIn)
|
if (!DoBreakIn)
|
||||||
{
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
||||||
|
|
||||||
|
@ -1678,9 +1662,7 @@ KdpGdbStubInit(PKD_DISPATCH_TABLE WrapperTable,
|
||||||
ULONG BootPhase)
|
ULONG BootPhase)
|
||||||
{
|
{
|
||||||
if (!KdDebuggerEnabled || !KdpDebugMode.Gdb)
|
if (!KdDebuggerEnabled || !KdpDebugMode.Gdb)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (BootPhase == 0)
|
if (BootPhase == 0)
|
||||||
{
|
{
|
||||||
|
@ -1692,9 +1674,8 @@ KdpGdbStubInit(PKD_DISPATCH_TABLE WrapperTable,
|
||||||
WrapperTable->KdpExceptionRoutine = KdpGdbEnterDebuggerException;
|
WrapperTable->KdpExceptionRoutine = KdpGdbEnterDebuggerException;
|
||||||
|
|
||||||
/* Initialize the Port */
|
/* Initialize the Port */
|
||||||
KdPortInitializeEx(&GdbPortInfo, 0, 0);
|
KdPortInitializeEx(&GdbPortInfo, GdbPortNumber);
|
||||||
|
// KdpPort = GdbPortInfo.ComPort;
|
||||||
KdpPort = GdbPortInfo.ComPort;
|
|
||||||
}
|
}
|
||||||
else if (BootPhase == 1)
|
else if (BootPhase == 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
# define RTL_NUMBER_OF(x) (sizeof(x) / sizeof((x)[0]))
|
# define RTL_NUMBER_OF(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* formerly located in kdbg/kdb_symbols.c */
|
||||||
|
#define TAG_KDBS 'SBDK'
|
||||||
|
#define TAG_KDBG 'GBDK'
|
||||||
|
|
||||||
/* TYPES *********************************************************************/
|
/* TYPES *********************************************************************/
|
||||||
|
|
||||||
/* from kdb.c */
|
/* from kdb.c */
|
||||||
|
|
Loading…
Reference in a new issue