Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3b3fcf36 in mainline for uspace/lib/c/generic/ipc_test.c


Ignore:
Timestamp:
2018-11-20T10:53:13Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
a615be0
Parents:
8be3230
git-author:
Jiri Svoboda <jiri@…> (2018-11-19 18:49:18)
git-committer:
Jiri Svoboda <jiri@…> (2018-11-20 10:53:13)
Message:

IPC share-in test using text and data segment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ipc_test.c

    r8be3230 r3b3fcf36  
    3434
    3535#include <abi/ipc/interfaces.h>
     36#include <as.h>
    3637#include <errno.h>
    3738#include <ipc/services.h>
     
    111112}
    112113
     114/** Get size of shared read-only memory area.
     115 *
     116 * @param test IPC test service
     117 * @param rsize Place to store size of the shared area
     118 * @return EOK on success or an error code
     119 */
     120errno_t ipc_test_get_ro_area_size(ipc_test_t *test, size_t *rsize)
     121{
     122        async_exch_t *exch;
     123        errno_t retval;
     124        sysarg_t size;
     125
     126        exch = async_exchange_begin(test->sess);
     127        retval = async_req_0_1(exch, IPC_TEST_GET_RO_AREA_SIZE, &size);
     128        async_exchange_end(exch);
     129
     130        if (retval != EOK)
     131                return retval;
     132
     133        *rsize = size;
     134        return EOK;
     135}
     136
     137/** Get size of shared read-write memory area.
     138 *
     139 * @param test IPC test service
     140 * @param rsize Place to store size of the shared area
     141 * @return EOK on success or an error code
     142 */
     143errno_t ipc_test_get_rw_area_size(ipc_test_t *test, size_t *rsize)
     144{
     145        async_exch_t *exch;
     146        errno_t retval;
     147        sysarg_t size;
     148
     149        exch = async_exchange_begin(test->sess);
     150        retval = async_req_0_1(exch, IPC_TEST_GET_RW_AREA_SIZE, &size);
     151        async_exchange_end(exch);
     152
     153        if (retval != EOK)
     154                return retval;
     155
     156        *rsize = size;
     157        return EOK;
     158}
     159
     160/** Test share-in of read-only area.
     161 *
     162 * @param test IPC test service
     163 * @param size Size of the shared area
     164 * @param rptr Place to store pointer to the shared-in area
     165 * @return EOK on success or an error code
     166 */
     167errno_t ipc_test_share_in_ro(ipc_test_t *test, size_t size, const void **rptr)
     168{
     169        async_exch_t *exch;
     170        ipc_call_t answer;
     171        aid_t req;
     172        void *dst;
     173        errno_t rc;
     174
     175        exch = async_exchange_begin(test->sess);
     176        req = async_send_0(exch, IPC_TEST_SHARE_IN_RO, &answer);
     177
     178        dst = NULL;
     179        rc = async_share_in_start_0_0(exch, size, &dst);
     180        if (rc != EOK || dst == AS_MAP_FAILED) {
     181                async_exchange_end(exch);
     182                async_forget(req);
     183                return ENOMEM;
     184        }
     185
     186        async_exchange_end(exch);
     187        async_wait_for(req, NULL);
     188        *rptr = dst;
     189        return EOK;
     190}
     191
     192/** Test share-in of read-write area.
     193 *
     194 * @param test IPC test service
     195 * @param size Size of the shared area
     196 * @param rptr Place to store pointer to the shared-in area
     197 * @return EOK on success or an error code
     198 */
     199errno_t ipc_test_share_in_rw(ipc_test_t *test, size_t size, void **rptr)
     200{
     201        async_exch_t *exch;
     202        ipc_call_t answer;
     203        aid_t req;
     204        void *dst;
     205        errno_t rc;
     206
     207        exch = async_exchange_begin(test->sess);
     208        req = async_send_0(exch, IPC_TEST_SHARE_IN_RW, &answer);
     209
     210        rc = async_share_in_start_0_0(exch, size, &dst);
     211        if (rc != EOK || dst == AS_MAP_FAILED) {
     212                async_exchange_end(exch);
     213                async_forget(req);
     214                return ENOMEM;
     215        }
     216
     217        async_exchange_end(exch);
     218        async_wait_for(req, NULL);
     219        *rptr = dst;
     220        return EOK;
     221}
     222
    113223/** @}
    114224 */
Note: See TracChangeset for help on using the changeset viewer.