Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #555, provide typedef for OSAL ID #568

Merged
merged 3 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/os/inc/common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
typedef size_t cpusize;
typedef ptrdiff_t cpudiff;

/**
* A type to be used for OSAL resource identifiers.
*/
typedef uint32_t osal_id_t;



#ifndef NULL /* pointer to nothing */
Expand Down
183 changes: 132 additions & 51 deletions src/os/inc/osapi-os-core.h

Large diffs are not rendered by default.

53 changes: 38 additions & 15 deletions src/os/inc/osapi-os-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typedef struct
typedef struct
{
char Path[OS_MAX_PATH_LEN];
uint32 User;
osal_id_t User;
uint8 IsValid; /* For backward compatibility -- always true if OS_FDGetInfo returned true */
}OS_file_prop_t;

Expand Down Expand Up @@ -215,7 +215,26 @@ int32 OS_creat (const char *path, int32 access);
*/
int32 OS_open (const char *path, int32 access, uint32 mode);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Open or create a file
*
* Implements the same as OS_open/OS_creat but follows the OSAL paradigm
* of outputting the ID/descriptor separately from the return value, rather
* than relying on the user to convert it back.
*
* @param[out] filedes The handle ID
* @param[in] path File name to create or open
* @param[in] flags The file permissions - see @ref OS_file_flag_t
* @param[in] access Intended access mode - see @ref OSFileAccess
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERROR if the command was not executed properly
*/
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access);

/**@}*/
/*-------------------------------------------------------------------------------------*/
/**
* @brief Closes an open file handle
Expand All @@ -230,7 +249,7 @@ int32 OS_open (const char *path, int32 access, uint32 mode);
* @retval #OS_ERROR if file descriptor could not be closed
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_close (uint32 filedes);
int32 OS_close (osal_id_t filedes);


/*-------------------------------------------------------------------------------------*/
Expand All @@ -251,7 +270,7 @@ int32 OS_close (uint32 filedes);
* @retval #OS_ERROR if OS call failed
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_read (uint32 filedes, void *buffer, uint32 nbytes);
int32 OS_read (osal_id_t filedes, void *buffer, uint32 nbytes);


/*-------------------------------------------------------------------------------------*/
Expand All @@ -273,7 +292,7 @@ int32 OS_read (uint32 filedes, void *buffer, uint32 nbytes);
* @retval #OS_ERROR if OS call failed
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_write (uint32 filedes, const void *buffer, uint32 nbytes);
int32 OS_write (osal_id_t filedes, const void *buffer, uint32 nbytes);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -304,7 +323,7 @@ int32 OS_write (uint32 filedes, const void *buffer, uint32 nbytes);
* @return Byte count on success, zero for timeout, or appropriate error code,
* see @ref OSReturnCodes
*/
int32 OS_TimedRead(uint32 filedes, void *buffer, uint32 nbytes, int32 timeout);
int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout);


/*-------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -336,7 +355,7 @@ int32 OS_TimedRead(uint32 filedes, void *buffer, uint32 nbytes, int32
* @return Byte count on success, zero for timeout, or appropriate error code,
* see @ref OSReturnCodes
*/
int32 OS_TimedWrite(uint32 filedes, const void *buffer, uint32 nbytes, int32 timeout);
int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout);


/*-------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -388,7 +407,7 @@ int32 OS_stat (const char *path, os_fstat_t *filestats);
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
* @retval #OS_ERROR if OS call failed
*/
int32 OS_lseek (uint32 filedes, int32 offset, uint32 whence);
int32 OS_lseek (osal_id_t filedes, int32 offset, uint32 whence);


/*-------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -506,7 +525,7 @@ int32 OS_mv (const char *src, const char *dest);
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_FDGetInfo (uint32 filedes, OS_file_prop_t *fd_prop);
int32 OS_FDGetInfo (osal_id_t filedes, OS_file_prop_t *fd_prop);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -569,7 +588,7 @@ int32 OS_CloseFileByName(const char *Filename);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_DirectoryOpen(uint32 *dir_id, const char *path);
int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path);


/*-------------------------------------------------------------------------------------*/
Expand All @@ -582,7 +601,7 @@ int32 OS_DirectoryOpen(uint32 *dir_id, const char *path);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_DirectoryClose(uint32 dir_id);
int32 OS_DirectoryClose(osal_id_t dir_id);


