ReactOS  0.4.14-dev-838-g99f979d
privateice.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1998-2001 Klaus P. Gerlicher
4 
5 Module Name:
6 
7  privateice.c
8 
9 Abstract:
10 
11 Environment:
12 
13 Author:
14 
15  Klaus P. Gerlicher
16 
17  reactos port by:
18  Eugene Ingerman
19 
20 Revision History:
21 
22  16-Jul-1998: created
23  15-Nov-2000: general cleanup of source files
24  19-Jan-2001: renamed to privateice.c
25 
26  10/20/2001: porting to reactos begins
27 
28 Copyright notice:
29 
30  This file may be distributed under the terms of the GNU Public License.
31 
32 --*/
33 
35 // INCLUDES
37 /*
38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <asm/uaccess.h>
41 #include <linux/fs.h>
42 #include <linux/config.h>
43 #include <linux/sched.h>
44 #include <asm/unistd.h>
45 #include <linux/string.h>
46 */
47 
48 #include <ntddk.h>
49 #include <debug.h>
50 #include <rosrtl/string.h>
51 
52 #include "precomp.h"
53 #include "serial.h"
54 
56 // GLOBALS
58 
60 
61 char tempPICE[1024];
62 
64 // FUNCTIONS
66 
67 //*************************************************************************
68 // pice_open()
69 //
70 //*************************************************************************
71 
73 {
74  DPRINT((0,"pice_open\n"));
75 
76  /* We don't want to talk to two processes at the
77  * same time */
78  if (bDeviceAlreadyOpen){
80  return STATUS_UNSUCCESSFUL; /* is there a more descriptive status code for this case? */
81  }
82 
85  return STATUS_SUCCESS;
86 }
87 
88 //*************************************************************************
89 // pice_close()
90 //
91 //*************************************************************************
93 {
94  DPRINT((0,"pice_close\n"));
95 
96  CleanUpPICE(); // used to be in cleanup_module
97 
98  /* We're now ready for our next caller */
101 
102  return STATUS_SUCCESS;
103 }
104 
105 
106 //*************************************************************************
107 // pice_ioctl()
108 //
109 //*************************************************************************
110 
112 {
113 // char* pFilename = (char*) ioctl_param;
114 
116 
117  ULONG Code = IoStack->Parameters.DeviceIoControl.IoControlCode;
118 
119  switch(Code)
120  {
121  case PICE_IOCTL_LOAD:
122  break;
123  case PICE_IOCTL_RELOAD:
124  if(!ReloadSymbols())
125  {
126  PICE_sprintf(tempPICE,"pICE: not able to reload symbols\n");
128  }
129  break;
130  case PICE_IOCTL_UNLOAD:
131  UnloadSymbols();
132  break;
133  case PICE_IOCTL_BREAK:
134  PICE_sprintf(tempPICE,"pICE: forcible break\n");
136  __asm__ __volatile("int $3");
137  break;
138  case PICE_IOCTL_STATUS:
139  {
140  PDEBUGGER_STATUS_BLOCK ustatus_block_p;
141  DEBUGGER_STATUS_BLOCK kstatus_block;
142 
143  ULONG OutLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
144  if( OutLength < sizeof( DEBUGGER_STATUS_BLOCK ) ){
146  }
147 
148  ustatus_block_p = (PDEBUGGER_STATUS_BLOCK)Irp->AssociatedIrp.SystemBuffer;
149 
150  //kstatus_block.Test = 0x12345678;
151  RtlCopyMemory(ustatus_block_p, &kstatus_block, sizeof(DEBUGGER_STATUS_BLOCK) );
152  }
153  break;
154  default:
157  }
159  return STATUS_SUCCESS;
160 }
161 
162 
165 /*
166  * FUNCTION: Module entry point
167  */
168 {
171  UNICODE_STRING SymlinkName;
172 
173  DPRINT((0,"PICE Debugger\n"));
174 
175 #if 0 // don't enable before completely ported
176 #ifdef DEBUG
177  // first we enable output of debug strings to COM port
178  DebugSetupSerial(1,115200);
179 #endif // DEBUG
180 #endif
181 
182  if(InitPICE()){
184  //ei unimplemented DriverObject->MajorFunction[IRP_MJ_CLOSE] = pice_close;
186 
189  0,
190  &DeviceName,
192  0,
193  TRUE,
194  &DeviceObject);
196 
197  RtlRosInitUnicodeStringFromLiteral(&SymlinkName, L"\\??\\Pice");
198  IoCreateSymbolicLink(&SymlinkName, &DeviceName);
199 
200  return(STATUS_SUCCESS);
201  }
202 }
203 
#define PICE_IOCTL_UNLOAD
Definition: shared.h:60
NTSTATUS NTAPI pice_open(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: privateice.c:72
#define PICE_IOCTL_RELOAD
Definition: shared.h:61
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
NTSTATUS NTAPI pice_ioctl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: privateice.c:111
void CleanUpPICE(void)
Definition: init.c:346
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char tempPICE[1024]
Definition: privateice.c:61
LONG NTSTATUS
Definition: precomp.h:26
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
WCHAR DeviceName[]
Definition: adapter.cpp:21
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define PICE_IOCTL_BREAK
Definition: shared.h:62
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
unsigned char BOOLEAN
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define Code
Definition: deflate.h:80
struct _DEBUGGER_STATUS_BLOCK * PDEBUGGER_STATUS_BLOCK
BOOLEAN InitPICE(void)
Definition: init.c:57
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define PICE_DEVICE_DEBUGGER
Definition: shared.h:57
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Definition: privateice.c:163
BOOLEAN bDeviceAlreadyOpen
Definition: privateice.c:59
NTSTATUS NTAPI pice_close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: privateice.c:92
#define PICE_IOCTL_STATUS
Definition: shared.h:63
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
BOOLEAN ReloadSymbols(void)
Definition: symbols.c:2074
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlRosInitUnicodeStringFromLiteral(__Name__, __Value__)
Definition: hivetest.c:10
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
void UnloadSymbols()
Definition: symbols.c:2093
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define PICE_IOCTL_LOAD
Definition: shared.h:59
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52