system.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #ifndef _ASM_IA64_SYSTEM_H
  2. #define _ASM_IA64_SYSTEM_H
  3. /*
  4. * System defines. Note that this is included both from .c and .S
  5. * files, so it does only defines, not any C code. This is based
  6. * on information published in the Processor Abstraction Layer
  7. * and the System Abstraction Layer manual.
  8. *
  9. * Copyright (C) 1998-2003 Hewlett-Packard Co
  10. * David Mosberger-Tang <davidm@hpl.hp.com>
  11. * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
  12. * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
  13. */
  14. #include <asm/kregs.h>
  15. #include <asm/page.h>
  16. #include <asm/pal.h>
  17. #include <asm/percpu.h>
  18. #define GATE_ADDR RGN_BASE(RGN_GATE)
  19. /*
  20. * 0xa000000000000000+2*PERCPU_PAGE_SIZE
  21. * - 0xa000000000000000+3*PERCPU_PAGE_SIZE remain unmapped (guard page)
  22. */
  23. #define KERNEL_START (GATE_ADDR+__IA64_UL_CONST(0x100000000))
  24. #define PERCPU_ADDR (-PERCPU_PAGE_SIZE)
  25. #define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE)
  26. #ifndef __ASSEMBLY__
  27. #include <linux/kernel.h>
  28. #include <linux/types.h>
  29. #define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */
  30. struct pci_vector_struct {
  31. __u16 segment; /* PCI Segment number */
  32. __u16 bus; /* PCI Bus number */
  33. __u32 pci_id; /* ACPI split 16 bits device, 16 bits function (see section 6.1.1) */
  34. __u8 pin; /* PCI PIN (0 = A, 1 = B, 2 = C, 3 = D) */
  35. __u32 irq; /* IRQ assigned */
  36. };
  37. extern struct ia64_boot_param {
  38. __u64 command_line; /* physical address of command line arguments */
  39. __u64 efi_systab; /* physical address of EFI system table */
  40. __u64 efi_memmap; /* physical address of EFI memory map */
  41. __u64 efi_memmap_size; /* size of EFI memory map */
  42. __u64 efi_memdesc_size; /* size of an EFI memory map descriptor */
  43. __u32 efi_memdesc_version; /* memory descriptor version */
  44. struct {
  45. __u16 num_cols; /* number of columns on console output device */
  46. __u16 num_rows; /* number of rows on console output device */
  47. __u16 orig_x; /* cursor's x position */
  48. __u16 orig_y; /* cursor's y position */
  49. } console_info;
  50. __u64 fpswa; /* physical address of the fpswa interface */
  51. __u64 initrd_start;
  52. __u64 initrd_size;
  53. } *ia64_boot_param;
  54. /*
  55. * Macros to force memory ordering. In these descriptions, "previous"
  56. * and "subsequent" refer to program order; "visible" means that all
  57. * architecturally visible effects of a memory access have occurred
  58. * (at a minimum, this means the memory has been read or written).
  59. *
  60. * wmb(): Guarantees that all preceding stores to memory-
  61. * like regions are visible before any subsequent
  62. * stores and that all following stores will be
  63. * visible only after all previous stores.
  64. * rmb(): Like wmb(), but for reads.
  65. * mb(): wmb()/rmb() combo, i.e., all previous memory
  66. * accesses are visible before all subsequent
  67. * accesses and vice versa. This is also known as
  68. * a "fence."
  69. *
  70. * Note: "mb()" and its variants cannot be used as a fence to order
  71. * accesses to memory mapped I/O registers. For that, mf.a needs to
  72. * be used. However, we don't want to always use mf.a because (a)
  73. * it's (presumably) much slower than mf and (b) mf.a is supported for
  74. * sequential memory pages only.
  75. */
  76. #define mb() ia64_mf()
  77. #define rmb() mb()
  78. #define wmb() mb()
  79. #define read_barrier_depends() do { } while(0)
  80. #ifdef CONFIG_SMP
  81. # define smp_mb() mb()
  82. # define smp_rmb() rmb()
  83. # define smp_wmb() wmb()
  84. # define smp_read_barrier_depends() read_barrier_depends()
  85. #else
  86. # define smp_mb() barrier()
  87. # define smp_rmb() barrier()
  88. # define smp_wmb() barrier()
  89. # define smp_read_barrier_depends() do { } while(0)
  90. #endif
  91. /*
  92. * XXX check on this ---I suspect what Linus really wants here is
  93. * acquire vs release semantics but we can't discuss this stuff with
  94. * Linus just yet. Grrr...
  95. */
  96. #define set_mb(var, value) do { (var) = (value); mb(); } while (0)
  97. /*
  98. * The group barrier in front of the rsm & ssm are necessary to ensure
  99. * that none of the previous instructions in the same group are
  100. * affected by the rsm/ssm.
  101. */
  102. #ifdef __KERNEL__
  103. /*
  104. * Context switch from one thread to another. If the two threads have
  105. * different address spaces, schedule() has already taken care of
  106. * switching to the new address space by calling switch_mm().
  107. *
  108. * Disabling access to the fph partition and the debug-register
  109. * context switch MUST be done before calling ia64_switch_to() since a
  110. * newly created thread returns directly to
  111. * ia64_ret_from_syscall_clear_r8.
  112. */
  113. extern struct task_struct *ia64_switch_to (void *next_task);
  114. struct task_struct;
  115. extern void ia64_save_extra (struct task_struct *task);
  116. extern void ia64_load_extra (struct task_struct *task);
  117. #ifdef CONFIG_VIRT_CPU_ACCOUNTING
  118. extern void ia64_account_on_switch (struct task_struct *prev, struct task_struct *next);
  119. # define IA64_ACCOUNT_ON_SWITCH(p,n) ia64_account_on_switch(p,n)
  120. #else
  121. # define IA64_ACCOUNT_ON_SWITCH(p,n)
  122. #endif
  123. #ifdef CONFIG_PERFMON
  124. DECLARE_PER_CPU(unsigned long, pfm_syst_info);
  125. # define PERFMON_IS_SYSWIDE() (__get_cpu_var(pfm_syst_info) & 0x1)
  126. #else
  127. # define PERFMON_IS_SYSWIDE() (0)
  128. #endif
  129. #define IA64_HAS_EXTRA_STATE(t) \
  130. ((t)->thread.flags & (IA64_THREAD_DBG_VALID|IA64_THREAD_PM_VALID) \
  131. || PERFMON_IS_SYSWIDE())
  132. #define __switch_to(prev,next,last) do { \
  133. IA64_ACCOUNT_ON_SWITCH(prev, next); \
  134. if (IA64_HAS_EXTRA_STATE(prev)) \
  135. ia64_save_extra(prev); \
  136. if (IA64_HAS_EXTRA_STATE(next)) \
  137. ia64_load_extra(next); \
  138. ia64_psr(task_pt_regs(next))->dfh = !ia64_is_local_fpu_owner(next); \
  139. (last) = ia64_switch_to((next)); \
  140. } while (0)
  141. #ifdef CONFIG_SMP
  142. /*
  143. * In the SMP case, we save the fph state when context-switching away from a thread that
  144. * modified fph. This way, when the thread gets scheduled on another CPU, the CPU can
  145. * pick up the state from task->thread.fph, avoiding the complication of having to fetch
  146. * the latest fph state from another CPU. In other words: eager save, lazy restore.
  147. */
  148. # define switch_to(prev,next,last) do { \
  149. if (ia64_psr(task_pt_regs(prev))->mfh && ia64_is_local_fpu_owner(prev)) { \
  150. ia64_psr(task_pt_regs(prev))->mfh = 0; \
  151. (prev)->thread.flags |= IA64_THREAD_FPH_VALID; \
  152. __ia64_save_fpu((prev)->thread.fph); \
  153. } \
  154. __switch_to(prev, next, last); \
  155. /* "next" in old context is "current" in new context */ \
  156. if (unlikely((current->thread.flags & IA64_THREAD_MIGRATION) && \
  157. (task_cpu(current) != \
  158. task_thread_info(current)->last_cpu))) { \
  159. platform_migrate(current); \
  160. task_thread_info(current)->last_cpu = task_cpu(current); \
  161. } \
  162. } while (0)
  163. #else
  164. # define switch_to(prev,next,last) __switch_to(prev, next, last)
  165. #endif
  166. #define __ARCH_WANT_UNLOCKED_CTXSW
  167. #define ARCH_HAS_PREFETCH_SWITCH_STACK
  168. #define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
  169. void cpu_idle_wait(void);
  170. #define arch_align_stack(x) (x)
  171. void default_idle(void);
  172. #endif /* __KERNEL__ */
  173. #endif /* __ASSEMBLY__ */
  174. #endif /* _ASM_IA64_SYSTEM_H */