1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2023 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 #ifndef _FSPRPC_NVSWITCH_H_ 25 #define _FSPRPC_NVSWITCH_H_ 26 27 #define FSP_OK (0x00U) 28 #define FSP_ERR_IFS_ERR_INVALID_STATE (0x9EU) 29 #define FSP_ERR_IFR_FILE_NOT_FOUND (0x9FU) 30 #define FSP_ERR_IFS_ERR_NOT_SUPPORTED (0xA0U) 31 #define FSP_ERR_IFS_ERR_INVALID_DATA (0xA1U) 32 33 #pragma pack(1) 34 typedef struct mctp_header 35 { 36 NvU32 constBlob; 37 NvU8 msgType; 38 NvU16 vendorId; 39 } MCTP_HEADER; 40 41 // Needed to remove unnecessary padding 42 #pragma pack(1) 43 typedef struct nvdm_payload_cot 44 { 45 NvU16 version; 46 NvU16 size; 47 NvU64 gspFmcSysmemOffset; 48 NvU64 frtsSysmemOffset; 49 NvU32 frtsSysmemSize; 50 51 // Note this is an offset from the end of FB 52 NvU64 frtsVidmemOffset; 53 NvU32 frtsVidmemSize; 54 55 // Authentication related fields 56 NvU32 hash384[12]; 57 NvU32 publicKey[96]; 58 NvU32 signature[96]; 59 60 NvU64 gspBootArgsSysmemOffset; 61 } NVDM_PAYLOAD_COT; 62 #pragma pack() 63 64 typedef struct nvdm_packet 65 { 66 NvU8 nvdmType; 67 68 // We can make this a union when adding more NVDM payloads 69 NVDM_PAYLOAD_COT cotPayload; 70 } NVDM_PACKET; 71 72 // The structure cannot have embedded pointers to send as byte stream 73 typedef struct mctp_packet 74 { 75 MCTP_HEADER header; 76 NVDM_PACKET nvdmPacket; 77 } MCTP_PACKET, *PMCTP_PACKET; 78 79 // Type of packet, can either be SOM, EOM, neither, or both (1-packet messages) 80 typedef enum mctp_packet_state 81 { 82 MCTP_PACKET_STATE_START, 83 MCTP_PACKET_STATE_INTERMEDIATE, 84 MCTP_PACKET_STATE_END, 85 MCTP_PACKET_STATE_SINGLE_PACKET 86 } MCTP_PACKET_STATE, *PMCTP_PACKET_STATE; 87 88 NvlStatus nvswitch_fsp_read_message(nvswitch_device *device, NvU8 *pPayloadBuffer, NvU32 payloadBufferSize); 89 NvlStatus nvswitch_fsp_send_packet(nvswitch_device *device, NvU8 *pPacket, NvU32 packetSize); 90 NvlStatus nvswitch_fsp_send_and_read_message(nvswitch_device *device, NvU8 *pPayload, NvU32 size, NvU32 nvdmType, NvU8 *pResponsePayload, NvU32 responseBufferSize); 91 92 #endif //_FSPRPC_NVSWITCH_H_ 93