pcspk.c (36cd6f6f20724d49aac1910e310f81a43e0cb657) pcspk.c (db895a1e6a97e919f9b86d60c969377357b05066)
1/*
2 * QEMU PC speaker emulation
3 *
4 * Copyright (c) 2006 Joachim Henke
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 149 unchanged lines hidden (view full) ---

158 .read = pcspk_io_read,
159 .write = pcspk_io_write,
160 .impl = {
161 .min_access_size = 1,
162 .max_access_size = 1,
163 },
164};
165
1/*
2 * QEMU PC speaker emulation
3 *
4 * Copyright (c) 2006 Joachim Henke
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 149 unchanged lines hidden (view full) ---

158 .read = pcspk_io_read,
159 .write = pcspk_io_write,
160 .impl = {
161 .min_access_size = 1,
162 .max_access_size = 1,
163 },
164};
165
166static int pcspk_initfn(ISADevice *dev)
166static void pcspk_initfn(Object *obj)
167{
167{
168 PCSpkState *s = PC_SPEAKER(dev);
168 PCSpkState *s = PC_SPEAKER(obj);
169
170 memory_region_init_io(&s->ioport, &pcspk_io_ops, s, "elcr", 1);
169
170 memory_region_init_io(&s->ioport, &pcspk_io_ops, s, "elcr", 1);
171 isa_register_ioport(dev, &s->ioport, s->iobase);
171}
172
172
173 pcspk_state = s;
173static void pcspk_realizefn(DeviceState *dev, Error **errp)
174{
175 ISADevice *isadev = ISA_DEVICE(dev);
176 PCSpkState *s = PC_SPEAKER(dev);
174
177
175 return 0;
178 isa_register_ioport(isadev, &s->ioport, s->iobase);
179
180 pcspk_state = s;
176}
177
178static Property pcspk_properties[] = {
179 DEFINE_PROP_HEX32("iobase", PCSpkState, iobase, -1),
180 DEFINE_PROP_PTR("pit", PCSpkState, pit),
181 DEFINE_PROP_END_OF_LIST(),
182};
183
184static void pcspk_class_initfn(ObjectClass *klass, void *data)
185{
186 DeviceClass *dc = DEVICE_CLASS(klass);
181}
182
183static Property pcspk_properties[] = {
184 DEFINE_PROP_HEX32("iobase", PCSpkState, iobase, -1),
185 DEFINE_PROP_PTR("pit", PCSpkState, pit),
186 DEFINE_PROP_END_OF_LIST(),
187};
188
189static void pcspk_class_initfn(ObjectClass *klass, void *data)
190{
191 DeviceClass *dc = DEVICE_CLASS(klass);
187 ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
188
192
189 ic->init = pcspk_initfn;
193 dc->realize = pcspk_realizefn;
190 dc->no_user = 1;
191 dc->props = pcspk_properties;
192}
193
194static const TypeInfo pcspk_info = {
195 .name = TYPE_PC_SPEAKER,
196 .parent = TYPE_ISA_DEVICE,
197 .instance_size = sizeof(PCSpkState),
194 dc->no_user = 1;
195 dc->props = pcspk_properties;
196}
197
198static const TypeInfo pcspk_info = {
199 .name = TYPE_PC_SPEAKER,
200 .parent = TYPE_ISA_DEVICE,
201 .instance_size = sizeof(PCSpkState),
202 .instance_init = pcspk_initfn,
198 .class_init = pcspk_class_initfn,
199};
200
201static void pcspk_register(void)
202{
203 type_register_static(&pcspk_info);
204 isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
205}
206type_init(pcspk_register)
203 .class_init = pcspk_class_initfn,
204};
205
206static void pcspk_register(void)
207{
208 type_register_static(&pcspk_info);
209 isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
210}
211type_init(pcspk_register)