]> git.sur5r.net Git - openocd/blob - src/jtag/drivers/versaloon/versaloon_include.h
Remove FSF address from GPL notices
[openocd] / src / jtag / drivers / versaloon / versaloon_include.h
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, see <http://www.gnu.org/licenses/>. *
16  ***************************************************************************/
17
18 /* This file is used to include different header and macros */
19 /* according to different platform */
20 #include <jtag/interface.h>
21 #include <jtag/commands.h>
22
23 #define PARAM_CHECK                                                     1
24
25 #define sleep_ms(ms)                                            jtag_sleep((ms) * 1000)
26 #define dimof(arr)                                                      (sizeof(arr) / sizeof((arr)[0]))
27 #define TO_STR(name)                                            #name
28
29 #define RESULT                                                          int
30 #define LOG_BUG                                                         LOG_ERROR
31
32 /* Common error messages */
33 #define ERRMSG_NOT_ENOUGH_MEMORY                        "Lack of memory."
34 #define ERRCODE_NOT_ENOUGH_MEMORY                       ERROR_FAIL
35
36 #define ERRMSG_INVALID_VALUE                            "%d is invalid for %s."
37 #define ERRMSG_INVALID_INDEX                            "Index %d is invalid for %s."
38 #define ERRMSG_INVALID_USAGE                            "Invalid usage of %s"
39 #define ERRMSG_INVALID_TARGET                           "Invalid %s"
40 #define ERRMSG_INVALID_PARAMETER                        "Invalid parameter of %s."
41 #define ERRMSG_INVALID_INTERFACE_NUM            "invalid inteface %d"
42 #define ERRMSG_INVALID_BUFFER                           "Buffer %s is not valid."
43 #define ERRCODE_INVALID_BUFFER                          ERROR_FAIL
44 #define ERRCODE_INVALID_PARAMETER                       ERROR_FAIL
45
46 #define ERRMSG_NOT_SUPPORT_BY                           "%s is not supported by %s."
47
48 #define ERRMSG_FAILURE_OPERATION                        "Fail to %s."
49 #define ERRMSG_FAILURE_OPERATION_MESSAGE        "Fail to %s, %s"
50 #define ERRCODE_FAILURE_OPERATION                       ERROR_FAIL
51
52 #define GET_U16_MSBFIRST(p)                     (((*((uint8_t *)(p) + 0)) << 8) | \
53                                                                         ((*((uint8_t *)(p) + 1)) << 0))
54 #define GET_U32_MSBFIRST(p)                     (((*((uint8_t *)(p) + 0)) << 24) | \
55                                                                         ((*((uint8_t *)(p) + 1)) << 16) | \
56                                                                         ((*((uint8_t *)(p) + 2)) << 8) | \
57                                                                         ((*((uint8_t *)(p) + 3)) << 0))
58 #define GET_U16_LSBFIRST(p)                     (((*((uint8_t *)(p) + 0)) << 0) | \
59                                                                         ((*((uint8_t *)(p) + 1)) << 8))
60 #define GET_U32_LSBFIRST(p)                     (((*((uint8_t *)(p) + 0)) << 0) | \
61                                                                         ((*((uint8_t *)(p) + 1)) << 8) | \
62                                                                         ((*((uint8_t *)(p) + 2)) << 16) | \
63                                                                         ((*((uint8_t *)(p) + 3)) << 24))
64
65 #define SET_U16_MSBFIRST(p, v)          \
66         do {\
67                 *((uint8_t *)(p) + 0) = (((uint16_t)(v)) >> 8) & 0xFF;\
68                 *((uint8_t *)(p) + 1) = (((uint16_t)(v)) >> 0) & 0xFF;\
69         } while (0)
70 #define SET_U32_MSBFIRST(p, v)          \
71         do {\
72                 *((uint8_t *)(p) + 0) = (((uint32_t)(v)) >> 24) & 0xFF;\
73                 *((uint8_t *)(p) + 1) = (((uint32_t)(v)) >> 16) & 0xFF;\
74                 *((uint8_t *)(p) + 2) = (((uint32_t)(v)) >> 8) & 0xFF;\
75                 *((uint8_t *)(p) + 3) = (((uint32_t)(v)) >> 0) & 0xFF;\
76         } while (0)
77 #define SET_U16_LSBFIRST(p, v)          \
78         do {\
79                 *((uint8_t *)(p) + 0) = (((uint16_t)(v)) >> 0) & 0xFF;\
80                 *((uint8_t *)(p) + 1) = (((uint16_t)(v)) >> 8) & 0xFF;\
81         } while (0)
82 #define SET_U32_LSBFIRST(p, v)          \
83         do {\
84                 *((uint8_t *)(p) + 0) = (((uint32_t)(v)) >> 0) & 0xFF;\
85                 *((uint8_t *)(p) + 1) = (((uint32_t)(v)) >> 8) & 0xFF;\
86                 *((uint8_t *)(p) + 2) = (((uint32_t)(v)) >> 16) & 0xFF;\
87                 *((uint8_t *)(p) + 3) = (((uint32_t)(v)) >> 24) & 0xFF;\
88         } while (0)
89
90 #define GET_LE_U16(p)                           GET_U16_LSBFIRST(p)
91 #define GET_LE_U32(p)                           GET_U32_LSBFIRST(p)
92 #define GET_BE_U16(p)                           GET_U16_MSBFIRST(p)
93 #define GET_BE_U32(p)                           GET_U32_MSBFIRST(p)
94 #define SET_LE_U16(p, v)                        SET_U16_LSBFIRST(p, v)
95 #define SET_LE_U32(p, v)                        SET_U32_LSBFIRST(p, v)
96 #define SET_BE_U16(p, v)                        SET_U16_MSBFIRST(p, v)
97 #define SET_BE_U32(p, v)                        SET_U32_MSBFIRST(p, v)