Skip to content

Commit 6e613a2

Browse files
committed
CCB 2019-90-25: Merge #15, #17
Reviewed and approved at 2019-09-25 CCB
2 parents d0f1a39 + 30a96b0 commit 6e613a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+7926
-5023
lines changed

src/os/inc/osapi-os-core.h

Lines changed: 940 additions & 49 deletions
Large diffs are not rendered by default.

src/os/inc/osapi-os-filesys.h

Lines changed: 533 additions & 119 deletions
Large diffs are not rendered by default.

src/os/inc/osapi-os-loader.h

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,83 @@ typedef const struct
8585
typedef OS_module_prop_t OS_module_record_t;
8686
#endif
8787

88-
/*
89-
** Loader API
90-
*/
91-
int32 OS_ModuleTableInit ( void );
92-
88+
/*-------------------------------------------------------------------------------------*/
89+
/**
90+
* @brief Find the Address of a Symbol
91+
*
92+
* This calls to the OS dynamic symbol lookup implementation,
93+
* and/or checks a static symbol table for a matching symbol name.
94+
*
95+
* The static table is intended to support embedded targets that do
96+
* not have module loading capability or have it disabled.
97+
*
98+
* @param[out] symbol_address Set to the address of the symbol
99+
* @param[in] symbol_name Name of the symbol to look up
100+
*
101+
* @returns OS_SUCCESS on success, or appropriate error code
102+
* OS_ERROR if the symbol could not be found
103+
* OS_INVALID_POINTER if one of the pointers passed in are NULL
104+
*/
93105
int32 OS_SymbolLookup (cpuaddr *symbol_address, const char *symbol_name );
94106

107+
/*-------------------------------------------------------------------------------------*/
108+
/**
109+
* @brief Dumps the system symbol table to a file
110+
*
111+
* @param[in] filename File to write to
112+
* @param[in] size_limit Maximum number of bytes to write
113+
*
114+
* @returns OS_SUCCESS on success, or appropriate error code
115+
* OS_ERR_NOT_IMPLEMENTED if the system does not support this function
116+
* OS_ERROR if the symbol table could not be read or dumped
117+
* OS_INVALID_FILE if the file could not be opened or written
118+
*/
95119
int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit );
96120

121+
/*-------------------------------------------------------------------------------------*/
122+
/**
123+
* @brief Loads an object file
124+
*
125+
* Loads an object file into the running operating system
126+
*
127+
* @param[out] module_id OSAL ID corresponding to the loaded module
128+
* @param[in] module_name Name of module
129+
* @param[in] filename File containing the object code to load
130+
*
131+
* @returns OS_SUCCESS on success, or appropriate error code
132+
* OS_ERROR if the module cannot be loaded
133+
* OS_INVALID_POINTER if one of the parameters is NULL
134+
* OS_ERR_NO_FREE_IDS if the module table is full
135+
* OS_ERR_NAME_TAKEN if the name is in use
136+
*/
97137
int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename );
98138

139+
/*-------------------------------------------------------------------------------------*/
140+
/**
141+
* @brief Unloads the module file
142+
*
143+
* Unloads the module file from the running operating system
144+
*
145+
* @param[in] module_id OSAL ID of the previously the loaded module
146+
*
147+
* @returns OS_SUCCESS on success, or appropriate error code
148+
* OS_ERROR if the module is invalid or cannot be unloaded
149+
*/
99150
int32 OS_ModuleUnload ( uint32 module_id );
100151

152+
/*-------------------------------------------------------------------------------------*/
153+
/**
154+
* @brief Obtain information about a module
155+
*
156+
* Returns information about the loadable module
157+
*
158+
* @param[in] module_id OSAL ID of the previously the loaded module
159+
* @param[out] module_info Buffer to store module information
160+
*
161+
* @returns OS_SUCCESS on success, or appropriate error code
162+
* OS_ERR_INVALID_ID if the module id invalid
163+
* OS_INVALID_POINTER if the pointer to the ModuleInfo structure is invalid
164+
*/
101165
int32 OS_ModuleInfo ( uint32 module_id, OS_module_prop_t *module_info );
102166

103167

src/os/inc/osapi-os-net.h

