From fe8db53413623035d550de452082a25059c4bf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Thu, 22 May 2003 15:11:29 +0000 Subject: [PATCH] Add DebugOut device driver svn path=/trunk/; revision=4741 --- reactos/Makefile | 2 +- reactos/bootcd.bat | 1 + reactos/bootdata/hivesys.inf | 7 ++ reactos/bootdata/txtsetup.sif | 1 + reactos/drivers/dd/debugout/.cvsignore | 7 ++ reactos/drivers/dd/debugout/debugout.c | 130 ++++++++++++++++++++++++ reactos/drivers/dd/debugout/debugout.rc | 39 +++++++ reactos/drivers/dd/debugout/makefile | 13 +++ reactos/install.bat | 1 + 9 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 reactos/drivers/dd/debugout/.cvsignore create mode 100644 reactos/drivers/dd/debugout/debugout.c create mode 100644 reactos/drivers/dd/debugout/debugout.rc create mode 100644 reactos/drivers/dd/debugout/makefile diff --git a/reactos/Makefile b/reactos/Makefile index e2a291a4e4e..0ce2e3fa0ff 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -56,7 +56,7 @@ DRIVERS_LIB = bzip2 # Kernel mode device drivers # Obsolete: ide # beep blue floppy null parallel ramdrv serenum serial vga videoprt -DEVICE_DRIVERS = beep blue floppy null serial vga videoprt +DEVICE_DRIVERS = beep blue debugout floppy null serial vga videoprt # Kernel mode input drivers # keyboard mouclass psaux sermouse diff --git a/reactos/bootcd.bat b/reactos/bootcd.bat index 3f083872772..b023d601bb2 100755 --- a/reactos/bootcd.bat +++ b/reactos/bootcd.bat @@ -45,6 +45,7 @@ copy /Y drivers\bus\isapnp\isapnp.sys %BOOTCD_DIR%\disk\reactos copy /Y drivers\dd\beep\beep.sys %BOOTCD_DIR%\disk\reactos copy /Y drivers\dd\blue\blue.sys %BOOTCD_DIR%\disk\reactos +copy /Y drivers\dd\debugout\debugout.sys %BOOTCD_DIR%\disk\reactos copy /Y drivers\dd\floppy\floppy.sys %BOOTCD_DIR%\disk\reactos copy /Y drivers\dd\null\null.sys %BOOTCD_DIR%\disk\reactos copy /Y drivers\dd\serial\serial.sys %BOOTCD_DIR%\disk\reactos diff --git a/reactos/bootdata/hivesys.inf b/reactos/bootdata/hivesys.inf index cee988e9256..2585dd3aa77 100644 --- a/reactos/bootdata/hivesys.inf +++ b/reactos/bootdata/hivesys.inf @@ -134,6 +134,13 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Class2","ImagePath",0x00020000,"system32 HKLM,"SYSTEM\CurrentControlSet\Services\Class2","Start",0x00010001,0x00000000 HKLM,"SYSTEM\CurrentControlSet\Services\Class2","Type",0x00010001,0x00000001 +; Debug output driver +HKLM,"SYSTEM\CurrentControlSet\Services\DebugOut","ErrorControl",0x00010001,0x00000000 +HKLM,"SYSTEM\CurrentControlSet\Services\DebugOut","Group",0x00000000,"Debug" +HKLM,"SYSTEM\CurrentControlSet\Services\DebugOut","ImagePath",0x00020000,"system32\drivers\debugout.sys" +HKLM,"SYSTEM\CurrentControlSet\Services\DebugOut","Start",0x00010001,0x00000001 +HKLM,"SYSTEM\CurrentControlSet\Services\DebugOut","Type",0x00010001,0x00000001 + ; Disk class driver HKLM,"SYSTEM\CurrentControlSet\Services\Disk","ErrorControl",0x00010001,0x00000000 HKLM,"SYSTEM\CurrentControlSet\Services\Disk","Group",0x00000000,"SCSI Class" diff --git a/reactos/bootdata/txtsetup.sif b/reactos/bootdata/txtsetup.sif index 60d57618c7e..610b82167a5 100644 --- a/reactos/bootdata/txtsetup.sif +++ b/reactos/bootdata/txtsetup.sif @@ -19,6 +19,7 @@ isapnp.sys = 3 beep.sys = 3 blue.sys = 3 +debugout.sys = 3 floppy.sys = 3 null.sys = 3 serial.sys = 3 diff --git a/reactos/drivers/dd/debugout/.cvsignore b/reactos/drivers/dd/debugout/.cvsignore new file mode 100644 index 00000000000..12e00b7fe27 --- /dev/null +++ b/reactos/drivers/dd/debugout/.cvsignore @@ -0,0 +1,7 @@ +base.tmp +junk.tmp +temp.exp +debugout.coff +*.sym +*.o +*.sys diff --git a/reactos/drivers/dd/debugout/debugout.c b/reactos/drivers/dd/debugout/debugout.c new file mode 100644 index 00000000000..313f9437981 --- /dev/null +++ b/reactos/drivers/dd/debugout/debugout.c @@ -0,0 +1,130 @@ +/* $Id: debugout.c,v 1.1 2003/05/22 15:11:29 gvg Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: drivers/dd/debugout.c + * PURPOSE: Debug output device driver + * PROGRAMMER: Ge van Geldorp (ge@gse.nl) + * UPDATE HISTORY: + * 2003/05/22: Created + * NOTES: + * In your usermode application, do something like this: + * + * DebugHandle = CreateFile("\\\\.\\DebugOut", + * GENERIC_WRITE, + * 0, + * NULL, + * OPEN_EXISTING, + * FILE_ATTRIBUTE_NORMAL, + * NULL); + * + * and write to your hearts content to DebugHandle. + */ + +/* INCLUDES */ +#include + +/* FUNCTIONS */ +NTSTATUS STDCALL_FUNC +DebugOutDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) +{ + PIO_STACK_LOCATION piosStack = IoGetCurrentIrpStackLocation(Irp); + NTSTATUS nErrCode; + char *Start; + char Buf[513]; + unsigned Remaining; + unsigned Length; + + nErrCode = STATUS_SUCCESS; + + switch(piosStack->MajorFunction) + { + /* opening and closing handles to the device */ + case IRP_MJ_CREATE: + case IRP_MJ_CLOSE: + break; + + /* write data */ + case IRP_MJ_WRITE: + Remaining = piosStack->Parameters.Write.Length; + Start = Irp->AssociatedIrp.SystemBuffer; + while (0 < Remaining) + { + Length = Remaining; + if (sizeof(Buf) - 1 < Length) + { + Length = sizeof(Buf) - 1; + } + RtlCopyMemory(Buf, Start, Length); + Buf[Length] = '\0'; + DbgPrint("%s", Buf); + Remaining -= Length; + Start += Length; + } + + Irp->IoStatus.Information = piosStack->Parameters.Write.Length; + break; + + /* read data */ + case IRP_MJ_READ: + Irp->IoStatus.Information = 0; + nErrCode = STATUS_END_OF_FILE; + break; + + /* unsupported operations */ + default: + nErrCode = STATUS_NOT_IMPLEMENTED; + } + + Irp->IoStatus.Status = nErrCode; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return nErrCode; +} + +NTSTATUS STDCALL +DebugOutUnload(PDRIVER_OBJECT DriverObject) +{ + return STATUS_SUCCESS; +} + +NTSTATUS STDCALL +DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) +{ + PDEVICE_OBJECT DebugOutDevice; + UNICODE_STRING DeviceName; + UNICODE_STRING DosName; + NTSTATUS Status; + + /* register driver routines */ + DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH) DebugOutDispatch; + DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH) DebugOutDispatch; + DriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH) DebugOutDispatch; + DriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH) DebugOutDispatch; + /* DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = (PDRIVER_DISPATCH) DebugOutDispatch; */ + DriverObject->DriverUnload = (PDRIVER_UNLOAD) DebugOutUnload; + + /* create device */ + RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\Device\\DebugOut"); + + Status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_NULL, + 0, FALSE, &DebugOutDevice); + if (! NT_SUCCESS(Status)) + { + return Status; + } + + RtlInitUnicodeStringFromLiteral(&DosName, L"\\DosDevices\\DebugOut"); + Status = IoCreateSymbolicLink(&DosName, &DeviceName); + if (! NT_SUCCESS(Status)) + { + IoDeleteDevice(DebugOutDevice); + return Status; + } + + DebugOutDevice->Flags |= DO_BUFFERED_IO; + + return Status; +} + +/* EOF */ diff --git a/reactos/drivers/dd/debugout/debugout.rc b/reactos/drivers/dd/debugout/debugout.rc new file mode 100644 index 00000000000..6b82ff5d1cb --- /dev/null +++ b/reactos/drivers/dd/debugout/debugout.rc @@ -0,0 +1,39 @@ + +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD + PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", RES_STR_COMPANY_NAME + VALUE "FileDescription", "Debug output Device Driver\0" + VALUE "FileVersion", "0.0.1\0" + VALUE "InternalName", "debug\0" + VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT + VALUE "OriginalFilename", "debugout.sys\0" + VALUE "ProductName", RES_STR_PRODUCT_NAME + VALUE "ProductVersion", RES_STR_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + diff --git a/reactos/drivers/dd/debugout/makefile b/reactos/drivers/dd/debugout/makefile new file mode 100644 index 00000000000..c76a8e0405b --- /dev/null +++ b/reactos/drivers/dd/debugout/makefile @@ -0,0 +1,13 @@ +# $Id: makefile,v 1.1 2003/05/22 15:11:29 gvg Exp $ + +PATH_TO_TOP = ../../.. + +TARGET_TYPE = driver + +TARGET_NAME = debugout + +TARGET_OBJECTS = debugout.o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk diff --git a/reactos/install.bat b/reactos/install.bat index 9e77d954d4c..a739ffc545d 100644 --- a/reactos/install.bat +++ b/reactos/install.bat @@ -44,6 +44,7 @@ copy drivers\input\mouclass\mouclass.sys %ROS_INSTALL%\system32\drivers copy drivers\input\psaux\psaux.sys %ROS_INSTALL%\system32\drivers copy drivers\dd\blue\blue.sys %ROS_INSTALL%\system32\drivers copy drivers\dd\beep\beep.sys %ROS_INSTALL%\system32\drivers +copy drivers\dd\debugout\debugout.sys %ROS_INSTALL%\system32\drivers copy drivers\dd\null\null.sys %ROS_INSTALL%\system32\drivers copy drivers\dd\serial\serial.sys %ROS_INSTALL%\system32\drivers copy drivers\dd\serenum\serenum.sys %ROS_INSTALL%\system32\drivers