[ros-diffs] [tkreuzer] 35703: - Convert PortAddress from ULONG to PUCHAR - Fix some int <-> pointer casts - remove useless #if __i386__ - use %p for pointer sized prints

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Wed Aug 27 17:37:36 CEST 2008


Author: tkreuzer
Date: Wed Aug 27 10:37:36 2008
New Revision: 35703

URL: http://svn.reactos.org/svn/reactos?rev=35703&view=rev
Log:
- Convert PortAddress from ULONG to PUCHAR
- Fix some int <-> pointer casts
- remove useless #if __i386__
- use %p for pointer sized prints

Modified:
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
    branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hardware.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -779,21 +779,21 @@
 }
 
 static VOID
-InitializeSerialPort(ULONG Port,
+InitializeSerialPort(PUCHAR Port,
 		     ULONG LineControl)
 {
-  WRITE_PORT_UCHAR((PUCHAR)Port + 3, 0x80);  /* set DLAB on   */
-  WRITE_PORT_UCHAR((PUCHAR)Port,     0x60);  /* speed LO byte */
-  WRITE_PORT_UCHAR((PUCHAR)Port + 1, 0);     /* speed HI byte */
-  WRITE_PORT_UCHAR((PUCHAR)Port + 3, LineControl);
-  WRITE_PORT_UCHAR((PUCHAR)Port + 1, 0);     /* set comm and DLAB to 0 */
-  WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x09);  /* DR int enable */
-  READ_PORT_UCHAR((PUCHAR)Port + 5);  /* clear error bits */
+  WRITE_PORT_UCHAR(Port + 3, 0x80);  /* set DLAB on   */
+  WRITE_PORT_UCHAR(Port,     0x60);  /* speed LO byte */
+  WRITE_PORT_UCHAR(Port + 1, 0);     /* speed HI byte */
+  WRITE_PORT_UCHAR(Port + 3, LineControl);
+  WRITE_PORT_UCHAR(Port + 1, 0);     /* set comm and DLAB to 0 */
+  WRITE_PORT_UCHAR(Port + 4, 0x09);  /* DR int enable */
+  READ_PORT_UCHAR(Port + 5);  /* clear error bits */
 }
 
 
 static ULONG
-DetectSerialMouse(ULONG Port)
+DetectSerialMouse(PUCHAR Port)
 {
   CHAR Buffer[4];
   ULONG i;
@@ -801,8 +801,8 @@
   UCHAR LineControl;
 
   /* Shutdown mouse or something like that */
-  LineControl = READ_PORT_UCHAR((PUCHAR)Port + 4);
-  WRITE_PORT_UCHAR((PUCHAR)Port + 4, (LineControl & ~0x02) | 0x01);
+  LineControl = READ_PORT_UCHAR(Port + 4);
+  WRITE_PORT_UCHAR(Port + 4, (LineControl & ~0x02) | 0x01);
   StallExecutionProcessor(100000);
 
   /*
@@ -812,18 +812,18 @@
    * therefore we must give up after some time.
    */
   TimeOut = 200;
-  while (READ_PORT_UCHAR((PUCHAR)Port + 5) & 0x01)
+  while (READ_PORT_UCHAR(Port + 5) & 0x01)
     {
       if (--TimeOut == 0)
         return MOUSE_TYPE_NONE;
-      READ_PORT_UCHAR((PUCHAR)Port);
+      READ_PORT_UCHAR(Port);
     }
 
   /*
    * Send modem control with 'Data Terminal Ready', 'Request To Send' and
    * 'Output Line 2' message. This enables mouse to identify.
    */
-  WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x0b);
+  WRITE_PORT_UCHAR(Port + 4, 0x0b);
 
   /* Wait 10 milliseconds for the mouse getting ready */
   StallExecutionProcessor(10000);
