3 Copyright (c) 1998-2001 Klaus P. Gerlicher
23 15-Nov-2000: general cleanup of source files
24 19-Jan-2001: renamed to privateice.c
26 10/20/2001: porting to reactos begins
30 This file may be distributed under the terms of the GNU Public License.
34 ////////////////////////////////////////////////////
38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <asm/uaccess.h>
42 #include <linux/config.h>
43 #include <linux/sched.h>
44 #include <asm/unistd.h>
45 #include <linux/string.h>
48 #include <ddk/ntddk.h>
54 ////////////////////////////////////////////////////
58 BOOLEAN bDeviceAlreadyOpen = FALSE;
62 ////////////////////////////////////////////////////
66 //*************************************************************************
69 //*************************************************************************
71 NTSTATUS STDCALL pice_open(PDEVICE_OBJECT DeviceObject, PIRP Irp)
73 DPRINT((0,"pice_open\n"));
75 /* We don't want to talk to two processes at the
77 if (bDeviceAlreadyOpen){
78 IoCompleteRequest (Irp, IO_NO_INCREMENT);
79 return STATUS_UNSUCCESSFUL; /* is there a more descriptive status code for this case? */
82 bDeviceAlreadyOpen = TRUE;
83 IoCompleteRequest (Irp, IO_NO_INCREMENT);
84 return STATUS_SUCCESS;
87 //*************************************************************************
90 //*************************************************************************
91 NTSTATUS STDCALL pice_close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
93 DPRINT((0,"pice_close\n"));
95 CleanUpPICE(); // used to be in cleanup_module
97 /* We're now ready for our next caller */
98 bDeviceAlreadyOpen = FALSE;
99 IoCompleteRequest (Irp, IO_NO_INCREMENT);
101 return STATUS_SUCCESS;
105 //*************************************************************************
108 //*************************************************************************
110 NTSTATUS STDCALL pice_ioctl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
112 // char* pFilename = (char*) ioctl_param;
114 PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation( Irp );
116 ULONG Code = IoStack->Parameters.DeviceIoControl.IoControlCode;
120 case PICE_IOCTL_LOAD:
122 case PICE_IOCTL_RELOAD:
125 PICE_sprintf(tempPICE,"pICE: not able to reload symbols\n");
126 Print(OUTPUT_WINDOW,tempPICE);
129 case PICE_IOCTL_UNLOAD:
132 case PICE_IOCTL_BREAK:
133 PICE_sprintf(tempPICE,"pICE: forcible break\n");
134 Print(OUTPUT_WINDOW,tempPICE);
135 __asm__ __volatile("int $3");
137 case PICE_IOCTL_STATUS:
139 PDEBUGGER_STATUS_BLOCK ustatus_block_p;
140 DEBUGGER_STATUS_BLOCK kstatus_block;
142 ULONG OutLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
143 if( OutLength < sizeof( DEBUGGER_STATUS_BLOCK ) ){
144 return STATUS_INVALID_PARAMETER;
147 ustatus_block_p = (PDEBUGGER_STATUS_BLOCK)Irp->AssociatedIrp.SystemBuffer;
149 //kstatus_block.Test = 0x12345678;
150 RtlCopyMemory(ustatus_block_p, &kstatus_block, sizeof(DEBUGGER_STATUS_BLOCK) );
154 IoCompleteRequest (Irp, IO_NO_INCREMENT);
155 return STATUS_INVALID_PARAMETER;
157 IoCompleteRequest (Irp, IO_NO_INCREMENT);
158 return STATUS_SUCCESS;
162 NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject,
163 PUNICODE_STRING RegistryPath)
165 * FUNCTION: Module entry point
168 PDEVICE_OBJECT DeviceObject;
169 UNICODE_STRING DeviceName;
170 UNICODE_STRING SymlinkName;
172 DPRINT((0,"PICE Debugger\n"));
174 #if 0 // don't enable before completely ported
176 // first we enable output of debug strings to COM port
177 DebugSetupSerial(1,115200);
182 DriverObject->MajorFunction[IRP_MJ_CREATE] = pice_open;
183 //ei unimplemented DriverObject->MajorFunction[IRP_MJ_CLOSE] = pice_close;
184 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = pice_ioctl;
186 RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\Device\\Pice");
187 IoCreateDevice(DriverObject,
190 PICE_DEVICE_DEBUGGER,
194 DeviceObject->Flags = DeviceObject->Flags | DO_BUFFERED_IO;
196 RtlInitUnicodeStringFromLiteral(&SymlinkName, L"\\??\\Pice");
197 IoCreateSymbolicLink(&SymlinkName, &DeviceName);
199 return(STATUS_SUCCESS);