xref: /openbmc/qemu/hw/char/parallel-isa.c (revision 1d1afd9f)
1bb3d5ea8SPhilippe Mathieu-Daudé /*
2bb3d5ea8SPhilippe Mathieu-Daudé  * QEMU Parallel PORT (ISA bus helpers)
3bb3d5ea8SPhilippe Mathieu-Daudé  *
43e3fdad6SThomas Huth  * These functions reside in a separate file since they also might be
53e3fdad6SThomas Huth  * required for linking when compiling QEMU without CONFIG_PARALLEL.
63e3fdad6SThomas Huth  *
7bb3d5ea8SPhilippe Mathieu-Daudé  * Copyright (c) 2003 Fabrice Bellard
8bb3d5ea8SPhilippe Mathieu-Daudé  *
9bb3d5ea8SPhilippe Mathieu-Daudé  * SPDX-License-Identifier: MIT
10bb3d5ea8SPhilippe Mathieu-Daudé  */
11a27bd6c7SMarkus Armbruster 
12bb3d5ea8SPhilippe Mathieu-Daudé #include "qemu/osdep.h"
13bb3d5ea8SPhilippe Mathieu-Daudé #include "sysemu/sysemu.h"
14bb3d5ea8SPhilippe Mathieu-Daudé #include "hw/isa/isa.h"
15a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
169cc44d9bSBernhard Beschow #include "hw/char/parallel-isa.h"
17bb3d5ea8SPhilippe Mathieu-Daudé #include "hw/char/parallel.h"
1896927c74SMarkus Armbruster #include "qapi/error.h"
19bb3d5ea8SPhilippe Mathieu-Daudé 
parallel_init(ISABus * bus,int index,Chardev * chr)20bb3d5ea8SPhilippe Mathieu-Daudé static void parallel_init(ISABus *bus, int index, Chardev *chr)
21bb3d5ea8SPhilippe Mathieu-Daudé {
22bb3d5ea8SPhilippe Mathieu-Daudé     DeviceState *dev;
23bb3d5ea8SPhilippe Mathieu-Daudé     ISADevice *isadev;
24bb3d5ea8SPhilippe Mathieu-Daudé 
25963e94a9SThomas Huth     isadev = isa_new(TYPE_ISA_PARALLEL);
26bb3d5ea8SPhilippe Mathieu-Daudé     dev = DEVICE(isadev);
27bb3d5ea8SPhilippe Mathieu-Daudé     qdev_prop_set_uint32(dev, "index", index);
28bb3d5ea8SPhilippe Mathieu-Daudé     qdev_prop_set_chr(dev, "chardev", chr);
2996927c74SMarkus Armbruster     isa_realize_and_unref(isadev, bus, &error_fatal);
30bb3d5ea8SPhilippe Mathieu-Daudé }
31bb3d5ea8SPhilippe Mathieu-Daudé 
parallel_hds_isa_init(ISABus * bus,int n)32bb3d5ea8SPhilippe Mathieu-Daudé void parallel_hds_isa_init(ISABus *bus, int n)
33bb3d5ea8SPhilippe Mathieu-Daudé {
34bb3d5ea8SPhilippe Mathieu-Daudé     int i;
35bb3d5ea8SPhilippe Mathieu-Daudé 
36bb3d5ea8SPhilippe Mathieu-Daudé     assert(n <= MAX_PARALLEL_PORTS);
37bb3d5ea8SPhilippe Mathieu-Daudé 
38bb3d5ea8SPhilippe Mathieu-Daudé     for (i = 0; i < n; i++) {
39bb3d5ea8SPhilippe Mathieu-Daudé         if (parallel_hds[i]) {
40bb3d5ea8SPhilippe Mathieu-Daudé             parallel_init(bus, i, parallel_hds[i]);
41bb3d5ea8SPhilippe Mathieu-Daudé         }
42bb3d5ea8SPhilippe Mathieu-Daudé     }
43bb3d5ea8SPhilippe Mathieu-Daudé }
44*1d1afd9fSBernhard Beschow 
isa_parallel_set_iobase(ISADevice * parallel,hwaddr iobase)45*1d1afd9fSBernhard Beschow void isa_parallel_set_iobase(ISADevice *parallel, hwaddr iobase)
46*1d1afd9fSBernhard Beschow {
47*1d1afd9fSBernhard Beschow     ISAParallelState *s = ISA_PARALLEL(parallel);
48*1d1afd9fSBernhard Beschow 
49*1d1afd9fSBernhard Beschow     parallel->ioport_id = iobase;
50*1d1afd9fSBernhard Beschow     s->iobase = iobase;
51*1d1afd9fSBernhard Beschow     portio_list_set_address(&s->portio_list, s->iobase);
52*1d1afd9fSBernhard Beschow }
53*1d1afd9fSBernhard Beschow 
isa_parallel_set_enabled(ISADevice * parallel,bool enabled)54*1d1afd9fSBernhard Beschow void isa_parallel_set_enabled(ISADevice *parallel, bool enabled)
55*1d1afd9fSBernhard Beschow {
56*1d1afd9fSBernhard Beschow     portio_list_set_enabled(&ISA_PARALLEL(parallel)->portio_list, enabled);
57*1d1afd9fSBernhard Beschow }
58