1 /* 2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef MM_COMMUNICATE_SERIALIZER_H 8 #define MM_COMMUNICATE_SERIALIZER_H 9 10 #include <stddef.h> 11 #include <stdint.h> 12 #include <protocols/common/efi/efi_status.h> 13 #include "protocols/common/efi/efi_types.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /** 20 * Provides an interface for encoding/decoding the MM Communicate and 21 * MM service specific headers. Based on the TS view of an RPC layer 22 * RPC related parameters are distributed between the generic 23 * MM Communicate header and the SMM service specific header. 24 * Concrete functions are determined by the requests SMM service GUID. 25 */ 26 struct mm_communicate_serializer; 27 28 /** 29 * \brief Find a MM Communicate serializer 30 * 31 * Find a serializer for the specified service GUID. 32 * 33 * \param[in] svc_guid The SMM service GUID 34 * 35 * \return Pointer to serializer or NULL if not found 36 */ 37 const struct mm_communicate_serializer *mm_communicate_serializer_find( 38 const EFI_GUID *svc_guid); 39 40 /** 41 * \brief Return the header size for the specified serializer 42 * 43 * \param[in] serializer The concrete serializer 44 * 45 * \return Header size comprising MM Communicate header + SMM service header 46 */ 47 size_t mm_communicate_serializer_header_size( 48 const struct mm_communicate_serializer *serializer); 49 50 /** 51 * \brief Encode the MM Communicate + SMM service header 52 * 53 * \param[in] serializer Concrete serializer 54 * \param[in] buf Encode to this buffer 55 * \param[in] opcode Service opcode 56 * \param[in] req_len Length of the request 57 */ 58 void mm_communicate_serializer_header_encode( 59 const struct mm_communicate_serializer *serializer, 60 uint8_t *buf, 61 uint32_t opcode, 62 size_t req_len); 63 64 /** 65 * \brief Header decode function 66 * 67 * \param[in] serializer Concrete serializer 68 * \param[in] buf Encode to this buffer 69 * \param[out] efi_status EFI status code 70 * \param[out] resp_buf Response buffer 71 * \param[out] resp_len Length of the response 72 */ 73 void mm_communicate_serializer_header_decode( 74 const struct mm_communicate_serializer *serializer, 75 uint8_t *buf, 76 efi_status_t *efi_status, 77 uint8_t **resp_buf, 78 size_t *resp_len); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 84 #endif /* MM_COMMUNICATE_SERIALIZER_H */ 85