> > -static Aml *build_com_device_aml(uint8_t uid) > > +static void build_com_device_aml(Aml *scope, uint8_t uid) > > { > > Aml *dev; > > Aml *crs; > > - Aml *method; > > - Aml *if_ctx; > > - Aml *else_ctx; > > - Aml *zero = aml_int(0); > > - Aml *is_present = aml_local(0); > > - const char *enabled_field = "CAEN"; > > uint8_t irq = 4; > > uint16_t io_port = 0x03F8; > > > > assert(uid == 1 || uid == 2); > > if (uid == 2) { > > - enabled_field = "CBEN"; > > irq = 3; > > io_port = 0x02F8; > > } > > + if (!memory_region_present(get_system_io(), io_port)) { > ^^^^^^ > even though acpi_setup() is a part of board code, usually it's not > recommended to > use get_system_foo() outside of machine_init() > > how about fishing out present serial ports from isa device in a helper > like acpi_get_misc_info(), and then generalize AML like > build_com_device_aml(Aml *scope, uint8_t uid, io_port, irq)
Hmm, I'm wondering whenever it would be useful to have ... ISADeviceClass->build_aml(Aml *scope, ISADevice *dev); ... then just walk all isa devices and call the handler (if present). Maybe the same for sysbus. cheers, Gerd