1 |
8 |
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 |
|
|
#include "alt_types.h"
|
32 |
|
|
#include "sys/alt_dev.h"
|
33 |
|
|
#include "altera_avalon_jtag_uart.h"
|
34 |
|
|
|
35 |
|
|
extern int altera_avalon_jtag_uart_read(altera_avalon_jtag_uart_state* sp,
|
36 |
|
|
char* buffer, int space, int flags);
|
37 |
|
|
extern int altera_avalon_jtag_uart_write(altera_avalon_jtag_uart_state* sp,
|
38 |
|
|
const char* ptr, int count, int flags);
|
39 |
|
|
extern int altera_avalon_jtag_uart_ioctl(altera_avalon_jtag_uart_state* sp,
|
40 |
|
|
int req, void* arg);
|
41 |
|
|
extern int altera_avalon_jtag_uart_close(altera_avalon_jtag_uart_state* sp,
|
42 |
|
|
int flags);
|
43 |
|
|
|
44 |
|
|
/* ----------------------------------------------------------------------- */
|
45 |
|
|
/* --------------------- WRAPPERS FOR ALT FD SUPPORT --------------------- */
|
46 |
|
|
/*
|
47 |
|
|
*
|
48 |
|
|
*/
|
49 |
|
|
|
50 |
|
|
int
|
51 |
|
|
altera_avalon_jtag_uart_read_fd(alt_fd* fd, char* buffer, int space)
|
52 |
|
|
{
|
53 |
|
|
altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev;
|
54 |
|
|
|
55 |
|
|
return altera_avalon_jtag_uart_read(&dev->state, buffer, space,
|
56 |
|
|
fd->fd_flags);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
int
|
60 |
|
|
altera_avalon_jtag_uart_write_fd(alt_fd* fd, const char* buffer, int space)
|
61 |
|
|
{
|
62 |
|
|
altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev;
|
63 |
|
|
|
64 |
|
|
return altera_avalon_jtag_uart_write(&dev->state, buffer, space,
|
65 |
|
|
fd->fd_flags);
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
#ifndef ALTERA_AVALON_JTAG_UART_SMALL
|
69 |
|
|
|
70 |
|
|
int
|
71 |
|
|
altera_avalon_jtag_uart_close_fd(alt_fd* fd)
|
72 |
|
|
{
|
73 |
|
|
altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev;
|
74 |
|
|
|
75 |
|
|
return altera_avalon_jtag_uart_close(&dev->state, fd->fd_flags);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
int
|
79 |
|
|
altera_avalon_jtag_uart_ioctl_fd(alt_fd* fd, int req, void* arg)
|
80 |
|
|
{
|
81 |
|
|
altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev;
|
82 |
|
|
|
83 |
|
|
return altera_avalon_jtag_uart_ioctl(&dev->state, req, arg);
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
#endif /* ALTERA_AVALON_JTAG_UART_SMALL */
|