Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /* $Id: io.h,v 1.18 1998/09/21 05:07:17 jj Exp $ */ #ifndef __SPARC_IO_H #define __SPARC_IO_H #include <linux/kernel.h> #include <linux/types.h> #include <asm/page.h> /* IO address mapping routines need this */ #include <asm/system.h> /* * Defines for io operations on the Sparc. Whether a memory access is going * to i/o sparc is encoded in the pte. The type bits determine whether this * is i/o sparc, on board memory, or VME space for VME cards. I think VME * space only works on sun4's */ #define virt_to_bus virt_to_phys extern __inline__ unsigned flip_dword (unsigned d) { return ((d&0xff)<<24) | (((d>>8)&0xff)<<16) | (((d>>16)&0xff)<<8)| ((d>>24)&0xff); } extern __inline__ unsigned short flip_word (unsigned short d) { return ((d&0xff) << 8) | ((d>>8)&0xff); } extern __inline__ unsigned long readb(unsigned long addr) { return *(volatile unsigned char*)addr; } extern __inline__ unsigned long readw(unsigned long addr) { return flip_word(*(volatile unsigned short*)addr); } extern __inline__ unsigned long readl(unsigned long addr) { return flip_dword(*(volatile unsigned long*)addr); } extern __inline__ void writeb(unsigned short b, unsigned long addr) { *(volatile unsigned char*)addr = b; } extern __inline__ void writew(unsigned short b, unsigned long addr) { *(volatile unsigned short*)addr = flip_word(b); } extern __inline__ void writel(unsigned int b, unsigned long addr) { *(volatile unsigned long*)addr = flip_dword(b); } extern __inline__ unsigned long inb_local(unsigned long addr) { return readb(addr); } extern __inline__ void outb_local(unsigned char b, unsigned long addr) { return writeb(b,addr); } extern __inline__ unsigned long inb(unsigned long addr) { return readb(addr); } extern __inline__ unsigned long inw(unsigned long addr) { return readw(addr); } extern __inline__ unsigned long inl(unsigned long addr) { return readl(addr); } extern __inline__ void outb(unsigned char b, unsigned long addr) { return writeb(b,addr); } extern __inline__ void outw(unsigned short b, unsigned long addr) { return writew(b,addr); } extern __inline__ void outl(unsigned int b, unsigned long addr) { return writel(b,addr); } #define inb_p inb #define outb_p outb extern void sun4c_mapioaddr(unsigned long, unsigned long, int bus_type, int rdonly); extern void srmmu_mapioaddr(unsigned long, unsigned long, int bus_type, int rdonly); extern __inline__ void mapioaddr(unsigned long physaddr, unsigned long virt_addr, int bus, int rdonly) { switch(sparc_cpu_model) { case sun4c: case sun4: sun4c_mapioaddr(physaddr, virt_addr, bus, rdonly); break; case sun4m: case sun4d: case sun4e: srmmu_mapioaddr(physaddr, virt_addr, bus, rdonly); break; default: printk("mapioaddr: Trying to map IO space for unsupported machine.\n"); printk("mapioaddr: sparc_cpu_model = %d\n", sparc_cpu_model); printk("mapioaddr: Halting...\n"); halt(); }; return; } extern void srmmu_unmapioaddr(unsigned long virt); extern void sun4c_unmapioaddr(unsigned long virt); extern __inline__ void unmapioaddr(unsigned long virt_addr) { switch(sparc_cpu_model) { case sun4c: case sun4: sun4c_unmapioaddr(virt_addr); break; case sun4m: case sun4d: case sun4e: srmmu_unmapioaddr(virt_addr); break; default: printk("unmapioaddr: sparc_cpu_model = %d, halt...\n", sparc_cpu_model); halt(); }; return; } extern void *sparc_alloc_io (u32 pa, void *va, int sz, char *name, u32 io, int rdonly); extern void sparc_free_io (void *vaddr, int sz); extern void *_sparc_dvma_malloc (int sz, char *name); /* Returns CPU visible address, dvmaaddr_p is a pointer to where * the DVMA visible (ie. SBUS/PSYCO+PCI) address should be stored. */ static __inline__ void *sparc_dvma_malloc(int size, char *name, __u32 *dvmaaddr_p) { void *cpuaddr = _sparc_dvma_malloc(size, name); *dvmaaddr_p = (__u32) cpuaddr; return cpuaddr; } #define virt_to_phys(x) __pa((unsigned long)(x)) #define phys_to_virt(x) __va((unsigned long)(x)) #endif /* !(__SPARC_IO_H) */ |