source: mainline/uspace/lib/c/generic/io/visualizer.c@ 1433ecda

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1433ecda was 1433ecda, checked in by Jiri Svoboda <jiri@…>, 7 years ago

Fix cstyle: make ccheck-fix and commit only files where all the changes are good.

  • Property mode set to 100644
File size: 5.2 KB
Line 
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
35#include <assert.h>
36#include <errno.h>
37#include <as.h>
38#include <ipc/graph.h>
39#include <io/visualizer.h>
40
41errno_t visualizer_claim(async_sess_t *sess, sysarg_t notif_callback_id)
42{
43 async_exch_t *exch = async_exchange_begin(sess);
44 errno_t ret = async_req_1_0(exch, VISUALIZER_CLAIM, notif_callback_id);
45 async_exchange_end(exch);
46
47 return ret;
48}
49
50errno_t visualizer_yield(async_sess_t *sess)
51{
52 async_exch_t *exch = async_exchange_begin(sess);
53 errno_t ret = async_req_0_0(exch, VISUALIZER_YIELD);
54 async_exchange_end(exch);
55
56 return ret;
57}
58
59errno_t visualizer_enumerate_modes(async_sess_t *sess, vslmode_t *mode, sysarg_t nth)
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
66 errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
67
68 async_exchange_end(exch);
69
70 errno_t ret;
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
82errno_t visualizer_get_default_mode(async_sess_t *sess, vslmode_t *mode)
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
89 errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
90
91 async_exchange_end(exch);
92
93 errno_t ret;
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
105errno_t visualizer_get_current_mode(async_sess_t *sess, vslmode_t *mode)
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
112 errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
113
114 async_exchange_end(exch);
115
116 errno_t ret;
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
128errno_t visualizer_get_mode(async_sess_t *sess, vslmode_t *mode, sysarg_t index)
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
135 errno_t rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
136
137 async_exchange_end(exch);
138
139 errno_t ret;
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
151errno_t visualizer_set_mode(async_sess_t *sess, sysarg_t index, sysarg_t version, void *cells)
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
158 errno_t rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
159
160 async_exchange_end(exch);
161
162 errno_t ret;
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
174errno_t visualizer_update_damaged_region(async_sess_t *sess,
175 sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height,
176 sysarg_t x_offset, sysarg_t y_offset)
177{
178 assert(x_offset <= UINT16_MAX);
179 assert(y_offset <= UINT16_MAX);
180
181 sysarg_t offsets = ((x_offset << 16) | (y_offset & 0x0000ffff));
182
183 async_exch_t *exch = async_exchange_begin(sess);
184 errno_t ret = async_req_5_0(exch, VISUALIZER_UPDATE_DAMAGED_REGION,
185 x, y, width, height, offsets);
186 async_exchange_end(exch);
187
188 return ret;
189}
190
191errno_t visualizer_suspend(async_sess_t *sess)
192{
193 async_exch_t *exch = async_exchange_begin(sess);
194 errno_t ret = async_req_0_0(exch, VISUALIZER_SUSPEND);
195 async_exchange_end(exch);
196
197 return ret;
198}
199
200errno_t visualizer_wakeup(async_sess_t *sess)
201{
202 async_exch_t *exch = async_exchange_begin(sess);
203 errno_t ret = async_req_0_0(exch, VISUALIZER_WAKE_UP);
204 async_exchange_end(exch);
205
206 return ret;
207}
208
209/** @}
210 */
Note: See TracBrowser for help on using the repository browser.