machvec.h 16.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Machine vector for IA-64.
 *
 * Copyright (C) 1999 Silicon Graphics, Inc.
 * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
 * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
 * Copyright (C) 1999-2001, 2003-2004 Hewlett-Packard Co.
 *	David Mosberger-Tang <davidm@hpl.hp.com>
 */
#ifndef _ASM_IA64_MACHVEC_H
#define _ASM_IA64_MACHVEC_H

#include <linux/types.h>
14
#include <linux/swiotlb.h>
L
Linus Torvalds 已提交
15 16 17 18 19 20 21 22

/* forward declarations: */
struct device;
struct pt_regs;
struct scatterlist;
struct page;
struct mm_struct;
struct pci_bus;
23
struct task_struct;
24
struct pci_dev;
25
struct msi_desc;
26
struct dma_attrs;
L
Linus Torvalds 已提交
27 28 29 30 31

typedef void ia64_mv_setup_t (char **);
typedef void ia64_mv_cpu_init_t (void);
typedef void ia64_mv_irq_init_t (void);
typedef void ia64_mv_send_ipi_t (int, int, int, int);
32
typedef void ia64_mv_timer_interrupt_t (int, void *);
33
typedef void ia64_mv_global_tlb_purge_t (struct mm_struct *, unsigned long, unsigned long, unsigned long);
L
Linus Torvalds 已提交
34
typedef void ia64_mv_tlb_migrate_finish_t (struct mm_struct *);
35
typedef u8 ia64_mv_irq_to_vector (int);
L
Linus Torvalds 已提交
36 37 38 39 40 41
typedef unsigned int ia64_mv_local_vector_to_irq (u8);
typedef char *ia64_mv_pci_get_legacy_mem_t (struct pci_bus *);
typedef int ia64_mv_pci_legacy_read_t (struct pci_bus *, u16 port, u32 *val,
				       u8 size);
typedef int ia64_mv_pci_legacy_write_t (struct pci_bus *, u16 port, u32 val,
					u8 size);
42
typedef void ia64_mv_migrate_t(struct task_struct * task);
J
John Keller 已提交
43
typedef void ia64_mv_pci_fixup_bus_t (struct pci_bus *);
Z
Zou Nan hai 已提交
44
typedef void ia64_mv_kernel_launch_event_t(void);
L
Linus Torvalds 已提交
45 46 47

/* DMA-mapping interface: */
typedef void ia64_mv_dma_init (void);
A
Al Viro 已提交
48
typedef void *ia64_mv_dma_alloc_coherent (struct device *, size_t, dma_addr_t *, gfp_t);
L
Linus Torvalds 已提交
49 50 51 52 53 54 55 56 57
typedef void ia64_mv_dma_free_coherent (struct device *, size_t, void *, dma_addr_t);
typedef dma_addr_t ia64_mv_dma_map_single (struct device *, void *, size_t, int);
typedef void ia64_mv_dma_unmap_single (struct device *, dma_addr_t, size_t, int);
typedef int ia64_mv_dma_map_sg (struct device *, struct scatterlist *, int, int);
typedef void ia64_mv_dma_unmap_sg (struct device *, struct scatterlist *, int, int);
typedef void ia64_mv_dma_sync_single_for_cpu (struct device *, dma_addr_t, size_t, int);
typedef void ia64_mv_dma_sync_sg_for_cpu (struct device *, struct scatterlist *, int, int);
typedef void ia64_mv_dma_sync_single_for_device (struct device *, dma_addr_t, size_t, int);
typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist *, int, int);
58
typedef int ia64_mv_dma_mapping_error(struct device *, dma_addr_t dma_addr);
L
Linus Torvalds 已提交
59 60
typedef int ia64_mv_dma_supported (struct device *, u64);

