bios.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_X86_UV_BIOS_H
  3. #define _ASM_X86_UV_BIOS_H
  4. /*
  5. * UV BIOS layer definitions.
  6. *
  7. * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
  8. * Copyright (C) 2007-2017 Silicon Graphics, Inc. All rights reserved.
  9. * Copyright (c) Russ Anderson <[email protected]>
  10. */
  11. #include <linux/rtc.h>
  12. /*
  13. * Values for the BIOS calls. It is passed as the first * argument in the
  14. * BIOS call. Passing any other value in the first argument will result
  15. * in a BIOS_STATUS_UNIMPLEMENTED return status.
  16. */
  17. enum uv_bios_cmd {
  18. UV_BIOS_COMMON,
  19. UV_BIOS_GET_SN_INFO,
  20. UV_BIOS_FREQ_BASE,
  21. UV_BIOS_WATCHLIST_ALLOC,
  22. UV_BIOS_WATCHLIST_FREE,
  23. UV_BIOS_MEMPROTECT,
  24. UV_BIOS_GET_PARTITION_ADDR,
  25. UV_BIOS_SET_LEGACY_VGA_TARGET
  26. };
  27. #define UV_BIOS_EXTRA 0x10000
  28. #define UV_BIOS_GET_PCI_TOPOLOGY 0x10001
  29. #define UV_BIOS_GET_GEOINFO 0x10003
  30. #define UV_BIOS_EXTRA_OP_MEM_COPYIN 0x1000
  31. #define UV_BIOS_EXTRA_OP_MEM_COPYOUT 0x2000
  32. #define UV_BIOS_EXTRA_OP_MASK 0x0fff
  33. #define UV_BIOS_EXTRA_GET_HEAPSIZE 1
  34. #define UV_BIOS_EXTRA_INSTALL_HEAP 2
  35. #define UV_BIOS_EXTRA_MASTER_NASID 3
  36. #define UV_BIOS_EXTRA_OBJECT_COUNT (10|UV_BIOS_EXTRA_OP_MEM_COPYOUT)
  37. #define UV_BIOS_EXTRA_ENUM_OBJECTS (12|UV_BIOS_EXTRA_OP_MEM_COPYOUT)
  38. #define UV_BIOS_EXTRA_ENUM_PORTS (13|UV_BIOS_EXTRA_OP_MEM_COPYOUT)
  39. /*
  40. * Status values returned from a BIOS call.
  41. */
  42. enum {
  43. BIOS_STATUS_MORE_PASSES = 1,
  44. BIOS_STATUS_SUCCESS = 0,
  45. BIOS_STATUS_UNIMPLEMENTED = -ENOSYS,
  46. BIOS_STATUS_EINVAL = -EINVAL,
  47. BIOS_STATUS_UNAVAIL = -EBUSY,
  48. BIOS_STATUS_ABORT = -EINTR,
  49. };
  50. /* Address map parameters */
  51. struct uv_gam_parameters {
  52. u64 mmr_base;
  53. u64 gru_base;
  54. u8 mmr_shift; /* Convert PNode to MMR space offset */
  55. u8 gru_shift; /* Convert PNode to GRU space offset */
  56. u8 gpa_shift; /* Size of offset field in GRU phys addr */
  57. u8 unused1;
  58. };
  59. /* UV_TABLE_GAM_RANGE_ENTRY values */
  60. #define UV_GAM_RANGE_TYPE_UNUSED 0 /* End of table */
  61. #define UV_GAM_RANGE_TYPE_RAM 1 /* Normal RAM */
  62. #define UV_GAM_RANGE_TYPE_NVRAM 2 /* Non-volatile memory */
  63. #define UV_GAM_RANGE_TYPE_NV_WINDOW 3 /* NVMDIMM block window */
  64. #define UV_GAM_RANGE_TYPE_NV_MAILBOX 4 /* NVMDIMM mailbox */
  65. #define UV_GAM_RANGE_TYPE_HOLE 5 /* Unused address range */
  66. #define UV_GAM_RANGE_TYPE_MAX 6
  67. /* The structure stores PA bits 56:26, for 64MB granularity */
  68. #define UV_GAM_RANGE_SHFT 26 /* 64MB */
  69. struct uv_gam_range_entry {
  70. char type; /* Entry type: GAM_RANGE_TYPE_UNUSED, etc. */
  71. char unused1;
  72. u16 nasid; /* HNasid */
  73. u16 sockid; /* Socket ID, high bits of APIC ID */
  74. u16 pnode; /* Index to MMR and GRU spaces */
  75. u32 unused2;
  76. u32 limit; /* PA bits 56:26 (UV_GAM_RANGE_SHFT) */
  77. };
  78. #define UV_AT_SIZE 8 /* 7 character arch type + NULL char */
  79. struct uv_arch_type_entry {
  80. char archtype[UV_AT_SIZE];
  81. };
  82. #define UV_SYSTAB_SIG "UVST"
  83. #define UV_SYSTAB_VERSION_1 1 /* UV2/3 BIOS version */
  84. #define UV_SYSTAB_VERSION_UV4 0x400 /* UV4 BIOS base version */
  85. #define UV_SYSTAB_VERSION_UV4_1 0x401 /* + gpa_shift */
  86. #define UV_SYSTAB_VERSION_UV4_2 0x402 /* + TYPE_NVRAM/WINDOW/MBOX */
  87. #define UV_SYSTAB_VERSION_UV4_3 0x403 /* - GAM Range PXM Value */
  88. #define UV_SYSTAB_VERSION_UV4_LATEST UV_SYSTAB_VERSION_UV4_3
  89. #define UV_SYSTAB_VERSION_UV5 0x500 /* UV5 GAM base version */
  90. #define UV_SYSTAB_VERSION_UV5_LATEST UV_SYSTAB_VERSION_UV5
  91. #define UV_SYSTAB_TYPE_UNUSED 0 /* End of table (offset == 0) */
  92. #define UV_SYSTAB_TYPE_GAM_PARAMS 1 /* GAM PARAM conversions */
  93. #define UV_SYSTAB_TYPE_GAM_RNG_TBL 2 /* GAM entry table */
  94. #define UV_SYSTAB_TYPE_ARCH_TYPE 3 /* UV arch type */
  95. #define UV_SYSTAB_TYPE_MAX 4
  96. /*
  97. * The UV system table describes specific firmware
  98. * capabilities available to the Linux kernel at runtime.
  99. */
  100. struct uv_systab {
  101. char signature[4]; /* must be UV_SYSTAB_SIG */
  102. u32 revision; /* distinguish different firmware revs */
  103. u64 function; /* BIOS runtime callback function ptr */
  104. u32 size; /* systab size (starting with _VERSION_UV4) */
  105. struct {
  106. u32 type:8; /* type of entry */
  107. u32 offset:24; /* byte offset from struct start to entry */
  108. } entry[1]; /* additional entries follow */
  109. };
  110. extern struct uv_systab *uv_systab;
  111. #define UV_BIOS_MAXSTRING 128
  112. struct uv_bios_hub_info {
  113. unsigned int id;
  114. union {
  115. struct {
  116. unsigned long long this_part:1;
  117. unsigned long long is_shared:1;
  118. unsigned long long is_disabled:1;
  119. } fields;
  120. struct {
  121. unsigned long long flags;
  122. unsigned long long reserved;
  123. } b;
  124. } f;
  125. char name[UV_BIOS_MAXSTRING];
  126. char location[UV_BIOS_MAXSTRING];
  127. unsigned int ports;
  128. };
  129. struct uv_bios_port_info {
  130. unsigned int port;
  131. unsigned int conn_id;
  132. unsigned int conn_port;
  133. };
  134. /* (... end of definitions from UV BIOS ...) */
  135. enum {
  136. BIOS_FREQ_BASE_PLATFORM = 0,
  137. BIOS_FREQ_BASE_INTERVAL_TIMER = 1,
  138. BIOS_FREQ_BASE_REALTIME_CLOCK = 2
  139. };
  140. union partition_info_u {
  141. u64 val;
  142. struct {
  143. u64 hub_version : 8,
  144. partition_id : 16,
  145. coherence_id : 16,
  146. region_size : 24;
  147. };
  148. };
  149. enum uv_memprotect {
  150. UV_MEMPROT_RESTRICT_ACCESS,
  151. UV_MEMPROT_ALLOW_AMO,
  152. UV_MEMPROT_ALLOW_RW
  153. };
  154. extern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *, long *);
  155. extern s64 uv_bios_freq_base(u64, u64 *);
  156. extern int uv_bios_mq_watchlist_alloc(unsigned long, unsigned int,
  157. unsigned long *);
  158. extern int uv_bios_mq_watchlist_free(int, int);
  159. extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect);
  160. extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *);
  161. extern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus);
  162. extern s64 uv_bios_get_master_nasid(u64 sz, u64 *nasid);
  163. extern s64 uv_bios_get_heapsize(u64 nasid, u64 sz, u64 *heap_sz);
  164. extern s64 uv_bios_install_heap(u64 nasid, u64 sz, u64 *heap);
  165. extern s64 uv_bios_obj_count(u64 nasid, u64 sz, u64 *objcnt);
  166. extern s64 uv_bios_enum_objs(u64 nasid, u64 sz, u64 *objbuf);
  167. extern s64 uv_bios_enum_ports(u64 nasid, u64 obj_id, u64 sz, u64 *portbuf);
  168. extern s64 uv_bios_get_geoinfo(u64 nasid, u64 sz, u64 *geo);
  169. extern s64 uv_bios_get_pci_topology(u64 sz, u64 *buf);
  170. extern int uv_bios_init(void);
  171. extern unsigned long get_uv_systab_phys(bool msg);
  172. extern unsigned long sn_rtc_cycles_per_second;
  173. extern int uv_type;
  174. extern long sn_partition_id;
  175. extern long sn_coherency_id;
  176. extern long sn_region_size;
  177. extern long system_serial_number;
  178. extern ssize_t uv_get_archtype(char *buf, int len);
  179. extern int uv_get_hubless_system(void);
  180. extern struct kobject *sgi_uv_kobj; /* /sys/firmware/sgi_uv */
  181. /*
  182. * EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details
  183. */
  184. extern struct semaphore __efi_uv_runtime_lock;
  185. #endif /* _ASM_X86_UV_BIOS_H */