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