[7c014d1] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Martin Decky
|
---|
| 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 <async.h>
|
---|
| 36 | #include <errno.h>
|
---|
| 37 | #include <as.h>
|
---|
| 38 | #include "fb.h"
|
---|
| 39 |
|
---|
| 40 | static async_exch_t *vp_exchange_begin(async_sess_t *sess, vp_handle_t vp)
|
---|
| 41 | {
|
---|
| 42 | vp_handle_t cur_vp = (vp_handle_t) async_remote_state_acquire(sess);
|
---|
| 43 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 44 |
|
---|
| 45 | if (cur_vp != vp) {
|
---|
| 46 | int ret = async_req_1_0(exch, FB_VP_FOCUS, vp);
|
---|
| 47 | if (ret != EOK) {
|
---|
| 48 | async_exchange_end(exch);
|
---|
| 49 | return NULL;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | async_remote_state_update(sess, (void *) vp);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | return exch;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | static void vp_exchange_end(async_exch_t *exch)
|
---|
| 59 | {
|
---|
| 60 | async_remote_state_release_exchange(exch);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | int fb_get_resolution(async_sess_t *sess, sysarg_t *maxx, sysarg_t *maxy)
|
---|
| 64 | {
|
---|
| 65 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 66 | int ret = async_req_0_2(exch, FB_GET_RESOLUTION, maxx, maxy);
|
---|
| 67 | async_exchange_end(exch);
|
---|
| 68 |
|
---|
| 69 | return ret;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | int fb_yield(async_sess_t *sess)
|
---|
| 73 | {
|
---|
| 74 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 75 | int ret = async_req_0_0(exch, FB_YIELD);
|
---|
| 76 | async_exchange_end(exch);
|
---|
| 77 |
|
---|
| 78 | return ret;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | int fb_claim(async_sess_t *sess)
|
---|
| 82 | {
|
---|
| 83 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 84 | int ret = async_req_0_0(exch, FB_CLAIM);
|
---|
| 85 | async_exchange_end(exch);
|
---|
| 86 |
|
---|
| 87 | return ret;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | int fb_pointer_update(async_sess_t *sess, sysarg_t x, sysarg_t y, bool visible)
|
---|
| 91 | {
|
---|
| 92 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 93 | int ret = async_req_3_0(exch, FB_POINTER_UPDATE, x, y, visible);
|
---|
| 94 | async_exchange_end(exch);
|
---|
| 95 |
|
---|
| 96 | return ret;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | vp_handle_t fb_vp_create(async_sess_t *sess, sysarg_t x, sysarg_t y,
|
---|
| 100 | sysarg_t width, sysarg_t height)
|
---|
| 101 | {
|
---|
| 102 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 103 |
|
---|
| 104 | vp_handle_t handle;
|
---|
| 105 | int ret = async_req_4_1(exch, FB_VP_CREATE, x, y, width, height,
|
---|
| 106 | &handle);
|
---|
| 107 |
|
---|
| 108 | async_exchange_end(exch);
|
---|
| 109 |
|
---|
| 110 | if (ret != EOK)
|
---|
| 111 | return 0;
|
---|
| 112 |
|
---|
| 113 | return handle;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | frontbuf_handle_t fb_frontbuf_create(async_sess_t *sess,
|
---|
| 117 | screenbuffer_t *frontbuf)
|
---|
| 118 | {
|
---|
| 119 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 120 |
|
---|
| 121 | ipc_call_t answer;
|
---|
| 122 | aid_t req = async_send_0(exch, FB_FRONTBUF_CREATE, &answer);
|
---|
| 123 | int rc = async_share_out_start(exch, frontbuf, AS_AREA_READ
|
---|
| 124 | | AS_AREA_WRITE | AS_AREA_CACHEABLE);
|
---|
| 125 |
|
---|
| 126 | async_exchange_end(exch);
|
---|
| 127 |
|
---|
| 128 | sysarg_t ret;
|
---|
| 129 | async_wait_for(req, &ret);
|
---|
| 130 |
|
---|
| 131 | if ((rc != EOK) || (ret != EOK))
|
---|
| 132 | return 0;
|
---|
| 133 |
|
---|
| 134 | return (frontbuf_handle_t) IPC_GET_ARG1(answer);
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | imagemap_handle_t fb_imagemap_create(async_sess_t *sess, imgmap_t *imgmap)
|
---|
| 138 | {
|
---|
| 139 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 140 |
|
---|
| 141 | ipc_call_t answer;
|
---|
| 142 | aid_t req = async_send_0(exch, FB_IMAGEMAP_CREATE, &answer);
|
---|
| 143 | int rc = async_share_out_start(exch, imgmap, AS_AREA_READ
|
---|
| 144 | | AS_AREA_WRITE | AS_AREA_CACHEABLE);
|
---|
| 145 |
|
---|
| 146 | async_exchange_end(exch);
|
---|
| 147 |
|
---|
| 148 | sysarg_t ret;
|
---|
| 149 | async_wait_for(req, &ret);
|
---|
| 150 |
|
---|
| 151 | if ((rc != EOK) || (ret != EOK))
|
---|
| 152 | return 0;
|
---|
| 153 |
|
---|
| 154 | return (imagemap_handle_t) IPC_GET_ARG1(answer);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | sequence_handle_t fb_sequence_create(async_sess_t *sess)
|
---|
| 158 | {
|
---|
| 159 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 160 |
|
---|
| 161 | sysarg_t ret;
|
---|
| 162 | int rc = async_req_0_1(exch, FB_SEQUENCE_CREATE, &ret);
|
---|
| 163 |
|
---|
| 164 | async_exchange_end(exch);
|
---|
| 165 |
|
---|
| 166 | if (rc != EOK)
|
---|
| 167 | return 0;
|
---|
| 168 |
|
---|
| 169 | return (sequence_handle_t) ret;
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | int fb_vp_get_dimensions(async_sess_t *sess, vp_handle_t vp, sysarg_t *cols,
|
---|
| 173 | sysarg_t *rows)
|
---|
| 174 | {
|
---|
| 175 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 176 | int ret = async_req_0_2(exch, FB_VP_GET_DIMENSIONS, cols, rows);
|
---|
| 177 | vp_exchange_end(exch);
|
---|
| 178 |
|
---|
| 179 | return ret;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | int fb_vp_get_caps(async_sess_t *sess, vp_handle_t vp, console_caps_t *ccaps)
|
---|
| 183 | {
|
---|
| 184 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 185 |
|
---|
| 186 | sysarg_t rv;
|
---|
| 187 | int ret = async_req_0_1(exch, FB_VP_GET_CAPS, &rv);
|
---|
| 188 |
|
---|
| 189 | vp_exchange_end(exch);
|
---|
| 190 |
|
---|
| 191 | if (ret == EOK)
|
---|
| 192 | *ccaps = (console_caps_t) rv;
|
---|
| 193 |
|
---|
| 194 | return ret;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | int fb_vp_clear(async_sess_t *sess, vp_handle_t vp)
|
---|
| 198 | {
|
---|
| 199 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 200 | int ret = async_req_0_0(exch, FB_VP_CLEAR);
|
---|
| 201 | vp_exchange_end(exch);
|
---|
| 202 |
|
---|
| 203 | return ret;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | int fb_vp_cursor_update(async_sess_t *sess, vp_handle_t vp,
|
---|
| 207 | frontbuf_handle_t frontbuf)
|
---|
| 208 | {
|
---|
| 209 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 210 | int ret = async_req_1_0(exch, FB_VP_CURSOR_UPDATE, frontbuf);
|
---|
| 211 | vp_exchange_end(exch);
|
---|
| 212 |
|
---|
| 213 | return ret;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | int fb_vp_set_style(async_sess_t *sess, vp_handle_t vp, console_style_t style)
|
---|
| 217 | {
|
---|
| 218 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 219 | int ret = async_req_1_0(exch, FB_VP_SET_STYLE, style);
|
---|
| 220 | vp_exchange_end(exch);
|
---|
| 221 |
|
---|
| 222 | return ret;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | int fb_vp_putchar(async_sess_t *sess, vp_handle_t vp, sysarg_t col,
|
---|
| 226 | sysarg_t row, wchar_t ch)
|
---|
| 227 | {
|
---|
| 228 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 229 | int ret = async_req_3_0(exch, FB_VP_PUTCHAR, col, row, ch);
|
---|
| 230 | vp_exchange_end(exch);
|
---|
| 231 |
|
---|
| 232 | return ret;
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | int fb_vp_update(async_sess_t *sess, vp_handle_t vp, frontbuf_handle_t frontbuf)
|
---|
| 236 | {
|
---|
| 237 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 238 | int ret = async_req_1_0(exch, FB_VP_UPDATE, frontbuf);
|
---|
| 239 | vp_exchange_end(exch);
|
---|
| 240 |
|
---|
| 241 | return ret;
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | int fb_vp_damage(async_sess_t *sess, vp_handle_t vp, frontbuf_handle_t frontbuf,
|
---|
| 245 | sysarg_t col, sysarg_t row, sysarg_t cols, sysarg_t rows)
|
---|
| 246 | {
|
---|
| 247 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 248 | int ret = async_req_5_0(exch, FB_VP_DAMAGE, frontbuf, col, row,
|
---|
| 249 | cols, rows);
|
---|
| 250 | vp_exchange_end(exch);
|
---|
| 251 |
|
---|
| 252 | return ret;
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | int fb_vp_imagemap_damage(async_sess_t *sess, vp_handle_t vp,
|
---|
| 256 | imagemap_handle_t imagemap, sysarg_t x, sysarg_t y, sysarg_t width,
|
---|
| 257 | sysarg_t height)
|
---|
| 258 | {
|
---|
| 259 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 260 | int ret = async_req_5_0(exch, FB_VP_IMAGEMAP_DAMAGE, imagemap, x, y,
|
---|
| 261 | width, height);
|
---|
| 262 | vp_exchange_end(exch);
|
---|
| 263 |
|
---|
| 264 | return ret;
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | int fb_sequence_add_imagemap(async_sess_t *sess, sequence_handle_t sequence,
|
---|
| 268 | imagemap_handle_t imagemap)
|
---|
| 269 | {
|
---|
| 270 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 271 | int ret = async_req_2_0(exch, FB_SEQUENCE_ADD_IMAGEMAP, sequence,
|
---|
| 272 | imagemap);
|
---|
| 273 | async_exchange_end(exch);
|
---|
| 274 |
|
---|
| 275 | return ret;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | int fb_vp_sequence_start(async_sess_t *sess, vp_handle_t vp,
|
---|
| 279 | sequence_handle_t sequence)
|
---|
| 280 | {
|
---|
| 281 | async_exch_t *exch = vp_exchange_begin(sess, vp);
|
---|
| 282 | int ret = async_req_1_0(exch, FB_VP_SEQUENCE_START, sequence);
|
---|
| 283 | vp_exchange_end(exch);
|
---|
| 284 |
|
---|
| 285 | return ret;
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | /** @}
|
---|
| 289 | */
|
---|