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>
50 #include <rosrtl/string.h>
55 ////////////////////////////////////////////////////
59 BOOLEAN bDeviceAlreadyOpen
= FALSE
;
63 ////////////////////////////////////////////////////
67 //*************************************************************************
70 //*************************************************************************
72 NTSTATUS NTAPI
pice_open(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
74 DPRINT((0,"pice_open\n"));
76 /* We don't want to talk to two processes at the
78 if (bDeviceAlreadyOpen
){
79 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
80 return STATUS_UNSUCCESSFUL
; /* is there a more descriptive status code for this case? */
83 bDeviceAlreadyOpen
= TRUE
;
84 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
85 return STATUS_SUCCESS
;
88 //*************************************************************************
91 //*************************************************************************
92 NTSTATUS NTAPI
pice_close(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
94 DPRINT((0,"pice_close\n"));
96 CleanUpPICE(); // used to be in cleanup_module
98 /* We're now ready for our next caller */
99 bDeviceAlreadyOpen
= FALSE
;
100 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
102 return STATUS_SUCCESS
;
106 //*************************************************************************
109 //*************************************************************************
111 NTSTATUS NTAPI
pice_ioctl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
113 // char* pFilename = (char*) ioctl_param;
115 PIO_STACK_LOCATION IoStack
= IoGetCurrentIrpStackLocation( Irp
);
117 ULONG Code
= IoStack
->Parameters
.DeviceIoControl
.IoControlCode
;
121 case PICE_IOCTL_LOAD
:
123 case PICE_IOCTL_RELOAD
:
126 PICE_sprintf(tempPICE
,"pICE: not able to reload symbols\n");
127 Print(OUTPUT_WINDOW
,tempPICE
);
130 case PICE_IOCTL_UNLOAD
:
133 case PICE_IOCTL_BREAK
:
134 PICE_sprintf(tempPICE
,"pICE: forcible break\n");
135 Print(OUTPUT_WINDOW
,tempPICE
);
136 __asm__
__volatile("int $3");
138 case PICE_IOCTL_STATUS
:
140 PDEBUGGER_STATUS_BLOCK ustatus_block_p
;
141 DEBUGGER_STATUS_BLOCK kstatus_block
;
143 ULONG OutLength
= IoStack
->Parameters
.DeviceIoControl
.OutputBufferLength
;
144 if( OutLength
< sizeof( DEBUGGER_STATUS_BLOCK
) ){
145 return STATUS_INVALID_PARAMETER
;
148 ustatus_block_p
= (PDEBUGGER_STATUS_BLOCK
)Irp
->AssociatedIrp
.SystemBuffer
;
150 //kstatus_block.Test = 0x12345678;
151 RtlCopyMemory(ustatus_block_p
, &kstatus_block
, sizeof(DEBUGGER_STATUS_BLOCK
) );
155 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
156 return STATUS_INVALID_PARAMETER
;
158 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
159 return STATUS_SUCCESS
;
163 NTSTATUS NTAPI
DriverEntry(PDRIVER_OBJECT DriverObject
,
164 PUNICODE_STRING RegistryPath
)
166 * FUNCTION: Module entry point
169 PDEVICE_OBJECT DeviceObject
;
170 UNICODE_STRING DeviceName
;
171 UNICODE_STRING SymlinkName
;
173 DPRINT((0,"PICE Debugger\n"));
175 #if 0 // don't enable before completely ported
177 // first we enable output of debug strings to COM port
178 DebugSetupSerial(1,115200);
183 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = pice_open
;
184 //ei unimplemented DriverObject->MajorFunction[IRP_MJ_CLOSE] = pice_close;
185 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = pice_ioctl
;
187 RtlRosInitUnicodeStringFromLiteral(&DeviceName
, L
"\\Device\\Pice");
188 IoCreateDevice(DriverObject
,
191 PICE_DEVICE_DEBUGGER
,
195 DeviceObject
->Flags
= DeviceObject
->Flags
| DO_BUFFERED_IO
;
197 RtlRosInitUnicodeStringFromLiteral(&SymlinkName
, L
"\\??\\Pice");
198 IoCreateSymbolicLink(&SymlinkName
, &DeviceName
);
200 return(STATUS_SUCCESS
);