fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/drivers/char/char.h *
7 * Created: 2009-03-06 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2009-2020 Hampa Hug <hampa@hampa.ch> *
9 *****************************************************************************/
10
11/*****************************************************************************
12 * This program is free software. You can redistribute it and / or modify it *
13 * under the terms of the GNU General Public License version 2 as published *
14 * by the Free Software Foundation. *
15 * *
16 * This program is distributed in the hope that it will be useful, but *
17 * WITHOUT ANY WARRANTY, without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
19 * Public License for more details. *
20 *****************************************************************************/
21
22
23#ifndef PCE_DRIVERS_CHAR_CHAR_H
24#define PCE_DRIVERS_CHAR_CHAR_H 1
25
26
27#include <stdio.h>
28
29
30#define PCE_CHAR_DTR 0x0001
31#define PCE_CHAR_RTS 0x0002
32
33#define PCE_CHAR_DSR 0x0100
34#define PCE_CHAR_CTS 0x0200
35#define PCE_CHAR_CD 0x0400
36#define PCE_CHAR_RI 0x0800
37
38
39/*!***************************************************************************
40 * @short The character driver context
41 *****************************************************************************/
42typedef struct char_drv_t {
43 void *ext;
44
45 unsigned long bps;
46 unsigned bpc;
47 unsigned parity;
48 unsigned stop;
49
50 unsigned ctl_inp;
51 unsigned ctl_out;
52
53 unsigned log_cnt;
54 unsigned char log_buf[16];
55 int log_out;
56 FILE *log_fp;
57
58 FILE *cap_fp;
59
60 void (*close) (struct char_drv_t *cdrv);
61
62 unsigned (*read) (struct char_drv_t *cdrv, void *buf, unsigned cnt);
63 unsigned (*write) (struct char_drv_t *cdrv, const void *buf, unsigned cnt);
64
65 int (*get_ctl) (struct char_drv_t *cdrv, unsigned *ctl);
66 int (*set_ctl) (struct char_drv_t *cdrv, unsigned ctl);
67
68 int (*set_params) (struct char_drv_t *cdrv,
69 unsigned long bps, unsigned bpc, unsigned parity, unsigned stop
70 );
71} char_drv_t;
72
73
74typedef char_drv_t *(*chr_open_f) (const char *name);
75
76
77void chr_init (char_drv_t *cdrv, void *ext);
78char_drv_t *chr_open (const char *name);
79void chr_close (char_drv_t *cdrv);
80
81int chr_register (const char *name, chr_open_f open);
82int chr_unregister (const char *name);
83int chr_register_default (void);
84
85unsigned chr_read (char_drv_t *cdrv, void *buf, unsigned cnt);
86unsigned chr_write (char_drv_t *cdrv, const void *buf, unsigned cnt);
87
88int chr_get_ctl (char_drv_t *cdrv, unsigned *ctl);
89int chr_set_ctl (char_drv_t *cdrv, unsigned ctl);
90
91int chr_set_params (char_drv_t *cdrv, unsigned long bps, unsigned bpc, unsigned parity, unsigned stop);
92
93FILE *chr_open_file (const char *name, const char *mode, const char *modeapp);
94
95int chr_set_log (char_drv_t *cdrv, const char *fname);
96int chr_set_cap (char_drv_t *cdrv, const char *fname);
97
98void chr_mouse_set (int dx, int dy, unsigned button);
99
100
101#endif