update files to correct FSF address
[openocd.git] / src / jtag / drivers / versaloon / versaloon_include.h
blob177ec83aeb565c35d055a0b008f271df3241c29a
1 /***************************************************************************
2 * Copyright (C) 2009 by Simon Qian <SimonQian@SimonQian.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ***************************************************************************/
20 /* This file is used to include different header and macros */
21 /* according to different platform */
22 #include <jtag/interface.h>
23 #include <jtag/commands.h>
24 #include "usb_common.h"
26 #define PARAM_CHECK 1
28 #define sleep_ms(ms) jtag_sleep((ms) * 1000)
29 #define dimof(arr) (sizeof(arr) / sizeof((arr)[0]))
30 #define TO_STR(name) #name
32 #define RESULT int
33 #define LOG_BUG LOG_ERROR
35 /* Common error messages */
36 #define ERRMSG_NOT_ENOUGH_MEMORY "Lack of memory."
37 #define ERRCODE_NOT_ENOUGH_MEMORY ERROR_FAIL
39 #define ERRMSG_INVALID_VALUE "%d is invalid for %s."
40 #define ERRMSG_INVALID_INDEX "Index %d is invalid for %s."
41 #define ERRMSG_INVALID_USAGE "Invalid usage of %s"
42 #define ERRMSG_INVALID_TARGET "Invalid %s"
43 #define ERRMSG_INVALID_PARAMETER "Invalid parameter of %s."
44 #define ERRMSG_INVALID_INTERFACE_NUM "invalid inteface %d"
45 #define ERRMSG_INVALID_BUFFER "Buffer %s is not valid."
46 #define ERRCODE_INVALID_BUFFER ERROR_FAIL
47 #define ERRCODE_INVALID_PARAMETER ERROR_FAIL
49 #define ERRMSG_NOT_SUPPORT_BY "%s is not supported by %s."
51 #define ERRMSG_FAILURE_OPERATION "Fail to %s."
52 #define ERRMSG_FAILURE_OPERATION_ERRSTRING "Fail to %s, error string is %s."
53 #define ERRMSG_FAILURE_OPERATION_MESSAGE "Fail to %s, %s"
54 #define ERRCODE_FAILURE_OPERATION ERROR_FAIL
56 #define GET_U16_MSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 8) | \
57 ((*((uint8_t *)(p) + 1)) << 0))
58 #define GET_U32_MSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 24) | \
59 ((*((uint8_t *)(p) + 1)) << 16) | \
60 ((*((uint8_t *)(p) + 2)) << 8) | \
61 ((*((uint8_t *)(p) + 3)) << 0))
62 #define GET_U16_LSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 0) | \
63 ((*((uint8_t *)(p) + 1)) << 8))
64 #define GET_U32_LSBFIRST(p) (((*((uint8_t *)(p) + 0)) << 0) | \
65 ((*((uint8_t *)(p) + 1)) << 8) | \
66 ((*((uint8_t *)(p) + 2)) << 16) | \
67 ((*((uint8_t *)(p) + 3)) << 24))
69 #define SET_U16_MSBFIRST(p, v) \
70 do {\
71 *((uint8_t *)(p) + 0) = (((uint16_t)(v)) >> 8) & 0xFF;\
72 *((uint8_t *)(p) + 1) = (((uint16_t)(v)) >> 0) & 0xFF;\
73 } while (0)
74 #define SET_U32_MSBFIRST(p, v) \
75 do {\
76 *((uint8_t *)(p) + 0) = (((uint32_t)(v)) >> 24) & 0xFF;\
77 *((uint8_t *)(p) + 1) = (((uint32_t)(v)) >> 16) & 0xFF;\
78 *((uint8_t *)(p) + 2) = (((uint32_t)(v)) >> 8) & 0xFF;\
79 *((uint8_t *)(p) + 3) = (((uint32_t)(v)) >> 0) & 0xFF;\
80 } while (0)
81 #define SET_U16_LSBFIRST(p, v) \
82 do {\
83 *((uint8_t *)(p) + 0) = (((uint16_t)(v)) >> 0) & 0xFF;\
84 *((uint8_t *)(p) + 1) = (((uint16_t)(v)) >> 8) & 0xFF;\
85 } while (0)
86 #define SET_U32_LSBFIRST(p, v) \
87 do {\
88 *((uint8_t *)(p) + 0) = (((uint32_t)(v)) >> 0) & 0xFF;\
89 *((uint8_t *)(p) + 1) = (((uint32_t)(v)) >> 8) & 0xFF;\
90 *((uint8_t *)(p) + 2) = (((uint32_t)(v)) >> 16) & 0xFF;\
91 *((uint8_t *)(p) + 3) = (((uint32_t)(v)) >> 24) & 0xFF;\
92 } while (0)
94 #define GET_LE_U16(p) GET_U16_LSBFIRST(p)
95 #define GET_LE_U32(p) GET_U32_LSBFIRST(p)
96 #define GET_BE_U16(p) GET_U16_MSBFIRST(p)
97 #define GET_BE_U32(p) GET_U32_MSBFIRST(p)
98 #define SET_LE_U16(p, v) SET_U16_LSBFIRST(p, v)
99 #define SET_LE_U32(p, v) SET_U32_LSBFIRST(p, v)
100 #define SET_BE_U16(p, v) SET_U16_MSBFIRST(p, v)
101 #define SET_BE_U32(p, v) SET_U32_MSBFIRST(p, v)