|
|
uae-0.6.8
/*
* UAE - The Un*x Amiga Emulator
*
* Memory access functions
*
* Copyright 1996 Bernd Schmidt
*/
static __inline__ ULONG do_get_mem_long(ULONG *a)
{
ULONG retval;
__asm__ ("bswapl %0" : "=r" (retval) : "0" (*a) : "cc");
return retval;
}
static __inline__ ULONG do_get_mem_word(UWORD *a)
{
ULONG retval;
__asm__ ("xorl %k0,%k0\n\tmovw %w1,%w0\n\trolw $8,%w0" : "=&r" (retval) : "m" (*a) : "cc");
return retval;
}
static __inline__ UBYTE do_get_mem_byte(UBYTE *a)
{
return *a;
}
static __inline__ void do_put_mem_long(ULONG *a, ULONG v)
{
__asm__ ("bswapl %0" : "=r" (v) : "0" (v) : "cc");
*a = v;
}
static __inline__ void do_put_mem_word(UWORD *a, UWORD v)
{
__asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc");
*a = v;
}
static __inline__ void do_put_mem_byte(UBYTE *a, UBYTE v)
{
*a = v;
}
#if 0
static __inline__ ULONG call_mem_get_func(mem_get_func func, CPTR addr)
{
ULONG result;
__asm__("call *%1"
: "=a" (result) : "r" (func), "a" (addr) : "cc", "edx", "ecx");
return result;
}
static __inline__ void call_mem_put_func(mem_put_func func, CPTR addr, ULONG v)
{
__asm__("call *%2"
: : "a" (addr), "d" (v), "r" (func) : "cc", "eax", "edx", "ecx", "memory");
}
#else
#define call_mem_get_func(func,addr) ((*func)(addr))
#define call_mem_put_func(func,addr,v) ((*func)(addr,v))
#endif
#undef USE_MAPPED_MEMORY
#if USER_PROGRAMS_BEHAVE > 0
#define USE_MAPPED_MEMORY
#endif
#define CAN_MAP_MEMORY
#undef NO_INLINE_MEMORY_ACCESS
#undef MD_HAVE_MEM_1_FUNCS
#if defined(MEMFUNCS_DIRECT_REQUESTED) && USER_PROGRAMS_BEHAVE > 0
#define MD_HAVE_MEM_1_FUNCS
#if USER_PROGRAMS_BEHAVE > 1
#define MAYBE_MASK_ADDR_24BIT(a) (a)
#else
#define MAYBE_MASK_ADDR_24BIT(a) ((a) & 0xFFFFFF)
#endif
static __inline__ ULONG longget_1(CPTR addr) { return do_get_mem_long ((ULONG *)(address_space + MAYBE_MASK_ADDR_24BIT(addr))); }
static __inline__ ULONG wordget_1(CPTR addr) { return do_get_mem_word ((UWORD *)(address_space + MAYBE_MASK_ADDR_24BIT(addr))); }
static __inline__ ULONG byteget_1(CPTR addr) { return do_get_mem_byte (address_space + MAYBE_MASK_ADDR_24BIT(addr)); }
static __inline__ void longput_1(CPTR addr, ULONG l) { do_put_mem_long ((ULONG*)(address_space + MAYBE_MASK_ADDR_24BIT(addr)), l); }
static __inline__ void wordput_1(CPTR addr, ULONG w) { do_put_mem_word ((UWORD *)(address_space + MAYBE_MASK_ADDR_24BIT(addr)), w); }
static __inline__ void byteput_1(CPTR addr, ULONG b) { do_put_mem_byte (address_space + MAYBE_MASK_ADDR_24BIT(addr), b); }
#define DIRECT_MEMFUNCS_SUCCESSFUL
#else /* ! MEMFUNCS_DIRECT_REQUESTED */
#ifdef MD_HAVE_MEM_1_FUNCS
#define alongget_1 longget_1
#define awordget_1 wordget_1
static __inline__ ULONG longget_1(CPTR addr)
{
ULONG result;
__asm__ ("andl $0x00FFFFFF,%1\n"
"\tcmpb $0,(%1,%3)\n"
"\tleal 1f,%%ecx\n"
"\tje longget_stub\n"
"\taddl address_space,%1\n"
"\tmovl (%1),%0\n"
"\tbswapl %0\n"
"\t1:"
: "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
return result;
}
static __inline__ ULONG wordget_1(CPTR addr)
{
ULONG result;
__asm__ ("andl $0x00FFFFFF,%1\n"
"\tcmpb $0,(%1,%3)\n"
"\tleal 1f,%%ecx\n"
"\tje wordget_stub\n"
"\taddl address_space,%1\n"
"\tmovzwl (%1),%0\n"
"\trolw $8,%w0\n"
"\t1:"
: "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
return result;
}
static __inline__ ULONG byteget_1(CPTR addr)
{
ULONG result;
__asm__ ("andl $0x00FFFFFF,%1\n"
"\tcmpb $0,(%1,%3)\n"
"\tleal 1f,%%ecx\n"
"\tje byteget_stub\n"
"\taddl address_space,%1\n"
"\tmovzbl (%1),%0\n"
"\t1:"
: "=c" (result), "=d" (addr) : "1" (addr), "r" (good_address_map) : "cc");
return result;
}
static __inline__ void longput_1(CPTR addr, ULONG l)
{
__asm__ __volatile__("andl $0x00FFFFFF,%0\n"
"\tcmpb $0,(%0,%3)\n"
"\tleal 1f,%%ecx\n"
"\tje longput_stub\n"
"\taddl address_space,%0\n"
"\tbswapl %1\n"
"\tmovl %1,(%0)\n"
"\t1:"
: "=d" (addr), "=b" (l) : "0" (addr), "r" (good_address_map), "1" (l) : "cc", "memory", "ecx");
}
static __inline__ void wordput_1(CPTR addr, ULONG w)
{
__asm__ __volatile__("andl $0x00FFFFFF,%0\n"
"\tcmpb $0,(%0,%3)\n"
"\tleal 1f,%%ecx\n"
"\tje wordput_stub\n"
"\taddl address_space,%0\n"
"\trolw $8,%1\n"
"\tmovw %w1,(%0)\n"
"\t1:"
: "=d" (addr), "=b" (w) : "0" (addr), "r" (good_address_map), "1" (w) : "cc", "memory", "ecx");
}
static __inline__ void byteput_1(CPTR addr, ULONG b)
{
__asm__ __volatile__("andl $0x00FFFFFF,%0\n"
"\tcmpb $0,(%0,%3)\n"
"\tleal 1f,%%ecx\n"
"\tje byteput_stub\n"
"\taddl address_space,%0\n"
"\tmovb %b1,(%0)\n"
"\t1:"
: "=d" (addr), "=b" (b) : "0" (addr), "r" (good_address_map), "1" (b) : "cc", "memory", "ecx");
}
#endif
#endif /* ! MEMFUNCS_DIRECT_REQUESTED */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.