Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101647
b: refs/heads/master
c: 0f3d6bc
h: refs/heads/master
i:
  101645: 355597a
  101643: b47e816
  101639: 8b5d3a4
  101631: ce916a4
v: v3
  • Loading branch information
Trent Piepho authored and Paul Mackerras committed Jun 9, 2008
1 parent fe69664 commit f53b8f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 19fc65b5251dfd90312ae0142cc8650cd273e6a6
refs/heads/master: 0f3d6bcd391b058c619fc30e8022e8a29fbf4bef
57 changes: 42 additions & 15 deletions trunk/include/asm-powerpc/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,60 @@ extern resource_size_t isa_mem_base;
#define IO_SET_SYNC_FLAG()
#endif

#define DEF_MMIO_IN(name, type, insn) \
static inline type name(const volatile type __iomem *addr) \
/* gcc 4.0 and older doesn't have 'Z' constraint */
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
#define DEF_MMIO_IN_LE(name, size, insn) \
static inline u##size name(const volatile u##size __iomem *addr) \
{ \
type ret; \
__asm__ __volatile__("sync;" insn ";twi 0,%0,0;isync" \
u##size ret; \
__asm__ __volatile__("sync;"#insn" %0,0,%1;twi 0,%0,0;isync" \
: "=r" (ret) : "r" (addr), "m" (*addr) : "memory"); \
return ret; \
}

#define DEF_MMIO_OUT(name, type, insn) \
static inline void name(volatile type __iomem *addr, type val) \
#define DEF_MMIO_OUT_LE(name, size, insn) \
static inline void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;" insn \
__asm__ __volatile__("sync;"#insn" %1,0,%2" \
: "=m" (*addr) : "r" (val), "r" (addr) : "memory"); \
IO_SET_SYNC_FLAG(); \
}
#else /* newer gcc */
#define DEF_MMIO_IN_LE(name, size, insn) \
static inline u##size name(const volatile u##size __iomem *addr) \
{ \
u##size ret; \
__asm__ __volatile__("sync;"#insn" %0,%y1;twi 0,%0,0;isync" \
: "=r" (ret) : "Z" (*addr) : "memory"); \
return ret; \
}

#define DEF_MMIO_OUT_LE(name, size, insn) \
static inline void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn" %1,%y0" \
: "=Z" (*addr) : "r" (val) : "memory"); \
IO_SET_SYNC_FLAG(); \
}
#endif

#define DEF_MMIO_IN_BE(name, size, insn) \
static inline u##size name(const volatile u##size __iomem *addr) \
{ \
u##size ret; \
__asm__ __volatile__("sync;"#insn"%U1%X1 %0,%1;twi 0,%0,0;isync"\
: "=r" (ret) : "m" (*addr) : "memory"); \
return ret; \
}

#define DEF_MMIO_IN_BE(name, size, insn) \
DEF_MMIO_IN(name, u##size, __stringify(insn)"%U2%X2 %0,%2")
#define DEF_MMIO_IN_LE(name, size, insn) \
DEF_MMIO_IN(name, u##size, __stringify(insn)" %0,0,%1")
#define DEF_MMIO_OUT_BE(name, size, insn) \
static inline void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
: "=m" (*addr) : "r" (val) : "memory"); \
IO_SET_SYNC_FLAG(); \
}

#define DEF_MMIO_OUT_BE(name, size, insn) \
DEF_MMIO_OUT(name, u##size, __stringify(insn)"%U0%X0 %1,%0")
#define DEF_MMIO_OUT_LE(name, size, insn) \
DEF_MMIO_OUT(name, u##size, __stringify(insn)" %1,0,%2")

DEF_MMIO_IN_BE(in_8, 8, lbz);
DEF_MMIO_IN_BE(in_be16, 16, lhz);
Expand Down

0 comments on commit f53b8f4

Please sign in to comment.