Commit | Line | Data |
---|---|---|
b34f6357 | 1 | /* frv device support |
dc3cf14f JB |
2 | Copyright (C) 1998, 1999, 2007, 2008, 2009, 2010 |
3 | Free Software Foundation, Inc. | |
b34f6357 DB |
4 | Contributed by Red Hat. |
5 | ||
6 | This file is part of the GNU simulators. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
4744ac1b JB |
10 | the Free Software Foundation; either version 3 of the License, or |
11 | (at your option) any later version. | |
b34f6357 DB |
12 | |
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
4744ac1b JB |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
b34f6357 DB |
20 | |
21 | /* ??? All of this is just to get something going. wip! */ | |
22 | ||
23 | #include "sim-main.h" | |
24 | ||
25 | #ifdef HAVE_DV_SOCKSER | |
26 | #include "dv-sockser.h" | |
27 | #endif | |
28 | ||
29 | device frv_devices; | |
30 | ||
31 | int | |
32 | device_io_read_buffer (device *me, void *source, int space, | |
33 | address_word addr, unsigned nr_bytes, | |
34 | SIM_DESC sd, SIM_CPU *cpu, sim_cia cia) | |
35 | { | |
36 | if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT) | |
37 | return nr_bytes; | |
38 | ||
39 | #ifdef HAVE_DV_SOCKSER | |
40 | if (addr == UART_INCHAR_ADDR) | |
41 | { | |
42 | int c = dv_sockser_read (sd); | |
43 | if (c == -1) | |
44 | return 0; | |
45 | *(char *) source = c; | |
46 | return 1; | |
47 | } | |
48 | if (addr == UART_STATUS_ADDR) | |
49 | { | |
50 | int status = dv_sockser_status (sd); | |
51 | unsigned char *p = source; | |
52 | p[0] = 0; | |
53 | p[1] = (((status & DV_SOCKSER_INPUT_EMPTY) | |
54 | #ifdef UART_INPUT_READY0 | |
55 | ? UART_INPUT_READY : 0) | |
56 | #else | |
57 | ? 0 : UART_INPUT_READY) | |
58 | #endif | |
59 | + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0)); | |
60 | return 2; | |
61 | } | |
62 | #endif | |
63 | ||
64 | return nr_bytes; | |
65 | } | |
66 | ||
67 | int | |
68 | device_io_write_buffer (device *me, const void *source, int space, | |
69 | address_word addr, unsigned nr_bytes, | |
70 | SIM_DESC sd, SIM_CPU *cpu, sim_cia cia) | |
71 | { | |
72 | ||
73 | #if WITH_SCACHE | |
74 | if (addr == MCCR_ADDR) | |
75 | { | |
76 | if ((*(const char *) source & MCCR_CP) != 0) | |
77 | scache_flush (sd); | |
78 | return nr_bytes; | |
79 | } | |
80 | #endif | |
81 | ||
82 | if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT) | |
83 | return nr_bytes; | |
84 | ||
85 | #if HAVE_DV_SOCKSER | |
86 | if (addr == UART_OUTCHAR_ADDR) | |
87 | { | |
88 | int rc = dv_sockser_write (sd, *(char *) source); | |
89 | return rc == 1; | |
90 | } | |
91 | #endif | |
92 | ||
93 | return nr_bytes; | |
94 | } | |
95 | ||
96 | void device_error (device *me, char* message, ...) {} |