Lines changed: 99 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,21 @@ typedef struct
107107
* --------------------------------------------------------------------------------------
108108
*/
109109

110+
/*-------------------------------------------------------------------------------------*/
110111
/**
111-
* Initialize a socket address structure to hold an address of the given family
112+
* @brief Initialize a socket address structure to hold an address of the given family
112113
*
113114
* The address is set to a suitable default value for the family.
114115
*
115-
* @param Addr The address buffer to initialize
116-
* @param Domain The address family
116+
* @param[out] Addr The address buffer to initialize
117+
* @param[in] Domain The address family
117118
* @returns OS_SUCCESS if successful
118119
*/
119120
int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain);
120121

122+
/*-------------------------------------------------------------------------------------*/
121123
/**
122-
* Get a string representation of a network host address
124+
* @brief Get a string representation of a network host address
123125
*
124126
* The specific format of the output string depends on the address family.
125127
*
@@ -129,15 +131,16 @@ int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain);
129131
*
130132
* @note For IPv4, this would typically be the dotted-decimal format (X.X.X.X).
131133
*
132-
* @param buffer Buffer to hold the output string
133-
* @param buflen Maximum length of the output string
134-
* @param Addr The network address buffer to convert
134+
* @param[out] buffer Buffer to hold the output string
135+
* @param[in] buflen Maximum length of the output string
136+
* @param[in] Addr The network address buffer to convert
135137
* @returns OS_SUCCESS if successful
136138
*/
137139
int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr);
138140

141+
/*-------------------------------------------------------------------------------------*/
139142
/**
140-
* Set a network host address from a string representation
143+
* @brief Set a network host address from a string representation
141144
*
142145
* The specific format of the output string depends on the address family.
143146
*
@@ -150,34 +153,36 @@ int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Ad
150153
* Since many embedded deployments do not have name services, this should
151154
* not be relied upon.
152155
*
153-
* @param Addr The address buffer to initialize
154-
* @param string The string to initialize the address from.
156+
* @param[out] Addr The address buffer to initialize
157+
* @param[in] string The string to initialize the address from.
155158
* @returns OS_SUCCESS if successful
156159
*/
157160
int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string);
158161

162+
/*-------------------------------------------------------------------------------------*/
159163
/**
160-
* Get the port number of a network address
164+
* @brief Get the port number of a network address
161165
*
162166
* For network prototcols that have the concept of a port number (such
163167
* as TCP/IP and UDP/IP) this function gets the port number from the
164168
* address structure.
165169
*
166-
* @param PortNum Buffer to store the port number
167-
* @param Addr The network address buffer
170+
* @param[out] PortNum Buffer to store the port number
171+
* @param[in] Addr The network address buffer
168172
* @returns OS_SUCCESS if successful
169173
*/
170174
int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr);
171175

176+
/*-------------------------------------------------------------------------------------*/
172177
/**
173-
* Get the port number of a network address
178+
* @brief Set the port number of a network address
174179
*
175180
* For network prototcols that have the concept of a port number (such
176-
* as TCP/IP and UDP/IP) this function gets the port number from the
181+
* as TCP/IP and UDP/IP) this function sets the port number from the
177182
* address structure.
178183
*
179-
* @param PortNum Buffer to store the port number
180-
* @param Addr The network address buffer
184+
* @param[in] PortNum The port number to set
185+
* @param[out] Addr The network address buffer
181186
* @returns OS_SUCCESS if successful
182187
*/
183188
int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum);
@@ -202,19 +207,21 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum);
202207
*/
203208

204209
/**
205-
* Opens a socket.
210+
* @brief Opens a socket.
206211
*
207212
* A new, unconnected and unbound socket is allocated of the given domain and type.
208213
*
209-
* @param sock_id Buffer to hold the OSAL ID
210-
* @param Domain The domain / address family of the socket (INET or INET6, etc)
211-
* @param Type The type of the socket (STREAM or DATAGRAM)
214+
* @param[out] sock_id Buffer to hold the OSAL ID
215+
* @param[in] Domain The domain / address family of the socket (INET or INET6, etc)
216+
* @param[in] Type The type of the socket (STREAM or DATAGRAM)
217+
*
212218
* @returns OS_SUCCESS if successful
213219
*/
214220
int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type);
215221

