diff --git a/hw/misc/esp32c3_aes.c b/hw/misc/esp32c3_aes.c new file mode 100644 index 0000000000..74fb1d36c1 --- /dev/null +++ b/hw/misc/esp32c3_aes.c @@ -0,0 +1,25 @@ +/* + * ESP32C3 AES 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 "hw/misc/esp32c3_aes.h" + +static const TypeInfo esp32c3_aes_info = { + .name = TYPE_ESP32C3_AES, + .parent = TYPE_ESP_AES, + .instance_size = sizeof(ESP32C3AesState), + .class_size = sizeof(ESP32C3AesClass) +}; + +static void esp32c3_aes_register_types(void) +{ + type_register_static(&esp32c3_aes_info); +} + +type_init(esp32c3_aes_register_types) diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 522639a50a..431628bf6e 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -161,6 +161,10 @@ if gcrypt.found() system_ss.add(when: [gcrypt, 'CONFIG_XTENSA_ESP32'], if_true: files( 'esp32_rsa.c', )) + system_ss.add(when: [gcrypt, 'CONFIG_RISCV_ESP32C3'], if_true: files( + 'esp_aes.c', + 'esp32c3_aes.c', + )) endif system_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_ahb_apb_pnp.c')) diff --git a/include/hw/misc/esp32c3_aes.h b/include/hw/misc/esp32c3_aes.h new file mode 100644 index 0000000000..715adccbed --- /dev/null +++ b/include/hw/misc/esp32c3_aes.h @@ -0,0 +1,27 @@ +/* + * ESP32-C3 AES 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/misc/esp_aes.h" + +#define TYPE_ESP32C3_AES "misc.esp32c3.aes" +#define ESP32C3_AES(obj) OBJECT_CHECK(ESP32C3AesState, (obj), TYPE_ESP32C3_AES) + +#define ESP32C3_AES_GET_CLASS(obj) OBJECT_GET_CLASS(ESP32C3AesClass, obj, TYPE_ESP32C3_AES) +#define ESP32C3_AES_CLASS(klass) OBJECT_CLASS_CHECK(ESP32C3AesClass, klass, TYPE_ESP32C3_AES) + +typedef struct ESP32C3AesState { + ESPAesState parent; +} ESP32C3AesState; + + +typedef struct ESP32C3AesClass { + ESPAesClass parent_class; +} ESP32C3AesClass;