hw/misc: implement ESP32-C3 USB Serial JTAG as a stub

The module doesn't do much at the moment, it is used as a stub
This commit is contained in:
Omar Chebib
2023-05-12 10:48:59 +08:00
committed by Ivan Grokhotkov
parent 6569a0882a
commit e9cb83a49f
3 changed files with 107 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
/*
* ESP32-C3 USB Serial JTAG emulation
*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co. Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 or
* (at your option) any later version.
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "hw/hw.h"
#include "hw/sysbus.h"
#include "hw/misc/esp32c3_jtag.h"
static uint64_t esp32c3_jtag_read(void *opaque, hwaddr addr, unsigned int size)
{
ESP32C3UsbJtagState *s = ESP32C3_JTAG(opaque);
(void) s;
return 0;
}
static void esp32c3_jtag_write(void *opaque, hwaddr addr, uint64_t value, unsigned int size)
{
ESP32C3UsbJtagState *s = ESP32C3_JTAG(opaque);
(void) s;
}
static const MemoryRegionOps esp32c3_jtag_ops = {
.read = esp32c3_jtag_read,
.write = esp32c3_jtag_write,
.endianness = DEVICE_LITTLE_ENDIAN,
};
static void esp32c3_jtag_reset(DeviceState *dev)
{
(void) dev;
}
static void esp32c3_jtag_realize(DeviceState *dev, Error **errp)
{
(void) dev;
(void) errp;
}
static void esp32c3_jtag_init(Object *obj)
{
ESP32C3UsbJtagState *s = ESP32C3_JTAG(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
memory_region_init_io(&s->iomem, obj, &esp32c3_jtag_ops, s,
TYPE_ESP32C3_JTAG, ESP32C3_JTAG_REGS_SIZE);
sysbus_init_mmio(sbd, &s->iomem);
}
static void esp32c3_jtag_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->legacy_reset = esp32c3_jtag_reset;
dc->realize = esp32c3_jtag_realize;
}
static const TypeInfo esp32c3_jtag_info = {
.name = TYPE_ESP32C3_JTAG,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(ESP32C3UsbJtagState),
.instance_init = esp32c3_jtag_init,
.class_init = esp32c3_jtag_class_init
};
static void esp32c3_jtag_types(void)
{
type_register_static(&esp32c3_jtag_info);
}
type_init(esp32c3_jtag_types)
+1
View File
@@ -152,6 +152,7 @@ system_ss.add(when: 'CONFIG_RISCV_ESP32C3', if_true: files(
'esp32c3_cache.c',
'esp_sha.c',
'esp32c3_sha.c',
'esp32c3_jtag.c',
))
if gcrypt.found()
system_ss.add(when: [gcrypt, 'CONFIG_XTENSA_ESP32'], if_true: files(
+26
View File
@@ -0,0 +1,26 @@
/*
* ESP32-C3 USB Serial JTAG emulation
*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co. Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 or
* (at your option) any later version.
*/
#pragma once
#include "hw/hw.h"
#include "hw/sysbus.h"
#include "hw/registerfields.h"
#define TYPE_ESP32C3_JTAG "misc.esp32c3.usb_serial_jtag"
#define ESP32C3_JTAG(obj) OBJECT_CHECK(ESP32C3UsbJtagState, (obj), TYPE_ESP32C3_JTAG)
#define ESP32C3_JTAG_REGS_SIZE (0x84)
typedef struct ESP32C3UsbJtagState {
SysBusDevice parent_object;
MemoryRegion iomem;
} ESP32C3UsbJtagState;