61 62 63 64
typedef dma_addr_t ia64_mv_dma_map_single_attrs (struct device *, void *, size_t, int, struct dma_attrs *);
typedef void ia64_mv_dma_unmap_single_attrs (struct device *, dma_addr_t, size_t, int, struct dma_attrs *);
typedef int ia64_mv_dma_map_sg_attrs (struct device *, struct scatterlist *, int, int, struct dma_attrs *);
typedef void ia64_mv_dma_unmap_sg_attrs (struct device *, struct scatterlist *, int, int, struct dma_attrs *);
65
typedef u64 ia64_mv_dma_get_required_mask (struct device *);
66

L
Linus Torvalds 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
/*
 * WARNING: The legacy I/O space is _architected_.  Platforms are
 * expected to follow this architected model (see Section 10.7 in the
 * IA-64 Architecture Software Developer's Manual).  Unfortunately,
 * some broken machines do not follow that model, which is why we have
 * to make the inX/outX operations part of the machine vector.
 * Platform designers should follow the architected model whenever
 * possible.
 */
typedef unsigned int ia64_mv_inb_t (unsigned long);
typedef unsigned int ia64_mv_inw_t (unsigned long);
typedef unsigned int ia64_mv_inl_t (unsigned long);
typedef void ia64_mv_outb_t (unsigned char, unsigned long);
typedef void ia64_mv_outw_t (unsigned short, unsigned long);
typedef void ia64_mv_outl_t (unsigned int, unsigned long);
typedef void ia64_mv_mmiowb_t (void);
typedef unsigned char ia64_mv_readb_t (const volatile void __iomem *);
typedef unsigned short ia64_mv_readw_t (const volatile void __iomem *);
typedef unsigned int ia64_mv_readl_t (const volatile void __iomem *);
typedef unsigned long ia64_mv_readq_t (const volatile void __iomem *);
typedef unsigned char ia64_mv_readb_relaxed_t (const volatile void __iomem *);
typedef unsigned short ia64_mv_readw_relaxed_t (const volatile void __iomem *);
typedef unsigned int ia64_mv_readl_relaxed_t (const volatile void __iomem *);
typedef unsigned long ia64_mv_readq_relaxed_t (const volatile void __iomem *);
91

92
typedef int ia64_mv_setup_msi_irq_t (struct pci_dev *pdev, struct msi_desc *);
93
typedef void ia64_mv_teardown_msi_irq_t (unsigned int irq);
L
Linus Torvalds 已提交
94 95 96 97 98 99 100 101 102 103 104

static inline void
machvec_noop (void)
{
}

static inline void
machvec_noop_mm (struct mm_struct *mm)
{
}

105 106 107 108 109
static inline void
machvec_noop_task (struct task_struct *task)
{
}

J
John Keller 已提交
110 111 112 113 114
static inline void
machvec_noop_bus (struct pci_bus *bus)
{
}

L
Linus Torvalds 已提交
115
extern void machvec_setup (char **);
116
extern void machvec_timer_interrupt (int, void *);
L
Linus Torvalds 已提交
117 118 119 120 121 122 123 124
extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, int);
extern void machvec_dma_sync_sg (struct device *, struct scatterlist *, int, int);
extern void machvec_tlb_migrate_finish (struct mm_struct *);

# if defined (CONFIG_IA64_HP_SIM)
#  include <asm/machvec_hpsim.h>
# elif defined (CONFIG_IA64_DIG)
#  include <asm/machvec_dig.h>
125 126
# elif defined(CONFIG_IA64_DIG_VTD)
#  include <asm/machvec_dig_vtd.h>
L
Linus Torvalds 已提交
127 128 129 130 131 132
# elif defined (CONFIG_IA64_HP_ZX1)
#  include <asm/machvec_hpzx1.h>
# elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB)
#  include <asm/machvec_hpzx1_swiotlb.h>
# elif defined (CONFIG_IA64_SGI_SN2)
#  include <asm/machvec_sn2.h>
133 134
# elif defined (CONFIG_IA64_SGI_UV)
#  include <asm/machvec_uv.h>
135 136
# elif defined (CONFIG_IA64_XEN_GUEST)
#  include <asm/machvec_xen.h>
L
Linus Torvalds 已提交
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
# elif defined (CONFIG_IA64_GENERIC)

# ifdef MACHVEC_PLATFORM_HEADER
#  include MACHVEC_PLATFORM_HEADER
# else
#  define platform_name		ia64_mv.name
#  define platform_setup	ia64_mv.setup
#  define platform_cpu_init	ia64_mv.cpu_init
#  define platform_irq_init	ia64_mv.irq_init
#  define platform_send_ipi	ia64_mv.send_ipi
#  define platform_timer_interrupt	ia64_mv.timer_interrupt
#  define platform_global_tlb_purge	ia64_mv.global_tlb_purge
#  define platform_tlb_migrate_finish	ia64_mv.tlb_migrate_finish
#  define platform_dma_init		ia64_mv.dma_init
#  define platform_dma_alloc_coherent	ia64_mv.dma_alloc_coherent
#  define platform_dma_free_coherent	ia64_mv.dma_free_coherent
153 154 155 156
#  define platform_dma_map_single_attrs	ia64_mv.dma_map_single_attrs
#  define platform_dma_unmap_single_attrs	ia64_mv.dma_unmap_single_attrs
#  define platform_dma_map_sg_attrs	ia64_mv.dma_map_sg_attrs
#  define platform_dma_unmap_sg_attrs	ia64_mv.dma_unmap_sg_attrs
L
Linus Torvalds 已提交
157 158 159 160 161 162
#  define platform_dma_sync_single_for_cpu ia64_mv.dma_sync_single_for_cpu
#  define platform_dma_sync_sg_for_cpu	ia64_mv.dma_sync_sg_for_cpu
#  define platform_dma_sync_single_for_device ia64_mv.dma_sync_single_for_device
#  define platform_dma_sync_sg_for_device ia64_mv.dma_sync_sg_for_device
#  define platform_dma_mapping_error		ia64_mv.dma_mapping_error
#  define platform_dma_supported	ia64_mv.dma_supported
163
#  define platform_dma_get_required_mask ia64_mv.dma_get_required_mask
164
#  define platform_irq_to_vector	ia64_mv.irq_to_vector
L
Linus Torvalds 已提交
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
#  define platform_local_vector_to_irq	ia64_mv.local_vector_to_irq
#  define platform_pci_get_legacy_mem	ia64_mv.pci_get_legacy_mem
#  define platform_pci_legacy_read	ia64_mv.pci_legacy_read
#  define platform_pci_legacy_write	ia64_mv.pci_legacy_write
#  define platform_inb		ia64_mv.inb
#  define platform_inw		ia64_mv.inw
#  define platform_inl		ia64_mv.inl
#  define platform_outb		ia64_mv.outb
#  define platform_outw		ia64_mv.outw
#  define platform_outl		ia64_mv.outl
#  define platform_mmiowb	ia64_mv.mmiowb
#  define platform_readb        ia64_mv.readb
#  define platform_readw        ia64_mv.readw
#  define platform_readl        ia64_mv.readl
#  define platform_readq        ia64_mv.readq
#  define platform_readb_relaxed        ia64_mv.readb_relaxed
#  define platform_readw_relaxed        ia64_mv.readw_relaxed
#  define platform_readl_relaxed        ia64_mv.readl_relaxed
#  define platform_readq_relaxed        ia64_mv.readq_relaxed
184
#  define platform_migrate		ia64_mv.migrate
185 186
#  define platform_setup_msi_irq	ia64_mv.setup_msi_irq
#  define platform_teardown_msi_irq	ia64_mv.teardown_msi_irq
J
John Keller 已提交
187
#  define platform_pci_fixup_bus	ia64_mv.pci_fixup_bus
188
#  define platform_kernel_launch_event	ia64_mv.kernel_launch_event
L
Linus Torvalds 已提交
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
# endif

/* __attribute__((__aligned__(16))) is required to make size of the
 * structure multiple of 16 bytes.
 * This will fillup the holes created because of section 3.3.1 in
 * Software Conventions guide.
 */
struct ia64_machine_vector {
	const char *name;
	ia64_mv_setup_t *setup;
	ia64_mv_cpu_init_t *cpu_init;
	ia64_mv_irq_init_t *irq_init;
	ia64_mv_send_ipi_t *send_ipi;
	ia64_mv_timer_interrupt_t *timer_interrupt;
	ia64_mv_global_tlb_purge_t *global_tlb_purge;
	ia64_mv_tlb_migrate_finish_t *tlb_migrate_finish;
	ia64_mv_dma_init *dma_init;
	ia64_mv_dma_alloc_coherent *dma_alloc_coherent;
	ia64_mv_dma_free_coherent *dma_free_coherent;
208 209 210 211
	ia64_mv_dma_map_single_attrs *dma_map_single_attrs;
	ia64_mv_dma_unmap_single_attrs *dma_unmap_single_attrs;
	ia64_mv_dma_map_sg_attrs *dma_map_sg_attrs;
	ia64_mv_dma_unmap_sg_attrs *dma_unmap_sg_attrs;
L
Linus Torvalds 已提交
212 213 214 215 216 217
	ia64_mv_dma_sync_single_for_cpu *dma_sync_single_for_cpu;
	ia64_mv_dma_sync_sg_for_cpu *dma_sync_sg_for_cpu;
	ia64_mv_dma_sync_single_for_device *dma_sync_single_for_device;
	ia64_mv_dma_sync_sg_for_device *dma_sync_sg_for_device;
	ia64_mv_dma_mapping_error *dma_mapping_error;
	ia64_mv_dma_supported *dma_supported;
218
	ia64_mv_dma_get_required_mask *dma_get_required_mask;
219
	ia64_mv_irq_to_vector *irq_to_vector;
L
Linus Torvalds 已提交
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
	ia64_mv_local_vector_to_irq *local_vector_to_irq;
	ia64_mv_pci_get_legacy_mem_t *pci_get_legacy_mem;
	ia64_mv_pci_legacy_read_t *pci_legacy_read;
	ia64_mv_pci_legacy_write_t *pci_legacy_write;
	ia64_mv_inb_t *inb;
	ia64_mv_inw_t *inw;
	ia64_mv_inl_t *inl;
	ia64_mv_outb_t *outb;
	ia64_mv_outw_t *outw;
	ia64_mv_outl_t *outl;
	ia64_mv_mmiowb_t *mmiowb;
	ia64_mv_readb_t *readb;
	ia64_mv_readw_t *readw;
	ia64_mv_readl_t *readl;
	ia64_mv_readq_t *readq;
	ia64_mv_readb_relaxed_t *readb_relaxed;
	ia64_mv_readw_relaxed_t *readw_relaxed;
	ia64_mv_readl_relaxed_t *readl_relaxed;
	ia64_mv_readq_relaxed_t *readq_relaxed;
239
	ia64_mv_migrate_t *migrate;
240 241
	ia64_mv_setup_msi_irq_t *setup_msi_irq;
	ia64_mv_teardown_msi_irq_t *teardown_msi_irq;
J
John Keller 已提交
242
	ia64_mv_pci_fixup_bus_t *pci_fixup_bus;
Z
Zou Nan hai 已提交
243
	ia64_mv_kernel_launch_event_t *kernel_launch_event;
L
Linus Torvalds 已提交
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
} __attribute__((__aligned__(16))); /* align attrib? see above comment */

