1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #pragma once 25 26 #ifndef GSP_FW_WPR_META_H_ 27 #define GSP_FW_WPR_META_H_ 28 29 /*! 30 * GSP firmware WPR metadata 31 * 32 * Initialized by CPU-RM and DMA'd to FB, at the end of what will be WPR2. 33 * Verified, and locked in WPR2 by Booter. 34 * 35 * Firmware scrubs the last 256mb of FB, no memory outside of this region 36 * may be used until the FW RM has scrubbed the remainder of memory. 37 * 38 * ---------------------------- <- fbSize (end of FB, 1M aligned) 39 * | VGA WORKSPACE | 40 * ---------------------------- <- vbiosReservedOffset (64K? aligned) 41 * | (potential align. gap) | 42 * ---------------------------- <- gspFwWprEnd (128K aligned) 43 * | FRTS data | (frtsSize is 0 on GA100) 44 * | ------------------------ | <- frtsOffset 45 * | BOOT BIN (e.g. SK + BL) | 46 * ---------------------------- <- bootBinOffset 47 * | GSP FW ELF | 48 * ---------------------------- <- gspFwOffset 49 * | GSP FW (WPR) HEAP | 50 * ---------------------------- <- gspFwHeapOffset 51 * | Booter-placed metadata | 52 * | (struct GspFwWprMeta) | 53 * ---------------------------- <- gspFwWprStart (128K aligned) 54 * | GSP FW (non-WPR) HEAP | 55 * ---------------------------- <- nonWprHeapOffset, gspFwRsvdStart 56 * (GSP_CARVEOUT_SIZE bytes from end of FB) 57 */ 58 typedef struct 59 { 60 // Magic 61 // BL to use for verification (i.e. Booter locked it in WPR2) 62 NvU64 magic; // = 0xdc3aae21371a60b3; 63 64 // Revision number of Booter-BL-Sequencer handoff interface 65 // Bumped up when we change this interface so it is not backward compatible. 66 // Bumped up when we revoke GSP-RM ucode 67 NvU64 revision; // = 1; 68 69 // ---- Members regarding data in SYSMEM ---------------------------- 70 // Consumed by Booter for DMA 71 72 NvU64 sysmemAddrOfRadix3Elf; 73 NvU64 sizeOfRadix3Elf; 74 75 NvU64 sysmemAddrOfBootloader; 76 NvU64 sizeOfBootloader; 77 78 // Offsets inside bootloader image needed by Booter 79 NvU64 bootloaderCodeOffset; 80 NvU64 bootloaderDataOffset; 81 NvU64 bootloaderManifestOffset; 82 83 union 84 { 85 // Used only at initial boot 86 struct 87 { 88 NvU64 sysmemAddrOfSignature; 89 NvU64 sizeOfSignature; 90 }; 91 92 // 93 // Used at suspend/resume to read GspFwHeapFreeList 94 // Offset relative to GspFwWprMeta FBMEM PA (gspFwWprStart) 95 // 96 struct 97 { 98 NvU32 gspFwHeapFreeListWprOffset; 99 NvU32 unused0; 100 NvU64 unused1; 101 }; 102 }; 103 104 // ---- Members describing FB layout -------------------------------- 105 NvU64 gspFwRsvdStart; 106 107 NvU64 nonWprHeapOffset; 108 NvU64 nonWprHeapSize; 109 110 NvU64 gspFwWprStart; 111 112 // GSP-RM to use to setup heap. 113 NvU64 gspFwHeapOffset; 114 NvU64 gspFwHeapSize; 115 116 // BL to use to find ELF for jump 117 NvU64 gspFwOffset; 118 // Size is sizeOfRadix3Elf above. 119 120 NvU64 bootBinOffset; 121 // Size is sizeOfBootloader above. 122 123 NvU64 frtsOffset; 124 NvU64 frtsSize; 125 126 NvU64 gspFwWprEnd; 127 128 // GSP-RM to use for fbRegionInfo? 129 NvU64 fbSize; 130 131 // ---- Other members ----------------------------------------------- 132 133 // GSP-RM to use for fbRegionInfo? 134 NvU64 vgaWorkspaceOffset; 135 NvU64 vgaWorkspaceSize; 136 137 // Boot count. Used to determine whether to load the firmware image. 138 NvU64 bootCount; 139 140 // This union is organized the way it is to start at an 8-byte boundary and achieve natural 141 // packing of the internal struct fields. 142 union 143 { 144 struct 145 { 146 // TODO: the partitionRpc* fields below do not really belong in this 147 // structure. The values are patched in by the partition bootstrapper 148 // when GSP-RM is booted in a partition, and this structure was a 149 // convenient place for the bootstrapper to access them. These should 150 // be moved to a different comm. mechanism between the bootstrapper 151 // and the GSP-RM tasks. 152 153 // Shared partition RPC memory (physical address) 154 NvU64 partitionRpcAddr; 155 156 // Offsets relative to partitionRpcAddr 157 NvU16 partitionRpcRequestOffset; 158 NvU16 partitionRpcReplyOffset; 159 160 // Code section and dataSection offset and size. 161 NvU32 elfCodeOffset; 162 NvU32 elfDataOffset; 163 NvU32 elfCodeSize; 164 NvU32 elfDataSize; 165 166 // Used during GSP-RM resume to check for revocation 167 NvU32 lsUcodeVersion; 168 }; 169 170 struct 171 { 172 // Pad for the partitionRpc* fields, plus 4 bytes 173 NvU32 partitionRpcPadding[4]; 174 175 // CrashCat (contiguous) buffer size/location - occupies same bytes as the 176 // elf(Code|Data)(Offset|Size) fields above. 177 // TODO: move to GSP_FMC_INIT_PARAMS 178 NvU64 sysmemAddrOfCrashReportQueue; 179 NvU32 sizeOfCrashReportQueue; 180 181 // Pad for the lsUcodeVersion field 182 NvU32 lsUcodeVersionPadding[1]; 183 }; 184 }; 185 186 // Number of VF partitions allocating sub-heaps from the WPR heap 187 // Used during boot to ensure the heap is adequately sized 188 NvU8 gspFwHeapVfPartitionCount; 189 190 // Flags to help decide GSP-FW flow. 191 NvU8 flags; 192 193 // Pad structure to exactly 256 bytes. Can replace padding with additional 194 // fields without incrementing revision. Padding initialized to 0. 195 NvU8 padding[6]; 196 197 // BL to use for verification (i.e. Booter says OK to boot) 198 NvU64 verified; // 0x0 -> unverified, 0xa0a0a0a0a0a0a0a0 -> verified 199 } GspFwWprMeta; 200 201 #define GSP_FW_WPR_META_VERIFIED 0xa0a0a0a0a0a0a0a0ULL 202 #define GSP_FW_WPR_META_REVISION 1 203 #define GSP_FW_WPR_META_MAGIC 0xdc3aae21371a60b3ULL 204 205 #define GSP_FW_WPR_HEAP_FREE_REGION_COUNT 128 206 207 typedef struct 208 { 209 // 210 // offset relative to GspFwWprMeta FBMEM PA 211 // describes a region at [offs, offs + length) 212 // 213 NvU32 offs; // start, inclusive 214 NvU32 length; 215 } GspFwHeapFreeRegion; 216 217 typedef struct 218 { 219 NvU64 magic; 220 NvU32 nregions; 221 GspFwHeapFreeRegion regions[GSP_FW_WPR_HEAP_FREE_REGION_COUNT]; 222 } GspFwHeapFreeList; 223 224 #define GSP_FW_HEAP_FREE_LIST_MAGIC 0x4845415046524545ULL 225 226 #define GSP_FW_FLAGS 8:0 227 #define GSP_FW_FLAGS_CLOCK_BOOST NVBIT(0) 228 #define GSP_FW_FLAGS_RECOVERY_MARGIN_PRESENT NVBIT(1) 229 230 #endif // GSP_FW_WPR_META_H_ 231