1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * 25 * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. 26 * Copyright 2022 Joyent, Inc. 27 * Copyright 2025 Oxide Computer Company 28 */ 29 30 #ifndef _SYS_UCODE_AMD_H 31 #define _SYS_UCODE_AMD_H 32 33 #include <sys/stddef.h> 34 #include <sys/debug.h> 35 #include <sys/types.h> 36 #include <ucode/ucode_errno.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * AMD microcode is generally distributed in container files which start with a 44 * magic number and then contain multiple TLV-encoded sections. Typically such 45 * a file will contain an equivalence table section followed by one or more 46 * patches. 47 */ 48 #define UCODE_AMD_CONTAINER_MAGIC 0x00414d44 /* "AMD\0" */ 49 #define UCODE_AMD_CONTAINER_TYPE_EQUIV 0 50 #define UCODE_AMD_CONTAINER_TYPE_PATCH 1 51 52 typedef struct ucode_section_amd { 53 uint32_t usa_type; 54 uint32_t usa_size; 55 uint8_t usa_data[]; 56 } ucode_section_amd_t; 57 58 CTASSERT(sizeof (ucode_section_amd_t) == 8); 59 CTASSERT(offsetof(ucode_section_amd_t, usa_data) == 8); 60 61 /* 62 * AMD Microcode file information 63 */ 64 typedef struct ucode_header_amd { 65 uint32_t uh_date; 66 uint32_t uh_patch_id; 67 uint32_t uh_internal; /* patch data id & length, init flag */ 68 uint32_t uh_cksum; 69 uint32_t uh_nb_id; 70 uint32_t uh_sb_id; 71 uint16_t uh_cpu_rev; 72 uint8_t uh_nb_rev; 73 uint8_t uh_sb_rev; 74 uint32_t uh_bios_rev; 75 uint32_t uh_match[8]; 76 } ucode_header_amd_t; 77 78 /* 79 * This is the maximum size of a microcode blob that we are prepared to load 80 * in the kernel. AMD Turin microcode files are 14KiB and the size has been 81 * increasing with each generation. This value provides some margin for the 82 * future. 83 */ 84 #define UCODE_AMD_MAXSIZE (256 * 1024) 85 86 typedef struct ucode_file_amd { 87 ucode_header_amd_t uf_header; 88 uint8_t uf_data[896]; 89 uint8_t uf_resv[896]; 90 uint8_t uf_code_present; 91 uint8_t uf_code[191]; 92 uint8_t uf_encr[]; 93 } ucode_file_amd_t; 94 95 typedef struct ucode_eqtbl_amd { 96 uint32_t ue_inst_cpu; 97 uint32_t ue_fixed_mask; 98 uint32_t ue_fixed_comp; 99 uint16_t ue_equiv_cpu; 100 uint16_t ue_reserved; 101 } ucode_eqtbl_amd_t; 102 103 #define UCODE_AMD_EQUIVALENCE_TABLE_NAME "equivalence-table" 104 #define UCODE_MAX_NAME_LEN_AMD (sizeof (UCODE_AMD_EQUIVALENCE_TABLE_NAME)) 105 106 #ifdef __cplusplus 107 } 108 #endif 109 110 #endif /* _SYS_UCODE_AMD_H */ 111