xref: /optee_os/ta/pkcs11/src/serializer.h (revision ee49d9f298c5bb8b5149a990d921b36656d9b469)
14f8a354fSEtienne Carriere /* SPDX-License-Identifier: BSD-2-Clause */
24f8a354fSEtienne Carriere /*
34f8a354fSEtienne Carriere  * Copyright (c) 2017-2020, Linaro Limited
44f8a354fSEtienne Carriere  */
54f8a354fSEtienne Carriere 
64f8a354fSEtienne Carriere #ifndef PKCS11_TA_SERIALIZER_H
74f8a354fSEtienne Carriere #define PKCS11_TA_SERIALIZER_H
84f8a354fSEtienne Carriere 
94f8a354fSEtienne Carriere #include <stdbool.h>
10*ee49d9f2SEtienne Carriere #include <stdint.h>
114f8a354fSEtienne Carriere 
124f8a354fSEtienne Carriere /*
134f8a354fSEtienne Carriere  * Util routines for serializes unformated arguments in a client memref
144f8a354fSEtienne Carriere  */
154f8a354fSEtienne Carriere struct serialargs {
164f8a354fSEtienne Carriere 	char *start;
174f8a354fSEtienne Carriere 	char *next;
184f8a354fSEtienne Carriere 	size_t size;
194f8a354fSEtienne Carriere };
204f8a354fSEtienne Carriere 
214f8a354fSEtienne Carriere void serialargs_init(struct serialargs *args, void *in, size_t size);
224f8a354fSEtienne Carriere 
234f8a354fSEtienne Carriere uint32_t serialargs_get(struct serialargs *args, void *out, size_t sz);
244f8a354fSEtienne Carriere 
254f8a354fSEtienne Carriere uint32_t serialargs_get_ptr(struct serialargs *args, void **out, size_t size);
264f8a354fSEtienne Carriere 
274f8a354fSEtienne Carriere uint32_t serialargs_alloc_and_get(struct serialargs *args,
284f8a354fSEtienne Carriere 				  void **out, size_t size);
294f8a354fSEtienne Carriere 
304f8a354fSEtienne Carriere bool serialargs_remaining_bytes(struct serialargs *args);
314f8a354fSEtienne Carriere 
324f8a354fSEtienne Carriere #endif /*PKCS11_TA_SERIALIZER_H*/
33