Porting pice.
authorEugene Ingerman <geneing@myrealbox.com>
Mon, 22 Oct 2001 05:02:47 +0000 (05:02 +0000)
committerEugene Ingerman <geneing@myrealbox.com>
Mon, 22 Oct 2001 05:02:47 +0000 (05:02 +0000)
svn path=/trunk/; revision=2313

reactos/apps/utils/pice/loader/main.c
reactos/apps/utils/pice/module/hardware.c
reactos/apps/utils/pice/module/output.c
reactos/apps/utils/pice/module/patch.c
reactos/apps/utils/pice/module/privateice.c
reactos/apps/utils/pice/module/remods.h
reactos/apps/utils/pice/module/symbols.c
reactos/apps/utils/pice/module/utils.c
reactos/apps/utils/pice/module/utils.h
reactos/apps/utils/pice/module/vga.c

index 5ed3392..7d3e244 100644 (file)
@@ -82,7 +82,7 @@ void process_stabs(
 
     //printf("LOADER: enter process_stabs()\n");
 
-    memset((void*)&SymbolFileHeader,0,sizeof(SymbolFileHeader));
+    PICE_memset((void*)&SymbolFileHeader,0,sizeof(SymbolFileHeader));
        SymbolFileHeader.magic = PICE_MAGIC;
        strcpy(temp,pExeName);
        pSlash = strrchr(temp,'/');
@@ -502,7 +502,7 @@ int process_file(char* filename)
         if(p)
         {
             //printf("LOADER: malloc'd @ %x\n",p);
-            memset(p,0,len+16);
+            PICE_memset(p,0,len+16);
 
             if(len == read(file,p,len))
             {
index 1db5e1d..d0fea1f 100644 (file)
@@ -952,8 +952,8 @@ BOOLEAN ConsoleInit(void)
     ENTER_FUNC();
 
     // preset ohandlers and ihandler to NULL
-    memset((void*)&ohandlers,0,sizeof(ohandlers));
-    memset((void*)&ihandlers,0,sizeof(ihandlers));
+    PICE_memset((void*)&ohandlers,0,sizeof(ohandlers));
+    PICE_memset((void*)&ihandlers,0,sizeof(ihandlers));
 
     switch(eTerminalMode)
     {
index 5369b09..d55c892 100644 (file)
@@ -34,7 +34,7 @@ Copyright notice:
 ////
 #include "remods.h"
 #include "precomp.h"
-
+/*
 #include <linux/sched.h>
 #include <asm/io.h>
 #include <asm/page.h>
@@ -43,6 +43,7 @@ Copyright notice:
 #include <linux/sched.h>
 #include <linux/console.h>
 #include <asm/delay.h>
+*/
 
 char tempOutput[1024],tempOutput2[1024];
 
@@ -51,7 +52,6 @@ BOOLEAN bInPrintk = FALSE;
 BOOLEAN bIsDebugPrint = FALSE;
 
 ULONG ulCountTimerEvents = 0;
-struct timer_list sPiceRunningTimer;
 
 asmlinkage int printk(const char *fmt, ...);
 
@@ -65,7 +65,9 @@ EXPORT_SYMBOL(printk);
 asmlinkage int printk(const char *fmt, ...)
 {
        ULONG len,ulRingBufferLock;
-    static ULONG ulOldJiffies = 0;
+    static LONGLONG ulOldJiffies = 0;
+       LARGE_INTEGER jiffies;
+
        va_list args;
        va_start(args, fmt);
 
@@ -76,12 +78,13 @@ asmlinkage int printk(const char *fmt, ...)
 
                PICE_vsprintf(tempOutput, fmt, args);
                bIsDebugPrint = TRUE;
-        // if the last debug print was longer than 5 timer ticks ago
+        // if the last debug print was longer than 50 ms ago
         // directly print it, else just add it to the ring buffer
         // and let the timer process it.
-        if( (jiffies-ulOldJiffies) > (1*wWindow[OUTPUT_WINDOW].cy)/2)
+               KeQuerySystemTime(&jiffies);
+        if( (jiffies.QuadPart-ulOldJiffies) > 10000*(1*wWindow[OUTPUT_WINDOW].cy)/2)
         {
-            ulOldJiffies = jiffies;
+            ulOldJiffies = jiffies.QuadPart;
                    Print(OUTPUT_WINDOW,tempOutput);
         }
         else
@@ -183,19 +186,28 @@ void PrintkCallback(void)
 // PiceRunningTimer() 
 // 
 //************************************************************************* 
-void PiceRunningTimer(unsigned long param)
-{
-       mod_timer(&sPiceRunningTimer,jiffies + HZ/10);
 
+KTIMER PiceTimer; 
+KDPC PiceTimerDPC;
+
+// do I need it here? Have to keep DPC memory resident #pragma code_seg()
+VOID PiceRunningTimer(IN PKDPC Dpc,
+                       IN PVOID DeferredContext,
+                       IN PVOID SystemArgument1,
+                       IN PVOID SystemArgument2)
+{
        CheckRingBuffer();
 
     if(ulCountTimerEvents++ > 10)
     {
         ulCountTimerEvents = 0;
 
+               LARGE_INTEGER jiffies;
+               
+               KeQuerySystemTime(&jiffies);
         SetForegroundColor(COLOR_TEXT);
            SetBackgroundColor(COLOR_CAPTION);
-        PICE_sprintf(tempOutput,"jiffies = %.8X\n",jiffies);
+        PICE_sprintf(tempOutput,"jiffies = %.8X\n",jiffies.LowPart);
            PutChar(tempOutput,GLOBAL_SCREEN_WIDTH-strlen(tempOutput),GLOBAL_SCREEN_HEIGHT-1);
         ResetColor();
     }
@@ -207,11 +219,19 @@ void PiceRunningTimer(unsigned long param)
 //************************************************************************* 
 void InitPiceRunningTimer(void)
 {
-       init_timer(&sPiceRunningTimer);
-       sPiceRunningTimer.data = 0;
-       sPiceRunningTimer.function = PiceRunningTimer;
-       sPiceRunningTimer.expires = jiffies + HZ;
-       add_timer(&sPiceRunningTimer);
+       LARGE_INTEGER   Interval;
+    
+       ENTER_FUNC();     
+ÿÿ
+       KeInitializeTimer( &PiceTimer );
+       KeInitializeDpc( &PiceTimerDPC, PiceRunningTimer, NULL );
+    
+       Interval.QuadPart=-1000000L;  // 100 millisec. (unit is 100 nanosec.)
+
+    KeSetTimerEx(&PiceTimer,
+                        Interval, 1000000L,
+                        &PiceTimerDpc);
+    LEAVE_FUNC();
 }
 
 //************************************************************************* 
@@ -220,7 +240,7 @@ void InitPiceRunningTimer(void)
 //************************************************************************* 
 void RemovePiceRunningTimer(void)
 {
-       del_timer(&sPiceRunningTimer);
+       KeCancelTimer( &PiceTimer );
 }
 
 //************************************************************************* 
@@ -230,9 +250,12 @@ void RemovePiceRunningTimer(void)
 void InstallPrintkHook(void)
 {
     ENTER_FUNC();
-    DPRINT((0,"enter InstallPrintk()\n"));
+    DPRINT((0,"installing PrintString hook\n"));
+
+    ScanExports("_KdpPrintString",(PULONG)&ulPrintk);
+       
+       ASSERT( ulPrintk );                 // temporary
 
-    ScanExports("printk",(PULONG)&ulPrintk);
     if(ulPrintk)
     {
         InstallSWBreakpoint(ulPrintk,TRUE,PrintkCallback);
index 159fd16..4d2967c 100644 (file)
@@ -125,7 +125,7 @@ BOOLEAN PatchKeyboardDriver(ULONG AddrOfKbdEvent,ULONG AddrOfScancode)
     DPRINT((0,"initial offset = %X\n",ulOffset));
        *pOffset = ulOffset;
 
-       while((memcmp(pPatchAddress,ucPattern,sizeof(ucPattern))!=0) &&
+       while((RtlCompareMemory(pPatchAddress,ucPattern,sizeof(ucPattern))!=0) &&
              (countBytes<0x1000))
        {
 /*        DPRINT((0,"offset = %X\n",ulOffset));
@@ -140,7 +140,7 @@ BOOLEAN PatchKeyboardDriver(ULONG AddrOfKbdEvent,ULONG AddrOfScancode)
                *pOffset = ulOffset;
        }
        
-       if(memcmp(pPatchAddress,ucPattern,sizeof(ucPattern))==0)
+       if(RtlCompareMemory(pPatchAddress,ucPattern,sizeof(ucPattern))==0)
        {
                DPRINT((0,"pattern found @ %x\n",pPatchAddress));
                
index 5b5f0be..6bd24df 100644 (file)
@@ -74,11 +74,13 @@ NTSTATUS STDCALL pice_open(PDEVICE_OBJECT DeviceObject, PIRP Irp)
     
     /* We don't want to talk to two processes at the 
     * same time */
-    if (bDeviceAlreadyOpen)
-        return STATUS_UNSUCCESSFUL;     /* is there a more descriptive status code for this case? */
+    if (bDeviceAlreadyOpen){
+               IoCompleteRequest (Irp, IO_NO_INCREMENT);
+               return STATUS_UNSUCCESSFUL;     /* is there a more descriptive status code for this case? */
+       }
     
     bDeviceAlreadyOpen = TRUE;
-    
+       IoCompleteRequest (Irp, IO_NO_INCREMENT);
        return STATUS_SUCCESS;
 }
 
@@ -94,6 +96,7 @@ NTSTATUS STDCALL pice_close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
     
        /* We're now ready for our next caller */
     bDeviceAlreadyOpen = FALSE;
+       IoCompleteRequest (Irp, IO_NO_INCREMENT);
        return STATUS_SUCCESS;
 }
 
@@ -147,9 +150,10 @@ NTSTATUS STDCALL pice_ioctl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
             }
             break;
         default:
-            return STATUS_BAD_PARAMETER;
+                       IoCompleteRequest (Irp, IO_NO_INCREMENT);
+                       return STATUS_BAD_PARAMETER;
        }
-
+       IoCompleteRequest (Irp, IO_NO_INCREMENT);
     return STATUS_SUCCESS;
 }
 
index 5075f4f..6c64d78 100644 (file)
@@ -28,9 +28,6 @@ Copyright notice:
   This file may be distributed under the terms of the GNU Public License.
 
 --*/
-#include <linux/kernel.h>
-#define __NO_VERSION__
-#include <linux/module.h>
-#include <linux/version.h>
+
 
 
index 3b12f89..5cbae23 100644 (file)
@@ -150,7 +150,7 @@ nomatch:
                p = temp;
                for(;*pStr!=0x0a;)*p++=*pStr++;
                *p=0;
-               p = strtok(temp," ");
+               p = PICE_strtok(temp," ");
                state=0;
                while(p)
                {
@@ -174,7 +174,7 @@ nomatch:
                                                
                        }
                        state++;
-                       p = strtok(NULL," ");
+                       p = PICE_strtok(NULL," ");
                }
        }
 
index 2b782c9..282637e 100644 (file)
@@ -2006,7 +2006,12 @@ UCHAR AsciiToScan(UCHAR s)
 //************************************************************************
 void outportb(USHORT port,UCHAR data)
 {
-    outb(data,port);
+    WRITE_PORT_UCHAR(data,port);
+}
+
+void outb_p(UCHAR data, USHORT port)
+{
+       WRITE_PORT_UCHAR(data,port);
 }
 
 //************************************************************************
@@ -2015,8 +2020,14 @@ void outportb(USHORT port,UCHAR data)
 //************************************************************************
 UCHAR inportb(USHORT port)
 {
-    return inb(port);
+    return READ_PORT_UCHAR(port);
 }
+                          
+UCHAR inb_p(USHORT port)
+{
+    return READ_PORT_UCHAR(port);
+}                         
+
 
 //************************************************************************* 
 // GetInitMm() 
index b369da0..0f0eb23 100644 (file)
@@ -218,8 +218,8 @@ BOOLEAN Disasm(PULONG pOffset, PUCHAR pchDst);
 #define GLOBAL_CODE_SEGMENT (__KERNEL_CS) 
 #define GLOBAL_DATA_SEGMENT (__KERNEL_DS) 
 
-#define OVR_CS .byte 0x2e 
-#define OVR_FS .byte 0x64 
+//#define OVR_CS .byte 0x2e 
+//#define OVR_FS .byte 0x64 
 
 void DisplayRegs(void);
 void SaveOldRegs(void);
@@ -239,6 +239,15 @@ UCHAR AsciiToScan(UCHAR s);
 void outportb(USHORT port,UCHAR data);
 UCHAR inportb(USHORT port);
 
+void outb_p(UCHAR data, USHORT port);
+UCHAR inb_p(USHORT port);
+
+#define save_flags(x)         __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
+#define restore_flags(x)      __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
+#define cli()                 __asm__ __volatile__("cli": : :"memory")
+#define sti()                 __asm__ __volatile__("sti": : :"memory")
+
+
 extern unsigned long sys_call_table[];
 
 struct mm_struct *GetInitMm(void);
index 8d84c53..78a02de 100644 (file)
@@ -35,7 +35,7 @@ Copyright notice:
 #include "remods.h"
 #include "precomp.h"
 
-#include <asm/io.h>
+//#include <asm/io.h>
 #include <linux/ctype.h>