@@ -832,14 +832,14 @@
   TimeOut = 200;
   for (i = 0; i < 4; i++)
     {
-      while (((READ_PORT_UCHAR((PUCHAR)Port + 5) & 1) == 0) && (TimeOut > 0))
+      while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
 	{
 	  StallExecutionProcessor(1000);
 	  --TimeOut;
 	  if (TimeOut == 0)
 	    return MOUSE_TYPE_NONE;
 	}
-      Buffer[i] = READ_PORT_UCHAR((PUCHAR)Port);
+      Buffer[i] = READ_PORT_UCHAR(Port);
     }
 
   DbgPrint((DPRINT_HWDETECT,
@@ -891,26 +891,26 @@
 
 
 static ULONG
-GetSerialMousePnpId(ULONG Port, char *Buffer)
+GetSerialMousePnpId(PUCHAR Port, char *Buffer)
 {
   ULONG TimeOut;
   ULONG i = 0;
   char c;
   char x;
 
-  WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x09);
+  WRITE_PORT_UCHAR(Port + 4, 0x09);
 
   /* Wait 10 milliseconds for the mouse getting ready */
   StallExecutionProcessor(10000);
 
-  WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x0b);
+  WRITE_PORT_UCHAR(Port + 4, 0x0b);
 
   StallExecutionProcessor(10000);
 
   for (;;)
     {
       TimeOut = 200;
-      while (((READ_PORT_UCHAR((PUCHAR)Port + 5) & 1) == 0) && (TimeOut > 0))
+      while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
 	{
 	  StallExecutionProcessor(1000);
 	  --TimeOut;
@@ -920,7 +920,7 @@
 	    }
 	}
 
-      c = READ_PORT_UCHAR((PUCHAR)Port);
+      c = READ_PORT_UCHAR(Port);
       if (c == 0x08 || c == 0x28)
 	break;
     }
