1582079c9SBastian Koppelmann /* 2582079c9SBastian Koppelmann * Copyright (c) 2018-2021 Bastian Koppelmann Paderborn University 3582079c9SBastian Koppelmann * 4582079c9SBastian Koppelmann * This library is free software; you can redistribute it and/or 5582079c9SBastian Koppelmann * modify it under the terms of the GNU Lesser General Public 6582079c9SBastian Koppelmann * License as published by the Free Software Foundation; either 7582079c9SBastian Koppelmann * version 2 of the License, or (at your option) any later version. 8582079c9SBastian Koppelmann * 9582079c9SBastian Koppelmann * This library is distributed in the hope that it will be useful, 10582079c9SBastian Koppelmann * but WITHOUT ANY WARRANTY; without even the implied warranty of 11582079c9SBastian Koppelmann * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12582079c9SBastian Koppelmann * Lesser General Public License for more details. 13582079c9SBastian Koppelmann * 14582079c9SBastian Koppelmann * You should have received a copy of the GNU Lesser General Public 15582079c9SBastian Koppelmann * License along with this library; if not, see <http://www.gnu.org/licenses/>. 16582079c9SBastian Koppelmann */ 17582079c9SBastian Koppelmann 18582079c9SBastian Koppelmann #include "qemu/osdep.h" 196d559996SBastian Koppelmann #include "qemu/log.h" 20582079c9SBastian Koppelmann #include "hw/sysbus.h" 21582079c9SBastian Koppelmann #include "hw/qdev-properties.h" 22582079c9SBastian Koppelmann #include "hw/tricore/tricore_testdevice.h" 23582079c9SBastian Koppelmann 24582079c9SBastian Koppelmann static void tricore_testdevice_write(void *opaque, hwaddr offset, 25582079c9SBastian Koppelmann uint64_t value, unsigned size) 26582079c9SBastian Koppelmann { 276d559996SBastian Koppelmann if (value != 0) { 286d559996SBastian Koppelmann qemu_log_mask(LOG_GUEST_ERROR, "Test %" PRIu64 " failed!\n", value); 296d559996SBastian Koppelmann } 30582079c9SBastian Koppelmann exit(value); 31582079c9SBastian Koppelmann } 32582079c9SBastian Koppelmann 33582079c9SBastian Koppelmann static uint64_t tricore_testdevice_read(void *opaque, hwaddr offset, 34582079c9SBastian Koppelmann unsigned size) 35582079c9SBastian Koppelmann { 36582079c9SBastian Koppelmann return 0xdeadbeef; 37582079c9SBastian Koppelmann } 38582079c9SBastian Koppelmann 39582079c9SBastian Koppelmann static void tricore_testdevice_reset(DeviceState *dev) 40582079c9SBastian Koppelmann { 41582079c9SBastian Koppelmann } 42582079c9SBastian Koppelmann 43582079c9SBastian Koppelmann static const MemoryRegionOps tricore_testdevice_ops = { 44582079c9SBastian Koppelmann .read = tricore_testdevice_read, 45582079c9SBastian Koppelmann .write = tricore_testdevice_write, 46582079c9SBastian Koppelmann .valid = { 47582079c9SBastian Koppelmann .min_access_size = 4, 48582079c9SBastian Koppelmann .max_access_size = 4, 49582079c9SBastian Koppelmann }, 50582079c9SBastian Koppelmann .endianness = DEVICE_NATIVE_ENDIAN, 51582079c9SBastian Koppelmann }; 52582079c9SBastian Koppelmann 53582079c9SBastian Koppelmann static void tricore_testdevice_init(Object *obj) 54582079c9SBastian Koppelmann { 55582079c9SBastian Koppelmann TriCoreTestDeviceState *s = TRICORE_TESTDEVICE(obj); 56582079c9SBastian Koppelmann /* map memory */ 57582079c9SBastian Koppelmann memory_region_init_io(&s->iomem, OBJECT(s), &tricore_testdevice_ops, s, 58582079c9SBastian Koppelmann "tricore_testdevice", 0x4); 59582079c9SBastian Koppelmann } 60582079c9SBastian Koppelmann 61582079c9SBastian Koppelmann static Property tricore_testdevice_properties[] = { 62582079c9SBastian Koppelmann DEFINE_PROP_END_OF_LIST() 63582079c9SBastian Koppelmann }; 64582079c9SBastian Koppelmann 65582079c9SBastian Koppelmann static void tricore_testdevice_class_init(ObjectClass *klass, void *data) 66582079c9SBastian Koppelmann { 67582079c9SBastian Koppelmann DeviceClass *dc = DEVICE_CLASS(klass); 68582079c9SBastian Koppelmann 69582079c9SBastian Koppelmann device_class_set_props(dc, tricore_testdevice_properties); 70*e3d08143SPeter Maydell device_class_set_legacy_reset(dc, tricore_testdevice_reset); 71582079c9SBastian Koppelmann } 72582079c9SBastian Koppelmann 73582079c9SBastian Koppelmann static const TypeInfo tricore_testdevice_info = { 74582079c9SBastian Koppelmann .name = TYPE_TRICORE_TESTDEVICE, 75582079c9SBastian Koppelmann .parent = TYPE_SYS_BUS_DEVICE, 76582079c9SBastian Koppelmann .instance_size = sizeof(TriCoreTestDeviceState), 77582079c9SBastian Koppelmann .instance_init = tricore_testdevice_init, 78582079c9SBastian Koppelmann .class_init = tricore_testdevice_class_init, 79582079c9SBastian Koppelmann }; 80582079c9SBastian Koppelmann 81582079c9SBastian Koppelmann static void tricore_testdevice_register_types(void) 82582079c9SBastian Koppelmann { 83582079c9SBastian Koppelmann type_register_static(&tricore_testdevice_info); 84582079c9SBastian Koppelmann } 85582079c9SBastian Koppelmann 86582079c9SBastian Koppelmann type_init(tricore_testdevice_register_types) 87