|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
4: * Memory access functions
5: *
6: * Copyright 1996 Bernd Schmidt
7: */
8:
9:
10: static __inline__ ULONG do_get_mem_long(ULONG *a)
11: {
12: ULONG retval;
13:
14: __asm__ ("bswapl %0" : "=r" (retval) : "0" (*a) : "cc");
15: return retval;
16: }
17:
18: static __inline__ ULONG do_get_mem_word(UWORD *a)
19: {
20: ULONG retval;
21:
22: __asm__ ("xorl %k0,%k0\n\tmovw %w1,%w0\n\trolw $8,%w0" : "=&r" (retval) : "m" (*a) : "cc");
23: return retval;
24: }
25:
26: static __inline__ UBYTE do_get_mem_byte(UBYTE *a)
27: {
28: return *a;
29: }
30:
31: static __inline__ void do_put_mem_long(ULONG *a, ULONG v)
32: {
33: __asm__ ("bswapl %0" : "=r" (v) : "0" (v) : "cc");
34: *a = v;
35: }
36:
37: static __inline__ void do_put_mem_word(UWORD *a, UWORD v)
38: {
39: __asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc");
40: *a = v;
41: }
42:
43: static __inline__ void do_put_mem_byte(UBYTE *a, UBYTE v)
44: {
45: *a = v;
46: }
47:
48: #if 0
49: static __inline__ ULONG call_mem_get_func(mem_get_func func, CPTR addr)
50: {
51: ULONG result;
52: __asm__("call *%1"
53: : "=a" (result) : "r" (func), "a" (addr) : "cc", "edx", "ecx");
54: return result;
55: }
56:
57: static __inline__ void call_mem_put_func(mem_put_func func, CPTR addr, ULONG v)
58: {
59: __asm__("call *%2"
60: : : "a" (addr), "d" (v), "r" (func) : "cc", "eax", "edx", "ecx", "memory");
61: }
62: #else
63:
64: #define call_mem_get_func(func,addr) ((*func)(addr))
65: #define call_mem_put_func(func,addr,v) ((*func)(addr,v))
66:
67: #endif
68:
69: #undef USE_MAPPED_MEMORY
70:
71: #if USER_PROGRAMS_BEHAVE > 0
72: #define USE_MAPPED_MEMORY
73: #endif
74:
75: #define CAN_MAP_MEMORY
76: #undef NO_INLINE_MEMORY_ACCESS
77: #undef MD_HAVE_MEM_1_FUNCS
78:
79:
80: #if defined(MEMFUNCS_DIRECT_REQUESTED) && USER_PROGRAMS_BEHAVE > 0
81:
82: #define MD_HAVE_MEM_1_FUNCS
83:
84: #if USER_PROGRAMS_BEHAVE > 1
85: #define MAYBE_MASK_ADDR_24BIT(a) (a)
86: #else
87: #define MAYBE_MASK_ADDR_24BIT(a) ((a) & 0xFFFFFF)
88: #endif
89:
90: static __inline__ ULONG longget_1(CPTR addr) { return do_get_mem_long ((ULONG *)(address_space + MAYBE_MASK_ADDR_24BIT(addr))); }
91: static __inline__ ULONG wordget_1(CPTR addr) { return do_get_mem_word ((UWORD *)(address_space + MAYBE_MASK_ADDR_24BIT(addr))); }
92: static __inline__ ULONG byteget_1(CPTR addr) { return do_get_mem_byte (address_space + MAYBE_MASK_ADDR_24BIT(addr)); }
93: static __inline__ void longput_1(CPTR addr, ULONG l) { do_put_mem_long ((ULONG*)(address_space + MAYBE_MASK_ADDR_24BIT(addr)), l); }
94: static __inline__ void wordput_1(CPTR addr, ULONG w) { do_put_mem_word ((UWORD *)(address_space + MAYBE_MASK_ADDR_24BIT(addr)), w); }
95: static __inline__ void byteput_1(CPTR addr, ULONG b) { do_put_mem_byte (address_space + MAYBE_MASK_ADDR_24BIT(addr), b); }
96:
97: #define DIRECT_MEMFUNCS_SUCCESSFUL
98:
99: #else /* ! MEMFUNCS_DIRECT_REQUESTED */
100:
101: #ifdef MD_HAVE_MEM_1_FUNCS
102:
103: #define alongget_1 longget_1
104: #define awordget_1 wordget_1
105:
106: static __inline__ ULONG longget_1(CPTR addr)
107: {
108: ULONG result;
109:
110: __asm__ ("andl $0x00FFFFFF,%1\n"
111: "\tcmpb $0,(%1,%3)\n"
112: "\tleal 1f,%%ecx\n"
113: "\tje longget_stub\n"
114: "\taddl address_space,%1\n"
115: "\tmovl (%1),%0\n"
116: "\tbswapl %0\n"
117: "\t1:"
118: : "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
119: return result;
120: }
121: static __inline__ ULONG wordget_1(CPTR addr)
122: {
123: ULONG result;
124:
125: __asm__ ("andl $0x00FFFFFF,%1\n"
126: "\tcmpb $0,(%1,%3)\n"
127: "\tleal 1f,%%ecx\n"
128: "\tje wordget_stub\n"
129: "\taddl address_space,%1\n"
130: "\tmovzwl (%1),%0\n"
131: "\trolw $8,%w0\n"
132: "\t1:"
133: : "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
134: return result;
135: }
136: static __inline__ ULONG byteget_1(CPTR addr)
137: {
138: ULONG result;
139:
140: __asm__ ("andl $0x00FFFFFF,%1\n"
141: "\tcmpb $0,(%1,%3)\n"
142: "\tleal 1f,%%ecx\n"
143: "\tje byteget_stub\n"
144: "\taddl address_space,%1\n"
145: "\tmovzbl (%1),%0\n"
146: "\t1:"
147: : "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
148: return result;
149: }
150: static __inline__ void longput_1(CPTR addr, ULONG l)
151: {
152: __asm__ __volatile__("andl $0x00FFFFFF,%0\n"
153: "\tcmpb $0,(%0,%3)\n"
154: "\tleal 1f,%%ecx\n"
155: "\tje longput_stub\n"
156: "\taddl address_space,%0\n"
157: "\tbswapl %1\n"
158: "\tmovl %1,(%0)\n"
159: "\t1:"
160: : "=d" (addr), "=b" (l) : "0" (addr), "r" (good_address_map), "1" (l) : "cc", "memory", "ecx");
161: }
162: static __inline__ void wordput_1(CPTR addr, ULONG w)
163: {
164: __asm__ __volatile__("andl $0x00FFFFFF,%0\n"
165: "\tcmpb $0,(%0,%3)\n"
166: "\tleal 1f,%%ecx\n"
167: "\tje wordput_stub\n"
168: "\taddl address_space,%0\n"
169: "\trolw $8,%1\n"
170: "\tmovw %w1,(%0)\n"
171: "\t1:"
172: : "=d" (addr), "=b" (w) : "0" (addr), "r" (good_address_map), "1" (w) : "cc", "memory", "ecx");
173: }
174: static __inline__ void byteput_1(CPTR addr, ULONG b)
175: {
176: __asm__ __volatile__("andl $0x00FFFFFF,%0\n"
177: "\tcmpb $0,(%0,%3)\n"
178: "\tleal 1f,%%ecx\n"
179: "\tje byteput_stub\n"
180: "\taddl address_space,%0\n"
181: "\tmovb %b1,(%0)\n"
182: "\t1:"
183: : "=d" (addr), "=b" (b) : "0" (addr), "r" (good_address_map), "1" (b) : "cc", "memory", "ecx");
184: }
185:
186: #endif
187:
188: #endif /* ! MEMFUNCS_DIRECT_REQUESTED */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.