source: mainline/uspace/lib/c/generic/io/window.c@ 36f0738

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 36f0738 was 25a179e, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 8 years ago

IPC return values are always errno constants. Adjust types to reflect that.

In principle, IPC server is not allowed to return non-errno values via
the "main" return value, because kernel interprets it (e.g. EHANGUP).
It's still possible to return arbitrary additional return values alongside EOK,
which are not interpreted in normal communication.

  • Property mode set to 100644
File size: 3.7 KB
RevLine 
[6d5e378]1/*
2 * Copyright (c) 2012 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/window.h>
38#include <io/window.h>
39
40#include <stdio.h>
41
[2c7fdaa]42int win_register(async_sess_t *sess, window_flags_t flags, service_id_t *in,
43 service_id_t *out)
[6d5e378]44{
45 async_exch_t *exch = async_exchange_begin(sess);
[2c7fdaa]46 int ret = async_req_1_2(exch, WINDOW_REGISTER, flags, in, out);
[6d5e378]47 async_exchange_end(exch);
[62fbb7e]48
[6d5e378]49 return ret;
50}
51
52int win_get_event(async_sess_t *sess, window_event_t *event)
53{
54 async_exch_t *exch = async_exchange_begin(sess);
55
56 ipc_call_t answer;
57 aid_t req = async_send_0(exch, WINDOW_GET_EVENT, &answer);
58
59 int rc = async_data_read_start(exch, event, sizeof(window_event_t));
60
61 async_exchange_end(exch);
62
[25a179e]63 int ret;
[6d5e378]64 async_wait_for(req, &ret);
65
66 if (rc != EOK) {
67 return rc;
68 } else if (ret != EOK) {
69 return ret;
70 } else {
71 return EOK;
72 }
73}
74
75int win_damage(async_sess_t *sess,
76 sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
77{
78 async_exch_t *exch = async_exchange_begin(sess);
79 int ret = async_req_4_0(exch, WINDOW_DAMAGE, x, y, width, height);
80 async_exchange_end(exch);
81
82 return ret;
83}
84
85int win_grab(async_sess_t *sess, sysarg_t pos_id, sysarg_t grab_flags)
86{
87 async_exch_t *exch = async_exchange_begin(sess);
88 int ret = async_req_2_0(exch, WINDOW_GRAB, pos_id, grab_flags);
89 async_exchange_end(exch);
90
91 return ret;
92}
93
[62fbb7e]94int win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width,
95 sysarg_t height, window_placement_flags_t placement_flags, void *cells)
[6d5e378]96{
97 async_exch_t *exch = async_exchange_begin(sess);
[62fbb7e]98
[6d5e378]99 ipc_call_t answer;
[62fbb7e]100 aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height,
101 (sysarg_t) placement_flags, &answer);
102
[6d5e378]103 int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
[62fbb7e]104
[6d5e378]105 async_exchange_end(exch);
[62fbb7e]106
[25a179e]107 int ret;
[6d5e378]108 async_wait_for(req, &ret);
[62fbb7e]109
110 if (rc != EOK)
[6d5e378]111 return rc;
[62fbb7e]112 else if (ret != EOK)
[6d5e378]113 return ret;
[62fbb7e]114
115 return EOK;
[6d5e378]116}
117
118int win_close(async_sess_t *sess)
119{
120 async_exch_t *exch = async_exchange_begin(sess);
121 int ret = async_req_0_0(exch, WINDOW_CLOSE);
122 async_exchange_end(exch);
123
124 return ret;
125}
126
127int win_close_request(async_sess_t *sess)
128{
129 async_exch_t *exch = async_exchange_begin(sess);
130 int ret = async_req_0_0(exch, WINDOW_CLOSE_REQUEST);
131 async_exchange_end(exch);
132
133 return ret;
134}
135
136/** @}
137 */
Note: See TracBrowser for help on using the repository browser.