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 
25 uint8_t inp_next(struct ud *);
26 uint8_t inp_peek(struct ud *);
27 uint8_t inp_uint8(struct ud *);
28 uint16_t inp_uint16(struct ud *);
29 uint32_t inp_uint32(struct ud *);
30 uint64_t inp_uint64(struct ud *);
31 void inp_move(struct ud *, size_t);
32 void inp_back(struct ud *);
33 
34 /* inp_init() - Initializes the input system. */
35 #define inp_init(u) \
36  do \
37  { \
38  u->inp_curr = 0; \
39  u->inp_fill = 0; \
40  u->inp_ctr = 0; \
41  u->inp_end = 0; \
42  } while (0)
43 
44 /* inp_start() - Should be called before each de-code operation. */
45 #define inp_start(u) u->inp_ctr = 0
46 
47 /* inp_back() - Resets the current pointer to its position before the current
48  * instruction disassembly was started.
49  */
50 #define inp_reset(u) \
51  do \
52  { \
53  u->inp_curr -= u->inp_ctr; \
54  u->inp_ctr = 0; \
55  } while (0)
56 
57 /* inp_sess() - Returns the pointer to current session. */
58 #define inp_sess(u) (u->inp_sess)
59 
60 /* inp_cur() - Returns the current input byte. */
61 #define inp_curr(u) ((u)->inp_cache[(u)->inp_curr])
62 
63 #endif