[6d5e378] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Petr Koupy
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libc
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[1c5c96d] | 35 | #include <assert.h>
|
---|
[6d5e378] | 36 | #include <errno.h>
|
---|
| 37 | #include <as.h>
|
---|
| 38 | #include <ipc/graph.h>
|
---|
| 39 | #include <io/visualizer.h>
|
---|
| 40 |
|
---|
[b7fd2a0] | 41 | errno_t visualizer_claim(async_sess_t *sess, sysarg_t notif_callback_id)
|
---|
[6d5e378] | 42 | {
|
---|
| 43 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 44 | errno_t ret = async_req_1_0(exch, VISUALIZER_CLAIM, notif_callback_id);
|
---|
[6d5e378] | 45 | async_exchange_end(exch);
|
---|
| 46 |
|
---|
| 47 | return ret;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[b7fd2a0] | 50 | errno_t visualizer_yield(async_sess_t *sess)
|
---|
[6d5e378] | 51 | {
|
---|
| 52 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 53 | errno_t ret = async_req_0_0(exch, VISUALIZER_YIELD);
|
---|
[6d5e378] | 54 | async_exchange_end(exch);
|
---|
| 55 |
|
---|
| 56 | return ret;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[b7fd2a0] | 59 | errno_t visualizer_enumerate_modes(async_sess_t *sess, vslmode_t *mode, sysarg_t nth)
|
---|
[6d5e378] | 60 | {
|
---|
| 61 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 62 |
|
---|
| 63 | ipc_call_t answer;
|
---|
| 64 | aid_t req = async_send_1(exch, VISUALIZER_ENUMERATE_MODES, nth, &answer);
|
---|
| 65 |
|
---|
[b7fd2a0] | 66 | errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
[6d5e378] | 67 |
|
---|
| 68 | async_exchange_end(exch);
|
---|
| 69 |
|
---|
[b7fd2a0] | 70 | errno_t ret;
|
---|
[6d5e378] | 71 | async_wait_for(req, &ret);
|
---|
| 72 |
|
---|
| 73 | if (rc != EOK) {
|
---|
| 74 | return rc;
|
---|
| 75 | } else if (ret != EOK) {
|
---|
| 76 | return ret;
|
---|
| 77 | } else {
|
---|
| 78 | return EOK;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[b7fd2a0] | 82 | errno_t visualizer_get_default_mode(async_sess_t *sess, vslmode_t *mode)
|
---|
[6d5e378] | 83 | {
|
---|
| 84 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 85 |
|
---|
| 86 | ipc_call_t answer;
|
---|
| 87 | aid_t req = async_send_0(exch, VISUALIZER_GET_DEFAULT_MODE, &answer);
|
---|
| 88 |
|
---|
[b7fd2a0] | 89 | errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
[6d5e378] | 90 |
|
---|
| 91 | async_exchange_end(exch);
|
---|
| 92 |
|
---|
[b7fd2a0] | 93 | errno_t ret;
|
---|
[6d5e378] | 94 | async_wait_for(req, &ret);
|
---|
| 95 |
|
---|
| 96 | if (rc != EOK) {
|
---|
| 97 | return rc;
|
---|
| 98 | } else if (ret != EOK) {
|
---|
| 99 | return ret;
|
---|
| 100 | } else {
|
---|
| 101 | return EOK;
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[b7fd2a0] | 105 | errno_t visualizer_get_current_mode(async_sess_t *sess, vslmode_t *mode)
|
---|
[6d5e378] | 106 | {
|
---|
| 107 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 108 |
|
---|
| 109 | ipc_call_t answer;
|
---|
| 110 | aid_t req = async_send_0(exch, VISUALIZER_GET_CURRENT_MODE, &answer);
|
---|
| 111 |
|
---|
[b7fd2a0] | 112 | errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
[6d5e378] | 113 |
|
---|
| 114 | async_exchange_end(exch);
|
---|
| 115 |
|
---|
[b7fd2a0] | 116 | errno_t ret;
|
---|
[6d5e378] | 117 | async_wait_for(req, &ret);
|
---|
| 118 |
|
---|
| 119 | if (rc != EOK) {
|
---|
| 120 | return rc;
|
---|
| 121 | } else if (ret != EOK) {
|
---|
| 122 | return ret;
|
---|
| 123 | } else {
|
---|
| 124 | return EOK;
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[b7fd2a0] | 128 | errno_t visualizer_get_mode(async_sess_t *sess, vslmode_t *mode, sysarg_t index)
|
---|
[6d5e378] | 129 | {
|
---|
| 130 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 131 |
|
---|
| 132 | ipc_call_t answer;
|
---|
| 133 | aid_t req = async_send_1(exch, VISUALIZER_GET_MODE, index, &answer);
|
---|
| 134 |
|
---|
[b7fd2a0] | 135 | errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
[6d5e378] | 136 |
|
---|
| 137 | async_exchange_end(exch);
|
---|
| 138 |
|
---|
[b7fd2a0] | 139 | errno_t ret;
|
---|
[6d5e378] | 140 | async_wait_for(req, &ret);
|
---|
| 141 |
|
---|
| 142 | if (rc != EOK) {
|
---|
| 143 | return rc;
|
---|
| 144 | } else if (ret != EOK) {
|
---|
| 145 | return ret;
|
---|
| 146 | } else {
|
---|
| 147 | return EOK;
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
| 150 |
|
---|
[b7fd2a0] | 151 | errno_t visualizer_set_mode(async_sess_t *sess, sysarg_t index, sysarg_t version, void *cells)
|
---|
[6d5e378] | 152 | {
|
---|
| 153 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 154 |
|
---|
| 155 | ipc_call_t answer;
|
---|
| 156 | aid_t req = async_send_2(exch, VISUALIZER_SET_MODE, index, version, &answer);
|
---|
| 157 |
|
---|
[b7fd2a0] | 158 | errno_t rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
|
---|
[6d5e378] | 159 |
|
---|
| 160 | async_exchange_end(exch);
|
---|
| 161 |
|
---|
[b7fd2a0] | 162 | errno_t ret;
|
---|
[6d5e378] | 163 | async_wait_for(req, &ret);
|
---|
| 164 |
|
---|
| 165 | if (rc != EOK) {
|
---|
| 166 | return rc;
|
---|
| 167 | } else if (ret != EOK) {
|
---|
| 168 | return ret;
|
---|
| 169 | } else {
|
---|
| 170 | return EOK;
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 |
|
---|
[b7fd2a0] | 174 | errno_t visualizer_update_damaged_region(async_sess_t *sess,
|
---|
[6d5e378] | 175 | sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height,
|
---|
[1433ecda] | 176 | sysarg_t x_offset, sysarg_t y_offset)
|
---|
[6d5e378] | 177 | {
|
---|
[1c5c96d] | 178 | assert(x_offset <= UINT16_MAX);
|
---|
| 179 | assert(y_offset <= UINT16_MAX);
|
---|
| 180 |
|
---|
[6d5e378] | 181 | sysarg_t offsets = ((x_offset << 16) | (y_offset & 0x0000ffff));
|
---|
| 182 |
|
---|
| 183 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 184 | errno_t ret = async_req_5_0(exch, VISUALIZER_UPDATE_DAMAGED_REGION,
|
---|
[6d5e378] | 185 | x, y, width, height, offsets);
|
---|
| 186 | async_exchange_end(exch);
|
---|
| 187 |
|
---|
| 188 | return ret;
|
---|
| 189 | }
|
---|
| 190 |
|
---|
[b7fd2a0] | 191 | errno_t visualizer_suspend(async_sess_t *sess)
|
---|
[6d5e378] | 192 | {
|
---|
| 193 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 194 | errno_t ret = async_req_0_0(exch, VISUALIZER_SUSPEND);
|
---|
[6d5e378] | 195 | async_exchange_end(exch);
|
---|
| 196 |
|
---|
| 197 | return ret;
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[b7fd2a0] | 200 | errno_t visualizer_wakeup(async_sess_t *sess)
|
---|
[6d5e378] | 201 | {
|
---|
| 202 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 203 | errno_t ret = async_req_0_0(exch, VISUALIZER_WAKE_UP);
|
---|
[6d5e378] | 204 | async_exchange_end(exch);
|
---|
| 205 |
|
---|
| 206 | return ret;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | /** @}
|
---|
| 210 | */
|
---|