Use "FARPTR" consistently in macros.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 23 Mar 2008 00:44:37 +0000 (20:44 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 23 Mar 2008 00:44:37 +0000 (20:44 -0400)
Rename MAKE_32_PTR to MAKE_FARPTR.
Rename PTR_TO_SEG to FARPTR_TO_SEG.
Rename PTR_TO_OFFSET to FARPTR_TO_OFFSET.

src/ata.c
src/cdrom.c
src/disk.c
src/farptr.h
src/post.c

index 6f4cf246c1afd54422a8b43cbbf284aa49607d11..d6284205c7a00f6e5b85096051e04a0b40fe1ca8 100644 (file)
--- a/src/ata.c
+++ b/src/ata.c
@@ -306,7 +306,7 @@ ata_cmd_packet(u16 biosid, u8 *cmdbuf, u8 cmdlen
     SET_EBDA(ata.trsfbytes,0L);
 
     // Send command to device
-    outsw_far(iobase1, MAKE_32_PTR(GET_SEG(SS), (u32)cmdbuf), cmdlen / 2);
+    outsw_far(iobase1, MAKE_FARPTR(GET_SEG(SS), (u32)cmdbuf), cmdlen / 2);
 
     u8 status;
     u16 loops = 0;
@@ -495,7 +495,7 @@ init_drive_atapi(u8 devid)
     memset(buffer, 0, sizeof(buffer));
     u16 ret = ata_cmd_data(devid, ATA_CMD_IDENTIFY_DEVICE_PACKET
                            , 1, 1
-                           , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
+                           , MAKE_FARPTR(GET_SEG(SS), (u32)buffer));
     if (ret != 0)
         BX_PANIC("ata-detect: Failed to detect ATAPI device\n");
 
@@ -536,7 +536,7 @@ init_drive_ata(u8 devid)
     memset(buffer, 0, sizeof(buffer));
     u16 ret = ata_cmd_data(devid, ATA_CMD_IDENTIFY_DEVICE
                            , 1, 1
-                           , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
+                           , MAKE_FARPTR(GET_SEG(SS), (u32)buffer));
     if (ret)
         BX_PANIC("ata-detect: Failed to detect ATA device\n");
 
index 590569ad0a793db2b5b3b56cc7ae87b81bd8267d..fc616e1a6ffd5921bce6e568ba705100a7b90231 100644 (file)
@@ -297,7 +297,7 @@ atapi_get_sense(u16 device, u8 *asc, u8 *ascq)
     atacmd[4] = sizeof(buffer);
     u16 ret = ata_cmd_packet(device, atacmd, sizeof(atacmd)
                              , 0, sizeof(buffer)
-                             , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
+                             , MAKE_FARPTR(GET_SEG(SS), (u32)buffer));
     if (ret != 0)
         return 0x0002;
 
@@ -334,7 +334,7 @@ atapi_is_ready(u16 device)
         }
         u16 ret = ata_cmd_packet(device, packet, sizeof(packet)
                                  , 0, sizeof(buf)
-                                 , MAKE_32_PTR(GET_SEG(SS), (u32)buf));
+                                 , MAKE_FARPTR(GET_SEG(SS), (u32)buf));
         if (ret == 0)
             break;
 
@@ -432,7 +432,7 @@ cdrom_boot()
     // Read the Boot Record Volume Descriptor
     u8 buffer[2048];
     ret = cdrom_read(device, 0x11, 2048
-                     , MAKE_32_PTR(GET_SEG(SS), (u32)buffer), 0);
+                     , MAKE_FARPTR(GET_SEG(SS), (u32)buffer), 0);
     if (ret)
         return 3;
 
@@ -447,7 +447,7 @@ cdrom_boot()
 
     // And we read the Boot Catalog
     ret = cdrom_read(device, lba, 2048
-                     , MAKE_32_PTR(GET_SEG(SS), (u32)buffer), 0);
+                     , MAKE_FARPTR(GET_SEG(SS), (u32)buffer), 0);
     if (ret)
         return 7;
 
@@ -485,7 +485,7 @@ cdrom_boot()
 
     // And we read the image in memory
     ret = cdrom_read(device, lba, nbsectors*512
-                     , MAKE_32_PTR(boot_segment, 0), 0);
+                     , MAKE_FARPTR(boot_segment, 0), 0);
     if (ret)
         return 12;
 
index 152315e6e291cde0e2a6f66b42aa1ba2973f2d56..23127921a28760cd82d7d4d040c1c959825f1323 100644 (file)
@@ -78,7 +78,7 @@ basic_access(struct bregs *regs, u8 device, u16 command)
                + (u32)sector - 1);
     irq_enable();
     u8 status = ata_cmd_data(device, command, lba, count
-                             , MAKE_32_PTR(segment, offset));
+                             , MAKE_FARPTR(segment, offset));
     irq_disable();
 
     // Set nb of sector transferred
@@ -139,7 +139,7 @@ emu_access(struct bregs *regs, u8 device, u16 command)
 
     irq_enable();
     u8 status = cdrom_read(device, lba, count*512
-                           , MAKE_32_PTR(segment, offset), before*512);
+                           , MAKE_FARPTR(segment, offset), before*512);
     irq_disable();
     if (status != 0) {
         BX_INFO("int13_harddisk: function %02x, error %02x !\n"
@@ -189,10 +189,10 @@ extended_access(struct bregs *regs, u8 device, u16 command)
     u8 status;
     if (type == ATA_TYPE_ATA)
         status = ata_cmd_data(device, command, lba, count
-                              , MAKE_32_PTR(segment, offset));
+                              , MAKE_FARPTR(segment, offset));
     else
         status = cdrom_read(device, lba, count*2048
-                            , MAKE_32_PTR(segment, offset), 0);
+                            , MAKE_FARPTR(segment, offset), 0);
 
     irq_disable();
 
