1 /*
2  * $Id$
3  *
4  * Copyright (C) 2002, 2003 ETC s.r.o.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  * 02111-1307, USA.
20  *
21  * Written by Marcel Telka <marcel@telka.sk>, 2002, 2003.
22  *
23  */
24 
25 #ifndef URJ_TAP_REGISTER_H
26 #define URJ_TAP_REGISTER_H
27 
28 #include "types.h"
29 #include <stdint.h>
30 
31 struct URJ_TAP_REGISTER
32 {
33     char *data;         /* (public, r/w) register data */
34     int len;            /* (public, r/o) register length */
35     char *string;       /* (private) string representation of register data */
36 };
37 
38 urj_tap_register_t *urj_tap_register_alloc (int len);
39 urj_tap_register_t *urj_tap_register_realloc (urj_tap_register_t *tr, int new_len);
40 urj_tap_register_t *urj_tap_register_duplicate (const urj_tap_register_t *tr);
41 void urj_tap_register_free (urj_tap_register_t *tr);
42 urj_tap_register_t *urj_tap_register_fill (urj_tap_register_t *tr, int val);
43 int urj_tap_register_set_string (urj_tap_register_t *tr, const char *str);
44 int urj_tap_register_set_string_bit_range (urj_tap_register_t *tr, const char *str, int msb, int lsb);
45 int urj_tap_register_set_value (urj_tap_register_t *tr, uint64_t val);
46 int urj_tap_register_set_value_bit_range (urj_tap_register_t *tr, uint64_t val, int msb, int lsb);
47 const char *urj_tap_register_get_string (const urj_tap_register_t *tr);
48 const char *urj_tap_register_get_string_bit_range (const urj_tap_register_t *tr, int msb, int lsb);
49 uint64_t urj_tap_register_get_value (const urj_tap_register_t *tr);
50 uint64_t urj_tap_register_get_value_bit_range (const urj_tap_register_t *tr, int msb, int lsb);
51 /** @return 0 or 1 on success; -1 on error */
52 int urj_tap_register_all_bits_same_value (const urj_tap_register_t *tr);
53 urj_tap_register_t *urj_tap_register_init (urj_tap_register_t *tr,
54                                            const char *value);
55 int urj_tap_register_compare (const urj_tap_register_t *tr,
56                               const urj_tap_register_t *tr2);
57 int urj_tap_register_match (const urj_tap_register_t *tr, const char *expr);
58 urj_tap_register_t *urj_tap_register_inc (urj_tap_register_t *tr);
59 urj_tap_register_t *urj_tap_register_dec (urj_tap_register_t *tr);
60 urj_tap_register_t *urj_tap_register_shift_right (urj_tap_register_t *tr,
61                                                   int shift);
62 urj_tap_register_t *urj_tap_register_shift_left (urj_tap_register_t *tr,
63                                                  int shift);
64 
65 #endif /* URJ_REGISTER_H */
66