@@ -931,14 +931,14 @@
   for (;;)
     {
       TimeOut = 200;
-      while (((READ_PORT_UCHAR((PUCHAR)Port + 5) & 1) == 0) && (TimeOut > 0))
+      while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
 	{
 	  StallExecutionProcessor(1000);
 	  --TimeOut;
 	  if (TimeOut == 0)
 	    return 0;
 	}
-      c = READ_PORT_UCHAR((PUCHAR)Port);
+      c = READ_PORT_UCHAR(Port);
       Buffer[i++] = c;
       if (c == x)
 	break;
@@ -952,7 +952,7 @@
 
 static VOID
 DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey,
-			      ULONG Base)
+			      PUCHAR Base)
 {
   CM_PARTIAL_RESOURCE_LIST PartialResourceList;
   char Buffer[256];
@@ -1227,7 +1227,7 @@
       if (!Rs232PortInUse(Base))
         {
           /* Detect serial mouse */
-          DetectSerialPointerPeripheral(ControllerKey, Base);
+          DetectSerialPointerPeripheral(ControllerKey, UlongToPtr(Base));
         }
 
       ControllerNumber++;

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -30,7 +30,7 @@
 
     /* Find the 'Root System Descriptor Table Pointer' */
     Ptr = (PUCHAR)0xE0000;
-    while ((ULONG)Ptr < 0x100000)
+    while ((ULONG_PTR)Ptr < 0x100000)
     {
         if (!memcmp(Ptr, "RSD PTR ", 8))
         {
@@ -39,7 +39,7 @@
             return (PRSDP_DESCRIPTOR)Ptr;
         }
 
-        Ptr = (PUCHAR)((ULONG)Ptr + 0x10);
+        Ptr = (PUCHAR)((ULONG_PTR)Ptr + 0x10);
     }
 
     DbgPrint((DPRINT_HWDETECT, "ACPI not supported\n"));

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -71,7 +71,7 @@
   ULONG i;
 
   Table = (PPCI_IRQ_ROUTING_TABLE)0xF0000;
-  while ((ULONG)Table < 0x100000)
+  while ((ULONG_PTR)Table < 0x100000)
     {
       if (Table->Signature == 0x52495024)
 	{
@@ -98,7 +98,7 @@
 	  return Table;
 	}
 
-      Table = (PPCI_IRQ_ROUTING_TABLE)((ULONG)Table + 0x10);
+      Table = (PPCI_IRQ_ROUTING_TABLE)((ULONG_PTR)Table + 0x10);
     }
 
   return NULL;

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -25,8 +25,6 @@
 /////////////////////////////////////////////////////////////////////////////////////////////
 // FUNCTIONS
 /////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef __i386__
 
 BOOLEAN DiskResetController(ULONG DriveNumber)
 {
@@ -177,7 +175,7 @@
         DbgPrint((DPRINT_DISK, "EED configuration parameters:            %x:%x\n", Ptr[13], Ptr[14]));
         if (Ptr[13] != 0xffff && Ptr[14] != 0xffff)
         {
-           PUCHAR SpecPtr = (PUCHAR)((Ptr[13] << 4) + Ptr[14]);
+           PUCHAR SpecPtr = (PUCHAR)(ULONG_PTR)((Ptr[13] << 4) + Ptr[14]);
            DbgPrint((DPRINT_DISK, "SpecPtr:                                 %x\n", SpecPtr));
            DbgPrint((DPRINT_DISK, "physical I/O port base address:          %x\n", *(PUSHORT)&SpecPtr[0]));
            DbgPrint((DPRINT_DISK, "disk-drive control port address:         %x\n", *(PUSHORT)&SpecPtr[2]));
@@ -198,6 +196,4 @@
 	return TRUE;
 }
 
-#endif /* defined __i386__ */
-
 /* EOF */

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -83,8 +83,8 @@
 	Packet->PacketSize = sizeof(I386_DISK_ADDRESS_PACKET);
 	Packet->Reserved = 0;
 	Packet->LBABlockCount = SectorCount;
-	Packet->TransferBufferOffset = ((ULONG)Buffer) & 0x0F;
-	Packet->TransferBufferSegment = ((ULONG)Buffer) >> 4;
+	Packet->TransferBufferOffset = ((ULONG_PTR)Buffer) & 0x0F;
+	Packet->TransferBufferSegment = ((ULONG_PTR)Buffer) >> 4;
 	Packet->LBAStartBlock = SectorNumber;
 
 	// BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
@@ -211,8 +211,8 @@
 		RegsIn.b.cl = (PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
 		RegsIn.b.dh = PhysicalHead;
 		RegsIn.b.dl = DriveNumber;
-		RegsIn.w.es = ((ULONG)Buffer) >> 4;
-		RegsIn.w.bx = ((ULONG)Buffer) & 0x0F;
+		RegsIn.w.es = ((ULONG_PTR)Buffer) >> 4;
+		RegsIn.w.bx = ((ULONG_PTR)Buffer) & 0x0F;
 
 		//
 		// Perform the read

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -194,8 +194,8 @@
       /* Copy data to caller's buffer */
       RtlCopyMemory(&BiosMemoryMap[MapCount], (PVOID)BIOSCALLBUFFER, Regs.x.ecx);
 
-      DbgPrint((DPRINT_MEMORY, "BaseAddress: 0x%x%x\n", BiosMemoryMap[MapCount].BaseAddress));
-      DbgPrint((DPRINT_MEMORY, "Length: 0x%x%x\n", BiosMemoryMap[MapCount].Length));
+      DbgPrint((DPRINT_MEMORY, "BaseAddress: 0x%p\n", (PVOID)BiosMemoryMap[MapCount].BaseAddress));
+      DbgPrint((DPRINT_MEMORY, "Length: 0x%p\n", (PVOID)BiosMemoryMap[MapCount].Length));
       DbgPrint((DPRINT_MEMORY, "Type: 0x%x\n", BiosMemoryMap[MapCount].Type));
       DbgPrint((DPRINT_MEMORY, "Reserved: 0x%x\n", BiosMemoryMap[MapCount].Reserved));
       DbgPrint((DPRINT_MEMORY, "\n"));

Modified: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c?rev=35703&r1=35702&r2=35703&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c [iso-8859-1] Wed Aug 27 10:37:36 2008
@@ -361,7 +361,7 @@
 static VOID
 PcVideoSet480ScanLines(VOID)
 {
-  int CRTC;
+  INT_PTR CRTC;
 
   /* Read CRTC port */
   CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
@@ -418,7 +418,7 @@
 static VOID
 PcVideoSetDisplayEnd(VOID)
 {
-  int	CRTC;
+  INT_PTR	CRTC;
 
   /* Read CRTC port */
   CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
@@ -1054,7 +1054,7 @@
 {
   USHORT *BufPtr;
 
-  BufPtr = (USHORT *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
+  BufPtr = (USHORT *) (ULONG_PTR)(VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
   *BufPtr = ((USHORT) Attr << 8) | (Ch & 0xff);
 }
 



More information about the Ros-diffs mailing list