~ubuntu-branches/ubuntu/quantal/vice/quantal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * parallel.h
 *
 * Written by
 *  André Fachat <a.fachat@physik.tu-chemnitz.de>
 *
 * This file is part of VICE, the Versatile Commodore Emulator.
 * See README for copyright notice.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307  USA.
 *
 */

/* This file contains the exported interface to the iec488 emulator.
 * The iec488 emulator then calls (modifed) routines from serial.c
 * to use the standard floppy interface.
 * The current state of the bus and methods to set output lines
 * are exported.
 * This hardware emulation is necessary, as different PET kernels would
 * need different traps. But it's also much faster than the (hardware
 * simulated) serial bus, as it's parallel. So we need no traps.
 */

#ifndef _PARALLEL_H
#define _PARALLEL_H

#include "types.h"

/* debug variable - set to 1 to generate output */
extern int parallel_debug;

/* to switch on/off IEEE488 filesystem engine */
extern void parallel_bus_enable(int enable);

extern void parallel_trap_eof_callback_set(void (*func)(void));
extern void parallel_trap_attention_callback_set(void (*func)(void));

/* state of the bus lines -> "if(parallel_eoi) { eoi is active }" */
extern BYTE parallel_eoi;
extern BYTE parallel_ndac;
extern BYTE parallel_nrfd;
extern BYTE parallel_dav;
extern BYTE parallel_atn;

extern BYTE parallel_bus;       /* data lines */

/* Each device has a mask bit in the parallel_* handshake lines */
#define PARALLEL_EMU    0x01
#define PARALLEL_CPU    0x02
#define PARALLEL_DRV0   0x04
#define PARALLEL_DRV1   0x08

/* methods to set handshake lines active for the devices */
extern void parallel_set_eoi(BYTE mask);
extern void parallel_set_ndac(BYTE mask);
extern void parallel_set_nrfd(BYTE mask);
extern void parallel_set_dav(BYTE mask);
extern void parallel_set_atn(BYTE mask);
extern void parallel_restore_set_atn(BYTE mask);

/* methods to set handshake lines inactive for the devices */
extern void parallel_clr_eoi(BYTE mask);
extern void parallel_clr_ndac(BYTE mask);
extern void parallel_clr_nrfd(BYTE mask);
extern void parallel_clr_dav(BYTE mask);
extern void parallel_clr_atn(BYTE mask);
extern void parallel_restore_clr_atn(BYTE mask);


/* methods to set output lines for the computer */
#define PARALLEL_SET_LINE(line,dev,mask)                      \
    static inline void parallel_##dev##_set_##line(BYTE val)  \
    {                                                         \
        if (val) {                                            \
            parallel_set_##line(PARALLEL_##mask);             \
        } else {                                              \
            parallel_clr_##line(~PARALLEL_##mask);            \
        }                                                     \
    }

#define PARALLEL_RESTORE_LINE(line,dev,mask)                      \
    static inline void parallel_##dev##_restore_##line(BYTE val)  \
    {                                                             \
        if (val) {                                                \
            parallel_restore_set_##line(PARALLEL_##mask);         \
        } else {                                                  \
            parallel_restore_clr_##line(~PARALLEL_##mask);        \
        }                                                         \
    }

/* Emulator functions */
PARALLEL_SET_LINE(eoi, emu, EMU)
PARALLEL_SET_LINE(dav, emu, EMU)
PARALLEL_SET_LINE(nrfd, emu, EMU)
PARALLEL_SET_LINE(ndac, emu, EMU)

extern void parallel_emu_set_bus(BYTE b);

/* CPU functions */
/* The *CPU* macros advance the drive CPU to the current clock. This
   is currently esp. for the VIC20 VIC1112 IEEE488 module. This seems
   to be necessary for ATN only. Too many of them make IEEE488
   slower... (AF, 01AUG1999) */
PARALLEL_SET_LINE(eoi, cpu, CPU)
PARALLEL_SET_LINE(dav, cpu, CPU)
PARALLEL_SET_LINE(nrfd, cpu, CPU)
PARALLEL_SET_LINE(ndac, cpu, CPU)

extern void parallel_cpu_set_atn(char val);

PARALLEL_RESTORE_LINE(atn, cpu, CPU)

extern void parallel_cpu_set_bus(BYTE b);

/* Drive 0 functions */
PARALLEL_SET_LINE(eoi, drv0, DRV0)
PARALLEL_SET_LINE(dav, drv0, DRV0)
PARALLEL_SET_LINE(nrfd, drv0, DRV0)
PARALLEL_SET_LINE(ndac, drv0, DRV0)

extern void parallel_drv0_set_bus(BYTE b);

/* Drive 1 functions */
PARALLEL_SET_LINE(eoi, drv1, DRV1)
PARALLEL_SET_LINE(dav, drv1, DRV1)
PARALLEL_SET_LINE(nrfd, drv1, DRV1)
PARALLEL_SET_LINE(ndac, drv1, DRV1)

extern void parallel_drv1_set_bus(BYTE b);

#endif