Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _ASM_X86_UV_BIOS_H
0003 #define _ASM_X86_UV_BIOS_H
0004 
0005 /*
0006  * UV BIOS layer definitions.
0007  *
0008  * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
0009  * Copyright (C) 2007-2017 Silicon Graphics, Inc. All rights reserved.
0010  * Copyright (c) Russ Anderson <rja@sgi.com>
0011  */
0012 
0013 #include <linux/rtc.h>
0014 
0015 /*
0016  * Values for the BIOS calls.  It is passed as the first * argument in the
0017  * BIOS call.  Passing any other value in the first argument will result
0018  * in a BIOS_STATUS_UNIMPLEMENTED return status.
0019  */
0020 enum uv_bios_cmd {
0021     UV_BIOS_COMMON,
0022     UV_BIOS_GET_SN_INFO,
0023     UV_BIOS_FREQ_BASE,
0024     UV_BIOS_WATCHLIST_ALLOC,
0025     UV_BIOS_WATCHLIST_FREE,
0026     UV_BIOS_MEMPROTECT,
0027     UV_BIOS_GET_PARTITION_ADDR,
0028     UV_BIOS_SET_LEGACY_VGA_TARGET
0029 };
0030 
0031 #define UV_BIOS_EXTRA               0x10000
0032 #define UV_BIOS_GET_PCI_TOPOLOGY        0x10001
0033 #define UV_BIOS_GET_GEOINFO         0x10003
0034 
0035 #define UV_BIOS_EXTRA_OP_MEM_COPYIN     0x1000
0036 #define UV_BIOS_EXTRA_OP_MEM_COPYOUT        0x2000
0037 #define UV_BIOS_EXTRA_OP_MASK           0x0fff
0038 #define UV_BIOS_EXTRA_GET_HEAPSIZE      1
0039 #define UV_BIOS_EXTRA_INSTALL_HEAP      2
0040 #define UV_BIOS_EXTRA_MASTER_NASID      3
0041 #define UV_BIOS_EXTRA_OBJECT_COUNT      (10|UV_BIOS_EXTRA_OP_MEM_COPYOUT)
0042 #define UV_BIOS_EXTRA_ENUM_OBJECTS      (12|UV_BIOS_EXTRA_OP_MEM_COPYOUT)
0043 #define UV_BIOS_EXTRA_ENUM_PORTS        (13|UV_BIOS_EXTRA_OP_MEM_COPYOUT)
0044 
0045 /*
0046  * Status values returned from a BIOS call.
0047  */
0048 enum {
0049     BIOS_STATUS_MORE_PASSES     =  1,
0050     BIOS_STATUS_SUCCESS     =  0,
0051     BIOS_STATUS_UNIMPLEMENTED   = -ENOSYS,
0052     BIOS_STATUS_EINVAL      = -EINVAL,
0053     BIOS_STATUS_UNAVAIL     = -EBUSY,
0054     BIOS_STATUS_ABORT       = -EINTR,
0055 };
0056 
0057 /* Address map parameters */
0058 struct uv_gam_parameters {
0059     u64 mmr_base;
0060     u64 gru_base;
0061     u8  mmr_shift;  /* Convert PNode to MMR space offset */
0062     u8  gru_shift;  /* Convert PNode to GRU space offset */
0063     u8  gpa_shift;  /* Size of offset field in GRU phys addr */
0064     u8  unused1;
0065 };
0066 
0067 /* UV_TABLE_GAM_RANGE_ENTRY values */
0068 #define UV_GAM_RANGE_TYPE_UNUSED    0 /* End of table */
0069 #define UV_GAM_RANGE_TYPE_RAM       1 /* Normal RAM */
0070 #define UV_GAM_RANGE_TYPE_NVRAM     2 /* Non-volatile memory */
0071 #define UV_GAM_RANGE_TYPE_NV_WINDOW 3 /* NVMDIMM block window */
0072 #define UV_GAM_RANGE_TYPE_NV_MAILBOX    4 /* NVMDIMM mailbox */
0073 #define UV_GAM_RANGE_TYPE_HOLE      5 /* Unused address range */
0074 #define UV_GAM_RANGE_TYPE_MAX       6
0075 
0076 /* The structure stores PA bits 56:26, for 64MB granularity */
0077 #define UV_GAM_RANGE_SHFT       26      /* 64MB */
0078 
0079 struct uv_gam_range_entry {
0080     char    type;       /* Entry type: GAM_RANGE_TYPE_UNUSED, etc. */
0081     char    unused1;
0082     u16 nasid;      /* HNasid */
0083     u16 sockid;     /* Socket ID, high bits of APIC ID */
0084     u16 pnode;      /* Index to MMR and GRU spaces */
0085     u32 unused2;
0086     u32 limit;      /* PA bits 56:26 (UV_GAM_RANGE_SHFT) */
0087 };
0088 
0089 #define UV_AT_SIZE  8   /* 7 character arch type + NULL char */
0090 struct uv_arch_type_entry {
0091     char    archtype[UV_AT_SIZE];
0092 };
0093 
0094 #define UV_SYSTAB_SIG           "UVST"
0095 #define UV_SYSTAB_VERSION_1     1   /* UV2/3 BIOS version */
0096 #define UV_SYSTAB_VERSION_UV4       0x400   /* UV4 BIOS base version */
0097 #define UV_SYSTAB_VERSION_UV4_1     0x401   /* + gpa_shift */
0098 #define UV_SYSTAB_VERSION_UV4_2     0x402   /* + TYPE_NVRAM/WINDOW/MBOX */
0099 #define UV_SYSTAB_VERSION_UV4_3     0x403   /* - GAM Range PXM Value */
0100 #define UV_SYSTAB_VERSION_UV4_LATEST    UV_SYSTAB_VERSION_UV4_3
0101 
0102 #define UV_SYSTAB_VERSION_UV5       0x500   /* UV5 GAM base version */
0103 #define UV_SYSTAB_VERSION_UV5_LATEST    UV_SYSTAB_VERSION_UV5
0104 
0105 #define UV_SYSTAB_TYPE_UNUSED       0   /* End of table (offset == 0) */
0106 #define UV_SYSTAB_TYPE_GAM_PARAMS   1   /* GAM PARAM conversions */
0107 #define UV_SYSTAB_TYPE_GAM_RNG_TBL  2   /* GAM entry table */
0108 #define UV_SYSTAB_TYPE_ARCH_TYPE    3   /* UV arch type */
0109 #define UV_SYSTAB_TYPE_MAX      4
0110 
0111 /*
0112  * The UV system table describes specific firmware
0113  * capabilities available to the Linux kernel at runtime.
0114  */
0115 struct uv_systab {
0116     char signature[4];  /* must be UV_SYSTAB_SIG */
0117     u32 revision;       /* distinguish different firmware revs */
0118     u64 function;       /* BIOS runtime callback function ptr */
0119     u32 size;       /* systab size (starting with _VERSION_UV4) */
0120     struct {
0121         u32 type:8; /* type of entry */
0122         u32 offset:24;  /* byte offset from struct start to entry */
0123     } entry[1];     /* additional entries follow */
0124 };
0125 extern struct uv_systab *uv_systab;
0126 
0127 #define UV_BIOS_MAXSTRING         128
0128 struct uv_bios_hub_info {
0129     unsigned int id;
0130     union {
0131         struct {
0132             unsigned long long this_part:1;
0133             unsigned long long is_shared:1;
0134             unsigned long long is_disabled:1;
0135         } fields;
0136         struct {
0137             unsigned long long flags;
0138             unsigned long long reserved;
0139         } b;
0140     } f;
0141     char name[UV_BIOS_MAXSTRING];
0142     char location[UV_BIOS_MAXSTRING];
0143     unsigned int ports;
0144 };
0145 
0146 struct uv_bios_port_info {
0147     unsigned int port;
0148     unsigned int conn_id;
0149     unsigned int conn_port;
0150 };
0151 
0152 /* (... end of definitions from UV BIOS ...) */
0153 
0154 enum {
0155     BIOS_FREQ_BASE_PLATFORM = 0,
0156     BIOS_FREQ_BASE_INTERVAL_TIMER = 1,
0157     BIOS_FREQ_BASE_REALTIME_CLOCK = 2
0158 };
0159 
0160 union partition_info_u {
0161     u64 val;
0162     struct {
0163         u64 hub_version :  8,
0164             partition_id    : 16,
0165             coherence_id    : 16,
0166             region_size : 24;
0167     };
0168 };
0169 
0170 enum uv_memprotect {
0171     UV_MEMPROT_RESTRICT_ACCESS,
0172     UV_MEMPROT_ALLOW_AMO,
0173     UV_MEMPROT_ALLOW_RW
0174 };
0175 
0176 extern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *, long *);
0177 extern s64 uv_bios_freq_base(u64, u64 *);
0178 extern int uv_bios_mq_watchlist_alloc(unsigned long, unsigned int,
0179                     unsigned long *);
0180 extern int uv_bios_mq_watchlist_free(int, int);
0181 extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect);
0182 extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *);
0183 extern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus);
0184 
0185 extern s64 uv_bios_get_master_nasid(u64 sz, u64 *nasid);
0186 extern s64 uv_bios_get_heapsize(u64 nasid, u64 sz, u64 *heap_sz);
0187 extern s64 uv_bios_install_heap(u64 nasid, u64 sz, u64 *heap);
0188 extern s64 uv_bios_obj_count(u64 nasid, u64 sz, u64 *objcnt);
0189 extern s64 uv_bios_enum_objs(u64 nasid, u64 sz, u64 *objbuf);
0190 extern s64 uv_bios_enum_ports(u64 nasid, u64 obj_id, u64 sz, u64 *portbuf);
0191 extern s64 uv_bios_get_geoinfo(u64 nasid, u64 sz, u64 *geo);
0192 extern s64 uv_bios_get_pci_topology(u64 sz, u64 *buf);
0193 
0194 extern int uv_bios_init(void);
0195 extern unsigned long get_uv_systab_phys(bool msg);
0196 
0197 extern unsigned long sn_rtc_cycles_per_second;
0198 extern int uv_type;
0199 extern long sn_partition_id;
0200 extern long sn_coherency_id;
0201 extern long sn_region_size;
0202 extern long system_serial_number;
0203 extern ssize_t uv_get_archtype(char *buf, int len);
0204 extern int uv_get_hubless_system(void);
0205 
0206 extern struct kobject *sgi_uv_kobj; /* /sys/firmware/sgi_uv */
0207 
0208 /*
0209  * EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details
0210  */
0211 extern struct semaphore __efi_uv_runtime_lock;
0212 
0213 #endif /* _ASM_X86_UV_BIOS_H */