source: mainline/uspace/lib/c/generic/udebug.c@ b538ca5c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b538ca5c 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
RevLine 
[9a1b20c]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
[64d2b10]33 */
[9a1b20c]34
35#include <udebug.h>
36#include <sys/types.h>
[c0699467]37#include <abi/ipc/methods.h>
[9a1b20c]38#include <async.h>
39
[79ae36dd]40int udebug_begin(async_sess_t *sess)
[9a1b20c]41{
[79ae36dd]42 async_exch_t *exch = async_exchange_begin(sess);
43 return async_req_1_0(exch, IPC_M_DEBUG, UDEBUG_M_BEGIN);
[9a1b20c]44}
45
[79ae36dd]46int udebug_end(async_sess_t *sess)
[9a1b20c]47{
[79ae36dd]48 async_exch_t *exch = async_exchange_begin(sess);
49 return async_req_1_0(exch, IPC_M_DEBUG, UDEBUG_M_END);
[9a1b20c]50}
51
[79ae36dd]52int udebug_set_evmask(async_sess_t *sess, udebug_evmask_t mask)
[9a1b20c]53{
[79ae36dd]54 async_exch_t *exch = async_exchange_begin(sess);
55 return async_req_2_0(exch, IPC_M_DEBUG, UDEBUG_M_SET_EVMASK, mask);
[9a1b20c]56}
57
[79ae36dd]58int udebug_thread_read(async_sess_t *sess, void *buffer, size_t n,
59 size_t *copied, size_t *needed)
[9a1b20c]60{
[96b02eb9]61 sysarg_t a_copied, a_needed;
[79ae36dd]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
[2e3355a]70 return rc;
[9a1b20c]71}
72
[79ae36dd]73int udebug_name_read(async_sess_t *sess, void *buffer, size_t n,
74 size_t *copied, size_t *needed)
[3698e44]75{
[96b02eb9]76 sysarg_t a_copied, a_needed;
[79ae36dd]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
[3698e44]85 return rc;
86}
87
[79ae36dd]88int udebug_areas_read(async_sess_t *sess, void *buffer, size_t n,
89 size_t *copied, size_t *needed)
[336db295]90{
[96b02eb9]91 sysarg_t a_copied, a_needed;
[79ae36dd]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
[336db295]100 return rc;
101}
102
[79ae36dd]103int udebug_mem_read(async_sess_t *sess, void *buffer, uintptr_t addr, size_t n)
[9a1b20c]104{
[79ae36dd]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);
[9a1b20c]108}
109
[79ae36dd]110int udebug_args_read(async_sess_t *sess, thash_t tid, sysarg_t *buffer)
[9a1b20c]111{
[79ae36dd]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);
[9a1b20c]115}
116
[79ae36dd]117int udebug_regs_read(async_sess_t *sess, thash_t tid, void *buffer)
[80487bc5]118{
[79ae36dd]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);
[80487bc5]122}
123
[79ae36dd]124int udebug_go(async_sess_t *sess, thash_t tid, udebug_event_t *ev_type,
[9a1b20c]125 sysarg_t *val0, sysarg_t *val1)
126{
[96b02eb9]127 sysarg_t a_ev_type;
[79ae36dd]128
129 async_exch_t *exch = async_exchange_begin(sess);
130 int rc = async_req_2_3(exch, IPC_M_DEBUG, UDEBUG_M_GO,
[2e3355a]131 tid, &a_ev_type, val0, val1);
[79ae36dd]132
[2e3355a]133 *ev_type = a_ev_type;
134 return rc;
[9a1b20c]135}
136
[79ae36dd]137int udebug_stop(async_sess_t *sess, thash_t tid)
[9a1b20c]138{
[79ae36dd]139 async_exch_t *exch = async_exchange_begin(sess);
140 return async_req_2_0(exch, IPC_M_DEBUG, UDEBUG_M_STOP, tid);
[9a1b20c]141}
142
143/** @}
144 */
Note: See TracBrowser for help on using the repository browser.