Changeset b252e87 in mainline for uspace/lib/ddev/src


Ignore:
Timestamp:
2020-02-11T11:17:22Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e1f2079
Parents:
b43edabe
git-author:
Jiri Svoboda <jiri@…> (2020-02-10 20:17:06)
git-committer:
Jiri Svoboda <jiri@…> (2020-02-11 11:17:22)
Message:

Add method for getting display device information

Location:
uspace/lib/ddev/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ddev/src/ddev.c

    rb43edabe rb252e87  
    111111}
    112112
     113/** Get display device information.
     114 *
     115 * @param ddev Display device
     116 * @param info Place to store information
     117 */
     118errno_t ddev_get_info(ddev_t *ddev, ddev_info_t *info)
     119{
     120        async_exch_t *exch;
     121        errno_t retval;
     122        ipc_call_t answer;
     123
     124        exch = async_exchange_begin(ddev->sess);
     125        aid_t req = async_send_0(exch, DDEV_GET_INFO, &answer);
     126
     127        errno_t rc = async_data_read_start(exch, info, sizeof(ddev_info_t));
     128        async_exchange_end(exch);
     129        if (rc != EOK) {
     130                async_forget(req);
     131                return rc;
     132        }
     133
     134        async_wait_for(req, &retval);
     135        if (retval != EOK)
     136                return rc;
     137
     138        return EOK;
     139}
     140
    113141/** @}
    114142 */
  • uspace/lib/ddev/src/ddev_srv.c

    rb43edabe rb252e87  
    7070}
    7171
     72/** Get display device information */
     73static void ddev_get_info_srv(ddev_srv_t *srv, ipc_call_t *icall)
     74{
     75        ddev_info_t info;
     76        errno_t rc;
     77
     78        printf("ddev_get_info_srv\n");
     79
     80        ipc_call_t call;
     81        size_t size;
     82        if (!async_data_read_receive(&call, &size)) {
     83                async_answer_0(&call, EREFUSED);
     84                async_answer_0(icall, EREFUSED);
     85                return;
     86        }
     87
     88        if (size != sizeof(ddev_info_t)) {
     89                async_answer_0(&call, EINVAL);
     90                async_answer_0(icall, EINVAL);
     91                return;
     92        }
     93
     94        if (srv->ops->get_info == NULL) {
     95                printf("get_info is NULL -> ENOTSUP\n");
     96                async_answer_0(&call, ENOTSUP);
     97                async_answer_0(icall, ENOTSUP);
     98                return;
     99        }
     100
     101        rc = srv->ops->get_info(srv->arg, &info);
     102        if (rc != EOK) {
     103                async_answer_0(&call, rc);
     104                async_answer_0(icall, rc);
     105                return;
     106        }
     107
     108        rc = async_data_read_finalize(&call, &info, sizeof(ddev_info_t));
     109        if (rc != EOK) {
     110                async_answer_0(icall, rc);
     111                return;
     112        }
     113
     114        async_answer_0(icall, EOK);
     115}
     116
    72117void ddev_conn(ipc_call_t *icall, ddev_srv_t *srv)
    73118{
     
    92137                case DDEV_GET_GC:
    93138                        ddev_get_gc_srv(srv, &call);
     139                        break;
     140                case DDEV_GET_INFO:
     141                        ddev_get_info_srv(srv, &call);
    94142                        break;
    95143                default:
Note: See TracChangeset for help on using the changeset viewer.