1 
2 /*! \file iecbus.h
3  *
4  *  \brief IEC bus handling.
5  *
6  *  \author Andreas Boose <viceteam@t-online.de>
7  *
8  *  \page iecbus IEC bus handling
9  *  \htmlinclude iec-bus.txt
10  */
11 
12 /*
13  * This file is part of VICE, the Versatile Commodore Emulator.
14  * See README for copyright notice.
15  *
16  *  This program is free software; you can redistribute it and/or modify
17  *  it under the terms of the GNU General Public License as published by
18  *  the Free Software Foundation; either version 2 of the License, or
19  *  (at your option) any later version.
20  *
21  *  This program is distributed in the hope that it will be useful,
22  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  *  GNU General Public License for more details.
25  *
26  *  You should have received a copy of the GNU General Public License
27  *  along with this program; if not, write to the Free Software
28  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29  *  02111-1307  USA.
30  *
31  */
32 
33 #ifndef VICE_IECBUS_H
34 #define VICE_IECBUS_H
35 
36 #include "types.h"
37 
38 #define IECBUS_NUM 16
39 
40 #define IECBUS_STATUS_TRUEDRIVE      0
41 #define IECBUS_STATUS_DRIVETYPE      1
42 #define IECBUS_STATUS_IECDEVICE      2
43 #define IECBUS_STATUS_VIRTUALDEVICES 3
44 
45 /*!
46  *
47  */
48 enum {
49     IECBUS_DEVICE_READ_DATA  = 0x01,
50     IECBUS_DEVICE_READ_CLK   = 0x04,
51     IECBUS_DEVICE_READ_ATN   = 0x80,
52 
53     IECBUS_DEVICE_ATNA       = 0x10,
54 
55     IECBUS_DEVICE_WRITE_CLK  = 0x40,
56     IECBUS_DEVICE_WRITE_DATA = 0x80
57 };
58 
59 typedef struct iecbus_s {
60     /*!
61      * the drive output ports as described by the
62      * IECBUS_DEVICE_WRITE_... macros
63      */
64     uint8_t drv_bus[IECBUS_NUM];
65 
66     /*! the drive output ports as seen by the drive */
67     uint8_t drv_data[IECBUS_NUM];
68 
69     /*!
70      * the drive input ports, as seen by the drive
71      * and also by the IECBUS_DEVICE_READ_... macros
72      */
73     uint8_t drv_port;
74 
75     /*!
76      * the computer output ports as described by the
77      * IECBUS_DEVICE_WRITE_... macros
78     */
79     uint8_t cpu_bus;
80 
81     /*! the computer output ports as seen by the computer */
82     uint8_t cpu_port;
83 
84     /*! \todo document */
85     uint8_t iec_fast_1541;
86 } iecbus_t;
87 
88 extern iecbus_t iecbus;
89 
90 extern iecbus_t *iecbus_drive_port(void);
91 
92 extern void iecbus_init(void);
93 extern void iecbus_cpu_undump(uint8_t data);
94 extern void iecbus_status_set(unsigned int type, unsigned int unit,
95                               unsigned int enable);
96 
97 extern uint8_t (*iecbus_callback_read)(CLOCK);
98 extern void (*iecbus_callback_write)(uint8_t, CLOCK);
99 
100 extern uint8_t iecbus_device_read(void);
101 extern int  iecbus_device_write(unsigned int unit, uint8_t data);
102 extern void (*iecbus_update_ports)(void);
103 
104 #endif
105