2 * Machine vector for IA-64.
4 * Copyright (C) 1999 Silicon Graphics, Inc.
5 * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
6 * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
7 * Copyright (C) 1999-2001, 2003-2004 Hewlett-Packard Co.
8 * David Mosberger-Tang <davidm@hpl.hp.com>
10 #ifndef _ASM_IA64_MACHVEC_H
11 #define _ASM_IA64_MACHVEC_H
13 #include <linux/config.h>
14 #include <linux/types.h>
16 /* forward declarations: */
23 typedef void ia64_mv_setup_t (char **);
24 typedef void ia64_mv_cpu_init_t (void);
25 typedef void ia64_mv_irq_init_t (void);
26 typedef void ia64_mv_send_ipi_t (int, int, int, int);
27 typedef void ia64_mv_timer_interrupt_t (int, void *, struct pt_regs *);
28 typedef void ia64_mv_global_tlb_purge_t (unsigned long, unsigned long, unsigned long);
29 typedef struct irq_desc *ia64_mv_irq_desc (unsigned int);
30 typedef u8 ia64_mv_irq_to_vector (u8);
31 typedef unsigned int ia64_mv_local_vector_to_irq (u8 vector);
33 /* DMA-mapping interface: */
34 typedef void ia64_mv_dma_init (void);
35 typedef void *ia64_mv_dma_alloc_coherent (struct device *, size_t, dma_addr_t *, int);
36 typedef void ia64_mv_dma_free_coherent (struct device *, size_t, void *, dma_addr_t);
37 typedef dma_addr_t ia64_mv_dma_map_single (struct device *, void *, size_t, int);
38 typedef void ia64_mv_dma_unmap_single (struct device *, dma_addr_t, size_t, int);
39 typedef int ia64_mv_dma_map_sg (struct device *, struct scatterlist *, int, int);
40 typedef void ia64_mv_dma_unmap_sg (struct device *, struct scatterlist *, int, int);
41 typedef void ia64_mv_dma_sync_single_for_cpu (struct device *, dma_addr_t, size_t, int);
42 typedef void ia64_mv_dma_sync_sg_for_cpu (struct device *, struct scatterlist *, int, int);
43 typedef void ia64_mv_dma_sync_single_for_device (struct device *, dma_addr_t, size_t, int);
44 typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist *, int, int);
45 typedef int ia64_mv_dma_mapping_error (dma_addr_t dma_addr);
46 typedef int ia64_mv_dma_supported (struct device *, u64);
49 * WARNING: The legacy I/O space is _architected_. Platforms are
50 * expected to follow this architected model (see Section 10.7 in the
51 * IA-64 Architecture Software Developer's Manual). Unfortunately,
52 * some broken machines do not follow that model, which is why we have
53 * to make the inX/outX operations part of the machine vector.
54 * Platform designers should follow the architected model whenever
57 typedef unsigned int ia64_mv_inb_t (unsigned long);
58 typedef unsigned int ia64_mv_inw_t (unsigned long);
59 typedef unsigned int ia64_mv_inl_t (unsigned long);
60 typedef void ia64_mv_outb_t (unsigned char, unsigned long);
61 typedef void ia64_mv_outw_t (unsigned short, unsigned long);
62 typedef void ia64_mv_outl_t (unsigned int, unsigned long);
63 typedef unsigned char ia64_mv_readb_t (void *);
64 typedef unsigned short ia64_mv_readw_t (void *);
65 typedef unsigned int ia64_mv_readl_t (void *);
66 typedef unsigned long ia64_mv_readq_t (void *);
67 typedef unsigned char ia64_mv_readb_relaxed_t (void *);
68 typedef unsigned short ia64_mv_readw_relaxed_t (void *);
69 typedef unsigned int ia64_mv_readl_relaxed_t (void *);
70 typedef unsigned long ia64_mv_readq_relaxed_t (void *);
72 extern void machvec_noop (void);
73 extern void machvec_setup (char **);
74 extern void machvec_timer_interrupt (int, void *, struct pt_regs *);
75 extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, int);
76 extern void machvec_dma_sync_sg (struct device *, struct scatterlist *, int, int);
78 # if defined (CONFIG_IA64_HP_SIM)
79 # include <asm/machvec_hpsim.h>
80 # elif defined (CONFIG_IA64_DIG)
81 # include <asm/machvec_dig.h>
82 # elif defined (CONFIG_IA64_HP_ZX1)
83 # include <asm/machvec_hpzx1.h>
84 # elif defined (CONFIG_IA64_SGI_SN2)
85 # include <asm/machvec_sn2.h>
86 # elif defined (CONFIG_IA64_GENERIC)
88 # ifdef MACHVEC_PLATFORM_HEADER
89 # include MACHVEC_PLATFORM_HEADER
91 # define platform_name ia64_mv.name
92 # define platform_setup ia64_mv.setup
93 # define platform_cpu_init ia64_mv.cpu_init
94 # define platform_irq_init ia64_mv.irq_init
95 # define platform_send_ipi ia64_mv.send_ipi
96 # define platform_timer_interrupt ia64_mv.timer_interrupt
97 # define platform_global_tlb_purge ia64_mv.global_tlb_purge
98 # define platform_dma_init ia64_mv.dma_init
99 # define platform_dma_alloc_coherent ia64_mv.dma_alloc_coherent
100 # define platform_dma_free_coherent ia64_mv.dma_free_coherent
101 # define platform_dma_map_single ia64_mv.dma_map_single
102 # define platform_dma_unmap_single ia64_mv.dma_unmap_single
103 # define platform_dma_map_sg ia64_mv.dma_map_sg
104 # define platform_dma_unmap_sg ia64_mv.dma_unmap_sg
105 # define platform_dma_sync_single_for_cpu ia64_mv.dma_sync_single_for_cpu
106 # define platform_dma_sync_sg_for_cpu ia64_mv.dma_sync_sg_for_cpu
107 # define platform_dma_sync_single_for_device ia64_mv.dma_sync_single_for_device
108 # define platform_dma_sync_sg_for_device ia64_mv.dma_sync_sg_for_device
109 # define platform_dma_mapping_error ia64_mv.dma_mapping_error
110 # define platform_dma_supported ia64_mv.dma_supported
111 # define platform_irq_desc ia64_mv.irq_desc
112 # define platform_irq_to_vector ia64_mv.irq_to_vector
113 # define platform_local_vector_to_irq ia64_mv.local_vector_to_irq
114 # define platform_inb ia64_mv.inb
115 # define platform_inw ia64_mv.inw
116 # define platform_inl ia64_mv.inl
117 # define platform_outb ia64_mv.outb
118 # define platform_outw ia64_mv.outw
119 # define platform_outl ia64_mv.outl
120 # define platform_readb ia64_mv.readb
121 # define platform_readw ia64_mv.readw
122 # define platform_readl ia64_mv.readl
123 # define platform_readq ia64_mv.readq
124 # define platform_readb_relaxed ia64_mv.readb_relaxed
125 # define platform_readw_relaxed ia64_mv.readw_relaxed
126 # define platform_readl_relaxed ia64_mv.readl_relaxed
127 # define platform_readq_relaxed ia64_mv.readq_relaxed
130 /* __attribute__((__aligned__(16))) is required to make size of the
131 * structure multiple of 16 bytes.
132 * This will fillup the holes created because of section 3.3.1 in
133 * Software Conventions guide.
135 struct ia64_machine_vector {
137 ia64_mv_setup_t *setup;
138 ia64_mv_cpu_init_t *cpu_init;
139 ia64_mv_irq_init_t *irq_init;
140 ia64_mv_send_ipi_t *send_ipi;
141 ia64_mv_timer_interrupt_t *timer_interrupt;
142 ia64_mv_global_tlb_purge_t *global_tlb_purge;
143 ia64_mv_dma_init *dma_init;
144 ia64_mv_dma_alloc_coherent *dma_alloc_coherent;
145 ia64_mv_dma_free_coherent *dma_free_coherent;
146 ia64_mv_dma_map_single *dma_map_single;
147 ia64_mv_dma_unmap_single *dma_unmap_single;
148 ia64_mv_dma_map_sg *dma_map_sg;
149 ia64_mv_dma_unmap_sg *dma_unmap_sg;
150 ia64_mv_dma_sync_single_for_cpu *dma_sync_single_for_cpu;
151 ia64_mv_dma_sync_sg_for_cpu *dma_sync_sg_for_cpu;
152 ia64_mv_dma_sync_single_for_device *dma_sync_single_for_device;
153 ia64_mv_dma_sync_sg_for_device *dma_sync_sg_for_device;
154 ia64_mv_dma_mapping_error *dma_mapping_error;
155 ia64_mv_dma_supported *dma_supported;
156 ia64_mv_irq_desc *irq_desc;
157 ia64_mv_irq_to_vector *irq_to_vector;
158 ia64_mv_local_vector_to_irq *local_vector_to_irq;
162 ia64_mv_outb_t *outb;
163 ia64_mv_outw_t *outw;
164 ia64_mv_outl_t *outl;
165 ia64_mv_readb_t *readb;
166 ia64_mv_readw_t *readw;
167 ia64_mv_readl_t *readl;
168 ia64_mv_readq_t *readq;
169 ia64_mv_readb_relaxed_t *readb_relaxed;
170 ia64_mv_readw_relaxed_t *readw_relaxed;
171 ia64_mv_readl_relaxed_t *readl_relaxed;
172 ia64_mv_readq_relaxed_t *readq_relaxed;
173 } __attribute__((__aligned__(16))); /* align attrib? see above comment */
175 #define MACHVEC_INIT(name) \
182 platform_timer_interrupt, \
183 platform_global_tlb_purge, \
185 platform_dma_alloc_coherent, \
186 platform_dma_free_coherent, \
187 platform_dma_map_single, \
188 platform_dma_unmap_single, \
189 platform_dma_map_sg, \
190 platform_dma_unmap_sg, \
191 platform_dma_sync_single_for_cpu, \
192 platform_dma_sync_sg_for_cpu, \
193 platform_dma_sync_single_for_device, \
194 platform_dma_sync_sg_for_device, \
195 platform_dma_mapping_error, \
196 platform_dma_supported, \
198 platform_irq_to_vector, \
199 platform_local_vector_to_irq, \
210 platform_readb_relaxed, \
211 platform_readw_relaxed, \
212 platform_readl_relaxed, \
213 platform_readq_relaxed, \
216 extern struct ia64_machine_vector ia64_mv;
217 extern void machvec_init (const char *name);
220 # error Unknown configuration. Update asm-ia64/machvec.h.
221 # endif /* CONFIG_IA64_GENERIC */
224 * Declare default routines which aren't declared anywhere else:
226 extern ia64_mv_dma_init swiotlb_init;
227 extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent;
228 extern ia64_mv_dma_free_coherent swiotlb_free_coherent;
229 extern ia64_mv_dma_map_single swiotlb_map_single;
230 extern ia64_mv_dma_unmap_single swiotlb_unmap_single;
231 extern ia64_mv_dma_map_sg swiotlb_map_sg;
232 extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg;
233 extern ia64_mv_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu;
234 extern ia64_mv_dma_sync_sg_for_cpu swiotlb_sync_sg_for_cpu;
235 extern ia64_mv_dma_sync_single_for_device swiotlb_sync_single_for_device;
236 extern ia64_mv_dma_sync_sg_for_device swiotlb_sync_sg_for_device;
237 extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error;
238 extern ia64_mv_dma_supported swiotlb_dma_supported;
241 * Define default versions so we can extend machvec for new platforms without having
242 * to update the machvec files for all existing platforms.
244 #ifndef platform_setup
245 # define platform_setup machvec_setup
247 #ifndef platform_cpu_init
248 # define platform_cpu_init machvec_noop
250 #ifndef platform_irq_init
251 # define platform_irq_init machvec_noop
254 #ifndef platform_send_ipi
255 # define platform_send_ipi ia64_send_ipi /* default to architected version */
257 #ifndef platform_timer_interrupt
258 # define platform_timer_interrupt machvec_timer_interrupt
260 #ifndef platform_global_tlb_purge
261 # define platform_global_tlb_purge ia64_global_tlb_purge /* default to architected version */
263 #ifndef platform_dma_init
264 # define platform_dma_init swiotlb_init
266 #ifndef platform_dma_alloc_coherent
267 # define platform_dma_alloc_coherent swiotlb_alloc_coherent
269 #ifndef platform_dma_free_coherent
270 # define platform_dma_free_coherent swiotlb_free_coherent
272 #ifndef platform_dma_map_single
273 # define platform_dma_map_single swiotlb_map_single
275 #ifndef platform_dma_unmap_single
276 # define platform_dma_unmap_single swiotlb_unmap_single
278 #ifndef platform_dma_map_sg
279 # define platform_dma_map_sg swiotlb_map_sg
281 #ifndef platform_dma_unmap_sg
282 # define platform_dma_unmap_sg swiotlb_unmap_sg
284 #ifndef platform_dma_sync_single_for_cpu
285 # define platform_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu
287 #ifndef platform_dma_sync_sg_for_cpu
288 # define platform_dma_sync_sg_for_cpu swiotlb_sync_sg_for_cpu
290 #ifndef platform_dma_sync_single_for_device
291 # define platform_dma_sync_single_for_device swiotlb_sync_single_for_device
293 #ifndef platform_dma_sync_sg_for_device
294 # define platform_dma_sync_sg_for_device swiotlb_sync_sg_for_device
296 #ifndef platform_dma_mapping_error
297 # define platform_dma_mapping_error swiotlb_dma_mapping_error
299 #ifndef platform_dma_supported
300 # define platform_dma_supported swiotlb_dma_supported
302 #ifndef platform_irq_desc
303 # define platform_irq_desc __ia64_irq_desc
305 #ifndef platform_irq_to_vector
306 # define platform_irq_to_vector __ia64_irq_to_vector
308 #ifndef platform_local_vector_to_irq
309 # define platform_local_vector_to_irq __ia64_local_vector_to_irq
312 # define platform_inb __ia64_inb
315 # define platform_inw __ia64_inw
318 # define platform_inl __ia64_inl
320 #ifndef platform_outb
321 # define platform_outb __ia64_outb
323 #ifndef platform_outw
324 # define platform_outw __ia64_outw
326 #ifndef platform_outl
327 # define platform_outl __ia64_outl
329 #ifndef platform_readb
330 # define platform_readb __ia64_readb
332 #ifndef platform_readw
333 # define platform_readw __ia64_readw
335 #ifndef platform_readl
336 # define platform_readl __ia64_readl
338 #ifndef platform_readq
339 # define platform_readq __ia64_readq
341 #ifndef platform_readb_relaxed
342 # define platform_readb_relaxed __ia64_readb_relaxed
344 #ifndef platform_readw_relaxed
345 # define platform_readw_relaxed __ia64_readw_relaxed
347 #ifndef platform_readl_relaxed
348 # define platform_readl_relaxed __ia64_readl_relaxed
350 #ifndef platform_readq_relaxed
351 # define platform_readq_relaxed __ia64_readq_relaxed
354 #endif /* _ASM_IA64_MACHVEC_H */