index 1dea4b6510472b7bcc778776d6ea55e3c14f9169..cc8cd68e9ab2d99edf9f1b3714f34e54a3090695 100644 (file)
@@ -95,9 +95,9 @@ extern void __force_link_error__unknown_type();
 
 // Macros for converting to/from 32bit style pointers to their
 // equivalent 16bit segment/offset values.
-#define PTR_TO_SEG(p) (((u32)(p)) >> 4)
-#define PTR_TO_OFFSET(p) (((u32)(p)) & 0xf)
-#define MAKE_32_PTR(seg,off) ((void*)(((seg)<<4)+(off)))
+#define FARPTR_TO_SEG(p) (((u32)(p)) >> 4)
+#define FARPTR_TO_OFFSET(p) (((u32)(p)) & 0xf)
+#define MAKE_FARPTR(seg,off) ((void*)(((seg)<<4)+(off)))
 
 
 #ifdef MODE16
@@ -113,35 +113,35 @@ extern void __force_link_error__unknown_type();
 #define SET_FARPTR(ptr, val) __SET_FARPTR((ptr), (val))
 
 static inline void insb_far(u16 port, void *farptr, u16 count) {
-    SET_SEG(ES, PTR_TO_SEG(farptr));
-    insb(port, (u8*)PTR_TO_OFFSET(farptr), count);
+    SET_SEG(ES, FARPTR_TO_SEG(farptr));
+    insb(port, (u8*)FARPTR_TO_OFFSET(farptr), count);
 }
 static inline void insw_far(u16 port, void *farptr, u16 count) {
-    SET_SEG(ES, PTR_TO_SEG(farptr));
-    insw(port, (u16*)PTR_TO_OFFSET(farptr), count);
+    SET_SEG(ES, FARPTR_TO_SEG(farptr));
+    insw(port, (u16*)FARPTR_TO_OFFSET(farptr), count);
 }
 static inline void insl_far(u16 port, void *farptr, u16 count) {
-    SET_SEG(ES, PTR_TO_SEG(farptr));
-    insl(port, (u32*)PTR_TO_OFFSET(farptr), count);
+    SET_SEG(ES, FARPTR_TO_SEG(farptr));
+    insl(port, (u32*)FARPTR_TO_OFFSET(farptr), count);
 }
 static inline void outsb_far(u16 port, void *farptr, u16 count) {
-    SET_SEG(ES, PTR_TO_SEG(farptr));
-    outsb(port, (u8*)PTR_TO_OFFSET(farptr), count);
+    SET_SEG(ES, FARPTR_TO_SEG(farptr));
+    outsb(port, (u8*)FARPTR_TO_OFFSET(farptr), count);
 }
 static inline void outsw_far(u16 port, void *farptr, u16 count) {
-    SET_SEG(ES, PTR_TO_SEG(farptr));
-    outsw(port, (u16*)PTR_TO_OFFSET(farptr), count);
+    SET_SEG(ES, FARPTR_TO_SEG(farptr));
+    outsw(port, (u16*)FARPTR_TO_OFFSET(farptr), count);
 }
 static inline void outsl_far(u16 port, void *farptr, u16 count) {
-    SET_SEG(ES, PTR_TO_SEG(farptr));
-    outsl(port, (u32*)PTR_TO_OFFSET(farptr), count);
+    SET_SEG(ES, FARPTR_TO_SEG(farptr));
+    outsl(port, (u32*)FARPTR_TO_OFFSET(farptr), count);
 }
 
 #else
 
 // In 32-bit mode there is no need to mess with the segments.
 #define GET_FARVAR(seg, var) \
-    (*((typeof(&(var)))MAKE_32_PTR((seg), (u32)&(var))))
+    (*((typeof(&(var)))MAKE_FARPTR((seg), (u32)&(var))))
 #define SET_FARVAR(seg, var, val) \
     do { GET_FARVAR((seg), (var)) = (val); } while (0)
 #define GET_VAR(seg, var) (var)
index c5dbaf3bed2b89236c924da53265439b667f6497..dc8edec9d919d5bc5bc651ff4874811a17462890 100644 (file)
@@ -330,7 +330,7 @@ rom_scan(u32 start, u32 end)
         if (checksum(rom, len) != 0)
             continue;
         p = (u8*)(((u32)p + len) / 2048 * 2048);
-        callrom(PTR_TO_SEG(rom), PTR_TO_OFFSET(rom + 3));
+        callrom(FARPTR_TO_SEG(rom), FARPTR_TO_OFFSET(rom + 3));
 
         // Look at the ROM's PnP Expansion header.  Properly, we're supposed
         // to init all the ROMs and then go back and build an IPL table of
@@ -351,11 +351,11 @@ rom_scan(u32 start, u32 end)
 
         struct ipl_entry_s *ip = &ipl->table[ipl->count];
         ip->type = IPL_TYPE_BEV;
-        ip->vector = (PTR_TO_SEG(rom) << 16) | entry;
+        ip->vector = (FARPTR_TO_SEG(rom) << 16) | entry;
 
         u16 desc = *(u16*)&rom[0x1a+0x10];
         if (desc)
-            ip->description = (PTR_TO_SEG(rom) << 16) | desc;
+            ip->description = (FARPTR_TO_SEG(rom) << 16) | desc;
 
         ipl->count++;
     }