trunk/src/emu/memconv.h
| r18152 | r18153 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | memconv.h |
| 4 | | |
| 5 | | Functions which help convert between different handlers. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | **************************************************************************** |
| 11 | | |
| 12 | | ***** VERY IMPORTANT NOTICE ***** |
| 13 | | |
| 14 | | These functions and macros are provided to facilitate the mapping |
| 15 | | of devices on cpus with different data bus widths. |
| 16 | | Devices should be implemented using their native data bus width, |
| 17 | | since that ensures that read/write operations are kept atomic. |
| 18 | | If we discover you have abused the functionality presented in this |
| 19 | | file, you *will* be publicly humiliated and your code submission |
| 20 | | will probably not be accepted. Seriously, please do not abuse these |
| 21 | | functions/macros. |
| 22 | | |
| 23 | | **************************************************************************** |
| 24 | | |
| 25 | | Conversions supported: |
| 26 | | |
| 27 | | CW = CPU Data Bus Width in bits |
| 28 | | CBO = CPU Byte Order |
| 29 | | DW = Device Data Bus Width in bits |
| 30 | | DBO = Device Byte Order |
| 31 | | |
| 32 | | CW | CBO | DW | DBO | Functions to use |
| 33 | | ---+--------+----+--------+----------------------------------------------------------- |
| 34 | | 16 | Big | 8 | N/A | read16be_with_read8_handler,write16be_with_write8_handler |
| 35 | | 16 | Little | 8 | N/A | read16le_with_read8_handler,write16le_with_write8_handler |
| 36 | | ---+--------+----+--------+----------------------------------------------------------- |
| 37 | | 32 | Big | 8 | N/A | read32be_with_read8_handler,write32be_with_write8_handler |
| 38 | | 32 | Little | 8 | N/A | read32le_with_read8_handler,write32le_with_write8_handler |
| 39 | | 32 | Big | 16 | Big | read32be_with_16be_handler,write32be_with_16be_handler |
| 40 | | 32 | Little | 16 | Little | read32le_with_16le_handler,write32le_with_16le_handler |
| 41 | | 32 | Big | 16 | Little | read32be_with_16le_handler,write32be_with_16le_handler |
| 42 | | 32 | Little | 16 | Big | read32le_with_16be_handler,write32le_with_16be_handler |
| 43 | | ---+--------+----+--------+----------------------------------------------------------- |
| 44 | | 64 | Big | 8 | N/A | read64be_with_read8_handler,write64be_with_write8_handler |
| 45 | | 64 | Little | 8 | N/A | read64le_with_read8_handler,write64le_with_write8_handler |
| 46 | | 64 | Big | 16 | Big | read64be_with_16be_handler,write64be_with_16be_handler |
| 47 | | 64 | Little | 16 | Little | read64le_with_16le_handler,write64le_with_16le_handler |
| 48 | | 64 | Big | 16 | Little | read64be_with_16le_handler,write64be_with_16le_handler |
| 49 | | 64 | Little | 16 | Big | read64le_with_16be_handler,write64le_with_16be_handler |
| 50 | | 64 | Big | 32 | Big | read64be_with_32be_handler,write64be_with_32be_handler |
| 51 | | 64 | Little | 32 | Little | read64le_with_32le_handler,write64le_with_32le_handler |
| 52 | | 64 | Big | 32 | Little | read64be_with_32le_handler,write64be_with_32le_handler |
| 53 | | 64 | Little | 32 | Big | read64le_with_32be_handler,write64le_with_32be_handler |
| 54 | | |
| 55 | | You can also find at the bottom of this file a few convernient |
| 56 | | macros that will create the stub read and/or write handlers for |
| 57 | | the most common mappings, that will use the functions above. |
| 58 | | Here's an example on how to use them: Say you have a 8 bit device |
| 59 | | whose handlers are device8_r and device8_w, and you want to connect |
| 60 | | it to a 16 bit, big endian cpu. We'll say the device is mapped on |
| 61 | | the least significant byte of the data bus (LSB). |
| 62 | | |
| 63 | | In your driver, you would add: |
| 64 | | |
| 65 | | READWRITE8TO16BE_LSB( device16, device8_r, device8_w ) |
| 66 | | |
| 67 | | which will create two 16 bit memory handlers, one for read, called |
| 68 | | device16_r, and one for write, called device16_w, with the proper |
| 69 | | mapping. |
| 70 | | |
| 71 | | then in the MEMORY_MAP you would specify: |
| 72 | | |
| 73 | | AM_RANGE(0x000000, 0x0000ff) AM_READWRITE( device16_r, device16_w ) |
| 74 | | |
| 75 | | And that is all. Your device should be mapped properly. |
| 76 | | If you need to do custom mappings, or a mapping that is not currently |
| 77 | | supported in this file, you can always write the stub yourself, and |
| 78 | | call the above functions to invoke the base handlers. |
| 79 | | |
| 80 | | ***************************************************************************/ |
| 81 | | |
| 82 | | /************************************* |
| 83 | | * |
| 84 | | * 16-bit BE using 8-bit handlers |
| 85 | | * |
| 86 | | *************************************/ |
| 87 | | |
| 88 | | INLINE UINT16 read16be_with_read8_handler(read8_space_func handler, address_space &space, offs_t offset, UINT16 mem_mask) |
| 89 | | { |
| 90 | | UINT16 result = 0; |
| 91 | | if (ACCESSING_BITS_8_15) |
| 92 | | result |= ((UINT16)(*handler)(space, offset * 2 + 0, mem_mask >> 8)) << 8; |
| 93 | | if (ACCESSING_BITS_0_7) |
| 94 | | result |= ((UINT16)(*handler)(space, offset * 2 + 1, mem_mask >> 0)) << 0; |
| 95 | | return result; |
| 96 | | } |
| 97 | | |
| 98 | | |
| 99 | | INLINE void write16be_with_write8_handler(write8_space_func handler, address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask) |
| 100 | | { |
| 101 | | if (ACCESSING_BITS_8_15) |
| 102 | | (*handler)(space, offset * 2 + 0, data >> 8, mem_mask >> 8); |
| 103 | | if (ACCESSING_BITS_0_7) |
| 104 | | (*handler)(space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 105 | | } |
| 106 | | |
| 107 | | |
| 108 | | /************************************* |
| 109 | | * |
| 110 | | * 16-bit LE using 8-bit handlers |
| 111 | | * |
| 112 | | *************************************/ |
| 113 | | |
| 114 | | INLINE UINT16 read16le_with_read8_handler(read8_space_func handler, address_space &space, offs_t offset, UINT16 mem_mask) |
| 115 | | { |
| 116 | | UINT16 result = 0; |
| 117 | | if (ACCESSING_BITS_0_7) |
| 118 | | result |= ((UINT16) (*handler)(space, offset * 2 + 0, mem_mask >> 0)) << 0; |
| 119 | | if (ACCESSING_BITS_8_15) |
| 120 | | result |= ((UINT16) (*handler)(space, offset * 2 + 1, mem_mask >> 8)) << 8; |
| 121 | | return result; |
| 122 | | } |
| 123 | | |
| 124 | | |
| 125 | | INLINE void write16le_with_write8_handler(write8_space_func handler, address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask) |
| 126 | | { |
| 127 | | if (ACCESSING_BITS_0_7) |
| 128 | | (*handler)(space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 129 | | if (ACCESSING_BITS_8_15) |
| 130 | | (*handler)(space, offset * 2 + 1, data >> 8, mem_mask >> 8); |
| 131 | | } |
| 132 | | |
| 133 | | |
| 134 | | /************************************* |
| 135 | | * |
| 136 | | * 32-bit BE using 8-bit handlers |
| 137 | | * |
| 138 | | *************************************/ |
| 139 | | |
| 140 | | INLINE UINT32 read32be_with_read8_handler(read8_space_func handler, address_space &space, offs_t offset, UINT32 mem_mask) |
| 141 | | { |
| 142 | | UINT32 result = 0; |
| 143 | | if (ACCESSING_BITS_16_31) |
| 144 | | result |= read16be_with_read8_handler(handler, space, offset * 2 + 0, mem_mask >> 16) << 16; |
| 145 | | if (ACCESSING_BITS_0_15) |
| 146 | | result |= read16be_with_read8_handler(handler, space, offset * 2 + 1, mem_mask) << 0; |
| 147 | | return result; |
| 148 | | } |
| 149 | | |
| 150 | | |
| 151 | | INLINE void write32be_with_write8_handler(write8_space_func handler, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 152 | | { |
| 153 | | if (ACCESSING_BITS_16_31) |
| 154 | | write16be_with_write8_handler(handler, space, offset * 2 + 0, data >> 16, mem_mask >> 16); |
| 155 | | if (ACCESSING_BITS_0_15) |
| 156 | | write16be_with_write8_handler(handler, space, offset * 2 + 1, data, mem_mask); |
| 157 | | } |
| 158 | | |
| 159 | | |
| 160 | | /************************************* |
| 161 | | * |
| 162 | | * 32-bit LE using 8-bit handlers |
| 163 | | * |
| 164 | | *************************************/ |
| 165 | | |
| 166 | | INLINE UINT32 read32le_with_read8_handler(read8_space_func handler, address_space &space, offs_t offset, UINT32 mem_mask) |
| 167 | | { |
| 168 | | UINT32 result = 0; |
| 169 | | if (ACCESSING_BITS_0_15) |
| 170 | | result |= read16le_with_read8_handler(handler, space, offset * 2 + 0, mem_mask) << 0; |
| 171 | | if (ACCESSING_BITS_16_31) |
| 172 | | result |= read16le_with_read8_handler(handler, space, offset * 2 + 1, mem_mask >> 16) << 16; |
| 173 | | return result; |
| 174 | | } |
| 175 | | |
| 176 | | |
| 177 | | INLINE void write32le_with_write8_handler(write8_space_func handler, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 178 | | { |
| 179 | | if (ACCESSING_BITS_0_15) |
| 180 | | write16le_with_write8_handler(handler, space, offset * 2 + 0, data, mem_mask); |
| 181 | | if (ACCESSING_BITS_16_31) |
| 182 | | write16le_with_write8_handler(handler, space, offset * 2 + 1, data >> 16, mem_mask >> 16); |
| 183 | | } |
| 184 | | |
| 185 | | |
| 186 | | /************************************* |
| 187 | | * |
| 188 | | * 32-bit BE using 16-bit BE handlers |
| 189 | | * |
| 190 | | *************************************/ |
| 191 | | |
| 192 | | INLINE UINT32 read32be_with_16be_handler(read16_space_func handler, address_space &space, offs_t offset, UINT32 mem_mask) |
| 193 | | { |
| 194 | | UINT32 result = 0; |
| 195 | | if (ACCESSING_BITS_16_31) |
| 196 | | result |= (*handler)(space, offset * 2 + 0, mem_mask >> 16) << 16; |
| 197 | | if (ACCESSING_BITS_0_15) |
| 198 | | result |= (*handler)(space, offset * 2 + 1, mem_mask) << 0; |
| 199 | | return result; |
| 200 | | } |
| 201 | | |
| 202 | | |
| 203 | | INLINE void write32be_with_16be_handler(write16_space_func handler, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 204 | | { |
| 205 | | if (ACCESSING_BITS_16_31) |
| 206 | | (*handler)(space, offset * 2 + 0, data >> 16, mem_mask >> 16); |
| 207 | | if (ACCESSING_BITS_0_15) |
| 208 | | (*handler)(space, offset * 2 + 1, data, mem_mask); |
| 209 | | } |
| 210 | | |
| 211 | | |
| 212 | | /************************************* |
| 213 | | * |
| 214 | | * 32-bit LE using 16-bit LE handlers |
| 215 | | * |
| 216 | | *************************************/ |
| 217 | | |
| 218 | | INLINE UINT32 read32le_with_16le_handler(read16_space_func handler, address_space &space, offs_t offset, UINT32 mem_mask) |
| 219 | | { |
| 220 | | UINT32 result = 0; |
| 221 | | if (ACCESSING_BITS_0_15) |
| 222 | | result |= (*handler)(space, offset * 2 + 0, mem_mask) << 0; |
| 223 | | if (ACCESSING_BITS_16_31) |
| 224 | | result |= (*handler)(space, offset * 2 + 1, mem_mask >> 16) << 16; |
| 225 | | return result; |
| 226 | | } |
| 227 | | |
| 228 | | |
| 229 | | INLINE void write32le_with_16le_handler(write16_space_func handler, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 230 | | { |
| 231 | | if (ACCESSING_BITS_0_15) |
| 232 | | (*handler)(space, offset * 2 + 0, data, mem_mask); |
| 233 | | if (ACCESSING_BITS_16_31) |
| 234 | | (*handler)(space, offset * 2 + 1, data >> 16, mem_mask >> 16); |
| 235 | | } |
| 236 | | |
| 237 | | |
| 238 | | /************************************* |
| 239 | | * |
| 240 | | * 32-bit BE using 16-bit LE handlers |
| 241 | | * |
| 242 | | *************************************/ |
| 243 | | |
| 244 | | INLINE UINT32 read32be_with_16le_handler(read16_space_func handler, address_space &space, offs_t offset, UINT32 mem_mask) |
| 245 | | { |
| 246 | | UINT32 result = 0; |
| 247 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 248 | | result = read32le_with_16le_handler(handler, space, offset, mem_mask); |
| 249 | | return FLIPENDIAN_INT32(result); |
| 250 | | } |
| 251 | | |
| 252 | | |
| 253 | | INLINE void write32be_with_16le_handler(write16_space_func handler, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 254 | | { |
| 255 | | data = FLIPENDIAN_INT32(data); |
| 256 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 257 | | write32le_with_16le_handler(handler, space, offset, data, mem_mask); |
| 258 | | } |
| 259 | | |
| 260 | | |
| 261 | | /************************************* |
| 262 | | * |
| 263 | | * 32-bit LE using 16-bit BE handlers |
| 264 | | * |
| 265 | | *************************************/ |
| 266 | | |
| 267 | | INLINE UINT32 read32le_with_16be_handler(read16_space_func handler, address_space &space, offs_t offset, UINT32 mem_mask) |
| 268 | | { |
| 269 | | UINT32 result = 0; |
| 270 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 271 | | result = read32be_with_16be_handler(handler, space, offset, mem_mask); |
| 272 | | return FLIPENDIAN_INT32(result); |
| 273 | | } |
| 274 | | |
| 275 | | |
| 276 | | INLINE void write32le_with_16be_handler(write16_space_func handler, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 277 | | { |
| 278 | | data = FLIPENDIAN_INT32(data); |
| 279 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 280 | | write32be_with_16be_handler(handler, space, offset, data, mem_mask); |
| 281 | | } |
| 282 | | |
| 283 | | |
| 284 | | /************************************* |
| 285 | | * |
| 286 | | * 64-bit BE using 8-bit handlers |
| 287 | | * |
| 288 | | *************************************/ |
| 289 | | |
| 290 | | INLINE UINT64 read64be_with_read8_handler(read8_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 291 | | { |
| 292 | | UINT64 result = 0; |
| 293 | | if (ACCESSING_BITS_32_63) |
| 294 | | result |= (UINT64)read32be_with_read8_handler(handler, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 295 | | if (ACCESSING_BITS_0_31) |
| 296 | | result |= (UINT64)read32be_with_read8_handler(handler, space, offset * 2 + 1, mem_mask) << 0; |
| 297 | | return result; |
| 298 | | } |
| 299 | | |
| 300 | | |
| 301 | | INLINE void write64be_with_write8_handler(write8_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 302 | | { |
| 303 | | if (ACCESSING_BITS_32_63) |
| 304 | | write32be_with_write8_handler(handler, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 305 | | if (ACCESSING_BITS_0_31) |
| 306 | | write32be_with_write8_handler(handler, space, offset * 2 + 1, data, mem_mask); |
| 307 | | } |
| 308 | | |
| 309 | | |
| 310 | | /************************************* |
| 311 | | * |
| 312 | | * 64-bit LE using 8-bit handlers |
| 313 | | * |
| 314 | | *************************************/ |
| 315 | | |
| 316 | | INLINE UINT64 read64le_with_read8_handler(read8_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 317 | | { |
| 318 | | UINT64 result = 0; |
| 319 | | if (ACCESSING_BITS_0_31) |
| 320 | | result |= (UINT64)read32le_with_read8_handler(handler, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 321 | | if (ACCESSING_BITS_32_63) |
| 322 | | result |= (UINT64)read32le_with_read8_handler(handler, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 323 | | return result; |
| 324 | | } |
| 325 | | |
| 326 | | |
| 327 | | INLINE void write64le_with_write8_handler(write8_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 328 | | { |
| 329 | | if (ACCESSING_BITS_0_31) |
| 330 | | write32le_with_write8_handler(handler, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 331 | | if (ACCESSING_BITS_32_63) |
| 332 | | write32le_with_write8_handler(handler, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 333 | | } |
| 334 | | |
| 335 | | |
| 336 | | /************************************* |
| 337 | | * |
| 338 | | * 64-bit BE using 16-bit BE handlers |
| 339 | | * |
| 340 | | *************************************/ |
| 341 | | |
| 342 | | INLINE UINT32 read64be_with_16be_handler(read16_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 343 | | { |
| 344 | | UINT64 result = 0; |
| 345 | | if (ACCESSING_BITS_32_63) |
| 346 | | result |= (UINT64)read32be_with_16be_handler(handler, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 347 | | if (ACCESSING_BITS_0_31) |
| 348 | | result |= (UINT64)read32be_with_16be_handler(handler, space, offset * 2 + 1, mem_mask >> 0) << 0; |
| 349 | | return result; |
| 350 | | } |
| 351 | | |
| 352 | | |
| 353 | | INLINE void write64be_with_16be_handler(write16_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 354 | | { |
| 355 | | if (ACCESSING_BITS_32_63) |
| 356 | | write32be_with_16be_handler(handler, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 357 | | if (ACCESSING_BITS_0_31) |
| 358 | | write32be_with_16be_handler(handler, space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 359 | | } |
| 360 | | |
| 361 | | |
| 362 | | /************************************* |
| 363 | | * |
| 364 | | * 64-bit LE using 16-bit LE handlers |
| 365 | | * |
| 366 | | *************************************/ |
| 367 | | |
| 368 | | INLINE UINT32 read64le_with_16le_handler(read16_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 369 | | { |
| 370 | | UINT64 result = 0; |
| 371 | | if (ACCESSING_BITS_0_31) |
| 372 | | result |= (UINT64)read32le_with_16le_handler(handler, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 373 | | if (ACCESSING_BITS_32_63) |
| 374 | | result |= (UINT64)read32le_with_16le_handler(handler, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 375 | | return result; |
| 376 | | } |
| 377 | | |
| 378 | | |
| 379 | | INLINE void write64le_with_16le_handler(write16_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 380 | | { |
| 381 | | if (ACCESSING_BITS_0_31) |
| 382 | | write32le_with_16le_handler(handler, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 383 | | if (ACCESSING_BITS_32_63) |
| 384 | | write32le_with_16le_handler(handler, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 385 | | } |
| 386 | | |
| 387 | | |
| 388 | | /************************************* |
| 389 | | * |
| 390 | | * 64-bit BE using 16-bit LE handlers |
| 391 | | * |
| 392 | | *************************************/ |
| 393 | | |
| 394 | | INLINE UINT32 read64be_with_16le_handler(read16_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 395 | | { |
| 396 | | UINT64 result = 0; |
| 397 | | if (ACCESSING_BITS_32_63) |
| 398 | | result |= (UINT64)read32be_with_16le_handler(handler, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 399 | | if (ACCESSING_BITS_0_31) |
| 400 | | result |= (UINT64)read32be_with_16le_handler(handler, space, offset * 2 + 1, mem_mask >> 0) << 0; |
| 401 | | return result; |
| 402 | | } |
| 403 | | |
| 404 | | |
| 405 | | INLINE void write64be_with_16le_handler(write16_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 406 | | { |
| 407 | | if (ACCESSING_BITS_32_63) |
| 408 | | write32be_with_16le_handler(handler, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 409 | | if (ACCESSING_BITS_0_31) |
| 410 | | write32be_with_16le_handler(handler, space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 411 | | } |
| 412 | | |
| 413 | | |
| 414 | | /************************************* |
| 415 | | * |
| 416 | | * 64-bit LE using 16-bit BE handlers |
| 417 | | * |
| 418 | | *************************************/ |
| 419 | | |
| 420 | | INLINE UINT32 read64le_with_16be_handler(read16_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 421 | | { |
| 422 | | UINT64 result = 0; |
| 423 | | if (ACCESSING_BITS_0_31) |
| 424 | | result |= (UINT64)read32le_with_16be_handler(handler, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 425 | | if (ACCESSING_BITS_32_63) |
| 426 | | result |= (UINT64)read32le_with_16be_handler(handler, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 427 | | return result; |
| 428 | | } |
| 429 | | |
| 430 | | |
| 431 | | INLINE void write64le_with_16be_handler(write16_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 432 | | { |
| 433 | | if (ACCESSING_BITS_0_31) |
| 434 | | write32le_with_16be_handler(handler, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 435 | | if (ACCESSING_BITS_32_63) |
| 436 | | write32le_with_16be_handler(handler, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 437 | | } |
| 438 | | |
| 439 | | |
| 440 | | /************************************* |
| 441 | | * |
| 442 | | * 64-bit BE using 32-bit BE handlers |
| 443 | | * |
| 444 | | *************************************/ |
| 445 | | |
| 446 | | INLINE UINT64 read64be_with_32be_handler(read32_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 447 | | { |
| 448 | | UINT64 result = 0; |
| 449 | | if (ACCESSING_BITS_32_63) |
| 450 | | result |= (UINT64)(*handler)(space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 451 | | if (ACCESSING_BITS_0_31) |
| 452 | | result |= (UINT64)(*handler)(space, offset * 2 + 1, mem_mask >> 0) << 0; |
| 453 | | return result; |
| 454 | | } |
| 455 | | |
| 456 | | |
| 457 | | INLINE void write64be_with_32be_handler(write32_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 458 | | { |
| 459 | | if (ACCESSING_BITS_32_63) |
| 460 | | (*handler)(space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 461 | | if (ACCESSING_BITS_0_31) |
| 462 | | (*handler)(space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 463 | | } |
| 464 | | |
| 465 | | |
| 466 | | /************************************* |
| 467 | | * |
| 468 | | * 64-bit LE using 32-bit LE handlers |
| 469 | | * |
| 470 | | *************************************/ |
| 471 | | |
| 472 | | INLINE UINT64 read64le_with_32le_handler(read32_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 473 | | { |
| 474 | | UINT64 result = 0; |
| 475 | | if (ACCESSING_BITS_0_31) |
| 476 | | result |= (UINT64)(*handler)(space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 477 | | if (ACCESSING_BITS_32_63) |
| 478 | | result |= (UINT64)(*handler)(space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 479 | | return result; |
| 480 | | } |
| 481 | | |
| 482 | | |
| 483 | | INLINE void write64le_with_32le_handler(write32_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 484 | | { |
| 485 | | if (ACCESSING_BITS_0_31) |
| 486 | | (*handler)(space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 487 | | if (ACCESSING_BITS_32_63) |
| 488 | | (*handler)(space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 489 | | } |
| 490 | | |
| 491 | | |
| 492 | | /************************************* |
| 493 | | * |
| 494 | | * 64-bit BE using 32-bit LE handlers |
| 495 | | * |
| 496 | | *************************************/ |
| 497 | | |
| 498 | | INLINE UINT64 read64be_with_32le_handler(read32_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 499 | | { |
| 500 | | UINT64 result; |
| 501 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 502 | | result = read64le_with_32le_handler(handler, space, offset, mem_mask); |
| 503 | | return FLIPENDIAN_INT64(result); |
| 504 | | } |
| 505 | | |
| 506 | | |
| 507 | | INLINE void write64be_with_32le_handler(write32_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 508 | | { |
| 509 | | data = FLIPENDIAN_INT64(data); |
| 510 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 511 | | write64le_with_32le_handler(handler, space, offset, data, mem_mask); |
| 512 | | } |
| 513 | | |
| 514 | | |
| 515 | | /************************************* |
| 516 | | * |
| 517 | | * 64-bit LE using 32-bit BE handlers |
| 518 | | * |
| 519 | | *************************************/ |
| 520 | | |
| 521 | | INLINE UINT64 read64le_with_32be_handler(read32_space_func handler, address_space &space, offs_t offset, UINT64 mem_mask) |
| 522 | | { |
| 523 | | UINT64 result; |
| 524 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 525 | | result = read64be_with_32be_handler(handler, space, offset, mem_mask); |
| 526 | | return FLIPENDIAN_INT64(result); |
| 527 | | } |
| 528 | | |
| 529 | | |
| 530 | | INLINE void write64le_with_32be_handler(write32_space_func handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 531 | | { |
| 532 | | data = FLIPENDIAN_INT64(data); |
| 533 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 534 | | write64be_with_32be_handler(handler, space, offset, data, mem_mask); |
| 535 | | } |
| 536 | | |
| 537 | | |
| 538 | | |
| 539 | | /************************************************************************** |
| 540 | | |
| 541 | | Utility macros |
| 542 | | |
| 543 | | **************************************************************************/ |
| 544 | | |
| 545 | | #define READ_TEMPLATE(bits, name, handler, func) \ |
| 546 | | READ##bits##_HANDLER( name##_r ) \ |
| 547 | | { \ |
| 548 | | return func(handler, space, offset, mem_mask); \ |
| 549 | | } |
| 550 | | |
| 551 | | #define READ_TEMPLATE_COND(bits, name, handler, func, cond) \ |
| 552 | | READ##bits##_HANDLER( name##_r ) \ |
| 553 | | { \ |
| 554 | | if (cond) \ |
| 555 | | return func(handler, space, offset, mem_mask); \ |
| 556 | | return 0; \ |
| 557 | | } |
| 558 | | |
| 559 | | #define WRITE_TEMPLATE(bits, name, handler, func) \ |
| 560 | | WRITE##bits##_HANDLER( name##_w ) \ |
| 561 | | { \ |
| 562 | | func(handler, space, offset, data, mem_mask); \ |
| 563 | | } |
| 564 | | |
| 565 | | #define WRITE_TEMPLATE_COND(bits, name, handler, func, cond) \ |
| 566 | | WRITE##bits##_HANDLER( name##_w ) \ |
| 567 | | { \ |
| 568 | | if (cond) \ |
| 569 | | func(handler, space, offset, data, mem_mask); \ |
| 570 | | } |
| 571 | | |
| 572 | | |
| 573 | | |
| 574 | | /************************************************************************** |
| 575 | | |
| 576 | | Generic conversions macros |
| 577 | | |
| 578 | | **************************************************************************/ |
| 579 | | |
| 580 | | |
| 581 | | /************************************* |
| 582 | | * 8->16be, 1:1 mapping |
| 583 | | ************************************/ |
| 584 | | |
| 585 | | #define READ8TO16BE( name, read8 ) \ |
| 586 | | READ_TEMPLATE( 16, name, read8, read16be_with_read8_handler ) |
| 587 | | |
| 588 | | |
| 589 | | #define WRITE8TO16BE( name, write8 ) \ |
| 590 | | WRITE_TEMPLATE( 16, name, write8, write16be_with_write8_handler ) |
| 591 | | |
| 592 | | |
| 593 | | #define READWRITE8TO16BE( name, read8, write8 ) \ |
| 594 | | READ8TO16BE(name,read8) \ |
| 595 | | WRITE8TO16BE(name,write8) |
| 596 | | |
| 597 | | |
| 598 | | /************************************* |
| 599 | | * 8->16le, 1:1 mapping |
| 600 | | ************************************/ |
| 601 | | |
| 602 | | #define READ8TO16LE( name, read8 ) \ |
| 603 | | READ_TEMPLATE( 16, name, read8, read16le_with_read8_handler ) |
| 604 | | |
| 605 | | |
| 606 | | #define WRITE8TO16LE( name, write8 ) \ |
| 607 | | WRITE_TEMPLATE( 16, name, write8, write16le_with_write8_handler ) |
| 608 | | |
| 609 | | |
| 610 | | #define READWRITE8TO16LE( name, read8, write8 ) \ |
| 611 | | READ8TO16LE(name,read8) \ |
| 612 | | WRITE8TO16LE(name,write8) |
| 613 | | |
| 614 | | |
| 615 | | /************************************* |
| 616 | | * 8->16be, MSB mapping |
| 617 | | ************************************/ |
| 618 | | |
| 619 | | #define READ8TO16BE_MSB( name, read8 ) \ |
| 620 | | READ_TEMPLATE_COND( 16, name, read8, read16be_with_read8_handler, ACCESSING_BITS_8_15 ) |
| 621 | | |
| 622 | | |
| 623 | | #define WRITE8TO16BE_MSB( name, write8 ) \ |
| 624 | | WRITE_TEMPLATE_COND( 16, name, write8, write16be_with_write8_handler, ACCESSING_BITS_8_15 ) |
| 625 | | |
| 626 | | |
| 627 | | #define READWRITE8TO16BE_MSB( name, read8, write8 ) \ |
| 628 | | READ8TO16BE_MSB(name,read8) \ |
| 629 | | WRITE8TO16BE_MSB(name,write8) |
| 630 | | |
| 631 | | |
| 632 | | /************************************* |
| 633 | | * 8->16le, MSB mapping |
| 634 | | ************************************/ |
| 635 | | |
| 636 | | #define READ8TO16LE_MSB( name, read8 ) \ |
| 637 | | READ_TEMPLATE_COND( 16, name, read8, read16le_with_read8_handler, ACCESSING_BITS_8_15 ) |
| 638 | | |
| 639 | | |
| 640 | | #define WRITE8TO16LE_MSB( name, write8 ) \ |
| 641 | | WRITE_TEMPLATE_COND( 16, name, write8, write16le_with_write8_handler, ACCESSING_BITS_8_15 ) |
| 642 | | |
| 643 | | |
| 644 | | #define READWRITE8TO16LE_MSB( name, read8, write8 ) \ |
| 645 | | READ8TO16LE_MSB(name,read8) \ |
| 646 | | WRITE8TO16LE_MSB(name,write8) |
| 647 | | |
| 648 | | |
| 649 | | /************************************* |
| 650 | | * 8->16be, LSB mapping |
| 651 | | ************************************/ |
| 652 | | |
| 653 | | #define READ8TO16BE_LSB( name, read8 ) \ |
| 654 | | READ_TEMPLATE_COND( 16, name, read8, read16be_with_read8_handler, ACCESSING_BITS_0_7 ) |
| 655 | | |
| 656 | | |
| 657 | | #define WRITE8TO16BE_LSB( name, write8 ) \ |
| 658 | | WRITE_TEMPLATE_COND( 16, name, write8, write16be_with_write8_handler, ACCESSING_BITS_0_7 ) |
| 659 | | |
| 660 | | |
| 661 | | #define READWRITE8TO16BE_LSB( name, read8, write8 ) \ |
| 662 | | READ8TO16BE_LSB(name,read8) \ |
| 663 | | WRITE8TO16BE_LSB(name,write8) |
| 664 | | |
| 665 | | |
| 666 | | /************************************* |
| 667 | | * 8->16le, LSB mapping |
| 668 | | ************************************/ |
| 669 | | |
| 670 | | #define READ8TO16LE_LSB( name, read8 ) \ |
| 671 | | READ_TEMPLATE_COND( 16, name, read8, read16le_with_read8_handler, ACCESSING_BITS_0_7 ) |
| 672 | | |
| 673 | | |
| 674 | | #define WRITE8TO16LE_LSB( name, write8 ) \ |
| 675 | | WRITE_TEMPLATE_COND( 16, name, write8, write16le_with_write8_handler, ACCESSING_BITS_0_7 ) |
| 676 | | |
| 677 | | |
| 678 | | #define READWRITE8TO16LE_LSB( name, read8, write8 ) \ |
| 679 | | READ8TO16LE_LSB(name,read8) \ |
| 680 | | WRITE8TO16LE_LSB(name,write8) |
| 681 | | |
| 682 | | |
| 683 | | /************************************* |
| 684 | | * 8->32be, 1:1 mapping |
| 685 | | ************************************/ |
| 686 | | |
| 687 | | #define READ8TO32BE( name, read8 ) \ |
| 688 | | READ_TEMPLATE( 32, name, read8, read32be_with_read8_handler ) |
| 689 | | |
| 690 | | |
| 691 | | #define WRITE8TO32BE( name, write8 ) \ |
| 692 | | WRITE_TEMPLATE( 32, name, write8, write32be_with_write8_handler ) |
| 693 | | |
| 694 | | |
| 695 | | #define READWRITE8TO32BE( name, read8, write8 ) \ |
| 696 | | READ8TO32BE(name,read8) \ |
| 697 | | WRITE8TO32BE(name,write8) |
| 698 | | |
| 699 | | |
| 700 | | /************************************* |
| 701 | | * 8->32le, 1:1 mapping |
| 702 | | ************************************/ |
| 703 | | |
| 704 | | #define READ8TO32LE( name, read8 ) \ |
| 705 | | READ_TEMPLATE( 32, name, read8, read32le_with_read8_handler ) |
| 706 | | |
| 707 | | |
| 708 | | #define WRITE8TO32LE( name, write8 ) \ |
| 709 | | WRITE_TEMPLATE( 32, name, write8, write32le_with_write8_handler ) |
| 710 | | |
| 711 | | |
| 712 | | #define READWRITE8TO32LE( name, read8, write8 ) \ |
| 713 | | READ8TO32LE(name,read8) \ |
| 714 | | WRITE8TO32LE(name,write8) |
| 715 | | |
| 716 | | |
| 717 | | /************************************* |
| 718 | | * 8->32be, MSB mapping |
| 719 | | ************************************/ |
| 720 | | |
| 721 | | #define READ8TO32BE_MSB( name, read8 ) \ |
| 722 | | READ_TEMPLATE_COND( 32, name, read8, read32be_with_read8_handler, ACCESSING_BITS_24_31 ) |
| 723 | | |
| 724 | | |
| 725 | | #define WRITE8TO32BE_MSB( name, write8 ) \ |
| 726 | | WRITE_TEMPLATE_COND( 32, name, write8, write32be_with_write8_handler, ACCESSING_BITS_24_31 ) |
| 727 | | |
| 728 | | |
| 729 | | #define READWRITE8TO32BE_MSB( name, read8, write8 ) \ |
| 730 | | READ8TO32BE_MSB(name,read8) \ |
| 731 | | WRITE8TO32BE_MSB(name,write8) |
| 732 | | |
| 733 | | |
| 734 | | /************************************* |
| 735 | | * 8->32le, MSB mapping |
| 736 | | ************************************/ |
| 737 | | |
| 738 | | #define READ8TO32LE_MSB( name, read8 ) \ |
| 739 | | READ_TEMPLATE_COND( 32, name, read8, read32le_with_read8_handler, ACCESSING_BITS_24_31 ) |
| 740 | | |
| 741 | | |
| 742 | | #define WRITE8TO32LE_MSB( name, write8 ) \ |
| 743 | | WRITE_TEMPLATE_COND( 32, name, write8, write32le_with_write8_handler, ACCESSING_BITS_24_31 ) |
| 744 | | |
| 745 | | |
| 746 | | #define READWRITE8TO32LE_MSB( name, read8, write8 ) \ |
| 747 | | READ8TO32LE_MSB(name,read8) \ |
| 748 | | WRITE8TO32LE_MSB(name,write8) |
| 749 | | |
| 750 | | |
| 751 | | /************************************* |
| 752 | | * 8->32be, LSB mapping |
| 753 | | ************************************/ |
| 754 | | |
| 755 | | #define READ8TO32BE_LSB( name, read8 ) \ |
| 756 | | READ_TEMPLATE_COND( 32, name, read8, read32be_with_read8_handler, ACCESSING_BITS_0_7 ) |
| 757 | | |
| 758 | | |
| 759 | | #define WRITE8TO32BE_LSB( name, write8 ) \ |
| 760 | | WRITE_TEMPLATE_COND( 32, name, write8, write32be_with_write8_handler, ACCESSING_BITS_0_7 ) |
| 761 | | |
| 762 | | |
| 763 | | #define READWRITE8TO32BE_LSB( name, read8, write8 ) \ |
| 764 | | READ8TO32BE_LSB(name,read8) \ |
| 765 | | WRITE8TO32BE_LSB(name,write8) |
| 766 | | |
| 767 | | |
| 768 | | /************************************* |
| 769 | | * 8->32le, LSB mapping |
| 770 | | ************************************/ |
| 771 | | |
| 772 | | #define READ8TO32LE_LSB( name, read8 ) \ |
| 773 | | READ_TEMPLATE_COND( 32, name, read8, read32le_with_read8_handler, ACCESSING_BITS_0_7 ) |
| 774 | | |
| 775 | | |
| 776 | | #define WRITE8TO32LE_LSB( name, write8 ) \ |
| 777 | | WRITE_TEMPLATE_COND( 32, name, write8, write32le_with_write8_handler, ACCESSING_BITS_0_7 ) |
| 778 | | |
| 779 | | |
| 780 | | #define READWRITE8TO32LE_LSB( name, read8, write8 ) \ |
| 781 | | READ8TO32LE_LSB(name,read8) \ |
| 782 | | WRITE8TO32LE_LSB(name,write8) |
| 783 | | |
| 784 | | |
| 785 | | /************************************* |
| 786 | | * 8->64be, 1:1 mapping |
| 787 | | ************************************/ |
| 788 | | |
| 789 | | #define READ8TO64BE( name, read8 ) \ |
| 790 | | READ_TEMPLATE( 64, name, read8, read64be_with_read8_handler ) |
| 791 | | |
| 792 | | |
| 793 | | #define WRITE8TO64BE( name, write8 ) \ |
| 794 | | WRITE_TEMPLATE( 64, name, write8, write64be_with_write8_handler ) |
| 795 | | |
| 796 | | |
| 797 | | #define READWRITE8TO64BE( name, read8, write8 ) \ |
| 798 | | READ8TO64BE(name,read8) \ |
| 799 | | WRITE8TO64BE(name,write8) |
| 800 | | |
| 801 | | |
| 802 | | /************************************* |
| 803 | | * 8->64le, 1:1 mapping |
| 804 | | ************************************/ |
| 805 | | |
| 806 | | #define READ8TO64LE( name, read8 ) \ |
| 807 | | READ_TEMPLATE( 64, name, read8, read64le_with_read8_handler ) |
| 808 | | |
| 809 | | |
| 810 | | #define WRITE8TO64LE( name, write8 ) \ |
| 811 | | WRITE_TEMPLATE( 64, name, write8, write64le_with_write8_handler ) |
| 812 | | |
| 813 | | |
| 814 | | #define READWRITE8TO64LE( name, read8, write8 ) \ |
| 815 | | READ8TO64LE(name,read8) \ |
| 816 | | WRITE8TO64LE(name,write8) |
| 817 | | |
| 818 | | |
| 819 | | /************************************* |
| 820 | | * 16be->32be, 1:1 mapping |
| 821 | | *************************************/ |
| 822 | | |
| 823 | | #define READ16BETO32BE( name, read16 ) \ |
| 824 | | READ_TEMPLATE( 32, name, read16, read32be_with_16be_handler ) |
| 825 | | |
| 826 | | |
| 827 | | #define WRITE16BETO32BE( name, write16 ) \ |
| 828 | | WRITE_TEMPLATE( 32, name, write16, write32be_with_16be_handler ) |
| 829 | | |
| 830 | | |
| 831 | | #define READWRITE16BETO32BE( name, read16, write16 ) \ |
| 832 | | READ16BETO32BE(name,read16) \ |
| 833 | | WRITE16BETO32BE(name,write16) |
| 834 | | |
| 835 | | |
| 836 | | /************************************* |
| 837 | | * 16le->32be, 1:1 mapping |
| 838 | | *************************************/ |
| 839 | | |
| 840 | | #define READ16LETO32BE( name, read16 ) \ |
| 841 | | READ_TEMPLATE( 32, name, read16, read32be_with_16le_handler ) |
| 842 | | |
| 843 | | |
| 844 | | #define WRITE16LETO32BE( name, write16 ) \ |
| 845 | | WRITE_TEMPLATE( 32, name, write16, write32be_with_16le_handler ) |
| 846 | | |
| 847 | | |
| 848 | | #define READWRITE16LETO32BE( name, read16, write16 ) \ |
| 849 | | READ16LETO32BE(name,read16) \ |
| 850 | | WRITE16LETO32BE(name,write16) |
| 851 | | |
| 852 | | |
| 853 | | /************************************* |
| 854 | | * 16be->32le, 1:1 mapping |
| 855 | | *************************************/ |
| 856 | | |
| 857 | | #define READ16BETO32LE( name, read16 ) \ |
| 858 | | READ_TEMPLATE( 32, name, read16, read32le_with_16be_handler ) |
| 859 | | |
| 860 | | |
| 861 | | #define WRITE16BETO32LE( name, write16 ) \ |
| 862 | | WRITE_TEMPLATE( 32, name, write16, write32le_with_16be_handler ) |
| 863 | | |
| 864 | | |
| 865 | | #define READWRITE16BETO32LE( name, read16, write16 ) \ |
| 866 | | READ16BETO32LE(name,read16) \ |
| 867 | | WRITE16BETO32LE(name,write16) |
| 868 | | |
| 869 | | |
| 870 | | /************************************* |
| 871 | | * 16le->32le, 1:1 mapping |
| 872 | | *************************************/ |
| 873 | | |
| 874 | | #define READ16LETO32LE( name, read16 ) \ |
| 875 | | READ_TEMPLATE( 32, name, read16, read32le_with_16le_handler ) |
| 876 | | |
| 877 | | |
| 878 | | #define WRITE16LETO32LE( name, write16 ) \ |
| 879 | | WRITE_TEMPLATE( 32, name, write16, write32le_with_16le_handler ) |
| 880 | | |
| 881 | | |
| 882 | | #define READWRITE16LETO32LE( name, read16, write16 ) \ |
| 883 | | READ16LETO32LE(name,read16) \ |
| 884 | | WRITE16LETO32LE(name,write16) |
| 885 | | |
| 886 | | |
| 887 | | /************************************* |
| 888 | | * 16be->32be, MSW mapping |
| 889 | | *************************************/ |
| 890 | | |
| 891 | | #define READ16BETO32BE_MSW( name, read16 ) \ |
| 892 | | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16be_handler, ACCESSING_BITS_16_31 ) |
| 893 | | |
| 894 | | |
| 895 | | #define WRITE16BETO32BE_MSW( name, write16 ) \ |
| 896 | | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16be_handler, ACCESSING_BITS_16_31 ) |
| 897 | | |
| 898 | | |
| 899 | | #define READWRITE16BETO32BE_MSW( name, read16, write16 ) \ |
| 900 | | READ16BETO32BE_MSW(name,read16) \ |
| 901 | | WRITE16BETO32BE_MSW(name,write16) |
| 902 | | |
| 903 | | |
| 904 | | /************************************* |
| 905 | | * 16le->32be, MSW mapping |
| 906 | | *************************************/ |
| 907 | | |
| 908 | | #define READ16LETO32BE_MSW( name, read16 ) \ |
| 909 | | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16le_handler, ACCESSING_BITS_16_31 ) |
| 910 | | |
| 911 | | |
| 912 | | #define WRITE16LETO32BE_MSW( name, write16 ) \ |
| 913 | | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16le_handler, ACCESSING_BITS_16_31 ) |
| 914 | | |
| 915 | | |
| 916 | | #define READWRITE16LETO32BE_MSW( name, read16, write16 ) \ |
| 917 | | READ16LETO32BE_MSW(name,read16) \ |
| 918 | | WRITE16LETO32BE_MSW(name,write16) |
| 919 | | |
| 920 | | |
| 921 | | /************************************* |
| 922 | | * 16be->32le, MSW mapping |
| 923 | | *************************************/ |
| 924 | | |
| 925 | | #define READ16BETO32LE_MSW( name, read16 ) \ |
| 926 | | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16be_handler, ACCESSING_BITS_16_31 ) |
| 927 | | |
| 928 | | |
| 929 | | #define WRITE16BETO32LE_MSW( name, write16 ) \ |
| 930 | | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16be_handler, ACCESSING_BITS_16_31 ) |
| 931 | | |
| 932 | | |
| 933 | | #define READWRITE16BETO32LE_MSW( name, read16, write16 ) \ |
| 934 | | READ16BETO32LE_MSW(name,read16) \ |
| 935 | | WRITE16BETO32LE_MSW(name,write16) |
| 936 | | |
| 937 | | |
| 938 | | /************************************* |
| 939 | | * 16le->32le, MSW mapping |
| 940 | | *************************************/ |
| 941 | | |
| 942 | | #define READ16LETO32LE_MSW( name, read16 ) \ |
| 943 | | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16le_handler, ACCESSING_BITS_16_31 ) |
| 944 | | |
| 945 | | |
| 946 | | #define WRITE16LETO32LE_MSW( name, write16 ) \ |
| 947 | | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16le_handler, ACCESSING_BITS_16_31 ) |
| 948 | | |
| 949 | | |
| 950 | | #define READWRITE16LETO32LE_MSW( name, read16, write16 ) \ |
| 951 | | READ16LETO32LE_MSW(name,read16) \ |
| 952 | | WRITE16LETO32LE_MSW(name,write16) |
| 953 | | |
| 954 | | /************************************* |
| 955 | | * 16be->32be, LSW mapping |
| 956 | | *************************************/ |
| 957 | | |
| 958 | | #define READ16BETO32BE_LSW( name, read16 ) \ |
| 959 | | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16be_handler, ACCESSING_BITS_0_15 ) |
| 960 | | |
| 961 | | |
| 962 | | #define WRITE16BETO32BE_LSW( name, write16 ) \ |
| 963 | | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16be_handler, ACCESSING_BITS_0_15 ) |
| 964 | | |
| 965 | | |
| 966 | | #define READWRITE16BETO32BE_LSW( name, read16, write16 ) \ |
| 967 | | READ16BETO32BE_LSW(name,read16) \ |
| 968 | | WRITE16BETO32BE_LSW(name,write16) |
| 969 | | |
| 970 | | |
| 971 | | /************************************* |
| 972 | | * 16le->32be, LSW mapping |
| 973 | | *************************************/ |
| 974 | | |
| 975 | | #define READ16LETO32BE_LSW( name, read16 ) \ |
| 976 | | READ_TEMPLATE_COND( 32, name, read16, read32be_with_16le_handler, ACCESSING_BITS_0_15 ) |
| 977 | | |
| 978 | | |
| 979 | | #define WRITE16LETO32BE_LSW( name, write16 ) \ |
| 980 | | WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16le_handler, ACCESSING_BITS_0_15 ) |
| 981 | | |
| 982 | | |
| 983 | | #define READWRITE16LETO32BE_LSW( name, read16, write16 ) \ |
| 984 | | READ16LETO32BE_LSW(name,read16) \ |
| 985 | | WRITE16LETO32BE_LSW(name,write16) |
| 986 | | |
| 987 | | |
| 988 | | /************************************* |
| 989 | | * 16be->32le, LSW mapping |
| 990 | | *************************************/ |
| 991 | | |
| 992 | | #define READ16BETO32LE_LSW( name, read16 ) \ |
| 993 | | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16be_handler, ACCESSING_BITS_0_15 ) |
| 994 | | |
| 995 | | |
| 996 | | #define WRITE16BETO32LE_LSW( name, write16 ) \ |
| 997 | | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16be_handler, ACCESSING_BITS_0_15 ) |
| 998 | | |
| 999 | | |
| 1000 | | #define READWRITE16BETO32LE_LSW( name, read16, write16 ) \ |
| 1001 | | READ16BETO32LE_LSW(name,read16) \ |
| 1002 | | WRITE16BETO32LE_LSW(name,write16) |
| 1003 | | |
| 1004 | | |
| 1005 | | /************************************* |
| 1006 | | * 16le->32le, LSW mapping |
| 1007 | | *************************************/ |
| 1008 | | |
| 1009 | | #define READ16LETO32LE_LSW( name, read16 ) \ |
| 1010 | | READ_TEMPLATE_COND( 32, name, read16, read32le_with_16le_handler, ACCESSING_BITS_0_15 ) |
| 1011 | | |
| 1012 | | |
| 1013 | | #define WRITE16LETO32LE_LSW( name, write16 ) \ |
| 1014 | | WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16le_handler, ACCESSING_BITS_0_15 ) |
| 1015 | | |
| 1016 | | |
| 1017 | | #define READWRITE16LETO32LE_LSW( name, read16, write16 ) \ |
| 1018 | | READ16LETO32LE_LSW(name,read16) \ |
| 1019 | | WRITE16LETO32LE_LSW(name,write16) |
| 1020 | | |
trunk/src/emu/devconv.h
| r18152 | r18153 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | devconv.h |
| 4 | | |
| 5 | | Functions which help convert between different device handlers. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | **************************************************************************** |
| 11 | | |
| 12 | | ***** VERY IMPORTANT NOTICE ***** |
| 13 | | |
| 14 | | These functions and macros are provided to facilitate the mapping |
| 15 | | of devices on cpus with different data bus widths. |
| 16 | | Devices should be implemented using their native data bus width, |
| 17 | | since that ensures that read/write operations are kept atomic. |
| 18 | | If we discover you have abused the functionality presented in this |
| 19 | | file, you *will* be publicly humiliated and your code submission |
| 20 | | will probably not be accepted. Seriously, please do not abuse these |
| 21 | | functions/macros. |
| 22 | | |
| 23 | | **************************************************************************** |
| 24 | | |
| 25 | | Conversions supported: |
| 26 | | |
| 27 | | CW = CPU Data Bus Width in bits |
| 28 | | CBO = CPU Byte Order |
| 29 | | DW = Device Data Bus Width in bits |
| 30 | | DBO = Device Byte Order |
| 31 | | |
| 32 | | CW | CBO | DW | DBO | Functions to use |
| 33 | | ---+--------+----+--------+----------------------------------------------------------- |
| 34 | | 16 | Big | 8 | N/A | read16be_with_read8_device_handler,write16be_with_write8_device_handler |
| 35 | | 16 | Little | 8 | N/A | read16le_with_read8_device_handler,write16le_with_write8_device_handler |
| 36 | | ---+--------+----+--------+----------------------------------------------------------- |
| 37 | | 32 | Big | 8 | N/A | read32be_with_read8_device_handler,write32be_with_write8_device_handler |
| 38 | | 32 | Little | 8 | N/A | read32le_with_read8_device_handler,write32le_with_write8_device_handler |
| 39 | | 32 | Big | 16 | Big | read32be_with_16be_device_handler,write32be_with_16be_device_handler |
| 40 | | 32 | Little | 16 | Little | read32le_with_16le_device_handler,write32le_with_16le_device_handler |
| 41 | | 32 | Big | 16 | Little | read32be_with_16le_device_handler,write32be_with_16le_device_handler |
| 42 | | 32 | Little | 16 | Big | read32le_with_16be_device_handler,write32le_with_16be_device_handler |
| 43 | | ---+--------+----+--------+----------------------------------------------------------- |
| 44 | | 64 | Big | 8 | N/A | read64be_with_read8_device_handler,write64be_with_write8_device_handler |
| 45 | | 64 | Little | 8 | N/A | read64le_with_read8_device_handler,write64le_with_write8_device_handler |
| 46 | | 64 | Big | 16 | Big | read64be_with_16be_device_handler,write64be_with_16be_device_handler |
| 47 | | 64 | Little | 16 | Little | read64le_with_16le_device_handler,write64le_with_16le_device_handler |
| 48 | | 64 | Big | 16 | Little | read64be_with_16le_device_handler,write64be_with_16le_device_handler |
| 49 | | 64 | Little | 16 | Big | read64le_with_16be_device_handler,write64le_with_16be_device_handler |
| 50 | | 64 | Big | 32 | Big | read64be_with_32be_device_handler,write64be_with_32be_device_handler |
| 51 | | 64 | Little | 32 | Little | read64le_with_32le_device_handler,write64le_with_32le_device_handler |
| 52 | | 64 | Big | 32 | Little | read64be_with_32le_device_handler,write64be_with_32le_device_handler |
| 53 | | 64 | Little | 32 | Big | read64le_with_32be_device_handler,write64le_with_32be_device_handler |
| 54 | | |
| 55 | | You can also find at the bottom of this file a few convernient |
| 56 | | macros that will create the stub read and/or write handlers for |
| 57 | | the most common mappings, that will use the functions above. |
| 58 | | Here's an example on how to use them: Say you have a 8 bit device |
| 59 | | whose handlers are device8_r and device8_w, and you want to connect |
| 60 | | it to a 16 bit, big endian cpu. We'll say the device is mapped on |
| 61 | | the least significant byte of the data bus (LSB). |
| 62 | | |
| 63 | | In your driver, you would add: |
| 64 | | |
| 65 | | DEV_READWRITE8TO16BE_LSB( device16, device8_r, device8_w ) |
| 66 | | |
| 67 | | which will create two 16 bit memory handlers, one for read, called |
| 68 | | device16_r, and one for write, called device16_w, with the proper |
| 69 | | mapping. |
| 70 | | |
| 71 | | then in the MEMORY_MAP you would specify: |
| 72 | | |
| 73 | | AM_RANGE(0x000000, 0x0000ff) AM_DEVREADWRITE( DEVICE, "device", device16_r, device16_w ) |
| 74 | | |
| 75 | | And that is all. Your device should be mapped properly. |
| 76 | | If you need to do custom mappings, or a mapping that is not currently |
| 77 | | supported in this file, you can always write the stub yourself, and |
| 78 | | call the above functions to invoke the base handlers. |
| 79 | | |
| 80 | | ***************************************************************************/ |
| 81 | | |
| 82 | | /************************************* |
| 83 | | * |
| 84 | | * 16-bit BE using 8-bit handlers |
| 85 | | * |
| 86 | | *************************************/ |
| 87 | | |
| 88 | | INLINE UINT16 read16be_with_read8_device_handler(read8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT16 mem_mask) |
| 89 | | { |
| 90 | | UINT16 result = 0; |
| 91 | | if (ACCESSING_BITS_8_15) |
| 92 | | result |= ((UINT16)(*handler)(device, space, offset * 2 + 0, mem_mask >> 8)) << 8; |
| 93 | | if (ACCESSING_BITS_0_7) |
| 94 | | result |= ((UINT16)(*handler)(device, space, offset * 2 + 1, mem_mask >> 0)) << 0; |
| 95 | | return result; |
| 96 | | } |
| 97 | | |
| 98 | | |
| 99 | | INLINE void write16be_with_write8_device_handler(write8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask) |
| 100 | | { |
| 101 | | if (ACCESSING_BITS_8_15) |
| 102 | | (*handler)(device, space, offset * 2 + 0, data >> 8, mem_mask >> 8); |
| 103 | | if (ACCESSING_BITS_0_7) |
| 104 | | (*handler)(device, space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 105 | | } |
| 106 | | |
| 107 | | |
| 108 | | /************************************* |
| 109 | | * |
| 110 | | * 16-bit LE using 8-bit handlers |
| 111 | | * |
| 112 | | *************************************/ |
| 113 | | |
| 114 | | INLINE UINT16 read16le_with_read8_device_handler(read8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT16 mem_mask) |
| 115 | | { |
| 116 | | UINT16 result = 0; |
| 117 | | if (ACCESSING_BITS_0_7) |
| 118 | | result |= ((UINT16) (*handler)(device, space, offset * 2 + 0, mem_mask >> 0)) << 0; |
| 119 | | if (ACCESSING_BITS_8_15) |
| 120 | | result |= ((UINT16) (*handler)(device, space, offset * 2 + 1, mem_mask >> 8)) << 8; |
| 121 | | return result; |
| 122 | | } |
| 123 | | |
| 124 | | |
| 125 | | INLINE void write16le_with_write8_device_handler(write8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask) |
| 126 | | { |
| 127 | | if (ACCESSING_BITS_0_7) |
| 128 | | (*handler)(device, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 129 | | if (ACCESSING_BITS_8_15) |
| 130 | | (*handler)(device, space, offset * 2 + 1, data >> 8, mem_mask >> 8); |
| 131 | | } |
| 132 | | |
| 133 | | |
| 134 | | /************************************* |
| 135 | | * |
| 136 | | * 32-bit BE using 8-bit handlers |
| 137 | | * |
| 138 | | *************************************/ |
| 139 | | |
| 140 | | INLINE UINT32 read32be_with_read8_device_handler(read8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 141 | | { |
| 142 | | UINT32 result = 0; |
| 143 | | if (ACCESSING_BITS_16_31) |
| 144 | | result |= read16be_with_read8_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 16) << 16; |
| 145 | | if (ACCESSING_BITS_0_15) |
| 146 | | result |= read16be_with_read8_device_handler(handler, device, space, offset * 2 + 1, mem_mask) << 0; |
| 147 | | return result; |
| 148 | | } |
| 149 | | |
| 150 | | |
| 151 | | INLINE void write32be_with_write8_device_handler(write8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 152 | | { |
| 153 | | if (ACCESSING_BITS_16_31) |
| 154 | | write16be_with_write8_device_handler(handler, device, space, offset * 2 + 0, data >> 16, mem_mask >> 16); |
| 155 | | if (ACCESSING_BITS_0_15) |
| 156 | | write16be_with_write8_device_handler(handler, device, space, offset * 2 + 1, data, mem_mask); |
| 157 | | } |
| 158 | | |
| 159 | | |
| 160 | | /************************************* |
| 161 | | * |
| 162 | | * 32-bit LE using 8-bit handlers |
| 163 | | * |
| 164 | | *************************************/ |
| 165 | | |
| 166 | | INLINE UINT32 read32le_with_read8_device_handler(read8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 167 | | { |
| 168 | | UINT32 result = 0; |
| 169 | | if (ACCESSING_BITS_0_15) |
| 170 | | result |= read16le_with_read8_device_handler(handler, device, space, offset * 2 + 0, mem_mask) << 0; |
| 171 | | if (ACCESSING_BITS_16_31) |
| 172 | | result |= read16le_with_read8_device_handler(handler, device, space, offset * 2 + 1, mem_mask >> 16) << 16; |
| 173 | | return result; |
| 174 | | } |
| 175 | | |
| 176 | | |
| 177 | | INLINE void write32le_with_write8_device_handler(write8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 178 | | { |
| 179 | | if (ACCESSING_BITS_0_15) |
| 180 | | write16le_with_write8_device_handler(handler, device, space, offset * 2 + 0, data, mem_mask); |
| 181 | | if (ACCESSING_BITS_16_31) |
| 182 | | write16le_with_write8_device_handler(handler, device, space, offset * 2 + 1, data >> 16, mem_mask >> 16); |
| 183 | | } |
| 184 | | |
| 185 | | |
| 186 | | /************************************* |
| 187 | | * |
| 188 | | * 32-bit BE using 16-bit BE handlers |
| 189 | | * |
| 190 | | *************************************/ |
| 191 | | |
| 192 | | INLINE UINT32 read32be_with_16be_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 193 | | { |
| 194 | | UINT32 result = 0; |
| 195 | | if (ACCESSING_BITS_16_31) |
| 196 | | result |= (*handler)(device, space, offset * 2 + 0, mem_mask >> 16) << 16; |
| 197 | | if (ACCESSING_BITS_0_15) |
| 198 | | result |= (*handler)(device, space, offset * 2 + 1, mem_mask) << 0; |
| 199 | | return result; |
| 200 | | } |
| 201 | | |
| 202 | | |
| 203 | | INLINE void write32be_with_16be_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 204 | | { |
| 205 | | if (ACCESSING_BITS_16_31) |
| 206 | | (*handler)(device, space, offset * 2 + 0, data >> 16, mem_mask >> 16); |
| 207 | | if (ACCESSING_BITS_0_15) |
| 208 | | (*handler)(device, space, offset * 2 + 1, data, mem_mask); |
| 209 | | } |
| 210 | | |
| 211 | | |
| 212 | | /************************************* |
| 213 | | * |
| 214 | | * 32-bit LE using 16-bit LE handlers |
| 215 | | * |
| 216 | | *************************************/ |
| 217 | | |
| 218 | | INLINE UINT32 read32le_with_16le_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 219 | | { |
| 220 | | UINT32 result = 0; |
| 221 | | if (ACCESSING_BITS_0_15) |
| 222 | | result |= (*handler)(device, space, offset * 2 + 0, mem_mask) << 0; |
| 223 | | if (ACCESSING_BITS_16_31) |
| 224 | | result |= (*handler)(device, space, offset * 2 + 1, mem_mask >> 16) << 16; |
| 225 | | return result; |
| 226 | | } |
| 227 | | |
| 228 | | |
| 229 | | INLINE void write32le_with_16le_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 230 | | { |
| 231 | | if (ACCESSING_BITS_0_15) |
| 232 | | (*handler)(device, space, offset * 2 + 0, data, mem_mask); |
| 233 | | if (ACCESSING_BITS_16_31) |
| 234 | | (*handler)(device, space, offset * 2 + 1, data >> 16, mem_mask >> 16); |
| 235 | | } |
| 236 | | |
| 237 | | |
| 238 | | /************************************* |
| 239 | | * |
| 240 | | * 32-bit BE using 16-bit LE handlers |
| 241 | | * |
| 242 | | *************************************/ |
| 243 | | |
| 244 | | INLINE UINT32 read32be_with_16le_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 245 | | { |
| 246 | | UINT32 result = 0; |
| 247 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 248 | | result = read32le_with_16le_device_handler(handler, device, space, offset, mem_mask); |
| 249 | | return FLIPENDIAN_INT32(result); |
| 250 | | } |
| 251 | | |
| 252 | | |
| 253 | | INLINE void write32be_with_16le_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 254 | | { |
| 255 | | data = FLIPENDIAN_INT32(data); |
| 256 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 257 | | write32le_with_16le_device_handler(handler, device, space, offset, data, mem_mask); |
| 258 | | } |
| 259 | | |
| 260 | | |
| 261 | | /************************************* |
| 262 | | * |
| 263 | | * 32-bit LE using 16-bit BE handlers |
| 264 | | * |
| 265 | | *************************************/ |
| 266 | | |
| 267 | | INLINE UINT32 read32le_with_16be_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 mem_mask) |
| 268 | | { |
| 269 | | UINT32 result = 0; |
| 270 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 271 | | result = read32be_with_16be_device_handler(handler, device, space, offset, mem_mask); |
| 272 | | return FLIPENDIAN_INT32(result); |
| 273 | | } |
| 274 | | |
| 275 | | |
| 276 | | INLINE void write32le_with_16be_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT32 data, UINT32 mem_mask) |
| 277 | | { |
| 278 | | data = FLIPENDIAN_INT32(data); |
| 279 | | mem_mask = FLIPENDIAN_INT32(mem_mask); |
| 280 | | write32be_with_16be_device_handler(handler, device, space, offset, data, mem_mask); |
| 281 | | } |
| 282 | | |
| 283 | | |
| 284 | | /************************************* |
| 285 | | * |
| 286 | | * 64-bit BE using 8-bit handlers |
| 287 | | * |
| 288 | | *************************************/ |
| 289 | | |
| 290 | | INLINE UINT64 read64be_with_read8_device_handler(read8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 291 | | { |
| 292 | | UINT64 result = 0; |
| 293 | | if (ACCESSING_BITS_32_63) |
| 294 | | result |= (UINT64)read32be_with_read8_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 295 | | if (ACCESSING_BITS_0_31) |
| 296 | | result |= (UINT64)read32be_with_read8_device_handler(handler, device, space, offset * 2 + 1, mem_mask) << 0; |
| 297 | | return result; |
| 298 | | } |
| 299 | | |
| 300 | | |
| 301 | | INLINE void write64be_with_write8_device_handler(write8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 302 | | { |
| 303 | | if (ACCESSING_BITS_32_63) |
| 304 | | write32be_with_write8_device_handler(handler, device, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 305 | | if (ACCESSING_BITS_0_31) |
| 306 | | write32be_with_write8_device_handler(handler, device, space, offset * 2 + 1, data, mem_mask); |
| 307 | | } |
| 308 | | |
| 309 | | |
| 310 | | /************************************* |
| 311 | | * |
| 312 | | * 64-bit LE using 8-bit handlers |
| 313 | | * |
| 314 | | *************************************/ |
| 315 | | |
| 316 | | INLINE UINT64 read64le_with_read8_device_handler(read8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 317 | | { |
| 318 | | UINT64 result = 0; |
| 319 | | if (ACCESSING_BITS_0_31) |
| 320 | | result |= (UINT64)read32le_with_read8_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 321 | | if (ACCESSING_BITS_32_63) |
| 322 | | result |= (UINT64)read32le_with_read8_device_handler(handler, device, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 323 | | return result; |
| 324 | | } |
| 325 | | |
| 326 | | |
| 327 | | INLINE void write64le_with_write8_device_handler(write8_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 328 | | { |
| 329 | | if (ACCESSING_BITS_0_31) |
| 330 | | write32le_with_write8_device_handler(handler, device, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 331 | | if (ACCESSING_BITS_32_63) |
| 332 | | write32le_with_write8_device_handler(handler, device, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 333 | | } |
| 334 | | |
| 335 | | |
| 336 | | /************************************* |
| 337 | | * |
| 338 | | * 64-bit BE using 16-bit BE handlers |
| 339 | | * |
| 340 | | *************************************/ |
| 341 | | |
| 342 | | INLINE UINT32 read64be_with_16be_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 343 | | { |
| 344 | | UINT64 result = 0; |
| 345 | | if (ACCESSING_BITS_32_63) |
| 346 | | result |= (UINT64)read32be_with_16be_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 347 | | if (ACCESSING_BITS_0_31) |
| 348 | | result |= (UINT64)read32be_with_16be_device_handler(handler, device, space, offset * 2 + 1, mem_mask >> 0) << 0; |
| 349 | | return result; |
| 350 | | } |
| 351 | | |
| 352 | | |
| 353 | | INLINE void write64be_with_16be_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 354 | | { |
| 355 | | if (ACCESSING_BITS_32_63) |
| 356 | | write32be_with_16be_device_handler(handler, device, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 357 | | if (ACCESSING_BITS_0_31) |
| 358 | | write32be_with_16be_device_handler(handler, device, space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 359 | | } |
| 360 | | |
| 361 | | |
| 362 | | /************************************* |
| 363 | | * |
| 364 | | * 64-bit LE using 16-bit LE handlers |
| 365 | | * |
| 366 | | *************************************/ |
| 367 | | |
| 368 | | INLINE UINT32 read64le_with_16le_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 369 | | { |
| 370 | | UINT64 result = 0; |
| 371 | | if (ACCESSING_BITS_0_31) |
| 372 | | result |= (UINT64)read32le_with_16le_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 373 | | if (ACCESSING_BITS_32_63) |
| 374 | | result |= (UINT64)read32le_with_16le_device_handler(handler, device, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 375 | | return result; |
| 376 | | } |
| 377 | | |
| 378 | | |
| 379 | | INLINE void write64le_with_16le_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 380 | | { |
| 381 | | if (ACCESSING_BITS_0_31) |
| 382 | | write32le_with_16le_device_handler(handler, device, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 383 | | if (ACCESSING_BITS_32_63) |
| 384 | | write32le_with_16le_device_handler(handler, device, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 385 | | } |
| 386 | | |
| 387 | | |
| 388 | | /************************************* |
| 389 | | * |
| 390 | | * 64-bit BE using 16-bit LE handlers |
| 391 | | * |
| 392 | | *************************************/ |
| 393 | | |
| 394 | | INLINE UINT32 read64be_with_16le_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 395 | | { |
| 396 | | UINT64 result = 0; |
| 397 | | if (ACCESSING_BITS_32_63) |
| 398 | | result |= (UINT64)read32be_with_16le_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 399 | | if (ACCESSING_BITS_0_31) |
| 400 | | result |= (UINT64)read32be_with_16le_device_handler(handler, device, space, offset * 2 + 1, mem_mask >> 0) << 0; |
| 401 | | return result; |
| 402 | | } |
| 403 | | |
| 404 | | |
| 405 | | INLINE void write64be_with_16le_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 406 | | { |
| 407 | | if (ACCESSING_BITS_32_63) |
| 408 | | write32be_with_16le_device_handler(handler, device, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 409 | | if (ACCESSING_BITS_0_31) |
| 410 | | write32be_with_16le_device_handler(handler, device, space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 411 | | } |
| 412 | | |
| 413 | | |
| 414 | | /************************************* |
| 415 | | * |
| 416 | | * 64-bit LE using 16-bit BE handlers |
| 417 | | * |
| 418 | | *************************************/ |
| 419 | | |
| 420 | | INLINE UINT32 read64le_with_16be_device_handler(read16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 421 | | { |
| 422 | | UINT64 result = 0; |
| 423 | | if (ACCESSING_BITS_0_31) |
| 424 | | result |= (UINT64)read32le_with_16be_device_handler(handler, device, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 425 | | if (ACCESSING_BITS_32_63) |
| 426 | | result |= (UINT64)read32le_with_16be_device_handler(handler, device, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 427 | | return result; |
| 428 | | } |
| 429 | | |
| 430 | | |
| 431 | | INLINE void write64le_with_16be_device_handler(write16_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 432 | | { |
| 433 | | if (ACCESSING_BITS_0_31) |
| 434 | | write32le_with_16be_device_handler(handler, device, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 435 | | if (ACCESSING_BITS_32_63) |
| 436 | | write32le_with_16be_device_handler(handler, device, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 437 | | } |
| 438 | | |
| 439 | | |
| 440 | | /************************************* |
| 441 | | * |
| 442 | | * 64-bit BE using 32-bit BE handlers |
| 443 | | * |
| 444 | | *************************************/ |
| 445 | | |
| 446 | | INLINE UINT64 read64be_with_32be_device_handler(read32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 447 | | { |
| 448 | | UINT64 result = 0; |
| 449 | | if (ACCESSING_BITS_32_63) |
| 450 | | result |= (UINT64)(*handler)(device, space, offset * 2 + 0, mem_mask >> 32) << 32; |
| 451 | | if (ACCESSING_BITS_0_31) |
| 452 | | result |= (UINT64)(*handler)(device, space, offset * 2 + 1, mem_mask >> 0) << 0; |
| 453 | | return result; |
| 454 | | } |
| 455 | | |
| 456 | | |
| 457 | | INLINE void write64be_with_32be_device_handler(write32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 458 | | { |
| 459 | | if (ACCESSING_BITS_32_63) |
| 460 | | (*handler)(device, space, offset * 2 + 0, data >> 32, mem_mask >> 32); |
| 461 | | if (ACCESSING_BITS_0_31) |
| 462 | | (*handler)(device, space, offset * 2 + 1, data >> 0, mem_mask >> 0); |
| 463 | | } |
| 464 | | |
| 465 | | |
| 466 | | /************************************* |
| 467 | | * |
| 468 | | * 64-bit LE using 32-bit LE handlers |
| 469 | | * |
| 470 | | *************************************/ |
| 471 | | |
| 472 | | INLINE UINT64 read64le_with_32le_device_handler(read32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 473 | | { |
| 474 | | UINT64 result = 0; |
| 475 | | if (ACCESSING_BITS_0_31) |
| 476 | | result |= (UINT64)(*handler)(device, space, offset * 2 + 0, mem_mask >> 0) << 0; |
| 477 | | if (ACCESSING_BITS_32_63) |
| 478 | | result |= (UINT64)(*handler)(device, space, offset * 2 + 1, mem_mask >> 32) << 32; |
| 479 | | return result; |
| 480 | | } |
| 481 | | |
| 482 | | |
| 483 | | INLINE void write64le_with_32le_device_handler(write32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 484 | | { |
| 485 | | if (ACCESSING_BITS_0_31) |
| 486 | | (*handler)(device, space, offset * 2 + 0, data >> 0, mem_mask >> 0); |
| 487 | | if (ACCESSING_BITS_32_63) |
| 488 | | (*handler)(device, space, offset * 2 + 1, data >> 32, mem_mask >> 32); |
| 489 | | } |
| 490 | | |
| 491 | | |
| 492 | | /************************************* |
| 493 | | * |
| 494 | | * 64-bit BE using 32-bit LE handlers |
| 495 | | * |
| 496 | | *************************************/ |
| 497 | | |
| 498 | | INLINE UINT64 read64be_with_32le_device_handler(read32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 499 | | { |
| 500 | | UINT64 result; |
| 501 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 502 | | result = read64le_with_32le_device_handler(handler, device, space, offset, mem_mask); |
| 503 | | return FLIPENDIAN_INT64(result); |
| 504 | | } |
| 505 | | |
| 506 | | |
| 507 | | INLINE void write64be_with_32le_device_handler(write32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 508 | | { |
| 509 | | data = FLIPENDIAN_INT64(data); |
| 510 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 511 | | write64le_with_32le_device_handler(handler, device, space, offset, data, mem_mask); |
| 512 | | } |
| 513 | | |
| 514 | | |
| 515 | | /************************************* |
| 516 | | * |
| 517 | | * 64-bit LE using 32-bit BE handlers |
| 518 | | * |
| 519 | | *************************************/ |
| 520 | | |
| 521 | | INLINE UINT64 read64le_with_32be_device_handler(read32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 mem_mask) |
| 522 | | { |
| 523 | | UINT64 result; |
| 524 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 525 | | result = read64be_with_32be_device_handler(handler, device, space, offset, mem_mask); |
| 526 | | return FLIPENDIAN_INT64(result); |
| 527 | | } |
| 528 | | |
| 529 | | |
| 530 | | INLINE void write64le_with_32be_device_handler(write32_device_func handler, device_t *device, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask) |
| 531 | | { |
| 532 | | data = FLIPENDIAN_INT64(data); |
| 533 | | mem_mask = FLIPENDIAN_INT64(mem_mask); |
| 534 | | write64be_with_32be_device_handler(handler, device, space, offset, data, mem_mask); |
| 535 | | } |
| 536 | | |
| 537 | | |
| 538 | | |
| 539 | | /************************************************************************** |
| 540 | | |
| 541 | | Utility macros |
| 542 | | |
| 543 | | **************************************************************************/ |
| 544 | | |
| 545 | | #define DEV_READ_TEMPLATE(bits, name, handler, func) \ |
| 546 | | READ##bits##_DEVICE_HANDLER( name##_r ) \ |
| 547 | | { \ |
| 548 | | return func(handler, device, space, offset, mem_mask); \ |
| 549 | | } |
| 550 | | |
| 551 | | #define DEV_READ_TEMPLATE_COND(bits, name, handler, func, cond) \ |
| 552 | | READ##bits##_DEVICE_HANDLER( name##_r ) \ |
| 553 | | { \ |
| 554 | | if (cond) \ |
| 555 | | return func(handler, device, space, offset, mem_mask); \ |
| 556 | | return 0; \ |
| 557 | | } |
| 558 | | |
| 559 | | #define DEV_WRITE_TEMPLATE(bits, name, handler, func) \ |
| 560 | | WRITE##bits##_DEVICE_HANDLER( name##_w ) \ |
| 561 | | { \ |
| 562 | | func(handler, device, space, offset, data, mem_mask); \ |
| 563 | | } |
| 564 | | |
| 565 | | #define DEV_WRITE_TEMPLATE_COND(bits, name, handler, func, cond) \ |
| 566 | | WRITE##bits##_DEVICE_HANDLER( name##_w ) \ |
| 567 | | { \ |
| 568 | | if (cond) \ |
| 569 | | func(handler, device, space, offset, data, mem_mask); \ |
| 570 | | } |
| 571 | | |
| 572 | | |
| 573 | | |
| 574 | | /************************************************************************** |
| 575 | | |
| 576 | | Generic conversions macros |
| 577 | | |
| 578 | | **************************************************************************/ |
| 579 | | |
| 580 | | |
| 581 | | /************************************* |
| 582 | | * 8->16be, 1:1 mapping |
| 583 | | ************************************/ |
| 584 | | |
| 585 | | #define DEV_READ8TO16BE( name, read8 ) \ |
| 586 | | DEV_READ_TEMPLATE( 16, name, read8, read16be_with_read8_device_handler ) |
| 587 | | |
| 588 | | |
| 589 | | #define DEV_WRITE8TO16BE( name, write8 ) \ |
| 590 | | DEV_WRITE_TEMPLATE( 16, name, write8, write16be_with_write8_device_handler ) |
| 591 | | |
| 592 | | |
| 593 | | #define DEV_READWRITE8TO16BE( name, read8, write8 ) \ |
| 594 | | DEV_READ8TO16BE(name,read8) \ |
| 595 | | DEV_WRITE8TO16BE(name,write8) |
| 596 | | |
| 597 | | |
| 598 | | /************************************* |
| 599 | | * 8->16le, 1:1 mapping |
| 600 | | ************************************/ |
| 601 | | |
| 602 | | #define DEV_READ8TO16LE( name, read8 ) \ |
| 603 | | DEV_READ_TEMPLATE( 16, name, read8, read16le_with_read8_device_handler ) |
| 604 | | |
| 605 | | |
| 606 | | #define DEV_WRITE8TO16LE( name, write8 ) \ |
| 607 | | DEV_WRITE_TEMPLATE( 16, name, write8, write16le_with_write8_device_handler ) |
| 608 | | |
| 609 | | |
| 610 | | #define DEV_READWRITE8TO16LE( name, read8, write8 ) \ |
| 611 | | DEV_READ8TO16LE(name,read8) \ |
| 612 | | DEV_WRITE8TO16LE(name,write8) |
| 613 | | |
| 614 | | |
| 615 | | /************************************* |
| 616 | | * 8->16be, MSB mapping |
| 617 | | ************************************/ |
| 618 | | |
| 619 | | #define DEV_READ8TO16BE_MSB( name, read8 ) \ |
| 620 | | DEV_READ_TEMPLATE_COND( 16, name, read8, read16be_with_read8_device_handler, ACCESSING_BITS_8_15 ) |
| 621 | | |
| 622 | | |
| 623 | | #define DEV_WRITE8TO16BE_MSB( name, write8 ) \ |
| 624 | | DEV_WRITE_TEMPLATE_COND( 16, name, write8, write16be_with_write8_device_handler, ACCESSING_BITS_8_15 ) |
| 625 | | |
| 626 | | |
| 627 | | #define DEV_READWRITE8TO16BE_MSB( name, read8, write8 ) \ |
| 628 | | DEV_READ8TO16BE_MSB(name,read8) \ |
| 629 | | DEV_WRITE8TO16BE_MSB(name,write8) |
| 630 | | |
| 631 | | |
| 632 | | /************************************* |
| 633 | | * 8->16le, MSB mapping |
| 634 | | ************************************/ |
| 635 | | |
| 636 | | #define DEV_READ8TO16LE_MSB( name, read8 ) \ |
| 637 | | DEV_READ_TEMPLATE_COND( 16, name, read8, read16le_with_read8_device_handler, ACCESSING_BITS_8_15 ) |
| 638 | | |
| 639 | | |
| 640 | | #define DEV_WRITE8TO16LE_MSB( name, write8 ) \ |
| 641 | | DEV_WRITE_TEMPLATE_COND( 16, name, write8, write16le_with_write8_device_handler, ACCESSING_BITS_8_15 ) |
| 642 | | |
| 643 | | |
| 644 | | #define DEV_READWRITE8TO16LE_MSB( name, read8, write8 ) \ |
| 645 | | DEV_READ8TO16LE_MSB(name,read8) \ |
| 646 | | DEV_WRITE8TO16LE_MSB(name,write8) |
| 647 | | |
| 648 | | |
| 649 | | /************************************* |
| 650 | | * 8->16be, LSB mapping |
| 651 | | ************************************/ |
| 652 | | |
| 653 | | #define DEV_READ8TO16BE_LSB( name, read8 ) \ |
| 654 | | DEV_READ_TEMPLATE_COND( 16, name, read8, read16be_with_read8_device_handler, ACCESSING_BITS_0_7 ) |
| 655 | | |
| 656 | | |
| 657 | | #define DEV_WRITE8TO16BE_LSB( name, write8 ) \ |
| 658 | | DEV_WRITE_TEMPLATE_COND( 16, name, write8, write16be_with_write8_device_handler, ACCESSING_BITS_0_7 ) |
| 659 | | |
| 660 | | |
| 661 | | #define DEV_READWRITE8TO16BE_LSB( name, read8, write8 ) \ |
| 662 | | DEV_READ8TO16BE_LSB(name,read8) \ |
| 663 | | DEV_WRITE8TO16BE_LSB(name,write8) |
| 664 | | |
| 665 | | |
| 666 | | /************************************* |
| 667 | | * 8->16le, LSB mapping |
| 668 | | ************************************/ |
| 669 | | |
| 670 | | #define DEV_READ8TO16LE_LSB( name, read8 ) \ |
| 671 | | DEV_READ_TEMPLATE_COND( 16, name, read8, read16le_with_read8_device_handler, ACCESSING_BITS_0_7 ) |
| 672 | | |
| 673 | | |
| 674 | | #define DEV_WRITE8TO16LE_LSB( name, write8 ) \ |
| 675 | | DEV_WRITE_TEMPLATE_COND( 16, name, write8, write16le_with_write8_device_handler, ACCESSING_BITS_0_7 ) |
| 676 | | |
| 677 | | |
| 678 | | #define DEV_READWRITE8TO16LE_LSB( name, read8, write8 ) \ |
| 679 | | DEV_READ8TO16LE_LSB(name,read8) \ |
| 680 | | DEV_WRITE8TO16LE_LSB(name,write8) |
| 681 | | |
| 682 | | |
| 683 | | /************************************* |
| 684 | | * 8->32be, 1:1 mapping |
| 685 | | ************************************/ |
| 686 | | |
| 687 | | #define DEV_READ8TO32BE( name, read8 ) \ |
| 688 | | DEV_READ_TEMPLATE( 32, name, read8, read32be_with_read8_device_handler ) |
| 689 | | |
| 690 | | |
| 691 | | #define DEV_WRITE8TO32BE( name, write8 ) \ |
| 692 | | DEV_WRITE_TEMPLATE( 32, name, write8, write32be_with_write8_device_handler ) |
| 693 | | |
| 694 | | |
| 695 | | #define DEV_READWRITE8TO32BE( name, read8, write8 ) \ |
| 696 | | DEV_READ8TO32BE(name,read8) \ |
| 697 | | DEV_WRITE8TO32BE(name,write8) |
| 698 | | |
| 699 | | |
| 700 | | /************************************* |
| 701 | | * 8->32le, 1:1 mapping |
| 702 | | ************************************/ |
| 703 | | |
| 704 | | #define DEV_READ8TO32LE( name, read8 ) \ |
| 705 | | DEV_READ_TEMPLATE( 32, name, read8, read32le_with_read8_device_handler ) |
| 706 | | |
| 707 | | |
| 708 | | #define DEV_WRITE8TO32LE( name, write8 ) \ |
| 709 | | DEV_WRITE_TEMPLATE( 32, name, write8, write32le_with_write8_device_handler ) |
| 710 | | |
| 711 | | |
| 712 | | #define DEV_READWRITE8TO32LE( name, read8, write8 ) \ |
| 713 | | DEV_READ8TO32LE(name,read8) \ |
| 714 | | DEV_WRITE8TO32LE(name,write8) |
| 715 | | |
| 716 | | |
| 717 | | /************************************* |
| 718 | | * 8->32be, MSB mapping |
| 719 | | ************************************/ |
| 720 | | |
| 721 | | #define DEV_READ8TO32BE_MSB( name, read8 ) \ |
| 722 | | DEV_READ_TEMPLATE_COND( 32, name, read8, read32be_with_read8_device_handler, ACCESSING_BITS_24_31 ) |
| 723 | | |
| 724 | | |
| 725 | | #define DEV_WRITE8TO32BE_MSB( name, write8 ) \ |
| 726 | | DEV_WRITE_TEMPLATE_COND( 32, name, write8, write32be_with_write8_device_handler, ACCESSING_BITS_24_31 ) |
| 727 | | |
| 728 | | |
| 729 | | #define DEV_READWRITE8TO32BE_MSB( name, read8, write8 ) \ |
| 730 | | DEV_READ8TO32BE_MSB(name,read8) \ |
| 731 | | DEV_WRITE8TO32BE_MSB(name,write8) |
| 732 | | |
| 733 | | |
| 734 | | /************************************* |
| 735 | | * 8->32le, MSB mapping |
| 736 | | ************************************/ |
| 737 | | |
| 738 | | #define DEV_READ8TO32LE_MSB( name, read8 ) \ |
| 739 | | DEV_READ_TEMPLATE_COND( 32, name, read8, read32le_with_read8_device_handler, ACCESSING_BITS_24_31 ) |
| 740 | | |
| 741 | | |
| 742 | | #define DEV_WRITE8TO32LE_MSB( name, write8 ) \ |
| 743 | | DEV_WRITE_TEMPLATE_COND( 32, name, write8, write32le_with_write8_device_handler, ACCESSING_BITS_24_31 ) |
| 744 | | |
| 745 | | |
| 746 | | #define DEV_READWRITE8TO32LE_MSB( name, read8, write8 ) \ |
| 747 | | DEV_READ8TO32LE_MSB(name,read8) \ |
| 748 | | DEV_WRITE8TO32LE_MSB(name,write8) |
| 749 | | |
| 750 | | |
| 751 | | /************************************* |
| 752 | | * 8->32be, LSB mapping |
| 753 | | ************************************/ |
| 754 | | |
| 755 | | #define DEV_READ8TO32BE_LSB( name, read8 ) \ |
| 756 | | DEV_READ_TEMPLATE_COND( 32, name, read8, read32be_with_read8_device_handler, ACCESSING_BITS_0_7 ) |
| 757 | | |
| 758 | | |
| 759 | | #define DEV_WRITE8TO32BE_LSB( name, write8 ) \ |
| 760 | | DEV_WRITE_TEMPLATE_COND( 32, name, write8, write32be_with_write8_device_handler, ACCESSING_BITS_0_7 ) |
| 761 | | |
| 762 | | |
| 763 | | #define DEV_READWRITE8TO32BE_LSB( name, read8, write8 ) \ |
| 764 | | DEV_READ8TO32BE_LSB(name,read8) \ |
| 765 | | DEV_WRITE8TO32BE_LSB(name,write8) |
| 766 | | |
| 767 | | |
| 768 | | /************************************* |
| 769 | | * 8->32le, LSB mapping |
| 770 | | ************************************/ |
| 771 | | |
| 772 | | #define DEV_READ8TO32LE_LSB( name, read8 ) \ |
| 773 | | DEV_READ_TEMPLATE_COND( 32, name, read8, read32le_with_read8_device_handler, ACCESSING_BITS_0_7 ) |
| 774 | | |
| 775 | | |
| 776 | | #define DEV_WRITE8TO32LE_LSB( name, write8 ) \ |
| 777 | | DEV_WRITE_TEMPLATE_COND( 32, name, write8, write32le_with_write8_device_handler, ACCESSING_BITS_0_7 ) |
| 778 | | |
| 779 | | |
| 780 | | #define DEV_READWRITE8TO32LE_LSB( name, read8, write8 ) \ |
| 781 | | DEV_READ8TO32LE_LSB(name,read8) \ |
| 782 | | DEV_WRITE8TO32LE_LSB(name,write8) |
| 783 | | |
| 784 | | |
| 785 | | /************************************* |
| 786 | | * 8->64be, 1:1 mapping |
| 787 | | ************************************/ |
| 788 | | |
| 789 | | #define DEV_READ8TO64BE( name, read8 ) \ |
| 790 | | DEV_READ_TEMPLATE( 64, name, read8, read64be_with_read8_device_handler ) |
| 791 | | |
| 792 | | |
| 793 | | #define DEV_WRITE8TO64BE( name, write8 ) \ |
| 794 | | DEV_WRITE_TEMPLATE( 64, name, write8, write64be_with_write8_device_handler ) |
| 795 | | |
| 796 | | |
| 797 | | #define DEV_READWRITE8TO64BE( name, read8, write8 ) \ |
| 798 | | DEV_READ8TO64BE(name,read8) \ |
| 799 | | DEV_WRITE8TO64BE(name,write8) |
| 800 | | |
| 801 | | |
| 802 | | /************************************* |
| 803 | | * 8->64le, 1:1 mapping |
| 804 | | ************************************/ |
| 805 | | |
| 806 | | #define DEV_READ8TO64LE( name, read8 ) \ |
| 807 | | DEV_READ_TEMPLATE( 64, name, read8, read64le_with_read8_device_handler ) |
| 808 | | |
| 809 | | |
| 810 | | #define DEV_WRITE8TO64LE( name, write8 ) \ |
| 811 | | DEV_WRITE_TEMPLATE( 64, name, write8, write64le_with_write8_device_handler ) |
| 812 | | |
| 813 | | |
| 814 | | #define DEV_READWRITE8TO64LE( name, read8, write8 ) \ |
| 815 | | DEV_READ8TO64LE(name,read8) \ |
| 816 | | DEV_WRITE8TO64LE(name,write8) |
| 817 | | |
| 818 | | |
| 819 | | /************************************* |
| 820 | | * 16be->32be, 1:1 mapping |
| 821 | | *************************************/ |
| 822 | | |
| 823 | | #define DEV_READ16BETO32BE( name, read16 ) \ |
| 824 | | DEV_READ_TEMPLATE( 32, name, read16, read32be_with_16be_device_handler ) |
| 825 | | |
| 826 | | |
| 827 | | #define DEV_WRITE16BETO32BE( name, write16 ) \ |
| 828 | | DEV_WRITE_TEMPLATE( 32, name, write16, write32be_with_16be_device_handler ) |
| 829 | | |
| 830 | | |
| 831 | | #define DEV_READWRITE16BETO32BE( name, read16, write16 ) \ |
| 832 | | DEV_READ16BETO32BE(name,read16) \ |
| 833 | | DEV_WRITE16BETO32BE(name,write16) |
| 834 | | |
| 835 | | |
| 836 | | /************************************* |
| 837 | | * 16le->32be, 1:1 mapping |
| 838 | | *************************************/ |
| 839 | | |
| 840 | | #define DEV_READ16LETO32BE( name, read16 ) \ |
| 841 | | DEV_READ_TEMPLATE( 32, name, read16, read32be_with_16le_device_handler ) |
| 842 | | |
| 843 | | |
| 844 | | #define DEV_WRITE16LETO32BE( name, write16 ) \ |
| 845 | | DEV_WRITE_TEMPLATE( 32, name, write16, write32be_with_16le_device_handler ) |
| 846 | | |
| 847 | | |
| 848 | | #define DEV_READWRITE16LETO32BE( name, read16, write16 ) \ |
| 849 | | DEV_READ16LETO32BE(name,read16) \ |
| 850 | | DEV_WRITE16LETO32BE(name,write16) |
| 851 | | |
| 852 | | |
| 853 | | /************************************* |
| 854 | | * 16be->32le, 1:1 mapping |
| 855 | | *************************************/ |
| 856 | | |
| 857 | | #define DEV_READ16BETO32LE( name, read16 ) \ |
| 858 | | DEV_READ_TEMPLATE( 32, name, read16, read32le_with_16be_device_handler ) |
| 859 | | |
| 860 | | |
| 861 | | #define DEV_WRITE16BETO32LE( name, write16 ) \ |
| 862 | | DEV_WRITE_TEMPLATE( 32, name, write16, write32le_with_16be_device_handler ) |
| 863 | | |
| 864 | | |
| 865 | | #define DEV_READWRITE16BETO32LE( name, read16, write16 ) \ |
| 866 | | DEV_READ16BETO32LE(name,read16) \ |
| 867 | | DEV_WRITE16BETO32LE(name,write16) |
| 868 | | |
| 869 | | |
| 870 | | /************************************* |
| 871 | | * 16le->32le, 1:1 mapping |
| 872 | | *************************************/ |
| 873 | | |
| 874 | | #define DEV_READ16LETO32LE( name, read16 ) \ |
| 875 | | DEV_READ_TEMPLATE( 32, name, read16, read32le_with_16le_device_handler ) |
| 876 | | |
| 877 | | |
| 878 | | #define DEV_WRITE16LETO32LE( name, write16 ) \ |
| 879 | | DEV_WRITE_TEMPLATE( 32, name, write16, write32le_with_16le_device_handler ) |
| 880 | | |
| 881 | | |
| 882 | | #define DEV_READWRITE16LETO32LE( name, read16, write16 ) \ |
| 883 | | DEV_READ16LETO32LE(name,read16) \ |
| 884 | | DEV_WRITE16LETO32LE(name,write16) |
| 885 | | |
| 886 | | |
| 887 | | /************************************* |
| 888 | | * 16be->32be, MSW mapping |
| 889 | | *************************************/ |
| 890 | | |
| 891 | | #define DEV_READ16BETO32BE_MSW( name, read16 ) \ |
| 892 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32be_with_16be_device_handler, ACCESSING_BITS_16_31 ) |
| 893 | | |
| 894 | | |
| 895 | | #define DEV_WRITE16BETO32BE_MSW( name, write16 ) \ |
| 896 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16be_device_handler, ACCESSING_BITS_16_31 ) |
| 897 | | |
| 898 | | |
| 899 | | #define DEV_READWRITE16BETO32BE_MSW( name, read16, write16 ) \ |
| 900 | | DEV_READ16BETO32BE_MSW(name,read16) \ |
| 901 | | DEV_WRITE16BETO32BE_MSW(name,write16) |
| 902 | | |
| 903 | | |
| 904 | | /************************************* |
| 905 | | * 16le->32be, MSW mapping |
| 906 | | *************************************/ |
| 907 | | |
| 908 | | #define DEV_READ16LETO32BE_MSW( name, read16 ) \ |
| 909 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32be_with_16le_device_handler, ACCESSING_BITS_16_31 ) |
| 910 | | |
| 911 | | |
| 912 | | #define DEV_WRITE16LETO32BE_MSW( name, write16 ) \ |
| 913 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16le_device_handler, ACCESSING_BITS_16_31 ) |
| 914 | | |
| 915 | | |
| 916 | | #define DEV_READWRITE16LETO32BE_MSW( name, read16, write16 ) \ |
| 917 | | DEV_READ16LETO32BE_MSW(name,read16) \ |
| 918 | | DEV_WRITE16LETO32BE_MSW(name,write16) |
| 919 | | |
| 920 | | |
| 921 | | /************************************* |
| 922 | | * 16be->32le, MSW mapping |
| 923 | | *************************************/ |
| 924 | | |
| 925 | | #define DEV_READ16BETO32LE_MSW( name, read16 ) \ |
| 926 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32le_with_16be_device_handler, ACCESSING_BITS_16_31 ) |
| 927 | | |
| 928 | | |
| 929 | | #define DEV_WRITE16BETO32LE_MSW( name, write16 ) \ |
| 930 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16be_device_handler, ACCESSING_BITS_16_31 ) |
| 931 | | |
| 932 | | |
| 933 | | #define DEV_READWRITE16BETO32LE_MSW( name, read16, write16 ) \ |
| 934 | | DEV_READ16BETO32LE_MSW(name,read16) \ |
| 935 | | DEV_WRITE16BETO32LE_MSW(name,write16) |
| 936 | | |
| 937 | | |
| 938 | | /************************************* |
| 939 | | * 16le->32le, MSW mapping |
| 940 | | *************************************/ |
| 941 | | |
| 942 | | #define DEV_READ16LETO32LE_MSW( name, read16 ) \ |
| 943 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32le_with_16le_device_handler, ACCESSING_BITS_16_31 ) |
| 944 | | |
| 945 | | |
| 946 | | #define DEV_WRITE16LETO32LE_MSW( name, write16 ) \ |
| 947 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16le_device_handler, ACCESSING_BITS_16_31 ) |
| 948 | | |
| 949 | | |
| 950 | | #define DEV_READWRITE16LETO32LE_MSW( name, read16, write16 ) \ |
| 951 | | DEV_READ16LETO32LE_MSW(name,read16) \ |
| 952 | | DEV_WRITE16LETO32LE_MSW(name,write16) |
| 953 | | |
| 954 | | /************************************* |
| 955 | | * 16be->32be, LSW mapping |
| 956 | | *************************************/ |
| 957 | | |
| 958 | | #define DEV_READ16BETO32BE_LSW( name, read16 ) \ |
| 959 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32be_with_16be_device_handler, ACCESSING_BITS_0_15 ) |
| 960 | | |
| 961 | | |
| 962 | | #define DEV_WRITE16BETO32BE_LSW( name, write16 ) \ |
| 963 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16be_device_handler, ACCESSING_BITS_0_15 ) |
| 964 | | |
| 965 | | |
| 966 | | #define DEV_READWRITE16BETO32BE_LSW( name, read16, write16 ) \ |
| 967 | | DEV_READ16BETO32BE_LSW(name,read16) \ |
| 968 | | DEV_WRITE16BETO32BE_LSW(name,write16) |
| 969 | | |
| 970 | | |
| 971 | | /************************************* |
| 972 | | * 16le->32be, LSW mapping |
| 973 | | *************************************/ |
| 974 | | |
| 975 | | #define DEV_READ16LETO32BE_LSW( name, read16 ) \ |
| 976 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32be_with_16le_device_handler, ACCESSING_BITS_0_15 ) |
| 977 | | |
| 978 | | |
| 979 | | #define DEV_WRITE16LETO32BE_LSW( name, write16 ) \ |
| 980 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32be_with_16le_device_handler, ACCESSING_BITS_0_15 ) |
| 981 | | |
| 982 | | |
| 983 | | #define DEV_READWRITE16LETO32BE_LSW( name, read16, write16 ) \ |
| 984 | | DEV_READ16LETO32BE_LSW(name,read16) \ |
| 985 | | DEV_WRITE16LETO32BE_LSW(name,write16) |
| 986 | | |
| 987 | | |
| 988 | | /************************************* |
| 989 | | * 16be->32le, LSW mapping |
| 990 | | *************************************/ |
| 991 | | |
| 992 | | #define DEV_READ16BETO32LE_LSW( name, read16 ) \ |
| 993 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32le_with_16be_device_handler, ACCESSING_BITS_0_15 ) |
| 994 | | |
| 995 | | |
| 996 | | #define DEV_WRITE16BETO32LE_LSW( name, write16 ) \ |
| 997 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16be_device_handler, ACCESSING_BITS_0_15 ) |
| 998 | | |
| 999 | | |
| 1000 | | #define DEV_READWRITE16BETO32LE_LSW( name, read16, write16 ) \ |
| 1001 | | DEV_READ16BETO32LE_LSW(name,read16) \ |
| 1002 | | DEV_WRITE16BETO32LE_LSW(name,write16) |
| 1003 | | |
| 1004 | | |
| 1005 | | /************************************* |
| 1006 | | * 16le->32le, LSW mapping |
| 1007 | | *************************************/ |
| 1008 | | |
| 1009 | | #define DEV_READ16LETO32LE_LSW( name, read16 ) \ |
| 1010 | | DEV_READ_TEMPLATE_COND( 32, name, read16, read32le_with_16le_device_handler, ACCESSING_BITS_0_15 ) |
| 1011 | | |
| 1012 | | |
| 1013 | | #define DEV_WRITE16LETO32LE_LSW( name, write16 ) \ |
| 1014 | | DEV_WRITE_TEMPLATE_COND( 32, name, write16, write32le_with_16le_device_handler, ACCESSING_BITS_0_15 ) |
| 1015 | | |
| 1016 | | |
| 1017 | | #define DEV_READWRITE16LETO32LE_LSW( name, read16, write16 ) \ |
| 1018 | | DEV_READ16LETO32LE_LSW(name,read16) \ |
| 1019 | | DEV_WRITE16LETO32LE_LSW(name,write16) |
| 1020 | | |