1/* This file is part of the program psim. 2 3 Copyright (C) 1994-1996, 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 3 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, see <http://www.gnu.org/licenses/>. 17 18 */ 19 20 21#ifndef N 22#error "N must be #defined" 23#endif 24 25/* NOTE: see end of file for #undef of these macros */ 26#define unsigned_N XCONCAT2(unsigned_,N) 27#define T2H_N XCONCAT2(T2H_,N) 28#define H2T_N XCONCAT2(H2T_,N) 29 30#define core_map_read_N XCONCAT2(core_map_read_,N) 31#define core_map_write_N XCONCAT2(core_map_write_,N) 32 33INLINE_CORE(unsigned_N) 34core_map_read_N(core_map *map, 35 unsigned_word addr, 36 cpu *processor, 37 unsigned_word cia) 38{ 39 core_mapping *mapping = core_map_find_mapping(map, 40 addr, 41 sizeof(unsigned_N), 42 processor, 43 cia, 44 1); /*abort*/ 45 if (WITH_CALLBACK_MEMORY && mapping->device != NULL) { 46 unsigned_N data; 47 if (device_io_read_buffer(mapping->device, 48 &data, 49 mapping->space, 50 addr, 51 sizeof(unsigned_N), /* nr_bytes */ 52 processor, 53 cia) != sizeof(unsigned_N)) 54 device_error(mapping->device, "internal error - core_read_N() - io_read_buffer should not fail"); 55 return T2H_N(data); 56 } 57 else 58 return T2H_N(*(unsigned_N*)core_translate(mapping, addr)); 59} 60 61 62 63INLINE_CORE(void) 64core_map_write_N(core_map *map, 65 unsigned_word addr, 66 unsigned_N val, 67 cpu *processor, 68 unsigned_word cia) 69{ 70 core_mapping *mapping = core_map_find_mapping(map, 71 addr, 72 sizeof(unsigned_N), 73 processor, 74 cia, 75 1); /*abort*/ 76 if (WITH_CALLBACK_MEMORY && mapping->device != NULL) { 77 unsigned_N data = H2T_N(val); 78 if (device_io_write_buffer(mapping->device, 79 &data, 80 mapping->space, 81 addr, 82 sizeof(unsigned_N), /* nr_bytes */ 83 processor, 84 cia) != sizeof(unsigned_N)) 85 device_error(mapping->device, "internal error - core_write_N() - io_write_buffer should not fail"); 86 } 87 else 88 *(unsigned_N*)core_translate(mapping, addr) = H2T_N(val); 89} 90 91/* NOTE: see start of file for #define of these macros */ 92#undef unsigned_N 93#undef T2H_N 94#undef H2T_N 95#undef core_map_read_N 96#undef core_map_write_N 97