Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* fr30 device support |
2 | Copyright (C) 1998, 1999 Free Software Foundation, Inc. | |
3 | Contributed by Cygnus Solutions. | |
4 | ||
5 | This file is part of the GNU simulators. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License along | |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
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 fr30_devices; | |
30 | ||
31 | int | |
32 | device_io_read_buffer (device *me, void *source, int space, | |
33 | address_word addr, unsigned nr_bytes, | |
34 | SIM_CPU *cpu, sim_cia cia) | |
35 | { | |
36 | SIM_DESC sd = CPU_STATE (cpu); | |
37 | ||
38 | if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT) | |
39 | return nr_bytes; | |
40 | ||
41 | #ifdef HAVE_DV_SOCKSER | |
42 | if (addr == UART_INCHAR_ADDR) | |
43 | { | |
44 | int c = dv_sockser_read (sd); | |
45 | if (c == -1) | |
46 | return 0; | |
47 | *(char *) source = c; | |
48 | return 1; | |
49 | } | |
50 | if (addr == UART_STATUS_ADDR) | |
51 | { | |
52 | int status = dv_sockser_status (sd); | |
53 | unsigned char *p = source; | |
54 | p[0] = 0; | |
55 | p[1] = (((status & DV_SOCKSER_INPUT_EMPTY) | |
56 | #ifdef UART_INPUT_READY0 | |
57 | ? UART_INPUT_READY : 0) | |
58 | #else | |
59 | ? 0 : UART_INPUT_READY) | |
60 | #endif | |
61 | + ((status & DV_SOCKSER_OUTPUT_EMPTY) ? UART_OUTPUT_READY : 0)); | |
62 | return 2; | |
63 | } | |
64 | #endif | |
65 | ||
66 | return nr_bytes; | |
67 | } | |
68 | ||
69 | int | |
70 | device_io_write_buffer (device *me, const void *source, int space, | |
71 | address_word addr, unsigned nr_bytes, | |
72 | SIM_CPU *cpu, sim_cia cia) | |
73 | { | |
74 | SIM_DESC sd = CPU_STATE (cpu); | |
75 | ||
76 | #if WITH_SCACHE | |
77 | if (addr == MCCR_ADDR) | |
78 | { | |
79 | if ((*(const char *) source & MCCR_CP) != 0) | |
80 | scache_flush (sd); | |
81 | return nr_bytes; | |
82 | } | |
83 | #endif | |
84 | ||
85 | if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT) | |
86 | return nr_bytes; | |
87 | ||
88 | #if HAVE_DV_SOCKSER | |
89 | if (addr == UART_OUTCHAR_ADDR) | |
90 | { | |
91 | int rc = dv_sockser_write (sd, *(char *) source); | |
92 | return rc == 1; | |
93 | } | |
94 | #endif | |
95 | ||
96 | return nr_bytes; | |
97 | } | |
98 | ||
99 | void device_error () {} |