The Pedigree Project 0.1
input.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef UD_INPUT_H
21#define UD_INPUT_H
22
23#include "pedigree/kernel/debugger/libudis86/types.h"
24
25uint8_t inp_next(struct ud*);
26uint8_t inp_peek(struct ud*);
27uint8_t inp_uint8(struct ud*);
28uint16_t inp_uint16(struct ud*);
29uint32_t inp_uint32(struct ud*);
30uint64_t inp_uint64(struct ud*);
31void inp_move(struct ud*, size_t);
32void inp_back(struct ud*);
33
34/* inp_init() - Initializes the input system. */
35#define inp_init(u) \
36 do { \
37 u->inp_curr = 0; \
38 u->inp_fill = 0; \
39 u->inp_ctr = 0; \
40 u->inp_end = 0; \
41 } while (0)
42
43/* inp_start() - Should be called before each de-code operation. */
44#define inp_start(u) u->inp_ctr = 0
45
46/* inp_back() - Resets the current pointer to its position before the current
47 * instruction disassembly was started.
48 */
49#define inp_reset(u) \
50 do { \
51 u->inp_curr -= u->inp_ctr; \
52 u->inp_ctr = 0; \
53 } while (0)
54
55/* inp_sess() - Returns the pointer to current session. */
56#define inp_sess(u) (u->inp_sess)
57
58/* inp_cur() - Returns the current input byte. */
59#define inp_curr(u) ((u)->inp_cache[(u)->inp_curr])
60
61#endif