3 Copyright (c) 1998-2001 Klaus P. Gerlicher
24 15-Nov-2000: general cleanup of source files
28 This file may be distributed under the terms of the GNU Public License.
32 #include "../../../../ntoskrnl/include/internal/ps.h"
34 #define STR(x) __STR(x)
43 // scancode to ASCII conversion
44 typedef struct tagSCANTOASCII
46 UCHAR s; // 0 terminates the table
48 }SCANTOASCII, *PSCANTOASCII;
50 typedef struct tagKEYBOARD_LAYOUT
56 } KEYBOARD_LAYOUT, *PKEYBOARD_LAYOUT;
58 extern PKEYBOARD_LAYOUT CurrentKeyboard;
68 #define SHOW_FIELD_BYTE(ptr,field,wait)\
70 if(wait && WaitForKey()==FALSE)\
72 PICE_sprintf(tempCmd,#field" = %.2x\n",ptr->##field);\
73 Print(OUTPUT_WINDOW,tempCmd);\
76 #define SHOW_FIELD_WORD(ptr,field,wait)\
78 if(wait && WaitForKey()==FALSE)\
80 PICE_sprintf(tempCmd,#field" = %.4x\n",ptr->##field);\
81 Print(OUTPUT_WINDOW,tempCmd);\
84 #define SHOW_FIELD_DWORD(ptr,field,wait)\
86 if(wait && WaitForKey()==FALSE)\
88 PICE_sprintf(tempCmd,#field" = %.8x\n",ptr->##field);\
89 Print(OUTPUT_WINDOW,tempCmd);\
92 #define SHOW_FIELD_SEG_OFS(ptr,field1,field2,wait)\
94 if(wait && WaitForKey()==FALSE)\
96 PICE_sprintf(tempCmd,#field1":"#field2" = %.4x:%.8x\n",ptr->##field1,ptr->##field2);\
97 Print(OUTPUT_WINDOW,tempCmd);\
100 typedef struct _PCI_NUMBER
106 ULONG reg : 6; // 64 regs per function
107 ULONG func : 3; // 8 functions per device
108 ULONG dev : 5; // 32 device per bus
109 ULONG bus : 8; // 256 buses
111 ULONG ce : 1; // 1 to enable
117 typedef struct _PCI_COMMON_CONFIG {
118 USHORT VendorID; // (ro)
119 USHORT DeviceID; // (ro)
120 USHORT Command; // Device control
122 UCHAR RevisionID; // (ro)
123 UCHAR ProgIf; // (ro)
124 UCHAR SubClass; // (ro)
125 UCHAR BaseClass; // (ro)
126 UCHAR CacheLineSize; // (ro+)
127 UCHAR LatencyTimer; // (ro+)
128 UCHAR HeaderType; // (ro)
129 UCHAR BIST; // Built in self test
130 ULONG BaseAddresses[6];
134 ULONG ROMBaseAddress;
135 UCHAR CapabilitiesPtr;
138 UCHAR InterruptLine; //
139 UCHAR InterruptPin; // (ro)
140 UCHAR MinimumGrant; // (ro)
141 UCHAR MaximumLatency; // (ro)
145 typedef struct tagPageDir
160 typedef struct tagGdt
162 ULONG Limit_15_0 :16;
169 ULONG Limit_19_16 :4;
177 typedef struct tagIdt
179 ULONG Offset_15_0 :16;
185 ULONG Offset_31_16 :16;
188 typedef struct tagDESCRIPTOR
190 USHORT Cpl :2; // current privilege level
191 USHORT Ti :1; // table index (GDT=0 LDT=1)
192 USHORT Val :13; // index into table
193 }DESCRIPTOR,*PDESCRIPTOR;
195 PKEYBOARD_LAYOUT GetKeyboardLayout();
196 PKEYBOARD_LAYOUT SetKeyboardLayoutByName(LPSTR Name);
197 void PICE_memset(void* p,unsigned char c,int sz);
198 void PICE_memcpy(void* t,void* s,int sz);
199 char *PICE_strrev(char *);
200 ULONG PICE_strcmp(char* s1,char* s2);
201 ULONG PICE_strcmpi(char* s1,char* s2);
202 ULONG PICE_strncmpi(char* s1,char* s2,ULONG len);
203 USHORT PICE_strlen(const char* s);
204 char* PICE_strcat(char* s1,char* s2);
205 BOOLEAN PICE_isprint(char c);
206 char* PICE_strcpy(char* s1,char* s2);
207 char* PICE_strncpy(char* s1,char* s2,int len);
208 char* PICE_strchr(char* s,char c);
209 int PICE_isdigit( int c );
210 int PICE_isxdigit( int c );
211 int PICE_islower( int c );
212 int PICE_isalpha( int c );
214 int PICE_sprintf(char * buf, const char *fmt, ...);
215 int PICE_vsprintf(char *buf, const char *fmt, va_list args);
217 BOOLEAN IsAddressValid(ULONG Addr);
218 BOOLEAN IsAddressWriteable(ULONG Addr);
219 BOOLEAN SetAddressWriteable(ULONG address,BOOLEAN bSet);
220 BOOLEAN IsRangeValid(ULONG addr,ULONG Length);
221 void IntelStackWalk(ULONG pc,ULONG ebp,ULONG esp);
223 ULONG ReadPhysMem(ULONG Address,ULONG ulSize);
224 void WritePhysMem(ULONG Address,ULONG Datum,ULONG ulSize);
226 BOOLEAN IsRetAtEIP(void);
227 BOOLEAN IsCallInstrAtEIP(void);
229 ULONG GetLinearAddress(USHORT Segment,ULONG Offset);
231 #define OUTPUT_BUFFER_FULL 0x01
232 #define INPUT_BUFFER_FULL 0x02
233 #define MOUSE_OUTPUT_BUFFER_FULL 0x20
235 void ShowStoppedMsg(void);
236 void ShowRunningMsg(void);
238 void SetHardwareBreakPoints(void);
239 void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg);
241 // this should be in disasm.h but someone misused the header files
242 BOOLEAN Disasm(PULONG pOffset, PUCHAR pchDst);
243 //////////////////////////////////////////////////////////////////
245 //segments defined in \include\napi\i386\segment.h
246 #define GLOBAL_CODE_SEGMENT (KERNEL_CS)
247 #define GLOBAL_DATA_SEGMENT (KERNEL_DS)
249 //#define OVR_CS .byte 0x2e
250 //#define OVR_FS .byte 0x64
252 void DisplayRegs(void);
253 void SaveOldRegs(void);
255 BOOLEAN CheckLoadAbort(void);
257 UCHAR KeyboardGetKeyPolled(void);
258 void KeyboardFlushKeyboardQueue(void);
260 #define _PAGE_PRESENT 0x001
261 #define _PAGE_RW 0x002
262 #define _PAGE_USER 0x004
263 #define _PAGE_PWT 0x008
264 #define _PAGE_PCD 0x010
265 #define _PAGE_ACCESSED 0x020
266 #define _PAGE_DIRTY 0x040
267 #define _PAGE_PSE 0x080
268 #define _PAGE_4M _PAGE_PSE
269 #define _PAGE_SIZE 0x1000
272 UCHAR AsciiFromScan(UCHAR s);
273 UCHAR AsciiToScan(UCHAR s);
275 void outportb(PUCHAR port,UCHAR data);
276 UCHAR inportb(PUCHAR port);
278 void outb_p(UCHAR data, PUCHAR port);
279 UCHAR inb_p(PUCHAR port);
281 VOID outl(ULONG l, PULONG port);
282 ULONG inl(PULONG port);
285 #define save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
286 #define restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
287 #define cli() __asm__ __volatile__("cli": : :"memory")
288 #define sti() __asm__ __volatile__("sti": : :"memory")
293 #define ASSERT(x) if (!(x)) { DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__); KeBugCheck(0); }
296 //extern unsigned long sys_call_table[];
298 //struct mm_struct *GetInitMm(void);
300 PMADDRESS_SPACE my_init_mm;
301 LIST_ENTRY* pPsProcessListHead;
303 void EnablePassThrough(void);
305 #define PAGEDPOOL (1)
306 #define NONPAGEDPOOL (0)
308 void * PICE_malloc( size_t numBytes, BOOLEAN fromPaged );
309 void PICE_free( void* p );
311 HANDLE PICE_open (LPCWSTR lpPathName, int iReadWrite);
312 long PICE_read(HANDLE hFile, LPVOID lpBuffer, long lBytes);
313 int PICE_close (HANDLE hFile);
314 size_t PICE_len( HANDLE hFile );
315 WCHAR * PICE_wcscpy(WCHAR * str1,const WCHAR * str2);
318 PICE_MultiByteToWideChar (
321 LPCSTR lpMultiByteStr,
323 LPWSTR lpWideCharStr,