#define MACHVEC_INIT(name)			\
{						\
	#name,					\
	platform_setup,				\
	platform_cpu_init,			\
	platform_irq_init,			\
	platform_send_ipi,			\
	platform_timer_interrupt,		\
	platform_global_tlb_purge,		\
	platform_tlb_migrate_finish,		\
	platform_dma_init,			\
	platform_dma_alloc_coherent,		\
	platform_dma_free_coherent,		\
259 260 261 262
	platform_dma_map_single_attrs,		\
	platform_dma_unmap_single_attrs,	\
	platform_dma_map_sg_attrs,		\
	platform_dma_unmap_sg_attrs,		\
L
Linus Torvalds 已提交
263 264 265 266 267 268
	platform_dma_sync_single_for_cpu,	\
	platform_dma_sync_sg_for_cpu,		\
	platform_dma_sync_single_for_device,	\
	platform_dma_sync_sg_for_device,	\
	platform_dma_mapping_error,			\
	platform_dma_supported,			\
269
	platform_dma_get_required_mask,		\
270
	platform_irq_to_vector,			\
L
Linus Torvalds 已提交
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
	platform_local_vector_to_irq,		\
	platform_pci_get_legacy_mem,		\
	platform_pci_legacy_read,		\
	platform_pci_legacy_write,		\
	platform_inb,				\
	platform_inw,				\
	platform_inl,				\
	platform_outb,				\
	platform_outw,				\
	platform_outl,				\
	platform_mmiowb,			\
	platform_readb,				\
	platform_readw,				\
	platform_readl,				\
	platform_readq,				\
	platform_readb_relaxed,			\
	platform_readw_relaxed,			\
	platform_readl_relaxed,			\
	platform_readq_relaxed,			\
290
	platform_migrate,			\
291 292
	platform_setup_msi_irq,			\
	platform_teardown_msi_irq,		\
J
John Keller 已提交
293
	platform_pci_fixup_bus,			\
294
	platform_kernel_launch_event            \
L
Linus Torvalds 已提交
295 296 297 298
}

extern struct ia64_machine_vector ia64_mv;
extern void machvec_init (const char *name);
299
extern void machvec_init_from_cmdline(const char *cmdline);
L
Linus Torvalds 已提交
300 301

# else
302
#  error Unknown configuration.  Update arch/ia64/include/asm/machvec.h.
L
Linus Torvalds 已提交
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
# endif /* CONFIG_IA64_GENERIC */

/*
 * Define default versions so we can extend machvec for new platforms without having
 * to update the machvec files for all existing platforms.
 */
#ifndef platform_setup
# define platform_setup			machvec_setup
#endif
#ifndef platform_cpu_init
# define platform_cpu_init		machvec_noop
#endif
#ifndef platform_irq_init
# define platform_irq_init		machvec_noop
#endif

