diff --git a/src/os/portable/os-impl-bsd-select.c b/src/os/portable/os-impl-bsd-select.c index 29c677f36..afe500527 100644 --- a/src/os/portable/os-impl-bsd-select.c +++ b/src/os/portable/os-impl-bsd-select.c @@ -45,6 +45,7 @@ #include #include "os-impl-select.h" #include "os-shared-select.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -249,17 +250,20 @@ static int32 OS_DoSelect(int maxfd, fd_set *rd_set, fd_set *wr_set, int32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SelectSingle_Impl(osal_index_t stream_id, uint32 *SelectFlags, int32 msecs) +int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags, int32 msecs) { - int32 return_code; - fd_set wr_set; - fd_set rd_set; + int32 return_code; + fd_set wr_set; + fd_set rd_set; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); /* * If called on a stream_id which does not support this * operation, return immediately and do not invoke the system call */ - if (!OS_impl_filehandle_table[stream_id].selectable) + if (!impl->selectable) { return OS_ERR_OPERATION_NOT_SUPPORTED; } @@ -270,22 +274,22 @@ int32 OS_SelectSingle_Impl(osal_index_t stream_id, uint32 *SelectFlags, int32 ms FD_ZERO(&rd_set); if (*SelectFlags & OS_STREAM_STATE_READABLE) { - FD_SET(OS_impl_filehandle_table[stream_id].fd, &rd_set); + FD_SET(impl->fd, &rd_set); } if (*SelectFlags & OS_STREAM_STATE_WRITABLE) { - FD_SET(OS_impl_filehandle_table[stream_id].fd, &wr_set); + FD_SET(impl->fd, &wr_set); } - return_code = OS_DoSelect(OS_impl_filehandle_table[stream_id].fd, &rd_set, &wr_set, msecs); + return_code = OS_DoSelect(impl->fd, &rd_set, &wr_set, msecs); if (return_code == OS_SUCCESS) { - if (!FD_ISSET(OS_impl_filehandle_table[stream_id].fd, &rd_set)) + if (!FD_ISSET(impl->fd, &rd_set)) { *SelectFlags &= ~OS_STREAM_STATE_READABLE; } - if (!FD_ISSET(OS_impl_filehandle_table[stream_id].fd, &wr_set)) + if (!FD_ISSET(impl->fd, &wr_set)) { *SelectFlags &= ~OS_STREAM_STATE_WRITABLE; } diff --git a/src/os/portable/os-impl-bsd-sockets.c b/src/os/portable/os-impl-bsd-sockets.c index 655dc0287..31ca3e911 100644 --- a/src/os/portable/os-impl-bsd-sockets.c +++ b/src/os/portable/os-impl-bsd-sockets.c @@ -57,6 +57,7 @@ #include "os-shared-file.h" #include "os-shared-select.h" #include "os-shared-sockets.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -84,16 +85,21 @@ typedef union * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketOpen_Impl(osal_index_t sock_id) +int32 OS_SocketOpen_Impl(const OS_object_token_t *token) { - int os_domain; - int os_type; - int os_proto; - int os_flags; + int os_domain; + int os_type; + int os_proto; + int os_flags; + OS_impl_file_internal_record_t *impl; + OS_stream_internal_record_t * stream; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + stream = OS_OBJECT_TABLE_GET(OS_stream_table, *token); os_proto = 0; - switch (OS_stream_table[sock_id].socket_type) + switch (stream->socket_type) { case OS_SocketType_DATAGRAM: os_type = SOCK_DGRAM; @@ -106,7 +112,7 @@ int32 OS_SocketOpen_Impl(osal_index_t sock_id) return OS_ERR_NOT_IMPLEMENTED; } - switch (OS_stream_table[sock_id].socket_domain) + switch (stream->socket_domain) { case OS_SocketDomain_INET: os_domain = AF_INET; @@ -120,11 +126,11 @@ int32 OS_SocketOpen_Impl(osal_index_t sock_id) return OS_ERR_NOT_IMPLEMENTED; } - switch (OS_stream_table[sock_id].socket_domain) + switch (stream->socket_domain) { case OS_SocketDomain_INET: case OS_SocketDomain_INET6: - switch (OS_stream_table[sock_id].socket_type) + switch (stream->socket_type) { case OS_SocketType_DATAGRAM: os_proto = IPPROTO_UDP; @@ -140,8 +146,8 @@ int32 OS_SocketOpen_Impl(osal_index_t sock_id) break; } - OS_impl_filehandle_table[sock_id].fd = socket(os_domain, os_type, os_proto); - if (OS_impl_filehandle_table[sock_id].fd < 0) + impl->fd = socket(os_domain, os_type, os_proto); + if (impl->fd < 0) { return OS_ERROR; } @@ -151,18 +157,18 @@ int32 OS_SocketOpen_Impl(osal_index_t sock_id) * code restarts. However if setting the option fails then it is not worth bailing out over. */ os_flags = 1; - setsockopt(OS_impl_filehandle_table[sock_id].fd, SOL_SOCKET, SO_REUSEADDR, &os_flags, sizeof(os_flags)); + setsockopt(impl->fd, SOL_SOCKET, SO_REUSEADDR, &os_flags, sizeof(os_flags)); /* * Set the standard options on the filehandle by default -- * this may set it to non-blocking mode if the implementation supports it. * any blocking would be done explicitly via the select() wrappers */ - os_flags = fcntl(OS_impl_filehandle_table[sock_id].fd, F_GETFL); + os_flags = fcntl(impl->fd, F_GETFL); os_flags |= OS_IMPL_SOCKET_FLAGS; - fcntl(OS_impl_filehandle_table[sock_id].fd, F_SETFL, os_flags); + fcntl(impl->fd, F_SETFL, os_flags); - OS_impl_filehandle_table[sock_id].selectable = ((os_flags & O_NONBLOCK) != 0); + impl->selectable = ((os_flags & O_NONBLOCK) != 0); return OS_SUCCESS; } /* end OS_SocketOpen_Impl */ @@ -175,11 +181,16 @@ int32 OS_SocketOpen_Impl(osal_index_t sock_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketBind_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr) +int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr) { - int os_result; - socklen_t addrlen; - const struct sockaddr *sa; + int os_result; + socklen_t addrlen; + const struct sockaddr * sa; + OS_impl_file_internal_record_t *impl; + OS_stream_internal_record_t * stream; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + stream = OS_OBJECT_TABLE_GET(OS_stream_table, *token); sa = (const struct sockaddr *)&Addr->AddrData; @@ -203,7 +214,7 @@ int32 OS_SocketBind_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr) return OS_ERR_BAD_ADDRESS; } - os_result = bind(OS_impl_filehandle_table[sock_id].fd, sa, addrlen); + os_result = bind(impl->fd, sa, addrlen); if (os_result < 0) { OS_DEBUG("bind: %s\n", strerror(errno)); @@ -211,9 +222,9 @@ int32 OS_SocketBind_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr) } /* Start listening on the socket (implied for stream sockets) */ - if (OS_stream_table[sock_id].socket_type == OS_SocketType_STREAM) + if (stream->socket_type == OS_SocketType_STREAM) { - os_result = listen(OS_impl_filehandle_table[sock_id].fd, 10); + os_result = listen(impl->fd, 10); if (os_result < 0) { OS_DEBUG("listen: %s\n", strerror(errno)); @@ -231,14 +242,17 @@ int32 OS_SocketBind_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int32 timeout) +int32 OS_SocketConnect_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr, int32 timeout) { - int32 return_code; - int os_status; - int sockopt; - socklen_t slen; - uint32 operation; - const struct sockaddr *sa; + int32 return_code; + int os_status; + int sockopt; + socklen_t slen; + uint32 operation; + const struct sockaddr * sa; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); sa = (const struct sockaddr *)&Addr->AddrData; switch (sa->sa_family) @@ -263,7 +277,7 @@ int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int else { return_code = OS_SUCCESS; - os_status = connect(OS_impl_filehandle_table[sock_id].fd, sa, slen); + os_status = connect(impl->fd, sa, slen); if (os_status < 0) { if (errno != EINPROGRESS) @@ -273,9 +287,9 @@ int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int else { operation = OS_STREAM_STATE_WRITABLE; - if (OS_impl_filehandle_table[sock_id].selectable) + if (impl->selectable) { - return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); + return_code = OS_SelectSingle_Impl(token, &operation, timeout); } if (return_code == OS_SUCCESS) { @@ -285,10 +299,9 @@ int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int } else { - sockopt = 0; - slen = sizeof(sockopt); - os_status = - getsockopt(OS_impl_filehandle_table[sock_id].fd, SOL_SOCKET, SO_ERROR, &sockopt, &slen); + sockopt = 0; + slen = sizeof(sockopt); + os_status = getsockopt(impl->fd, SOL_SOCKET, SO_ERROR, &sockopt, &slen); if (os_status < 0 || sockopt != 0) { return_code = OS_ERROR; @@ -309,17 +322,23 @@ int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketAccept_Impl(osal_index_t sock_id, osal_index_t connsock_id, OS_SockAddr_t *Addr, int32 timeout) +int32 OS_SocketAccept_Impl(const OS_object_token_t *sock_token, const OS_object_token_t *conn_token, + OS_SockAddr_t *Addr, int32 timeout) { - int32 return_code; - uint32 operation; - socklen_t addrlen; - int os_flags; + int32 return_code; + uint32 operation; + socklen_t addrlen; + int os_flags; + OS_impl_file_internal_record_t *sock_impl; + OS_impl_file_internal_record_t *conn_impl; + + sock_impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *sock_token); + conn_impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *conn_token); operation = OS_STREAM_STATE_READABLE; - if (OS_impl_filehandle_table[sock_id].selectable) + if (sock_impl->selectable) { - return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); + return_code = OS_SelectSingle_Impl(sock_token, &operation, timeout); } else { @@ -334,10 +353,9 @@ int32 OS_SocketAccept_Impl(osal_index_t sock_id, osal_index_t connsock_id, OS_So } else { - addrlen = Addr->ActualLength; - OS_impl_filehandle_table[connsock_id].fd = - accept(OS_impl_filehandle_table[sock_id].fd, (struct sockaddr *)&Addr->AddrData, &addrlen); - if (OS_impl_filehandle_table[connsock_id].fd < 0) + addrlen = Addr->ActualLength; + conn_impl->fd = accept(sock_impl->fd, (struct sockaddr *)&Addr->AddrData, &addrlen); + if (conn_impl->fd < 0) { return_code = OS_ERROR; } @@ -350,11 +368,11 @@ int32 OS_SocketAccept_Impl(osal_index_t sock_id, osal_index_t connsock_id, OS_So * this may set it to non-blocking mode if the implementation supports it. * any blocking would be done explicitly via the select() wrappers */ - os_flags = fcntl(OS_impl_filehandle_table[connsock_id].fd, F_GETFL); + os_flags = fcntl(conn_impl->fd, F_GETFL); os_flags |= OS_IMPL_SOCKET_FLAGS; - fcntl(OS_impl_filehandle_table[connsock_id].fd, F_SETFL, os_flags); + fcntl(conn_impl->fd, F_SETFL, os_flags); - OS_impl_filehandle_table[connsock_id].selectable = ((os_flags & O_NONBLOCK) != 0); + conn_impl->selectable = ((os_flags & O_NONBLOCK) != 0); } } } @@ -370,15 +388,18 @@ int32 OS_SocketAccept_Impl(osal_index_t sock_id, osal_index_t connsock_id, OS_So * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketRecvFrom_Impl(osal_index_t sock_id, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, +int32 OS_SocketRecvFrom_Impl(const OS_object_token_t *token, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - int32 return_code; - int os_result; - int waitflags; - uint32 operation; - struct sockaddr *sa; - socklen_t addrlen; + int32 return_code; + int os_result; + int waitflags; + uint32 operation; + struct sockaddr * sa; + socklen_t addrlen; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); if (RemoteAddr == NULL) { @@ -396,10 +417,10 @@ int32 OS_SocketRecvFrom_Impl(osal_index_t sock_id, void *buffer, size_t buflen, * If "O_NONBLOCK" flag is set then use select() * Note this is the only way to get a correct timeout */ - if (OS_impl_filehandle_table[sock_id].selectable) + if (impl->selectable) { waitflags = MSG_DONTWAIT; - return_code = OS_SelectSingle_Impl(sock_id, &operation, timeout); + return_code = OS_SelectSingle_Impl(token, &operation, timeout); } else { @@ -423,7 +444,7 @@ int32 OS_SocketRecvFrom_Impl(osal_index_t sock_id, void *buffer, size_t buflen, } else { - os_result = recvfrom(OS_impl_filehandle_table[sock_id].fd, buffer, buflen, waitflags, sa, &addrlen); + os_result = recvfrom(impl->fd, buffer, buflen, waitflags, sa, &addrlen); if (os_result < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) @@ -459,11 +480,15 @@ int32 OS_SocketRecvFrom_Impl(osal_index_t sock_id, void *buffer, size_t buflen, * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketSendTo_Impl(osal_index_t sock_id, const void *buffer, size_t buflen, const OS_SockAddr_t *RemoteAddr) +int32 OS_SocketSendTo_Impl(const OS_object_token_t *token, const void *buffer, size_t buflen, + const OS_SockAddr_t *RemoteAddr) { - int os_result; - socklen_t addrlen; - const struct sockaddr *sa; + int os_result; + socklen_t addrlen; + const struct sockaddr * sa; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); sa = (const struct sockaddr *)&RemoteAddr->AddrData; switch (sa->sa_family) @@ -486,7 +511,7 @@ int32 OS_SocketSendTo_Impl(osal_index_t sock_id, const void *buffer, size_t bufl return OS_ERR_BAD_ADDRESS; } - os_result = sendto(OS_impl_filehandle_table[sock_id].fd, buffer, buflen, MSG_DONTWAIT, sa, addrlen); + os_result = sendto(impl->fd, buffer, buflen, MSG_DONTWAIT, sa, addrlen); if (os_result < 0) { OS_DEBUG("sendto: %s\n", strerror(errno)); @@ -504,7 +529,7 @@ int32 OS_SocketSendTo_Impl(osal_index_t sock_id, const void *buffer, size_t bufl * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_SocketGetInfo_Impl(osal_index_t sock_id, OS_socket_prop_t *sock_prop) +int32 OS_SocketGetInfo_Impl(const OS_object_token_t *token, OS_socket_prop_t *sock_prop) { return OS_SUCCESS; } /* end OS_SocketGetInfo_Impl */ diff --git a/src/os/portable/os-impl-console-bsp.c b/src/os/portable/os-impl-console-bsp.c index 815c423d5..fc3d8290b 100644 --- a/src/os/portable/os-impl-console-bsp.c +++ b/src/os/portable/os-impl-console-bsp.c @@ -39,6 +39,7 @@ #include "os-impl-console.h" #include "os-shared-printf.h" +#include "os-shared-idmap.h" /**************************************************************************************** CONSOLE OUTPUT @@ -52,14 +53,14 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleOutput_Impl(osal_index_t local_id) +void OS_ConsoleOutput_Impl(const OS_object_token_t *token) { size_t StartPos; size_t EndPos; size_t WriteSize; OS_console_internal_record_t *console; - console = &OS_console_table[local_id]; + console = OS_OBJECT_TABLE_GET(OS_console_table, *token); StartPos = console->ReadPos; EndPos = console->WritePos; while (StartPos != EndPos) diff --git a/src/os/portable/os-impl-no-loader.c b/src/os/portable/os-impl-no-loader.c index 046fe3419..dbed7b8e8 100644 --- a/src/os/portable/os-impl-no-loader.c +++ b/src/os/portable/os-impl-no-loader.c @@ -38,7 +38,7 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) +int32 OS_ModuleLoad_Impl(const OS_object_token_t *token, const char *translated_path) { return OS_ERR_NOT_IMPLEMENTED; @@ -52,7 +52,7 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl(osal_index_t module_id) +int32 OS_ModuleUnload_Impl(const OS_object_token_t *token) { return OS_ERR_NOT_IMPLEMENTED; @@ -66,7 +66,7 @@ int32 OS_ModuleUnload_Impl(osal_index_t module_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl(osal_index_t module_id, OS_module_prop_t *module_prop) +int32 OS_ModuleGetInfo_Impl(const OS_object_token_t *token, OS_module_prop_t *module_prop) { return OS_ERR_NOT_IMPLEMENTED; diff --git a/src/os/portable/os-impl-no-shell.c b/src/os/portable/os-impl-no-shell.c index 5f86dc1af..77ca23208 100644 --- a/src/os/portable/os-impl-no-shell.c +++ b/src/os/portable/os-impl-no-shell.c @@ -34,7 +34,7 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(osal_index_t file_id, const char *Cmd) +int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd) { return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/os/portable/os-impl-posix-dirs.c b/src/os/portable/os-impl-posix-dirs.c index e840ed089..05b246f6d 100644 --- a/src/os/portable/os-impl-posix-dirs.c +++ b/src/os/portable/os-impl-posix-dirs.c @@ -49,6 +49,7 @@ #include "os-impl-dirs.h" #include "os-shared-dir.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -104,14 +105,19 @@ int32 OS_DirCreate_Impl(const char *local_path, uint32 access) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirOpen_Impl(osal_index_t local_id, const char *local_path) +int32 OS_DirOpen_Impl(const OS_object_token_t *token, const char *local_path) { - DIR *dp = opendir(local_path); + DIR * dp = opendir(local_path); + OS_impl_dir_internal_record_t *impl; + if (dp == NULL) { return OS_ERROR; } - OS_impl_dir_table[local_id].dp = dp; + + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); + impl->dp = dp; + return OS_SUCCESS; } /* end OS_DirOpen_Impl */ @@ -123,10 +129,15 @@ int32 OS_DirOpen_Impl(osal_index_t local_id, const char *local_path) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirClose_Impl(osal_index_t local_id) +int32 OS_DirClose_Impl(const OS_object_token_t *token) { - closedir(OS_impl_dir_table[local_id].dp); - OS_impl_dir_table[local_id].dp = NULL; + OS_impl_dir_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); + + closedir(impl->dp); + impl->dp = NULL; + return OS_SUCCESS; } /* end OS_DirClose_Impl */ @@ -138,9 +149,11 @@ int32 OS_DirClose_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent) +int32 OS_DirRead_Impl(const OS_object_token_t *token, os_dirent_t *dirent) { - struct dirent *de; + struct dirent * de; + OS_impl_dir_internal_record_t *impl; + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); /* NOTE - the readdir() call is non-reentrant .... * However, this is performed while the global dir table lock is taken. @@ -151,7 +164,7 @@ int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent) */ /* cppcheck-suppress readdirCalled */ /* cppcheck-suppress nonreentrantFunctionsreaddir */ - de = readdir(OS_impl_dir_table[local_id].dp); + de = readdir(impl->dp); if (de == NULL) { return OS_ERROR; @@ -171,9 +184,11 @@ int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirRewind_Impl(osal_index_t local_id) +int32 OS_DirRewind_Impl(const OS_object_token_t *token) { - rewinddir(OS_impl_dir_table[local_id].dp); + OS_impl_dir_internal_record_t *impl; + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); + rewinddir(impl->dp); return OS_SUCCESS; } /* end OS_DirRewind_Impl */ diff --git a/src/os/portable/os-impl-posix-dl-loader.c b/src/os/portable/os-impl-posix-dl-loader.c index 2a8036dcc..3843d5050 100644 --- a/src/os/portable/os-impl-posix-dl-loader.c +++ b/src/os/portable/os-impl-posix-dl-loader.c @@ -48,6 +48,7 @@ #include "os-impl-loader.h" #include "os-shared-module.h" +#include "os-shared-idmap.h" /**************************************************************************************** Module Loader API @@ -61,10 +62,15 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) +int32 OS_ModuleLoad_Impl(const OS_object_token_t *token, const char *translated_path) { - int32 status = OS_ERROR; - int dl_mode; + int32 status = OS_ERROR; + int dl_mode; + OS_impl_module_internal_record_t *impl; + OS_module_internal_record_t * module; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); + module = OS_OBJECT_TABLE_GET(OS_module_table, *token); /* * RTLD_NOW should instruct dlopen() to resolve all the symbols in the @@ -74,7 +80,7 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) */ dl_mode = RTLD_NOW; - if ((OS_module_table[module_id].flags & OS_MODULE_FLAG_LOCAL_SYMBOLS) != 0) + if ((module->flags & OS_MODULE_FLAG_LOCAL_SYMBOLS) != 0) { /* * Do not add the symbols in this module to the global symbol table. @@ -95,8 +101,8 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) } dlerror(); - OS_impl_module_table[module_id].dl_handle = dlopen(translated_path, dl_mode); - if (OS_impl_module_table[module_id].dl_handle != NULL) + impl->dl_handle = dlopen(translated_path, dl_mode); + if (impl->dl_handle != NULL) { status = OS_SUCCESS; } @@ -117,18 +123,21 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl(osal_index_t module_id) +int32 OS_ModuleUnload_Impl(const OS_object_token_t *token) { - int32 status = OS_ERROR; + int32 status = OS_ERROR; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); /* ** Attempt to close/unload the module */ dlerror(); - if (dlclose(OS_impl_module_table[module_id].dl_handle) == 0) + if (dlclose(impl->dl_handle) == 0) { - OS_impl_module_table[module_id].dl_handle = NULL; - status = OS_SUCCESS; + impl->dl_handle = NULL; + status = OS_SUCCESS; } else { @@ -147,7 +156,7 @@ int32 OS_ModuleUnload_Impl(osal_index_t module_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl(osal_index_t module_id, OS_module_prop_t *module_prop) +int32 OS_ModuleGetInfo_Impl(const OS_object_token_t *token, OS_module_prop_t *module_prop) { /* * Limiting strictly to POSIX-defined API means there is no defined diff --git a/src/os/portable/os-impl-posix-dl-symtab.c b/src/os/portable/os-impl-posix-dl-symtab.c index ff78c19d5..629ba8d8e 100644 --- a/src/os/portable/os-impl-posix-dl-symtab.c +++ b/src/os/portable/os-impl-posix-dl-symtab.c @@ -47,6 +47,7 @@ #include "os-impl-loader.h" #include "os-shared-module.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -157,11 +158,14 @@ int32 OS_GlobalSymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleSymbolLookup_Impl(osal_index_t local_id, cpuaddr *SymbolAddress, const char *SymbolName) +int32 OS_ModuleSymbolLookup_Impl(const OS_object_token_t *token, cpuaddr *SymbolAddress, const char *SymbolName) { - int32 status; + int32 status; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); - status = OS_GenericSymbolLookup_Impl(OS_impl_module_table[local_id].dl_handle, SymbolAddress, SymbolName); + status = OS_GenericSymbolLookup_Impl(impl->dl_handle, SymbolAddress, SymbolName); return status; diff --git a/src/os/portable/os-impl-posix-files.c b/src/os/portable/os-impl-posix-files.c index ba59fcba0..d46aa2142 100644 --- a/src/os/portable/os-impl-posix-files.c +++ b/src/os/portable/os-impl-posix-files.c @@ -46,6 +46,7 @@ #include "os-impl-files.h" #include "os-shared-file.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -63,10 +64,13 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileOpen_Impl(osal_index_t local_id, const char *local_path, int32 flags, int32 access) +int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access) { - int os_perm; - int os_mode; + int os_perm; + int os_mode; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); /* ** Check for a valid access mode @@ -100,9 +104,9 @@ int32 OS_FileOpen_Impl(osal_index_t local_id, const char *local_path, int32 flag os_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - OS_impl_filehandle_table[local_id].fd = open(local_path, os_perm, os_mode); + impl->fd = open(local_path, os_perm, os_mode); - if (OS_impl_filehandle_table[local_id].fd < 0) + if (impl->fd < 0) { OS_DEBUG("open(%s): %s\n", local_path, strerror(errno)); return OS_ERROR; @@ -112,7 +116,7 @@ int32 OS_FileOpen_Impl(osal_index_t local_id, const char *local_path, int32 flag * If the flags included O_NONBLOCK, then * enable the "select" call on this handle. */ - OS_impl_filehandle_table[local_id].selectable = ((os_perm & O_NONBLOCK) != 0); + impl->selectable = ((os_perm & O_NONBLOCK) != 0); return OS_SUCCESS; } /* end OS_FileOpen_Impl */ diff --git a/src/os/portable/os-impl-posix-io.c b/src/os/portable/os-impl-posix-io.c index 429e931b0..cabe43541 100644 --- a/src/os/portable/os-impl-posix-io.c +++ b/src/os/portable/os-impl-posix-io.c @@ -48,6 +48,7 @@ #include "os-impl-io.h" #include "os-shared-file.h" #include "os-shared-select.h" +#include "os-shared-idmap.h" /* some OS libraries (e.g. VxWorks) do not declare the API to be const-correct * It can still use this generic implementation but the call to write() must be @@ -66,11 +67,14 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_GenericClose_Impl(osal_index_t local_id) +int32 OS_GenericClose_Impl(const OS_object_token_t *token) { - int result; + int result; + OS_impl_file_internal_record_t *impl; - result = close(OS_impl_filehandle_table[local_id].fd); + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + + result = close(impl->fd); if (result < 0) { /* @@ -86,7 +90,7 @@ int32 OS_GenericClose_Impl(osal_index_t local_id) */ OS_DEBUG("close: %s\n", strerror(errno)); } - OS_impl_filehandle_table[local_id].fd = -1; + impl->fd = -1; return OS_SUCCESS; } /* end OS_GenericClose_Impl */ @@ -98,11 +102,14 @@ int32 OS_GenericClose_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_GenericSeek_Impl(osal_index_t local_id, int32 offset, uint32 whence) +int32 OS_GenericSeek_Impl(const OS_object_token_t *token, int32 offset, uint32 whence) { - int where; - off_t os_result; - int32 retval; + int where; + off_t os_result; + int32 retval; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); switch (whence) { @@ -119,7 +126,7 @@ int32 OS_GenericSeek_Impl(osal_index_t local_id, int32 offset, uint32 whence) return OS_ERROR; } - os_result = lseek(OS_impl_filehandle_table[local_id].fd, (off_t)offset, where); + os_result = lseek(impl->fd, (off_t)offset, where); if (os_result == (off_t)-1) { if (errno == ESPIPE) @@ -163,11 +170,14 @@ int32 OS_GenericSeek_Impl(osal_index_t local_id, int32 offset, uint32 whence) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, int32 timeout) +int32 OS_GenericRead_Impl(const OS_object_token_t *token, void *buffer, size_t nbytes, int32 timeout) { - int32 return_code; - ssize_t os_result; - uint32 operation; + int32 return_code; + ssize_t os_result; + uint32 operation; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); return_code = OS_SUCCESS; @@ -183,14 +193,14 @@ int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, in * * Note that a timeout will not work unless selectable is true. */ - if (OS_impl_filehandle_table[local_id].selectable) + if (impl->selectable) { - return_code = OS_SelectSingle_Impl(local_id, &operation, timeout); + return_code = OS_SelectSingle_Impl(token, &operation, timeout); } if (return_code == OS_SUCCESS && (operation & OS_STREAM_STATE_READABLE) != 0) { - os_result = read(OS_impl_filehandle_table[local_id].fd, buffer, nbytes); + os_result = read(impl->fd, buffer, nbytes); if (os_result < 0) { OS_DEBUG("read: %s\n", strerror(errno)); @@ -215,11 +225,14 @@ int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, in * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_GenericWrite_Impl(osal_index_t local_id, const void *buffer, size_t nbytes, int32 timeout) +int32 OS_GenericWrite_Impl(const OS_object_token_t *token, const void *buffer, size_t nbytes, int32 timeout) { - int32 return_code; - ssize_t os_result; - uint32 operation; + int32 return_code; + ssize_t os_result; + uint32 operation; + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); return_code = OS_SUCCESS; @@ -235,16 +248,16 @@ int32 OS_GenericWrite_Impl(osal_index_t local_id, const void *buffer, size_t nby * * Note that a timeout will not work unless selectable is true. */ - if (OS_impl_filehandle_table[local_id].selectable) + if (impl->selectable) { - return_code = OS_SelectSingle_Impl(local_id, &operation, timeout); + return_code = OS_SelectSingle_Impl(token, &operation, timeout); } if (return_code == OS_SUCCESS && (operation & OS_STREAM_STATE_WRITABLE) != 0) { /* on some system libraries for which the write() argument is not * qualified correctly, it needs to be case to a void* here */ - os_result = write(OS_impl_filehandle_table[local_id].fd, GENERIC_IO_CONST_DATA_CAST buffer, nbytes); + os_result = write(impl->fd, GENERIC_IO_CONST_DATA_CAST buffer, nbytes); if (os_result < 0) { OS_DEBUG("write: %s\n", strerror(errno)); diff --git a/src/os/posix/src/os-impl-binsem.c b/src/os/posix/src/os-impl-binsem.c index 89227a2f4..fe86c4b8a 100644 --- a/src/os/posix/src/os-impl-binsem.c +++ b/src/os/posix/src/os-impl-binsem.c @@ -32,6 +32,7 @@ ***************************************************************************************/ #include "os-posix.h" +#include "os-shared-idmap.h" #include "os-shared-binsem.h" #include "os-impl-binsem.h" @@ -118,7 +119,7 @@ int32 OS_Posix_BinSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 initial_value, uint32 options) +int32 OS_BinSemCreate_Impl(const OS_object_token_t *token, uint32 initial_value, uint32 options) { int ret; int attr_created; @@ -141,7 +142,7 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 initial_value, uint32 opt attr_created = 0; mutex_created = 0; cond_created = 0; - sem = &OS_impl_bin_sem_table[sem_id]; + sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); memset(sem, 0, sizeof(*sem)); do @@ -240,12 +241,12 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 initial_value, uint32 opt * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl(osal_index_t sem_id) +int32 OS_BinSemDelete_Impl(const OS_object_token_t *token) { OS_impl_binsem_internal_record_t *sem; int32 return_code; - sem = &OS_impl_bin_sem_table[sem_id]; + sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); if (pthread_cond_destroy(&(sem->cv)) != 0) { @@ -279,11 +280,11 @@ int32 OS_BinSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl(osal_index_t sem_id) +int32 OS_BinSemGive_Impl(const OS_object_token_t *token) { OS_impl_binsem_internal_record_t *sem; - sem = &OS_impl_bin_sem_table[sem_id]; + sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); /* * Note there is a possibility that another thread is concurrently taking this sem, @@ -324,11 +325,11 @@ int32 OS_BinSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl(osal_index_t sem_id) +int32 OS_BinSemFlush_Impl(const OS_object_token_t *token) { OS_impl_binsem_internal_record_t *sem; - sem = &OS_impl_bin_sem_table[sem_id]; + sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); /* Lock the mutex ( not the table! ) */ if (OS_Posix_BinSemAcquireMutex(&sem->id) != OS_SUCCESS) @@ -358,10 +359,13 @@ int32 OS_BinSemFlush_Impl(osal_index_t sem_id) becomes nonzero (via SemGive) or the semaphore gets flushed. ---------------------------------------------------------------------------------------*/ -static int32 OS_GenericBinSemTake_Impl(OS_impl_binsem_internal_record_t *sem, const struct timespec *timeout) +static int32 OS_GenericBinSemTake_Impl(const OS_object_token_t *token, const struct timespec *timeout) { - sig_atomic_t flush_count; - int32 return_code; + sig_atomic_t flush_count; + int32 return_code; + OS_impl_binsem_internal_record_t *sem; + + sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); /* * Note - this lock should be quickly available - should not delay here. @@ -441,9 +445,9 @@ static int32 OS_GenericBinSemTake_Impl(OS_impl_binsem_internal_record_t *sem, co * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl(osal_index_t sem_id) +int32 OS_BinSemTake_Impl(const OS_object_token_t *token) { - return (OS_GenericBinSemTake_Impl(&OS_impl_bin_sem_table[sem_id], NULL)); + return (OS_GenericBinSemTake_Impl(token, NULL)); } /* end OS_BinSemTake_Impl */ /*---------------------------------------------------------------- @@ -454,7 +458,7 @@ int32 OS_BinSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) +int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) { struct timespec ts; @@ -463,7 +467,7 @@ int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) */ OS_Posix_CompAbsDelayTime(msecs, &ts); - return (OS_GenericBinSemTake_Impl(&OS_impl_bin_sem_table[sem_id], &ts)); + return (OS_GenericBinSemTake_Impl(token, &ts)); } /* end OS_BinSemTimedWait_Impl */ /*---------------------------------------------------------------- @@ -474,9 +478,13 @@ int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(osal_index_t sem_id, OS_bin_sem_prop_t *sem_prop) +int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *sem_prop) { + OS_impl_binsem_internal_record_t *sem; + + sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); + /* put the info into the stucture */ - sem_prop->value = OS_impl_bin_sem_table[sem_id].current_value; + sem_prop->value = sem->current_value; return OS_SUCCESS; } /* end OS_BinSemGetInfo_Impl */ diff --git a/src/os/posix/src/os-impl-console.c b/src/os/posix/src/os-impl-console.c index be6197a6f..7ba6baa63 100644 --- a/src/os/posix/src/os-impl-console.c +++ b/src/os/posix/src/os-impl-console.c @@ -32,6 +32,7 @@ #include "os-posix.h" #include "os-impl-console.h" +#include "os-shared-idmap.h" #include "os-shared-printf.h" /* @@ -59,9 +60,11 @@ OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(osal_index_t local_id) +void OS_ConsoleWakeup_Impl(const OS_object_token_t *token) { - OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; + OS_impl_console_internal_record_t *local; + + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, *token); if (local->is_async) { @@ -71,7 +74,7 @@ void OS_ConsoleWakeup_Impl(osal_index_t local_id) else { /* output directly */ - OS_ConsoleOutput_Impl(local_id); + OS_ConsoleOutput_Impl(token); } } /* end OS_ConsoleWakeup_Impl */ @@ -87,13 +90,18 @@ static void *OS_ConsoleTask_Entry(void *arg) { OS_U32ValueWrapper_t local_arg; OS_impl_console_internal_record_t *local; + OS_object_token_t token; local_arg.opaque_arg = arg; - local = &OS_impl_console_table[local_arg.idx]; - while (true) + if (OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_CONSOLE, local_arg.id, &token) == OS_SUCCESS) { - OS_ConsoleOutput_Impl(local_arg.idx); - sem_wait(&local->data_sem); + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token); + while (true) + { + OS_ConsoleOutput_Impl(&token); + sem_wait(&local->data_sem); + } + OS_ObjectIdRelease(&token); } return NULL; } /* end OS_ConsoleTask_Entry */ @@ -106,33 +114,35 @@ static void *OS_ConsoleTask_Entry(void *arg) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ConsoleCreate_Impl(osal_index_t local_id) +int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token) { - OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; + OS_impl_console_internal_record_t *local; pthread_t consoletask; int32 return_code; OS_U32ValueWrapper_t local_arg = {0}; - if (local_id == 0) + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, *token); + + if (token->obj_idx == 0) { return_code = OS_SUCCESS; local->is_async = OS_CONSOLE_ASYNC; if (local->is_async) { - if (sem_init(&OS_impl_console_table[local_id].data_sem, 0, 0) < 0) + if (sem_init(&local->data_sem, 0, 0) < 0) { return_code = OS_SEM_FAILURE; } else { - local_arg.idx = local_id; - return_code = OS_Posix_InternalTaskCreate_Impl(&consoletask, OS_CONSOLE_TASK_PRIORITY, 0, + local_arg.id = OS_ObjectIdFromToken(token); + return_code = OS_Posix_InternalTaskCreate_Impl(&consoletask, OS_CONSOLE_TASK_PRIORITY, 0, OS_ConsoleTask_Entry, local_arg.opaque_arg); if (return_code != OS_SUCCESS) { - sem_destroy(&OS_impl_console_table[local_id].data_sem); + sem_destroy(&local->data_sem); } } } diff --git a/src/os/posix/src/os-impl-countsem.c b/src/os/posix/src/os-impl-countsem.c index d399e0857..dac78b6ab 100644 --- a/src/os/posix/src/os-impl-countsem.c +++ b/src/os/posix/src/os-impl-countsem.c @@ -32,6 +32,7 @@ #include "os-posix.h" #include "os-impl-countsem.h" #include "os-shared-countsem.h" +#include "os-shared-idmap.h" /* * Added SEM_VALUE_MAX Define @@ -74,14 +75,18 @@ int32 OS_Posix_CountSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options) { + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + if (sem_initial_value > SEM_VALUE_MAX) { return OS_INVALID_SEM_VALUE; } - if (sem_init(&OS_impl_count_sem_table[sem_id].id, 0, sem_initial_value) < 0) + if (sem_init(&impl->id, 0, sem_initial_value) < 0) { return OS_SEM_FAILURE; } @@ -98,9 +103,13 @@ int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl(osal_index_t sem_id) +int32 OS_CountSemDelete_Impl(const OS_object_token_t *token) { - if (sem_destroy(&OS_impl_count_sem_table[sem_id].id) < 0) + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + + if (sem_destroy(&impl->id) < 0) { return OS_SEM_FAILURE; } @@ -117,9 +126,13 @@ int32 OS_CountSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl(osal_index_t sem_id) +int32 OS_CountSemGive_Impl(const OS_object_token_t *token) { - if (sem_post(&OS_impl_count_sem_table[sem_id].id) < 0) + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + + if (sem_post(&impl->id) < 0) { return OS_SEM_FAILURE; } @@ -136,9 +149,13 @@ int32 OS_CountSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl(osal_index_t sem_id) +int32 OS_CountSemTake_Impl(const OS_object_token_t *token) { - if (sem_wait(&OS_impl_count_sem_table[sem_id].id) < 0) + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + + if (sem_wait(&impl->id) < 0) { return OS_SEM_FAILURE; } @@ -154,17 +171,20 @@ int32 OS_CountSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) +int32 OS_CountSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) { - struct timespec ts; - int result; + struct timespec ts; + int result; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); /* ** Compute an absolute time for the delay */ OS_Posix_CompAbsDelayTime(msecs, &ts); - if (sem_timedwait(&OS_impl_count_sem_table[sem_id].id, &ts) == 0) + if (sem_timedwait(&impl->id, &ts) == 0) { result = OS_SUCCESS; } @@ -189,11 +209,14 @@ int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl(osal_index_t sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo_Impl(const OS_object_token_t *token, OS_count_sem_prop_t *count_prop) { - int sval; + int sval; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); - if (sem_getvalue(&OS_impl_count_sem_table[sem_id].id, &sval) < 0) + if (sem_getvalue(&impl->id, &sval) < 0) { return OS_SEM_FAILURE; } diff --git a/src/os/posix/src/os-impl-filesys.c b/src/os/posix/src/os-impl-filesys.c index 6e71e3321..4213b39ad 100644 --- a/src/os/posix/src/os-impl-filesys.c +++ b/src/os/posix/src/os-impl-filesys.c @@ -44,6 +44,7 @@ #include "os-posix.h" #include "os-shared-filesys.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -82,9 +83,9 @@ int32 OS_Posix_FileSysAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; struct stat stat_buf; const char * tmpdir; uint32 i; @@ -97,6 +98,8 @@ int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) VOLATILE_DISK_LOC_MAX }; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + /* * Determine basic type of filesystem, if not already known */ @@ -184,7 +187,7 @@ int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysStopVolume_Impl(const OS_object_token_t *token) { /* * This is a no-op. @@ -207,7 +210,7 @@ int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysFormatVolume_Impl(const OS_object_token_t *token) { /* * In theory, this should wipe any existing files in the ramdisk, @@ -230,11 +233,13 @@ int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysMountVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; struct stat stat_buf; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + /* * This will do a mkdir() for the mount point if it does * not already exist. @@ -282,7 +287,7 @@ int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysUnmountVolume_Impl(const OS_object_token_t *token) { /* * NOTE: Mounting/Unmounting on POSIX is not implemented. @@ -303,11 +308,13 @@ int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(const OS_object_token_t *token, OS_statvfs_t *result) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; struct statvfs stat_buf; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + if (statvfs(local->system_mountpt, &stat_buf) != 0) { return OS_ERROR; @@ -328,7 +335,7 @@ int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl(osal_index_t filesys_id, bool repair) +int32 OS_FileSysCheckVolume_Impl(const OS_object_token_t *token, bool repair) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_FileSysCheckVolume_Impl */ diff --git a/src/os/posix/src/os-impl-mutex.c b/src/os/posix/src/os-impl-mutex.c index 8d6de200a..5a0e43593 100644 --- a/src/os/posix/src/os-impl-mutex.c +++ b/src/os/posix/src/os-impl-mutex.c @@ -31,6 +31,7 @@ #include "os-posix.h" #include "os-shared-mutex.h" +#include "os-shared-idmap.h" #include "os-impl-mutex.h" /* Tables where the OS object information is stored */ @@ -61,10 +62,13 @@ int32 OS_Posix_MutexAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) +int32 OS_MutSemCreate_Impl(const OS_object_token_t *token, uint32 options) { - int return_code; - pthread_mutexattr_t mutex_attr; + int return_code; + pthread_mutexattr_t mutex_attr; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); /* ** initialize the attribute with default values @@ -72,8 +76,8 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) return_code = pthread_mutexattr_init(&mutex_attr); if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_init failed ID = %u: %s\n", (unsigned int)sem_id, - strerror(return_code)); + OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_init failed ID = %lu: %s\n", + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), strerror(return_code)); return OS_SEM_FAILURE; } @@ -83,8 +87,8 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) return_code = pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_setprotocol failed ID = %u: %s\n", - (unsigned int)sem_id, strerror(return_code)); + OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_setprotocol failed ID = %lu: %s\n", + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), strerror(return_code)); return OS_SEM_FAILURE; } @@ -94,8 +98,8 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) return_code = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_settype failed ID = %u: %s\n", - (unsigned int)sem_id, strerror(return_code)); + OS_DEBUG("Error: Mutex could not be created. pthread_mutexattr_settype failed ID = %lu: %s\n", + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), strerror(return_code)); return OS_SEM_FAILURE; } @@ -103,10 +107,11 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) ** create the mutex ** upon successful initialization, the state of the mutex becomes initialized and unlocked */ - return_code = pthread_mutex_init(&OS_impl_mutex_table[sem_id].id, &mutex_attr); + return_code = pthread_mutex_init(&impl->id, &mutex_attr); if (return_code != 0) { - OS_DEBUG("Error: Mutex could not be created. ID = %u: %s\n", (unsigned int)sem_id, strerror(return_code)); + OS_DEBUG("Error: Mutex could not be created. ID = %lu: %s\n", OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), + strerror(return_code)); return OS_SEM_FAILURE; } @@ -121,11 +126,14 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl(osal_index_t sem_id) +int32 OS_MutSemDelete_Impl(const OS_object_token_t *token) { - int status; + int status; + OS_impl_mutex_internal_record_t *impl; - status = pthread_mutex_destroy(&(OS_impl_mutex_table[sem_id].id)); /* 0 = success */ + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); + + status = pthread_mutex_destroy(&(impl->id)); /* 0 = success */ if (status != 0) { @@ -144,14 +152,17 @@ int32 OS_MutSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl(osal_index_t sem_id) +int32 OS_MutSemGive_Impl(const OS_object_token_t *token) { - int status; + int status; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); /* ** Unlock the mutex */ - status = pthread_mutex_unlock(&(OS_impl_mutex_table[sem_id].id)); + status = pthread_mutex_unlock(&(impl->id)); if (status != 0) { return OS_SEM_FAILURE; @@ -168,14 +179,17 @@ int32 OS_MutSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl(osal_index_t sem_id) +int32 OS_MutSemTake_Impl(const OS_object_token_t *token) { - int status; + int status; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); /* ** Lock the mutex */ - status = pthread_mutex_lock(&(OS_impl_mutex_table[sem_id].id)); + status = pthread_mutex_lock(&(impl->id)); if (status != 0) { return OS_SEM_FAILURE; @@ -192,7 +206,7 @@ int32 OS_MutSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl(osal_index_t sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo_Impl(const OS_object_token_t *token, OS_mut_sem_prop_t *mut_prop) { return OS_SUCCESS; diff --git a/src/os/posix/src/os-impl-queues.c b/src/os/posix/src/os-impl-queues.c index 913d0773b..87ce7e935 100644 --- a/src/os/posix/src/os-impl-queues.c +++ b/src/os/posix/src/os-impl-queues.c @@ -81,17 +81,22 @@ int32 OS_Posix_QueueAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) +int32 OS_QueueCreate_Impl(const OS_object_token_t *token, uint32 flags) { - int return_code; - mqd_t queueDesc; - struct mq_attr queueAttr; - char name[OS_MAX_API_NAME * 2]; + int return_code; + mqd_t queueDesc; + struct mq_attr queueAttr; + char name[OS_MAX_API_NAME * 2]; + OS_impl_queue_internal_record_t *impl; + OS_queue_internal_record_t * queue; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); + queue = OS_OBJECT_TABLE_GET(OS_queue_table, *token); /* set queue attributes */ memset(&queueAttr, 0, sizeof(queueAttr)); - queueAttr.mq_maxmsg = OS_queue_table[queue_id].max_depth; - queueAttr.mq_msgsize = OS_queue_table[queue_id].max_size; + queueAttr.mq_maxmsg = queue->max_depth; + queueAttr.mq_msgsize = queue->max_size; /* * The "TruncateQueueDepth" indicates a soft limit to the size of a queue. @@ -107,7 +112,7 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) ** Construct the queue name: ** The name will consist of "/.queue_name" */ - snprintf(name, sizeof(name), "/%d.%s", (int)getpid(), OS_global_queue_table[queue_id].name_entry); + snprintf(name, sizeof(name), "/%d.%s", (int)getpid(), queue->queue_name); /* ** create message queue @@ -128,8 +133,8 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) } else { - OS_impl_queue_table[queue_id].id = queueDesc; - return_code = OS_SUCCESS; + impl->id = queueDesc; + return_code = OS_SUCCESS; /* * Unlink the queue right now -- @@ -159,12 +164,15 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl(osal_index_t queue_id) +int32 OS_QueueDelete_Impl(const OS_object_token_t *token) { - int32 return_code; + int32 return_code; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); /* Try to delete and unlink the queue */ - if (mq_close(OS_impl_queue_table[queue_id].id) != 0) + if (mq_close(impl->id) != 0) { OS_DEBUG("OS_QueueDelete Error during mq_close(). errno = %d (%s)\n", errno, strerror(errno)); return_code = OS_ERROR; @@ -185,11 +193,14 @@ int32 OS_QueueDelete_Impl(osal_index_t queue_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *size_copied, int32 timeout) +int32 OS_QueueGet_Impl(const OS_object_token_t *token, void *data, size_t size, size_t *size_copied, int32 timeout) { - int32 return_code; - ssize_t sizeCopied; - struct timespec ts; + int32 return_code; + ssize_t sizeCopied; + struct timespec ts; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); /* ** Read the message queue for data @@ -203,7 +214,7 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *s */ do { - sizeCopied = mq_receive(OS_impl_queue_table[queue_id].id, data, size, NULL); + sizeCopied = mq_receive(impl->id, data, size, NULL); } while (sizeCopied < 0 && errno == EINTR); } else @@ -232,7 +243,7 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *s */ do { - sizeCopied = mq_timedreceive(OS_impl_queue_table[queue_id].id, data, size, NULL, &ts); + sizeCopied = mq_timedreceive(impl->id, data, size, NULL, &ts); } while (timeout != OS_CHECK && sizeCopied < 0 && errno == EINTR); } /* END timeout */ @@ -281,11 +292,14 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *s * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, size_t size, uint32 flags) +int32 OS_QueuePut_Impl(const OS_object_token_t *token, const void *data, size_t size, uint32 flags) { - int32 return_code; - int result; - struct timespec ts; + int32 return_code; + int result; + struct timespec ts; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); /* * NOTE - using a zero timeout here for the same reason that QueueGet does --- @@ -298,7 +312,7 @@ int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, size_t size, uin /* send message */ do { - result = mq_timedsend(OS_impl_queue_table[queue_id].id, data, size, 1, &ts); + result = mq_timedsend(impl->id, data, size, 1, &ts); } while (result == -1 && errno == EINTR); if (result == 0) diff --git a/src/os/posix/src/os-impl-shell.c b/src/os/posix/src/os-impl-shell.c index e85654380..445ae4d38 100644 --- a/src/os/posix/src/os-impl-shell.c +++ b/src/os/posix/src/os-impl-shell.c @@ -57,12 +57,15 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(osal_index_t file_id, const char *Cmd) +int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd) { - pid_t cpid; - uint32 local_id; - int wstat; - const char *shell = getenv("SHELL"); + pid_t cpid; + uint32 local_id; + int wstat; + const char * shell = getenv("SHELL"); + OS_impl_file_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); if (shell == NULL) { @@ -79,8 +82,8 @@ int32 OS_ShellOutputToFile_Impl(osal_index_t file_id, const char *Cmd) if (cpid == 0) { /* child process */ - dup2(OS_impl_filehandle_table[file_id].fd, STDOUT_FILENO); - dup2(OS_impl_filehandle_table[file_id].fd, STDERR_FILENO); + dup2(impl->fd, STDOUT_FILENO); + dup2(impl->fd, STDERR_FILENO); /* close all _other_ filehandles */ for (local_id = 0; local_id < OS_MAX_NUM_OPEN_FILES; ++local_id) diff --git a/src/os/posix/src/os-impl-tasks.c b/src/os/posix/src/os-impl-tasks.c index a529264ee..cb94efcc5 100644 --- a/src/os/posix/src/os-impl-tasks.c +++ b/src/os/posix/src/os-impl-tasks.c @@ -564,17 +564,21 @@ int32 OS_Posix_InternalTaskCreate_Impl(pthread_t *pthr, osal_priority_t priority * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) +int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags) { - OS_U32ValueWrapper_t arg; - int32 return_code; + OS_U32ValueWrapper_t arg; + int32 return_code; + OS_impl_task_internal_record_t *impl; + OS_task_internal_record_t * task; arg.opaque_arg = NULL; - arg.id = OS_global_task_table[task_id].active_id; + arg.id = OS_ObjectIdFromToken(token); + + task = OS_OBJECT_TABLE_GET(OS_task_table, *token); + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); - return_code = - OS_Posix_InternalTaskCreate_Impl(&OS_impl_task_table[task_id].id, OS_task_table[task_id].priority, - OS_task_table[task_id].stack_size, OS_PthreadTaskEntry, arg.opaque_arg); + return_code = OS_Posix_InternalTaskCreate_Impl(&impl->id, task->priority, task->stack_size, OS_PthreadTaskEntry, + arg.opaque_arg); return return_code; } /* end OS_TaskCreate_Impl */ @@ -587,9 +591,13 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskMatch_Impl(osal_index_t task_id) +int32 OS_TaskMatch_Impl(const OS_object_token_t *token) { - if (pthread_equal(pthread_self(), OS_impl_task_table[task_id].id) == 0) + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + + if (pthread_equal(pthread_self(), impl->id) == 0) { return OS_ERROR; } @@ -605,15 +613,19 @@ int32 OS_TaskMatch_Impl(osal_index_t task_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl(osal_index_t task_id) +int32 OS_TaskDelete_Impl(const OS_object_token_t *token) { + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + /* ** Try to delete the task ** If this fails, not much recourse - the only potential cause of failure ** to cancel here is that the thread ID is invalid because it already exited itself, ** and if that is true there is nothing wrong - everything is OK to continue normally. */ - pthread_cancel(OS_impl_task_table[task_id].id); + pthread_cancel(impl->id); return OS_SUCCESS; } /* end OS_TaskDelete_Impl */ @@ -678,11 +690,15 @@ int32 OS_TaskDelay_Impl(uint32 millisecond) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority) +int32 OS_TaskSetPriority_Impl(const OS_object_token_t *token, osal_priority_t new_priority) { int os_priority; int ret; + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + if (POSIX_GlobalVars.EnableTaskPriorities) { /* Change OSAL priority into a priority that will work for this OS */ @@ -691,11 +707,11 @@ int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority /* ** Set priority */ - ret = pthread_setschedprio(OS_impl_task_table[task_id].id, os_priority); + ret = pthread_setschedprio(impl->id, os_priority); if (ret != 0) { - OS_DEBUG("pthread_setschedprio: Task ID = %u, prio = %d, err = %s\n", (unsigned int)task_id, os_priority, - strerror(ret)); + OS_DEBUG("pthread_setschedprio: Task ID = %lu, prio = %d, err = %s\n", + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), os_priority, strerror(ret)); return (OS_ERROR); } } @@ -758,7 +774,7 @@ osal_id_t OS_TaskGetId_Impl(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl(osal_index_t task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo_Impl(const OS_object_token_t *token, OS_task_prop_t *task_prop) { return OS_SUCCESS; } /* end OS_TaskGetInfo_Impl */ @@ -771,11 +787,14 @@ int32 OS_TaskGetInfo_Impl(osal_index_t task_id, OS_task_prop_t *task_prop) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -bool OS_TaskIdMatchSystemData_Impl(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_TaskIdMatchSystemData_Impl(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { - const pthread_t *target = (const pthread_t *)ref; + const pthread_t * target = (const pthread_t *)ref; + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); - return (pthread_equal(*target, OS_impl_task_table[local_id].id) != 0); + return (pthread_equal(*target, impl->id) != 0); } /*---------------------------------------------------------------- diff --git a/src/os/posix/src/os-impl-timebase.c b/src/os/posix/src/os-impl-timebase.c index a618435ac..bbd177bc4 100644 --- a/src/os/posix/src/os-impl-timebase.c +++ b/src/os/posix/src/os-impl-timebase.c @@ -108,9 +108,13 @@ static void OS_UsecToTimespec(uint32 usecs, struct timespec *time_spec) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_TimeBaseLock_Impl(osal_index_t local_id) +void OS_TimeBaseLock_Impl(const OS_object_token_t *token) { - pthread_mutex_lock(&OS_impl_timebase_table[local_id].handler_mutex); + OS_impl_timebase_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + + pthread_mutex_lock(&impl->handler_mutex); } /* end OS_TimeBaseLock_Impl */ /*---------------------------------------------------------------- @@ -121,9 +125,13 @@ void OS_TimeBaseLock_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_TimeBaseUnlock_Impl(osal_index_t local_id) +void OS_TimeBaseUnlock_Impl(const OS_object_token_t *token) { - pthread_mutex_unlock(&OS_impl_timebase_table[local_id].handler_mutex); + OS_impl_timebase_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + + pthread_mutex_unlock(&impl->handler_mutex); } /* end OS_TimeBaseUnlock_Impl */ /*---------------------------------------------------------------- @@ -286,8 +294,8 @@ int32 OS_Posix_TimeBaseAPI_Impl_Init(void) * - This is used internally for reporting accuracy, * - TicksPerSecond values over 2M will return zero */ - OS_SharedGlobalVars.MicroSecPerTick = - (1000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / OS_SharedGlobalVars.TicksPerSecond; + OS_SharedGlobalVars.MicroSecPerTick = (1000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / + OS_SharedGlobalVars.TicksPerSecond; } while (0); return (return_code); @@ -314,7 +322,7 @@ static void *OS_TimeBasePthreadEntry(void *arg) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) +int32 OS_TimeBaseCreate_Impl(const OS_object_token_t *token) { int32 return_code; int status; @@ -323,11 +331,11 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) struct sigevent evp; struct timespec ts; OS_impl_timebase_internal_record_t *local; - OS_common_record_t * global; + OS_timebase_internal_record_t * timebase; OS_U32ValueWrapper_t arg; - local = &OS_impl_timebase_table[timer_id]; - global = &OS_global_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, *token); /* * Spawn a dedicated time base handler thread @@ -340,7 +348,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * the global table lock. */ arg.opaque_arg = NULL; - arg.id = global->active_id; + arg.id = OS_ObjectIdFromToken(token); return_code = OS_Posix_InternalTaskCreate_Impl(&local->handler_thread, OSAL_PRIORITY_C(0), 0, OS_TimeBasePthreadEntry, arg.opaque_arg); if (return_code != OS_SUCCESS) @@ -360,7 +368,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * If no external sync function is provided then this will set up a POSIX * timer to locally simulate the timer tick using the CPU clock. */ - if (OS_timebase_table[timer_id].external_sync == NULL) + if (timebase->external_sync == NULL) { sigemptyset(&local->sigset); @@ -371,7 +379,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) */ for (idx = 0; idx < OS_MAX_TIMEBASES; ++idx) { - if (idx != timer_id && OS_ObjectIdDefined(OS_global_timebase_table[idx].active_id) && + if (OS_ObjectIdDefined(OS_global_timebase_table[idx].active_id) && OS_impl_timebase_table[idx].assigned_signal != 0) { sigaddset(&local->sigset, OS_impl_timebase_table[idx].assigned_signal); @@ -439,7 +447,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * and doing it this way should still work on a system where sizeof(sival_int) < sizeof(uint32) * (as long as sizeof(sival_int) >= number of bits in OS_OBJECT_INDEX_MASK) */ - evp.sigev_value.sival_int = (int)OS_ObjectIdToSerialNumber_Impl(global->active_id); + evp.sigev_value.sival_int = (int)OS_ObjectIdToSerialNumber_Impl(OS_ObjectIdFromToken(token)); /* ** Create the timer @@ -453,7 +461,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) break; } - OS_timebase_table[timer_id].external_sync = OS_TimeBase_SigWaitImpl; + timebase->external_sync = OS_TimeBase_SigWaitImpl; } while (0); } @@ -480,14 +488,16 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 interval_time) +int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uint32 interval_time) { OS_impl_timebase_internal_record_t *local; struct itimerspec timeout; int32 return_code; int status; + OS_timebase_internal_record_t * timebase; - local = &OS_impl_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, *token); return_code = OS_SUCCESS; /* There is only something to do here if we are generating a simulated tick */ @@ -514,11 +524,11 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter } else if (interval_time > 0) { - OS_timebase_table[timer_id].accuracy_usec = (uint32)((timeout.it_interval.tv_nsec + 999) / 1000); + timebase->accuracy_usec = (uint32)((timeout.it_interval.tv_nsec + 999) / 1000); } else { - OS_timebase_table[timer_id].accuracy_usec = (uint32)((timeout.it_value.tv_nsec + 999) / 1000); + timebase->accuracy_usec = (uint32)((timeout.it_value.tv_nsec + 999) / 1000); } } @@ -534,12 +544,12 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) +int32 OS_TimeBaseDelete_Impl(const OS_object_token_t *token) { OS_impl_timebase_internal_record_t *local; int status; - local = &OS_impl_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); pthread_cancel(local->handler_thread); @@ -548,7 +558,7 @@ int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) */ if (local->assigned_signal != 0) { - status = timer_delete(OS_impl_timebase_table[timer_id].host_timerid); + status = timer_delete(local->host_timerid); if (status < 0) { OS_DEBUG("Error deleting timer: %s\n", strerror(errno)); @@ -569,7 +579,7 @@ int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl(osal_index_t timer_id, OS_timebase_prop_t *timer_prop) +int32 OS_TimeBaseGetInfo_Impl(const OS_object_token_t *token, OS_timebase_prop_t *timer_prop) { return OS_SUCCESS; diff --git a/src/os/rtems/inc/os-impl-io.h b/src/os/rtems/inc/os-impl-io.h index 9fc1893c1..78a9e3ca5 100644 --- a/src/os/rtems/inc/os-impl-io.h +++ b/src/os/rtems/inc/os-impl-io.h @@ -36,7 +36,7 @@ typedef struct { int fd; bool selectable; -} OS_Rtems_filehandle_entry_t; +} OS_impl_file_internal_record_t; /* * The global file handle table. @@ -44,6 +44,6 @@ typedef struct * This table is shared across multiple units (files, sockets, etc) and they will share * the same file handle table from the basic file I/O. */ -extern OS_Rtems_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; +extern OS_impl_file_internal_record_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; #endif /* INCLUDE_OS_IMPL_IO_H_ */ diff --git a/src/os/rtems/src/os-impl-binsem.c b/src/os/rtems/src/os-impl-binsem.c index d3a8933bf..8d15204fa 100644 --- a/src/os/rtems/src/os-impl-binsem.c +++ b/src/os/rtems/src/os-impl-binsem.c @@ -87,17 +87,20 @@ int32 OS_Rtems_BinSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_BinSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options) { - rtems_status_code status; - rtems_name r_name; + rtems_status_code status; + rtems_name r_name; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); /* ** RTEMS task names are 4 byte integers. ** It is convenient to use the OSAL ID in here, as we know it is already unique ** and trying to use the real name would be less than useful (only 4 chars) */ - r_name = OS_ObjectIdToInteger(OS_global_bin_sem_table[sem_id].active_id); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); /* Check to make sure the sem value is going to be either 0 or 1 */ if (sem_initial_value > 1) @@ -106,8 +109,7 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 } /* Create RTEMS Semaphore */ - status = rtems_semaphore_create(r_name, sem_initial_value, OSAL_BINARY_SEM_ATTRIBS, 0, - &(OS_impl_bin_sem_table[sem_id].id)); + status = rtems_semaphore_create(r_name, sem_initial_value, OSAL_BINARY_SEM_ATTRIBS, 0, &(impl->id)); /* check if Create failed */ if (status != RTEMS_SUCCESSFUL) @@ -128,11 +130,14 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl(osal_index_t sem_id) +int32 OS_BinSemDelete_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); - status = rtems_semaphore_delete(OS_impl_bin_sem_table[sem_id].id); + status = rtems_semaphore_delete(impl->id); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled semaphore_delete error: %s\n", rtems_status_text(status)); @@ -151,11 +156,14 @@ int32 OS_BinSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl(osal_index_t sem_id) +int32 OS_BinSemGive_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); - status = rtems_semaphore_release(OS_impl_bin_sem_table[sem_id].id); + status = rtems_semaphore_release(impl->id); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled semaphore_release error: %s\n", rtems_status_text(status)); @@ -173,12 +181,15 @@ int32 OS_BinSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl(osal_index_t sem_id) +int32 OS_BinSemFlush_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); /* Give Semaphore */ - status = rtems_semaphore_flush(OS_impl_bin_sem_table[sem_id].id); + status = rtems_semaphore_flush(impl->id); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled semaphore_flush error: %s\n", rtems_status_text(status)); @@ -197,11 +208,14 @@ int32 OS_BinSemFlush_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl(osal_index_t sem_id) +int32 OS_BinSemTake_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); - status = rtems_semaphore_obtain(OS_impl_bin_sem_table[sem_id].id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); /* ** If the semaphore is flushed, this function will return ** RTEMS_UNSATISFIED. If this happens, the OSAL does not want to return @@ -228,17 +242,20 @@ int32 OS_BinSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) +int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) { - rtems_status_code status; - int TimeInTicks; + rtems_status_code status; + int TimeInTicks; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); if (OS_Milli2Ticks(msecs, &TimeInTicks) != OS_SUCCESS) { return OS_ERROR; } - status = rtems_semaphore_obtain(OS_impl_bin_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks); + status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, TimeInTicks); if (status == RTEMS_TIMEOUT) { @@ -264,7 +281,7 @@ int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(osal_index_t sem_id, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) { /* RTEMS has no API for obtaining the current value of a semaphore */ return OS_SUCCESS; diff --git a/src/os/rtems/src/os-impl-console.c b/src/os/rtems/src/os-impl-console.c index 7bad84748..ba0f2534a 100644 --- a/src/os/rtems/src/os-impl-console.c +++ b/src/os/rtems/src/os-impl-console.c @@ -86,9 +86,11 @@ OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(osal_index_t local_id) +void OS_ConsoleWakeup_Impl(const OS_object_token_t *token) { - OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; + OS_impl_console_internal_record_t *local; + + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, *token); if (local->is_async) { @@ -98,7 +100,7 @@ void OS_ConsoleWakeup_Impl(osal_index_t local_id) else { /* output directly */ - OS_ConsoleOutput_Impl(local_id); + OS_ConsoleOutput_Impl(token); } } /* end OS_ConsoleWakeup_Impl */ @@ -111,14 +113,19 @@ void OS_ConsoleWakeup_Impl(osal_index_t local_id) *-----------------------------------------------------------------*/ static void OS_ConsoleTask_Entry(rtems_task_argument arg) { - uint32 local_id = arg; + OS_object_token_t token; OS_impl_console_internal_record_t *local; - local = &OS_impl_console_table[local_id]; - while (true) + if (OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_CONSOLE, OS_ObjectIdFromInteger(arg), &token) == + OS_SUCCESS) { - OS_ConsoleOutput_Impl(local_id); - rtems_semaphore_obtain(local->data_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token); + while (true) + { + OS_ConsoleOutput_Impl(&token); + rtems_semaphore_obtain(local->data_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + } + OS_ObjectIdRelease(&token); } } /* end OS_ConsoleTask_Entry */ @@ -130,15 +137,17 @@ static void OS_ConsoleTask_Entry(rtems_task_argument arg) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ConsoleCreate_Impl(osal_index_t local_id) +int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token) { - OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; + OS_impl_console_internal_record_t *local; int32 return_code; rtems_name r_name; rtems_id r_task_id; rtems_status_code status; - if (local_id == 0) + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, *token); + + if (OS_ObjectIndexFromToken(token) == 0) { return_code = OS_SUCCESS; local->is_async = OS_CONSOLE_ASYNC; @@ -152,7 +161,7 @@ int32 OS_ConsoleCreate_Impl(osal_index_t local_id) ** It is convenient to use the OSAL ID in here, as we know it is already unique ** and trying to use the real name would be less than useful (only 4 chars) */ - r_name = OS_ObjectIdToInteger(OS_global_console_table[local_id].active_id); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); status = rtems_semaphore_create(r_name, 0, RTEMS_PRIORITY, 0, &local->data_sem); if (status != RTEMS_SUCCESSFUL) { @@ -175,9 +184,9 @@ int32 OS_ConsoleCreate_Impl(osal_index_t local_id) else { /* will place the task in 'ready for scheduling' state */ - status = rtems_task_start(r_task_id, /*rtems task id*/ - OS_ConsoleTask_Entry, /* task entry point */ - (rtems_task_argument)local_id); /* passed argument */ + status = rtems_task_start(r_task_id, /*rtems task id*/ + OS_ConsoleTask_Entry, /* task entry point */ + (rtems_task_argument)r_name); /* passed argument */ if (status != RTEMS_SUCCESSFUL) { diff --git a/src/os/rtems/src/os-impl-countsem.c b/src/os/rtems/src/os-impl-countsem.c index 11c294918..33b1719b6 100644 --- a/src/os/rtems/src/os-impl-countsem.c +++ b/src/os/rtems/src/os-impl-countsem.c @@ -84,10 +84,13 @@ int32 OS_Rtems_CountSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options) { - rtems_status_code status; - rtems_name r_name; + rtems_status_code status; + rtems_name r_name; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); /* ** Verify that the semaphore maximum value is not too high @@ -102,9 +105,8 @@ int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint ** It is convenient to use the OSAL ID in here, as we know it is already unique ** and trying to use the real name would be less than useful (only 4 chars) */ - r_name = OS_ObjectIdToInteger(OS_global_count_sem_table[sem_id].active_id); - status = rtems_semaphore_create(r_name, sem_initial_value, OSAL_COUNT_SEM_ATTRIBS, 0, - &(OS_impl_count_sem_table[sem_id].id)); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); + status = rtems_semaphore_create(r_name, sem_initial_value, OSAL_COUNT_SEM_ATTRIBS, 0, &(impl->id)); /* check if Create failed */ if (status != RTEMS_SUCCESSFUL) @@ -125,11 +127,14 @@ int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl(osal_index_t sem_id) +int32 OS_CountSemDelete_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); - status = rtems_semaphore_delete(OS_impl_count_sem_table[sem_id].id); + status = rtems_semaphore_delete(impl->id); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled semaphore_delete error: %s\n", rtems_status_text(status)); @@ -148,11 +153,14 @@ int32 OS_CountSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl(osal_index_t sem_id) +int32 OS_CountSemGive_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); - status = rtems_semaphore_release(OS_impl_count_sem_table[sem_id].id); + status = rtems_semaphore_release(impl->id); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled semaphore_release error: %s\n", rtems_status_text(status)); @@ -171,11 +179,14 @@ int32 OS_CountSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl(osal_index_t sem_id) +int32 OS_CountSemTake_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_countsem_internal_record_t *impl; - status = rtems_semaphore_obtain(OS_impl_count_sem_table[sem_id].id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + + status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled semaphore_obtain error: %s\n", rtems_status_text(status)); @@ -194,17 +205,20 @@ int32 OS_CountSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) +int32 OS_CountSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) { - rtems_status_code status; - int TimeInTicks; + rtems_status_code status; + int TimeInTicks; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); if (OS_Milli2Ticks(msecs, &TimeInTicks) != OS_SUCCESS) { return OS_ERROR; } - status = rtems_semaphore_obtain(OS_impl_count_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks); + status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, TimeInTicks); if (status == RTEMS_TIMEOUT) { return OS_SEM_TIMEOUT; @@ -228,7 +242,7 @@ int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl(osal_index_t sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo_Impl(const OS_object_token_t *token, OS_count_sem_prop_t *count_prop) { /* RTEMS does not provide an API to get the value */ return OS_SUCCESS; diff --git a/src/os/rtems/src/os-impl-files.c b/src/os/rtems/src/os-impl-files.c index d82de88fe..48e76807d 100644 --- a/src/os/rtems/src/os-impl-files.c +++ b/src/os/rtems/src/os-impl-files.c @@ -47,7 +47,7 @@ * This is shared by all OSAL entities that perform low-level I/O. */ /* The file/stream table is referenced by multiple entities, i.e. sockets, select, etc */ -OS_Rtems_filehandle_entry_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; +OS_impl_file_internal_record_t OS_impl_filehandle_table[OS_MAX_NUM_OPEN_FILES]; /**************************************************************************************** IMPLEMENTATION-SPECIFIC ROUTINES diff --git a/src/os/rtems/src/os-impl-filesys.c b/src/os/rtems/src/os-impl-filesys.c index 3583303c7..4bdea8453 100644 --- a/src/os/rtems/src/os-impl-filesys.c +++ b/src/os/rtems/src/os-impl-filesys.c @@ -104,13 +104,16 @@ int32 OS_Rtems_FileSysAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_filesys_internal_record_t * local; + OS_impl_filesys_internal_record_t *impl; rtems_status_code sc; int32 return_code; + impl = OS_OBJECT_TABLE_GET(OS_impl_filesys_table, *token); + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + return_code = OS_ERR_NOT_IMPLEMENTED; memset(impl, 0, sizeof(*impl)); @@ -161,7 +164,7 @@ int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) impl->mount_fstype = RTEMS_FILESYSTEM_TYPE_RFS; impl->mount_options = RTEMS_FILESYSTEM_READ_WRITE; snprintf(impl->blockdev_name, sizeof(impl->blockdev_name), "%s%c", RAMDISK_DEVICE_BASE_NAME, - (int)filesys_id + 'a'); + (int)OS_ObjectIndexFromToken(token) + 'a'); sc = rtems_blkdev_create(impl->blockdev_name, local->blocksize, local->numblocks, ramdisk_ioctl, impl->allocated_disk); @@ -205,9 +208,11 @@ int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysStopVolume_Impl(const OS_object_token_t *token) { - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_impl_filesys_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filesys_table, *token); /* * If this was a dynamically allocated disk, then unlink it. @@ -229,14 +234,17 @@ int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysFormatVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_filesys_internal_record_t * local; + OS_impl_filesys_internal_record_t *impl; rtems_rfs_format_config config; int32 return_code; int sc; + impl = OS_OBJECT_TABLE_GET(OS_impl_filesys_table, *token); + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + return_code = OS_ERR_NOT_IMPLEMENTED; switch (local->fstype) @@ -291,12 +299,15 @@ int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysMountVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_filesys_internal_record_t * local; + OS_impl_filesys_internal_record_t *impl; struct stat stat_buf; + impl = OS_OBJECT_TABLE_GET(OS_impl_filesys_table, *token); + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + /* * This will do a mkdir() for the mount point if it does * not already exist. @@ -345,9 +356,11 @@ int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysUnmountVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; + + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); if (local->fstype == OS_FILESYS_TYPE_VOLATILE_DISK || local->fstype == OS_FILESYS_TYPE_NORMAL_DISK) { @@ -373,12 +386,14 @@ int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(const OS_object_token_t *token, OS_statvfs_t *result) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; struct statvfs stat_buf; int32 return_code; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + if (statvfs(local->system_mountpt, &stat_buf) != 0) { /* @@ -415,7 +430,7 @@ int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl(osal_index_t filesys_id, bool repair) +int32 OS_FileSysCheckVolume_Impl(const OS_object_token_t *token, bool repair) { return OS_ERR_NOT_IMPLEMENTED; } /* end OS_FileSysCheckVolume_Impl */ diff --git a/src/os/rtems/src/os-impl-loader.c b/src/os/rtems/src/os-impl-loader.c index f3f1fb1d8..40278f27e 100644 --- a/src/os/rtems/src/os-impl-loader.c +++ b/src/os/rtems/src/os-impl-loader.c @@ -34,6 +34,7 @@ #include "os-rtems.h" #include "os-impl-loader.h" #include "os-shared-module.h" +#include "os-shared-idmap.h" /**************************************************************************************** GLOBAL DATA @@ -104,11 +105,14 @@ static bool OS_rtems_rtl_check_unresolved(rtems_rtl_unresolv_rec_t *rec, void *d * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) +int32 OS_ModuleLoad_Impl(const OS_object_token_t *token, const char *translated_path) { - int32 status = OS_ERROR; - int unresolved; - void *dl_handle; + int32 status = OS_ERROR; + int unresolved; + void * dl_handle; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); dlerror(); dl_handle = dlopen(translated_path, RTLD_NOW | RTLD_GLOBAL); @@ -152,7 +156,7 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) if (status == OS_SUCCESS) { /* success: save for future use */ - OS_impl_module_table[module_id].dl_handle = dl_handle; + impl->dl_handle = dl_handle; } else if (dl_handle != NULL) { @@ -177,18 +181,21 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl(osal_index_t module_id) +int32 OS_ModuleUnload_Impl(const OS_object_token_t *token) { - int32 status = OS_ERROR; + int32 status = OS_ERROR; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); /* ** Attempt to close/unload the module */ dlerror(); - if (dlclose(OS_impl_module_table[module_id].dl_handle) == 0) + if (dlclose(impl->dl_handle) == 0) { - OS_impl_module_table[module_id].dl_handle = NULL; - status = OS_SUCCESS; + impl->dl_handle = NULL; + status = OS_SUCCESS; } else { @@ -207,7 +214,7 @@ int32 OS_ModuleUnload_Impl(osal_index_t module_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl(osal_index_t module_id, OS_module_prop_t *module_prop) +int32 OS_ModuleGetInfo_Impl(const OS_object_token_t *token, OS_module_prop_t *module_prop) { /* ** RTEMS does not specify a way to get these values diff --git a/src/os/rtems/src/os-impl-mutex.c b/src/os/rtems/src/os-impl-mutex.c index c02b95665..48874bdcc 100644 --- a/src/os/rtems/src/os-impl-mutex.c +++ b/src/os/rtems/src/os-impl-mutex.c @@ -85,16 +85,19 @@ int32 OS_Rtems_MutexAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) +int32 OS_MutSemCreate_Impl(const OS_object_token_t *token, uint32 options) { - rtems_status_code status; - rtems_name r_name; + rtems_status_code status; + rtems_name r_name; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); /* ** Try to create the mutex */ - r_name = OS_ObjectIdToInteger(OS_global_mutex_table[sem_id].active_id); - status = rtems_semaphore_create(r_name, 1, OSAL_MUTEX_ATTRIBS, 0, &OS_impl_mutex_table[sem_id].id); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); + status = rtems_semaphore_create(r_name, 1, OSAL_MUTEX_ATTRIBS, 0, &impl->id); if (status != RTEMS_SUCCESSFUL) { @@ -114,11 +117,14 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl(osal_index_t sem_id) +int32 OS_MutSemDelete_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); - status = rtems_semaphore_delete(OS_impl_mutex_table[sem_id].id); + status = rtems_semaphore_delete(impl->id); if (status != RTEMS_SUCCESSFUL) { /* clean up? */ @@ -138,12 +144,15 @@ int32 OS_MutSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl(osal_index_t sem_id) +int32 OS_MutSemGive_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); /* Give the mutex */ - status = rtems_semaphore_release(OS_impl_mutex_table[sem_id].id); + status = rtems_semaphore_release(impl->id); if (status != RTEMS_SUCCESSFUL) { @@ -163,11 +172,14 @@ int32 OS_MutSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl(osal_index_t sem_id) +int32 OS_MutSemTake_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_mutex_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); - status = rtems_semaphore_obtain(OS_impl_mutex_table[sem_id].id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (status != RTEMS_SUCCESSFUL) { @@ -187,7 +199,7 @@ int32 OS_MutSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl(osal_index_t sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo_Impl(const OS_object_token_t *token, OS_mut_sem_prop_t *mut_prop) { /* RTEMS provides no additional info */ return OS_SUCCESS; diff --git a/src/os/rtems/src/os-impl-queues.c b/src/os/rtems/src/os-impl-queues.c index f94385f5c..58e978ceb 100644 --- a/src/os/rtems/src/os-impl-queues.c +++ b/src/os/rtems/src/os-impl-queues.c @@ -78,17 +78,22 @@ int32 OS_Rtems_QueueAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) +int32 OS_QueueCreate_Impl(const OS_object_token_t *token, uint32 flags) { - rtems_status_code status; - rtems_name r_name; + rtems_status_code status; + rtems_name r_name; + OS_impl_queue_internal_record_t *impl; + OS_queue_internal_record_t * queue; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); + queue = OS_OBJECT_TABLE_GET(OS_queue_table, *token); /* ** RTEMS task names are 4 byte integers. ** It is convenient to use the OSAL queue ID in here, as we know it is already unique ** and trying to use the real queue name would be less than useful (only 4 chars) */ - r_name = OS_ObjectIdToInteger(OS_global_queue_table[queue_id].active_id); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); /* ** Create the message queue. @@ -96,12 +101,11 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) ** (RTEMS_FIFO or RTEMS_PRIORITY) is irrelevant since only one task waits ** on each queue. */ - status = rtems_message_queue_create( - r_name, /* 32-bit RTEMS object name; not used */ - OS_queue_table[queue_id].max_depth, /* maximum number of messages in queue (queue depth) */ - OS_queue_table[queue_id].max_size, /* maximum size in bytes of a message */ - RTEMS_FIFO | RTEMS_LOCAL, /* attributes (default) */ - &(OS_impl_queue_table[queue_id].id) /* object ID returned for queue */ + status = rtems_message_queue_create(r_name, /* 32-bit RTEMS object name; not used */ + queue->max_depth, /* maximum number of messages in queue (queue depth) */ + queue->max_size, /* maximum size in bytes of a message */ + RTEMS_FIFO | RTEMS_LOCAL, /* attributes (default) */ + &(impl->id) /* object ID returned for queue */ ); /* @@ -125,12 +129,15 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl(osal_index_t queue_id) +int32 OS_QueueDelete_Impl(const OS_object_token_t *token) { - rtems_status_code status; + rtems_status_code status; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); /* Try to delete the queue */ - status = rtems_message_queue_delete(OS_impl_queue_table[queue_id].id); + status = rtems_message_queue_delete(impl->id); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled queue_delete error: %s\n", rtems_status_text(status)); @@ -149,17 +156,20 @@ int32 OS_QueueDelete_Impl(osal_index_t queue_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) +int32 OS_QueueGet_Impl(const OS_object_token_t *token, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - int32 return_code; - rtems_status_code status; - rtems_interval ticks; - int tick_count; - rtems_option option_set; - size_t rtems_size; - rtems_id rtems_queue_id; + int32 return_code; + rtems_status_code status; + rtems_interval ticks; + int tick_count; + rtems_option option_set; + size_t rtems_size; + rtems_id rtems_queue_id; + OS_impl_queue_internal_record_t *impl; - rtems_queue_id = OS_impl_queue_table[queue_id].id; + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); + + rtems_queue_id = impl->id; /* Get Message From Message Queue */ if (timeout == OS_PEND) @@ -243,12 +253,15 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, uint32 size, uint32 *s * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, uint32 size, uint32 flags) +int32 OS_QueuePut_Impl(const OS_object_token_t *token, const void *data, uint32 size, uint32 flags) { - rtems_status_code status; - rtems_id rtems_queue_id; + rtems_status_code status; + rtems_id rtems_queue_id; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); - rtems_queue_id = OS_impl_queue_table[queue_id].id; + rtems_queue_id = impl->id; /* Write the buffer pointer to the queue. If an error occurred, report it ** with the corresponding SB status code. @@ -287,7 +300,7 @@ int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, uint32 size, uin * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGetInfo_Impl(osal_index_t queue_id, OS_queue_prop_t *queue_prop) +int32 OS_QueueGetInfo_Impl(const OS_object_token_t *token, OS_queue_prop_t *queue_prop) { /* No extra info for queues in the OS implementation */ return OS_SUCCESS; diff --git a/src/os/rtems/src/os-impl-tasks.c b/src/os/rtems/src/os-impl-tasks.c index cc278e422..a9db8a73b 100644 --- a/src/os/rtems/src/os-impl-tasks.c +++ b/src/os/rtems/src/os-impl-tasks.c @@ -90,19 +90,24 @@ int32 OS_Rtems_TaskAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) +int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags) { - rtems_status_code status; - rtems_name r_name; - rtems_mode r_mode; - rtems_attribute r_attributes; + rtems_status_code status; + rtems_name r_name; + rtems_mode r_mode; + rtems_attribute r_attributes; + OS_impl_task_internal_record_t *impl; + OS_task_internal_record_t * task; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + task = OS_OBJECT_TABLE_GET(OS_task_table, *token); /* ** RTEMS task names are 4 byte integers. ** It is convenient to use the OSAL task ID in here, as we know it is already unique ** and trying to use the real task name would be less than useful (only 4 chars) */ - r_name = OS_ObjectIdToInteger(OS_global_task_table[task_id].active_id); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); r_mode = RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0); /* @@ -115,8 +120,7 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) r_attributes |= RTEMS_FLOATING_POINT; } - status = rtems_task_create(r_name, OS_task_table[task_id].priority, OS_task_table[task_id].stack_size, r_mode, - r_attributes, &OS_impl_task_table[task_id].id); + status = rtems_task_create(r_name, task->priority, task->stack_size, r_mode, r_attributes, &impl->id); /* check if task_create failed */ if (status != RTEMS_SUCCESSFUL) @@ -127,15 +131,14 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) } /* will place the task in 'ready for scheduling' state */ - status = rtems_task_start( - OS_impl_task_table[task_id].id, /*rtems task id*/ - (rtems_task_entry)OS_RtemsEntry, /* task entry point */ - (rtems_task_argument)OS_ObjectIdToInteger(OS_global_task_table[task_id].active_id)); /* passed argument */ + status = rtems_task_start(impl->id, /*rtems task id*/ + (rtems_task_entry)OS_RtemsEntry, /* task entry point */ + (rtems_task_argument)r_name); /* passed argument */ if (status != RTEMS_SUCCESSFUL) { OS_printf("rtems_task_start failed: %s\n", rtems_status_text(status)); - rtems_task_delete(OS_impl_task_table[task_id].id); + rtems_task_delete(impl->id); return OS_ERROR; } @@ -151,8 +154,12 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl(osal_index_t task_id) +int32 OS_TaskDelete_Impl(const OS_object_token_t *token) { + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + /* ** Try to delete the task ** If this fails, not much recourse - the only potential cause of failure @@ -160,7 +167,7 @@ int32 OS_TaskDelete_Impl(osal_index_t task_id) ** and if that is true there is nothing wrong - everything is OK to continue normally. */ - rtems_task_delete(OS_impl_task_table[task_id].id); + rtems_task_delete(impl->id); return OS_SUCCESS; } /* end OS_TaskDelete_Impl */ @@ -221,13 +228,16 @@ int32 OS_TaskDelay_Impl(uint32 milli_second) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority) +int32 OS_TaskSetPriority_Impl(const OS_object_token_t *token, osal_priority_t new_priority) { - rtems_task_priority old_pri; - rtems_status_code status; + rtems_task_priority old_pri; + rtems_status_code status; + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); /* Set RTEMS Task Priority */ - status = rtems_task_set_priority(OS_impl_task_table[task_id].id, new_priority, &old_pri); + status = rtems_task_set_priority(impl->id, new_priority, &old_pri); if (status != RTEMS_SUCCESSFUL) { OS_DEBUG("Unhandled task_set_priority error: %s\n", rtems_status_text(status)); @@ -246,12 +256,16 @@ int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskMatch_Impl(osal_index_t task_id) +int32 OS_TaskMatch_Impl(const OS_object_token_t *token) { + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + /* ** Get RTEMS Task Id */ - if (rtems_task_self() != OS_impl_task_table[task_id].id) + if (rtems_task_self() != impl->id) { return (OS_ERROR); } @@ -329,7 +343,7 @@ osal_id_t OS_TaskGetId_Impl(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl(osal_index_t task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo_Impl(const OS_object_token_t *token, OS_task_prop_t *task_prop) { return OS_SUCCESS; @@ -360,9 +374,12 @@ int32 OS_TaskValidateSystemData_Impl(const void *sysdata, uint32 sysdata_size) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -bool OS_TaskIdMatchSystemData_Impl(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_TaskIdMatchSystemData_Impl(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { - const rtems_id *target = (const rtems_id *)ref; + const rtems_id * target = (const rtems_id *)ref; + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); - return (*target == OS_impl_task_table[local_id].id); + return (*target == impl->id); } diff --git a/src/os/rtems/src/os-impl-timebase.c b/src/os/rtems/src/os-impl-timebase.c index c5c74370c..c4c72a349 100644 --- a/src/os/rtems/src/os-impl-timebase.c +++ b/src/os/rtems/src/os-impl-timebase.c @@ -89,9 +89,13 @@ OS_impl_timebase_internal_record_t OS_impl_timebase_table[OS_MAX_TIMEBASES]; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_TimeBaseLock_Impl(osal_index_t local_id) +void OS_TimeBaseLock_Impl(const OS_object_token_t *token) { - rtems_semaphore_obtain(OS_impl_timebase_table[local_id].handler_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + OS_impl_timebase_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + + rtems_semaphore_obtain(impl->handler_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT); } /* end OS_TimeBaseLock_Impl */ /*---------------------------------------------------------------- @@ -102,9 +106,13 @@ void OS_TimeBaseLock_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_TimeBaseUnlock_Impl(osal_index_t local_id) +void OS_TimeBaseUnlock_Impl(const OS_object_token_t *token) { - rtems_semaphore_release(OS_impl_timebase_table[local_id].handler_mutex); + OS_impl_timebase_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + + rtems_semaphore_release(impl->handler_mutex); } /* end OS_TimeBaseUnlock_Impl */ /*---------------------------------------------------------------- @@ -119,14 +127,14 @@ void OS_TimeBaseUnlock_Impl(osal_index_t local_id) static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void *arg) { OS_U32ValueWrapper_t user_data; - osal_index_t local_id; + OS_object_token_t token; OS_impl_timebase_internal_record_t *local; user_data.opaque_arg = arg; - OS_ConvertToArrayIndex(user_data.id, &local_id); - local = &OS_impl_timebase_table[local_id]; - if (OS_ObjectIdEqual(OS_global_timebase_table[local_id].active_id, user_data.id)) + if (OS_ObjectIdGetById(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TIMEBASE, user_data.id, &token) == OS_SUCCESS) { + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, token); + /* * Reset the timer, but only if an interval was selected */ @@ -219,8 +227,8 @@ int32 OS_Rtems_TimeBaseAPI_Impl_Init(void) * This really should be an exact/whole number result; otherwise this * will round to the nearest nanosecond. */ - RTEMS_GlobalVars.ClockAccuracyNsec = - (1000000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / OS_SharedGlobalVars.TicksPerSecond; + RTEMS_GlobalVars.ClockAccuracyNsec = (1000000000 + (OS_SharedGlobalVars.TicksPerSecond / 2)) / + OS_SharedGlobalVars.TicksPerSecond; /* * Finally compute the Microseconds per tick @@ -280,22 +288,22 @@ void OS_UsecsToTicks(uint32 usecs, rtems_interval *ticks) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) +int32 OS_TimeBaseCreate_Impl(const OS_object_token_t *token) { int32 return_code; rtems_status_code rtems_sc; OS_impl_timebase_internal_record_t *local; - OS_common_record_t * global; rtems_name r_name; + OS_timebase_internal_record_t * timebase; return_code = OS_SUCCESS; - local = &OS_impl_timebase_table[timer_id]; - global = &OS_global_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, *token); /* * The RTEMS classic name for dependent resources */ - r_name = OS_ObjectIdToInteger(global->active_id); + r_name = OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)); /* * Set up the necessary OS constructs @@ -306,17 +314,17 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * If no external sync function is provided then this will set up an RTEMS * timer to locally simulate the timer tick using the CPU clock. */ - local->simulate_flag = (OS_timebase_table[timer_id].external_sync == NULL); + local->simulate_flag = (timebase->external_sync == NULL); if (local->simulate_flag) { - OS_timebase_table[timer_id].external_sync = OS_TimeBase_WaitImpl; + timebase->external_sync = OS_TimeBase_WaitImpl; /* * The tick_sem is a simple semaphore posted by the ISR and taken by the * timebase helper task (created later). */ - rtems_sc = - rtems_semaphore_create(r_name, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0, &local->tick_sem); + rtems_sc = rtems_semaphore_create(r_name, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0, + &local->tick_sem); if (rtems_sc != RTEMS_SUCCESSFUL) { OS_DEBUG("Error: Tick Sem could not be created: %d\n", (int)rtems_sc); @@ -376,10 +384,9 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) else { /* will place the task in 'ready for scheduling' state */ - rtems_sc = - rtems_task_start(local->handler_task, /*rtems task id*/ - (rtems_task_entry)OS_TimeBase_CallbackThread, /* task entry point */ - (rtems_task_argument)OS_ObjectIdToInteger(global->active_id)); /* passed argument */ + rtems_sc = rtems_task_start(local->handler_task, /*rtems task id*/ + (rtems_task_entry)OS_TimeBase_CallbackThread, /* task entry point */ + (rtems_task_argument)r_name); /* passed argument */ if (rtems_sc != RTEMS_SUCCESSFUL) { @@ -410,15 +417,17 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 interval_time) +int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uint32 interval_time) { OS_U32ValueWrapper_t user_data; OS_impl_timebase_internal_record_t *local; int32 return_code; int status; rtems_interval start_ticks; + OS_timebase_internal_record_t * timebase; - local = &OS_impl_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, *token); return_code = OS_SUCCESS; /* There is only something to do here if we are generating a simulated tick */ @@ -458,7 +467,7 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter OS_UsecsToTicks(start_time, &start_ticks); user_data.opaque_arg = NULL; - user_data.id = OS_global_timebase_table[timer_id].active_id; + user_data.id = OS_ObjectIdFromToken(token); status = rtems_timer_fire_after(local->rtems_timer_id, start_ticks, OS_TimeBase_ISR, user_data.opaque_arg); if (status != RTEMS_SUCCESSFUL) @@ -475,23 +484,23 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter if (local->configured_start_time != start_time) { OS_DEBUG("WARNING: timer %lu start_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, (unsigned long)start_time, + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), (unsigned long)start_time, (unsigned long)local->configured_start_time); } if (local->configured_interval_time != interval_time) { OS_DEBUG("WARNING: timer %lu interval_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, (unsigned long)interval_time, + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), (unsigned long)interval_time, (unsigned long)local->configured_interval_time); } if (local->interval_ticks > 0) { - OS_timebase_table[timer_id].accuracy_usec = local->configured_interval_time; + timebase->accuracy_usec = local->configured_interval_time; } else { - OS_timebase_table[timer_id].accuracy_usec = local->configured_start_time; + timebase->accuracy_usec = local->configured_start_time; } } } @@ -512,13 +521,13 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) +int32 OS_TimeBaseDelete_Impl(const OS_object_token_t *token) { rtems_status_code rtems_sc; OS_impl_timebase_internal_record_t *local; int32 return_code; - local = &OS_impl_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); return_code = OS_SUCCESS; /* @@ -576,7 +585,7 @@ int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl(osal_index_t timer_id, OS_timebase_prop_t *timer_prop) +int32 OS_TimeBaseGetInfo_Impl(const OS_object_token_t *token, OS_timebase_prop_t *timer_prop) { return OS_SUCCESS; diff --git a/src/os/shared/inc/os-shared-binsem.h b/src/os/shared/inc/os-shared-binsem.h index f9b743f62..13070731f 100644 --- a/src/os/shared/inc/os-shared-binsem.h +++ b/src/os/shared/inc/os-shared-binsem.h @@ -62,7 +62,7 @@ int32 OS_BinSemAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options); +int32 OS_BinSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options); /*---------------------------------------------------------------- Function: OS_BinSemFlush_Impl @@ -72,7 +72,7 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl(osal_index_t sem_id); +int32 OS_BinSemFlush_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_BinSemGive_Impl @@ -81,7 +81,7 @@ int32 OS_BinSemFlush_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl(osal_index_t sem_id); +int32 OS_BinSemGive_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_BinSemTake_Impl @@ -91,7 +91,7 @@ int32 OS_BinSemGive_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl(osal_index_t sem_id); +int32 OS_BinSemTake_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_BinSemTimedWait_Impl @@ -101,7 +101,7 @@ int32 OS_BinSemTake_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code OS_SEM_TIMEOUT must be returned if the time limit was reached ------------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs); +int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs); /*---------------------------------------------------------------- Function: OS_BinSemDelete_Impl @@ -110,7 +110,7 @@ int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl(osal_index_t sem_id); +int32 OS_BinSemDelete_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_BinSemGetInfo_Impl @@ -119,6 +119,6 @@ int32 OS_BinSemDelete_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(osal_index_t sem_id, OS_bin_sem_prop_t *bin_prop); +int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop); #endif /* INCLUDE_OS_SHARED_BINSEM_H_ */ diff --git a/src/os/shared/inc/os-shared-countsem.h b/src/os/shared/inc/os-shared-countsem.h index fc4715d62..08966db51 100644 --- a/src/os/shared/inc/os-shared-countsem.h +++ b/src/os/shared/inc/os-shared-countsem.h @@ -62,7 +62,7 @@ int32 OS_CountSemAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options); +int32 OS_CountSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options); /*---------------------------------------------------------------- Function: OS_CountSemGive_Impl @@ -71,7 +71,7 @@ int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl(osal_index_t sem_id); +int32 OS_CountSemGive_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_CountSemTake_Impl @@ -81,7 +81,7 @@ int32 OS_CountSemGive_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl(osal_index_t sem_id); +int32 OS_CountSemTake_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_CountSemTimedWait_Impl @@ -91,7 +91,7 @@ int32 OS_CountSemTake_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code OS_SEM_TIMEOUT must be returned if the time limit was reached ------------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs); +int32 OS_CountSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs); /*---------------------------------------------------------------- Function: OS_CountSemDelete_Impl @@ -100,7 +100,7 @@ int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl(osal_index_t sem_id); +int32 OS_CountSemDelete_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_CountSemGetInfo_Impl @@ -109,6 +109,6 @@ int32 OS_CountSemDelete_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl(osal_index_t sem_id, OS_count_sem_prop_t *count_prop); +int32 OS_CountSemGetInfo_Impl(const OS_object_token_t *token, OS_count_sem_prop_t *count_prop); #endif /* INCLUDE_OS_SHARED_COUNTSEM_H_ */ diff --git a/src/os/shared/inc/os-shared-dir.h b/src/os/shared/inc/os-shared-dir.h index e52d682ad..638fac1ad 100644 --- a/src/os/shared/inc/os-shared-dir.h +++ b/src/os/shared/inc/os-shared-dir.h @@ -72,7 +72,7 @@ int32 OS_DirCreate_Impl(const char *local_path, uint32 access); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_DirOpen_Impl(osal_index_t local_id, const char *local_path); +int32 OS_DirOpen_Impl(const OS_object_token_t *token, const char *local_path); /*---------------------------------------------------------------- Function: OS_DirClose_Impl @@ -81,7 +81,7 @@ int32 OS_DirOpen_Impl(osal_index_t local_id, const char *local_path); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_DirClose_Impl(osal_index_t local_id); +int32 OS_DirClose_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_DirRead_Impl @@ -90,7 +90,7 @@ int32 OS_DirClose_Impl(osal_index_t local_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent); +int32 OS_DirRead_Impl(const OS_object_token_t *token, os_dirent_t *dirent); /*---------------------------------------------------------------- Function: OS_DirRewind_Impl @@ -99,7 +99,7 @@ int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_DirRewind_Impl(osal_index_t local_id); +int32 OS_DirRewind_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_DirRemove_Impl diff --git a/src/os/shared/inc/os-shared-file.h b/src/os/shared/inc/os-shared-file.h index 547bde042..32058fa1a 100644 --- a/src/os/shared/inc/os-shared-file.h +++ b/src/os/shared/inc/os-shared-file.h @@ -78,7 +78,7 @@ int32 OS_FileAPI_Init(void); Returns: File position (non-negative) on success, or relevant error code (negative) ------------------------------------------------------------------*/ -int32 OS_GenericSeek_Impl(osal_index_t local_id, int32 offset, uint32 whence); +int32 OS_GenericSeek_Impl(const OS_object_token_t *token, int32 offset, uint32 whence); /*---------------------------------------------------------------- Function: OS_GenericRead_Impl @@ -88,7 +88,7 @@ int32 OS_GenericSeek_Impl(osal_index_t local_id, int32 offset, uint32 whence); Returns: Number of bytes read (non-negative) on success, or relevant error code (negative) ------------------------------------------------------------------*/ -int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, int32 timeout); +int32 OS_GenericRead_Impl(const OS_object_token_t *token, void *buffer, size_t nbytes, int32 timeout); /*---------------------------------------------------------------- Function: OS_GenericWrite_Impl @@ -98,7 +98,7 @@ int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, in Returns: Number of bytes written (non-negative) on success, or relevant error code (negative) ------------------------------------------------------------------*/ -int32 OS_GenericWrite_Impl(osal_index_t local_id, const void *buffer, size_t nbytes, int32 timeout); +int32 OS_GenericWrite_Impl(const OS_object_token_t *token, const void *buffer, size_t nbytes, int32 timeout); /*---------------------------------------------------------------- Function: OS_GenericClose_Impl @@ -108,7 +108,7 @@ int32 OS_GenericWrite_Impl(osal_index_t local_id, const void *buffer, size_t nby Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_GenericClose_Impl(osal_index_t local_id); +int32 OS_GenericClose_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_FileOpen_Impl @@ -118,7 +118,7 @@ int32 OS_GenericClose_Impl(osal_index_t local_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileOpen_Impl(osal_index_t local_id, const char *local_path, int32 flags, int32 access); +int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access); /*---------------------------------------------------------------- Function: OS_ShellOutputToFile_Impl @@ -127,7 +127,7 @@ int32 OS_FileOpen_Impl(osal_index_t local_id, const char *local_path, int32 flag Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(osal_index_t stream_id, const char *Cmd); +int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd); /**************************************************************************************** Filename-based Operations diff --git a/src/os/shared/inc/os-shared-filesys.h b/src/os/shared/inc/os-shared-filesys.h index 110a23697..bba3ec767 100644 --- a/src/os/shared/inc/os-shared-filesys.h +++ b/src/os/shared/inc/os-shared-filesys.h @@ -140,7 +140,7 @@ int32 OS_FileSysAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id); +int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_FileSysStopVolume_Impl @@ -149,7 +149,7 @@ int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id); +int32 OS_FileSysStopVolume_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_FileSysFormatVolume_Impl @@ -158,7 +158,7 @@ int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id); +int32 OS_FileSysFormatVolume_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_FileSysCheckVolume_Impl @@ -167,7 +167,7 @@ int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl(osal_index_t filesys_id, bool repair); +int32 OS_FileSysCheckVolume_Impl(const OS_object_token_t *token, bool repair); /*---------------------------------------------------------------- Function: OS_FileSysStatVolume_Impl @@ -176,7 +176,7 @@ int32 OS_FileSysCheckVolume_Impl(osal_index_t filesys_id, bool repair); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result); +int32 OS_FileSysStatVolume_Impl(const OS_object_token_t *token, OS_statvfs_t *result); /*---------------------------------------------------------------- Function: OS_FileSysMountVolume_Impl @@ -185,7 +185,7 @@ int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id); +int32 OS_FileSysMountVolume_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_FileSysUnmountVolume_Impl @@ -194,7 +194,7 @@ int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id); +int32 OS_FileSysUnmountVolume_Impl(const OS_object_token_t *token); /* * Internal helper functions @@ -202,7 +202,7 @@ int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id); * Not normally invoked outside this unit, except for unit testing */ -bool OS_FileSys_FindVirtMountPoint(void *ref, osal_index_t local_id, const OS_common_record_t *obj); +bool OS_FileSys_FindVirtMountPoint(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj); int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fsvolname, size_t blocksize, osal_blockcount_t numblocks, bool should_format); diff --git a/src/os/shared/inc/os-shared-idmap.h b/src/os/shared/inc/os-shared-idmap.h index 1413c30a7..a63d2eea6 100644 --- a/src/os/shared/inc/os-shared-idmap.h +++ b/src/os/shared/inc/os-shared-idmap.h @@ -91,7 +91,7 @@ struct OS_object_token * * Returns true if the id/obj matches the reference, false otherwise. */ -typedef bool (*OS_ObjectMatchFunc_t)(void *ref, osal_index_t local_id, const OS_common_record_t *obj); +typedef bool (*OS_ObjectMatchFunc_t)(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj); /* * State object associated with an object iterator @@ -481,7 +481,7 @@ int32 OS_ObjectIdIteratorProcessEntry(OS_object_iter_t *iter, int32 (*func)(osal * These are not normally called outside this unit, but need * to be exposed for unit testing. */ -bool OS_ObjectNameMatch(void *ref, osal_index_t local_id, const OS_common_record_t *obj); +bool OS_ObjectNameMatch(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj); int32 OS_ObjectIdFindNextMatch(OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_object_token_t *token); int32 OS_ObjectIdFindNextFree(OS_object_token_t *token); diff --git a/src/os/shared/inc/os-shared-module.h b/src/os/shared/inc/os-shared-module.h index 4f9284264..6f651b648 100644 --- a/src/os/shared/inc/os-shared-module.h +++ b/src/os/shared/inc/os-shared-module.h @@ -72,7 +72,7 @@ int32 OS_ModuleAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path); +int32 OS_ModuleLoad_Impl(const OS_object_token_t *token, const char *translated_path); /*---------------------------------------------------------------- @@ -82,7 +82,7 @@ int32 OS_ModuleLoad_Impl(osal_index_t module_id, const char *translated_path); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl(osal_index_t module_id); +int32 OS_ModuleUnload_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_ModuleGetInfo_Impl @@ -91,7 +91,7 @@ int32 OS_ModuleUnload_Impl(osal_index_t module_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl(osal_index_t module_id, OS_module_prop_t *module_prop); +int32 OS_ModuleGetInfo_Impl(const OS_object_token_t *token, OS_module_prop_t *module_prop); /*---------------------------------------------------------------- Function: OS_GlobalSymbolLookup_Impl @@ -111,7 +111,7 @@ int32 OS_GlobalSymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleSymbolLookup_Impl(osal_index_t local_id, cpuaddr *SymbolAddress, const char *SymbolName); +int32 OS_ModuleSymbolLookup_Impl(const OS_object_token_t *token, cpuaddr *SymbolAddress, const char *SymbolName); /*---------------------------------------------------------------- Function: OS_SymbolTableDump_Impl diff --git a/src/os/shared/inc/os-shared-mutex.h b/src/os/shared/inc/os-shared-mutex.h index 576540228..b7703aa66 100644 --- a/src/os/shared/inc/os-shared-mutex.h +++ b/src/os/shared/inc/os-shared-mutex.h @@ -58,7 +58,7 @@ int32 OS_MutexAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options); +int32 OS_MutSemCreate_Impl(const OS_object_token_t *token, uint32 options); /*---------------------------------------------------------------- Function: OS_MutSemGive_Impl @@ -67,7 +67,7 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl(osal_index_t sem_id); +int32 OS_MutSemGive_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_MutSemTake_Impl @@ -76,7 +76,7 @@ int32 OS_MutSemGive_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl(osal_index_t sem_id); +int32 OS_MutSemTake_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_MutSemDelete_Impl @@ -85,7 +85,7 @@ int32 OS_MutSemTake_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl(osal_index_t sem_id); +int32 OS_MutSemDelete_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_MutSemGetInfo_Impl @@ -94,6 +94,6 @@ int32 OS_MutSemDelete_Impl(osal_index_t sem_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl(osal_index_t sem_id, OS_mut_sem_prop_t *mut_prop); +int32 OS_MutSemGetInfo_Impl(const OS_object_token_t *token, OS_mut_sem_prop_t *mut_prop); #endif /* INCLUDE_OS_SHARED_MUTEX_H_ */ diff --git a/src/os/shared/inc/os-shared-printf.h b/src/os/shared/inc/os-shared-printf.h index 165dd3dec..6bc2b6b48 100644 --- a/src/os/shared/inc/os-shared-printf.h +++ b/src/os/shared/inc/os-shared-printf.h @@ -73,7 +73,7 @@ int32 OS_ConsoleAPI_Init(void); Purpose: Prepare a console device for use For Async devices, this sets up the background writer task ------------------------------------------------------------------*/ -int32 OS_ConsoleCreate_Impl(osal_index_t local_id); +int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_ConsoleOutput_Impl @@ -85,7 +85,7 @@ int32 OS_ConsoleCreate_Impl(osal_index_t local_id); The data is already formatted, this just writes the characters. ------------------------------------------------------------------*/ -void OS_ConsoleOutput_Impl(osal_index_t local_id); +void OS_ConsoleOutput_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_ConsoleOutput_Impl @@ -100,6 +100,6 @@ void OS_ConsoleOutput_Impl(osal_index_t local_id); service, this should wakeup the actual console servicing thread. ------------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(osal_index_t local_id); +void OS_ConsoleWakeup_Impl(const OS_object_token_t *token); #endif /* INCLUDE_OS_SHARED_PRINTF_H_ */ diff --git a/src/os/shared/inc/os-shared-queue.h b/src/os/shared/inc/os-shared-queue.h index 752c61f89..03b5c309d 100644 --- a/src/os/shared/inc/os-shared-queue.h +++ b/src/os/shared/inc/os-shared-queue.h @@ -63,7 +63,7 @@ int32 OS_QueueAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags); +int32 OS_QueueCreate_Impl(const OS_object_token_t *token, uint32 flags); /*---------------------------------------------------------------- Function: OS_QueueDelete_Impl @@ -72,7 +72,7 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl(osal_index_t queue_id); +int32 OS_QueueDelete_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_QueueGet_Impl @@ -85,7 +85,7 @@ int32 OS_QueueDelete_Impl(osal_index_t queue_id); OS_QUEUE_EMPTY must be returned if the queue is empty when polled (OS_CHECK) OS_QUEUE_INVALID_SIZE must be returned if the supplied buffer is too small ------------------------------------------------------------------*/ -int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *size_copied, int32 timeout); +int32 OS_QueueGet_Impl(const OS_object_token_t *token, void *data, size_t size, size_t *size_copied, int32 timeout); /*---------------------------------------------------------------- Function: OS_QueuePut_Impl @@ -95,7 +95,7 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *s Returns: OS_SUCCESS on success, or relevant error code OS_QUEUE_FULL must be returned if the queue is full. ------------------------------------------------------------------*/ -int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, size_t size, uint32 flags); +int32 OS_QueuePut_Impl(const OS_object_token_t *token, const void *data, size_t size, uint32 flags); /*---------------------------------------------------------------- Function: OS_QueueGetInfo_Impl @@ -104,6 +104,6 @@ int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, size_t size, uin Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_QueueGetInfo_Impl(osal_index_t queue_id, OS_queue_prop_t *queue_prop); +int32 OS_QueueGetInfo_Impl(const OS_object_token_t *token, OS_queue_prop_t *queue_prop); #endif /* INCLUDE_OS_SHARED_QUEUE_H_ */ diff --git a/src/os/shared/inc/os-shared-select.h b/src/os/shared/inc/os-shared-select.h index a1d7e9c85..66cf33f3c 100644 --- a/src/os/shared/inc/os-shared-select.h +++ b/src/os/shared/inc/os-shared-select.h @@ -50,7 +50,7 @@ Returns: OS_SUCCESS on success, or relevant error code OS_ERR_OPERATION_NOT_SUPPORTED if the specified file handle does not support select ------------------------------------------------------------------*/ -int32 OS_SelectSingle_Impl(osal_index_t stream_id, uint32 *SelectFlags, int32 msecs); +int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags, int32 msecs); /*---------------------------------------------------------------- diff --git a/src/os/shared/inc/os-shared-shell.h b/src/os/shared/inc/os-shared-shell.h index a26044648..1b896ee8f 100644 --- a/src/os/shared/inc/os-shared-shell.h +++ b/src/os/shared/inc/os-shared-shell.h @@ -41,6 +41,6 @@ Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(osal_index_t stream_id, const char *Cmd); +int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd); #endif /* INCLUDE_OS_SHARED_SHELL_H_ */ diff --git a/src/os/shared/inc/os-shared-sockets.h b/src/os/shared/inc/os-shared-sockets.h index 8bd9fcfb6..12a9cc7b9 100644 --- a/src/os/shared/inc/os-shared-sockets.h +++ b/src/os/shared/inc/os-shared-sockets.h @@ -50,7 +50,7 @@ int32 OS_SocketAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketOpen_Impl(osal_index_t sock_id); +int32 OS_SocketOpen_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_SocketBind_Impl @@ -59,7 +59,7 @@ int32 OS_SocketOpen_Impl(osal_index_t sock_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketBind_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr); +int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr); /*---------------------------------------------------------------- Function: OS_SocketAccept_Impl @@ -70,7 +70,8 @@ int32 OS_SocketBind_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketAccept_Impl(osal_index_t sock_id, osal_index_t connsock_id, OS_SockAddr_t *Addr, int32 timeout); +int32 OS_SocketAccept_Impl(const OS_object_token_t *sock_token, const OS_object_token_t *conn_token, + OS_SockAddr_t *Addr, int32 timeout); /*---------------------------------------------------------------- Function: OS_SocketConnect_Impl @@ -80,7 +81,7 @@ int32 OS_SocketAccept_Impl(osal_index_t sock_id, osal_index_t connsock_id, OS_So Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int32 timeout); +int32 OS_SocketConnect_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Addr, int32 timeout); /*---------------------------------------------------------------- Function: OS_SocketRecvFrom_Impl @@ -93,7 +94,7 @@ int32 OS_SocketConnect_Impl(osal_index_t sock_id, const OS_SockAddr_t *Addr, int Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketRecvFrom_Impl(osal_index_t sock_id, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, +int32 OS_SocketRecvFrom_Impl(const OS_object_token_t *token, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, int32 timeout); /*---------------------------------------------------------------- @@ -105,7 +106,8 @@ int32 OS_SocketRecvFrom_Impl(osal_index_t sock_id, void *buffer, size_t buflen, Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketSendTo_Impl(osal_index_t sock_id, const void *buffer, size_t buflen, const OS_SockAddr_t *RemoteAddr); +int32 OS_SocketSendTo_Impl(const OS_object_token_t *token, const void *buffer, size_t buflen, + const OS_SockAddr_t *RemoteAddr); /*---------------------------------------------------------------- @@ -115,7 +117,7 @@ int32 OS_SocketSendTo_Impl(osal_index_t sock_id, const void *buffer, size_t bufl Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_SocketGetInfo_Impl(osal_index_t sock_id, OS_socket_prop_t *sock_prop); +int32 OS_SocketGetInfo_Impl(const OS_object_token_t *token, OS_socket_prop_t *sock_prop); /*---------------------------------------------------------------- @@ -175,6 +177,6 @@ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum); * Internal helper functions * Not normally called outside the local unit, except during unit test */ -void OS_CreateSocketName(osal_index_t local_id, const OS_SockAddr_t *Addr, const char *parent_name); +void OS_CreateSocketName(const OS_object_token_t *token, const OS_SockAddr_t *Addr, const char *parent_name); #endif /* INCLUDE_OS_SHARED_SOCKETS_H_ */ diff --git a/src/os/shared/inc/os-shared-task.h b/src/os/shared/inc/os-shared-task.h index 74ba5386a..03fc11fe7 100644 --- a/src/os/shared/inc/os-shared-task.h +++ b/src/os/shared/inc/os-shared-task.h @@ -81,7 +81,7 @@ void OS_TaskEntryPoint(osal_id_t global_task_id); Returns: OS_SUCCESS on match, any other code on non-match ------------------------------------------------------------------*/ -int32 OS_TaskMatch_Impl(osal_index_t task_id); +int32 OS_TaskMatch_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- @@ -92,7 +92,7 @@ int32 OS_TaskMatch_Impl(osal_index_t task_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags); +int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags); /*---------------------------------------------------------------- Function: OS_TaskDelete_Impl @@ -101,7 +101,7 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl(osal_index_t task_id); +int32 OS_TaskDelete_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_TaskExit_Impl @@ -128,7 +128,7 @@ int32 OS_TaskDelay_Impl(uint32 millisecond); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority); +int32 OS_TaskSetPriority_Impl(const OS_object_token_t *token, osal_priority_t new_priority); /*---------------------------------------------------------------- Function: OS_TaskGetId_Impl @@ -146,7 +146,7 @@ osal_id_t OS_TaskGetId_Impl(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl(osal_index_t task_id, OS_task_prop_t *task_prop); +int32 OS_TaskGetInfo_Impl(const OS_object_token_t *token, OS_task_prop_t *task_prop); /*---------------------------------------------------------------- @@ -169,7 +169,7 @@ int32 OS_TaskRegister_Impl(osal_id_t global_task_id); Compatible with the "OS_ObjectIdFindBySearch" routine ------------------------------------------------------------------*/ -bool OS_TaskIdMatchSystemData_Impl(void *ref, osal_index_t local_id, const OS_common_record_t *obj); +bool OS_TaskIdMatchSystemData_Impl(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj); /*---------------------------------------------------------------- diff --git a/src/os/shared/inc/os-shared-timebase.h b/src/os/shared/inc/os-shared-timebase.h index 9b8c9fe57..3e06d4f18 100644 --- a/src/os/shared/inc/os-shared-timebase.h +++ b/src/os/shared/inc/os-shared-timebase.h @@ -73,7 +73,7 @@ int32 OS_TimeBaseAPI_Init(void); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseCreate_Impl(osal_index_t timebase_id); +int32 OS_TimeBaseCreate_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_TimeBaseSet_Impl @@ -82,7 +82,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timebase_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseSet_Impl(osal_index_t timebase_id, uint32 start_time, uint32 interval_time); +int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uint32 interval_time); /*---------------------------------------------------------------- Function: OS_TimeBaseDelete_Impl @@ -91,7 +91,7 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timebase_id, uint32 start_time, uint32 in Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseDelete_Impl(osal_index_t timebase_id); +int32 OS_TimeBaseDelete_Impl(const OS_object_token_t *token); /**************************************************************************************** INTERNAL FUNCTIONS @@ -103,7 +103,7 @@ int32 OS_TimeBaseDelete_Impl(osal_index_t timebase_id); Purpose: Get exclusive access to the given timebase Add/remove of application callbacks is prevented ------------------------------------------------------------------*/ -void OS_TimeBaseLock_Impl(osal_index_t timebase_id); +void OS_TimeBaseLock_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_TimeBaseLock_Impl @@ -111,7 +111,7 @@ void OS_TimeBaseLock_Impl(osal_index_t timebase_id); Purpose: Release exclusive access to the given timebase Add/remove of application callbacks is allowed ------------------------------------------------------------------*/ -void OS_TimeBaseUnlock_Impl(osal_index_t timebase_id); +void OS_TimeBaseUnlock_Impl(const OS_object_token_t *token); /*---------------------------------------------------------------- Function: OS_TimeBaseGetInfo_Impl @@ -120,7 +120,7 @@ void OS_TimeBaseUnlock_Impl(osal_index_t timebase_id); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl(osal_index_t timer_id, OS_timebase_prop_t *timer_prop); +int32 OS_TimeBaseGetInfo_Impl(const OS_object_token_t *token, OS_timebase_prop_t *timer_prop); /*---------------------------------------------------------------- Function: OS_TimeBase_CallbackThread diff --git a/src/os/shared/src/osapi-binsem.c b/src/os/shared/src/osapi-binsem.c index d46bfee21..8fbe7ec20 100644 --- a/src/os/shared/src/osapi-binsem.c +++ b/src/os/shared/src/osapi-binsem.c @@ -121,7 +121,7 @@ int32 OS_BinSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initia OS_OBJECT_INIT(token, binsem, obj_name, sem_name); /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_BinSemCreate_Impl(OS_ObjectIndexFromToken(&token), sem_initial_value, options); + return_code = OS_BinSemCreate_Impl(&token, sem_initial_value, options); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, sem_id); @@ -147,7 +147,7 @@ int32 OS_BinSemDelete(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_BinSemDelete_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_BinSemDelete_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -174,7 +174,7 @@ int32 OS_BinSemGive(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_BinSemGive_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_BinSemGive_Impl(&token); } return return_code; @@ -198,7 +198,7 @@ int32 OS_BinSemFlush(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_BinSemFlush_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_BinSemFlush_Impl(&token); } return return_code; @@ -221,7 +221,7 @@ int32 OS_BinSemTake(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_BinSemTake_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_BinSemTake_Impl(&token); } return return_code; @@ -244,7 +244,7 @@ int32 OS_BinSemTimedWait(osal_id_t sem_id, uint32 msecs) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_BinSemTimedWait_Impl(OS_ObjectIndexFromToken(&token), msecs); + return_code = OS_BinSemTimedWait_Impl(&token, msecs); } return return_code; @@ -302,7 +302,7 @@ int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) strncpy(bin_prop->name, record->name_entry, OS_MAX_API_NAME - 1); bin_prop->creator = record->creator; - return_code = OS_BinSemGetInfo_Impl(OS_ObjectIndexFromToken(&token), bin_prop); + return_code = OS_BinSemGetInfo_Impl(&token, bin_prop); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-countsem.c b/src/os/shared/src/osapi-countsem.c index a47988841..a73f55843 100644 --- a/src/os/shared/src/osapi-countsem.c +++ b/src/os/shared/src/osapi-countsem.c @@ -113,7 +113,7 @@ int32 OS_CountSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_init OS_OBJECT_INIT(token, countsem, obj_name, sem_name); /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_CountSemCreate_Impl(OS_ObjectIndexFromToken(&token), sem_initial_value, options); + return_code = OS_CountSemCreate_Impl(&token, sem_initial_value, options); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, sem_id); @@ -139,7 +139,7 @@ int32 OS_CountSemDelete(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_CountSemDelete_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_CountSemDelete_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -166,7 +166,7 @@ int32 OS_CountSemGive(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_CountSemGive_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_CountSemGive_Impl(&token); } return return_code; @@ -190,7 +190,7 @@ int32 OS_CountSemTake(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_CountSemTake_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_CountSemTake_Impl(&token); } return return_code; @@ -213,7 +213,7 @@ int32 OS_CountSemTimedWait(osal_id_t sem_id, uint32 msecs) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_CountSemTimedWait_Impl(OS_ObjectIndexFromToken(&token), msecs); + return_code = OS_CountSemTimedWait_Impl(&token, msecs); } return return_code; @@ -272,7 +272,7 @@ int32 OS_CountSemGetInfo(osal_id_t sem_id, OS_count_sem_prop_t *count_prop) strncpy(count_prop->name, record->name_entry, OS_MAX_API_NAME - 1); count_prop->creator = record->creator; - return_code = OS_CountSemGetInfo_Impl(OS_ObjectIndexFromToken(&token), count_prop); + return_code = OS_CountSemGetInfo_Impl(&token, count_prop); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-dir.c b/src/os/shared/src/osapi-dir.c index 7f9ac053b..0c82b98a6 100644 --- a/src/os/shared/src/osapi-dir.c +++ b/src/os/shared/src/osapi-dir.c @@ -134,7 +134,7 @@ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path) OS_OBJECT_INIT(token, dir, dir_name, path); /* Now call the OS-specific implementation. */ - return_code = OS_DirOpen_Impl(OS_ObjectIndexFromToken(&token), local_path); + return_code = OS_DirOpen_Impl(&token, local_path); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, dir_id); @@ -161,7 +161,7 @@ int32 OS_DirectoryClose(osal_id_t dir_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, dir_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_DirClose_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_DirClose_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -202,7 +202,7 @@ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent) * reads the "/" directory, the application will see the * real name (eeprom) and not the virtualized name (cf). */ - return_code = OS_DirRead_Impl(OS_ObjectIndexFromToken(&token), dirent); + return_code = OS_DirRead_Impl(&token, dirent); OS_ObjectIdRelease(&token); } @@ -228,7 +228,7 @@ int32 OS_DirectoryRewind(osal_id_t dir_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, dir_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_DirRewind_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_DirRewind_Impl(&token); } return return_code; diff --git a/src/os/shared/src/osapi-file.c b/src/os/shared/src/osapi-file.c index 1dc99247a..2b045375b 100644 --- a/src/os/shared/src/osapi-file.c +++ b/src/os/shared/src/osapi-file.c @@ -124,7 +124,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc OS_OBJECT_INIT(token, stream, stream_name, path); /* Now call the OS-specific implementation. */ - return_code = OS_FileOpen_Impl(OS_ObjectIndexFromToken(&token), local_path, flags, access); + return_code = OS_FileOpen_Impl(&token, local_path, flags, access); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, filedes); @@ -234,7 +234,7 @@ int32 OS_close(osal_id_t filedes) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, filedes, &token); if (return_code == OS_SUCCESS) { - return_code = OS_GenericClose_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_GenericClose_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -266,7 +266,8 @@ int32 OS_TimedRead(osal_id_t filedes, void *buffer, size_t nbytes, int32 timeout return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &token); if (return_code == OS_SUCCESS) { - return_code = OS_GenericRead_Impl(OS_ObjectIndexFromToken(&token), buffer, nbytes, timeout); + return_code = OS_GenericRead_Impl(&token, buffer, nbytes, timeout); + OS_ObjectIdRelease(&token); } @@ -295,7 +296,7 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, size_t nbytes, int32 return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &token); if (return_code == OS_SUCCESS) { - return_code = OS_GenericWrite_Impl(OS_ObjectIndexFromToken(&token), buffer, nbytes, timeout); + return_code = OS_GenericWrite_Impl(&token, buffer, nbytes, timeout); OS_ObjectIdRelease(&token); } @@ -397,7 +398,7 @@ int32 OS_lseek(osal_id_t filedes, int32 offset, uint32 whence) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, filedes, &token); if (return_code == OS_SUCCESS) { - return_code = OS_GenericSeek_Impl(OS_ObjectIndexFromToken(&token), offset, whence); + return_code = OS_GenericSeek_Impl(&token, offset, whence); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index d791c7d05..3c51d646e 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -74,12 +74,14 @@ const char OS_FILESYS_RAMDISK_VOLNAME_PREFIX[] = "RAM"; * Returns: true if the entry matches, false if it does not match * *-----------------------------------------------------------------*/ -bool OS_FileSys_FindVirtMountPoint(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_FileSys_FindVirtMountPoint(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { - OS_filesys_internal_record_t *filesys = &OS_filesys_table[local_id]; - const char * target = (const char *)ref; + OS_filesys_internal_record_t *filesys; + const char * target = (const char *)ref; size_t mplen; + filesys = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + if ((filesys->flags & OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL) == 0) { return false; @@ -157,7 +159,7 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs filesys->fstype = OS_FILESYS_TYPE_VOLATILE_DISK; } - return_code = OS_FileSysStartVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysStartVolume_Impl(&token); if (return_code == OS_SUCCESS) { @@ -167,7 +169,7 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs */ if (should_format) { - return_code = OS_FileSysFormatVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysFormatVolume_Impl(&token); } if (return_code == OS_SUCCESS) @@ -182,7 +184,7 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs * Cast to void to repress analysis warnings for * ignored return value. */ - (void)OS_FileSysStopVolume_Impl(OS_ObjectIndexFromToken(&token)); + (void)OS_FileSysStopVolume_Impl(&token); } } @@ -282,12 +284,12 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const * The "mount" implementation is required as it will * create the mountpoint if it does not already exist */ - return_code = OS_FileSysStartVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysStartVolume_Impl(&token); if (return_code == OS_SUCCESS) { filesys->flags |= OS_FILESYS_FLAG_IS_READY; - return_code = OS_FileSysMountVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysMountVolume_Impl(&token); } if (return_code == OS_SUCCESS) @@ -369,7 +371,7 @@ int32 OS_rmfs(const char *devname) * the filesystem is unmounted first, but this would break * compatibility with the existing unit tests. */ - return_code = OS_FileSysStopVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysStopVolume_Impl(&token); /* Free the entry in the master table */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -463,7 +465,7 @@ int32 OS_mount(const char *devname, const char *mountpoint) } else { - return_code = OS_FileSysMountVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysMountVolume_Impl(&token); } if (return_code == OS_SUCCESS) @@ -533,7 +535,7 @@ int32 OS_unmount(const char *mountpoint) } else { - return_code = OS_FileSysUnmountVolume_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_FileSysUnmountVolume_Impl(&token); } if (return_code == OS_SUCCESS) @@ -583,7 +585,7 @@ int32 OS_fsBlocksFree(const char *name) if (return_code == OS_SUCCESS) { - return_code = OS_FileSysStatVolume_Impl(OS_ObjectIndexFromToken(&token), &statfs); + return_code = OS_FileSysStatVolume_Impl(&token, &statfs); OS_ObjectIdRelease(&token); @@ -631,7 +633,7 @@ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) if (return_code == OS_SUCCESS) { - return_code = OS_FileSysStatVolume_Impl(OS_ObjectIndexFromToken(&token), &statfs); + return_code = OS_FileSysStatVolume_Impl(&token, &statfs); OS_ObjectIdRelease(&token); @@ -685,7 +687,7 @@ int32 OS_chkfs(const char *name, bool repair) if (return_code == OS_SUCCESS) { - return_code = OS_FileSysCheckVolume_Impl(OS_ObjectIndexFromToken(&token), repair); + return_code = OS_FileSysCheckVolume_Impl(&token, repair); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-idmap.c b/src/os/shared/src/osapi-idmap.c index 44fee7580..0ccaf16f0 100644 --- a/src/os/shared/src/osapi-idmap.c +++ b/src/os/shared/src/osapi-idmap.c @@ -240,7 +240,7 @@ OS_common_record_t *OS_ObjectIdGlobalFromToken(const OS_object_token_t *token) * returns: true if match, false otherwise * *-----------------------------------------------------------------*/ -bool OS_ObjectNameMatch(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_ObjectNameMatch(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { return (obj->name_entry != NULL && strcmp((const char *)ref, obj->name_entry) == 0); } /* end OS_ObjectNameMatch */ @@ -504,7 +504,7 @@ int32 OS_ObjectIdFindNextMatch(OS_ObjectMatchFunc_t MatchFunc, void *arg, OS_obj record = OS_OBJECT_TABLE_GET(base, *token); - if (OS_ObjectIdDefined(record->active_id) && MatchFunc(arg, token->obj_idx, record)) + if (OS_ObjectIdDefined(record->active_id) && MatchFunc(arg, token, record)) { return_code = OS_SUCCESS; token->obj_id = record->active_id; @@ -1172,7 +1172,7 @@ int32 OS_ObjectIdIteratorInit(OS_ObjectMatchFunc_t matchfunc, void *matcharg, os Purpose: Match function to iterate only active objects ------------------------------------------------------------------*/ -bool OS_ObjectFilterActive(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_ObjectFilterActive(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { return OS_ObjectIdDefined(obj->active_id); } @@ -1209,7 +1209,7 @@ bool OS_ObjectIdIteratorGetNext(OS_object_iter_t *iter) } record = OS_OBJECT_TABLE_GET(iter->base, iter->token); - if (iter->match == NULL || iter->match(iter->arg, iter->token.obj_idx, record)) + if (iter->match == NULL || iter->match(iter->arg, &iter->token, record)) { iter->token.obj_id = record->active_id; got_next = true; diff --git a/src/os/shared/src/osapi-module.c b/src/os/shared/src/osapi-module.c index 6510bf44c..ad42b5fd0 100644 --- a/src/os/shared/src/osapi-module.c +++ b/src/os/shared/src/osapi-module.c @@ -260,7 +260,7 @@ int32 OS_ModuleLoad(osal_id_t *module_id, const char *module_name, const char *f module->module_type = OS_MODULE_TYPE_DYNAMIC; /* Now call the OS-specific implementation. This reads info from the module table. */ - return_code = OS_ModuleLoad_Impl(OS_ObjectIndexFromToken(&token), translated_path); + return_code = OS_ModuleLoad_Impl(&token, translated_path); } } @@ -298,7 +298,7 @@ int32 OS_ModuleUnload(osal_id_t module_id) */ if (module->module_type == OS_MODULE_TYPE_DYNAMIC) { - return_code = OS_ModuleUnload_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_ModuleUnload_Impl(&token); } /* Complete the operation via the common routine */ @@ -340,7 +340,7 @@ int32 OS_ModuleInfo(osal_id_t module_id, OS_module_prop_t *module_prop) strncpy(module_prop->name, record->name_entry, OS_MAX_API_NAME - 1); strncpy(module_prop->filename, module->file_name, OS_MAX_API_NAME - 1); - return_code = OS_ModuleGetInfo_Impl(OS_ObjectIndexFromToken(&token), module_prop); + return_code = OS_ModuleGetInfo_Impl(&token, module_prop); OS_ObjectIdRelease(&token); } @@ -425,7 +425,7 @@ int32 OS_ModuleSymbolLookup(osal_id_t module_id, cpuaddr *symbol_address, const { record = OS_OBJECT_TABLE_GET(OS_global_module_table, token); - return_code = OS_ModuleSymbolLookup_Impl(OS_ObjectIndexFromToken(&token), symbol_address, symbol_name); + return_code = OS_ModuleSymbolLookup_Impl(&token, symbol_address, symbol_name); if (return_code != OS_SUCCESS) { /* look for a static symbol that also matches this module name */ diff --git a/src/os/shared/src/osapi-mutex.c b/src/os/shared/src/osapi-mutex.c index 73c9adab1..e861ff667 100644 --- a/src/os/shared/src/osapi-mutex.c +++ b/src/os/shared/src/osapi-mutex.c @@ -113,7 +113,7 @@ int32 OS_MutSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 options) OS_OBJECT_INIT(token, mutex, obj_name, sem_name); /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_MutSemCreate_Impl(OS_ObjectIndexFromToken(&token), options); + return_code = OS_MutSemCreate_Impl(&token, options); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, sem_id); @@ -139,7 +139,7 @@ int32 OS_MutSemDelete(osal_id_t sem_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, sem_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_MutSemDelete_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_MutSemDelete_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -180,7 +180,7 @@ int32 OS_MutSemGive(osal_id_t sem_id) mutex->last_owner = OS_OBJECT_ID_UNDEFINED; - return_code = OS_MutSemGive_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_MutSemGive_Impl(&token); } return return_code; @@ -208,7 +208,7 @@ int32 OS_MutSemTake(osal_id_t sem_id) { mutex = OS_OBJECT_TABLE_GET(OS_mutex_table, token); - return_code = OS_MutSemTake_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_MutSemTake_Impl(&token); if (return_code == OS_SUCCESS) { self_task = OS_TaskGetId(); @@ -281,7 +281,7 @@ int32 OS_MutSemGetInfo(osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop) strncpy(mut_prop->name, record->name_entry, OS_MAX_API_NAME - 1); mut_prop->creator = record->creator; - return_code = OS_MutSemGetInfo_Impl(OS_ObjectIndexFromToken(&token), mut_prop); + return_code = OS_MutSemGetInfo_Impl(&token, mut_prop); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-printf.c b/src/os/shared/src/osapi-printf.c index edcc033b5..780476a72 100644 --- a/src/os/shared/src/osapi-printf.c +++ b/src/os/shared/src/osapi-printf.c @@ -99,7 +99,7 @@ int32 OS_ConsoleAPI_Init(void) console->BufBase = OS_printf_buffer_mem; console->BufSize = sizeof(OS_printf_buffer_mem); - return_code = OS_ConsoleCreate_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_ConsoleCreate_Impl(&token); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, &OS_SharedGlobalVars.PrintfConsoleId); @@ -233,7 +233,7 @@ int32 OS_ConsoleWrite(osal_id_t console_id, const char *Str) * This is done while still locked, so it can support * either a synchronous or asynchronous implementation. */ - OS_ConsoleWakeup_Impl(OS_ObjectIndexFromToken(&token)); + OS_ConsoleWakeup_Impl(&token); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-queue.c b/src/os/shared/src/osapi-queue.c index 0105db711..509680df7 100644 --- a/src/os/shared/src/osapi-queue.c +++ b/src/os/shared/src/osapi-queue.c @@ -122,7 +122,7 @@ int32 OS_QueueCreate(osal_id_t *queue_id, const char *queue_name, osal_blockcoun queue->max_size = data_size; /* Now call the OS-specific implementation. This reads info from the queue table. */ - return_code = OS_QueueCreate_Impl(OS_ObjectIndexFromToken(&token), flags); + return_code = OS_QueueCreate_Impl(&token, flags); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, queue_id); @@ -148,7 +148,7 @@ int32 OS_QueueDelete(osal_id_t queue_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, queue_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_QueueDelete_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_QueueDelete_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -194,7 +194,7 @@ int32 OS_QueueGet(osal_id_t queue_id, void *data, size_t size, size_t *size_copi } else { - return_code = OS_QueueGet_Impl(OS_ObjectIndexFromToken(&token), data, size, size_copied, timeout); + return_code = OS_QueueGet_Impl(&token, data, size, size_copied, timeout); } } } @@ -237,7 +237,7 @@ int32 OS_QueuePut(osal_id_t queue_id, const void *data, size_t size, uint32 flag } else { - return_code = OS_QueuePut_Impl(OS_ObjectIndexFromToken(&token), data, size, flags); + return_code = OS_QueuePut_Impl(&token, data, size, flags); } } } diff --git a/src/os/shared/src/osapi-select.c b/src/os/shared/src/osapi-select.c index cb759afb5..cecad98c0 100644 --- a/src/os/shared/src/osapi-select.c +++ b/src/os/shared/src/osapi-select.c @@ -69,7 +69,7 @@ int32 OS_SelectSingle(osal_id_t objid, uint32 *StateFlags, int32 msecs) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_STREAM, objid, &token); if (return_code == OS_SUCCESS) { - return_code = OS_SelectSingle_Impl(OS_ObjectIndexFromToken(&token), StateFlags, msecs); + return_code = OS_SelectSingle_Impl(&token, StateFlags, msecs); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-shell.c b/src/os/shared/src/osapi-shell.c index e35e103f2..62e182fcc 100644 --- a/src/os/shared/src/osapi-shell.c +++ b/src/os/shared/src/osapi-shell.c @@ -64,7 +64,7 @@ int32 OS_ShellOutputToFile(const char *Cmd, osal_id_t filedes) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_STREAM, filedes, &token); if (return_code == OS_SUCCESS) { - return_code = OS_ShellOutputToFile_Impl(OS_ObjectIndexFromToken(&token), Cmd); + return_code = OS_ShellOutputToFile_Impl(&token, Cmd); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-sockets.c b/src/os/shared/src/osapi-sockets.c index de9e9022b..99c2968ee 100644 --- a/src/os/shared/src/osapi-sockets.c +++ b/src/os/shared/src/osapi-sockets.c @@ -84,11 +84,13 @@ int32 OS_SocketAPI_Init(void) * Purpose: Local helper routine, not part of OSAL API. * *-----------------------------------------------------------------*/ -void OS_CreateSocketName(osal_index_t local_id, const OS_SockAddr_t *Addr, const char *parent_name) +void OS_CreateSocketName(const OS_object_token_t *token, const OS_SockAddr_t *Addr, const char *parent_name) { size_t len; uint16 port; - OS_stream_internal_record_t *sock = &OS_stream_table[local_id]; + OS_stream_internal_record_t *sock; + + sock = OS_OBJECT_TABLE_GET(OS_stream_table, *token); if (OS_SocketAddrToString_Impl(sock->stream_name, OS_MAX_API_NAME, Addr) != OS_SUCCESS) { @@ -142,7 +144,7 @@ int32 OS_SocketOpen(osal_id_t *sock_id, OS_SocketDomain_t Domain, OS_SocketType_ stream->socket_type = Type; /* Now call the OS-specific implementation. This reads info from the table. */ - return_code = OS_SocketOpen_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_SocketOpen_Impl(&token); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, sock_id); @@ -190,11 +192,11 @@ int32 OS_SocketBind(osal_id_t sock_id, const OS_SockAddr_t *Addr) } else { - return_code = OS_SocketBind_Impl(OS_ObjectIndexFromToken(&token), Addr); + return_code = OS_SocketBind_Impl(&token, Addr); if (return_code == OS_SUCCESS) { - OS_CreateSocketName(OS_ObjectIndexFromToken(&token), Addr, NULL); + OS_CreateSocketName(&token, Addr, NULL); record->name_entry = stream->stream_name; stream->stream_state |= OS_STREAM_STATE_BOUND; } @@ -290,8 +292,7 @@ int32 OS_SocketAccept(osal_id_t sock_id, osal_id_t *connsock_id, OS_SockAddr_t * OS_SocketAddrInit_Impl(Addr, sock->socket_domain); /* The actual accept impl is done without global table lock, only refcount lock */ - return_code = OS_SocketAccept_Impl(OS_ObjectIndexFromToken(&sock_token), OS_ObjectIndexFromToken(&conn_token), - Addr, timeout); + return_code = OS_SocketAccept_Impl(&sock_token, &conn_token, Addr, timeout); } if (conn_record != NULL) @@ -301,7 +302,7 @@ int32 OS_SocketAccept(osal_id_t sock_id, osal_id_t *connsock_id, OS_SockAddr_t * if (return_code == OS_SUCCESS) { /* Generate an entry name based on the remote address */ - OS_CreateSocketName(OS_ObjectIndexFromToken(&conn_token), Addr, sock_record->name_entry); + OS_CreateSocketName(&conn_token, Addr, sock_record->name_entry); conn_record->name_entry = conn->stream_name; conn->stream_state |= OS_STREAM_STATE_CONNECTED; } @@ -367,7 +368,7 @@ int32 OS_SocketConnect(osal_id_t sock_id, const OS_SockAddr_t *Addr, int32 Timeo if (return_code == OS_SUCCESS) { - return_code = OS_SocketConnect_Impl(OS_ObjectIndexFromToken(&token), Addr, Timeout); + return_code = OS_SocketConnect_Impl(&token, Addr, Timeout); OS_Lock_Global(LOCAL_OBJID_TYPE); if (return_code == OS_SUCCESS) @@ -417,7 +418,7 @@ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, size_t buflen, OS_SockA } else { - return_code = OS_SocketRecvFrom_Impl(OS_ObjectIndexFromToken(&token), buffer, buflen, RemoteAddr, timeout); + return_code = OS_SocketRecvFrom_Impl(&token, buffer, buflen, RemoteAddr, timeout); } OS_ObjectIdRelease(&token); @@ -457,7 +458,7 @@ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, size_t buflen, cons } else { - return_code = OS_SocketSendTo_Impl(OS_ObjectIndexFromToken(&token), buffer, buflen, RemoteAddr); + return_code = OS_SocketSendTo_Impl(&token, buffer, buflen, RemoteAddr); } OS_ObjectIdRelease(&token); @@ -518,7 +519,7 @@ int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop) strncpy(sock_prop->name, record->name_entry, OS_MAX_API_NAME - 1); sock_prop->creator = record->creator; - return_code = OS_SocketGetInfo_Impl(OS_ObjectIndexFromToken(&token), sock_prop); + return_code = OS_SocketGetInfo_Impl(&token, sock_prop); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-task.c b/src/os/shared/src/osapi-task.c index 88777744b..54738a855 100644 --- a/src/os/shared/src/osapi-task.c +++ b/src/os/shared/src/osapi-task.c @@ -90,7 +90,7 @@ static int32 OS_TaskPrepare(osal_id_t task_id, osal_task_entry *entrypt) { task = OS_OBJECT_TABLE_GET(OS_task_table, token); - return_code = OS_TaskMatch_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_TaskMatch_Impl(&token); *entrypt = task->entry_function_pointer; OS_ObjectIdRelease(&token); @@ -213,7 +213,7 @@ int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry f task->stack_pointer = stack_pointer; /* Now call the OS-specific implementation. This reads info from the task table. */ - return_code = OS_TaskCreate_Impl(OS_ObjectIndexFromToken(&token), flags); + return_code = OS_TaskCreate_Impl(&token, flags); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, task_id); @@ -246,7 +246,7 @@ int32 OS_TaskDelete(osal_id_t task_id) /* Save the delete hook, as we do not want to call it while locked */ delete_hook = task->delete_hook_pointer; - return_code = OS_TaskDelete_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_TaskDelete_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -322,7 +322,7 @@ int32 OS_TaskSetPriority(osal_id_t task_id, osal_priority_t new_priority) { task = OS_OBJECT_TABLE_GET(OS_task_table, token); - return_code = OS_TaskSetPriority_Impl(OS_ObjectIndexFromToken(&token), new_priority); + return_code = OS_TaskSetPriority_Impl(&token, new_priority); if (return_code == OS_SUCCESS) { @@ -442,7 +442,7 @@ int32 OS_TaskGetInfo(osal_id_t task_id, OS_task_prop_t *task_prop) task_prop->stack_size = task->stack_size; task_prop->priority = task->priority; - return_code = OS_TaskGetInfo_Impl(OS_ObjectIndexFromToken(&token), task_prop); + return_code = OS_TaskGetInfo_Impl(&token, task_prop); OS_ObjectIdRelease(&token); } diff --git a/src/os/shared/src/osapi-time.c b/src/os/shared/src/osapi-time.c index ed79e9bca..6c78ea160 100644 --- a/src/os/shared/src/osapi-time.c +++ b/src/os/shared/src/osapi-time.c @@ -173,7 +173,7 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ * Now we need to add it to the time base callback ring, so take the * timebase-specific lock to prevent a tick from being processed at this moment. */ - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&timebase_token)); + OS_TimeBaseLock_Impl(&timebase_token); cb_list = timebase->first_cb; timebase->first_cb = OS_ObjectIdFromToken(&timecb_token); @@ -187,7 +187,7 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ OS_timecb_table[timecb->next_ref].prev_ref = OS_ObjectIndexFromToken(&timecb_token); } - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&timebase_token)); + OS_TimeBaseUnlock_Impl(&timebase_token); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &timecb_token, timer_id); @@ -349,7 +349,7 @@ int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) { timecb = OS_OBJECT_TABLE_GET(OS_timecb_table, token); - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); + OS_TimeBaseLock_Impl(&timecb->timebase_token); if ((timecb->flags & TIMECB_FLAG_DEDICATED_TIMEBASE) != 0) { @@ -359,7 +359,7 @@ int32 OS_TimerSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time) timecb->wait_time = (int32)start_time; timecb->interval_time = (int32)interval_time; - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); + OS_TimeBaseUnlock_Impl(&timecb->timebase_token); OS_ObjectIdRelease(&token); } @@ -423,7 +423,7 @@ int32 OS_TimerDelete(osal_id_t timer_id) OS_ObjectIdTransferToken(&timecb->timebase_token, &timebase_token); - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); + OS_TimeBaseLock_Impl(&timecb->timebase_token); /* * If the timer uses a dedicated time base, then also delete that. @@ -456,7 +456,7 @@ int32 OS_TimerDelete(osal_id_t timer_id) timecb->next_ref = OS_ObjectIndexFromToken(&timecb_token); timecb->prev_ref = OS_ObjectIndexFromToken(&timecb_token); - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&timecb->timebase_token)); + OS_TimeBaseUnlock_Impl(&timecb->timebase_token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &timecb_token); diff --git a/src/os/shared/src/osapi-timebase.c b/src/os/shared/src/osapi-timebase.c index 491bf4d6f..62e935a95 100644 --- a/src/os/shared/src/osapi-timebase.c +++ b/src/os/shared/src/osapi-timebase.c @@ -155,7 +155,7 @@ int32 OS_TimeBaseCreate(osal_id_t *timer_id, const char *timebase_name, OS_Timer } /* Now call the OS-specific implementation. This reads info from the timer table. */ - return_code = OS_TimeBaseCreate_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_TimeBaseCreate_Impl(&token); /* Check result, finalize record, and unlock global table. */ return_code = OS_ObjectIdFinalizeNew(return_code, &token, timer_id); @@ -208,9 +208,9 @@ int32 OS_TimeBaseSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, token); /* Need to take the time base lock to ensure that no ticks are currently being processed */ - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&token)); + OS_TimeBaseLock_Impl(&token); - return_code = OS_TimeBaseSet_Impl(OS_ObjectIndexFromToken(&token), start_time, interval_time); + return_code = OS_TimeBaseSet_Impl(&token, start_time, interval_time); if (return_code == OS_SUCCESS) { @@ -219,7 +219,7 @@ int32 OS_TimeBaseSet(osal_id_t timer_id, uint32 start_time, uint32 interval_time timebase->nominal_interval_time = interval_time; } - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&token)); + OS_TimeBaseUnlock_Impl(&token); OS_ObjectIdRelease(&token); } @@ -254,7 +254,7 @@ int32 OS_TimeBaseDelete(osal_id_t timer_id) return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE, OS_OBJECT_TYPE_OS_TIMEBASE, timer_id, &token); if (return_code == OS_SUCCESS) { - return_code = OS_TimeBaseDelete_Impl(OS_ObjectIndexFromToken(&token)); + return_code = OS_TimeBaseDelete_Impl(&token); /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, &token); @@ -342,7 +342,7 @@ int32 OS_TimeBaseGetInfo(osal_id_t timebase_id, OS_timebase_prop_t *timebase_pro timebase_prop->freerun_time = timebase->freerun_time; timebase_prop->accuracy = timebase->accuracy_usec; - return_code = OS_TimeBaseGetInfo_Impl(OS_ObjectIndexFromToken(&token), timebase_prop); + return_code = OS_TimeBaseGetInfo_Impl(&token, timebase_prop); OS_ObjectIdRelease(&token); } @@ -438,7 +438,7 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) * Call the sync function - this will pend for some period of time * and return the amount of elapsed time in units of "timebase ticks" */ - tick_time = (*syncfunc)(OS_ObjectIndexFromToken(&token)); + tick_time = (*syncfunc)(timebase_id); /* * The returned tick_time should be nonzero. If the sync function @@ -480,7 +480,7 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) } } - OS_TimeBaseLock_Impl(OS_ObjectIndexFromToken(&token)); + OS_TimeBaseLock_Impl(&token); /* * After waiting, check that our ID still matches @@ -488,7 +488,7 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) */ if (!OS_ObjectIdEqual(timebase_id, record->active_id)) { - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&token)); + OS_TimeBaseUnlock_Impl(&token); break; } @@ -540,7 +540,7 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id) } while (curr_cb_local_id != timer_id); } - OS_TimeBaseUnlock_Impl(OS_ObjectIndexFromToken(&token)); + OS_TimeBaseUnlock_Impl(&token); } } /* end OS_TimeBase_CallbackThread */ diff --git a/src/os/vxworks/inc/os-vxworks.h b/src/os/vxworks/inc/os-vxworks.h index 997a12aaa..88bbe1826 100644 --- a/src/os/vxworks/inc/os-vxworks.h +++ b/src/os/vxworks/inc/os-vxworks.h @@ -94,7 +94,7 @@ int OS_VxWorks_ConsoleTask_Entry(int arg); uint32 OS_VxWorks_SigWait(osal_index_t local_id); int OS_VxWorks_TimeBaseTask(int arg); -void OS_VxWorks_RegisterTimer(osal_index_t local_id); +void OS_VxWorks_RegisterTimer(osal_id_t obj_id); void OS_VxWorks_UsecToTimespec(uint32 usecs, struct timespec *time_spec); int32 OS_VxWorks_GenericSemTake(SEM_ID vxid, int sys_ticks); diff --git a/src/os/vxworks/src/os-impl-binsem.c b/src/os/vxworks/src/os-impl-binsem.c index 0f90efd2b..4c9a1acd4 100644 --- a/src/os/vxworks/src/os-impl-binsem.c +++ b/src/os/vxworks/src/os-impl-binsem.c @@ -33,6 +33,7 @@ #include "os-impl-binsem.h" #include "os-shared-binsem.h" #include "os-shared-timebase.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -70,13 +71,16 @@ int32 OS_VxWorks_BinSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_BinSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options) { - SEM_ID tmp_sem_id; + SEM_ID tmp_sem_id; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); /* Initialize VxWorks Semaphore. * The memory for this sem is statically allocated. */ - tmp_sem_id = semBInitialize(OS_impl_bin_sem_table[sem_id].bmem, SEM_Q_PRIORITY, sem_initial_value); + tmp_sem_id = semBInitialize(impl->bmem, SEM_Q_PRIORITY, sem_initial_value); /* check if semBInitialize failed */ if (tmp_sem_id == (SEM_ID)0) @@ -85,7 +89,7 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 return OS_SEM_FAILURE; } - OS_impl_bin_sem_table[sem_id].vxid = tmp_sem_id; + impl->vxid = tmp_sem_id; return OS_SUCCESS; } /* end OS_BinSemCreate_Impl */ @@ -98,12 +102,16 @@ int32 OS_BinSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemDelete_Impl(osal_index_t sem_id) +int32 OS_BinSemDelete_Impl(const OS_object_token_t *token) { + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); + /* * As the memory for the sem is statically allocated, delete is a no-op. */ - OS_impl_bin_sem_table[sem_id].vxid = 0; + impl->vxid = 0; return OS_SUCCESS; } /* end OS_BinSemDelete_Impl */ @@ -116,10 +124,14 @@ int32 OS_BinSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGive_Impl(osal_index_t sem_id) +int32 OS_BinSemGive_Impl(const OS_object_token_t *token) { + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); + /* Use common routine */ - return OS_VxWorks_GenericSemGive(OS_impl_bin_sem_table[sem_id].vxid); + return OS_VxWorks_GenericSemGive(impl->vxid); } /* end OS_BinSemGive_Impl */ /*---------------------------------------------------------------- @@ -130,10 +142,14 @@ int32 OS_BinSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemFlush_Impl(osal_index_t sem_id) +int32 OS_BinSemFlush_Impl(const OS_object_token_t *token) { + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); + /* Flush VxWorks Semaphore */ - if (semFlush(OS_impl_bin_sem_table[sem_id].vxid) != OK) + if (semFlush(impl->vxid) != OK) { OS_DEBUG("semFlush() - vxWorks errno %d\n", errno); return OS_SEM_FAILURE; @@ -150,10 +166,14 @@ int32 OS_BinSemFlush_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTake_Impl(osal_index_t sem_id) +int32 OS_BinSemTake_Impl(const OS_object_token_t *token) { + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); + /* Use common routine */ - return OS_VxWorks_GenericSemTake(OS_impl_bin_sem_table[sem_id].vxid, WAIT_FOREVER); + return OS_VxWorks_GenericSemTake(impl->vxid, WAIT_FOREVER); } /* end OS_BinSemTake_Impl */ @@ -165,16 +185,19 @@ int32 OS_BinSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) +int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) { - int ticks; - int32 status; + int ticks; + int32 status; + OS_impl_binsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token); status = OS_Milli2Ticks(msecs, &ticks); if (status == OS_SUCCESS) { - status = OS_VxWorks_GenericSemTake(OS_impl_bin_sem_table[sem_id].vxid, ticks); + status = OS_VxWorks_GenericSemTake(impl->vxid, ticks); } return status; @@ -188,7 +211,7 @@ int32 OS_BinSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_BinSemGetInfo_Impl(osal_index_t sem_id, OS_bin_sem_prop_t *bin_prop) +int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop) { /* VxWorks has no API for obtaining the current value of a semaphore */ return OS_SUCCESS; diff --git a/src/os/vxworks/src/os-impl-console.c b/src/os/vxworks/src/os-impl-console.c index 7accef4bb..0a8bbe886 100644 --- a/src/os/vxworks/src/os-impl-console.c +++ b/src/os/vxworks/src/os-impl-console.c @@ -32,6 +32,7 @@ #include "os-impl-console.h" #include "os-shared-printf.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -66,9 +67,11 @@ OS_impl_console_internal_record_t OS_impl_console_table[OS_MAX_CONSOLES]; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ConsoleWakeup_Impl(osal_index_t local_id) +void OS_ConsoleWakeup_Impl(const OS_object_token_t *token) { - OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; + OS_impl_console_internal_record_t *local; + + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, *token); if (local->is_async) { @@ -81,7 +84,7 @@ void OS_ConsoleWakeup_Impl(osal_index_t local_id) else { /* output directly */ - OS_ConsoleOutput_Impl(local_id); + OS_ConsoleOutput_Impl(token); } } /* end OS_ConsoleWakeup_Impl */ @@ -94,18 +97,23 @@ void OS_ConsoleWakeup_Impl(osal_index_t local_id) *-----------------------------------------------------------------*/ int OS_VxWorks_ConsoleTask_Entry(int arg) { - osal_index_t local_id = OSAL_INDEX_C(arg); OS_impl_console_internal_record_t *local; + OS_object_token_t token; - local = &OS_impl_console_table[local_id]; - while (true) + if (OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_CONSOLE, OS_ObjectIdFromInteger(arg), &token) == + OS_SUCCESS) { - OS_ConsoleOutput_Impl(local_id); - if (semTake(local->datasem, WAIT_FOREVER) == ERROR) + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token); + while (true) { - OS_DEBUG("semTake() - vxWorks errno %d\n", errno); - break; + OS_ConsoleOutput_Impl(&token); + if (semTake(local->datasem, WAIT_FOREVER) == ERROR) + { + OS_DEBUG("semTake() - vxWorks errno %d\n", errno); + break; + } } + OS_ObjectIdRelease(&token); } return OK; @@ -119,12 +127,16 @@ int OS_VxWorks_ConsoleTask_Entry(int arg) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ConsoleCreate_Impl(osal_index_t local_id) +int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token) { - OS_impl_console_internal_record_t *local = &OS_impl_console_table[local_id]; + OS_impl_console_internal_record_t *local; int32 return_code; + OS_console_internal_record_t * console; + + local = OS_OBJECT_TABLE_GET(OS_impl_console_table, *token); + console = OS_OBJECT_TABLE_GET(OS_console_table, *token); - if (local_id == 0) + if (OS_ObjectIndexFromToken(token) == 0) { return_code = OS_SUCCESS; local->is_async = OS_CONSOLE_ASYNC; @@ -145,9 +157,9 @@ int32 OS_ConsoleCreate_Impl(osal_index_t local_id) } /* spawn the async output helper task */ - local->taskid = taskSpawn(OS_console_table[local_id].device_name, OS_CONSOLE_TASK_PRIORITY, 0, - OS_CONSOLE_TASK_STACKSIZE, (FUNCPTR)OS_VxWorks_ConsoleTask_Entry, local_id, 0, 0, - 0, 0, 0, 0, 0, 0, 0); + local->taskid = taskSpawn(console->device_name, OS_CONSOLE_TASK_PRIORITY, 0, OS_CONSOLE_TASK_STACKSIZE, + (FUNCPTR)OS_VxWorks_ConsoleTask_Entry, + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), 0, 0, 0, 0, 0, 0, 0, 0, 0); if (local->taskid == (TASK_ID)ERROR) { diff --git a/src/os/vxworks/src/os-impl-countsem.c b/src/os/vxworks/src/os-impl-countsem.c index 41cff591d..3f4ef65e7 100644 --- a/src/os/vxworks/src/os-impl-countsem.c +++ b/src/os/vxworks/src/os-impl-countsem.c @@ -32,6 +32,7 @@ #include "os-impl-countsem.h" #include "os-shared-countsem.h" #include "os-shared-timebase.h" +#include "os-shared-idmap.h" /**************************************************************************************** DEFINES @@ -69,13 +70,16 @@ int32 OS_VxWorks_CountSemAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint32 options) +int32 OS_CountSemCreate_Impl(const OS_object_token_t *token, uint32 sem_initial_value, uint32 options) { - SEM_ID tmp_sem_id; + SEM_ID tmp_sem_id; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); /* Initialize VxWorks Semaphore. * The memory for this sem is statically allocated. */ - tmp_sem_id = semCInitialize(OS_impl_count_sem_table[sem_id].cmem, SEM_Q_PRIORITY, sem_initial_value); + tmp_sem_id = semCInitialize(impl->cmem, SEM_Q_PRIORITY, sem_initial_value); /* check if semCInitialize failed */ if (tmp_sem_id == (SEM_ID)0) @@ -84,7 +88,7 @@ int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint return OS_SEM_FAILURE; } - OS_impl_count_sem_table[sem_id].vxid = tmp_sem_id; + impl->vxid = tmp_sem_id; return OS_SUCCESS; } /* end OS_CountSemCreate_Impl */ @@ -97,12 +101,16 @@ int32 OS_CountSemCreate_Impl(osal_index_t sem_id, uint32 sem_initial_value, uint * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemDelete_Impl(osal_index_t sem_id) +int32 OS_CountSemDelete_Impl(const OS_object_token_t *token) { + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + /* * As the memory for the sem is statically allocated, delete is a no-op. */ - OS_impl_count_sem_table[sem_id].vxid = 0; + impl->vxid = 0; return OS_SUCCESS; } /* end OS_CountSemDelete_Impl */ @@ -115,10 +123,14 @@ int32 OS_CountSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGive_Impl(osal_index_t sem_id) +int32 OS_CountSemGive_Impl(const OS_object_token_t *token) { + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + /* Give VxWorks Semaphore */ - return OS_VxWorks_GenericSemGive(OS_impl_count_sem_table[sem_id].vxid); + return OS_VxWorks_GenericSemGive(impl->vxid); } /* end OS_CountSemGive_Impl */ /*---------------------------------------------------------------- @@ -129,9 +141,13 @@ int32 OS_CountSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTake_Impl(osal_index_t sem_id) +int32 OS_CountSemTake_Impl(const OS_object_token_t *token) { - return OS_VxWorks_GenericSemTake(OS_impl_count_sem_table[sem_id].vxid, WAIT_FOREVER); + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); + + return OS_VxWorks_GenericSemTake(impl->vxid, WAIT_FOREVER); } /* end OS_CountSemTake_Impl */ /*---------------------------------------------------------------- @@ -142,16 +158,19 @@ int32 OS_CountSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) +int32 OS_CountSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs) { - int ticks; - int32 status; + int ticks; + int32 status; + OS_impl_countsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_count_sem_table, *token); status = OS_Milli2Ticks(msecs, &ticks); if (status == OS_SUCCESS) { - status = OS_VxWorks_GenericSemTake(OS_impl_count_sem_table[sem_id].vxid, ticks); + status = OS_VxWorks_GenericSemTake(impl->vxid, ticks); } return status; @@ -165,7 +184,7 @@ int32 OS_CountSemTimedWait_Impl(osal_index_t sem_id, uint32 msecs) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_CountSemGetInfo_Impl(osal_index_t sem_id, OS_count_sem_prop_t *count_prop) +int32 OS_CountSemGetInfo_Impl(const OS_object_token_t *token, OS_count_sem_prop_t *count_prop) { /* VxWorks does not provide an API to get the value */ return OS_SUCCESS; diff --git a/src/os/vxworks/src/os-impl-dirs.c b/src/os/vxworks/src/os-impl-dirs.c index 513b8b878..e20da3b87 100644 --- a/src/os/vxworks/src/os-impl-dirs.c +++ b/src/os/vxworks/src/os-impl-dirs.c @@ -32,6 +32,7 @@ #include "os-vxworks.h" #include "os-impl-dirs.h" #include "os-shared-dir.h" +#include "os-shared-idmap.h" /* * The directory handle table. @@ -83,10 +84,14 @@ int32 OS_DirCreate_Impl(const char *local_path, uint32 access) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirOpen_Impl(osal_index_t local_id, const char *local_path) +int32 OS_DirOpen_Impl(const OS_object_token_t *token, const char *local_path) { - OS_impl_dir_table[local_id].dp = opendir(local_path); - if (OS_impl_dir_table[local_id].dp == NULL) + OS_impl_dir_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); + + impl->dp = opendir(local_path); + if (impl->dp == NULL) { return OS_ERROR; } @@ -101,10 +106,14 @@ int32 OS_DirOpen_Impl(osal_index_t local_id, const char *local_path) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirClose_Impl(osal_index_t local_id) +int32 OS_DirClose_Impl(const OS_object_token_t *token) { - closedir(OS_impl_dir_table[local_id].dp); - OS_impl_dir_table[local_id].dp = NULL; + OS_impl_dir_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); + + closedir(impl->dp); + impl->dp = NULL; return OS_SUCCESS; } /* end OS_DirClose_Impl */ @@ -116,9 +125,12 @@ int32 OS_DirClose_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent) +int32 OS_DirRead_Impl(const OS_object_token_t *token, os_dirent_t *dirent) { - struct dirent *de; + struct dirent * de; + OS_impl_dir_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); /* NOTE - the readdir() call is non-reentrant .... * However, this is performed while the global dir table lock is taken. @@ -129,7 +141,7 @@ int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent) */ /* cppcheck-suppress readdirCalled */ /* cppcheck-suppress nonreentrantFunctionsreaddir */ - de = readdir(OS_impl_dir_table[local_id].dp); + de = readdir(impl->dp); if (de == NULL) { return OS_ERROR; @@ -149,9 +161,13 @@ int32 OS_DirRead_Impl(osal_index_t local_id, os_dirent_t *dirent) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_DirRewind_Impl(osal_index_t local_id) +int32 OS_DirRewind_Impl(const OS_object_token_t *token) { - rewinddir(OS_impl_dir_table[local_id].dp); + OS_impl_dir_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_dir_table, *token); + + rewinddir(impl->dp); return OS_SUCCESS; } /* end OS_DirRewind_Impl */ diff --git a/src/os/vxworks/src/os-impl-filesys.c b/src/os/vxworks/src/os-impl-filesys.c index 2876348e4..5a7080c6e 100644 --- a/src/os/vxworks/src/os-impl-filesys.c +++ b/src/os/vxworks/src/os-impl-filesys.c @@ -76,12 +76,15 @@ OS_impl_filesys_internal_record_t OS_impl_filesys_table[OS_MAX_FILE_SYSTEMS]; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_filesys_internal_record_t * local; + OS_impl_filesys_internal_record_t *impl; int32 return_code; + impl = OS_OBJECT_TABLE_GET(OS_impl_filesys_table, *token); + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + memset(impl, 0, sizeof(*impl)); return_code = OS_ERR_NOT_IMPLEMENTED; switch (local->fstype) @@ -192,10 +195,13 @@ int32 OS_FileSysStartVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysStopVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t * local = &OS_filesys_table[filesys_id]; - OS_impl_filesys_internal_record_t *impl = &OS_impl_filesys_table[filesys_id]; + OS_filesys_internal_record_t * local; + OS_impl_filesys_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_filesys_table, *token); + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); switch (local->fstype) { @@ -231,12 +237,14 @@ int32 OS_FileSysStopVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysFormatVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; int32 return_code = OS_ERR_NOT_IMPLEMENTED; int status; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + switch (local->fstype) { case OS_FILESYS_TYPE_FS_BASED: @@ -282,12 +290,14 @@ int32 OS_FileSysFormatVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysMountVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; int32 status; int fd; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + /* * Calling open() on the physical device path * mounts the device. @@ -315,12 +325,14 @@ int32 OS_FileSysMountVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id) +int32 OS_FileSysUnmountVolume_Impl(const OS_object_token_t *token) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; int32 status; int fd; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + /* ** vxWorks uses an ioctl to unmount */ @@ -355,12 +367,14 @@ int32 OS_FileSysUnmountVolume_Impl(osal_index_t filesys_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(const OS_object_token_t *token, OS_statvfs_t *result) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; struct statfs stat_buf; int return_code; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + if (statfs(local->system_mountpt, &stat_buf) != 0) { return_code = OS_ERROR; @@ -386,13 +400,15 @@ int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FileSysCheckVolume_Impl(osal_index_t filesys_id, bool repair) +int32 OS_FileSysCheckVolume_Impl(const OS_object_token_t *token, bool repair) { - OS_filesys_internal_record_t *local = &OS_filesys_table[filesys_id]; + OS_filesys_internal_record_t *local; STATUS chk_status; int flags; int fd; + local = OS_OBJECT_TABLE_GET(OS_filesys_table, *token); + fd = open(local->system_mountpt, O_RDONLY, 0); if (fd < 0) { diff --git a/src/os/vxworks/src/os-impl-loader.c b/src/os/vxworks/src/os-impl-loader.c index ba9a607c2..49e693be4 100644 --- a/src/os/vxworks/src/os-impl-loader.c +++ b/src/os/vxworks/src/os-impl-loader.c @@ -32,6 +32,7 @@ #include "os-vxworks.h" #include "os-impl-loader.h" #include "os-shared-module.h" +#include "os-shared-idmap.h" #include #include @@ -71,11 +72,14 @@ int32 OS_VxWorks_ModuleAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl(osal_index_t local_id, const char *translated_path) +int32 OS_ModuleLoad_Impl(const OS_object_token_t *token, const char *translated_path) { - int32 return_code; - int fd; - MODULE_ID vxModuleId; + int32 return_code; + int fd; + MODULE_ID vxModuleId; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); /* ** File is ready to load @@ -104,8 +108,8 @@ int32 OS_ModuleLoad_Impl(osal_index_t local_id, const char *translated_path) } else { - OS_impl_module_table[local_id].moduleID = vxModuleId; - return_code = OS_SUCCESS; + impl->moduleID = vxModuleId; + return_code = OS_SUCCESS; } /* @@ -126,14 +130,17 @@ int32 OS_ModuleLoad_Impl(osal_index_t local_id, const char *translated_path) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload_Impl(osal_index_t local_id) +int32 OS_ModuleUnload_Impl(const OS_object_token_t *token) { - STATUS vxStatus; + STATUS vxStatus; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); /* ** Attempt to close/unload the module */ - vxStatus = unldByModuleId(OS_impl_module_table[local_id].moduleID, 0); + vxStatus = unldByModuleId(impl->moduleID, 0); if (vxStatus == ERROR) { OS_DEBUG("OSAL: Error, Cannot Close/Unload application file: %d\n", vxStatus); @@ -152,17 +159,20 @@ int32 OS_ModuleUnload_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleGetInfo_Impl(osal_index_t local_id, OS_module_prop_t *module_prop) +int32 OS_ModuleGetInfo_Impl(const OS_object_token_t *token, OS_module_prop_t *module_prop) { - MODULE_INFO vxModuleInfo; - STATUS vxStatus; + MODULE_INFO vxModuleInfo; + STATUS vxStatus; + OS_impl_module_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token); - module_prop->host_module_id = (cpuaddr)OS_impl_module_table[local_id].moduleID; + module_prop->host_module_id = (cpuaddr)impl->moduleID; /* ** Get the module info from vxWorks */ - vxStatus = moduleInfoGet(OS_impl_module_table[local_id].moduleID, &vxModuleInfo); + vxStatus = moduleInfoGet(impl->moduleID, &vxModuleInfo); if (vxStatus == ERROR) { OS_DEBUG("OSAL: OS_ModuleInfoGet Error from vxWorks: %d\n", vxStatus); diff --git a/src/os/vxworks/src/os-impl-mutex.c b/src/os/vxworks/src/os-impl-mutex.c index 72e09afe5..d044e5bed 100644 --- a/src/os/vxworks/src/os-impl-mutex.c +++ b/src/os/vxworks/src/os-impl-mutex.c @@ -32,6 +32,7 @@ #include "os-impl-mutex.h" #include "os-shared-mutex.h" +#include "os-shared-idmap.h" #include @@ -67,13 +68,16 @@ int32 OS_VxWorks_MutexAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) +int32 OS_MutSemCreate_Impl(const OS_object_token_t *token, uint32 options) { - SEM_ID tmp_sem_id; + SEM_ID tmp_sem_id; + OS_impl_mutsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); /* Initialize VxWorks Semaphore. * The memory for this sem is statically allocated. */ - tmp_sem_id = semMInitialize(OS_impl_mutex_table[sem_id].mmem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); + tmp_sem_id = semMInitialize(impl->mmem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); if (tmp_sem_id == (SEM_ID)0) { @@ -81,7 +85,7 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) return OS_SEM_FAILURE; } - OS_impl_mutex_table[sem_id].vxid = tmp_sem_id; + impl->vxid = tmp_sem_id; return OS_SUCCESS; } /* end OS_MutSemCreate_Impl */ @@ -93,12 +97,16 @@ int32 OS_MutSemCreate_Impl(osal_index_t sem_id, uint32 options) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemDelete_Impl(osal_index_t sem_id) +int32 OS_MutSemDelete_Impl(const OS_object_token_t *token) { + OS_impl_mutsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); + /* * As the memory for the sem is statically allocated, delete is a no-op. */ - OS_impl_mutex_table[sem_id].vxid = 0; + impl->vxid = 0; return OS_SUCCESS; } /* end OS_MutSemDelete_Impl */ @@ -111,10 +119,14 @@ int32 OS_MutSemDelete_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGive_Impl(osal_index_t sem_id) +int32 OS_MutSemGive_Impl(const OS_object_token_t *token) { + OS_impl_mutsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); + /* Give VxWorks Semaphore */ - return OS_VxWorks_GenericSemGive(OS_impl_mutex_table[sem_id].vxid); + return OS_VxWorks_GenericSemGive(impl->vxid); } /* end OS_MutSemGive_Impl */ /*---------------------------------------------------------------- @@ -125,10 +137,14 @@ int32 OS_MutSemGive_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemTake_Impl(osal_index_t sem_id) +int32 OS_MutSemTake_Impl(const OS_object_token_t *token) { + OS_impl_mutsem_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_mutex_table, *token); + /* Take VxWorks Semaphore */ - return OS_VxWorks_GenericSemTake(OS_impl_mutex_table[sem_id].vxid, WAIT_FOREVER); + return OS_VxWorks_GenericSemTake(impl->vxid, WAIT_FOREVER); } /* end OS_MutSemTake_Impl */ /*---------------------------------------------------------------- @@ -139,7 +155,7 @@ int32 OS_MutSemTake_Impl(osal_index_t sem_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_MutSemGetInfo_Impl(osal_index_t sem_id, OS_mut_sem_prop_t *mut_prop) +int32 OS_MutSemGetInfo_Impl(const OS_object_token_t *token, OS_mut_sem_prop_t *mut_prop) { /* VxWorks provides no additional info */ return OS_SUCCESS; diff --git a/src/os/vxworks/src/os-impl-queues.c b/src/os/vxworks/src/os-impl-queues.c index bbc95b175..99e8a3002 100644 --- a/src/os/vxworks/src/os-impl-queues.c +++ b/src/os/vxworks/src/os-impl-queues.c @@ -32,6 +32,7 @@ #include "os-impl-queues.h" #include "os-shared-queue.h" #include "os-shared-timebase.h" +#include "os-shared-idmap.h" /**************************************************************************************** GLOBAL DATA @@ -63,11 +64,19 @@ int32 OS_VxWorks_QueueAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) +int32 OS_QueueCreate_Impl(const OS_object_token_t *token, uint32 flags) { - MSG_Q_ID tmp_msgq_id; - int queue_depth = OS_queue_table[queue_id].max_depth; /* maximum number of messages in queue (queue depth) */ - int data_size = OS_queue_table[queue_id].max_size; /* maximum size in bytes of a message */ + MSG_Q_ID tmp_msgq_id; + int queue_depth; + int data_size; + OS_impl_queue_internal_record_t *impl; + OS_queue_internal_record_t * queue; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); + queue = OS_OBJECT_TABLE_GET(OS_queue_table, *token); + + queue_depth = queue->max_depth; /* maximum number of messages in queue (queue depth) */ + data_size = queue->max_size; /* maximum size in bytes of a message */ /* Create VxWorks Message Queue */ tmp_msgq_id = msgQCreate(queue_depth, data_size, MSG_Q_FIFO); @@ -79,7 +88,7 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) return OS_ERROR; } - OS_impl_queue_table[queue_id].vxid = tmp_msgq_id; + impl->vxid = tmp_msgq_id; return OS_SUCCESS; } /* end OS_QueueCreate_Impl */ @@ -92,16 +101,20 @@ int32 OS_QueueCreate_Impl(osal_index_t queue_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueDelete_Impl(osal_index_t queue_id) +int32 OS_QueueDelete_Impl(const OS_object_token_t *token) { + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); + /* Try to delete the queue */ - if (msgQDelete(OS_impl_queue_table[queue_id].vxid) != OK) + if (msgQDelete(impl->vxid) != OK) { OS_DEBUG("msgQDelete() - vxWorks errno %d\n", errno); return OS_ERROR; } - OS_impl_queue_table[queue_id].vxid = 0; + impl->vxid = 0; return OS_SUCCESS; } /* end OS_QueueDelete_Impl */ @@ -114,11 +127,14 @@ int32 OS_QueueDelete_Impl(osal_index_t queue_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *size_copied, int32 timeout) +int32 OS_QueueGet_Impl(const OS_object_token_t *token, void *data, size_t size, size_t *size_copied, int32 timeout) { - int32 return_code; - STATUS status; - int ticks; + int32 return_code; + STATUS status; + int ticks; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); /* Get Message From Message Queue */ if (timeout == OS_PEND) @@ -138,7 +154,7 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *s } } - status = msgQReceive(OS_impl_queue_table[queue_id].vxid, data, size, ticks); + status = msgQReceive(impl->vxid, data, size, ticks); if (status == ERROR) { @@ -174,11 +190,14 @@ int32 OS_QueueGet_Impl(osal_index_t queue_id, void *data, size_t size, size_t *s * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, size_t size, uint32 flags) +int32 OS_QueuePut_Impl(const OS_object_token_t *token, const void *data, size_t size, uint32 flags) { - int32 return_code; + int32 return_code; + OS_impl_queue_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_queue_table, *token); - if (msgQSend(OS_impl_queue_table[queue_id].vxid, (void *)data, size, NO_WAIT, MSG_PRI_NORMAL) == OK) + if (msgQSend(impl->vxid, (void *)data, size, NO_WAIT, MSG_PRI_NORMAL) == OK) { return_code = OS_SUCCESS; } @@ -204,7 +223,7 @@ int32 OS_QueuePut_Impl(osal_index_t queue_id, const void *data, size_t size, uin * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_QueueGetInfo_Impl(osal_index_t queue_id, OS_queue_prop_t *queue_prop) +int32 OS_QueueGetInfo_Impl(const OS_object_token_t *token, OS_queue_prop_t *queue_prop) { /* No extra info for queues in the OS implementation */ return OS_SUCCESS; diff --git a/src/os/vxworks/src/os-impl-shell.c b/src/os/vxworks/src/os-impl-shell.c index 2b942a41d..7fc9f3342 100644 --- a/src/os/vxworks/src/os-impl-shell.c +++ b/src/os/vxworks/src/os-impl-shell.c @@ -33,6 +33,7 @@ #include "os-impl-io.h" #include "os-shared-shell.h" #include "os-shared-file.h" +#include "os-shared-idmap.h" #include #include @@ -52,13 +53,15 @@ * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ShellOutputToFile_Impl(osal_index_t file_id, const char *Cmd) +int32 OS_ShellOutputToFile_Impl(const OS_object_token_t *token, const char *Cmd) { - int32 ReturnCode = OS_ERROR; - int32 Result; - osal_id_t fdCmd; - osal_index_t cmdidx; - char * shellName; + int32 ReturnCode = OS_ERROR; + int32 Result; + osal_id_t fdCmd; + char * shellName; + OS_impl_file_internal_record_t *out_impl; + OS_impl_file_internal_record_t *cmd_impl; + OS_object_token_t cmd_token; /* Create a file to write the command to (or write over the old one) */ Result = @@ -69,16 +72,18 @@ int32 OS_ShellOutputToFile_Impl(osal_index_t file_id, const char *Cmd) return Result; } - if (OS_ConvertToArrayIndex(fdCmd, &cmdidx) == OS_SUCCESS) + if (OS_ObjectIdGetById(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_STREAM, fdCmd, &cmd_token) == OS_SUCCESS) { + out_impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, *token); + cmd_impl = OS_OBJECT_TABLE_GET(OS_impl_filehandle_table, cmd_token); + /* copy the command to the file, and then seek back to the beginning of the file */ OS_write(fdCmd, Cmd, strlen(Cmd)); OS_lseek(fdCmd, 0, OS_SEEK_SET); /* Create a shell task the will run the command in the file, push output to OS_fd */ - Result = - shellGenericInit("INTERPRETER=Cmd", 0, NULL, &shellName, false, false, OS_impl_filehandle_table[cmdidx].fd, - OS_impl_filehandle_table[file_id].fd, OS_impl_filehandle_table[file_id].fd); + Result = shellGenericInit("INTERPRETER=Cmd", 0, NULL, &shellName, false, false, + cmd_impl->fd, out_impl->fd, out_impl->fd); } if (Result == OK) diff --git a/src/os/vxworks/src/os-impl-symtab.c b/src/os/vxworks/src/os-impl-symtab.c index be689df95..5dc9f94ee 100644 --- a/src/os/vxworks/src/os-impl-symtab.c +++ b/src/os/vxworks/src/os-impl-symtab.c @@ -119,7 +119,6 @@ int32 OS_GlobalSymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) return OS_GenericSymbolLookup_Impl(sysSymTbl, SymbolAddress, SymbolName); } /* end OS_GlobalSymbolLookup_Impl */ - /*---------------------------------------------------------------- * * Function: OS_ModuleSymbolLookup_Impl @@ -128,7 +127,7 @@ int32 OS_GlobalSymbolLookup_Impl(cpuaddr *SymbolAddress, const char *SymbolName) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleSymbolLookup_Impl(osal_index_t local_id, cpuaddr *SymbolAddress, const char *SymbolName) +int32 OS_ModuleSymbolLookup_Impl(const OS_object_token_t *token, cpuaddr *SymbolAddress, const char *SymbolName) { /* * NOTE: this is currently exactly the same as OS_GlobalSymbolLookup_Impl(). @@ -140,8 +139,6 @@ int32 OS_ModuleSymbolLookup_Impl(osal_index_t local_id, cpuaddr *SymbolAddress, return OS_GenericSymbolLookup_Impl(sysSymTbl, SymbolAddress, SymbolName); } /* end OS_ModuleSymbolLookup_Impl */ - - /*---------------------------------------------------------------- * * Function: OS_SymTableIterator_Impl diff --git a/src/os/vxworks/src/os-impl-tasks.c b/src/os/vxworks/src/os-impl-tasks.c index 83afb2922..ccb0e5a76 100644 --- a/src/os/vxworks/src/os-impl-tasks.c +++ b/src/os/vxworks/src/os-impl-tasks.c @@ -83,11 +83,7 @@ OS_impl_task_internal_record_t OS_impl_task_table[OS_MAX_TASKS]; ---------------------------------------------------------------------------------------*/ int OS_VxWorks_TaskEntry(int arg) { - VxWorks_ID_Buffer_t id; - - id.arg = arg; - - OS_TaskEntryPoint(id.id); + OS_TaskEntryPoint(OS_ObjectIdFromInteger(arg)); return 0; } /* end OS_VxWorksEntry */ @@ -117,7 +113,7 @@ int32 OS_VxWorks_TaskAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) +int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags) { STATUS status; int vxflags; @@ -126,9 +122,10 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) unsigned long userstackbase; unsigned long actualstackbase; OS_impl_task_internal_record_t *lrec; - VxWorks_ID_Buffer_t id; + OS_task_internal_record_t * task; - lrec = &OS_impl_task_table[task_id]; + lrec = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + task = OS_OBJECT_TABLE_GET(OS_task_table, *token); /* Create VxWorks Task */ @@ -145,9 +142,9 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) * Get priority/stack specs from main struct * priority should be a direct passthru */ - vxpri = OS_task_table[task_id].priority; - actualsz = OS_task_table[task_id].stack_size; - userstackbase = (unsigned long)OS_task_table[task_id].stack_pointer; + vxpri = task->priority; + actualsz = task->stack_size; + userstackbase = (unsigned long)task->stack_pointer; /* * NOTE: Using taskInit() here rather than taskSpawn() allows us @@ -237,14 +234,13 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) actualstackbase += actualsz; /* move to last byte of stack block */ #endif - id.id = OS_global_task_table[task_id].active_id; - status = taskInit(&lrec->tcb, /* address of new task's TCB */ - (char *)OS_global_task_table[task_id].name_entry, vxpri, /* priority of new task */ - vxflags, /* task option word */ - (char *)actualstackbase, /* base of new task's stack */ - actualsz, /* size (bytes) of stack needed */ - (FUNCPTR)OS_VxWorks_TaskEntry, /* entry point of new task */ - id.arg, /* 1st arg is ID */ + status = taskInit(&lrec->tcb, /* address of new task's TCB */ + (char *)task->task_name, vxpri, /* priority of new task */ + vxflags, /* task option word */ + (char *)actualstackbase, /* base of new task's stack */ + actualsz, /* size (bytes) of stack needed */ + (FUNCPTR)OS_VxWorks_TaskEntry, /* entry point of new task */ + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), /* 1st arg is ID */ 0, 0, 0, 0, 0, 0, 0, 0, 0); if (status != OK) @@ -268,21 +264,25 @@ int32 OS_TaskCreate_Impl(osal_index_t task_id, uint32 flags) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskDelete_Impl(osal_index_t task_id) +int32 OS_TaskDelete_Impl(const OS_object_token_t *token) { + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + /* ** Try to delete the task ** If this fails, not much recourse - the only potential cause of failure ** to cancel here is that the thread ID is invalid because it already exited itself, ** and if that is true there is nothing wrong - everything is OK to continue normally. */ - if (taskDelete(OS_impl_task_table[task_id].vxid) != OK) + if (taskDelete(impl->vxid) != OK) { OS_DEBUG("taskDelete() - vxWorks errno %d\n", errno); return OS_ERROR; } - OS_impl_task_table[task_id].vxid = 0; + impl->vxid = 0; return OS_SUCCESS; } /* end OS_TaskDelete_Impl */ @@ -336,10 +336,14 @@ int32 OS_TaskDelay_Impl(uint32 milli_second) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority) +int32 OS_TaskSetPriority_Impl(const OS_object_token_t *token, osal_priority_t new_priority) { + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + /* Set VxWorks Task Priority */ - if (taskPrioritySet(OS_impl_task_table[task_id].vxid, new_priority) != OK) + if (taskPrioritySet(impl->vxid, new_priority) != OK) { return OS_ERROR; } @@ -356,12 +360,16 @@ int32 OS_TaskSetPriority_Impl(osal_index_t task_id, osal_priority_t new_priority * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskMatch_Impl(osal_index_t task_id) +int32 OS_TaskMatch_Impl(const OS_object_token_t *token) { + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); + /* ** Get VxWorks Task Id */ - if (taskIdSelf() != OS_impl_task_table[task_id].vxid) + if (taskIdSelf() != impl->vxid) { return (OS_ERROR); } @@ -420,7 +428,7 @@ osal_id_t OS_TaskGetId_Impl(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TaskGetInfo_Impl(osal_index_t task_id, OS_task_prop_t *task_prop) +int32 OS_TaskGetInfo_Impl(const OS_object_token_t *token, OS_task_prop_t *task_prop) { return OS_SUCCESS; @@ -451,9 +459,12 @@ int32 OS_TaskValidateSystemData_Impl(const void *sysdata, size_t sysdata_size) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -bool OS_TaskIdMatchSystemData_Impl(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_TaskIdMatchSystemData_Impl(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { - const TASK_ID *target = (const TASK_ID *)ref; + const TASK_ID * target = (const TASK_ID *)ref; + OS_impl_task_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token); - return (*target == OS_impl_task_table[local_id].vxid); + return (*target == impl->vxid); } diff --git a/src/os/vxworks/src/os-impl-timebase.c b/src/os/vxworks/src/os-impl-timebase.c index 8b75c100d..04b90513e 100644 --- a/src/os/vxworks/src/os-impl-timebase.c +++ b/src/os/vxworks/src/os-impl-timebase.c @@ -93,9 +93,13 @@ static uint32 OS_ClockAccuracyNsec; * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_TimeBaseLock_Impl(osal_index_t local_id) +void OS_TimeBaseLock_Impl(const OS_object_token_t *token) { - semTake(OS_impl_timebase_table[local_id].handler_mutex, WAIT_FOREVER); + OS_impl_timebase_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + + semTake(impl->handler_mutex, WAIT_FOREVER); } /* end OS_TimeBaseLock_Impl */ /*---------------------------------------------------------------- @@ -106,9 +110,13 @@ void OS_TimeBaseLock_Impl(osal_index_t local_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -void OS_TimeBaseUnlock_Impl(osal_index_t local_id) +void OS_TimeBaseUnlock_Impl(const OS_object_token_t *token) { - semGive(OS_impl_timebase_table[local_id].handler_mutex); + OS_impl_timebase_internal_record_t *impl; + + impl = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + + semGive(impl->handler_mutex); } /* end OS_TimeBaseUnlock_Impl */ /*---------------------------------------------------------------- @@ -204,38 +212,42 @@ uint32 OS_VxWorks_SigWait(osal_index_t local_id) * Purpose: Local helper routine, not part of OSAL API. * *-----------------------------------------------------------------*/ -void OS_VxWorks_RegisterTimer(osal_index_t local_id) +void OS_VxWorks_RegisterTimer(osal_id_t obj_id) { OS_impl_timebase_internal_record_t *local; + OS_object_token_t token; struct sigevent evp; int status; - local = &OS_impl_timebase_table[local_id]; + if (OS_ObjectIdGetById(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TIMEBASE, obj_id, &token) == OS_SUCCESS) + { + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, token); - memset(&evp, 0, sizeof(evp)); - evp.sigev_notify = SIGEV_SIGNAL; - evp.sigev_signo = local->assigned_signal; + memset(&evp, 0, sizeof(evp)); + evp.sigev_notify = SIGEV_SIGNAL; + evp.sigev_signo = local->assigned_signal; - /* - ** Create the timer - ** - ** The result is not returned from this function, because - ** this is a different task context from the original creator. - ** - ** The registration status is returned through the OS_impl_timebase_table entry, - ** which is checked by the creator before returning. - ** - ** If set to ERROR, then this task will be subsequently deleted. - */ - status = timer_create(OS_PREFERRED_CLOCK, &evp, &local->host_timerid); - if (status < 0) - { - OS_DEBUG("timer_create() failed: errno=%d\n", errno); - local->timer_state = OS_TimerRegState_ERROR; - } - else - { - local->timer_state = OS_TimerRegState_SUCCESS; + /* + ** Create the timer + ** + ** The result is not returned from this function, because + ** this is a different task context from the original creator. + ** + ** The registration status is returned through the OS_impl_timebase_table entry, + ** which is checked by the creator before returning. + ** + ** If set to ERROR, then this task will be subsequently deleted. + */ + status = timer_create(OS_PREFERRED_CLOCK, &evp, &local->host_timerid); + if (status < 0) + { + OS_DEBUG("timer_create() failed: errno=%d\n", errno); + local->timer_state = OS_TimerRegState_ERROR; + } + else + { + local->timer_state = OS_TimerRegState_SUCCESS; + } } } /* end OS_VxWorks_RegisterTimer */ @@ -253,14 +265,10 @@ void OS_VxWorks_RegisterTimer(osal_index_t local_id) int OS_VxWorks_TimeBaseTask(int arg) { VxWorks_ID_Buffer_t id; - osal_index_t local_id; id.arg = arg; - if (OS_ConvertToArrayIndex(id.id, &local_id) == OS_SUCCESS) - { - OS_VxWorks_RegisterTimer(local_id); - OS_TimeBase_CallbackThread(id.id); - } + OS_VxWorks_RegisterTimer(id.id); + OS_TimeBase_CallbackThread(id.id); return 0; } /* end OS_VxWorks_TimeBaseTask */ @@ -323,7 +331,7 @@ int32 OS_VxWorks_TimeBaseAPI_Impl_Init(void) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) +int32 OS_TimeBaseCreate_Impl(const OS_object_token_t *token) { /* * The tick_sem is a simple semaphore posted by the ISR and taken by the @@ -331,7 +339,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) */ int32 return_code; OS_impl_timebase_internal_record_t *local; - OS_common_record_t * global; + OS_timebase_internal_record_t * timebase; int signo; sigset_t inuse; osal_index_t idx; @@ -339,8 +347,9 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) VxWorks_ID_Buffer_t idbuf; return_code = OS_SUCCESS; - local = &OS_impl_timebase_table[timer_id]; - global = &OS_global_timebase_table[timer_id]; + + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); + timebase = OS_OBJECT_TABLE_GET(OS_timebase_table, *token); sigemptyset(&local->timer_sigset); local->assigned_signal = 0; @@ -359,7 +368,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * If no external sync function is provided then this will set up a VxWorks * timer to locally simulate the timer tick using the CPU clock. */ - if (OS_timebase_table[timer_id].external_sync == NULL) + if (timebase->external_sync == NULL) { /* * find an RT signal that is not used by another time base object. @@ -411,7 +420,7 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) /* * Use local sigwait() wrapper as a sync function for the local task. */ - OS_timebase_table[timer_id].external_sync = OS_VxWorks_SigWait; + timebase->external_sync = OS_VxWorks_SigWait; } } @@ -444,9 +453,9 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) */ if (return_code == OS_SUCCESS) { - idbuf.id = global->active_id; - local->handler_task = taskSpawn((char *)global->name_entry, OSAL_TIMEBASE_TASK_PRIORITY, /* priority */ - OSAL_TIMEBASE_TASK_OPTION_WORD, /* task option word */ + idbuf.id = OS_ObjectIdFromToken(token); + local->handler_task = taskSpawn(timebase->timebase_name, OSAL_TIMEBASE_TASK_PRIORITY, /* priority */ + OSAL_TIMEBASE_TASK_OPTION_WORD, /* task option word */ OSAL_TIMEBASE_TASK_STACK_SIZE, /* size (bytes) of stack needed */ (FUNCPTR)OS_VxWorks_TimeBaseTask, idbuf.arg, /* 1st arg is ID */ 0, 0, 0, 0, 0, 0, 0, 0, 0); @@ -501,14 +510,14 @@ int32 OS_TimeBaseCreate_Impl(osal_index_t timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 interval_time) +int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uint32 interval_time) { OS_impl_timebase_internal_record_t *local; struct itimerspec timeout; int32 return_code; int status; - local = &OS_impl_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); /* There is only something to do here if we are generating a simulated tick */ if (local->assigned_signal <= 0) @@ -550,19 +559,19 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter if (status == OK) { local->configured_start_time = (timeout.it_value.tv_sec * 1000000) + (timeout.it_value.tv_nsec / 1000); - local->configured_interval_time = - (timeout.it_interval.tv_sec * 1000000) + (timeout.it_interval.tv_nsec / 1000); + local->configured_interval_time = (timeout.it_interval.tv_sec * 1000000) + + (timeout.it_interval.tv_nsec / 1000); if (local->configured_start_time != start_time) { OS_DEBUG("WARNING: timer %lu start_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, (unsigned long)start_time, + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), (unsigned long)start_time, (unsigned long)local->configured_start_time); } if (local->configured_interval_time != interval_time) { OS_DEBUG("WARNING: timer %lu interval_time requested=%luus, configured=%luus\n", - (unsigned long)timer_id, (unsigned long)interval_time, + OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), (unsigned long)interval_time, (unsigned long)local->configured_interval_time); } } @@ -589,12 +598,12 @@ int32 OS_TimeBaseSet_Impl(osal_index_t timer_id, uint32 start_time, uint32 inter * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) +int32 OS_TimeBaseDelete_Impl(const OS_object_token_t *token) { OS_impl_timebase_internal_record_t *local; int32 return_code; - local = &OS_impl_timebase_table[timer_id]; + local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, *token); return_code = OS_SUCCESS; /* An assigned_signal value indicates the OS timer needs deletion too */ @@ -623,7 +632,7 @@ int32 OS_TimeBaseDelete_Impl(osal_index_t timer_id) * See prototype for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_TimeBaseGetInfo_Impl(osal_index_t timer_id, OS_timebase_prop_t *timer_prop) +int32 OS_TimeBaseGetInfo_Impl(const OS_object_token_t *token, OS_timebase_prop_t *timer_prop) { return OS_SUCCESS; diff --git a/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c b/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c index b86fe134a..fd2f7951c 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c +++ b/src/unit-test-coverage/portable/src/coveragetest-bsd-select.c @@ -26,6 +26,7 @@ #include "os-portable-coveragetest.h" #include "ut-adaptor-portable-posix-io.h" #include "os-shared-select.h" +#include "os-shared-idmap.h" #include @@ -35,20 +36,21 @@ void Test_OS_SelectSingle_Impl(void) * int32 OS_SelectSingle_Impl(uint32 stream_id, uint32 *SelectFlags, int32 msecs) */ uint32 SelectFlags; - osal_index_t StreamID; + OS_object_token_t token; struct OCS_timespec nowtime; struct OCS_timespec latertime; - StreamID = UT_INDEX_0; + memset(&token, 0, sizeof(token)); + UT_PortablePosixIOTest_Set_Selectable(UT_INDEX_0, false); SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; - OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 0), OS_ERR_OPERATION_NOT_SUPPORTED); + OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (&token, &SelectFlags, 0), OS_ERR_OPERATION_NOT_SUPPORTED); UT_PortablePosixIOTest_Set_Selectable(UT_INDEX_0, true); - OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (&token, &SelectFlags, 0), OS_SUCCESS); SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; - OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, -1), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (&token, &SelectFlags, -1), OS_SUCCESS); SelectFlags = 0; - OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (&token, &SelectFlags, 0), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_select), 0); SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; @@ -58,7 +60,7 @@ void Test_OS_SelectSingle_Impl(void) latertime.tv_nsec = 0; UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &nowtime, sizeof(nowtime), false); UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &latertime, sizeof(latertime), false); - OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 999), OS_ERROR_TIMEOUT); + OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (&token, &SelectFlags, 999), OS_ERROR_TIMEOUT); UT_SetDefaultReturnValue(UT_KEY(OCS_select), -1); SelectFlags = OS_STREAM_STATE_READABLE | OS_STREAM_STATE_WRITABLE; @@ -68,7 +70,7 @@ void Test_OS_SelectSingle_Impl(void) latertime.tv_nsec = 600000000; UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &nowtime, sizeof(nowtime), false); UT_SetDataBuffer(UT_KEY(OCS_clock_gettime), &latertime, sizeof(latertime), false); - OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (StreamID, &SelectFlags, 2100), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_SelectSingle_Impl, (&token, &SelectFlags, 2100), OS_ERROR); } /* end OS_SelectSingle_Impl */ void Test_OS_SelectMultiple_Impl(void) diff --git a/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c b/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c index fc38f97a0..51727f590 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c +++ b/src/unit-test-coverage/portable/src/coveragetest-console-bsp.c @@ -27,6 +27,7 @@ #include "os-portable-coveragetest.h" #include "os-shared-printf.h" +#include "os-shared-idmap.h" #include #include @@ -37,8 +38,11 @@ const char TEST_BUF_INITIALIZER[1 + TEST_BUFFER_LEN] = "abcdefghijklmnop"; void Test_OS_ConsoleOutput_Impl(void) { - char TestConsoleBspBuffer[TEST_BUFFER_LEN]; - char TestOutputBuffer[32]; + char TestConsoleBspBuffer[TEST_BUFFER_LEN]; + char TestOutputBuffer[32]; + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); memcpy(TestConsoleBspBuffer, TEST_BUF_INITIALIZER, sizeof(TestConsoleBspBuffer)); memset(TestOutputBuffer, 0, sizeof(TestOutputBuffer)); @@ -49,11 +53,11 @@ void Test_OS_ConsoleOutput_Impl(void) UT_SetDataBuffer(UT_KEY(OCS_OS_BSP_ConsoleOutput_Impl), TestOutputBuffer, sizeof(TestOutputBuffer), false); OS_console_table[0].WritePos = 4; - OS_ConsoleOutput_Impl(0); + OS_ConsoleOutput_Impl(&token); UtAssert_True(strcmp(TestOutputBuffer, "abcd") == 0, "TestOutputBuffer (%s) == abcd", TestOutputBuffer); OS_console_table[0].WritePos = 2; - OS_ConsoleOutput_Impl(0); + OS_ConsoleOutput_Impl(&token); UtAssert_True(strcmp(TestOutputBuffer, "abcdefghijklmnopab") == 0, "TestOutputBuffer (%s) == abcdefghijklmnopab", TestOutputBuffer); } diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c index 372914b28..f6bb0788e 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c @@ -28,6 +28,7 @@ #include "ut-adaptor-portable-posix-files.h" #include "os-shared-file.h" +#include "os-shared-idmap.h" #include #include @@ -41,14 +42,18 @@ void Test_OS_FileOpen_Impl(void) * Test Case For: * int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access) */ - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", 0, OS_READ_ONLY), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", OS_FILE_FLAG_CREATE, OS_READ_WRITE), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", 0, -1234), OS_ERROR); + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); + + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (&token, "local", OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (&token, "local", 0, OS_READ_ONLY), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (&token, "local", OS_FILE_FLAG_CREATE, OS_READ_WRITE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (&token, "local", 0, -1234), OS_ERROR); /* failure mode */ UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (UT_INDEX_0, "local", 0, OS_READ_ONLY), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileOpen_Impl, (&token, "local", 0, OS_READ_ONLY), OS_ERROR); } void Test_OS_FileStat_Impl(void) diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c index b272d9792..f3c7ea87b 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c @@ -43,14 +43,18 @@ void Test_OS_GenericClose_Impl(void) * Test Case For: * int32 OS_GenericClose_Impl(uint32 local_id) */ - OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); + + OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (&token), OS_SUCCESS); /* * Test path where underlying close() fails. * Should still return success. */ UT_SetDefaultReturnValue(UT_KEY(OCS_close), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (UT_INDEX_0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_GenericClose_Impl, (&token), OS_SUCCESS); } void Test_OS_GenericSeek_Impl(void) @@ -59,25 +63,28 @@ void Test_OS_GenericSeek_Impl(void) * Test Case For: * int32 OS_GenericSeek_Impl (uint32 local_id, int32 offset, uint32 whence) */ + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); /* note on success this wrapper returns the result of lseek(), not OS_SUCCESS */ UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), 111); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_CUR), 111); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (&token, 0, OS_SEEK_CUR), 111); UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), 222); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_SET), 222); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (&token, 0, OS_SEEK_SET), 222); UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), 333); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_END), 333); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (&token, 0, OS_SEEK_END), 333); /* bad whence */ - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, 1234), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (&token, 0, 1234), OS_ERROR); /* generic failure of lseek() */ UT_SetDefaultReturnValue(UT_KEY(OCS_lseek), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_END), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (&token, 0, OS_SEEK_END), OS_ERROR); /* The seek implementation also checks for this specific pipe errno */ OCS_errno = OCS_ESPIPE; - OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (UT_INDEX_0, 0, OS_SEEK_END), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_GenericSeek_Impl, (&token, 0, OS_SEEK_END), OS_ERR_NOT_IMPLEMENTED); } void Test_OS_GenericRead_Impl(void) @@ -86,24 +93,27 @@ void Test_OS_GenericRead_Impl(void) * Test Case For: * int32 OS_GenericRead_Impl (uint32 local_id, void *buffer, uint32 nbytes, int32 timeout) */ - char SrcData[] = "ABCDEFGHIJK"; - char DestData[sizeof(SrcData)] = {0}; + char SrcData[] = "ABCDEFGHIJK"; + char DestData[sizeof(SrcData)] = {0}; + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); UT_SetDataBuffer(UT_KEY(OCS_read), SrcData, sizeof(SrcData), false); UT_PortablePosixIOTest_Set_Selectable(UT_INDEX_0, false); - OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (UT_INDEX_0, DestData, sizeof(DestData), 0), sizeof(DestData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (&token, DestData, sizeof(DestData), 0), sizeof(DestData)); UtAssert_MemCmp(SrcData, DestData, sizeof(SrcData), "read() data Valid"); /* test invocation of select() in nonblocking mode */ UT_ResetState(UT_KEY(OCS_read)); UT_SetDataBuffer(UT_KEY(OCS_read), SrcData, sizeof(SrcData), false); UT_PortablePosixIOTest_Set_Selectable(UT_INDEX_0, true); - OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (UT_INDEX_0, DestData, sizeof(DestData), 0), sizeof(DestData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (&token, DestData, sizeof(DestData), 0), sizeof(DestData)); UtAssert_True(UT_GetStubCount(UT_KEY(OS_SelectSingle_Impl)) == 1, "OS_SelectSingle() called"); /* read() failure */ UT_SetDefaultReturnValue(UT_KEY(OCS_read), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (UT_INDEX_0, DestData, sizeof(DestData), 0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericRead_Impl, (&token, DestData, sizeof(DestData), 0), OS_ERROR); } void Test_OS_GenericWrite_Impl(void) @@ -112,24 +122,27 @@ void Test_OS_GenericWrite_Impl(void) * Test Case For: * int32 OS_GenericWrite_Impl(uint32 local_id, const void *buffer, uint32 nbytes, int32 timeout) */ - char SrcData[] = "ABCDEFGHIJKL"; - char DestData[sizeof(SrcData)] = {0}; + char SrcData[] = "ABCDEFGHIJKL"; + char DestData[sizeof(SrcData)] = {0}; + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); UT_SetDataBuffer(UT_KEY(OCS_write), DestData, sizeof(DestData), false); UT_PortablePosixIOTest_Set_Selectable(UT_INDEX_0, false); - OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (UT_INDEX_0, SrcData, sizeof(SrcData), 0), sizeof(SrcData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (&token, SrcData, sizeof(SrcData), 0), sizeof(SrcData)); UtAssert_MemCmp(SrcData, DestData, sizeof(SrcData), "write() data valid"); /* test invocation of select() in nonblocking mode */ UT_ResetState(UT_KEY(OCS_write)); UT_SetDataBuffer(UT_KEY(OCS_write), DestData, sizeof(DestData), false); UT_PortablePosixIOTest_Set_Selectable(UT_INDEX_0, true); - OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (UT_INDEX_0, SrcData, sizeof(SrcData), 0), sizeof(SrcData)); + OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (&token, SrcData, sizeof(SrcData), 0), sizeof(SrcData)); UtAssert_True(UT_GetStubCount(UT_KEY(OS_SelectSingle_Impl)) == 1, "OS_SelectSingle() called"); /* write() failure */ UT_SetDefaultReturnValue(UT_KEY(OCS_write), -1); - OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (UT_INDEX_0, DestData, sizeof(DestData), 0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_GenericWrite_Impl, (&token, DestData, sizeof(DestData), 0), OS_ERROR); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index 8fd9dc218..6aaceacff 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -237,8 +237,8 @@ void Test_OS_unmount(void) UtAssert_True(actual == expected, "OS_mount() (%ld) == OS_ERR_NAME_NOT_FOUND", (long)actual); /* set up so record is in the right state for mounting */ - OS_filesys_table[1].flags = - OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | + OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; expected = OS_SUCCESS; actual = OS_unmount("/ram0"); UtAssert_True(actual == expected, "OS_unmount(nominal) (%ld) == OS_SUCCESS", (long)actual); @@ -267,8 +267,8 @@ void Test_OS_fsBlocksFree(void) statval.blocks_free = OSAL_BLOCKCOUNT_C(1111); statval.total_blocks = OSAL_BLOCKCOUNT_C(2222); UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume_Impl), &statval, sizeof(statval), false); - OS_filesys_table[1].flags = - OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | + OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; actual = OS_fsBlocksFree("/cf"); UtAssert_True(actual == expected, "OS_fsBlocksFree() (%ld) == 1111", (long)actual); @@ -304,8 +304,8 @@ void Test_OS_fsBytesFree(void) statval.blocks_free = OSAL_BLOCKCOUNT_C(1111); statval.total_blocks = OSAL_BLOCKCOUNT_C(2222); UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume_Impl), &statval, sizeof(statval), false); - OS_filesys_table[1].flags = - OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | + OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; actual = OS_fsBytesFree("/cf", &bytes_free); @@ -381,8 +381,8 @@ void Test_OS_FS_GetPhysDriveName(void) actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_ERR_INCORRECT_OBJ_STATE", (long)actual); - OS_filesys_table[1].flags = - OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | + OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; expected = OS_SUCCESS; actual = OS_FS_GetPhysDriveName(NameBuf, "none"); UtAssert_True(actual == expected, "OS_FS_GetPhysDriveName() (%ld) == OS_SUCCESS", (long)actual); @@ -436,8 +436,8 @@ void Test_OS_TranslatePath(void) int32 actual = ~OS_SUCCESS; /* Set up the local record for success */ - OS_filesys_table[1].flags = - OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; + OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | + OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; strcpy(OS_filesys_table[1].virtual_mountpt, "/cf"); strcpy(OS_filesys_table[1].system_mountpt, "/mnt/cf"); @@ -507,12 +507,17 @@ void Test_OS_FileSys_FindVirtMountPoint(void) bool result; OS_common_record_t refobj; const char refstr[] = "/ut"; + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); + token.obj_idx = UT_INDEX_1; + token.obj_type = OS_OBJECT_TYPE_OS_FILESYS; memset(&refobj, 0, sizeof(refobj)); OS_filesys_table[1].flags = 0; OS_filesys_table[1].virtual_mountpt[0] = 0; - result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, &token, &refobj); UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (unmounted) == false", refstr); OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; @@ -520,17 +525,17 @@ void Test_OS_FileSys_FindVirtMountPoint(void) /* Verify cases where one is a substring of the other - * these should also return false */ strncpy(OS_filesys_table[1].virtual_mountpt, "/ut11", sizeof(OS_filesys_table[1].virtual_mountpt)); - result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, &token, &refobj); UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (mountpt=%s) == false", refstr, OS_filesys_table[1].virtual_mountpt); strncpy(OS_filesys_table[1].virtual_mountpt, "/u", sizeof(OS_filesys_table[1].virtual_mountpt)); - result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, &token, &refobj); UtAssert_True(!result, "OS_FileSys_FindVirtMountPoint(%s) (mountpt=%s) == false", refstr, OS_filesys_table[1].virtual_mountpt); strncpy(OS_filesys_table[1].virtual_mountpt, "/ut", sizeof(OS_filesys_table[1].virtual_mountpt)); - result = OS_FileSys_FindVirtMountPoint((void *)refstr, 1, &refobj); + result = OS_FileSys_FindVirtMountPoint((void *)refstr, &token, &refobj); UtAssert_True(result, "OS_FileSys_FindVirtMountPoint(%s) (nominal) == true", refstr); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 5ac362b92..b5bd75288 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -40,7 +40,7 @@ typedef struct } Test_OS_ObjTypeCount_t; /* a match function that always matches */ -static bool TestAlwaysMatch(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +static bool TestAlwaysMatch(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { return true; } diff --git a/src/unit-test-coverage/shared/src/coveragetest-sockets.c b/src/unit-test-coverage/shared/src/coveragetest-sockets.c index d3a7feb63..938032578 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-sockets.c +++ b/src/unit-test-coverage/shared/src/coveragetest-sockets.c @@ -58,10 +58,18 @@ void Test_OS_CreateSocketName(void) * * This focuses on coverage paths, as this function does not return a value */ - OS_SockAddr_t testaddr; + OS_SockAddr_t testaddr; + OS_object_token_t token; + + OS_stream_table[0].stream_name[0] = 'x'; + + token.lock_mode = OS_LOCK_MODE_NONE; + token.obj_idx = UT_INDEX_0; + token.obj_id = UT_OBJID_1; + token.obj_type = OS_OBJECT_TYPE_OS_STREAM; UT_SetDefaultReturnValue(UT_KEY(OS_SocketAddrToString_Impl), OS_ERROR); - OS_CreateSocketName(0, &testaddr, "ut"); + OS_CreateSocketName(&token, &testaddr, "ut"); /* * The function should have called snprintf() to create the name diff --git a/src/unit-test-coverage/shared/src/os-shared-coverage-support.c b/src/unit-test-coverage/shared/src/os-shared-coverage-support.c index 4d105dc82..a857abb8a 100644 --- a/src/unit-test-coverage/shared/src/os-shared-coverage-support.c +++ b/src/unit-test-coverage/shared/src/os-shared-coverage-support.c @@ -55,6 +55,7 @@ void OS_UT_SetupTestTargetIndex(osal_objtype_t obj_type, osal_index_t test_idx) token.obj_id = OS_ObjectIdFromInteger((obj_type << OS_OBJECT_TYPE_SHIFT) | test_idx); UT_SetDataBuffer(UT_KEY(OS_ObjectIdGetById), &token, sizeof(OS_object_token_t), true); + UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdGetById), 1, OS_SUCCESS); } void OS_UT_SetupBasicInfoTest(osal_objtype_t obj_type, osal_index_t test_idx, const char *name, osal_id_t creator) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c index d1b8bfede..cee315962 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c @@ -38,10 +38,10 @@ ** Semaphore API */ -UT_DEFAULT_STUB(OS_BinSemCreate_Impl, (osal_index_t sem_id, uint32 sem_initial_value, uint32 options)) -UT_DEFAULT_STUB(OS_BinSemFlush_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_BinSemGive_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_BinSemTake_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_BinSemTimedWait_Impl, (osal_index_t sem_id, uint32 msecs)) -UT_DEFAULT_STUB(OS_BinSemDelete_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_BinSemGetInfo_Impl, (osal_index_t sem_id, OS_bin_sem_prop_t *bin_prop)) +UT_DEFAULT_STUB(OS_BinSemCreate_Impl, (const OS_object_token_t *token, uint32 sem_initial_value, uint32 options)) +UT_DEFAULT_STUB(OS_BinSemFlush_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_BinSemGive_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_BinSemTake_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_BinSemTimedWait_Impl, (const OS_object_token_t *token, uint32 msecs)) +UT_DEFAULT_STUB(OS_BinSemDelete_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_BinSemGetInfo_Impl, (const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c index ec77389bb..99dc96511 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c @@ -37,11 +37,11 @@ /* ** Console output API (printf) */ -void OS_ConsoleWakeup_Impl(osal_index_t local_id) +void OS_ConsoleWakeup_Impl(const OS_object_token_t *token) { UT_DEFAULT_IMPL(OS_ConsoleWakeup_Impl); } -int32 OS_ConsoleCreate_Impl(osal_index_t local_id) +int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token) { return UT_DEFAULT_IMPL(OS_ConsoleCreate_Impl); } diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c index c48a8168b..d6dcf2a54 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c @@ -38,9 +38,9 @@ ** Semaphore API */ -UT_DEFAULT_STUB(OS_CountSemCreate_Impl, (osal_index_t sem_id, uint32 sem_initial_value, uint32 options)) -UT_DEFAULT_STUB(OS_CountSemGive_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_CountSemTake_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_CountSemTimedWait_Impl, (osal_index_t sem_id, uint32 msecs)) -UT_DEFAULT_STUB(OS_CountSemDelete_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_CountSemGetInfo_Impl, (osal_index_t sem_id, OS_count_sem_prop_t *count_prop)) +UT_DEFAULT_STUB(OS_CountSemCreate_Impl, (const OS_object_token_t *token, uint32 sem_initial_value, uint32 options)) +UT_DEFAULT_STUB(OS_CountSemGive_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_CountSemTake_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_CountSemTimedWait_Impl, (const OS_object_token_t *token, uint32 msecs)) +UT_DEFAULT_STUB(OS_CountSemDelete_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_CountSemGetInfo_Impl, (const OS_object_token_t *token, OS_count_sem_prop_t *count_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c index ae3b5ac87..e5f0d52f5 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c @@ -39,27 +39,27 @@ * File API abstraction layer */ -UT_DEFAULT_STUB(OS_FileOpen_Impl, (osal_index_t file_id, const char *local_path, int32 flags, int32 access)) +UT_DEFAULT_STUB(OS_FileOpen_Impl, (const OS_object_token_t *token, const char *local_path, int32 flags, int32 access)) UT_DEFAULT_STUB(OS_FileStat_Impl, (const char *local_path, os_fstat_t *filestat)) UT_DEFAULT_STUB(OS_FileRemove_Impl, (const char *local_path)) UT_DEFAULT_STUB(OS_FileRename_Impl, (const char *old_path, const char *new_path)) UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access)) -UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl, (osal_index_t file_id, const char *Cmd)) +UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl, (const OS_object_token_t *token, const char *Cmd)) /* * Directory API abstraction layer */ UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access)) -UT_DEFAULT_STUB(OS_DirOpen_Impl, (osal_index_t dir_id, const char *local_path)) -UT_DEFAULT_STUB(OS_DirClose_Impl, (osal_index_t dir_id)) -UT_DEFAULT_STUB(OS_DirRead_Impl, (osal_index_t dir_id, os_dirent_t *dirent)) -UT_DEFAULT_STUB(OS_DirRewind_Impl, (osal_index_t dir_id)) +UT_DEFAULT_STUB(OS_DirOpen_Impl, (const OS_object_token_t *token, const char *local_path)) +UT_DEFAULT_STUB(OS_DirClose_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_DirRead_Impl, (const OS_object_token_t *token, os_dirent_t *dirent)) +UT_DEFAULT_STUB(OS_DirRewind_Impl, (const OS_object_token_t *token)) UT_DEFAULT_STUB(OS_DirRemove_Impl, (const char *local_path)) /* * Stream abstraction layer (applies to sockets and files) */ -int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, int32 timeout) +int32 OS_GenericRead_Impl(const OS_object_token_t *token, void *buffer, size_t nbytes, int32 timeout) { int32 Status = UT_DEFAULT_IMPL(OS_GenericRead_Impl); @@ -71,7 +71,7 @@ int32 OS_GenericRead_Impl(osal_index_t local_id, void *buffer, size_t nbytes, in return Status; } -int32 OS_GenericWrite_Impl(osal_index_t local_id, const void *buffer, size_t nbytes, int32 timeout) +int32 OS_GenericWrite_Impl(const OS_object_token_t *token, const void *buffer, size_t nbytes, int32 timeout) { int32 Status = UT_DEFAULT_IMPL(OS_GenericWrite_Impl); @@ -83,5 +83,5 @@ int32 OS_GenericWrite_Impl(osal_index_t local_id, const void *buffer, size_t nby return Status; } -UT_DEFAULT_STUB(OS_GenericSeek_Impl, (osal_index_t file_id, int32 offset, uint32 whence)) -UT_DEFAULT_STUB(OS_GenericClose_Impl, (osal_index_t file_id)) +UT_DEFAULT_STUB(OS_GenericSeek_Impl, (const OS_object_token_t *token, int32 offset, uint32 whence)) +UT_DEFAULT_STUB(OS_GenericClose_Impl, (const OS_object_token_t *token)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c index e3f5d1037..0dd5577e0 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-filesys-impl-stubs.c @@ -36,14 +36,14 @@ /* * File system abstraction layer */ -UT_DEFAULT_STUB(OS_FileSysStartVolume_Impl, (osal_index_t filesys_id)) -UT_DEFAULT_STUB(OS_FileSysStopVolume_Impl, (osal_index_t filesys_id)) -UT_DEFAULT_STUB(OS_FileSysFormatVolume_Impl, (osal_index_t filesys_id)) -UT_DEFAULT_STUB(OS_FileSysCheckVolume_Impl, (osal_index_t filesys_id, bool repair)) -UT_DEFAULT_STUB(OS_FileSysMountVolume_Impl, (osal_index_t filesys_id)) -UT_DEFAULT_STUB(OS_FileSysUnmountVolume_Impl, (osal_index_t filesys_id)) +UT_DEFAULT_STUB(OS_FileSysStartVolume_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_FileSysStopVolume_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_FileSysFormatVolume_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_FileSysCheckVolume_Impl, (const OS_object_token_t *token, bool repair)) +UT_DEFAULT_STUB(OS_FileSysMountVolume_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_FileSysUnmountVolume_Impl, (const OS_object_token_t *token)) -int32 OS_FileSysStatVolume_Impl(osal_index_t filesys_id, OS_statvfs_t *result) +int32 OS_FileSysStatVolume_Impl(const OS_object_token_t *token, OS_statvfs_t *result) { int32 Status = UT_DEFAULT_IMPL(OS_FileSysStatVolume_Impl); diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c index c92e8ce31..7c2b2ccc5 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c @@ -36,9 +36,9 @@ /* * Module Loader API */ -UT_DEFAULT_STUB(OS_ModuleLoad_Impl, (osal_index_t module_id, const char *translated_path)) -UT_DEFAULT_STUB(OS_ModuleUnload_Impl, (osal_index_t module_id)) -UT_DEFAULT_STUB(OS_ModuleGetInfo_Impl, (osal_index_t module_id, OS_module_prop_t *module_prop)) +UT_DEFAULT_STUB(OS_ModuleLoad_Impl, (const OS_object_token_t *token, const char *translated_path)) +UT_DEFAULT_STUB(OS_ModuleUnload_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_ModuleGetInfo_Impl, (const OS_object_token_t *token, OS_module_prop_t *module_prop)) UT_DEFAULT_STUB(OS_GlobalSymbolLookup_Impl, (cpuaddr * SymbolAddress, const char *SymbolName)) -UT_DEFAULT_STUB(OS_ModuleSymbolLookup_Impl, (osal_index_t module_id, cpuaddr *SymbolAddress, const char *SymbolName)) +UT_DEFAULT_STUB(OS_ModuleSymbolLookup_Impl, (const OS_object_token_t *token, cpuaddr *SymbolAddress, const char *SymbolName)) UT_DEFAULT_STUB(OS_SymbolTableDump_Impl, (const char *filename, size_t size_limit)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c index 6bbe47829..f106785f4 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c @@ -38,8 +38,8 @@ ** Mutex API */ -UT_DEFAULT_STUB(OS_MutSemCreate_Impl, (osal_index_t sem_id, uint32 options)) -UT_DEFAULT_STUB(OS_MutSemGive_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_MutSemTake_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_MutSemDelete_Impl, (osal_index_t sem_id)) -UT_DEFAULT_STUB(OS_MutSemGetInfo_Impl, (osal_index_t sem_id, OS_mut_sem_prop_t *mut_prop)) +UT_DEFAULT_STUB(OS_MutSemCreate_Impl, (const OS_object_token_t *token, uint32 options)) +UT_DEFAULT_STUB(OS_MutSemGive_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_MutSemTake_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_MutSemDelete_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_MutSemGetInfo_Impl, (const OS_object_token_t *token, OS_mut_sem_prop_t *mut_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c index 32cb5e40c..f797457e7 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-network-impl-stubs.c @@ -37,17 +37,17 @@ /* * Sockets API abstraction layer */ -UT_DEFAULT_STUB(OS_SocketOpen_Impl, (osal_index_t sock_id)) -UT_DEFAULT_STUB(OS_SocketClose_Impl, (osal_index_t sock_id)) -UT_DEFAULT_STUB(OS_SocketBind_Impl, (osal_index_t sock_id, const OS_SockAddr_t *Addr)) -UT_DEFAULT_STUB(OS_SocketAccept_Impl, - (osal_index_t sock_id, osal_index_t connsock_id, OS_SockAddr_t *Addr, int32 timeout)) -UT_DEFAULT_STUB(OS_SocketConnect_Impl, (osal_index_t sock_id, const OS_SockAddr_t *Addr, int32 timeout)) +UT_DEFAULT_STUB(OS_SocketOpen_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_SocketClose_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_SocketBind_Impl, (const OS_object_token_t *token, const OS_SockAddr_t *Addr)) +UT_DEFAULT_STUB(OS_SocketAccept_Impl, (const OS_object_token_t *sock_token, const OS_object_token_t *conn_token, + OS_SockAddr_t *Addr, int32 timeout)) +UT_DEFAULT_STUB(OS_SocketConnect_Impl, (const OS_object_token_t *token, const OS_SockAddr_t *Addr, int32 timeout)) UT_DEFAULT_STUB(OS_SocketRecvFrom_Impl, - (osal_index_t sock_id, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, int32 timeout)) + (const OS_object_token_t *token, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, int32 timeout)) UT_DEFAULT_STUB(OS_SocketSendTo_Impl, - (osal_index_t sock_id, const void *buffer, size_t buflen, const OS_SockAddr_t *RemoteAddr)) -UT_DEFAULT_STUB(OS_SocketGetInfo_Impl, (osal_index_t sock_id, OS_socket_prop_t *sock_prop)) + (const OS_object_token_t *token, const void *buffer, size_t buflen, const OS_SockAddr_t *RemoteAddr)) +UT_DEFAULT_STUB(OS_SocketGetInfo_Impl, (const OS_object_token_t *token, OS_socket_prop_t *sock_prop)) UT_DEFAULT_STUB(OS_SocketAddrInit_Impl, (OS_SockAddr_t * Addr, OS_SocketDomain_t Domain)) UT_DEFAULT_STUB(OS_SocketAddrToString_Impl, (char *buffer, size_t buflen, const OS_SockAddr_t *Addr)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c index 222204017..d3eea368a 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c @@ -38,8 +38,8 @@ ** Message Queue API */ -UT_DEFAULT_STUB(OS_QueueCreate_Impl, (osal_index_t queue_id, uint32 flags)) -UT_DEFAULT_STUB(OS_QueueDelete_Impl, (osal_index_t queue_id)) -UT_DEFAULT_STUB(OS_QueueGet_Impl, (osal_index_t queue_id, void *data, size_t size, size_t *size_copied, int32 timeout)) -UT_DEFAULT_STUB(OS_QueuePut_Impl, (osal_index_t queue_id, const void *data, size_t size, uint32 flags)) -UT_DEFAULT_STUB(OS_QueueGetInfo_Impl, (osal_index_t queue_id, OS_queue_prop_t *queue_prop)) +UT_DEFAULT_STUB(OS_QueueCreate_Impl, (const OS_object_token_t *token, uint32 flags)) +UT_DEFAULT_STUB(OS_QueueDelete_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_QueueGet_Impl, (const OS_object_token_t *token, void *data, size_t size, size_t *size_copied, int32 timeout)) +UT_DEFAULT_STUB(OS_QueuePut_Impl, (const OS_object_token_t *token, const void *data, size_t size, uint32 flags)) +UT_DEFAULT_STUB(OS_QueueGetInfo_Impl, (const OS_object_token_t *token, OS_queue_prop_t *queue_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c index 1e3d84f25..4f4b720d6 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-select-impl-stubs.c @@ -33,5 +33,5 @@ #include "utstubs.h" #include "os-shared-select.h" -UT_DEFAULT_STUB(OS_SelectSingle_Impl, (osal_index_t stream_id, uint32 *SelectFlags, int32 msecs)) +UT_DEFAULT_STUB(OS_SelectSingle_Impl, (const OS_object_token_t *token, uint32 *SelectFlags, int32 msecs)) UT_DEFAULT_STUB(OS_SelectMultiple_Impl, (OS_FdSet * ReadSet, OS_FdSet *WriteSet, int32 msecs)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c index 56ad1c2ff..fdf9844c4 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c @@ -37,22 +37,22 @@ /* ** Task API */ -UT_DEFAULT_STUB(OS_TaskMatch_Impl, (osal_index_t task_id)) -UT_DEFAULT_STUB(OS_TaskCreate_Impl, (osal_index_t task_id, uint32 flags)) -UT_DEFAULT_STUB(OS_TaskDelete_Impl, (osal_index_t task_id)) +UT_DEFAULT_STUB(OS_TaskMatch_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_TaskCreate_Impl, (const OS_object_token_t *token, uint32 flags)) +UT_DEFAULT_STUB(OS_TaskDelete_Impl, (const OS_object_token_t *token)) void OS_TaskExit_Impl(void) { UT_DEFAULT_IMPL(OS_TaskExit_Impl); } UT_DEFAULT_STUB(OS_TaskDelay_Impl, (uint32 millisecond)) -UT_DEFAULT_STUB(OS_TaskSetPriority_Impl, (osal_index_t task_id, osal_priority_t new_priority)) +UT_DEFAULT_STUB(OS_TaskSetPriority_Impl, (const OS_object_token_t *token, osal_priority_t new_priority)) osal_id_t OS_TaskGetId_Impl(void) { int32 status; osal_id_t id; - status = UT_DEFAULT_IMPL(OS_TaskGetId_Impl); + status = UT_DEFAULT_IMPL_RC(OS_TaskGetId_Impl, 1); /* convert the int32 status value to an osal_id_t - * (this assumes the types are compatible) */ @@ -60,10 +60,10 @@ osal_id_t OS_TaskGetId_Impl(void) return id; } -UT_DEFAULT_STUB(OS_TaskGetInfo_Impl, (osal_index_t task_id, OS_task_prop_t *task_prop)) +UT_DEFAULT_STUB(OS_TaskGetInfo_Impl, (const OS_object_token_t *token, OS_task_prop_t *task_prop)) UT_DEFAULT_STUB(OS_TaskRegister_Impl, (osal_id_t global_task_id)) -bool OS_TaskIdMatchSystemData_Impl(void *ref, osal_index_t local_id, const OS_common_record_t *obj) +bool OS_TaskIdMatchSystemData_Impl(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj) { return UT_DEFAULT_IMPL(OS_TaskIdMatchSystemData_Impl); } diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c index 29bb94214..f04c150ca 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-timer-impl-stubs.c @@ -37,22 +37,21 @@ /* ** OS Time/Tick related API */ -UT_DEFAULT_STUB(OS_TimeBaseCreate_Impl, (osal_index_t timer_id)) -UT_DEFAULT_STUB(OS_TimeBaseSet_Impl, (osal_index_t timer_id, uint32 start_time, uint32 interval_time)) -UT_DEFAULT_STUB(OS_TimeBaseDelete_Impl, (osal_index_t timer_id)) -void OS_TimeBaseLock_Impl(osal_index_t timebase_id) +UT_DEFAULT_STUB(OS_TimeBaseCreate_Impl, (const OS_object_token_t *token)) +UT_DEFAULT_STUB(OS_TimeBaseSet_Impl, (const OS_object_token_t *token, uint32 start_time, uint32 interval_time)) +UT_DEFAULT_STUB(OS_TimeBaseDelete_Impl, (const OS_object_token_t *token)) +void OS_TimeBaseLock_Impl(const OS_object_token_t *token) { UT_DEFAULT_IMPL(OS_TimeBaseLock_Impl); } -void OS_TimeBaseUnlock_Impl(osal_index_t timebase_id) +void OS_TimeBaseUnlock_Impl(const OS_object_token_t *token) { UT_DEFAULT_IMPL(OS_TimeBaseUnlock_Impl); } -UT_DEFAULT_STUB(OS_TimeBaseGetInfo_Impl, (osal_index_t timer_id, OS_timebase_prop_t *timer_prop)) +UT_DEFAULT_STUB(OS_TimeBaseGetInfo_Impl, (const OS_object_token_t *token, OS_timebase_prop_t *timer_prop)) -UT_DEFAULT_STUB(OS_TimeBaseRegister_Impl, (osal_index_t timebase_id)) /* * Clock API low-level handlers */ diff --git a/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c index c4fdbee58..60fab614f 100644 --- a/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/portable-console-bsp-impl-stubs.c @@ -37,7 +37,7 @@ /* ** Console output API (printf) */ -void OS_ConsoleOutput_Impl(osal_index_t local_id) +void OS_ConsoleOutput_Impl(const OS_object_token_t *token) { UT_DEFAULT_IMPL(OS_ConsoleOutput_Impl); } diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h index e63fc68a6..b0a4bbb67 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-tasks.h @@ -45,7 +45,7 @@ extern size_t const UT_Ref_OS_impl_task_table_SIZE; int32 UT_Call_OS_VxWorks_TaskAPI_Impl_Init(void); void UT_TaskTest_SetImplTaskId(osal_index_t local_id, OCS_TASK_ID TaskId); -int UT_TaskTest_CallEntryPoint(int arg); +int UT_TaskTest_CallEntryPoint(osal_id_t arg); OCS_WIND_TCB *UT_TaskTest_GetTaskTcb(osal_index_t local_id); #endif /* INCLUDE_UT_ADAPTOR_TASKS_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h index 6bb020cfd..af148e2f1 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-timebase.h @@ -49,7 +49,7 @@ int32 UT_TimeBaseTest_CallSigWaitFunc(osal_index_t local_id); int UT_TimeBaseTest_CallHelperTaskFunc(int arg); /* Invokes the static OS_VxWorks_RegisterTimer() function with given argument */ -void UT_TimeBaseTest_CallRegisterTimer(osal_index_t local_id); +void UT_TimeBaseTest_CallRegisterTimer(osal_id_t obj_id); /* Hook functions which set the timer registration state */ void UT_TimeBaseTest_SetTimeBaseRegState(osal_index_t local_id, bool is_success); diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c index 2b2d19edf..f256dbaa9 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-tasks.c @@ -50,9 +50,9 @@ void UT_TaskTest_SetImplTaskId(osal_index_t local_id, OCS_TASK_ID TaskId) * in order for the UT to invoke it there must be a non-static * way to get access to it. */ -int UT_TaskTest_CallEntryPoint(int arg) +int UT_TaskTest_CallEntryPoint(osal_id_t arg) { - return OS_VxWorks_TaskEntry(arg); + return OS_VxWorks_TaskEntry(OS_ObjectIdToInteger(arg)); } OCS_WIND_TCB *UT_TaskTest_GetTaskTcb(osal_index_t local_id) diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c index 0ec0b7a2b..f7814058a 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-timebase.c @@ -50,9 +50,9 @@ int UT_TimeBaseTest_CallHelperTaskFunc(int arg) return OS_VxWorks_TimeBaseTask(arg); } -void UT_TimeBaseTest_CallRegisterTimer(osal_index_t local_id) +void UT_TimeBaseTest_CallRegisterTimer(osal_id_t obj_id) { - OS_VxWorks_RegisterTimer(local_id); + OS_VxWorks_RegisterTimer(obj_id); } bool UT_TimeBaseTest_CheckTimeBaseRegisteredState(osal_index_t local_id) diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c index 906b4187b..41e19cf25 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c @@ -50,10 +50,12 @@ void Test_OS_BinSemCreate_Impl(void) * Test Case For: * int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 initial_value, uint32 options) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(&token, 0, 0), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_semBInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate_Impl(&token, 0, 0), OS_SEM_FAILURE); } void Test_OS_BinSemDelete_Impl(void) @@ -62,7 +64,9 @@ void Test_OS_BinSemDelete_Impl(void) * Test Case For: * int32 OS_BinSemDelete_Impl (uint32 sem_id) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemDelete_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_BinSemDelete_Impl(&token), OS_SUCCESS); } void Test_OS_BinSemGive_Impl(void) @@ -71,10 +75,12 @@ void Test_OS_BinSemGive_Impl(void) * Test Case For: * int32 OS_BinSemGive_Impl ( uint32 sem_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemGive_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_BinSemGive_Impl(&token), OS_SUCCESS); UT_SetDefaultReturnValue(UT_StubKey_GenericSemGive, OS_SEM_FAILURE); - OSAPI_TEST_FUNCTION_RC(OS_BinSemGive_Impl(UT_INDEX_0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGive_Impl(&token), OS_SEM_FAILURE); } void Test_OS_BinSemFlush_Impl(void) @@ -83,10 +89,12 @@ void Test_OS_BinSemFlush_Impl(void) * Test Case For: * int32 OS_BinSemFlush_Impl (uint32 sem_id) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemFlush_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_BinSemFlush_Impl(&token), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_semFlush), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_BinSemFlush_Impl(UT_INDEX_0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_BinSemFlush_Impl(&token), OS_SEM_FAILURE); } void Test_OS_BinSemTake_Impl(void) @@ -95,7 +103,9 @@ void Test_OS_BinSemTake_Impl(void) * Test Case For: * int32 OS_BinSemTake_Impl ( uint32 sem_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemTake_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_BinSemTake_Impl(&token), OS_SUCCESS); } void Test_OS_BinSemTimedWait_Impl(void) @@ -104,13 +114,15 @@ void Test_OS_BinSemTimedWait_Impl(void) * Test Case For: * int32 OS_BinSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) */ - OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(UT_INDEX_0, 100), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(&token, 100), OS_SUCCESS); UT_SetDefaultReturnValue(UT_StubKey_GenericSemTake, OS_SEM_FAILURE); - OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(UT_INDEX_0, 100), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(&token, 100), OS_SEM_FAILURE); UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(UT_INDEX_0, 100), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_BinSemTimedWait_Impl(&token, 100), OS_ERROR); } void Test_OS_BinSemGetInfo_Impl(void) @@ -120,8 +132,10 @@ void Test_OS_BinSemGetInfo_Impl(void) * int32 OS_BinSemGetInfo_Impl (uint32 sem_id, OS_bin_sem_prop_t *sem_prop) */ OS_bin_sem_prop_t sem_prop; + OS_object_token_t token = UT_TOKEN_0; + memset(&sem_prop, 0xEE, sizeof(sem_prop)); - OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo_Impl(UT_INDEX_0, &sem_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_BinSemGetInfo_Impl(&token, &sem_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-console.c b/src/unit-test-coverage/vxworks/src/coveragetest-console.c index f3a358f32..0f0f437fa 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-console.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-console.c @@ -41,35 +41,41 @@ void Test_OS_ConsoleWakeup_Impl(void) * Test Case For: * void OS_ConsoleWakeup_Impl(const char *string) */ + OS_object_token_t token = UT_TOKEN_0; /* no return code - check for coverage */ UT_ConsoleTest_SetConsoleAsync(0, true); - OS_ConsoleWakeup_Impl(0); + OS_ConsoleWakeup_Impl(&token); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semGive)) == 1, "semGive() called in async mode"); UT_SetDefaultReturnValue(UT_KEY(OCS_semGive), -1); - OS_ConsoleWakeup_Impl(0); + OS_ConsoleWakeup_Impl(&token); UT_ConsoleTest_SetConsoleAsync(0, false); OS_console_table[0].WritePos = 1; - OS_ConsoleWakeup_Impl(0); + OS_ConsoleWakeup_Impl(&token); UtAssert_True(UT_GetStubCount(UT_KEY(OS_ConsoleOutput_Impl)) == 1, "OS_ConsoleOutput_Impl() called in sync mode"); } void Test_OS_ConsoleCreate_Impl(void) { - OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(0), OS_SUCCESS); + OS_object_token_t token; + + memset(&token, 0, sizeof(token)); + + OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskSpawn)) == 1, "taskSpawn() called"); UT_SetDefaultReturnValue(UT_KEY(OCS_semCInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_SEM_FAILURE); UT_ClearForceFail(UT_KEY(OCS_semCInitialize)); UT_SetDefaultReturnValue(UT_KEY(OCS_taskSpawn), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_taskSpawn)); - OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(OS_MAX_CONSOLES + 1), OS_ERR_NOT_IMPLEMENTED); + token.obj_idx = OS_MAX_CONSOLES + 1; + OSAPI_TEST_FUNCTION_RC(OS_ConsoleCreate_Impl(&token), OS_ERR_NOT_IMPLEMENTED); /* Also call the actual console task, to get coverage on it. * This task has an infinite loop, which only exits if semTake fails */ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c index daa20093a..e09a9ee78 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c @@ -46,10 +46,12 @@ void Test_OS_CountSemCreate_Impl(void) * Test Case For: * int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 options) */ - OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(&token, 0, 0), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_semCInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(UT_INDEX_0, 0, 0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate_Impl(&token, 0, 0), OS_SEM_FAILURE); } void Test_OS_CountSemDelete_Impl(void) @@ -58,7 +60,9 @@ void Test_OS_CountSemDelete_Impl(void) * Test Case For: * int32 OS_CountSemDelete_Impl (uint32 sem_id) */ - OSAPI_TEST_FUNCTION_RC(OS_CountSemDelete_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_CountSemDelete_Impl(&token), OS_SUCCESS); } void Test_OS_CountSemGive_Impl(void) @@ -67,7 +71,9 @@ void Test_OS_CountSemGive_Impl(void) * Test Case For: * int32 OS_CountSemGive_Impl ( uint32 sem_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_CountSemGive_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_CountSemGive_Impl(&token), OS_SUCCESS); } void Test_OS_CountSemTake_Impl(void) @@ -76,7 +82,9 @@ void Test_OS_CountSemTake_Impl(void) * Test Case For: * int32 OS_CountSemTake_Impl ( uint32 sem_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_CountSemTake_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_CountSemTake_Impl(&token), OS_SUCCESS); } void Test_OS_CountSemTimedWait_Impl(void) @@ -85,10 +93,12 @@ void Test_OS_CountSemTimedWait_Impl(void) * Test Case For: * int32 OS_CountSemTimedWait_Impl ( uint32 sem_id, uint32 msecs ) */ - OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(UT_INDEX_0, 100), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(&token, 100), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(UT_INDEX_0, 100), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_CountSemTimedWait_Impl(&token, 100), OS_ERROR); } void Test_OS_CountSemGetInfo_Impl(void) @@ -98,8 +108,10 @@ void Test_OS_CountSemGetInfo_Impl(void) * int32 OS_CountSemGetInfo_Impl (uint32 sem_id, OS_count_sem_prop_t *count_prop) */ OS_count_sem_prop_t count_prop; + OS_object_token_t token = UT_TOKEN_0; + memset(&count_prop, 0xEE, sizeof(count_prop)); - OSAPI_TEST_FUNCTION_RC(OS_CountSemGetInfo_Impl(UT_INDEX_0, &count_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_CountSemGetInfo_Impl(&token, &count_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c index f31a0bbe2..8818db37e 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-dirs.c @@ -63,9 +63,11 @@ void Test_OS_DirOpen_Impl(void) * Test Case For: * int32 OS_DirOpen_Impl(uint32 local_id, const char *local_path) */ - OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(UT_INDEX_0, "dir"), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(&token, "dir"), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_opendir), -1); - OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(UT_INDEX_0, "dir"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_DirOpen_Impl(&token, "dir"), OS_ERROR); } void Test_OS_DirClose_Impl(void) @@ -74,7 +76,9 @@ void Test_OS_DirClose_Impl(void) * Test Case For: * int32 OS_DirClose_Impl(uint32 local_id) */ - OSAPI_TEST_FUNCTION_RC(OS_DirClose_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_DirClose_Impl(&token), OS_SUCCESS); } void Test_OS_DirRead_Impl(void) @@ -83,12 +87,13 @@ void Test_OS_DirRead_Impl(void) * Test Case For: * int32 OS_DirRead_Impl(uint32 local_id, os_dirent_t *dirent) */ - os_dirent_t dirent_buff; + os_dirent_t dirent_buff; + OS_object_token_t token = UT_TOKEN_0; - OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(UT_INDEX_0, &dirent_buff), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(&token, &dirent_buff), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_readdir), -1); - OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(UT_INDEX_0, &dirent_buff), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_DirRead_Impl(&token, &dirent_buff), OS_ERROR); } void Test_OS_DirRewind_Impl(void) @@ -97,7 +102,9 @@ void Test_OS_DirRewind_Impl(void) * Test Case For: * int32 OS_DirRewind_Impl(uint32 local_id) */ - OSAPI_TEST_FUNCTION_RC(OS_DirRewind_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_DirRewind_Impl(&token), OS_SUCCESS); } void Test_OS_DirRemove_Impl(void) diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c index f10632e2b..52c2c69cf 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c @@ -45,19 +45,23 @@ void Test_OS_FileSysStartVolume_Impl(void) * Test Case For: * int32 OS_FileSysStartVolume_Impl (uint32 filesys_id) */ - int32 expected; + int32 expected; + OS_object_token_t token; + + token = UT_TOKEN_0; /* Emulate an UNKNOWN entry */ OS_filesys_table[0].fstype = OS_FILESYS_TYPE_UNKNOWN; - OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(0), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(&token), OS_ERR_NOT_IMPLEMENTED); /* Emulate an FS_BASED entry */ OS_filesys_table[0].fstype = OS_FILESYS_TYPE_FS_BASED; - OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(&token), OS_SUCCESS); /* Emulate a VOLATILE_DISK entry (ramdisk) */ OS_filesys_table[1].fstype = OS_FILESYS_TYPE_VOLATILE_DISK; - OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(1), OS_SUCCESS); + token.obj_idx = UT_INDEX_1; + OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(&token), OS_SUCCESS); /* Emulate a NORMAL_DISK entry (ATA) */ OS_filesys_table[2].fstype = OS_FILESYS_TYPE_NORMAL_DISK; @@ -67,15 +71,17 @@ void Test_OS_FileSysStartVolume_Impl(void) #else expected = OS_ERR_NOT_IMPLEMENTED; #endif - OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(2), expected); + token = UT_TOKEN_2; + OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(&token), expected); /* Failure to create XBD layer */ UT_SetDefaultReturnValue(UT_KEY(OCS_xbdBlkDevCreateSync), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(1), OS_FS_ERR_DRIVE_NOT_CREATED); + token = UT_TOKEN_1; + OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(&token), OS_FS_ERR_DRIVE_NOT_CREATED); /* Failure to create low level block dev */ UT_SetDefaultReturnValue(UT_KEY(OCS_ramDevCreate), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(1), OS_FS_ERR_DRIVE_NOT_CREATED); + OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(&token), OS_FS_ERR_DRIVE_NOT_CREATED); } void Test_OS_FileSysStopVolume_Impl(void) @@ -83,12 +89,15 @@ void Test_OS_FileSysStopVolume_Impl(void) /* Test Case For: * int32 OS_FileSysStopVolume_Impl (uint32 filesys_id) */ - OSAPI_TEST_FUNCTION_RC(OS_FileSysStopVolume_Impl(0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_FileSysStopVolume_Impl(&token), OS_SUCCESS); /* Failure to delete XBD layer */ OS_filesys_table[1].fstype = OS_FILESYS_TYPE_VOLATILE_DISK; UT_FileSysTest_SetupFileSysEntry(1, NULL, 1, 4); - OSAPI_TEST_FUNCTION_RC(OS_FileSysStopVolume_Impl(1), OS_SUCCESS); + token = UT_TOKEN_1; + OSAPI_TEST_FUNCTION_RC(OS_FileSysStopVolume_Impl(&token), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_xbdBlkDevDelete)) == 1, "xbdBlkDevDelete() called"); } @@ -97,21 +106,22 @@ void Test_OS_FileSysFormatVolume_Impl(void) /* Test Case For: * int32 OS_FileSysFormatVolume_Impl (uint32 filesys_id) */ + OS_object_token_t token = UT_TOKEN_0; /* test unimplemented fs type */ OS_filesys_table[0].fstype = OS_FILESYS_TYPE_UNKNOWN; - OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_ERR_NOT_IMPLEMENTED); + OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(&token), OS_ERR_NOT_IMPLEMENTED); /* fs-based should be noop */ OS_filesys_table[0].fstype = OS_FILESYS_TYPE_FS_BASED; - OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(&token), OS_SUCCESS); OS_filesys_table[0].fstype = OS_FILESYS_TYPE_VOLATILE_DISK; - OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(&token), OS_SUCCESS); /* Failure of the dosFsVolFormat() call */ UT_SetDefaultReturnValue(UT_KEY(OCS_dosFsVolFormat), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(0), OS_FS_ERR_DRIVE_NOT_CREATED); + OSAPI_TEST_FUNCTION_RC(OS_FileSysFormatVolume_Impl(&token), OS_FS_ERR_DRIVE_NOT_CREATED); } void Test_OS_FileSysMountVolume_Impl(void) @@ -119,11 +129,12 @@ void Test_OS_FileSysMountVolume_Impl(void) /* Test Case For: * int32 OS_FileSysMountVolume_Impl (uint32 filesys_id) */ + OS_object_token_t token = UT_TOKEN_0; - OSAPI_TEST_FUNCTION_RC(OS_FileSysMountVolume_Impl(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileSysMountVolume_Impl(&token), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysMountVolume_Impl(0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysMountVolume_Impl(&token), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); } @@ -132,15 +143,16 @@ void Test_OS_FileSysUnmountVolume_Impl(void) /* Test Case For: * int32 OS_FileSysUnmountVolume_Impl (uint32 filesys_id) */ + OS_object_token_t token = UT_TOKEN_0; - OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(&token), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(&token), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); UT_SetDefaultReturnValue(UT_KEY(OCS_ioctl), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysUnmountVolume_Impl(&token), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_ioctl)); } @@ -150,11 +162,13 @@ void Test_OS_FileSysStatVolume_Impl(void) * Test Case For: * int32 OS_FileSysStatVolume_Impl (uint32 filesys_id, OS_statvfs_t *result) */ - OS_statvfs_t stat; - OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0, &stat), OS_SUCCESS); + OS_statvfs_t stat; + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(&token, &stat), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_statvfs), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(0, &stat), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysStatVolume_Impl(&token, &stat), OS_ERROR); } void Test_OS_FileSysCheckVolume_Impl(void) @@ -163,14 +177,16 @@ void Test_OS_FileSysCheckVolume_Impl(void) * Test Case For: * int32 OS_FileSysCheckVolume_Impl (uint32 filesys_id, bool repair) */ - OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, true), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(&token, true), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, false), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(&token, false), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); UT_SetDefaultReturnValue(UT_KEY(OCS_ioctl), -1); - OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(0, false), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_FileSysCheckVolume_Impl(&token, false), OS_ERROR); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c index 5c718df1c..21fcb7858 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c @@ -50,12 +50,14 @@ void Test_OS_ModuleLoad_Impl(void) /* Test Case For: * int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) */ - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(UT_INDEX_0, "local"), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(&token, "local"), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_open), -1); - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(UT_INDEX_0, "local"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(&token, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_open)); UT_SetDefaultReturnValue(UT_KEY(OCS_loadModule), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(UT_INDEX_0, "local"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad_Impl(&token, "local"), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_loadModule)); } @@ -64,9 +66,11 @@ void Test_OS_ModuleUnload_Impl(void) /* Test Case For: * int32 OS_ModuleUnload_Impl ( uint32 module_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(&token), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_unldByModuleId), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(UT_INDEX_0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleUnload_Impl(&token), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_unldByModuleId)); } @@ -75,10 +79,11 @@ void Test_OS_ModuleGetInfo_Impl(void) /* Test Case For: * int32 OS_ModuleGetInfo_Impl ( uint32 module_id, OS_module_prop_t *module_prop ) */ - OS_module_prop_t module_prop; + OS_module_prop_t module_prop; + OS_object_token_t token = UT_TOKEN_0; memset(&module_prop, 0, sizeof(module_prop)); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(UT_INDEX_0, &module_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(&token, &module_prop), OS_SUCCESS); UtAssert_True(module_prop.addr.valid, "addresses in output valid"); /* @@ -87,7 +92,7 @@ void Test_OS_ModuleGetInfo_Impl(void) */ memset(&module_prop, 0, sizeof(module_prop)); UT_SetDefaultReturnValue(UT_KEY(OCS_moduleInfoGet), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(UT_INDEX_0, &module_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleGetInfo_Impl(&token, &module_prop), OS_SUCCESS); UT_ClearForceFail(UT_KEY(OCS_moduleInfoGet)); UtAssert_True(!module_prop.addr.valid, "addresses in output not valid"); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c b/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c index 2320fb3a1..c606a95fb 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-mutex.c @@ -43,10 +43,12 @@ void Test_OS_MutSemCreate_Impl(void) * Test Case For: * int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options) */ - OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(UT_INDEX_0, 0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(&token, 0), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_semMInitialize), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(UT_INDEX_0, 0), OS_SEM_FAILURE); + OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate_Impl(&token, 0), OS_SEM_FAILURE); } void Test_OS_MutSemDelete_Impl(void) @@ -55,7 +57,9 @@ void Test_OS_MutSemDelete_Impl(void) * Test Case For: * int32 OS_MutSemDelete_Impl (uint32 sem_id) */ - OSAPI_TEST_FUNCTION_RC(OS_MutSemDelete_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_MutSemDelete_Impl(&token), OS_SUCCESS); } void Test_OS_MutSemGive_Impl(void) @@ -64,7 +68,9 @@ void Test_OS_MutSemGive_Impl(void) * Test Case For: * int32 OS_MutSemGive_Impl ( uint32 sem_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_MutSemGive_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_MutSemGive_Impl(&token), OS_SUCCESS); } void Test_OS_MutSemTake_Impl(void) @@ -73,7 +79,9 @@ void Test_OS_MutSemTake_Impl(void) * Test Case For: * int32 OS_MutSemTake_Impl ( uint32 sem_id ) */ - OSAPI_TEST_FUNCTION_RC(OS_MutSemTake_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_MutSemTake_Impl(&token), OS_SUCCESS); } void Test_OS_MutSemGetInfo_Impl(void) @@ -83,8 +91,10 @@ void Test_OS_MutSemGetInfo_Impl(void) * int32 OS_MutSemGetInfo_Impl (uint32 sem_id, OS_mut_sem_prop_t *mut_prop) */ OS_mut_sem_prop_t mut_prop; + OS_object_token_t token = UT_TOKEN_0; + memset(&mut_prop, 0xEE, sizeof(mut_prop)); - OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo_Impl(UT_INDEX_0, &mut_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo_Impl(&token, &mut_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c index a752c4e25..f8f67afd4 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c @@ -47,10 +47,12 @@ void Test_OS_QueueCreate_Impl(void) * Test Case For: * int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags) */ - OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(UT_INDEX_0, 0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(&token, 0), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_msgQCreate), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(UT_INDEX_0, 0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_QueueCreate_Impl(&token, 0), OS_ERROR); } void Test_OS_QueueDelete_Impl(void) @@ -59,10 +61,12 @@ void Test_OS_QueueDelete_Impl(void) * Test Case For: * int32 OS_QueueDelete_Impl (uint32 queue_id) */ - OSAPI_TEST_FUNCTION_RC(OS_QueueDelete_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_QueueDelete_Impl(&token), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_msgQDelete), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_QueueDelete_Impl(UT_INDEX_0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_QueueDelete_Impl(&token), OS_ERROR); } void Test_OS_QueueGet_Impl(void) @@ -71,23 +75,24 @@ void Test_OS_QueueGet_Impl(void) * Test Case For: * int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) */ - char Data[16]; - size_t ActSz; + char Data[16]; + size_t ActSz; + OS_object_token_t token = UT_TOKEN_0; - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_PEND), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, 100), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, OS_PEND), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, 100), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_Milli2Ticks), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, 100), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, 100), OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OCS_msgQReceive), OCS_ERROR); OCS_errno = OCS_S_objLib_OBJ_TIMEOUT; - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_QUEUE_TIMEOUT); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_QUEUE_TIMEOUT); OCS_errno = OCS_S_objLib_OBJ_UNAVAILABLE; - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_QUEUE_EMPTY); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_QUEUE_EMPTY); OCS_errno = 0; - OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(UT_INDEX_0, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_QueueGet_Impl(&token, &Data, sizeof(Data), &ActSz, OS_CHECK), OS_ERROR); } void Test_OS_QueuePut_Impl(void) @@ -96,14 +101,16 @@ void Test_OS_QueuePut_Impl(void) * Test Case For: * int32 OS_QueuePut_Impl (uint32 queue_id, const void *data, uint32 size, uint32 flags) */ - char Data[16] = "Test"; - OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(UT_INDEX_0, Data, sizeof(Data), 0), OS_SUCCESS); + char Data[16] = "Test"; + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(&token, Data, sizeof(Data), 0), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_msgQSend), OCS_ERROR); OCS_errno = OCS_S_objLib_OBJ_UNAVAILABLE; - OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(UT_INDEX_0, Data, sizeof(Data), 0), OS_QUEUE_FULL); + OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(&token, Data, sizeof(Data), 0), OS_QUEUE_FULL); OCS_errno = 0; - OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(UT_INDEX_0, Data, sizeof(Data), 0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_QueuePut_Impl(&token, Data, sizeof(Data), 0), OS_ERROR); } void Test_OS_QueueGetInfo_Impl(void) @@ -112,9 +119,11 @@ void Test_OS_QueueGetInfo_Impl(void) * Test Case For: * int32 OS_QueueGetInfo_Impl (uint32 queue_id, OS_queue_prop_t *queue_prop) */ - OS_queue_prop_t queue_prop; + OS_queue_prop_t queue_prop; + OS_object_token_t token = UT_TOKEN_0; + memset(&queue_prop, 0xEE, sizeof(queue_prop)); - OSAPI_TEST_FUNCTION_RC(OS_QueueGetInfo_Impl(UT_INDEX_0, &queue_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_QueueGetInfo_Impl(&token, &queue_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-shell.c b/src/unit-test-coverage/vxworks/src/coveragetest-shell.c index b9f547159..2195ff349 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-shell.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-shell.c @@ -37,8 +37,9 @@ void Test_OS_ShellOutputToFile_Impl(void) * Test Case For: * int32 OS_ShellOutputToFile_Impl(uint32 file_id, const char *Cmd) */ - int32 expected = OS_SUCCESS; - int32 actual; + int32 expected = OS_SUCCESS; + int32 actual; + OS_object_token_t token = UT_TOKEN_0; /* * The ShellOutputToFile will loop until the @@ -47,7 +48,7 @@ void Test_OS_ShellOutputToFile_Impl(void) */ UT_SetDeferredRetcode(UT_KEY(OCS_taskNameToId), 2, -1); - actual = OS_ShellOutputToFile_Impl(UT_INDEX_0, "TestCmd"); + actual = OS_ShellOutputToFile_Impl(&token, "TestCmd"); UtAssert_True(actual == expected, "OS_ShellOutputToFile_Impl() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_shellGenericInit)) == 1, "shellGenericInit() called"); @@ -55,7 +56,7 @@ void Test_OS_ShellOutputToFile_Impl(void) /* failure to open the output file */ UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); expected = OS_ERROR; - actual = OS_ShellOutputToFile_Impl(UT_INDEX_0, "TestCmd"); + actual = OS_ShellOutputToFile_Impl(&token, "TestCmd"); UtAssert_True(actual == expected, "OS_ShellOutputToFile_Impl() (%ld) == OS_ERROR", (long)actual); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c index c7fddf233..9f7d9b9db 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c @@ -44,7 +44,6 @@ void Test_OS_GlobalSymbolLookup_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_GlobalSymbolLookup_Impl(NULL, NULL), OS_INVALID_POINTER); UT_SetDefaultReturnValue(UT_KEY(OCS_symFind), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_GlobalSymbolLookup_Impl(&SymAddr, "symname"), OS_ERROR); - } void Test_OS_ModuleSymbolLookup_Impl(void) @@ -52,11 +51,13 @@ void Test_OS_ModuleSymbolLookup_Impl(void) /* Test Case For: * int32 OS_ModuleSymbolLookup_Impl( uint32 local_id, cpuaddr *SymbolAddress, const char *SymbolName ) */ - cpuaddr SymAddr; + cpuaddr SymAddr; + OS_object_token_t token = UT_TOKEN_0; - OSAPI_TEST_FUNCTION_RC(OS_ModuleSymbolLookup_Impl(UT_INDEX_0, &SymAddr, "symname"), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(OS_ModuleSymbolLookup_Impl(UT_INDEX_0, NULL, NULL), OS_INVALID_POINTER); - UT_SetDefaultReturnValue(UT_KEY(OCS_symFind), OCS_ERROR); OSAPI_TEST_FUNCTION_RC(OS_ModuleSymbolLookup_Impl(UT_INDEX_0, &SymAddr, "symname"), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleSymbolLookup_Impl(&token, &SymAddr, "symname"), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_ModuleSymbolLookup_Impl(&token, NULL, NULL), OS_INVALID_POINTER); + UT_SetDefaultReturnValue(UT_KEY(OCS_symFind), OCS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_ModuleSymbolLookup_Impl(&token, &SymAddr, "symname"), OS_ERROR); } void Test_OS_SymTableIterator_Impl(void) diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c index 1705b5fc9..7f27a328d 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c @@ -54,7 +54,7 @@ void Test_OS_VxWorksEntry(void) * Test Case For: * static int OS_VxWorksEntry(int arg) */ - OSAPI_TEST_FUNCTION_RC(UT_TaskTest_CallEntryPoint(0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(UT_TaskTest_CallEntryPoint(OS_OBJECT_ID_UNDEFINED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OS_TaskEntryPoint)) == 1, "OS_TaskEntryPoint() called"); } @@ -64,6 +64,8 @@ void Test_OS_TaskCreate_Impl(void) * Test Case For: * int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags) */ + OS_object_token_t token = UT_TOKEN_0; + UT_SetDataBuffer(UT_KEY(OCS_malloc), TestHeap, sizeof(TestHeap), false); UT_SetDataBuffer(UT_KEY(OCS_free), TestHeap, sizeof(TestHeap), false); @@ -71,10 +73,10 @@ void Test_OS_TaskCreate_Impl(void) * The first call checks the failure path and ensures that a malloc failure gets handled */ OS_task_table[0].stack_size = 250; UT_SetDefaultReturnValue(UT_KEY(OCS_malloc), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, 0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(&token, 0), OS_ERROR); UT_ClearForceFail(UT_KEY(OCS_malloc)); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, OS_FP_ENABLED), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(&token, OS_FP_ENABLED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_malloc)) == 2, "malloc() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_free)) == 0, "free() not called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskInit)) == 1, "taskInit() called"); @@ -82,7 +84,7 @@ void Test_OS_TaskCreate_Impl(void) /* create again with smaller stack - this should re-use existing buffer */ OS_task_table[0].stack_size = 100; - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, OS_FP_ENABLED), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(&token, OS_FP_ENABLED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_malloc)) == 2, "malloc() not called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_free)) == 0, "free() not called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskInit)) == 2, "taskInit() called"); @@ -90,7 +92,7 @@ void Test_OS_TaskCreate_Impl(void) /* create again with larger stack - this should free existing and malloc() new buffer */ OS_task_table[0].stack_size = 400; - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, OS_FP_ENABLED), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(&token, OS_FP_ENABLED), OS_SUCCESS); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_malloc)) == 3, "malloc() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_free)) == 1, "free() called"); UtAssert_True(UT_GetStubCount(UT_KEY(OCS_taskInit)) == 3, "taskInit() called"); @@ -98,7 +100,7 @@ void Test_OS_TaskCreate_Impl(void) /* other failure modes */ UT_SetDefaultReturnValue(UT_KEY(OCS_taskInit), -1); - OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(UT_INDEX_0, 0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_TaskCreate_Impl(&token, 0), OS_ERROR); } void Test_OS_TaskMatch_Impl(void) @@ -107,10 +109,12 @@ void Test_OS_TaskMatch_Impl(void) * Test Case For: * int32 OS_TaskMatch_Impl(uint32 task_id) */ + OS_object_token_t token = UT_TOKEN_0; + UT_TaskTest_SetImplTaskId(UT_INDEX_0, OCS_taskIdSelf()); - OSAPI_TEST_FUNCTION_RC(OS_TaskMatch_Impl(UT_INDEX_0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskMatch_Impl(&token), OS_SUCCESS); UT_TaskTest_SetImplTaskId(UT_INDEX_0, (OCS_TASK_ID)0); - OSAPI_TEST_FUNCTION_RC(OS_TaskMatch_Impl(UT_INDEX_0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_TaskMatch_Impl(&token), OS_ERROR); } void Test_OS_TaskDelete_Impl(void) @@ -119,11 +123,13 @@ void Test_OS_TaskDelete_Impl(void) * Test Case For: * int32 OS_TaskDelete_Impl (uint32 task_id) */ - OSAPI_TEST_FUNCTION_RC(OS_TaskDelete_Impl(UT_INDEX_0), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_TaskDelete_Impl(&token), OS_SUCCESS); /* failure mode */ UT_SetDefaultReturnValue(UT_KEY(OCS_taskDelete), -1); - OSAPI_TEST_FUNCTION_RC(OS_TaskDelete_Impl(UT_INDEX_0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_TaskDelete_Impl(&token), OS_ERROR); } void Test_OS_TaskExit_Impl(void) @@ -157,10 +163,12 @@ void Test_OS_TaskSetPriority_Impl(void) * Test Case For: * int32 OS_TaskSetPriority_Impl (uint32 task_id, uint32 new_priority) */ - OSAPI_TEST_FUNCTION_RC(OS_TaskSetPriority_Impl(UT_INDEX_0, OSAL_PRIORITY_C(100)), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_TaskSetPriority_Impl(&token, OSAL_PRIORITY_C(100)), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_taskPrioritySet), OCS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_TaskSetPriority_Impl(UT_INDEX_0, OSAL_PRIORITY_C(100)), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_TaskSetPriority_Impl(&token, OSAL_PRIORITY_C(100)), OS_ERROR); } void Test_OS_TaskRegister_Impl(void) @@ -196,9 +204,11 @@ void Test_OS_TaskGetInfo_Impl(void) * Test Case For: * int32 OS_TaskGetInfo_Impl (uint32 task_id, OS_task_prop_t *task_prop) */ - OS_task_prop_t task_prop; + OS_task_prop_t task_prop; + OS_object_token_t token = UT_TOKEN_0; + memset(&task_prop, 0xEE, sizeof(task_prop)); - OSAPI_TEST_FUNCTION_RC(OS_TaskGetInfo_Impl(UT_INDEX_0, &task_prop), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TaskGetInfo_Impl(&token, &task_prop), OS_SUCCESS); } void Test_OS_TaskValidateSystemData_Impl(void) @@ -222,15 +232,16 @@ void Test_OS_TaskIdMatchSystemData_Impl(void) * Test Case For: * bool OS_TaskIdMatchSystemData_Impl(void *ref, uint32 local_id, const OS_common_record_t *obj) */ - OCS_TASK_ID test_sys_id; + OCS_TASK_ID test_sys_id; + OS_object_token_t token = UT_TOKEN_0; memset(&test_sys_id, 'x', sizeof(test_sys_id)); UT_TaskTest_SetImplTaskId(UT_INDEX_0, test_sys_id); - OSAPI_TEST_FUNCTION_RC(OS_TaskIdMatchSystemData_Impl(&test_sys_id, UT_INDEX_0, NULL), true); + OSAPI_TEST_FUNCTION_RC(OS_TaskIdMatchSystemData_Impl(&test_sys_id, &token, NULL), true); memset(&test_sys_id, 'y', sizeof(test_sys_id)); - OSAPI_TEST_FUNCTION_RC(OS_TaskIdMatchSystemData_Impl(&test_sys_id, UT_INDEX_0, NULL), false); + OSAPI_TEST_FUNCTION_RC(OS_TaskIdMatchSystemData_Impl(&test_sys_id, &token, NULL), false); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c index d001875bd..82098fe2c 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c @@ -50,7 +50,8 @@ void Test_OS_TimeBaseLock_Impl(void) /* Test Case For: * void OS_TimeBaseLock_Impl(uint32 local_id) */ - OS_TimeBaseLock_Impl(UT_INDEX_0); + OS_object_token_t token = UT_TOKEN_0; + OS_TimeBaseLock_Impl(&token); } void Test_OS_TimeBaseUnlock_Impl(void) @@ -58,7 +59,8 @@ void Test_OS_TimeBaseUnlock_Impl(void) /* Test Case For: * void OS_TimeBaseUnlock_Impl(uint32 local_id) */ - OS_TimeBaseUnlock_Impl(UT_INDEX_0); + OS_object_token_t token = UT_TOKEN_0; + OS_TimeBaseUnlock_Impl(&token); } static int32 UT_TimeBaseTest_TimeBaseRegHook(void *UserObj, int32 StubRetcode, uint32 CallCount, @@ -99,7 +101,8 @@ void Test_OS_TimeBaseCreate_Impl(void) /* Test Case For: * int32 OS_TimeBaseCreate_Impl(uint32 timer_id) */ - osal_id_t id; + osal_id_t id; + OS_object_token_t token = UT_TOKEN_0; /* * Test paths though the signal number assignment. @@ -111,17 +114,17 @@ void Test_OS_TimeBaseCreate_Impl(void) OS_global_timebase_table[1].active_id = id; UT_TimeBaseTest_Setup(UT_INDEX_1, OCS_SIGRTMIN, false); UT_SetDefaultReturnValue(UT_KEY(OCS_sigismember), true); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_UNAVAILABLE); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(&token), OS_TIMER_ERR_UNAVAILABLE); UT_ResetState(UT_KEY(OCS_sigismember)); /* fail to initialize the sem */ UT_SetDefaultReturnValue(UT_KEY(OCS_semMInitialize), -1); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_INTERNAL); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(&token), OS_TIMER_ERR_INTERNAL); UT_ClearForceFail(UT_KEY(OCS_semMInitialize)); /* fail to spawn the task */ UT_SetDefaultReturnValue(UT_KEY(OCS_taskSpawn), -1); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_INTERNAL); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(&token), OS_TIMER_ERR_INTERNAL); UT_ClearForceFail(UT_KEY(OCS_taskSpawn)); /* @@ -129,7 +132,7 @@ void Test_OS_TimeBaseCreate_Impl(void) * this mimics the situation where the reg global is never * set past OS_TimerRegState_INIT */ - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_TIMER_ERR_INTERNAL); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(&token), OS_TIMER_ERR_INTERNAL); /* * Do Nominal/success case now. @@ -137,7 +140,7 @@ void Test_OS_TimeBaseCreate_Impl(void) * mimic registration success */ UT_SetHookFunction(UT_KEY(OCS_taskSpawn), UT_TimeBaseTest_TimeBaseRegHook, NULL); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(UT_INDEX_0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseCreate_Impl(&token), OS_SUCCESS); /* * For coverage, call the OS_VxWorks_TimeBaseTask() function. @@ -147,13 +150,13 @@ void Test_OS_TimeBaseCreate_Impl(void) /* * Check outputs of OS_VxWorks_RegisterTimer() function. */ - UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0); - UT_TimeBaseTest_CallRegisterTimer(UT_INDEX_0); + UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_1); + UT_TimeBaseTest_CallRegisterTimer(OS_OBJECT_ID_UNDEFINED); UtAssert_True(UT_TimeBaseTest_CheckTimeBaseRegisteredState(UT_INDEX_0), "timer successfully registered"); - UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0); + UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_1); UT_SetDefaultReturnValue(UT_KEY(OCS_timer_create), -1); - UT_TimeBaseTest_CallRegisterTimer(UT_INDEX_0); + UT_TimeBaseTest_CallRegisterTimer(OS_OBJECT_ID_UNDEFINED); UtAssert_True(UT_TimeBaseTest_CheckTimeBaseErrorState(UT_INDEX_0), "timer registration failure state"); } @@ -166,6 +169,7 @@ void Test_OS_VxWorks_SigWait(void) int signo = OCS_SIGRTMIN; struct OCS_itimerspec config_value; osal_id_t id; + OS_object_token_t token = UT_TOKEN_0; memset(&id, 0x02, sizeof(id)); OS_global_timebase_table[0].active_id = id; @@ -176,7 +180,7 @@ void Test_OS_VxWorks_SigWait(void) UT_SetDataBuffer(UT_KEY(OCS_timer_settime), &config_value, sizeof(config_value), false); UT_SetDataBuffer(UT_KEY(OCS_timer_gettime), &config_value, sizeof(config_value), false); UT_TimeBaseTest_Setup(UT_INDEX_0, signo, true); - OS_TimeBaseSet_Impl(UT_INDEX_0, 1111111, 2222222); + OS_TimeBaseSet_Impl(&token, 1111111, 2222222); UT_SetDataBuffer(UT_KEY(OCS_sigwait), &signo, sizeof(signo), false); OSAPI_TEST_FUNCTION_RC(UT_TimeBaseTest_CallSigWaitFunc(UT_INDEX_0), 1111111); @@ -195,13 +199,15 @@ void Test_OS_TimeBaseSet_Impl(void) /* Test Case For: * int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time) */ - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(UT_INDEX_0, 1, 1), OS_ERR_NOT_IMPLEMENTED); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1, 1), OS_ERR_NOT_IMPLEMENTED); UT_TimeBaseTest_Setup(UT_INDEX_0, OCS_SIGRTMIN, false); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(UT_INDEX_0, 1, 1), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1, 1), OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OCS_timer_settime), -1); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(UT_INDEX_0, 1, 1), OS_TIMER_ERR_INVALID_ARGS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1, 1), OS_TIMER_ERR_INVALID_ARGS); } void Test_OS_TimeBaseDelete_Impl(void) @@ -209,8 +215,10 @@ void Test_OS_TimeBaseDelete_Impl(void) /* Test Case For: * int32 OS_TimeBaseDelete_Impl(uint32 timer_id) */ + OS_object_token_t token = UT_TOKEN_0; + UT_TimeBaseTest_Setup(UT_INDEX_0, OCS_SIGRTMIN, false); - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseDelete_Impl(UT_INDEX_0), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseDelete_Impl(&token), OS_SUCCESS); } void Test_OS_TimeBaseGetInfo_Impl(void) @@ -219,7 +227,9 @@ void Test_OS_TimeBaseGetInfo_Impl(void) * int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_prop) */ OS_timebase_prop_t timer_prop; - OSAPI_TEST_FUNCTION_RC(OS_TimeBaseGetInfo_Impl(UT_INDEX_0, &timer_prop), OS_SUCCESS); + OS_object_token_t token = UT_TOKEN_0; + + OSAPI_TEST_FUNCTION_RC(OS_TimeBaseGetInfo_Impl(&token, &timer_prop), OS_SUCCESS); } /* ------------------- End of test cases --------------------------------------*/ diff --git a/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h b/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h index 989f27da7..629929372 100644 --- a/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h +++ b/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h @@ -47,6 +47,22 @@ #define UT_INDEX_1 OSAL_INDEX_C(1) #define UT_INDEX_2 OSAL_INDEX_C(2) +#define UT_TOKEN_0 \ + (OS_object_token_t) \ + { \ + .obj_id = (osal_id_t) {0x10000}, .obj_idx = 0 \ + } +#define UT_TOKEN_1 \ + (OS_object_token_t) \ + { \ + .obj_id = (osal_id_t) {0x10001}, .obj_idx = 1 \ + } +#define UT_TOKEN_2 \ + (OS_object_token_t) \ + { \ + .obj_id = (osal_id_t) {0x10002}, .obj_idx = 2 \ + } + /* Osapi_Test_Setup * * Purpose: