|
|
1.1.1.3 root 1: /*
2: * UAE - The Un*x Amiga Emulator - CPU core
3: *
4: * Big endian memory access functions.
1.1 root 5: *
6: * Copyright 1996 Bernd Schmidt
1.1.1.3 root 7: *
8: * Adaptation to Hatari by Thomas Huth, Eero Tamminen
9: *
1.1.1.5 root 10: * This file is distributed under the GNU General Public License, version 2
11: * or at your option any later version. Read the file gpl.txt for details.
1.1 root 12: */
13:
1.1.1.2 root 14: #ifndef UAE_MACCESS_H
15: #define UAE_MACCESS_H
16:
17:
1.1.1.3 root 18: /* Can the actual CPU access unaligned memory? */
19: #ifndef CPU_CAN_ACCESS_UNALIGNED
1.1.1.6 ! root 20: # if defined(__i386__) || defined(__x86_64__) || defined(__mc68020__) || \
! 21: defined(powerpc) || defined(__ppc__) || defined(__ppc64__)
1.1.1.3 root 22: # define CPU_CAN_ACCESS_UNALIGNED 1
23: # else
24: # define CPU_CAN_ACCESS_UNALIGNED 0
25: # endif
26: #endif
27:
28:
29: /* If the CPU can access unaligned memory, use these accelerated functions: */
30: #if CPU_CAN_ACCESS_UNALIGNED
31:
32: #include <SDL_endian.h>
33:
34:
1.1.1.4 root 35: static inline uae_u32 do_get_mem_long(void *a)
1.1 root 36: {
1.1.1.4 root 37: return SDL_SwapBE32(*(uae_u32 *)a);
1.1 root 38: }
39:
1.1.1.4 root 40: static inline uae_u16 do_get_mem_word(void *a)
1.1 root 41: {
1.1.1.4 root 42: return SDL_SwapBE16(*(uae_u16 *)a);
1.1 root 43: }
44:
1.1.1.3 root 45:
1.1.1.4 root 46: static inline void do_put_mem_long(void *a, uae_u32 v)
1.1 root 47: {
1.1.1.4 root 48: *(uae_u32 *)a = SDL_SwapBE32(v);
1.1 root 49: }
50:
1.1.1.4 root 51: static inline void do_put_mem_word(void *a, uae_u16 v)
1.1 root 52: {
1.1.1.4 root 53: *(uae_u16 *)a = SDL_SwapBE16(v);
1.1 root 54: }
55:
1.1.1.3 root 56:
57: #else /* Cpu can not access unaligned memory: */
58:
59:
1.1.1.4 root 60: static inline uae_u32 do_get_mem_long(void *a)
1.1 root 61: {
1.1.1.3 root 62: uae_u8 *b = (uae_u8 *)a;
63:
64: return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
1.1 root 65: }
66:
1.1.1.4 root 67: static inline uae_u16 do_get_mem_word(void *a)
1.1 root 68: {
1.1.1.3 root 69: uae_u8 *b = (uae_u8 *)a;
70:
71: return (b[0] << 8) | b[1];
1.1 root 72: }
73:
74:
1.1.1.4 root 75: static inline void do_put_mem_long(void *a, uae_u32 v)
1.1.1.3 root 76: {
77: uae_u8 *b = (uae_u8 *)a;
78:
79: b[0] = v >> 24;
80: b[1] = v >> 16;
81: b[2] = v >> 8;
82: b[3] = v;
83: }
84:
1.1.1.4 root 85: static inline void do_put_mem_word(void *a, uae_u16 v)
1.1.1.3 root 86: {
87: uae_u8 *b = (uae_u8 *)a;
88:
89: b[0] = v >> 8;
90: b[1] = v;
91: }
92:
93:
94: #endif /* CPU_CAN_ACCESS_UNALIGNED */
95:
96:
97: /* These are same for all architectures: */
98:
99: static inline uae_u8 do_get_mem_byte(uae_u8 *a)
100: {
101: return *a;
102: }
103:
104: static inline void do_put_mem_byte(uae_u8 *a, uae_u8 v)
105: {
106: *a = v;
107: }
1.1 root 108:
1.1.1.2 root 109:
110: #endif /* UAE_MACCESS_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.