home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gdb-4.16-base.tgz / gdb-4.16-base.tar / fsf / gdb / sim / ppc / vm_n.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-19  |  4.1 KB  |  131 lines

  1. /*  This file is part of the program psim.
  2.  
  3.     Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19.     */
  20.  
  21.  
  22. #ifndef N
  23. #error "N must be #defined"
  24. #endif
  25.  
  26. /* NOTE: See end of file for #undef */
  27. #define unsigned_N XCONCAT2(unsigned_,N)
  28. #define T2H_N XCONCAT2(T2H_,N)
  29. #define H2T_N XCONCAT2(H2T_,N)
  30. #define vm_data_map_read_N XCONCAT2(vm_data_map_read_,N)
  31. #define vm_data_map_write_N XCONCAT2(vm_data_map_write_,N)
  32.  
  33.  
  34. INLINE_VM\
  35. (unsigned_N)
  36. vm_data_map_read_N(vm_data_map *map,
  37.            unsigned_word ea,
  38.            cpu *processor,
  39.            unsigned_word cia)
  40. {
  41.   if ((ea & (sizeof(unsigned_N)-1)) == 0) {
  42.     unsigned ra = vm_real_data_addr(map, ea, 1/*is-read*/, processor, cia);
  43.     unsigned_N val;
  44.     if (WITH_XOR_ENDIAN)
  45.       ra ^= map->translation.xor[sizeof(unsigned_N) - 1];
  46.     val = XCONCAT2(core_map_read_,N)(map->read, ra, processor, cia);
  47.     if (WITH_MON & MONITOR_LOAD_STORE_UNIT)
  48.       mon_read(ea, ra, sizeof(unsigned_N), processor, cia);
  49.     TRACE(trace_load_store, ("load cia=0x%lx ea=0x%lx N=%ld val=0x%lx\n",
  50.                  (long)cia, (long)ea, (long)sizeof(unsigned_N), (long)val));
  51.     return val;
  52.   }
  53.   else {
  54.     switch (CURRENT_ALIGNMENT) {
  55.     case STRICT_ALIGNMENT:
  56.       alignment_interrupt(processor, cia, ea);
  57.       return 0;
  58.     case NONSTRICT_ALIGNMENT:
  59.       {
  60.     unsigned_N val;
  61.     if (vm_data_map_read_buffer(map, &val, ea, sizeof(unsigned_N))
  62.         != sizeof(unsigned_N))
  63.       alignment_interrupt(processor, cia, ea);
  64.     val = T2H_N(val);
  65.     if (WITH_MON & MONITOR_LOAD_STORE_UNIT) {
  66.       /* YUCK */
  67.       unsigned ra = vm_real_data_addr(map, ea, 1, processor, cia);
  68.       mon_read(ea, ra, sizeof(unsigned_N), processor, cia);
  69.     }
  70.     TRACE(trace_load_store, ("load cia=0x%lx ea=0x%lx N=%ld data=0x%lx\n",
  71.                  (long)cia, (long)ea, (long)sizeof(unsigned_N), (long)val));
  72.     return val;
  73.       }
  74.     default:
  75.       error("unknown alignment support\n");
  76.       return 0;
  77.     }
  78.   }
  79. }
  80.  
  81. INLINE_VM\
  82. (void)
  83. vm_data_map_write_N(vm_data_map *map,
  84.             unsigned_word ea,
  85.             unsigned_N val,
  86.             cpu *processor,
  87.             unsigned_word cia)
  88. {
  89.   if ((ea & (sizeof(unsigned_N)-1)) == 0) {
  90.     unsigned ra = vm_real_data_addr(map, ea, 0/*is-read?*/, processor, cia);
  91.     if (WITH_XOR_ENDIAN)
  92.       ra ^= map->translation.xor[sizeof(unsigned_N) - 1];
  93.     XCONCAT2(core_map_write_,N)(map->write, ra, val, processor, cia);
  94.     if (WITH_MON & MONITOR_LOAD_STORE_UNIT)
  95.       mon_write(ea, ra, sizeof(unsigned_N), processor, cia);
  96.     TRACE(trace_load_store, ("store cia=0x%lx ea=0x%lx N=%ld val=0x%lx\n",
  97.                  (long)cia, (long)ea, (long)sizeof(unsigned_N), (long)val));
  98.   }
  99.   else {
  100.     switch (CURRENT_ALIGNMENT) {
  101.     case STRICT_ALIGNMENT:
  102.       alignment_interrupt(processor, cia, ea);
  103.       break;
  104.     case NONSTRICT_ALIGNMENT:
  105.       {
  106.     unsigned_N data = H2T_N(val);
  107.         if (vm_data_map_write_buffer(map, &data, ea, sizeof(unsigned_N), 0)
  108.         != sizeof(unsigned_N))
  109.           alignment_interrupt(processor, cia, ea);
  110.     if (WITH_MON & MONITOR_LOAD_STORE_UNIT) {
  111.       /* YUCK */
  112.       unsigned ra = vm_real_data_addr(map, ea, 1, processor, cia);
  113.       mon_write(ea, ra, sizeof(unsigned_N), processor, cia);
  114.     }
  115.     TRACE(trace_load_store, ("store cia=0x%lx ea=0x%lx N=%ld val=0x%lx\n",
  116.                  (long)cia, (long)ea, (long)sizeof(unsigned_N), (long)val));
  117.       }
  118.       break;
  119.     default:
  120.       error("unknown alignment support\n");
  121.     }
  122.   }
  123. }
  124.  
  125. /* NOTE: see start of file for #define */
  126. #undef unsigned_N
  127. #undef T2H_N
  128. #undef H2T_N
  129. #undef vm_data_map_read_N
  130. #undef vm_data_map_write_N
  131.