1 |
2 |
alfik |
/******************************************************************************
|
2 |
|
|
* *
|
3 |
|
|
* License Agreement *
|
4 |
|
|
* *
|
5 |
|
|
* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. *
|
6 |
|
|
* All rights reserved. *
|
7 |
|
|
* *
|
8 |
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
9 |
|
|
* copy of this software and associated documentation files (the "Software"), *
|
10 |
|
|
* to deal in the Software without restriction, including without limitation *
|
11 |
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
12 |
|
|
* and/or sell copies of the Software, and to permit persons to whom the *
|
13 |
|
|
* Software is furnished to do so, subject to the following conditions: *
|
14 |
|
|
* *
|
15 |
|
|
* The above copyright notice and this permission notice shall be included in *
|
16 |
|
|
* all copies or substantial portions of the Software. *
|
17 |
|
|
* *
|
18 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
19 |
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
20 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
21 |
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
22 |
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
23 |
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
24 |
|
|
* DEALINGS IN THE SOFTWARE. *
|
25 |
|
|
* *
|
26 |
|
|
* This agreement shall be governed in all respects by the laws of the State *
|
27 |
|
|
* of California and by the laws of the United States of America. *
|
28 |
|
|
* *
|
29 |
|
|
******************************************************************************/
|
30 |
|
|
|
31 |
|
|
#ifndef __ALT_AVALON_JTAG_UART_FD_H__
|
32 |
|
|
#define __ALT_AVALON_JTAG_UART_FD_H__
|
33 |
|
|
|
34 |
|
|
#include "sys/alt_dev.h"
|
35 |
|
|
|
36 |
|
|
#ifdef __cplusplus
|
37 |
|
|
extern "C"
|
38 |
|
|
{
|
39 |
|
|
#endif /* __cplusplus */
|
40 |
|
|
|
41 |
|
|
/*
|
42 |
|
|
* Externally referenced routines
|
43 |
|
|
*/
|
44 |
|
|
extern int altera_avalon_jtag_uart_read_fd (alt_fd* fd, char* ptr, int len);
|
45 |
|
|
extern int altera_avalon_jtag_uart_write_fd (alt_fd* fd, const char* ptr,
|
46 |
|
|
int len);
|
47 |
|
|
|
48 |
|
|
/*
|
49 |
|
|
* Device structure definition. This is needed by alt_sys_init in order to
|
50 |
|
|
* reserve memory for the device instance.
|
51 |
|
|
*/
|
52 |
|
|
|
53 |
|
|
typedef struct altera_avalon_jtag_uart_dev_s
|
54 |
|
|
{
|
55 |
|
|
alt_dev dev;
|
56 |
|
|
altera_avalon_jtag_uart_state state;
|
57 |
|
|
} altera_avalon_jtag_uart_dev;
|
58 |
|
|
|
59 |
|
|
/*
|
60 |
|
|
* Macros used by alt_sys_init when the ALT file descriptor facility is used.
|
61 |
|
|
*/
|
62 |
|
|
|
63 |
|
|
#ifdef ALTERA_AVALON_JTAG_UART_SMALL
|
64 |
|
|
|
65 |
|
|
#define ALTERA_AVALON_JTAG_UART_DEV_INSTANCE(name, d) \
|
66 |
|
|
static altera_avalon_jtag_uart_dev d = \
|
67 |
|
|
{ \
|
68 |
|
|
{ \
|
69 |
|
|
ALT_LLIST_ENTRY, \
|
70 |
|
|
name##_NAME, \
|
71 |
|
|
NULL, /* open */ \
|
72 |
|
|
NULL, /* close */ \
|
73 |
|
|
altera_avalon_jtag_uart_read_fd, \
|
74 |
|
|
altera_avalon_jtag_uart_write_fd, \
|
75 |
|
|
NULL, /* lseek */ \
|
76 |
|
|
NULL, /* fstat */ \
|
77 |
|
|
NULL, /* ioctl */ \
|
78 |
|
|
}, \
|
79 |
|
|
{ \
|
80 |
|
|
name##_BASE, \
|
81 |
|
|
} \
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
#define ALTERA_AVALON_JTAG_UART_DEV_INIT(name, d) alt_dev_reg (&d.dev)
|
85 |
|
|
|
86 |
|
|
#else /* !ALTERA_AVALON_JTAG_UART_SMALL */
|
87 |
|
|
|
88 |
|
|
extern int altera_avalon_jtag_uart_close_fd(alt_fd* fd);
|
89 |
|
|
extern int altera_avalon_jtag_uart_ioctl_fd (alt_fd* fd, int req, void* arg);
|
90 |
|
|
|
91 |
|
|
#define ALTERA_AVALON_JTAG_UART_DEV_INSTANCE(name, d) \
|
92 |
|
|
static altera_avalon_jtag_uart_dev d = \
|
93 |
|
|
{ \
|
94 |
|
|
{ \
|
95 |
|
|
ALT_LLIST_ENTRY, \
|
96 |
|
|
name##_NAME, \
|
97 |
|
|
NULL, /* open */ \
|
98 |
|
|
altera_avalon_jtag_uart_close_fd, \
|
99 |
|
|
altera_avalon_jtag_uart_read_fd, \
|
100 |
|
|
altera_avalon_jtag_uart_write_fd, \
|
101 |
|
|
NULL, /* lseek */ \
|
102 |
|
|
NULL, /* fstat */ \
|
103 |
|
|
altera_avalon_jtag_uart_ioctl_fd, \
|
104 |
|
|
}, \
|
105 |
|
|
{ \
|
106 |
|
|
name##_BASE, \
|
107 |
|
|
ALTERA_AVALON_JTAG_UART_DEFAULT_TIMEOUT, \
|
108 |
|
|
} \
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
#define ALTERA_AVALON_JTAG_UART_DEV_INIT(name, d) \
|
112 |
|
|
{ \
|
113 |
|
|
ALTERA_AVALON_JTAG_UART_STATE_INIT(name, d.state); \
|
114 |
|
|
\
|
115 |
|
|
/* make the device available to the system */ \
|
116 |
|
|
alt_dev_reg(&d.dev); \
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
#endif /* ALTERA_AVALON_JTAG_UART_SMALL */
|
120 |
|
|
|
121 |
|
|
#ifdef __cplusplus
|
122 |
|
|
}
|
123 |
|
|
#endif /* __cplusplus */
|
124 |
|
|
|
125 |
|
|
#endif /* __ALT_AVALON_JTAG_UART_FD_H__ */
|