1 From 74ab27f64a747ee45810f99cdc6e29b82cf8035e Mon Sep 17 00:00:00 2001
2 From: Tiago Vignatti <tiago.vignatti@nokia.com>
3 Date: Mon, 28 Dec 2009 16:00:28 +0000
4 Subject: Revert "Make sys.c use unaligned access functions provided in compiler."
6 This reverts commit da923d0bc15e99a8ed1986bd6f5df37f7af7284b.
8 Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
9 Signed-off-by: Keith Packard <keithp@keithp.com>
11 diff --git a/hw/xfree86/x86emu/Makefile.am b/hw/xfree86/x86emu/Makefile.am
12 index e7368f5..df96977 100644
13 --- a/hw/xfree86/x86emu/Makefile.am
14 +++ b/hw/xfree86/x86emu/Makefile.am
15 @@ -11,7 +11,7 @@ libx86emu_la_SOURCES = debug.c \
19 -INCLUDES = $(XORG_INCS)
22 AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
24 diff --git a/hw/xfree86/x86emu/sys.c b/hw/xfree86/x86emu/sys.c
25 index 2ebf6f1..e15fb09 100644
26 --- a/hw/xfree86/x86emu/sys.c
27 +++ b/hw/xfree86/x86emu/sys.c
29 #ifndef NO_SYS_HEADERS
32 -#include "compiler.h" /* for unaligned access functions */
33 /*------------------------- Global Variables ------------------------------*/
35 X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */
36 X86EMU_intrFuncs _X86EMU_intrTab[256];
38 /*----------------------------- Implementation ----------------------------*/
39 +#if defined(__alpha__) || defined(__alpha)
40 +/* to cope with broken egcs-1.1.2 :-(((( */
42 +#define ALPHA_UALOADS
44 + * inline functions to do unaligned accesses
45 + * from linux/include/asm-alpha/unaligned.h
49 + * EGCS 1.1 knows about arbitrary unaligned loads. Define some
50 + * packed structures to talk about such things with.
53 +#if defined(__GNUC__)
54 +struct __una_u64 { unsigned long x __attribute__((packed)); };
55 +struct __una_u32 { unsigned int x __attribute__((packed)); };
56 +struct __una_u16 { unsigned short x __attribute__((packed)); };
59 +static __inline__ unsigned long ldq_u(unsigned long * r11)
61 +#if defined(__GNUC__)
62 + const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
65 + unsigned long r1,r2;
66 + __asm__("ldq_u %0,%3\n\t"
68 + "extql %0,%2,%0\n\t"
70 + :"=&r" (r1), "=&r" (r2)
73 + "m" (*(const unsigned long *)(7+(char *) r11)));
78 +static __inline__ unsigned long ldl_u(unsigned int * r11)
80 +#if defined(__GNUC__)
81 + const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
84 + unsigned long r1,r2;
85 + __asm__("ldq_u %0,%3\n\t"
87 + "extll %0,%2,%0\n\t"
89 + :"=&r" (r1), "=&r" (r2)
92 + "m" (*(const unsigned long *)(3+(char *) r11)));
97 +static __inline__ unsigned long ldw_u(unsigned short * r11)
99 +#if defined(__GNUC__)
100 + const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
103 + unsigned long r1,r2;
104 + __asm__("ldq_u %0,%3\n\t"
106 + "extwl %0,%2,%0\n\t"
108 + :"=&r" (r1), "=&r" (r2)
111 + "m" (*(const unsigned long *)(1+(char *) r11)));
117 + * Elemental unaligned stores
120 +static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
122 +#if defined(__GNUC__)
123 + struct __una_u64 *ptr = (struct __una_u64 *) r11;
126 + unsigned long r1,r2,r3,r4;
128 + __asm__("ldq_u %3,%1\n\t"
130 + "insqh %6,%7,%5\n\t"
131 + "insql %6,%7,%4\n\t"
132 + "mskqh %3,%7,%3\n\t"
133 + "mskql %2,%7,%2\n\t"
139 + "=m" (*(unsigned long *)(7+(char *) r11)),
140 + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
141 + :"r" (r5), "r" (r11));
145 +static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
147 +#if defined(__GNUC__)
148 + struct __una_u32 *ptr = (struct __una_u32 *) r11;
151 + unsigned long r1,r2,r3,r4;
153 + __asm__("ldq_u %3,%1\n\t"
155 + "inslh %6,%7,%5\n\t"
156 + "insll %6,%7,%4\n\t"
157 + "msklh %3,%7,%3\n\t"
158 + "mskll %2,%7,%2\n\t"
164 + "=m" (*(unsigned long *)(3+(char *) r11)),
165 + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
166 + :"r" (r5), "r" (r11));
170 +static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
172 +#if defined(__GNUC__)
173 + struct __una_u16 *ptr = (struct __una_u16 *) r11;
176 + unsigned long r1,r2,r3,r4;
178 + __asm__("ldq_u %3,%1\n\t"
180 + "inswh %6,%7,%5\n\t"
181 + "inswl %6,%7,%4\n\t"
182 + "mskwh %3,%7,%3\n\t"
183 + "mskwl %2,%7,%2\n\t"
189 + "=m" (*(unsigned long *)(1+(char *) r11)),
190 + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
191 + :"r" (r5), "r" (r11));
196 /****************************************************************************
198 @@ -107,7 +262,13 @@ u16 X86API rdw(
202 +#if defined(ALPHA_UALOADS)
203 val = ldw_u((u16*)(M.mem_base + addr));
204 +#elif defined(IA64_UALOADS)
205 + val = uldw((u16*)(M.mem_base + addr));
207 + val = *(u16*)(M.mem_base + addr);
209 DB( if (DEBUG_MEM_TRACE())
210 printk("%#08x 2 -> %#x\n", addr, val);)
212 @@ -140,7 +301,13 @@ u32 X86API rdl(
216 +#if defined(ALPHA_UALOADS)
217 val = ldl_u((u32*)(M.mem_base + addr));
218 +#elif defined(IA64_UALOADS)
219 + val = uldl((u32*)(M.mem_base + addr));
221 + val = *(u32*)(M.mem_base + addr);
223 DB( if (DEBUG_MEM_TRACE())
224 printk("%#08x 4 -> %#x\n", addr, val);)
226 @@ -192,7 +359,13 @@ DB( if (DEBUG_MEM_TRACE())
230 +#if defined(ALPHA_UALOADS)
231 stw_u(val,(u16*)(M.mem_base + addr));
232 +#elif defined(IA64_UALOADS)
233 + ustw(val,(u16*)(M.mem_base + addr));
235 + *(u16*)(M.mem_base + addr) = val;
239 /****************************************************************************
240 @@ -222,7 +395,13 @@ DB( if (DEBUG_MEM_TRACE())
244 +#if defined(ALPHA_UALOADS)
245 stl_u(val,(u32*)(M.mem_base + addr));
246 +#elif defined(IA64_UALOADS)
247 + ustl(val,(u32*)(M.mem_base + addr));
249 + *(u32*)(M.mem_base + addr) = val;
253 /****************************************************************************