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 <ipc/output.h>
|
---|
39 | #include <io/output.h>
|
---|
40 |
|
---|
41 | int output_yield(async_sess_t *sess)
|
---|
42 | {
|
---|
43 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
44 | int ret = async_req_0_0(exch, OUTPUT_YIELD);
|
---|
45 | async_exchange_end(exch);
|
---|
46 |
|
---|
47 | return ret;
|
---|
48 | }
|
---|
49 |
|
---|
50 | int output_claim(async_sess_t *sess)
|
---|
51 | {
|
---|
52 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
53 | int ret = async_req_0_0(exch, OUTPUT_CLAIM);
|
---|
54 | async_exchange_end(exch);
|
---|
55 |
|
---|
56 | return ret;
|
---|
57 | }
|
---|
58 |
|
---|
59 | int output_get_dimensions(async_sess_t *sess, sysarg_t *maxx, sysarg_t *maxy)
|
---|
60 | {
|
---|
61 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
62 | int ret = async_req_0_2(exch, OUTPUT_GET_DIMENSIONS, maxx, maxy);
|
---|
63 | async_exchange_end(exch);
|
---|
64 |
|
---|
65 | return ret;
|
---|
66 | }
|
---|
67 |
|
---|
68 | int output_get_caps(async_sess_t *sess, console_caps_t *ccaps)
|
---|
69 | {
|
---|
70 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
71 |
|
---|
72 | sysarg_t rv;
|
---|
73 | int ret = async_req_0_1(exch, OUTPUT_GET_CAPS, &rv);
|
---|
74 |
|
---|
75 | async_exchange_end(exch);
|
---|
76 |
|
---|
77 | if (ret == EOK)
|
---|
78 | *ccaps = (console_caps_t) rv;
|
---|
79 |
|
---|
80 | return ret;
|
---|
81 | }
|
---|
82 |
|
---|
83 | frontbuf_handle_t output_frontbuf_create(async_sess_t *sess,
|
---|
84 | chargrid_t *frontbuf)
|
---|
85 | {
|
---|
86 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
87 |
|
---|
88 | ipc_call_t answer;
|
---|
89 | aid_t req = async_send_0(exch, OUTPUT_FRONTBUF_CREATE, &answer);
|
---|
90 | int rc = async_share_out_start(exch, frontbuf, AS_AREA_READ
|
---|
91 | | AS_AREA_WRITE | AS_AREA_CACHEABLE);
|
---|
92 |
|
---|
93 | async_exchange_end(exch);
|
---|
94 |
|
---|
95 | sysarg_t ret;
|
---|
96 | async_wait_for(req, &ret);
|
---|
97 |
|
---|
98 | if ((rc != EOK) || (ret != EOK))
|
---|
99 | return 0;
|
---|
100 |
|
---|
101 | return (frontbuf_handle_t) IPC_GET_ARG1(answer);
|
---|
102 | }
|
---|
103 |
|
---|
104 | int output_set_style(async_sess_t *sess, console_style_t style)
|
---|
105 | {
|
---|
106 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
107 | int ret = async_req_1_0(exch, OUTPUT_SET_STYLE, style);
|
---|
108 | async_exchange_end(exch);
|
---|
109 |
|
---|
110 | return ret;
|
---|
111 | }
|
---|
112 |
|
---|
113 | int output_cursor_update(async_sess_t *sess, frontbuf_handle_t frontbuf)
|
---|
114 | {
|
---|
115 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
116 | int ret = async_req_1_0(exch, OUTPUT_CURSOR_UPDATE, frontbuf);
|
---|
117 | async_exchange_end(exch);
|
---|
118 |
|
---|
119 | return ret;
|
---|
120 | }
|
---|
121 |
|
---|
122 | int output_update(async_sess_t *sess, frontbuf_handle_t frontbuf)
|
---|
123 | {
|
---|
124 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
125 | int ret = async_req_1_0(exch, OUTPUT_UPDATE, frontbuf);
|
---|
126 | async_exchange_end(exch);
|
---|
127 |
|
---|
128 | return ret;
|
---|
129 | }
|
---|
130 |
|
---|
131 | int output_damage(async_sess_t *sess, frontbuf_handle_t frontbuf, sysarg_t col,
|
---|
132 | sysarg_t row, sysarg_t cols, sysarg_t rows)
|
---|
133 | {
|
---|
134 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
135 | int ret = async_req_5_0(exch, OUTPUT_DAMAGE, frontbuf, col, row,
|
---|
136 | cols, rows);
|
---|
137 | async_exchange_end(exch);
|
---|
138 |
|
---|
139 | return ret;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /** @}
|
---|
143 | */
|
---|