1 /** @file
2  * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved.
3  * SPDX-License-Identifier : Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16 **/
17 
18 #include "val_target.h"
19 #include "pal_interfaces_ns.h"
20 #include "val_framework.h"
21 #include "val_client_defs.h"
22 #include "val_peripherals.h"
23 #include "val_storage.h"
24 
25 /**
26     @brief    - This API will call the requested internal trusted storage function
27     @param    - type : function code
28                 ...  : variable number of arguments
29     @return   - Error status
30 **/
val_storage_function(int type,...)31 int32_t val_storage_function(int type, ...)
32 {
33 #if defined(STORAGE) || defined(INTERNAL_TRUSTED_STORAGE) || defined(PROTECTED_STORAGE)
34     va_list valist;
35     int32_t status;
36 
37     va_start(valist, type);
38     switch (type)
39     {
40 #if defined(STORAGE) || defined(INTERNAL_TRUSTED_STORAGE)
41         case VAL_ITS_SET:
42         case VAL_ITS_GET:
43         case VAL_ITS_GET_INFO:
44         case VAL_ITS_REMOVE:
45             status = pal_its_function(type, valist);
46             break;
47 #endif
48 #if defined(STORAGE) || defined(PROTECTED_STORAGE)
49         case VAL_PS_SET:
50         case VAL_PS_GET:
51         case VAL_PS_GET_INFO:
52         case VAL_PS_REMOVE:
53         case VAL_PS_CREATE:
54         case VAL_PS_SET_EXTENDED:
55         case VAL_PS_GET_SUPPORT:
56             status = pal_ps_function(type, valist);
57             break;
58 #endif
59         default:
60             val_print(PRINT_ERROR, "\n\nError: Not a valid ITS or PS function code!", 0);
61             return VAL_STATUS_ERROR;
62     }
63     va_end(valist);
64     return status;
65 #else
66     (void)type;
67     return VAL_STATUS_ERROR;
68 #endif
69 }
70