Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers configuration_store_stub.c Source File

configuration_store_stub.c

00001 /*
00002  * Copyright (c) 2016 ARM Limited. All rights reserved.
00003  */
00004 
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 #include <string.h>
00008 #include <inttypes.h>
00009 #include <configuration-store/configuration_store.h>
00010 #include "configuration_store_stub.h"
00011 
00012 configuration_store_stub_data_t cfstore_stub = {ARM_DRIVER_OK, ARM_DRIVER_OK, ARM_DRIVER_OK, ARM_DRIVER_OK, ARM_DRIVER_OK, 0, NULL, NULL, NULL};
00013 
00014 static int32_t test_cfstore_close(ARM_CFSTORE_HANDLE  hkey)
00015 {
00016     return cfstore_stub.close_ret_val;
00017 }
00018 
00019 static int32_t test_cfstore_create(const char* key_name, ARM_CFSTORE_SIZE value_len, const ARM_CFSTORE_KEYDESC* kdesc, ARM_CFSTORE_HANDLE  hkey)
00020 {
00021     return cfstore_stub.ret_val;
00022 }
00023 
00024 static int32_t test_cfstore_delete(ARM_CFSTORE_HANDLE  hkey)
00025 {
00026     return cfstore_stub.delete_ret_val;
00027 }
00028 
00029 static int32_t test_cfstore_find(const char* key_name_query, const ARM_CFSTORE_HANDLE  previous, ARM_CFSTORE_HANDLE  next)
00030 {
00031     return ARM_DRIVER_OK;
00032 }
00033 
00034 static int32_t test_cfstore_flush(void)
00035 {
00036     return cfstore_stub.ret_val;
00037 }
00038 
00039 ARM_CFSTORE_CAPABILITIES test_cfstore_get_capabilities(void)
00040 {
00041     static ARM_CFSTORE_CAPABILITIES cfstore_caps_g = { .asynchronous_ops = 1, .uvisor_support_enabled = 0 };
00042     return cfstore_caps_g;
00043 }
00044 
00045 static int32_t test_cfstore_get_key_name(ARM_CFSTORE_HANDLE  hkey, char* key_name, uint8_t *key_name_len)
00046 {
00047     return ARM_DRIVER_OK;
00048 }
00049 
00050 static ARM_CFSTORE_STATUS test_cfstore_get_status(void)
00051 {
00052     ARM_CFSTORE_STATUS status;
00053     return status;
00054 }
00055 
00056 static int32_t test_cfstore_get_value_len(ARM_CFSTORE_HANDLE  hkey, ARM_CFSTORE_SIZE *value_len)
00057 {
00058     return ARM_DRIVER_OK;
00059 }
00060 
00061 ARM_DRIVER_VERSION test_cfstore_get_version(void)
00062 {
00063     static const ARM_DRIVER_VERSION cfstore_driver_version_g = { .api = ARM_CFSTORE_API_VERSION, .drv = ARM_CFSTORE_DRV_VERSION };
00064     return cfstore_driver_version_g;
00065 }
00066 
00067 static int32_t test_cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void* client_context)
00068 {
00069     cfstore_stub.callback = callback;
00070     cfstore_stub.client_context = client_context;
00071     return cfstore_stub.ret_val;
00072 }
00073 
00074 static int32_t test_cfstore_open(const char* key_name, ARM_CFSTORE_FMODE flags, ARM_CFSTORE_HANDLE  hkey)
00075 {
00076     return cfstore_stub.ret_val;
00077 }
00078 
00079 static int32_t test_cfstore_power_control(ARM_POWER_STATE state)
00080 {
00081     return ARM_DRIVER_OK;
00082 }
00083 
00084 static int32_t test_cfstore_read(ARM_CFSTORE_HANDLE  hkey, void* data, ARM_CFSTORE_SIZE* len)
00085 {
00086     return cfstore_stub.read_ret_val;
00087 }
00088 
00089 static int32_t test_cfstore_rseek(ARM_CFSTORE_HANDLE  hkey, ARM_CFSTORE_OFFSET offset)
00090 {
00091     return ARM_DRIVER_OK;
00092 }
00093 
00094 static int32_t test_cfstore_uninitialise(void)
00095 {
00096     return cfstore_stub.ret_val;
00097 }
00098 
00099 static int32_t test_cfstore_write(ARM_CFSTORE_HANDLE  hkey, const char* data, ARM_CFSTORE_SIZE* len)
00100 {
00101     return cfstore_stub.write_ret_val;
00102 }
00103 
00104 ARM_CFSTORE_DRIVER cfstore_driver =
00105 {
00106         .Close = test_cfstore_close,
00107         .Create = test_cfstore_create,
00108         .Delete= test_cfstore_delete,
00109         .Find = test_cfstore_find,
00110         .Flush = test_cfstore_flush,
00111         .GetCapabilities = test_cfstore_get_capabilities,
00112         .GetKeyName = test_cfstore_get_key_name,
00113         .GetStatus = test_cfstore_get_status,
00114         .GetValueLen = test_cfstore_get_value_len,
00115         .GetVersion = test_cfstore_get_version,
00116         .Initialize = test_cfstore_initialise,
00117         .Open = test_cfstore_open,
00118         .PowerControl = test_cfstore_power_control,
00119         .Read = test_cfstore_read,
00120         .Rseek = test_cfstore_rseek,
00121         .Uninitialize = test_cfstore_uninitialise,
00122         .Write = test_cfstore_write,
00123 };
00124 
00125 
00126 void test_cfstore_callback_trigger()
00127 {
00128     cfstore_stub.callback(cfstore_stub.ret_val, cfstore_stub.cmd_code, cfstore_stub.client_context, cfstore_stub.handle);
00129 }
00130