Previous 15994 Revisions Next

r8912 Thursday 26th August, 2010 at 20:50:23 UTC by Angelo Salese
Fixed broken error.log offsets
[src/emu]memory.c

src/emu/memory.c
r8911r8912
766766   _UintType unmap_r(address_space &space, offs_t offset, _UintType mask)
767767   {
768768      if (m_space.log_unmap() && !m_space.debugger_access())
769         logerror("%s: unmapped %s memory read from %s & %s\n",
770                  cpuexec_describe_context(&m_space.m_machine), m_space.name(),
771                  core_i64_hex_format(m_space.byte_to_address(offset), m_space.addrchars()),
769         logerror("%s: unmapped %s memory read from %s & %s\n",
770                  cpuexec_describe_context(&m_space.m_machine), m_space.name(),
771                  core_i64_hex_format(m_space.byte_to_address(offset * sizeof(_UintType)), m_space.addrchars()),
772772                  core_i64_hex_format(mask, 2 * sizeof(_UintType)));
773773      return m_space.unmap();
774774   }
r8911r8912
822822   void unmap_w(address_space &space, offs_t offset, _UintType data, _UintType mask)
823823   {
824824      if (m_space.log_unmap() && !m_space.debugger_access())
825         logerror("%s: unmapped %s memory write to %s = %s & %s\n",
826               cpuexec_describe_context(&m_space.m_machine), m_space.name(),
827               core_i64_hex_format(m_space.byte_to_address(offset), m_space.addrchars()),
825         logerror("%s: unmapped %s memory write to %s = %s & %s\n",
826               cpuexec_describe_context(&m_space.m_machine), m_space.name(),
827               core_i64_hex_format(m_space.byte_to_address(offset * sizeof(_UintType)), m_space.addrchars()),
828828               core_i64_hex_format(data, 2 * sizeof(_UintType)),
829829               core_i64_hex_format(mask, 2 * sizeof(_UintType)));
830830   }
r8911r8912
860860class address_space_specific : public address_space
861861{
862862   typedef address_space_specific<_NativeType, _Endian, _Large> this_type;
863   
863
864864   // constants describing the native size
865865   static const UINT32 NATIVE_BYTES = sizeof(_NativeType);
866866   static const UINT32 NATIVE_MASK = NATIVE_BYTES - 1;
r8911r8912
880880#if (TEST_HANDLER)
881881      // test code to verify the read/write handlers are touching the correct bits
882882      // and returning the correct results
883     
883
884884      // install some dummy RAM for the first 16 bytes with well-known values
885885      UINT8 buffer[16];
886886      for (int index = 0; index < 16; index++)
r8911r8912
903903         UINT32 expected32 = (_Endian == ENDIANNESS_LITTLE) ? expected64 : (expected64 >> 32);
904904         UINT16 expected16 = (_Endian == ENDIANNESS_LITTLE) ? expected32 : (expected32 >> 16);
905905         UINT8 expected8 = (_Endian == ENDIANNESS_LITTLE) ? expected16 : (expected16 >> 8);
906         
906
907907         UINT64 result64;
908908         UINT32 result32;
909909         UINT16 result16;
910910         UINT8 result8;
911     
911
912912         // validate byte accesses
913913         printf("\nAddress %d\n", address);
914914         printf("   read_byte = "); printf("%02X\n", result8 = read_byte(address)); assert(result8 == expected8);
r8911r8912
935935         if (address % 4 == 0) { printf("              (0x00ffffff) = "); printf("%08X\n", result32 = read_dword(address, 0x00ffffff)); assert((result32 & 0x00ffffff) == (expected32 & 0x00ffffff)); }
936936
937937         // validate unaligned dword accesses
938         printf("   read_dword_unaligned = "); printf("%08X\n", result32 = read_dword_unaligned(address)); assert(result32 == expected32);
938         printf("   read_dword_unaligned = "); printf("%08X\n", result32 = read_dword_unaligned(address)); assert(result32 == expected32);
939939         printf("   read_dword_unaligned (0xff000000) = "); printf("%08X\n", result32 = read_dword_unaligned(address, 0xff000000)); assert((result32 & 0xff000000) == (expected32 & 0xff000000));
940940         printf("                        (0x00ff0000) = "); printf("%08X\n", result32 = read_dword_unaligned(address, 0x00ff0000)); assert((result32 & 0x00ff0000) == (expected32 & 0x00ff0000));
941941         printf("                        (0x0000ff00) = "); printf("%08X\n", result32 = read_dword_unaligned(address, 0x0000ff00)); assert((result32 & 0x0000ff00) == (expected32 & 0x0000ff00));
r8911r8912
979979         if (address % 8 == 0) { printf("              (0x00ffffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00ffffffffffffff)), 16)); assert((result64 & U64(0x00ffffffffffffff)) == (expected64 & U64(0x00ffffffffffffff))); }
980980
981981         // validate unaligned qword accesses
982         printf("   read_qword_unaligned = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address), 16)); assert(result64 == expected64);
982         printf("   read_qword_unaligned = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address), 16)); assert(result64 == expected64);
983983         printf("   read_qword_unaligned (0xff00000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xff00000000000000)), 16)); assert((result64 & U64(0xff00000000000000)) == (expected64 & U64(0xff00000000000000)));
984984         printf("                        (0x00ff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00ff000000000000)), 16)); assert((result64 & U64(0x00ff000000000000)) == (expected64 & U64(0x00ff000000000000)));
985985         printf("                        (0x0000ff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ff0000000000)), 16)); assert((result64 & U64(0x0000ff0000000000)) == (expected64 & U64(0x0000ff0000000000)));
r8911r8912
11871187         }
11881188      }
11891189
1190      // determine our alignment against the native boundaries, and mask the address     
1190      // determine our alignment against the native boundaries, and mask the address
11911191      UINT32 offsbits = 8 * (address & (NATIVE_BYTES - 1));
11921192      address &= ~NATIVE_MASK;
11931193
r8911r8912
12251225            // read lower bits from upper address
12261226            curmask = ljmask << offsbits;
12271227            if (curmask != 0) result |= read_native(address + NATIVE_BYTES, curmask) >> offsbits;
1228           
1228
12291229            // return the un-justified result
12301230            return result >> LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT;
12311231         }
r8911r8912
12381238         // a fixed number of loops for the compiler to unroll if it desires
12391239         const UINT32 MAX_SPLITS_MINUS_ONE = TARGET_BYTES / NATIVE_BYTES - 1;
12401240         _TargetType result = 0;
1241         
1241
12421242         // little-endian case
12431243         if (_Endian == ENDIANNESS_LITTLE)
12441244         {
r8911r8912
12711271            offsbits = TARGET_BITS - (NATIVE_BITS - offsbits);
12721272            _NativeType curmask = mask >> offsbits;
12731273            if (curmask != 0) result = (_TargetType)read_native(address, curmask) << offsbits;
1274           
1274
12751275            // read middle bits from subsequent addresses
12761276            for (UINT32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++)
12771277            {
r8911r8912
12801280               curmask = mask >> offsbits;
12811281               if (curmask != 0) result |= (_TargetType)read_native(address, curmask) << offsbits;
12821282            }
1283           
1283
12841284            // if we're not aligned and we still have bits left, read lowermost bits from the last address
12851285            if (!_Aligned && offsbits != 0)
12861286            {
r8911r8912
12921292         return result;
12931293      }
12941294   }
1295   
1295
12961296   // generic direct write
12971297   template<typename _TargetType, bool _Aligned>
12981298   void write_direct(offs_t address, _TargetType data, _TargetType mask)
r8911r8912
13151315         }
13161316      }
13171317
1318      // determine our alignment against the native boundaries, and mask the address     
1318      // determine our alignment against the native boundaries, and mask the address
13191319      UINT32 offsbits = 8 * (address & (NATIVE_BYTES - 1));
13201320      address &= ~NATIVE_MASK;
13211321
r8911r8912
13281328            // write lower bits to lower address
13291329            _NativeType curmask = (_NativeType)mask << offsbits;
13301330            if (curmask != 0) write_native(address, (_NativeType)data << offsbits, curmask);
1331           
1331
13321332            // write upper bits to upper address
13331333            offsbits = NATIVE_BITS - offsbits;
13341334            curmask = mask >> offsbits;
r8911r8912
13421342            const UINT32 LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT = ((NATIVE_BITS >= TARGET_BITS) ? (NATIVE_BITS - TARGET_BITS) : 0);
13431343            _NativeType ljdata = (_NativeType)data << LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT;
13441344            _NativeType ljmask = (_NativeType)mask << LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT;
1345           
1345
13461346            // write upper bits to lower address
13471347            _NativeType curmask = ljmask >> offsbits;
13481348            if (curmask != 0) write_native(address, ljdata >> offsbits, curmask);
1349           
1349
13501350            // write lower bits to upper address
13511351            offsbits = NATIVE_BITS - offsbits;
13521352            curmask = ljmask << offsbits;
r8911r8912
13601360         // compute the maximum number of loops; we do it this way so that there are
13611361         // a fixed number of loops for the compiler to unroll if it desires
13621362         const UINT32 MAX_SPLITS_MINUS_ONE = TARGET_BYTES / NATIVE_BYTES - 1;
1363         
1363
13641364         // little-endian case
13651365         if (_Endian == ENDIANNESS_LITTLE)
13661366         {
13671367            // write lowest bits to first address
13681368            _NativeType curmask = mask << offsbits;
13691369            if (curmask != 0) write_native(address, data << offsbits, curmask);
1370           
1370
13711371            // write middle bits to subsequent addresses
13721372            offsbits = NATIVE_BITS - offsbits;
13731373            for (UINT32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++)
r8911r8912
13771377               if (curmask != 0) write_native(address, data >> offsbits, curmask);
13781378               offsbits += NATIVE_BITS;
13791379            }
1380           
1380
13811381            // if we're not aligned and we still have bits left, write uppermost bits to last address
13821382            if (!_Aligned && offsbits < TARGET_BITS)
13831383            {
r8911r8912
13931393            offsbits = TARGET_BITS - (NATIVE_BITS - offsbits);
13941394            _NativeType curmask = mask >> offsbits;
13951395            if (curmask != 0) write_native(address, data >> offsbits, curmask);
1396           
1396
13971397            // write middle bits to subsequent addresses
13981398            for (UINT32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++)
13991399            {
r8911r8912
14021402               curmask = mask >> offsbits;
14031403               if (curmask != 0) write_native(address, data >> offsbits, curmask);
14041404            }
1405           
1405
14061406            // if we're not aligned and we still have bits left, write lowermost bits to the last address
14071407            if (!_Aligned && offsbits != 0)
14081408            {
r8911r8912
23592359void address_space::unmap(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read_or_write readorwrite, bool quiet)
23602360{
23612361   VPRINTF(("address_space::unmap(%s-%s mask=%s mirror=%s, %s, %s)\n",
2362          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2363          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2362          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2363          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
23642364          (readorwrite == ROW_READ) ? "read" : (readorwrite == ROW_WRITE) ? "write" : (readorwrite == ROW_READWRITE) ? "read/write" : "??",
23652365          quiet ? "quiet" : "normal"));
23662366
r8911r8912
23822382void address_space::install_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag)
23832383{
23842384   VPRINTF(("address_space::install_port(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n",
2385          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2386          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2385          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2386          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
23872387          (rtag != NULL) ? rtag : "(none)", (wtag != NULL) ? wtag : "(none)"));
23882388
23892389   // read handler
r8911r8912
24242424void address_space::install_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag)
24252425{
24262426   VPRINTF(("address_space::install_bank(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n",
2427          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2428          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2427          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2428          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
24292429          (rtag != NULL) ? rtag : "(none)", (wtag != NULL) ? wtag : "(none)"));
24302430
24312431   // map the read bank
r8911r8912
24572457   memory_private *memdata = m_machine.memory_data;
24582458
24592459   VPRINTF(("address_space::install_ram(%s-%s mask=%s mirror=%s, %s, %p)\n",
2460          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2461          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2460          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2461          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
24622462          (readorwrite == ROW_READ) ? "read" : (readorwrite == ROW_WRITE) ? "write" : (readorwrite == ROW_READWRITE) ? "read/write" : "??",
24632463          baseptr));
24642464
r8911r8912
25322532UINT8 *address_space::install_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_delegate handler, UINT64 unitmask)
25332533{
25342534   VPRINTF(("address_space::install_handler(%s-%s mask=%s mirror=%s, %s, %s)\n",
2535          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2536          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2535          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2536          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
25372537          handler.name(), core_i64_hex_format(unitmask, data_width() / 4)));
25382538
25392539   UINT32 entry = read().map_range(addrstart, addrend, addrmask, addrmirror);
r8911r8912
25452545UINT8 *address_space::install_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_delegate handler, UINT64 unitmask)
25462546{
25472547   VPRINTF(("address_space::install_handler(%s-%s mask=%s mirror=%s, %s, %s)\n",
2548          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2549          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2548          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2549          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
25502550          handler.name(), core_i64_hex_format(unitmask, data_width() / 4)));
25512551
25522552   UINT32 entry = write().map_range(addrstart, addrend, addrmask, addrmirror);
r8911r8912
25712571UINT8 *address_space::install_legacy_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_space_func rhandler, const char *rname, UINT64 unitmask)
25722572{
25732573   VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s) [read8]\n",
2574          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2575          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2574          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2575          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
25762576          rname, core_i64_hex_format(unitmask, data_width() / 4)));
25772577
25782578   UINT32 entry = read().map_range(addrstart, addrend, addrmask, addrmirror);
r8911r8912
25842584UINT8 *address_space::install_legacy_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_space_func whandler, const char *wname, UINT64 unitmask)
25852585{
25862586   VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s) [write8]\n",
2587          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2588          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2587          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2588          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
25892589          wname, core_i64_hex_format(unitmask, data_width() / 4)));
25902590
25912591   UINT32 entry = write().map_range(addrstart, addrend, addrmask, addrmirror);
r8911r8912
26092609UINT8 *address_space::install_legacy_handler(device_t &device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rname, UINT64 unitmask)
26102610{
26112611   VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s, \"%s\") [read8]\n",
2612          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2613          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2612          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2613          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
26142614          rname, core_i64_hex_format(unitmask, data_width() / 4), device.tag()));
26152615
26162616   UINT32 entry = read().map_range(addrstart, addrend, addrmask, addrmirror);
r8911r8912
26222622UINT8 *address_space::install_legacy_handler(device_t &device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_device_func whandler, const char *wname, UINT64 unitmask)
26232623{
26242624   VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s, \"%s\") [write8]\n",
2625          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2626          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
2625          core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars),
2626          core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars),
26272627          wname, core_i64_hex_format(unitmask, data_width() / 4), device.tag()));
26282628
26292629   UINT32 entry = write().map_range(addrstart, addrend, addrmask, addrmirror);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team