222+
/*-------------------------------------------------------------------------------------*/
216223
/**
217-
* Binds a socket to a given local address.
224+
* @brief Binds a socket to a given local address.
218225
*
219226
* The specified socket will be bound to the local address and port, if available.
220227
*
@@ -223,28 +230,30 @@ int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t T
223230
* If the socket is connection-oriented (stream), then this will also put the
224231
* socket into a listening state for incoming connections at the local address.
225232
*
226-
* @param sock_id The socket ID
227-
* @param Addr The local address to bind to
233+
* @param[in] sock_id The socket ID
234+
* @param[in] Addr The local address to bind to
228235
* @returns OS_SUCCESS if successful
229236
*/
230237
int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr);
231238

239+
/*-------------------------------------------------------------------------------------*/
232240
/**
233-
* Connects a socket to a given remote address.
241+
* @brief Connects a socket to a given remote address.
234242
*
235243
* The socket will be connected to the remote address and port, if available.
236244
* This only applies to stream-oriented sockets. Calling this on a datagram
237245
* socket will return an error (these sockets should use SendTo/RecvFrom).
238246
*
239-
* @param sock_id The socket ID
240-
* @param Addr The remote address to connect to
241-
* @param timeout The maximum amount of time to wait, or OS_PEND to wait forever
247+
* @param[in] sock_id The socket ID
248+
* @param[in] Addr The remote address to connect to
249+
* @param[in] timeout The maximum amount of time to wait, or OS_PEND to wait forever
242250
* @returns OS_SUCCESS if successful
243251
*/
244252
int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout);
245253

254+
/*-------------------------------------------------------------------------------------*/
246255
/**
247-
* Waits for and accept the next incoming connection on the given socket
256+
* @brief Waits for and accept the next incoming connection on the given socket
248257
*
249258
* This is used for sockets operating in a "server" role. The socket must be
250259
* a stream type (connection-oriented) and previously bound to a local address
@@ -254,85 +263,113 @@ int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout)
254263
* The new stream connection is then returned to the caller and the original
255264
* server socket ID can be reused for the next connection.
256265
*
257-
* @param sock_id The server socket ID, previously bound using OS_SocketBind()
258-
* @param connsock_id The connection socket, a new ID that can be read/written
259-
* @param Addr The remote address of the incoming connection
260-
* @param timeout The maximum amount of time to wait, or OS_PEND to wait forever
266+
* @param[in] sock_id The server socket ID, previously bound using OS_SocketBind()
267+
* @param[out] connsock_id The connection socket, a new ID that can be read/written
268+
* @param[in] Addr The remote address of the incoming connection
269+
* @param[in] timeout The maximum amount of time to wait, or OS_PEND to wait forever
270+
*
261271
* @returns OS_SUCCESS if successful
262272
*/
263273
int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout);
264274

275+
/*-------------------------------------------------------------------------------------*/
265276
/**
266-
* Reads data from a message-oriented (datagram) socket
277+
* @brief Reads data from a message-oriented (datagram) socket
267278
*
268279
* If a message is already available on the socket, this should immediately return
269280
* that data without blocking. Otherwise, it may block up to the given timeout.
270281
*
271-
* @param sock_id The socket ID, previously bound using OS_SocketBind()
272-
* @param buffer Pointer to message data receive buffer
273-
* @param buflen The maximum length of the message data to receive
274-
* @param RemoteAddr Buffer to store the remote network address (may be NULL)
275-
* @param timeout The maximum amount of time to wait, or OS_PEND to wait forever
276-
* @returns OS_SUCCESS if successful
282+
* @param[in] sock_id The socket ID, previously bound using OS_SocketBind()
283+
* @param[out] buffer Pointer to message data receive buffer
284+
* @param[in] buflen The maximum length of the message data to receive
285+
* @param[out] RemoteAddr Buffer to store the remote network address (may be NULL)
286+
* @param[in] timeout The maximum amount of time to wait, or OS_PEND to wait forever
287+
*
288+
* @returns non-negative count of actual bytes received if successful, or an appropriate error code
277289
*/
278290
int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout);
279291

