xref: /qemu/include/hw/isa/superio.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
1 /*
2  * Generic ISA Super I/O
3  *
4  * Copyright (c) 2018 Philippe Mathieu-Daudé
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 #ifndef HW_ISA_SUPERIO_H
11 #define HW_ISA_SUPERIO_H
12 
13 #include "sysemu/sysemu.h"
14 #include "hw/isa/isa.h"
15 #include "qom/object.h"
16 
17 #define TYPE_ISA_SUPERIO "isa-superio"
18 typedef struct ISASuperIOClass ISASuperIOClass;
19 typedef struct ISASuperIODevice ISASuperIODevice;
20 #define ISA_SUPERIO(obj) \
21     OBJECT_CHECK(ISASuperIODevice, (obj), TYPE_ISA_SUPERIO)
22 #define ISA_SUPERIO_GET_CLASS(obj) \
23     OBJECT_GET_CLASS(ISASuperIOClass, (obj), TYPE_ISA_SUPERIO)
24 #define ISA_SUPERIO_CLASS(klass) \
25     OBJECT_CLASS_CHECK(ISASuperIOClass, (klass), TYPE_ISA_SUPERIO)
26 
27 #define SUPERIO_MAX_SERIAL_PORTS 4
28 
29 struct ISASuperIODevice {
30     /*< private >*/
31     ISADevice parent_obj;
32     /*< public >*/
33 
34     ISADevice *parallel[MAX_PARALLEL_PORTS];
35     ISADevice *serial[SUPERIO_MAX_SERIAL_PORTS];
36     ISADevice *floppy;
37     ISADevice *kbc;
38     ISADevice *ide;
39 };
40 
41 typedef struct ISASuperIOFuncs {
42     size_t count;
43     bool (*is_enabled)(ISASuperIODevice *sio, uint8_t index);
44     uint16_t (*get_iobase)(ISASuperIODevice *sio, uint8_t index);
45     unsigned int (*get_irq)(ISASuperIODevice *sio, uint8_t index);
46     unsigned int (*get_dma)(ISASuperIODevice *sio, uint8_t index);
47 } ISASuperIOFuncs;
48 
49 struct ISASuperIOClass {
50     /*< private >*/
51     ISADeviceClass parent_class;
52     /*< public >*/
53     DeviceRealize parent_realize;
54 
55     ISASuperIOFuncs parallel;
56     ISASuperIOFuncs serial;
57     ISASuperIOFuncs floppy;
58     ISASuperIOFuncs ide;
59 };
60 
61 #define TYPE_FDC37M81X_SUPERIO  "fdc37m81x-superio"
62 #define TYPE_SMC37C669_SUPERIO  "smc37c669-superio"
63 
64 #endif /* HW_ISA_SUPERIO_H */
65