1 /*
2 * Copyright 2017, NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #include <assert.h>
10
11 #include "srtm_service.h"
12 #include "srtm_service_struct.h"
13 #include "srtm_message.h"
14
15 /*******************************************************************************
16 * Definitions
17 ******************************************************************************/
18
19 /*******************************************************************************
20 * Prototypes
21 ******************************************************************************/
22
23 /*******************************************************************************
24 * Variables
25 ******************************************************************************/
26
27 /*******************************************************************************
28 * Code
29 ******************************************************************************/
SRTM_Service_Destroy(srtm_service_t service)30 void SRTM_Service_Destroy(srtm_service_t service)
31 {
32 assert(service);
33 assert(service->destroy);
34 service->destroy(service);
35 }
36
SRTM_Service_Request(srtm_service_t service,srtm_request_t request)37 srtm_status_t SRTM_Service_Request(srtm_service_t service, srtm_request_t request)
38 {
39 assert(service);
40 assert(service->request);
41
42 return service->request(service, request);
43 }
44
SRTM_Service_Notify(srtm_service_t service,srtm_notification_t notification)45 srtm_status_t SRTM_Service_Notify(srtm_service_t service, srtm_notification_t notification)
46 {
47 assert(service);
48 assert(service->notify);
49
50 return service->notify(service, notification);
51 }
52
SRTM_Service_CheckVersion(srtm_service_t service,srtm_message_t msg,uint16_t svcVer)53 srtm_status_t SRTM_Service_CheckVersion(srtm_service_t service, srtm_message_t msg, uint16_t svcVer)
54 {
55 uint16_t msgVer = SRTM_CommMessage_GetVersion(msg);
56
57 if (SRTM_MESSAGE_MAJOR_VERSION(msgVer) != SRTM_MESSAGE_MAJOR_VERSION(svcVer))
58 {
59 SRTM_DEBUG_MESSAGE(SRTM_DEBUG_VERBOSE_WARN,
60 "SRTM_WARN: SRTM_Service_CheckVersion mismatch req %d, service %d!\r\n", msgVer, svcVer);
61 return SRTM_Status_ServiceVerMismatch;
62 }
63
64 return SRTM_Status_Success;
65 }
66