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 <errno.h>
|
---|
36 | #include <as.h>
|
---|
37 | #include <ipc/graph.h>
|
---|
38 | #include <io/visualizer.h>
|
---|
39 |
|
---|
40 | int visualizer_claim(async_sess_t *sess, sysarg_t notif_callback_id)
|
---|
41 | {
|
---|
42 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
43 | int ret = async_req_1_0(exch, VISUALIZER_CLAIM, notif_callback_id);
|
---|
44 | async_exchange_end(exch);
|
---|
45 |
|
---|
46 | return ret;
|
---|
47 | }
|
---|
48 |
|
---|
49 | int visualizer_yield(async_sess_t *sess)
|
---|
50 | {
|
---|
51 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
52 | int ret = async_req_0_0(exch, VISUALIZER_YIELD);
|
---|
53 | async_exchange_end(exch);
|
---|
54 |
|
---|
55 | return ret;
|
---|
56 | }
|
---|
57 |
|
---|
58 | int visualizer_enumerate_modes(async_sess_t *sess, vslmode_t *mode, sysarg_t nth)
|
---|
59 | {
|
---|
60 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
61 |
|
---|
62 | ipc_call_t answer;
|
---|
63 | aid_t req = async_send_1(exch, VISUALIZER_ENUMERATE_MODES, nth, &answer);
|
---|
64 |
|
---|
65 | int rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
66 |
|
---|
67 | async_exchange_end(exch);
|
---|
68 |
|
---|
69 | sysarg_t ret;
|
---|
70 | async_wait_for(req, &ret);
|
---|
71 |
|
---|
72 | if (rc != EOK) {
|
---|
73 | return rc;
|
---|
74 | } else if (ret != EOK) {
|
---|
75 | return ret;
|
---|
76 | } else {
|
---|
77 | return EOK;
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | int visualizer_get_default_mode(async_sess_t *sess, vslmode_t *mode)
|
---|
82 | {
|
---|
83 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
84 |
|
---|
85 | ipc_call_t answer;
|
---|
86 | aid_t req = async_send_0(exch, VISUALIZER_GET_DEFAULT_MODE, &answer);
|
---|
87 |
|
---|
88 | int rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
89 |
|
---|
90 | async_exchange_end(exch);
|
---|
91 |
|
---|
92 | sysarg_t ret;
|
---|
93 | async_wait_for(req, &ret);
|
---|
94 |
|
---|
95 | if (rc != EOK) {
|
---|
96 | return rc;
|
---|
97 | } else if (ret != EOK) {
|
---|
98 | return ret;
|
---|
99 | } else {
|
---|
100 | return EOK;
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 | int visualizer_get_current_mode(async_sess_t *sess, vslmode_t *mode)
|
---|
105 | {
|
---|
106 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
107 |
|
---|
108 | ipc_call_t answer;
|
---|
109 | aid_t req = async_send_0(exch, VISUALIZER_GET_CURRENT_MODE, &answer);
|
---|
110 |
|
---|
111 | int rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
112 |
|
---|
113 | async_exchange_end(exch);
|
---|
114 |
|
---|
115 | sysarg_t ret;
|
---|
116 | async_wait_for(req, &ret);
|
---|
117 |
|
---|
118 | if (rc != EOK) {
|
---|
119 | return rc;
|
---|
120 | } else if (ret != EOK) {
|
---|
121 | return ret;
|
---|
122 | } else {
|
---|
123 | return EOK;
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | int visualizer_get_mode(async_sess_t *sess, vslmode_t *mode, sysarg_t index)
|
---|
128 | {
|
---|
129 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
130 |
|
---|
131 | ipc_call_t answer;
|
---|
132 | aid_t req = async_send_1(exch, VISUALIZER_GET_MODE, index, &answer);
|
---|
133 |
|
---|
134 | int rc = async_data_read_start(exch, mode, sizeof(vslmode_t));
|
---|
135 |
|
---|
136 | async_exchange_end(exch);
|
---|
137 |
|
---|
138 | sysarg_t ret;
|
---|
139 | async_wait_for(req, &ret);
|
---|
140 |
|
---|
141 | if (rc != EOK) {
|
---|
142 | return rc;
|
---|
143 | } else if (ret != EOK) {
|
---|
144 | return ret;
|
---|
145 | } else {
|
---|
146 | return EOK;
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|
150 | int visualizer_set_mode(async_sess_t *sess, sysarg_t index, sysarg_t version, void *cells)
|
---|
151 | {
|
---|
152 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
153 |
|
---|
154 | ipc_call_t answer;
|
---|
155 | aid_t req = async_send_2(exch, VISUALIZER_SET_MODE, index, version, &answer);
|
---|
156 |
|
---|
157 | int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
|
---|
158 |
|
---|
159 | async_exchange_end(exch);
|
---|
160 |
|
---|
161 | sysarg_t ret;
|
---|
162 | async_wait_for(req, &ret);
|
---|
163 |
|
---|
164 | if (rc != EOK) {
|
---|
165 | return rc;
|
---|
166 | } else if (ret != EOK) {
|
---|
167 | return ret;
|
---|
168 | } else {
|
---|
169 | return EOK;
|
---|
170 | }
|
---|
171 | }
|
---|
172 |
|
---|
173 | int visualizer_update_damaged_region(async_sess_t *sess,
|
---|
174 | sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height,
|
---|
175 | sysarg_t x_offset, sysarg_t y_offset)
|
---|
176 | {
|
---|
177 | #ifdef __32_BITS__
|
---|
178 | sysarg_t offsets = ((x_offset << 16) | (y_offset & 0x0000ffff));
|
---|
179 | #else
|
---|
180 | sysarg_t offsets = ((x_offset << 32) | (y_offset & 0xffffffff));
|
---|
181 | #endif
|
---|
182 |
|
---|
183 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
184 | int 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 |
|
---|
191 | int visualizer_suspend(async_sess_t *sess)
|
---|
192 | {
|
---|
193 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
194 | int ret = async_req_0_0(exch, VISUALIZER_SUSPEND);
|
---|
195 | async_exchange_end(exch);
|
---|
196 |
|
---|
197 | return ret;
|
---|
198 | }
|
---|
199 |
|
---|
200 | int visualizer_wakeup(async_sess_t *sess)
|
---|
201 | {
|
---|
202 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
203 | int ret = async_req_0_0(exch, VISUALIZER_WAKE_UP);
|
---|
204 | async_exchange_end(exch);
|
---|
205 |
|
---|
206 | return ret;
|
---|
207 | }
|
---|
208 |
|
---|
209 | /** @}
|
---|
210 | */
|
---|