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 /* 6 * UV BIOS layer definitions. 7 * 8 * Copyright (c) 2008-2009 Silicon Graphics, Inc. All Rights Reserved. 9 * Copyright (c) Russ Anderson <rja@sgi.com> 10 */ 11 12 #include <linux/rtc.h> 13 14 /* 15 * Values for the BIOS calls. It is passed as the first * argument in the 16 * BIOS call. Passing any other value in the first argument will result 17 * in a BIOS_STATUS_UNIMPLEMENTED return status. 18 */ 19 enum uv_bios_cmd { 20 UV_BIOS_COMMON, 21 UV_BIOS_GET_SN_INFO, 22 UV_BIOS_FREQ_BASE, 23 UV_BIOS_WATCHLIST_ALLOC, 24 UV_BIOS_WATCHLIST_FREE, 25 UV_BIOS_MEMPROTECT, 26 UV_BIOS_GET_PARTITION_ADDR, 27 UV_BIOS_SET_LEGACY_VGA_TARGET 28 }; 29 30 /* 31 * Status values returned from a BIOS call. 32 */ 33 enum { 34 BIOS_STATUS_MORE_PASSES = 1, 35 BIOS_STATUS_SUCCESS = 0, 36 BIOS_STATUS_UNIMPLEMENTED = -ENOSYS, 37 BIOS_STATUS_EINVAL = -EINVAL, 38 BIOS_STATUS_UNAVAIL = -EBUSY, 39 BIOS_STATUS_ABORT = -EINTR, 40 }; 41 42 /* Address map parameters */ 43 struct uv_gam_parameters { 44 u64 mmr_base; 45 u64 gru_base; 46 u8 mmr_shift; /* Convert PNode to MMR space offset */ 47 u8 gru_shift; /* Convert PNode to GRU space offset */ 48 u8 gpa_shift; /* Size of offset field in GRU phys addr */ 49 u8 unused1; 50 }; 51 52 /* UV_TABLE_GAM_RANGE_ENTRY values */ 53 #define UV_GAM_RANGE_TYPE_UNUSED 0 /* End of table */ 54 #define UV_GAM_RANGE_TYPE_RAM 1 /* Normal RAM */ 55 #define UV_GAM_RANGE_TYPE_NVRAM 2 /* Non-volatile memory */ 56 #define UV_GAM_RANGE_TYPE_NV_WINDOW 3 /* NVMDIMM block window */ 57 #define UV_GAM_RANGE_TYPE_NV_MAILBOX 4 /* NVMDIMM mailbox */ 58 #define UV_GAM_RANGE_TYPE_HOLE 5 /* Unused address range */ 59 #define UV_GAM_RANGE_TYPE_MAX 6 60 61 /* The structure stores PA bits 56:26, for 64MB granularity */ 62 #define UV_GAM_RANGE_SHFT 26 /* 64MB */ 63 64 struct uv_gam_range_entry { 65 char type; /* Entry type: GAM_RANGE_TYPE_UNUSED, etc. */ 66 char unused1; 67 u16 nasid; /* HNasid */ 68 u16 sockid; /* Socket ID, high bits of APIC ID */ 69 u16 pnode; /* Index to MMR and GRU spaces */ 70 u32 unused2; 71 u32 limit; /* PA bits 56:26 (UV_GAM_RANGE_SHFT) */ 72 }; 73 74 #define UV_SYSTAB_SIG "UVST" 75 #define UV_SYSTAB_VERSION_1 1 /* UV1/2/3 BIOS version */ 76 #define UV_SYSTAB_VERSION_UV4 0x400 /* UV4 BIOS base version */ 77 #define UV_SYSTAB_VERSION_UV4_1 0x401 /* + gpa_shift */ 78 #define UV_SYSTAB_VERSION_UV4_2 0x402 /* + TYPE_NVRAM/WINDOW/MBOX */ 79 #define UV_SYSTAB_VERSION_UV4_3 0x403 /* - GAM Range PXM Value */ 80 #define UV_SYSTAB_VERSION_UV4_LATEST UV_SYSTAB_VERSION_UV4_3 81 82 #define UV_SYSTAB_TYPE_UNUSED 0 /* End of table (offset == 0) */ 83 #define UV_SYSTAB_TYPE_GAM_PARAMS 1 /* GAM PARAM conversions */ 84 #define UV_SYSTAB_TYPE_GAM_RNG_TBL 2 /* GAM entry table */ 85 #define UV_SYSTAB_TYPE_MAX 3 86 87 /* 88 * The UV system table describes specific firmware 89 * capabilities available to the Linux kernel at runtime. 90 */ 91 struct uv_systab { 92 char signature[4]; /* must be UV_SYSTAB_SIG */ 93 u32 revision; /* distinguish different firmware revs */ 94 u64 function; /* BIOS runtime callback function ptr */ 95 u32 size; /* systab size (starting with _VERSION_UV4) */ 96 struct { 97 u32 type:8; /* type of entry */ 98 u32 offset:24; /* byte offset from struct start to entry */ 99 } entry[1]; /* additional entries follow */ 100 }; 101 extern struct uv_systab *uv_systab; 102 /* (... end of definitions from UV BIOS ...) */ 103 104 enum { 105 BIOS_FREQ_BASE_PLATFORM = 0, 106 BIOS_FREQ_BASE_INTERVAL_TIMER = 1, 107 BIOS_FREQ_BASE_REALTIME_CLOCK = 2 108 }; 109 110 union partition_info_u { 111 u64 val; 112 struct { 113 u64 hub_version : 8, 114 partition_id : 16, 115 coherence_id : 16, 116 region_size : 24; 117 }; 118 }; 119 120 enum uv_memprotect { 121 UV_MEMPROT_RESTRICT_ACCESS, 122 UV_MEMPROT_ALLOW_AMO, 123 UV_MEMPROT_ALLOW_RW 124 }; 125 126 extern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *, long *); 127 extern s64 uv_bios_freq_base(u64, u64 *); 128 extern int uv_bios_mq_watchlist_alloc(unsigned long, unsigned int, 129 unsigned long *); 130 extern int uv_bios_mq_watchlist_free(int, int); 131 extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect); 132 extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *); 133 extern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus); 134 135 extern int uv_bios_init(void); 136 137 extern unsigned long sn_rtc_cycles_per_second; 138 extern int uv_type; 139 extern long sn_partition_id; 140 extern long sn_coherency_id; 141 extern long sn_region_size; 142 extern long system_serial_number; 143 144 extern struct kobject *sgi_uv_kobj; /* /sys/firmware/sgi_uv */ 145 146 /* 147 * EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details 148 */ 149 extern struct semaphore __efi_uv_runtime_lock; 150 151 #endif /* _ASM_X86_UV_BIOS_H */ 152