Tizen RT Libs&Environment  v1.1 D4
configdata.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
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,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * apps/include/platform/configdata.h
20  *
21  * Copyright (C) 2013 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
52 
53 #ifndef __APPS_INCLUDE_PLATFORM_CONFIGDATA_H
54 #define __APPS_INCLUDE_PLATFORM_CONFIGDATA_H
55 
56 /****************************************************************************
57  * Included Files
58  ****************************************************************************/
59 
60 #include <tinyara/config.h>
61 
62 #include <sys/types.h>
63 
64 #ifdef CONFIG_PLATFORM_CONFIGDATA
65 
66 /****************************************************************************
67  * Pre-processor Definitions
68  ****************************************************************************/
69 
70 /****************************************************************************
71  * Public Types
72  ****************************************************************************/
73 /* This enumeration identifies classes of configuration data */
74 
75 enum config_data_e {
76  /* Product identification */
77 
78  CONFIGDATA_SERIALNUMBER = 0, /* Product serial number */
79 
80  /* Prduct networking configuration */
81 
82  CONFIGDATA_MACADDRESS, /* Assigned MAC address */
83  CONFIGDATA_IPADDRESS, /* Configured IP address */
84  CONFIGDATA_NETMASK, /* Configured network mask */
85  CONFIGDATA_DIPADDR, /* Configured default router address */
86 
87  /* GUI configuration */
88 
89  CONFIGDATA_TSCALIBRATION, /* Measured touchscreen calibration data */
90  CONFIGDATA_OTHER /* Other configuration data */
91 };
92 
93 /****************************************************************************
94  * Public Data
95  ****************************************************************************/
96 
97 #undef EXTERN
98 #if defined(__cplusplus)
99 #define EXTERN extern "C"
100 extern "C" {
101 #else
102 
103 #define EXTERN extern
104 #endif
105 
106 /****************************************************************************
107  * Public Functions
108  ****************************************************************************/
109 
110 /****************************************************************************
111  * Name: platform_setconfig
112  *
113  * Description:
114  * Save platform-specific configuration data
115  *
116  * Input Parameter:
117  * id - Defines the class of configuration data
118  * instance - Defines which instance of configuration data. For example,
119  * if a board has two networks, then there would be two MAC
120  * addresses: instance 0 and instance 1
121  * configdata - The new configuration data to be saved
122  * datalen - The size of the configuration data in bytes.
123  *
124  * Returned Value:
125  * This is an end-user function, so it follows the normal convention:
126  * Returns the OK (zero) on success. On failure, it.returns -1 (ERROR) and
127  * sets errno appropriately.
128  *
129  * Values for the errno would include:
130  *
131  * EINVAL - The configdata point is invalid
132  * ENOSYS - The request ID/instance is not supported on this platform
133  *
134  * Other errors may be returned from lower level drivers on failure to
135  * write to the underlying media (if applicable)
136  *
137  ****************************************************************************/
138 
139 int platform_setconfig(enum config_data_e id, int instance, FAR const uint8_t *configdata, size_t datalen);
140 
141 /****************************************************************************
142  * Name: platform_getconfig
143  *
144  * Description:
145  * Get platform-specific configuration data
146  *
147  * Input Parameter:
148  * id - Defines the class of configuration data
149  * instance - Defines which instance of configuration data. For example,
150  * if a board has two networks, then there would be two MAC
151  * addresses: instance 0 and instance 1
152  * configdata - The user provided location to return the configuration data
153  * datalen - The expected size of the configuration data to be returned.
154  *
155  * Returned Value:
156  * This is an end-user function, so it follows the normal convention:
157  * Returns the OK (zero) on success. On failure, it.returns -1 (ERROR) and
158  * sets errno appropriately.
159  *
160  * Values for the errno would include:
161  *
162  * EINVAL - The configdata point is invalid
163  * ENOSYS - The request ID/instance is not supported on this platform
164  *
165  * Other errors may be returned from lower level drivers on failure to
166  * read from the underlying media (if applicable)
167  *
168  ****************************************************************************/
169 
170 int platform_getconfig(enum config_data_e id, int instance, FAR uint8_t *configdata, size_t datalen);
171 
172 #undef EXTERN
173 #if defined(__cplusplus)
174 }
175 #endif
176 
177 #endif /* CONFIG_PLATFORM_CONFIGDATA */
178 #endif /* __APPS_INCLUDE_PLATFORM_CONFIGDATA_H */