#ifndef platform_send_ipi
# define platform_send_ipi		ia64_send_ipi	/* default to architected version */
#endif
#ifndef platform_timer_interrupt
# define platform_timer_interrupt 	machvec_timer_interrupt
#endif
#ifndef platform_global_tlb_purge
# define platform_global_tlb_purge	ia64_global_tlb_purge /* default to architected version */
#endif
#ifndef platform_tlb_migrate_finish
# define platform_tlb_migrate_finish	machvec_noop_mm
#endif
Z
Zou Nan hai 已提交
331 332 333
#ifndef platform_kernel_launch_event
# define platform_kernel_launch_event	machvec_noop
#endif
L
Linus Torvalds 已提交
334 335 336 337 338 339 340 341 342
#ifndef platform_dma_init
# define platform_dma_init		swiotlb_init
#endif
#ifndef platform_dma_alloc_coherent
# define platform_dma_alloc_coherent	swiotlb_alloc_coherent
#endif
#ifndef platform_dma_free_coherent
# define platform_dma_free_coherent	swiotlb_free_coherent
#endif
343 344
#ifndef platform_dma_map_single_attrs
# define platform_dma_map_single_attrs	swiotlb_map_single_attrs
L
Linus Torvalds 已提交
345
#endif
346 347
#ifndef platform_dma_unmap_single_attrs
# define platform_dma_unmap_single_attrs	swiotlb_unmap_single_attrs
L
Linus Torvalds 已提交
348
#endif
349 350
#ifndef platform_dma_map_sg_attrs
# define platform_dma_map_sg_attrs	swiotlb_map_sg_attrs
L
Linus Torvalds 已提交
351
#endif
352 353
#ifndef platform_dma_unmap_sg_attrs
# define platform_dma_unmap_sg_attrs	swiotlb_unmap_sg_attrs
L
Linus Torvalds 已提交
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
#endif
#ifndef platform_dma_sync_single_for_cpu
# define platform_dma_sync_single_for_cpu	swiotlb_sync_single_for_cpu
#endif
#ifndef platform_dma_sync_sg_for_cpu
# define platform_dma_sync_sg_for_cpu		swiotlb_sync_sg_for_cpu
#endif
#ifndef platform_dma_sync_single_for_device
# define platform_dma_sync_single_for_device	swiotlb_sync_single_for_device
#endif
#ifndef platform_dma_sync_sg_for_device
# define platform_dma_sync_sg_for_device	swiotlb_sync_sg_for_device
#endif
#ifndef platform_dma_mapping_error
# define platform_dma_mapping_error		swiotlb_dma_mapping_error
#endif
#ifndef platform_dma_supported
# define  platform_dma_supported	swiotlb_dma_supported
#endif
373 374 375
#ifndef platform_dma_get_required_mask
# define  platform_dma_get_required_mask	ia64_dma_get_required_mask
#endif
376 377 378
#ifndef platform_irq_to_vector
# define platform_irq_to_vector		__ia64_irq_to_vector
#endif
L
Linus Torvalds 已提交
379 380 381 382 383 384 385 386
#ifndef platform_local_vector_to_irq
# define platform_local_vector_to_irq	__ia64_local_vector_to_irq
#endif
#ifndef platform_pci_get_legacy_mem
# define platform_pci_get_legacy_mem	ia64_pci_get_legacy_mem
#endif
#ifndef platform_pci_legacy_read
# define platform_pci_legacy_read	ia64_pci_legacy_read
387
extern int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size);
L
Linus Torvalds 已提交
388 389 390
#endif
#ifndef platform_pci_legacy_write
# define platform_pci_legacy_write	ia64_pci_legacy_write
391
extern int ia64_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size);
L
Linus Torvalds 已提交
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
#endif
#ifndef platform_inb
# define platform_inb		__ia64_inb
#endif
#ifndef platform_inw
# define platform_inw		__ia64_inw
#endif
#ifndef platform_inl
# define platform_inl		__ia64_inl
#endif
#ifndef platform_outb
# define platform_outb		__ia64_outb
#endif
#ifndef platform_outw
# define platform_outw		__ia64_outw
#endif
#ifndef platform_outl
# define platform_outl		__ia64_outl
#endif
#ifndef platform_mmiowb
# define platform_mmiowb	__ia64_mmiowb
#endif
#ifndef platform_readb
# define platform_readb		__ia64_readb
#endif
#ifndef platform_readw
# define platform_readw		__ia64_readw
#endif
#ifndef platform_readl
# define platform_readl		__ia64_readl
#endif
#ifndef platform_readq
# define platform_readq		__ia64_readq
#endif
#ifndef platform_readb_relaxed
# define platform_readb_relaxed	__ia64_readb_relaxed
#endif
#ifndef platform_readw_relaxed
# define platform_readw_relaxed	__ia64_readw_relaxed
#endif
#ifndef platform_readl_relaxed
# define platform_readl_relaxed	__ia64_readl_relaxed
#endif
#ifndef platform_readq_relaxed
# define platform_readq_relaxed	__ia64_readq_relaxed
#endif
438 439 440
#ifndef platform_migrate
# define platform_migrate machvec_noop_task
#endif
441 442 443 444 445
#ifndef platform_setup_msi_irq
# define platform_setup_msi_irq		((ia64_mv_setup_msi_irq_t*)NULL)
#endif
#ifndef platform_teardown_msi_irq
# define platform_teardown_msi_irq	((ia64_mv_teardown_msi_irq_t*)NULL)
446
#endif
J
John Keller 已提交
447 448 449
#ifndef platform_pci_fixup_bus
# define platform_pci_fixup_bus	machvec_noop_bus
#endif
L
Linus Torvalds 已提交
450 451

#endif /* _ASM_IA64_MACHVEC_H */