2 * Copyright (c) 2018-2021 Bastian Koppelmann Paderborn University
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 #include "qemu/osdep.h"
19 #include "hw/sysbus.h"
20 #include "hw/qdev-properties.h"
21 #include "hw/tricore/tricore_testdevice.h"
23 static void tricore_testdevice_write(void *opaque
, hwaddr offset
,
24 uint64_t value
, unsigned size
)
29 static uint64_t tricore_testdevice_read(void *opaque
, hwaddr offset
,
35 static void tricore_testdevice_reset(DeviceState
*dev
)
39 static const MemoryRegionOps tricore_testdevice_ops
= {
40 .read
= tricore_testdevice_read
,
41 .write
= tricore_testdevice_write
,
46 .endianness
= DEVICE_NATIVE_ENDIAN
,
49 static void tricore_testdevice_init(Object
*obj
)
51 TriCoreTestDeviceState
*s
= TRICORE_TESTDEVICE(obj
);
53 memory_region_init_io(&s
->iomem
, OBJECT(s
), &tricore_testdevice_ops
, s
,
54 "tricore_testdevice", 0x4);
57 static Property tricore_testdevice_properties
[] = {
58 DEFINE_PROP_END_OF_LIST()
61 static void tricore_testdevice_class_init(ObjectClass
*klass
, void *data
)
63 DeviceClass
*dc
= DEVICE_CLASS(klass
);
65 device_class_set_props(dc
, tricore_testdevice_properties
);
66 dc
->reset
= tricore_testdevice_reset
;
69 static const TypeInfo tricore_testdevice_info
= {
70 .name
= TYPE_TRICORE_TESTDEVICE
,
71 .parent
= TYPE_SYS_BUS_DEVICE
,
72 .instance_size
= sizeof(TriCoreTestDeviceState
),
73 .instance_init
= tricore_testdevice_init
,
74 .class_init
= tricore_testdevice_class_init
,
77 static void tricore_testdevice_register_types(void)
79 type_register_static(&tricore_testdevice_info
);
82 type_init(tricore_testdevice_register_types
)