source: mainline/uspace/lib/c/generic/udebug.c@ 4c14b88

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4c14b88 was c0699467, checked in by Martin Decky <martin@…>, 14 years ago

do not provide general access to kernel headers from uspace, only allow specific headers to be accessed or shared
externalize headers which serve as kernel/uspace API/ABI into a special tree

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 * Copyright (c) 2008 Jiri Svoboda
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 <udebug.h>
36#include <sys/types.h>
37#include <abi/ipc/methods.h>
38#include <async.h>
39
40int udebug_begin(async_sess_t *sess)
41{
42 async_exch_t *exch = async_exchange_begin(sess);
43 return async_req_1_0(exch, IPC_M_DEBUG, UDEBUG_M_BEGIN);
44}
45
46int udebug_end(async_sess_t *sess)
47{
48 async_exch_t *exch = async_exchange_begin(sess);
49 return async_req_1_0(exch, IPC_M_DEBUG, UDEBUG_M_END);
50}
51
52int udebug_set_evmask(async_sess_t *sess, udebug_evmask_t mask)
53{
54 async_exch_t *exch = async_exchange_begin(sess);
55 return async_req_2_0(exch, IPC_M_DEBUG, UDEBUG_M_SET_EVMASK, mask);
56}
57
58int udebug_thread_read(async_sess_t *sess, void *buffer, size_t n,
59 size_t *copied, size_t *needed)
60{
61 sysarg_t a_copied, a_needed;
62
63 async_exch_t *exch = async_exchange_begin(sess);
64 int rc = async_req_3_3(exch, IPC_M_DEBUG, UDEBUG_M_THREAD_READ,
65 (sysarg_t) buffer, n, NULL, &a_copied, &a_needed);
66
67 *copied = (size_t) a_copied;
68 *needed = (size_t) a_needed;
69
70 return rc;
71}
72
73int udebug_name_read(async_sess_t *sess, void *buffer, size_t n,
74 size_t *copied, size_t *needed)
75{
76 sysarg_t a_copied, a_needed;
77
78 async_exch_t *exch = async_exchange_begin(sess);
79 int rc = async_req_3_3(exch, IPC_M_DEBUG, UDEBUG_M_NAME_READ,
80 (sysarg_t) buffer, n, NULL, &a_copied, &a_needed);
81
82 *copied = (size_t) a_copied;
83 *needed = (size_t) a_needed;
84
85 return rc;
86}
87
88int udebug_areas_read(async_sess_t *sess, void *buffer, size_t n,
89 size_t *copied, size_t *needed)
90{
91 sysarg_t a_copied, a_needed;
92
93 async_exch_t *exch = async_exchange_begin(sess);
94 int rc = async_req_3_3(exch, IPC_M_DEBUG, UDEBUG_M_AREAS_READ,
95 (sysarg_t) buffer, n, NULL, &a_copied, &a_needed);
96
97 *copied = (size_t) a_copied;
98 *needed = (size_t) a_needed;
99
100 return rc;
101}
102
103int udebug_mem_read(async_sess_t *sess, void *buffer, uintptr_t addr, size_t n)
104{
105 async_exch_t *exch = async_exchange_begin(sess);
106 return async_req_4_0(exch, IPC_M_DEBUG, UDEBUG_M_MEM_READ,
107 (sysarg_t) buffer, addr, n);
108}
109
110int udebug_args_read(async_sess_t *sess, thash_t tid, sysarg_t *buffer)
111{
112 async_exch_t *exch = async_exchange_begin(sess);
113 return async_req_3_0(exch, IPC_M_DEBUG, UDEBUG_M_ARGS_READ,
114 tid, (sysarg_t) buffer);
115}
116
117int udebug_regs_read(async_sess_t *sess, thash_t tid, void *buffer)
118{
119 async_exch_t *exch = async_exchange_begin(sess);
120 return async_req_3_0(exch, IPC_M_DEBUG, UDEBUG_M_REGS_READ,
121 tid, (sysarg_t) buffer);
122}
123
124int udebug_go(async_sess_t *sess, thash_t tid, udebug_event_t *ev_type,
125 sysarg_t *val0, sysarg_t *val1)
126{
127 sysarg_t a_ev_type;
128
129 async_exch_t *exch = async_exchange_begin(sess);
130 int rc = async_req_2_3(exch, IPC_M_DEBUG, UDEBUG_M_GO,
131 tid, &a_ev_type, val0, val1);
132
133 *ev_type = a_ev_type;
134 return rc;
135}
136
137int udebug_stop(async_sess_t *sess, thash_t tid)
138{
139 async_exch_t *exch = async_exchange_begin(sess);
140 return async_req_2_0(exch, IPC_M_DEBUG, UDEBUG_M_STOP, tid);
141}
142
143/** @}
144 */
Note: See TracBrowser for help on using the repository browser.