292+
/*-------------------------------------------------------------------------------------*/
280293
/**
281-
* Sends data to a message-oriented (datagram) socket
294+
* @brief Sends data to a message-oriented (datagram) socket
282295
*
283296
* This sends data in a non-blocking mode. If the socket is not currently able to
284297
* queue the message, such as if its outbound buffer is full, then this returns
285298
* an error code.
286299
*
287-
* @param sock_id The socket ID, which must be of the datagram type
288-
* @param buffer Pointer to message data to send
289-
* @param buflen The length of the message data to send
290-
* @param RemoteAddr Buffer containing the remote network address to send to
291-
* @returns OS_SUCCESS if successful
300+
* @param[in] sock_id The socket ID, which must be of the datagram type
301+
* @param[in] buffer Pointer to message data to send
302+
* @param[in] buflen The length of the message data to send
303+
* @param[in] RemoteAddr Buffer containing the remote network address to send to
304+
*
305+
* @returns non-negative count of actual bytes sent if successful, or an appropriate error code
292306
*/
293307
int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr);
294308

309+
/*-------------------------------------------------------------------------------------*/
295310
/**
296-
* Gets an OSAL ID from a given name
311+
* @brief Gets an OSAL ID from a given name
297312
*
298-
* OSAL Sockets use generated names according to the address and type.
313+
* @note OSAL Sockets use generated names according to the address and type.
299314
*
300315
* @sa OS_SocketGetInfo()
301316
*
302-
* @param sock_id Buffer to hold result
303-
* @param sock_name Name of socket to find
304-
* @returns OS_SUCCESS if successful
317+
* @param[out] sock_id Buffer to hold result
318+
* @param[in] sock_name Name of socket to find
319+
*
320+
* @returns OS_SUCCESS if successful, or appropriate error code
321+
* OS_INVALID_POINTER is id or name are NULL pointers
322+
* OS_ERR_NAME_TOO_LONG if the name given is to long to have been stored
323+
* OS_ERR_NAME_NOT_FOUND if the name was not found in the table
305324
*/
306325
int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name);
307326

327+
/*-------------------------------------------------------------------------------------*/
308328
/**
309-
* Gets information about an OSAL Socket ID
329+
* @brief Gets information about an OSAL Socket ID
310330
*
311331
* OSAL Sockets use generated names according to the address and type.
312332
* This allows applications to find the name of a given socket.
313333
*
314-
* @param sock_id The socket ID
315-
* @param sock_prop Buffer to hold socket information
316-
* @returns OS_SUCCESS if successful
334+
* @param[in] sock_id The socket ID
335+
* @param[out] sock_prop Buffer to hold socket information
336+
*
337+
* @returns OS_SUCCESS if successful, or appropriate error code
338+
* OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
339+
* OS_INVALID_POINTER if the count_prop pointer is null
317340
*/
318341
int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop);
319342

320343

321-
/*
322-
** OS_NetworkGetID is currently [[deprecated]] as its behavior is
323-
** unknown and not consistent across operating systems.
324-
*/
344+
/*-------------------------------------------------------------------------------------*/
345+
/**
346+
* @brief Gets the network ID of the local machine
347+
*
348+
* The ID is an implementation-defined value and may not be consistent
349+
* in meaning across different platform types.
350+
*
351+
* @note this API may be removed in a future version of OSAL due to
352+
* inconsistencies between platforms.
353+
*
354+
* @returns The ID or fixed value of -1 if the host id could not be found
355+
*
356+
* Note it is not possible to differentiate between error codes and valid
357+
* network IDs here. It is assumed, however, that -1 is never a valid ID.
358+
*
359+
*/
325360
int32 OS_NetworkGetID (void);
326361

327362

363+
/*-------------------------------------------------------------------------------------*/
328364
/**
329-
* Gets the local machine network host name
365+
* @brief Gets the local machine network host name
330366
*
331367
* If configured in the underlying network stack,
332368
* this function retrieves the local hostname of the system.
333369
*
334-
* @param host_name Buffer to hold name information
335-
* @param name_len Maximum length of host name buffer
370+
* @param[out] host_name Buffer to hold name information
371+
* @param[in] name_len Maximum length of host name buffer
372+
*
336373
* @returns OS_SUCCESS if successful
337374
*/
338375
int32 OS_NetworkGetHostName (char *host_name, uint32 name_len);

0 commit comments

Comments
 (0)