/*-------------------------------------------------------------------------------------*/
Expand All @@ -595,7 +614,7 @@ int32 OS_DirectoryClose(uint32 dir_id);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_DirectoryRewind(uint32 dir_id);
int32 OS_DirectoryRewind(osal_id_t dir_id);


/*-------------------------------------------------------------------------------------*/
Expand All @@ -609,7 +628,7 @@ int32 OS_DirectoryRewind(uint32 dir_id);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_DirectoryRead(uint32 dir_id, os_dirent_t *dirent);
int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent);


/*-------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -671,7 +690,7 @@ int32 OS_rmdir (const char *path);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path,
int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path,
const char *virt_path);

/*-------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -899,7 +918,11 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info);
* @retval #OS_ERROR if the command was not executed properly
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_ShellOutputToFile(const char* Cmd, uint32 filedes);
/**@}*/
int32 OS_ShellOutputToFile(const char* Cmd, osal_id_t filedes);






#endif
6 changes: 3 additions & 3 deletions src/os/inc/osapi-os-loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit );
* @retval #OS_ERR_NO_FREE_IDS if the module table is full
* @retval #OS_ERR_NAME_TAKEN if the name is in use
*/
int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename );
int32 OS_ModuleLoad ( osal_id_t *module_id, const char *module_name, const char *filename );

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -153,7 +153,7 @@ int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *fi
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERROR if the module is invalid or cannot be unloaded
*/
int32 OS_ModuleUnload ( uint32 module_id );
int32 OS_ModuleUnload ( osal_id_t module_id );

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -169,7 +169,7 @@ int32 OS_ModuleUnload ( uint32 module_id );
* @retval #OS_ERR_INVALID_ID if the module id invalid
* @retval #OS_INVALID_POINTER if the pointer to the ModuleInfo structure is invalid
*/
int32 OS_ModuleInfo ( uint32 module_id, OS_module_prop_t *module_info );
int32 OS_ModuleInfo ( osal_id_t module_id, OS_module_prop_t *module_info );
/**@}*/

#endif
18 changes: 9 additions & 9 deletions src/os/inc/osapi-os-net.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ typedef struct
typedef struct
{
char name [OS_MAX_API_NAME]; /**< @brief Name of the socket */
uint32 creator; /**< @brief OSAL TaskID which opened the socket */
osal_id_t creator; /**< @brief OSAL TaskID which opened the socket */
} OS_socket_prop_t;

/**
Expand Down Expand Up @@ -247,7 +247,7 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type);
int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -265,7 +265,7 @@ int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t T
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr);
int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -281,7 +281,7 @@ int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout);
int32 OS_SocketConnect(osal_id_t sock_id, const OS_SockAddr_t *Addr, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -302,7 +302,7 @@ int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout)
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout);
int32 OS_SocketAccept(osal_id_t sock_id, osal_id_t *connsock_id, OS_SockAddr_t *Addr, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -319,7 +319,7 @@ int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr,
*
* @return Count of actual bytes received or error status, see @ref OSReturnCodes
*/
int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout);
int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -336,7 +336,7 @@ int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr
*
* @return Count of actual bytes sent or error status, see @ref OSReturnCodes
*/
int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr);
int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -355,7 +355,7 @@ int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const O
* @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME
* @retval #OS_ERR_NAME_NOT_FOUND if the name was not found in the table
*/
int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name);
int32 OS_SocketGetIdByName (osal_id_t *sock_id, const char *sock_name);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -372,7 +372,7 @@ int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name);
* @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
* @retval #OS_INVALID_POINTER if the count_prop pointer is null
*/
int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop);
int32 OS_SocketGetInfo (osal_id_t sock_id, OS_socket_prop_t *sock_prop);


/*-------------------------------------------------------------------------------------*/
Expand Down
Loading