6 extern unsigned int va_shift; // Set in entry.S
9 extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
11 // XXX check use and merge
12 #define phys_to_virt(phys) ((void *) ((unsigned long) (phys)))
13 #define virt_to_phys(virt) ((unsigned long) (virt))
22 * The insw/outsw/insl/outsl macros don't do byte-swapping.
23 * They are only used in practice for transferring buffers which
24 * are arrays of bytes, and byte-swapping is not appropriate in
27 #define insw(port, buf, ns) _insw_ns((uint16_t *)((port)+_IO_BASE), (buf), (ns))
28 #define outsw(port, buf, ns) _outsw_ns((uint16_t *)((port)+_IO_BASE), (buf), (ns))
30 #define inb(port) in_8((uint8_t *)((port)+_IO_BASE))
31 #define outb(val, port) out_8((uint8_t *)((port)+_IO_BASE), (val))
32 #define inw(port) in_le16((uint16_t *)((port)+_IO_BASE))
33 #define outw(val, port) out_le16((uint16_t *)((port)+_IO_BASE), (val))
34 #define inl(port) in_le32((uint32_t *)((port)+_IO_BASE))
35 #define outl(val, port) out_le32((uint32_t *)((port)+_IO_BASE), (val))
38 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
40 static inline int in_8(volatile unsigned char *addr)
44 __asm__ __volatile__("ldub [%1], %0\n\t"
46 :"=r"(ret):"r"(addr):"memory");
51 static inline void out_8(volatile unsigned char *addr, int val)
53 __asm__ __volatile__("stb %0, [%1]\n\t"
55 : : "r"(val), "r"(addr):"memory");
58 static inline int in_le16(volatile unsigned short *addr)
63 __asm__ __volatile__("lduh [%1], %0\n\t"
65 :"=r"(ret):"r"(addr):"memory");
70 static inline int in_be16(volatile unsigned short *addr)
74 __asm__ __volatile__("lduh [%1], %0\n\t"
76 :"=r"(ret):"r"(addr):"memory");
81 static inline void out_le16(volatile unsigned short *addr, int val)
84 __asm__ __volatile__("sth %0, [%1]\n\t"
86 : : "r"(val), "r"(addr):"memory");
89 static inline void out_be16(volatile unsigned short *addr, int val)
91 __asm__ __volatile__("sth %0, [%1]\n\t"
93 : : "r"(val), "r"(addr):"memory");
96 static inline unsigned in_le32(volatile unsigned *addr)
101 __asm__ __volatile__("ld [%1], %0\n\t"
103 :"=r"(ret):"r"(addr):"memory");
108 static inline unsigned in_be32(volatile unsigned *addr)
112 __asm__ __volatile__("ld [%1], %0\n\t"
114 :"=r"(ret):"r"(addr):"memory");
119 static inline void out_le32(volatile unsigned *addr, int val)
122 __asm__ __volatile__("st %0, [%1]\n\t"
124 : : "r"(val), "r"(addr):"memory");
127 static inline void out_be32(volatile unsigned *addr, int val)
129 __asm__ __volatile__("st %0, [%1]\n\t"
131 : : "r"(val), "r"(addr):"memory");
134 static inline void _insw_ns(volatile uint16_t * port, void *buf, int ns)
136 uint16_t *b = (uint16_t *) buf;
139 *b++ = in_le16(port);
144 static inline void _outsw_ns(volatile uint16_t * port, const void *buf,
147 uint16_t *b = (uint16_t *) buf;
150 out_le16(port, *b++);
155 static inline void _insw(volatile uint16_t * port, void *buf, int ns)
157 uint16_t *b = (uint16_t *) buf;
160 *b++ = in_be16(port);
165 static inline void _outsw(volatile uint16_t * port, const void *buf,
168 uint16_t *b = (uint16_t *) buf;
171 out_be16(port, *b++);
175 #else /* BOOTSTRAP */
177 #define inb(reg) ((u8)0xff)
178 #define inw(reg) ((u16)0xffff)
179 #define inl(reg) ((u32)0xffffffff)
180 #define outb(reg, val) do{} while(0)
181 #define outw(reg, val) do{} while(0)
182 #define outl(reg, val) do{} while(0)
184 extern u8 inb(u32 reg);
185 extern u16 inw(u32 reg);
186 extern u32 inl(u32 reg);
187 extern void insw(u32 reg, void *addr, unsigned long count);
188 extern void outb(u32 reg, u8 val);
189 extern void outw(u32 reg, u16 val);
190 extern void outl(u32 reg, u32 val);
191 extern void outsw(u32 reg, const void *addr, unsigned long count);
195 #if defined(CONFIG_QEMU)
196 #define FW_CFG_ARCH_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
197 #define FW_CFG_ARCH_WIDTH (FW_CFG_ARCH_LOCAL + 0x01)
198 #define FW_CFG_ARCH_HEIGHT (FW_CFG_ARCH_LOCAL + 0x02)
201 #endif /* _ASM_IO_H */