XFree86 generic.c problem
hello,linux-mips
When trying to crossing compile XFree86 server for my linux on mipselmachine(idt64474,p6032) i find some problems:
1. In: xc/programs/Xserver/hw/xfree86/int10/generic
write_w & write_l
They use
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
if (OFF(addr + 3) > 2)
{ V_ADDR_WL(addr, val); }
#endif
V_ADDR_WB(addr, val);
V_ADDR_WB(addr + 1, val >> 8);
V_ADDR_WB(addr + 2, val >> 16);
V_ADDR_WB(addr + 3, val >> 24);I think there should be a #else to prevent executing of the WB statement in little endian machines,am i missing something?
2.in xc/programs/Xserver/hw/xfree86/common/comiler.h These statements seems wrong:
#define stq_u(v,p) stl_u(v,p)
#define stl_u(v,p) (*(unsigned char *)(p)) = (v); \
(*(unsigned char *)(p)+1) = ((v) >> 8); \
^^^^^
Should it be (*((unsigned char*)(p) + 1))?
(*(unsigned char *)(p)+2) = ((v) >> 16); \
(*(unsigned char *)(p)+3) = ((v) >> 24)#define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
(*(unsigned char *)(p)+1) = ((v) >> 8)Mr. Guido Guenther has posted a patch to work around it.But could it be right somewhere?Just curious:)
Thank you in advance.
Regards
Fuxin Zhang
[email protected]
Quoted 6 lines · Fuxin Zhang
hello,linux-mips
When trying to crossing compile XFree86 server for my linux on mipsel
Mr. Guido Guenther has posted a patch to work around it.But could it be right somewhere?Just curious:)
Thank you in advance.
I have fixed this(and some other problems) in the debian XFree86 Packages but not submitted upstream yet. I've attched the patch.
-- Guido
programs/Xserver/hw/xfree86/common/compiler.h renamed from programs/Xserver/hw/xfree86/common/compiler.h.orig +62 -0
@@ -862,6 +862,67 @@return r1; } +#ifdef linux/* don't mess with other OSs */ + +/* +* EGCS 1.1 knows about arbitrary unaligned loads (and we don't support older +* versions anyway. Define some packed structures to talk about such things +* with. +*/ + +struct __una_u32 {unsigned int x __attribute__((packed)); }; +struct __una_u16 {unsigned short x __attribute__((packed)); }; + +static __inline__void stw_u (unsigned long val,unsigned short *p) +{ +struct __una_u16 *ptr = (struct __una_u16 *) p; + ptr->x = val; +} + +static __inline__void stl_u (unsigned long val,unsigned int *p) +{ +struct __una_u32 *ptr = (struct __una_u32 *) p; + ptr->x = val; +} + +#if X_BYTE_ORDER ==X_BIG_ENDIAN +static __inline__unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ +unsigned long addr = ((unsigned long )base) + offset; +unsigned int ret; + + __asm__ __volatile__("lw %0, 0(%1)" + :"=r" (ret) + :"r" (addr)); +return ret; +} + +static __inline__void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, +const unsigned int val) +{ +unsigned long addr = ((unsigned long )base) + offset; + + __asm__ __volatile__("sw %0, 0(%1)" + :/* No outputs */ + :"r" (val),"r" (addr)); +} +#endif + +#define mem_barrier() \ +__asm__ __volatile__( \ + "# prevent instructions being moved around\n\t" \ + ".set\tnoreorder\n\t" \ + "# 8 nops to fool the R4400 pipeline\n\t" \ + "nop;nop;nop;nop;nop;nop;nop;nop\n\t" \ + ".set\treorder" \ + : /* no output */ \ + : /* no input */ \ + : "memory") +#define write_mem_barrier () mem_barrier() + +#else /* !linux */ #define stq_u (v,p) stl_u(v,p)#define stl_u (v,p) (*(unsigned char *)(p)) = (v); \ (*(unsigned char *)(p)+1) = ((v) >> 8); \
@@ -872,6 +934,7 @@ (*(unsigned char *)(p)+1) = ((v) >> 8)#define mem_barrier ()/* NOP */ +#endif /* !linux */ #endif /* __mips__ */ #if defined(__arm32__)