8 #include "arch/common/fw_cfg.h"
10 extern unsigned long va_shift; // Set in entry.S
11 // Defined in ldscript
12 extern char _start, _data, _stack, _estack, _end, _iomem;
14 // XXX check use and merge
15 #define phys_to_virt(phys) ((void *) ((unsigned long) (phys)))
16 #define virt_to_phys(virt) ((unsigned long) (virt))
20 extern unsigned long isa_io_base;
23 * The insw/outsw/insl/outsl macros don't do byte-swapping.
24 * They are only used in practice for transferring buffers which
25 * are arrays of bytes, and byte-swapping is not appropriate in
28 #define insw(port, buf, ns) _insw_ns((uint16_t *)((port)+isa_io_base), (buf), (ns))
29 #define outsw(port, buf, ns) _outsw_ns((uint16_t *)((port)+isa_io_base), (buf), (ns))
31 #define inb(port) in_8((uint8_t *)((port)+isa_io_base))
32 #define outb(val, port) out_8((uint8_t *)((port)+isa_io_base), (val))
33 #define inw(port) in_be16((uint16_t *)((port)+isa_io_base))
34 #define outw(val, port) out_be16((uint16_t *)((port)+isa_io_base), (val))
35 #define inl(port) in_be32((uint32_t *)((port)+isa_io_base))
36 #define outl(val, port) out_be32((uint32_t *)((port)+isa_io_base), (val))
39 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
40 * On Sparc64, BE versions must swap bytes using LE access ASI.
42 static inline int in_8(volatile unsigned char *addr)
46 __asm__ __volatile__("lduba [%1] %2, %0\n\t"
48 : "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E)
54 static inline void out_8(volatile unsigned char *addr, int val)
56 __asm__ __volatile__("stba %0, [%1] %2\n\t"
58 : "r"(val), "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E)
62 static inline int in_le16(volatile unsigned short *addr)
66 __asm__ __volatile__("lduha [%1] %2, %0\n\t"
68 : "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E)
74 static inline int in_be16(volatile unsigned short *addr)
78 __asm__ __volatile__("lduha [%1] %2, %0\n\t"
80 : "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
86 static inline void out_le16(volatile unsigned short *addr, int val)
89 __asm__ __volatile__("stha %0, [%1] %2\n\t"
91 : "r"(val), "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E)
95 static inline void out_be16(volatile unsigned short *addr, int val)
97 __asm__ __volatile__("stha %0, [%1] %2\n\t"
99 : "r"(val), "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
103 static inline unsigned in_le32(volatile unsigned *addr)
107 __asm__ __volatile__("lduwa [%1] %2, %0\n\t"
109 : "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E)
115 static inline unsigned in_be32(volatile unsigned *addr)
119 __asm__ __volatile__("lduwa [%1] %2, %0\n\t"
121 : "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
126 static inline void out_le32(volatile unsigned *addr, int val)
128 __asm__ __volatile__("stwa %0, [%1] %2\n\t"
130 : "r"(val), "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E)
134 static inline void out_be32(volatile unsigned *addr, int val)
136 __asm__ __volatile__("stwa %0, [%1] %2\n\t"
138 : "r"(val), "r"(addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
142 static inline void _insw_ns(volatile uint16_t * port, void *buf, int ns)
144 uint16_t *b = (uint16_t *) buf;
147 *b++ = in_le16(port);
152 static inline void _outsw_ns(volatile uint16_t * port, const void *buf,
155 uint16_t *b = (uint16_t *) buf;
158 out_le16(port, *b++);
163 static inline void _insw(volatile uint16_t * port, void *buf, int ns)
165 uint16_t *b = (uint16_t *) buf;
168 *b++ = in_be16(port);
173 static inline void _outsw(volatile uint16_t * port, const void *buf,
176 uint16_t *b = (uint16_t *) buf;
179 out_be16(port, *b++);
183 #else /* BOOTSTRAP */
185 #define inb(reg) ((u8)0xff)
186 #define inw(reg) ((u16)0xffff)
187 #define inl(reg) ((u32)0xffffffff)
188 #define outb(reg, val) do{} while(0)
189 #define outw(reg, val) do{} while(0)
190 #define outl(reg, val) do{} while(0)
192 extern u8 inb(u32 reg);
193 extern u16 inw(u32 reg);
194 extern u32 inl(u32 reg);
195 extern void insw(u32 reg, void *addr, unsigned long count);
196 extern void outb(u32 reg, u8 val);
197 extern void outw(u32 reg, u16 val);
198 extern void outl(u32 reg, u32 val);
199 extern void outsw(u32 reg, const void *addr, unsigned long count);
203 #if defined(CONFIG_QEMU)
204 #define FW_CFG_ARCH_WIDTH (FW_CFG_ARCH_LOCAL + 0x00)
205 #define FW_CFG_ARCH_HEIGHT (FW_CFG_ARCH_LOCAL + 0x01)
206 #define FW_CFG_ARCH_DEPTH (FW_CFG_ARCH_LOCAL + 0x02)
209 #endif /* _ASM_IO_H */