|
|
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: static __inline__ uae_u32 do_get_mem_long (uae_u32 *a)
10: {
11: uae_u32 retval;
12:
13: __asm__ ("bswapl %0" : "=r" (retval) : "0" (*a) : "cc");
14: return retval;
15: }
16:
17: static __inline__ uae_u32 do_get_mem_word (uae_u16 *a)
18: {
19: uae_u32 retval;
20:
21: #ifdef X86_PPRO_OPT
22: __asm__ ("movzwl %w1,%k0\n\tshll $16,%k0\n\tbswapl %k0\n" : "=&r" (retval) : "m" (*a) : "cc");
23: #else
24: __asm__ ("xorl %k0,%k0\n\tmovw %w1,%w0\n\trolw $8,%w0" : "=&r" (retval) : "m" (*a) : "cc");
25: #endif
26: return retval;
27: }
28:
29: #define HAVE_GET_WORD_UNSWAPPED
30:
31: #define do_get_mem_word_unswapped(a) ((uae_u32)*((uae_u16 *)a))
32: #define do_get_mem_byte(a) ((uae_u32)*((uae_u8 *)a))
33:
34: static __inline__ void do_put_mem_long (uae_u32 *a, uae_u32 v)
35: {
36: __asm__ ("bswapl %0" : "=r" (v) : "0" (v) : "cc");
37: *a = v;
38: }
39:
40: static __inline__ void do_put_mem_word (uae_u16 *a, uae_u32 v)
41: {
42: #ifdef X86_PPRO_OPT
43: __asm__ ("bswapl %0" : "=&r" (v) : "0" (v << 16) : "cc");
44: #else
45: __asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc");
46: #endif
47: *a = v;
48: }
49:
50: #define do_put_mem_byte(a,v) (*(uae_u8 *)(a) = (v))
51:
52: #if 0
53: static __inline__ uae_u32 call_mem_get_func(mem_get_func func, uae_cptr addr)
54: {
55: uae_u32 result;
56: __asm__("call *%1"
57: : "=a" (result) : "r" (func), "a" (addr) : "cc", "edx", "ecx");
58: return result;
59: }
60:
61: static __inline__ void call_mem_put_func(mem_put_func func, uae_cptr addr, uae_u32 v)
62: {
63: __asm__("call *%2"
64: : : "a" (addr), "d" (v), "r" (func) : "cc", "eax", "edx", "ecx", "memory");
65: }
66: #else
67:
68: #define call_mem_get_func(func,addr) ((*func)(addr))
69: #define call_mem_put_func(func,addr,v) ((*func)(addr,v))
70:
71: #endif
72:
73: #undef NO_INLINE_MEMORY_ACCESS
74: #undef MD_HAVE_MEM_1_FUNCS
75:
76: #ifdef MD_HAVE_MEM_1_FUNCS
77: static __inline__ uae_u32 longget_1 (uae_cptr addr)
78: {
79: uae_u32 result;
80:
81: __asm__ ("andl $0x00FFFFFF,%1\n"
82: "\tcmpb $0,(%1,%3)\n"
83: "\tleal 1f,%%ecx\n"
84: "\tje longget_stub\n"
85: "\taddl address_space,%1\n"
86: "\tmovl (%1),%0\n"
87: "\tbswapl %0\n"
88: "\t1:"
89: : "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
90: return result;
91: }
92: static __inline__ uae_u32 wordget_1 (uae_cptr addr)
93: {
94: uae_u32 result;
95:
96: __asm__ ("andl $0x00FFFFFF,%1\n"
97: "\tcmpb $0,(%1,%3)\n"
98: "\tleal 1f,%%ecx\n"
99: "\tje wordget_stub\n"
100: "\taddl address_space,%1\n"
101: "\tmovzwl (%1),%0\n"
102: "\trolw $8,%w0\n"
103: "\t1:"
104: : "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
105: return result;
106: }
107: static __inline__ uae_u32 byteget_1 (uae_cptr addr)
108: {
109: uae_u32 result;
110:
111: __asm__ ("andl $0x00FFFFFF,%1\n"
112: "\tcmpb $0,(%1,%3)\n"
113: "\tleal 1f,%%ecx\n"
114: "\tje byteget_stub\n"
115: "\taddl address_space,%1\n"
116: "\tmovzbl (%1),%0\n"
117: "\t1:"
118: : "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
119: return result;
120: }
121: static __inline__ void longput_1 (uae_cptr addr, uae_u32 l)
122: {
123: __asm__ __volatile__("andl $0x00FFFFFF,%0\n"
124: "\tcmpb $0,(%0,%3)\n"
125: "\tleal 1f,%%ecx\n"
126: "\tje longput_stub\n"
127: "\taddl address_space,%0\n"
128: "\tbswapl %1\n"
129: "\tmovl %1,(%0)\n"
130: "\t1:"
131: : "=d" (addr), "=b" (l) : "0" (addr), "r" (good_address_map), "1" (l) : "cc", "memory", "ecx");
132: }
133: static __inline__ void wordput_1 (uae_cptr addr, uae_u32 w)
134: {
135: __asm__ __volatile__("andl $0x00FFFFFF,%0\n"
136: "\tcmpb $0,(%0,%3)\n"
137: "\tleal 1f,%%ecx\n"
138: "\tje wordput_stub\n"
139: "\taddl address_space,%0\n"
140: "\trolw $8,%1\n"
141: "\tmovw %w1,(%0)\n"
142: "\t1:"
143: : "=d" (addr), "=b" (w) : "0" (addr), "r" (good_address_map), "1" (w) : "cc", "memory", "ecx");
144: }
145: static __inline__ void byteput_1 (uae_cptr addr, uae_u32 b)
146: {
147: __asm__ __volatile__("andl $0x00FFFFFF,%0\n"
148: "\tcmpb $0,(%0,%3)\n"
149: "\tleal 1f,%%ecx\n"
150: "\tje byteput_stub\n"
151: "\taddl address_space,%0\n"
152: "\tmovb %b1,(%0)\n"
153: "\t1:"
154: : "=d" (addr), "=b" (b) : "0" (addr), "r" (good_address_map), "1" (b) : "cc", "memory", "ecx");
155: }
156:
157: #endif
158:
159: #define ALIGN_POINTER_TO32(p) ((~(unsigned long)(p)) & 3)
160:
161: /* Not the best place for this, but then there's no good place for a kludge
162: * like this... */
163: #define HAVE_UAE_U24
164: typedef struct {
165: unsigned char a, b, c;
166: } __attribute__ ((packed)) uae_u24;
167:
168: static __inline__ uae_u24 uae24_convert (uae_u32 v)
169: {
170: return *(uae_u24 *)&v;
171: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.