QEMU AVR 8 bit cores
Re: [PATCH v35 10/13] target/avr: Add limited support for USART and 16 bit timer peripherals
In reply to Aleksandar MarkovicOk, understood.
Quoted 902 lines · Aleksandar Markovic
Quoted 10 lines · Michael Rolnik
From: Sarah Harris <[email protected]>
These were designed to facilitate testing but should provide enough function to be useful in other contexts.
Only a subset of the functions of each peripheral is implemented, mainly due to the lack of a standard way to handle electrical connections (like GPIO pins).Signed-off-by Sarah Harris <[email protected]>---
Apart from splitting this patch into three, Michael, please move "build" patch before this patch (of course, a little modified, without bits and pieces for USART and other devices, and then gradually update all Makefiles etc., within each patch that follows, until the end of the series.
This is important in case of board/soc/device reworking, which is likely.
Thanks,
AleksandarQuoted 873 lines
hw/char/Kconfig | 3 + hw/char/Makefile.objs | 1 + hw/char/avr_usart.c | 324 ++++++++++++++++++ hw/misc/Kconfig | 3 + hw/misc/Makefile.objs | 2 + hw/misc/avr_mask.c | 112 ++++++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 2 + hw/timer/avr_timer16.c | 605 +++++++++++++++++++++++++++++++++ include/hw/char/avr_usart.h | 97 ++++++ include/hw/misc/avr_mask.h | 47 +++ include/hw/timer/avr_timer16.h | 97 ++++++ 12 files changed, 1296 insertions(+) create mode 100644 hw/char/avr_usart.c create mode 100644 hw/misc/avr_mask.c create mode 100644 hw/timer/avr_timer16.c create mode 100644 include/hw/char/avr_usart.h create mode 100644 include/hw/misc/avr_mask.h create mode 100644 include/hw/timer/avr_timer16.hhw/char/Kconfig +3
-0@@ -46,3 +46,6 @@ config SCLPCONSOLE config TERMINAL3270 bool + +config AVR_USART + boolhw/char/Makefile.objs +1
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_PSERIES) += spapr_vty.o obj-$(CONFIG_DIGIC) += digic-uart.o obj-$(CONFIG_STM32F2XX_USART) += stm32f2xx_usart.o obj-$(CONFIG_RASPI) += bcm2835_aux.o +common-obj-$(CONFIG_AVR_USART) += avr_usart.o common-obj-$(CONFIG_CMSDK_APB_UART) += cmsdk-apb-uart.o common-obj-$(CONFIG_ETRAXFS) += etraxfs_ser.ohw/char/avr_usart.c new file +7
-0@@ -0,0 +1,324 @@ +/* +* AVR USART +* +* Copyright (c) 2018 University of Kent +* Author: Sarah Harris +* +* Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */hw/char/avr_usart.c new file +18
-0+ +#include "qemu/osdep.h" +#include "hw/char/avr_usart.h" +#include "qemu/log.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" + +static int avr_usart_can_receive (void *opaque) +{ +AVRUsartState *usart = opaque; + +if (usart->data_valid || !(usart->csrb &USART_CSRB_RXEN )) { +return 0 ; + } +return 1 ; +} + +static void avr_usart_receive(void *opaque, const uint8_t *buffer, intsize)
hw/char/avr_usart.c new file +45
-0+{ +AVRUsartState *usart = opaque; +assert (size ==1 ); +assert (!usart->data_valid); + usart->data = buffer[0 ]; + usart->data_valid = true; + usart->csra |=USART_CSRA_RXC ; +if (usart->csrb &USART_CSRB_RXCIE ) { +qemu_set_irq (usart->rxc_irq,1 ); + } +} + +static void update_char_mask (AVRUsartState *usart) +{ +uint8_t mode = ((usart->csrc &USART_CSRC_CSZ0 ) ?1 :0 ) | + ((usart->csrc &USART_CSRC_CSZ1 ) ?2 :0 ) | + ((usart->csrb &USART_CSRB_CSZ2 ) ?4 :0 ); +switch (mode) { +case 0 : + usart->char_mask =0b11111 ; +break ; +case 1 : + usart->char_mask =0b111111 ; +break ; +case 2 : + usart->char_mask =0b1111111 ; +break ; +case 3 : + usart->char_mask =0b11111111 ; +break ; +case 4 : +/* Fallthrough. */ +case 5 : +/* Fallthrough. */ +case 6 : +qemu_log_mask ( +LOG_GUEST_ERROR , +"%s: Reserved character size 0x%x\n" , + __func__, + mode); +break ; +case 7 : + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: Nine bit character size not supported (forcingeight)\n",
hw/char/avr_usart.c new file +24
-0+ __func__); + usart->char_mask =0b11111111 ; +break ; +default : +assert (0 ); + } +} + +static void avr_usart_reset (DeviceState *dev) +{ +AVRUsartState *usart =AVR_USART (dev); + usart->data_valid = false; + usart->csra =0b00100000 ; + usart->csrb =0b00000000 ; + usart->csrc =0b00000110 ; + usart->brrl =0 ; + usart->brrh =0 ; +update_char_mask (usart); +qemu_set_irq (usart->rxc_irq,0 ); +qemu_set_irq (usart->txc_irq,0 ); +qemu_set_irq (usart->dre_irq,0 ); +} + +static uint64_t avr_usart_read(void *opaque, hwaddr addr, unsigned intsize)
hw/char/avr_usart.c new file +122
-0+{ +AVRUsartState *usart = opaque; +uint8_t data; +assert (size ==1 ); + +if (!usart->enabled) { +return 0 ; + } + +switch (addr) { +case USART_DR : +if (!(usart->csrb &USART_CSRB_RXEN )) { +/* Receiver disabled, ignore. */ +return 0 ; + } +if (usart->data_valid) { + data = usart->data & usart->char_mask; + usart->data_valid = false; + }else { + data =0 ; + } + usart->csra &=0xff ^USART_CSRA_RXC ; +qemu_set_irq (usart->rxc_irq,0 ); +qemu_chr_fe_accept_input (&usart->chr); +return data; +case USART_CSRA : +return usart->csra; +case USART_CSRB : +return usart->csrb; +case USART_CSRC : +return usart->csrc; +case USART_BRRL : +return usart->brrl; +case USART_BRRH : +return usart->brrh; +default : +qemu_log_mask ( +LOG_GUEST_ERROR , +"%s: Bad offset 0x%" HWADDR_PRIx"\n" , + __func__, + addr); + } +return 0 ; +} + +static void avr_usart_write (void *opaque,hwaddr addr,uint64_t value, +unsigned int size) +{ +AVRUsartState *usart = opaque; +uint8_t mask; +uint8_t data; +assert ((value &0xff ) == value); +assert (size ==1 ); + +if (!usart->enabled) { +return ; + } + +switch (addr) { +case USART_DR : +if (!(usart->csrb &USART_CSRB_TXEN )) { +/* Transmitter disabled, ignore. */ +return ; + } + usart->csra |=USART_CSRA_TXC ; + usart->csra |=USART_CSRA_DRE ; +if (usart->csrb &USART_CSRB_TXCIE ) { +qemu_set_irq (usart->txc_irq,1 ); + usart->csra &=0xff ^USART_CSRA_TXC ; + } +if (usart->csrb &USART_CSRB_DREIE ) { +qemu_set_irq (usart->dre_irq,1 ); + } + data = value; +qemu_chr_fe_write_all (&usart->chr, &data,1 ); +break ; +case USART_CSRA : + mask =0b01000011 ; +/* Mask read-only bits. */ + value = (value & mask) | (usart->csra & (0xff ^ mask)); + usart->csra = value; +if (value &USART_CSRA_TXC ) { + usart->csra ^=USART_CSRA_TXC ; +qemu_set_irq (usart->txc_irq,0 ); + } +if (value &USART_CSRA_MPCM ) { +qemu_log_mask ( +LOG_GUEST_ERROR , +"%s: MPCM not supported by USART\n" , + __func__); + } +break ; +case USART_CSRB : + mask =0b11111101 ; +/* Mask read-only bits. */ + value = (value & mask) | (usart->csrb & (0xff ^ mask)); + usart->csrb = value; +if (!(value &USART_CSRB_RXEN )) { +/* Receiver disabled, flush input buffer. */ + usart->data_valid = false; + } +qemu_set_irq (usart->rxc_irq, + ((value &USART_CSRB_RXCIE ) && + (usart->csra &USART_CSRA_RXC )) ?1 :0 ); +qemu_set_irq (usart->txc_irq, + ((value &USART_CSRB_TXCIE ) && + (usart->csra &USART_CSRA_TXC )) ?1 :0 ); +qemu_set_irq (usart->dre_irq, + ((value &USART_CSRB_DREIE ) && + (usart->csra &USART_CSRA_DRE )) ?1 :0 ); +update_char_mask (usart); +break ; +case USART_CSRC : + usart->csrc = value; +if ((value &USART_CSRC_MSEL1 ) && (value &USART_CSRC_MSEL0 )) { +qemu_log_mask ( +LOG_GUEST_ERROR , +"%s: SPI mode not supported by USART\n" , + __func__); + } +if ((value &USART_CSRC_MSEL1 ) && !(value &USART_CSRC_MSEL0 )) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad USART mode\n",
__func__);hw/char/avr_usart.c new file +54
-0+ } +if (!(value &USART_CSRC_PM1 ) && (value &USART_CSRC_PM0 )) { +qemu_log_mask ( +LOG_GUEST_ERROR , +"%s: Bad USART parity mode\n" , + __func__); + } +update_char_mask (usart); +break ; +case USART_BRRL : + usart->brrl = value; +break ; +case USART_BRRH : + usart->brrh = value &0b00001111 ; +break ; +default : +qemu_log_mask ( +LOG_GUEST_ERROR , +"%s: Bad offset 0x%" HWADDR_PRIx"\n" , + __func__, + addr); + } +} + +static const MemoryRegionOps avr_usart_ops = { + .read = avr_usart_read, + .write = avr_usart_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = {.min_access_size =1 , .max_access_size =1 } +}; + +static Property avr_usart_properties[] = { +DEFINE_PROP_CHR ("chardev" , AVRUsartState, chr), +DEFINE_PROP_END_OF_LIST (), +}; + +static void avr_usart_pr (void *opaque,int irq,int level) +{ +AVRUsartState *s =AVR_USART (opaque); + + s->enabled = !level; + +if (!s->enabled) { +avr_usart_reset (DEVICE (s)); + } +} + +static void avr_usart_init (Object *obj) +{ +AVRUsartState *s =AVR_USART (obj); +sysbus_init_irq (SYS_BUS_DEVICE (obj), &s->rxc_irq); +sysbus_init_irq (SYS_BUS_DEVICE (obj), &s->dre_irq); +sysbus_init_irq (SYS_BUS_DEVICE (obj), &s->txc_irq); + memory_region_init_io(&s->mmio, obj, &avr_usart_ops, s,
TYPE_AVR_USART, 8);hw/char/avr_usart.c new file +37
-0+sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->mmio); +qdev_init_gpio_in (DEVICE (s), avr_usart_pr,1 ); + s->enabled = true; +} + +static void avr_usart_realize (DeviceState *dev,Error **errp) +{ +AVRUsartState *s =AVR_USART (dev); +qemu_chr_fe_set_handlers (&s->chr, avr_usart_can_receive, + avr_usart_receive,NULL ,NULL , + s,NULL , true); +avr_usart_reset (dev); +} + +static void avr_usart_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->reset = avr_usart_reset; + dc->props = avr_usart_properties; + dc->realize = avr_usart_realize; +} + +static const TypeInfo avr_usart_info = { + .name =TYPE_AVR_USART , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (AVRUsartState), + .instance_init = avr_usart_init, + .class_init = avr_usart_class_init, +}; + +static void avr_usart_register_types (void ) +{ +type_register_static (&avr_usart_info); +} + +type_init (avr_usart_register_types)hw/misc/Kconfig +3
-0@@ -125,4 +125,7 @@ config MAC_VIA select MOS6522 select ADB +config AVR_MASK + bool + source macio/Kconfighw/misc/Makefile.objs +2
-0@@ -82,3 +82,5 @@ common-obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o obj-$(CONFIG_MAC_VIA) += mac_via.o common-obj-$(CONFIG_GRLIB) += grlib_ahb_apb_pnp.o + +obj-$(CONFIG_AVR_MASK) += avr_mask.ohw/misc/avr_mask.c new file +6
-0@@ -0,0 +1,112 @@ +/* +* AVR Power Reduction +* +* Copyright (c) 2019 Michael Rolnik +* +* Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */hw/misc/avr_mask.c new file +9
-0+ +#include "qemu/osdep.h" +#include "hw/misc/avr_mask.h" +#include "qemu/log.h" +#include "hw/qdev-properties.h" +#include "hw/irq.h" + +#define DB_PRINT(fmt, args...) /* Nothing */ +/*#define DB_PRINT(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)*/
hw/misc/avr_mask.c new file +50
-0+ +static void avr_mask_reset (DeviceState *dev) +{ +AVRMaskState *s =AVR_MASK (dev); + + s->val =0x00 ; + +for (int i =0 ; i <8 ; i++) { +qemu_set_irq (s->irq[i],0 ); + } +} + +static uint64_t avr_mask_read (void *opaque,hwaddr offset,unsigned size) +{ +assert (size ==1 ); +assert (offset ==0 ); +AVRMaskState *s = opaque; + +return (uint64_t )s->val; +} + +static void avr_mask_write (void *opaque,hwaddr offset, +uint64_t val64,unsigned size) +{ +assert (size ==1 ); +assert (offset ==0 ); +AVRMaskState *s = opaque; +uint8_t val8 = val64; + +DB_PRINT ("write %d to offset %d" , val8, (uint8_t )offset); + + s->val = val8; +for (int i =0 ; i <8 ; i++) { +qemu_set_irq (s->irq[i], (val8 & (1 << i)) !=0 ); + } +} + +static const MemoryRegionOps avr_mask_ops = { + .read = avr_mask_read, + .write = avr_mask_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = {.max_access_size =1 } +}; + +static void avr_mask_init (Object *dev) +{ +AVRMaskState *s =AVR_MASK (dev); +SysBusDevice *busdev =SYS_BUS_DEVICE (dev); + + memory_region_init_io(&s->iomem, dev, &avr_mask_ops, s,
TYPE_AVR_MASK,hw/misc/avr_mask.c new file +30
-0+ 0x01); +sysbus_init_mmio (busdev, &s->iomem); + +for (int i =0 ; i <8 ; i++) { +sysbus_init_irq (busdev, &s->irq[i]); + } + s->val =0x00 ; +} + +static void avr_mask_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->reset = avr_mask_reset; +} + +static const TypeInfo avr_mask_info = { + .name =TYPE_AVR_MASK , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (AVRMaskState), + .class_init = avr_mask_class_init, + .instance_init = avr_mask_init, +}; + +static void avr_mask_register_types (void ) +{ +type_register_static (&avr_mask_info); +} + +type_init (avr_mask_register_types)hw/timer/Kconfig +3
-0@@ -34,3 +34,6 @@ config CMSDK_APB_TIMER config CMSDK_APB_DUALTIMER bool select PTIMER + +config AVR_TIMER16 + boolhw/timer/Makefile.objs +0
-0@@ -35,3 +35,5 @@ common-obj-$(CONFIG_CMSDK_APB_TIMER) +=cmsdk-apb-timer.o
common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o common-obj-$(CONFIG_MSF2) += mss-timer.o common-obj-$(CONFIG_RASPI) += bcm2835_systmr.ohw/timer/Makefile.objs +2
-0+ +obj-$(CONFIG_AVR_TIMER16) += avr_timer16.ohw/timer/avr_timer16.c new file +7
-0@@ -0,0 +1,605 @@ +/* +* AVR 16 bit timer +* +* Copyright (c) 2018 University of Kent +* Author: Ed Robbins +* +* Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */hw/timer/avr_timer16.c new file +5
-0+ +/* +* Driver for 16 bit timers on 8 bit AVR devices. +* Note: +* ATmega640/V-1280/V-1281/V-2560/V-2561/V timers 1, 3, 4 and 5 are 16 bit
+ */hw/timer/avr_timer16.c new file +83
-0+ +/* +* XXX TODO: Power Reduction Register support +* prescaler pause support +* PWM modes, GPIO, output capture pins, input compare pin +*/ + +#include "qemu/osdep.h" +#include "hw/timer/avr_timer16.h" +#include "qemu/log.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" + +/* Register offsets */ +#define T16_CRA 0x0 +#define T16_CRB 0x1 +#define T16_CRC 0x2 +#define T16_CNTL 0x4 +#define T16_CNTH 0x5 +#define T16_ICRL 0x6 +#define T16_ICRH 0x7 +#define T16_OCRAL 0x8 +#define T16_OCRAH 0x9 +#define T16_OCRBL 0xa +#define T16_OCRBH 0xb +#define T16_OCRCL 0xc +#define T16_OCRCH 0xd + +/* Field masks */ +#define T16_CRA_WGM01 0x3 +#define T16_CRA_COMC 0xc +#define T16_CRA_COMB 0x30 +#define T16_CRA_COMA 0xc0 +#define T16_CRA_OC_CONF \ + (T16_CRA_COMA | T16_CRA_COMB | T16_CRA_COMC) + +#define T16_CRB_CS 0x7 +#define T16_CRB_WGM23 0x18 +#define T16_CRB_ICES 0x40 +#define T16_CRB_ICNC 0x80 + +#define T16_CRC_FOCC 0x20 +#define T16_CRC_FOCB 0x40 +#define T16_CRC_FOCA 0x80 + +/* Fields masks both TIMSK and TIFR (interrupt mask/flag registers) */ +#define T16_INT_TOV 0x1/* Timer overflow */ +#define T16_INT_OCA 0x2/* Output compare A */ +#define T16_INT_OCB 0x4/* Output compare B */ +#define T16_INT_OCC 0x8/* Output compare C */ +#define T16_INT_IC 0x20/* Input capture */ + +/* Clock source values */ +#define T16_CLKSRC_STOPPED 0 +#define T16_CLKSRC_DIV1 1 +#define T16_CLKSRC_DIV8 2 +#define T16_CLKSRC_DIV64 3 +#define T16_CLKSRC_DIV256 4 +#define T16_CLKSRC_DIV1024 5 +#define T16_CLKSRC_EXT_FALLING 6 +#define T16_CLKSRC_EXT_RISING 7 + +/* Timer mode values (not including PWM modes) */ +#define T16_MODE_NORMAL 0 +#define T16_MODE_CTC_OCRA 4 +#define T16_MODE_CTC_ICR 12 + +/* Accessors */ +#define CLKSRC (t16) (t16->crb & T16_CRB_CS) +#define MODE (t16) (((t16->crb & T16_CRB_WGM23) >> 1) | \ + (t16->cra & T16_CRA_WGM01)) +#define CNT (t16) VAL16(t16->cntl, t16->cnth) +#define OCRA (t16) VAL16(t16->ocral, t16->ocrah) +#define OCRB (t16) VAL16(t16->ocrbl, t16->ocrbh) +#define OCRC (t16) VAL16(t16->ocrcl, t16->ocrch) +#define ICR (t16) VAL16(t16->icrl, t16->icrh) + +/* Helper macros */ +#define VAL16 (l, h) ((h << 8) | l) +#define ERROR(fmt, args...) \ + qemu_log_mask(LOG_GUEST_ERROR, "%s: " fmt "\n", __func__, ## args) +#define DB_PRINT(fmt, args...) /* Nothing */ +/*#define DB_PRINT(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)*/
hw/timer/avr_timer16.c new file +2
-0+ +static inline int64_t avr_timer16_ns_to_ticks(AVRTimer16State *t16,
int64_tt)hw/timer/avr_timer16.c new file +11
-0+{ +if (t16->period_ns ==0 ) { +return 0 ; + } +return t / t16->period_ns; +} + +static void avr_timer16_update_cnt (AVRTimer16State *t16) +{ +uint16_t cnt; + cnt = avr_timer16_ns_to_ticks(t16,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)-hw/timer/avr_timer16.c new file +49
-0+ t16->reset_time_ns); + t16->cntl = (uint8_t )(cnt &0xff ); + t16->cnth = (uint8_t )((cnt &0xff00 ) >>8 ); +} + +static inline void avr_timer16_recalc_reset_time (AVRTimer16State *t16) +{ + t16->reset_time_ns =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) - +CNT (t16) * t16->period_ns; +} + +static void avr_timer16_clock_reset (AVRTimer16State *t16) +{ + t16->cntl =0 ; + t16->cnth =0 ; + t16->reset_time_ns =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +} + +static void avr_timer16_clksrc_update(AVRTimer16State *t16) +{ + uint16_t divider = 0; + switch (CLKSRC(t16)) { + case T16_CLKSRC_EXT_FALLING: + case T16_CLKSRC_EXT_RISING: + ERROR("external clock source unsupported"); + goto end; + case T16_CLKSRC_STOPPED: + goto end; + case T16_CLKSRC_DIV1: + divider = 1; + break; + case T16_CLKSRC_DIV8: + divider = 8; + break; + case T16_CLKSRC_DIV64: + divider = 64; + break; + case T16_CLKSRC_DIV256: + divider = 256; + break; + case T16_CLKSRC_DIV1024: + divider = 1024; + break; + default: + goto end; + } + t16->freq_hz = t16->cpu_freq_hz / divider; + t16->period_ns = 1000000000ULL / t16->freq_hz; + DB_PRINT("Timer frequency %" PRIu64 " hz, period %" PRIu64 " ns (%fs)",
hw/timer/avr_timer16.c new file +11
-0+ t16->freq_hz, t16->period_ns, 1 / (double)t16->freq_hz); +end: +return ; +} + +static void avr_timer16_set_alarm (AVRTimer16State *t16) +{ +if (CLKSRC (t16) ==T16_CLKSRC_EXT_FALLING || +CLKSRC (t16) ==T16_CLKSRC_EXT_RISING || +CLKSRC (t16) ==T16_CLKSRC_STOPPED ) { +/* Timer is disabled or set to external clock source (unsupported) */
hw/timer/avr_timer16.c new file +53
-0+ goto end; + } + +uint64_t alarm_offset =0xffff ; +enum NextInterrupt next_interrupt =OVERFLOW ; + +switch (MODE (t16)) { +case T16_MODE_NORMAL : +/* Normal mode */ +if (OCRA (t16) < alarm_offset &&OCRA (t16) >CNT (t16) && + (t16->imsk &T16_INT_OCA )) { + alarm_offset =OCRA (t16); + next_interrupt =COMPA ; + } +break ; +case T16_MODE_CTC_OCRA : +/* CTC mode, top = ocra */ +if (OCRA (t16) < alarm_offset &&OCRA (t16) >CNT (t16)) { + alarm_offset =OCRA (t16); + next_interrupt =COMPA ; + } +break ; +case T16_MODE_CTC_ICR : +/* CTC mode, top = icr */ +if (ICR (t16) < alarm_offset &&ICR (t16) >CNT (t16)) { + alarm_offset =ICR (t16); + next_interrupt =CAPT ; + } +if (OCRA (t16) < alarm_offset &&OCRA (t16) >CNT (t16) && + (t16->imsk &T16_INT_OCA )) { + alarm_offset =OCRA (t16); + next_interrupt =COMPA ; + } +break ; +default : +ERROR ("pwm modes are unsupported" ); + goto end; + } +if (OCRB (t16) < alarm_offset &&OCRB (t16) >CNT (t16) && + (t16->imsk &T16_INT_OCB )) { + alarm_offset =OCRB (t16); + next_interrupt =COMPB ; + } +if (OCRC (t16) < alarm_offset &&OCRB (t16) >CNT (t16) && + (t16->imsk &T16_INT_OCC )) { + alarm_offset =OCRB (t16); + next_interrupt =COMPC ; + } + alarm_offset -=CNT (t16); + + t16->next_interrupt = next_interrupt; +uint64_t alarm_ns = + t16->reset_time_ns + ((CNT(t16) + alarm_offset) *
t16->period_ns);hw/timer/avr_timer16.c new file +20
-0+timer_mod (t16->timer, alarm_ns); + +DB_PRINT ("next alarm %" PRIu64" ns from now" , + alarm_offset * t16->period_ns); + +end: +return ; +} + +static void avr_timer16_interrupt (void *opaque) +{ +AVRTimer16State *t16 = opaque; +uint8_t mode =MODE (t16); + +avr_timer16_update_cnt (t16); + +if (CLKSRC (t16) ==T16_CLKSRC_EXT_FALLING || +CLKSRC (t16) ==T16_CLKSRC_EXT_RISING || +CLKSRC (t16) ==T16_CLKSRC_STOPPED ) { +/* Timer is disabled or set to external clock source (unsupported) */
hw/timer/avr_timer16.c new file +22
-0+return ; + } + +DB_PRINT ("interrupt, cnt = %d" ,CNT (t16)); + +/* Counter overflow */ +if (t16->next_interrupt ==OVERFLOW ) { +DB_PRINT ("0xffff overflow" ); +avr_timer16_clock_reset (t16); +if (t16->imsk &T16_INT_TOV ) { + t16->ifr |=T16_INT_TOV ; +qemu_set_irq (t16->ovf_irq,1 ); + } + } +/* Check for ocra overflow in CTC mode */ +if (mode ==T16_MODE_CTC_OCRA && t16->next_interrupt ==COMPA ) { +DB_PRINT ("CTC OCRA overflow" ); +avr_timer16_clock_reset (t16); + } +/* Check for icr overflow in CTC mode */ +if (mode ==T16_MODE_CTC_ICR && t16->next_interrupt ==CAPT ) { + DB_PRINT("CTC ICR overflow");--2.17.2 (Apple Git-113)
Signature · 2 lines
Best Regards, Michael Rolnik
PATCH v35 11/13 target/avr: Add example board configuration
In reply to Michael RolnikA simple board setup that configures an AVR CPU to run a given firmware image.
This is all that's useful to implement without peripheral emulation as AVR CPUs include a lot of on-board peripherals.
NOTE: this is not a real board !!!!
NOTE: it's used for CPU testing!!!!
--- hw/Kconfig | 1 + hw/avr/Kconfig | 6 + hw/avr/Makefile.objs | 1 + hw/avr/sample.c | 282 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 290 insertions(+) create mode 100644 hw/avr/Kconfig create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c
hw/Kconfig +1 -0
@@ -44,6 +44,7 @@ source watchdog/Kconfig # arch Kconfig source arm/Kconfig source alpha/Kconfig +source avr/Kconfig source cris/Kconfig source hppa/Kconfig source i386/Kconfig
hw/avr/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +config AVR_SAMPLE + bool + select AVR_TIMER16 + select AVR_USART + select AVR_MASK + select UNIMP
hw/avr/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-y += sample.o
hw/avr/sample.c new file +282 -0
282 lines not on this page · raw message
Signature · 1 line
2.17.2 (Apple Git-113)
PATCH v35 12/13 target/avr: Register AVR support with the rest of QEMU, the build system, and the WMAINTAINERS file
In reply to Michael Rolnik--- MAINTAINERS | 9 +++++++++ arch_init.c | 2 ++ configure | 7 +++++++ default-configs/avr-softmmu.mak | 5 +++++ include/disas/dis-asm.h | 6 ++++++ include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 ++- target/avr/Makefile.objs | 33 +++++++++++++++++++++++++++++++++ tests/machine-none-test.c | 1 + 9 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 target/avr/Makefile.objs
MAINTAINERS +9 -0
@@ -163,6 +163,15 @@ S: Maintained F: hw/arm/smmu* F: include/hw/arm/smmu* +AVR TCG CPUs +M: Michael Rolnik <[email protected]> +S: Maintained +F: target/avr/ +F: hw/misc/avr_mask.c +F: hw/char/avr_usart.c +F: hw/timer/avr_timer16.c +F: hw/avr/ + CRIS TCG CPUs M: Edgar E. Iglesias <[email protected]> S: Maintained
arch_init.c +2 -0
@@ -89,6 +89,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_UNICORE32#elif defined(TARGET_XTENSA )#define QEMU_ARCH QEMU_ARCH_XTENSA +#elif defined(TARGET_AVR ) +#define QEMU_ARCH QEMU_ARCH_AVR#endif const uint32_t arch_type =QEMU_ARCH ;
configure +7 -0
@@ -7516,6 +7516,10 @@ case "$target_name" in mttcg="yes" gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" ;; + avr) + gdb_xml_files="avr-cpu.xml" + target_compiler=$cross_cc_avr + ;; cris) ;; hppa)
@@ -7735,6 +7739,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do disas_config "ARM_A64" fi ;; + avr) + disas_config "AVR" + ;; cris) disas_config "CRIS" ;;
default-configs/avr-softmmu.mak new file +5 -0
@@ -0,0 +1,5 @@ +# Default configuration for avr-softmmu + +# Boards: +# +CONFIG_AVR_SAMPLE=y
include/disas/dis-asm.h +6 -0
@@ -211,6 +211,12 @@ enum bfd_architecture#define bfd_mach_m32r 0/* backwards compatibility */ bfd_arch_mn10200, /* Matsushita MN10200 */ bfd_arch_mn10300, /* Matsushita MN10300 */ + bfd_arch_avr, /* Atmel AVR microcontrollers. */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 bfd_arch_cris, /* Axis CRIS */#define bfd_mach_cris_v0_v10 255#define bfd_mach_cris_v32 32
include/sysemu/arch_init.h +1 -0
@@ -24,6 +24,7 @@ enum {QEMU_ARCH_NIOS2 = (1 <<17 ),QEMU_ARCH_HPPA = (1 <<18 ),QEMU_ARCH_RISCV = (1 <<19 ), + QEMU_ARCH_AVR = (1 << 20), };extern const uint32_t arch_type;
qapi/machine.json +2 -1
@@ -21,11 +21,12 @@ # is true even for "qemu-system-x86_64". # # ppcemb: dropped in 3.1 +# avr: since 4.2 # # Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'cris', 'hppa', 'i386', 'lm32', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'cris', 'hppa', 'i386', 'lm32', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'moxie', 'nios2', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 's390x', 'sh4',
target/avr/Makefile.objs new file +33 -0
@@ -0,0 +1,33 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2019 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +DECODETREE = $(SRC_PATH)/scripts/decodetree.py +decode-y = $(SRC_PATH)/target/avr/insn.decode + +target/avr/decode_insn.inc.c: $(decode-y) $(DECODETREE) + $(call quiet-command, \ + $(PYTHON) $(DECODETREE) -o $@ --decode decode_insn --insnwidth 16 $<, \ + "GEN", $(TARGET_DIR)$@) + +target/avr/translate.o: target/avr/decode_insn.inc.c + +obj-y += translate.o cpu.o helper.o +obj-y += gdbstub.o +obj-$(CONFIG_SOFTMMU) += machine.o
tests/machine-none-test.c +1 -0
@@ -27,6 +27,7 @@ static struct arch2cpu cpus_map[] = {/* tested targets list */ { "arm", "cortex-a15" }, { "aarch64", "cortex-a57" }, + { "avr", "avr6-avr-cpu" }, { "x86_64", "qemu64,apic-id=0" }, { "i386", "qemu32,apic-id=0" }, { "alpha", "ev67" },
Signature · 1 line
2.17.2 (Apple Git-113)
Re: [PATCH v35 12/13] target/avr: Register AVR support with the rest of QEMU, the build system, and the WMAINTAINERS file
Quoted 176 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>--- MAINTAINERS | 9 +++++++++ arch_init.c | 2 ++ configure | 7 +++++++ default-configs/avr-softmmu.mak | 5 +++++ include/disas/dis-asm.h | 6 ++++++ include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 ++- target/avr/Makefile.objs | 33 +++++++++++++++++++++++++++++++++ tests/machine-none-test.c | 1 + 9 files changed, 66 insertions(+), 1 deletion(-)create mode 100644 default-configs/avr-softmmu.mak create mode 100644 target/avr/Makefile.objs
MAINTAINERS +9
-0@@ -163,6 +163,15 @@ S: Maintained F: hw/arm/smmu* F: include/hw/arm/smmu* +AVR TCG CPUs +M: Michael Rolnik <[email protected]> +S: Maintained +F: target/avr/ +F: hw/misc/avr_mask.c +F: hw/char/avr_usart.c +F: hw/timer/avr_timer16.c +F: hw/avr/ + CRIS TCG CPUs M: Edgar E. Iglesias <[email protected]> S: Maintainedarch_init.c +2
-0@@ -89,6 +89,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_UNICORE32#elif defined(TARGET_XTENSA )#define QEMU_ARCH QEMU_ARCH_XTENSA +#elif defined(TARGET_AVR ) +#define QEMU_ARCH QEMU_ARCH_AVR#endif const uint32_t arch_type =QEMU_ARCH ;configure +7
-0@@ -7516,6 +7516,10 @@ case "$target_name" in mttcg="yes" gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" ;; + avr) + gdb_xml_files="avr-cpu.xml" + target_compiler=$cross_cc_avr + ;; cris) ;; hppa)@@ -7735,6 +7739,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do disas_config "ARM_A64" fi ;; + avr) + disas_config "AVR" + ;; cris) disas_config "CRIS" ;;default-configs/avr-softmmu.mak new file +5
-0@@ -0,0 +1,5 @@ +# Default configuration for avr-softmmu + +# Boards: +# +CONFIG_AVR_SAMPLE=yinclude/disas/dis-asm.h +6
-0@@ -211,6 +211,12 @@ enum bfd_architecture#define bfd_mach_m32r 0/* backwards compatibility */ bfd_arch_mn10200, /* Matsushita MN10200 */ bfd_arch_mn10300, /* Matsushita MN10300 */ + bfd_arch_avr, /* Atmel AVR microcontrollers. */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 bfd_arch_cris, /* Axis CRIS */#define bfd_mach_cris_v0_v10 255#define bfd_mach_cris_v32 32include/sysemu/arch_init.h +1
-0@@ -24,6 +24,7 @@ enum {QEMU_ARCH_NIOS2 = (1 <<17 ),QEMU_ARCH_HPPA = (1 <<18 ),QEMU_ARCH_RISCV = (1 <<19 ), + QEMU_ARCH_AVR = (1 << 20), };extern const uint32_t arch_type;qapi/machine.json +2
-1@@ -21,11 +21,12 @@ # is true even for "qemu-system-x86_64". # # ppcemb: dropped in 3.1 +# avr: since 4.2 # # Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'cris', 'hppa', 'i386', 'lm32', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'cris', 'hppa', 'i386', 'lm32', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'moxie', 'nios2', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 's390x', 'sh4',target/avr/Makefile.objs new file +33
-0@@ -0,0 +1,33 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2019 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +DECODETREE = $(SRC_PATH)/scripts/decodetree.py +decode-y = $(SRC_PATH)/target/avr/insn.decode + +target/avr/decode_insn.inc.c: $(decode-y) $(DECODETREE) + $(call quiet-command, \ + $(PYTHON) $(DECODETREE) -o $@ --decode decode_insn --insnwidth 16 $<, \ + "GEN", $(TARGET_DIR)$@) + +target/avr/translate.o: target/avr/decode_insn.inc.c + +obj-y += translate.o cpu.o helper.o +obj-y += gdbstub.o +obj-$(CONFIG_SOFTMMU) += machine.otests/machine-none-test.c +0
-0
tests/machine-none-test.c static struct arch2cpu cpus_map[] = { · line 33
Quoted 7 lines
tests/machine-none-test.c +1
-0@@ -27,6 +27,7 @@ static struct arch2cpu cpus_map[] = {/* tested targets list */ { "arm", "cortex-a15" }, { "aarch64", "cortex-a57" }, + { "avr", "avr6-avr-cpu" }, { "x86_64", "qemu64,apic-id=0" }, { "i386", "qemu32,apic-id=0" }, { "alpha", "ev67" },
Re: [PATCH v35 12/13] target/avr: Register AVR support with the rest of QEMU, the build system, and the WMAINTAINERS file
In reply to Michael Rolnikqapi/machine.json line 24
Quoted 9 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>---
+++
b/qapi/machine.jsonqapi/machine.json +1
-0@@ -21,11 +21,12 @@ # is true even for "qemu-system-x86_64". # # ppcemb: dropped in 3.1 +# avr: since 4.2
At this point, we've missed the cutoff for new features in 4.2, so this should be 5.0
Quoted 9 lines
qapi/machine.json +1
-1# # Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'cris', 'hppa', 'i386', 'lm32', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'cris', 'hppa', 'i386', 'lm32', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'moxie', 'nios2', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 's390x', 'sh4',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v35 12/13] target/avr: Register AVR support with the rest of QEMU, the build system, and the WMAINTAINERS file
In reply to Michael RolnikQuoted 16 lines · Michael Rolnik
Signed-off-by Michael Rolnik <[email protected]>--- MAINTAINERS | 9 +++++++++ arch_init.c | 2 ++ configure | 7 +++++++ default-configs/avr-softmmu.mak | 5 +++++ include/disas/dis-asm.h | 6 ++++++ include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 ++- target/avr/Makefile.objs | 33 +++++++++++++++++++++++++++++++++ tests/machine-none-test.c | 1 + 9 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 target/avr/Makefile.objs
Michael, hi.
Can you please do the following:
1. replace "4.2" with "5.0", as Eric hinted
2. divide this patch into three patches:
- target/avr: Register AVR support with the rest of QEMU
- target/avr: Update build system
- target/avr: Update MAINTAINERS file
(distribution of files to patches is obvious)
3. Add at least a sentence to the commit messages of three new patches
4. Don't forget to add Philippe's "Tested-by:"s to all three commit messages
5. At this stage you can add:
to all three new patches.
6. Rearange last patches in your series so that their order look like this:
(prior to this you need to do split of the patch 13/13 as I described in my response to it, half an hour ago)
- target/avr: Register AVR support with the rest of QEMU
- target/avr: Update build system
- target/avr: Add boot serial test
- target/avr: Add Avocado acceptance test
- target/avr: Update MAINTAINERS file
That way, the "MAINTAINERS" patch acts as some kind of signature. :-)
...........................
You may think that these are all unnecessary details, but, trust me, they give a lot of quality and gravity to the series.
Yours, Aleksandar
Quoted 175 lines
MAINTAINERS +9
-0@@ -163,6 +163,15 @@ S: Maintained F: hw/arm/smmu* F: include/hw/arm/smmu* +AVR TCG CPUs +M: Michael Rolnik <[email protected]> +S: Maintained +F: target/avr/ +F: hw/misc/avr_mask.c +F: hw/char/avr_usart.c +F: hw/timer/avr_timer16.c +F: hw/avr/ + CRIS TCG CPUs M: Edgar E. Iglesias <[email protected]> S: Maintainedarch_init.c +2
-0@@ -89,6 +89,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_UNICORE32#elif defined(TARGET_XTENSA )#define QEMU_ARCH QEMU_ARCH_XTENSA +#elif defined(TARGET_AVR ) +#define QEMU_ARCH QEMU_ARCH_AVR#endif const uint32_t arch_type =QEMU_ARCH ;configure +0
-0@@ -7516,6 +7516,10 @@ case "$target_name" in mttcg="yes" gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xmlarm-vfp.xml arm-vfp3.xml arm-neon.xml"
;;configure +7
-0+ avr) + gdb_xml_files="avr-cpu.xml" + target_compiler=$cross_cc_avr + ;; cris) ;; hppa)@@ -7735,6 +7739,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do disas_config "ARM_A64" fi ;; + avr) + disas_config "AVR" + ;; cris) disas_config "CRIS" ;;default-configs/avr-softmmu.mak new file +5
-0@@ -0,0 +1,5 @@ +# Default configuration for avr-softmmu + +# Boards: +# +CONFIG_AVR_SAMPLE=yinclude/disas/dis-asm.h +6
-0@@ -211,6 +211,12 @@ enum bfd_architecture#define bfd_mach_m32r 0/* backwards compatibility */ bfd_arch_mn10200, /* Matsushita MN10200 */ bfd_arch_mn10300, /* Matsushita MN10300 */ + bfd_arch_avr, /* Atmel AVR microcontrollers. */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 bfd_arch_cris, /* Axis CRIS */#define bfd_mach_cris_v0_v10 255#define bfd_mach_cris_v32 32include/sysemu/arch_init.h +1
-0@@ -24,6 +24,7 @@ enum {QEMU_ARCH_NIOS2 = (1 <<17 ),QEMU_ARCH_HPPA = (1 <<18 ),QEMU_ARCH_RISCV = (1 <<19 ), + QEMU_ARCH_AVR = (1 << 20), };extern const uint32_t arch_type;qapi/machine.json +2
-1@@ -21,11 +21,12 @@ # is true even for "qemu-system-x86_64". # # ppcemb: dropped in 3.1 +# avr: since 4.2 # # Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'cris', 'hppa', 'i386', 'lm32', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'cris', 'hppa', 'i386', 'lm32', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'moxie', 'nios2', 'or1k', 'ppc','ppc64', 'riscv32', 'riscv64', 's390x', 'sh4',target/avr/Makefile.objs new file +26
-0@@ -0,0 +1,33 @@ +# +# QEMU AVR CPU +# +# Copyright (c) 2019 Michael Rolnik +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see +# <http://www.gnu.org/licenses/lgpl-2.1.html> +# + +DECODETREE = $(SRC_PATH)/scripts/decodetree.py +decode-y = $(SRC_PATH)/target/avr/insn.decode + +target/avr/decode_insn.inc.c: $(decode-y) $(DECODETREE) + $(call quiet-command, \ + $(PYTHON) $(DECODETREE) -o $@ --decode decode_insn --insnwidth16 $<, \
target/avr/Makefile.objs new file +7
-0+ "GEN", $(TARGET_DIR)$@) + +target/avr/translate.o: target/avr/decode_insn.inc.c + +obj-y += translate.o cpu.o helper.o +obj-y += gdbstub.o +obj-$(CONFIG_SOFTMMU) += machine.otests/machine-none-test.c +1
-1@@ -27,6 +27,7 @@ static struct arch2cpu cpus_map[] = {/* tested targets list */ { "arm", "cortex-a15" }, { "aarch64", "cortex-a57" }, + { "avr", "avr6-avr-cpu" }, { "x86_64", "qemu64,apic-id=0" }, { "i386", "qemu32,apic-id=0" }, { "alpha", "ev67" }, --2.17.2 (Apple Git-113)
PATCH v35 13/13 target/avr: Add tests
In reply to Michael Rolnik1. Avocado test
The test is based on
https://github.com/seharris/qemu-avr-tests/tree/master/free-rtos/Demo
demo which. If working correctly, prints 'ABCDEFGHIJKLMNOPQRSTUVWX' out. it also demostrates that timer and IRQ are working
2. Boot serial test
Print out 'T' through serial port
--- tests/Makefile.include | 2 ++ tests/acceptance/machine_avr6.py | 36 ++++++++++++++++++++++++++++++++ tests/boot-serial-test.c | 10 +++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/acceptance/machine_avr6.py
tests/Makefile.include +2 -0
@@ -206,6 +206,8 @@ check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF) check-qtest-i386-y += tests/numa-test$(EXESUF) check-qtest-x86_64-y += $(check-qtest-i386-y) +check-qtest-avr-y += tests/boot-serial-test$(EXESUF) + check-qtest-alpha-y += tests/boot-serial-test$(EXESUF) check-qtest-alpha-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF)
tests/acceptance/machine_avr6.py new file +36 -0
@@ -0,0 +1,36 @@ +import logging +import time +import distutils.spawn + +from avocado import skipUnless +from avocado_qemu import Test +from avocado.utils import process + +class AVR6Machine(Test): + timeout = 5 + + def test_freertos(self): + """ + :avocado: tags=arch:avr + :avocado: tags=machine:sample + """ + """ + https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf + constantly prints out 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX' + """ + rom_url = 'https://github.com/seharris/qemu-avr-tests' + rom_url += '/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf' + rom_hash = '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4' + rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash) + + self.vm.set_machine('sample') + self.vm.add_args('-bios', rom_path) + self.vm.add_args('-nographic') + self.vm.launch() + + time.sleep(2) + self.vm.shutdown() + + match = 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX' + + self.assertIn(match, self.vm.get_log())
tests/boot-serial-test.c +10 -0
@@ -16,6 +16,15 @@#include "qemu/osdep.h" #include "libqtest.h" +static const uint8_t bios_avr[] = { +0x88 ,0xe0 ,/* ldi r24, 0x08 */ +0x80 ,0x93 ,0xc1 ,0x00 ,/* sts 0x00C1, r24 ; Enable tx */ +0x86 ,0xe0 ,/* ldi r24, 0x06 */ +0x80 ,0x93 ,0xc2 ,0x00 ,/* sts 0x00C2, r24 ; Set the data bits to 8 */ +0x84 ,0xe5 ,/* ldi r24, 0x54 */ +0x80 ,0x93 ,0xc6 ,0x00 ,/* sts 0x00C6, r24 ; Output 'T' */ +}; +static const uint8_t kernel_mcf5208[] = {0x41 ,0xf9 ,0xfc ,0x06 ,0x00 ,0x00 ,/* lea 0xfc060000,%a0 */ 0x10 ,0x3c ,0x00 ,0x54 ,/* move.b #'T',%d0 */
@@ -103,6 +112,7 @@ typedef struct testdef {static testdef_t tests[] = { {"alpha" ,"clipper" ,"" ,"PCI:" }, + {"avr" ,"sample" ,"" ,"T" ,sizeof (bios_avr),NULL , bios_avr }, {"ppc" ,"ppce500" ,"" ,"U-Boot" }, {"ppc" ,"40p" ,"-vga none -boot d" ,"Trying cd:," }, {"ppc" ,"g3beige" ,"" ,"PowerPC,750" },
Signature · 1 line
2.17.2 (Apple Git-113)
Re: [PATCH v35 13/13] target/avr: Add tests
Quoted 7 lines · Michael Rolnik
1. Avocado test
The test is based on
https://github.com/seharris/qemu-avr-tests/tree/master/free-rtos/Demo
demo which. If working correctly, prints 'ABCDEFGHIJKLMNOPQRSTUVWX'
out.
it also demostrates that timer and IRQ are working
Quoted 8 lines
2. Boot serial test
Print out 'T' through serial portSigned-off-by Michael Rolnik <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Acked-by Thomas Huth <[email protected]>---
But, please, Michael, divide this patch into two in the next version:
- target/avr: Add boot serial test
- target/avr: Add Avocado acceptance test
with, of course, adjusted corresponding commit messages. You can transfer all "Reviewed-by:"s, "Tested-by:"s and "Acked-by:"s (includong mine) to both new patches.
Yours, Aleksandar
Quoted 98 lines
tests/Makefile.include | 2 ++ tests/acceptance/machine_avr6.py | 36 ++++++++++++++++++++++++++++++++ tests/boot-serial-test.c | 10 +++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/acceptance/machine_avr6.pytests/Makefile.include +2
-0@@ -206,6 +206,8 @@ check-qtest-i386-y += tests/test-x86-cpuid-compat$( EXESUF) check-qtest-i386-y += tests/numa-test$(EXESUF) check-qtest-x86_64-y += $(check-qtest-i386-y) +check-qtest-avr-y += tests/boot-serial-test$(EXESUF) + check-qtest-alpha-y += tests/boot-serial-test$(EXESUF) check-qtest-alpha-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF)tests/acceptance/machine_ renamed from tests/acceptance/machine_avr6.py +0
-0
avr6.py
new file mode 100644
index 0000000000..0601080b01tests/acceptance/machine_avr6.py new file +18
-0@@ -0,0 +1,36 @@ +import logging +import time +import distutils.spawn + +from avocado import skipUnless +from avocado_qemu import Test +from avocado.utils import process + +class AVR6Machine(Test): + timeout = 5 + + def test_freertos(self): + """ + :avocado: tags=arch:avr + :avocado: tags=machine:sample + """ + """ + https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf
+ constantly prints out 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEF
GHIJKLMNOPQRSTUVWX'tests/acceptance/machine_avr6.py new file +3
-0+ """ + rom_url = 'https://github.com/seharris/qemu-avr-tests' + rom_url += '/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf'
tests/acceptance/machine_avr6.py new file +14
-0+ rom_hash = '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4' + rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash) + + self.vm.set_machine('sample') + self.vm.add_args('-bios', rom_path) + self.vm.add_args('-nographic') + self.vm.launch() + + time.sleep(2) + self.vm.shutdown() + + match = 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX' + + self.assertIn(match, self.vm.get_log())tests/boot-serial-test.c +10
-1@@ -16,6 +16,15 @@#include "qemu/osdep.h" #include "libqtest.h" +static const uint8_t bios_avr[] = { +0x88 ,0xe0 ,/* ldi r24, 0x08 */ +0x80 ,0x93 ,0xc1 ,0x00 ,/* sts 0x00C1, r24 ; Enable tx */ +0x86 ,0xe0 ,/* ldi r24, 0x06 */ +0x80 ,0x93 ,0xc2 ,0x00 ,/* sts 0x00C2, r24 ; Set the data bits to 8 */ +0x84 ,0xe5 ,/* ldi r24, 0x54 */ +0x80 ,0x93 ,0xc6 ,0x00 ,/* sts 0x00C6, r24 ; Output 'T' */ +}; +static const uint8_t kernel_mcf5208[] = {0x41 ,0xf9 ,0xfc ,0x06 ,0x00 ,0x00 ,/* lea 0xfc060000,%a0 */ 0x10 ,0x3c ,0x00 ,0x54 ,/* move.b #'T',%d0 */ @@ -103,6 +112,7 @@ typedef struct testdef {static testdef_t tests[] = { {"alpha" ,"clipper" ,"" ,"PCI:" }, + {"avr" ,"sample" ,"" ,"T" ,sizeof (bios_avr),NULL , bios_avr }, {"ppc" ,"ppce500" ,"" ,"U-Boot" }, {"ppc" ,"40p" ,"-vga none -boot d" ,"Trying cd:," }, {"ppc" ,"g3beige" ,"" ,"PowerPC,750" }, --2.17.2 (Apple Git-113)
Quoted 1 line · Michael Rolnik
This series of patches adds 8bit AVR cores to QEMU.
Hi Michael,
I am going to take more detailed look at your series as soon as these hectic days around softfreeze/hardfreeze days pass. It is definitely a series that needed a lot of hard work, and it deserves to be seriously considered.
Yours, Aleksandar
Quoted 337 lines
All instruction, except BREAK/DES/SPM/SPMX, are implemented. Not fully tested yet.
However I was able to execute simple code with functions. e.g fibonacci calculation.
This series of patches include a non real, sample board.
No fuses support yet. PC is set to 0 at reset.the patches include the following
1. just a basic 8bit AVR CPU, without instruction decoding or translation
2. CPU features which allow define the following 8bit AVR coresavr1 avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 xmega2 xmega4 xmega5 xmega6 xmega73. a definition of sample machine with SRAM, FLASH and CPU which allows to execute simple code
4. encoding for all AVR instructions
5. interrupt handling
6. helpers for IN, OUT, SLEEP, WBR & unsupported instructions
7. a decoder which given an opcode decides what istruction it is
8. translation of AVR instruction into TCG
9. all features togetherchanges since v3
1. rampD/X/Y/Z registers are encoded as0x00ff0000(instead of0x000000ff) for faster address manipulaton
2. ffs changed to ctz32
3. duplicate code removed atavr_cpu_do_interrupt
4. using andc instead of not + and
5. fixing V flag calculation in varios instructions
6. freeing local variables in PUSH
7.tcg_const_local_i32->tcg_const_i32
8. using sextract32 instead of my implementation
9. fixing BLD instruction
10.xor(r) instead of0xff- r at COM
11.fixing MULS/MULSU not to modify inputs' content
12.using SUB for NEG
13.fixing tcg_gen_qemu_ld/st call in XCHchanges since v4
1. target is now defined as big endian in order to optimize push_ret/pop_ret
2. all style warnings are fixed
3. adding cpu_set/get_sreg functions
4. simplifyinggen_goto_tbas there is no real paging
5.env->pc->env->pc_w
6. making flag dump more compact
7. more spacing
8. renaming CODE/DATA_INDEX -> MMU_CODE/DATA_IDX
9. removingavr_set_feature
10. SPL/SPH set bug fix
11. switchingstb_phystocpu_stb_data
12. cleaning upavr_decode
13. saving sreg, rampD/X/Y/Z, eind in HW format (savevm)
14. saving CPU features (savevm)changes since v5
1. BLD bug fix
2. decoder generator is addedchages since v6
1. using cpu_get_sreg/cpu_set_sreg in avr_cpu_gdb_read_register/avr_cpu_gdb_write_register
2. configure the target as little endian because otherwise GDB does not work
3. fixing and testing gen_push_ret/gen_pop_retchanges since v7
1. folding back v6
2. logging athelper_outbandhelper_inbare done for non supported yet registers only
3.MAINTAINERSupdatedchanges since v8
1. removing hw/avr from hw/Makefile.obj as it should not be built for all
2. making linux compilable
3. testing ona. Mac, Apple LLVM version 7.0.0 b. Ubuntu 12.04, gcc 4.9.2 c. Fedora 23, gcc 5.3.14. folding back some patches
5. translation bug fixes for ORI, CPI, XOR instructions
6. propper handling of cpu register writes though memorychanges since v9
1. removing forward declarations of static functions
2. disabling debug prints
3. switching to case range instead of if else if ...
4. LD/ST IN/OUT accessing CPU maintainder registers are not routed to any device
5. commenst about sample board and sample IO device added
6. sample board description is more descriptive now
7.memory_region_allocate_system_memoryis used to create RAM
8. now there arehelper_fullrd&helper_fullwrwhen LD/ST try to access registerschanges since v10
1. movig back fullwr & fullrd into the commit where outb and inb were introduced
2. changingtlb_fillfunction signature
3. adding empty line between functions
4. adding newline on the last line of the file
5. usingtb->flagsto generae full access ST/LD instructions
6. fixing SBRC bug
7. folding back 10th commit
8. whenever a new file is introduced it's added to Makefile.objschanges since v11
1. updating to v2.7.0-rc
2. removing assignment toenv->fullaccfromgen_intermediate_codechanges since v12
1. fixing spacing
2. fixing get/put_segment functions
3. removingtarget-avr/machine.hfile
4.VMSTATE_SINGLE_TEST->VMSTATE_SINGLE
5. comment spelling
6. removinghw/avr/sample_io.c
7. char const* -> const char*
8. proper ram allocation
9. fixing breakpoint functionality.
10.env1 -> env
11.fixingavr_cpu_gdb_write_register&avr_cpu_gdb_read_registerfunctions 12.any cpu is removed
12.feature bits are not saved into vm statechanges since v13
1. rebasing to v2.7.0-rc1changes since v14
1. I made self review with git gui tool. (I did not know such a thing exists)
2. removing all double/tripple spaces
3. removing comment reference to SampleIO
4. folding back some changes, so there is not deleted lines in my code
5. moving avr configuration, within configure file, before chrischanges since v15
1. removing IO registers cache from CPU
2. implementing CBI/SBI asread(helper_inb), modify,write(helper_outb)
3. implementing CBIC/SBIC asread(helper_inb), check, branch
4. adding missingtcg_temp_free_i32fortcg_const_i32changes since v16
1. removing EXT IO registers knoledge from CPU. These registers are accessible
by LD/ST only. CPU has no interest in themchanges since v17 (by Richard Henderson)
This is Michael's v17, with some adjustments of my own:1. Fix the whitespace errors reported by "git am",
2. Replace the utf-8 characters with normal ascii,
3. Ditch the separate compilation oftranslate.c.I retained the two separate files that could be regenerated from the included cpugen program, but merged in
translate-insn.c. Not that it matters, but the code generated is about 3k smaller.changes since v18
1. moving target-avr into target/avr 2. do not call cpu_exec_initfn function from avr_cpu_initfn 3. call cpu_exec_realizefn avr_cpu_realizefn 4. do not fail sample machine creation if no rom is suplied 5. add tcg_gen_exit_tb(0) for BS_BRANCH in gen_intermediate_code 6. fix a register getters/setters in machine.c 7. changing QEMU_ARCH_AVR from 1<<17 to 1<<18changes since v19
1. use decodetree.py tool to decode instructions 2. adding USART 3. adding 16 bit timer peripherals 4. changing QEMU_ARCH_AVR from 1<<18 to 1<<20 5. renaming tlb_fill to avr_cpu_tlb_fillchanges since v20
1. use one CPU naming convention 2. merging insn16.decode & insn32.decode files 3. modifying skip next instruction mechanizm 4. translate BREAK as NOP for nowchanges since v21
1. Reorganize bstate.
This will make transition to <exec/translator.h> easier, and fixes a
couple of bugs wrt single stepping
by [email protected]
2. Drop cpc and fix page cross condition.
by [email protected]
3. Refactor checking supported/unsupported instructions
4. Addgdb-xml/avr-cpu.xmlchanges since v22
1. Rebase
2. Split long commentchanges since v23
1. remove avr_cpu_list_compare function 2. modify avr_cpu_class_by_name function 3. modify avr_cpu_list_entry function 4. modify avr_cpu_list functionchanges since v24
1. removeAVR_CPU_TYPE_NAMEmacrochanges since v25
1. fix patches. every file belong to one patch only 2. change copyright year from 2016 to 2019 3. create mask device to emulate prr0/prr1changes since v26
1. add avocado acceptence test
2. add boot serial testchanges since v27
1. list atmel2560 devices as unimplemented
2. fix sram base/sizechanges since v28
1. rebase
2. fix includes & buildchanges since v29
1. fixing ownership
2. using 'since' instread of 'added in'changes since v30
1. rebasechanges since v31
1. splitting 'Add instruction translation' commit 2. fixing typo in qapi/machine.json sicne -> since 3. removing unintended changes in configure file 4. adding Richard Henderson as a co developer to 'Add instructiontranslation - CPU main translation funcions' commit
changes since v32
1. modifycpu_get_sregto treat sreg C as other flags, except sreg Zchanges since v33
1. ensure flag C is always calculated as one bit
2. calculate flag Z as one bit, without using inverse logicchanges since v34
1. rebaseMichael Rolnik (12):
target/avr: Add outward facing interfaces and core CPU logic target/avr: Add instruction helpers
target/avr: Add instruction decoding
target/avr: Add instruction translation - Registers definition target/avr: Add instruction translation - Arithmetic and Logic
Instructions
target/avr: Add instruction translation - Branch Instructions target/avr: Add instruction translation - Bit and Bit-test
Instructions
target/avr: Add instruction translation - MCU Control Instructions target/avr: Add instruction translation - CPU main translation
function
target/avr: Add example board configuration
target/avr: Register AVR support with the rest of QEMU, the build
system, and the WMAINTAINERS file
target/avr: Add testsSarah Harris (1):
target/avr: Add limited support for USART and 16 bit timer peripheralsMAINTAINERS | 9 + arch_init.c | 2 + configure | 7 + default-configs/avr-softmmu.mak | 5 + gdb-xml/avr-cpu.xml | 49 + hw/Kconfig | 1 + hw/avr/Kconfig | 6 + hw/avr/Makefile.objs | 1 + hw/avr/sample.c | 282 +++ hw/char/Kconfig | 3 + hw/char/Makefile.objs | 1 + hw/char/avr_usart.c | 324 ++++ hw/misc/Kconfig | 3 + hw/misc/Makefile.objs | 2 + hw/misc/avr_mask.c | 112 ++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 2 + hw/timer/avr_timer16.c | 605 ++++++ include/disas/dis-asm.h | 6 + include/hw/char/avr_usart.h | 97 + include/hw/misc/avr_mask.h | 47 + include/hw/timer/avr_timer16.h | 97 + include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 +- target/avr/Makefile.objs | 33 + target/avr/cpu-param.h | 37 + target/avr/cpu-qom.h | 54 + target/avr/cpu.c | 576 ++++++ target/avr/cpu.h | 253 +++ target/avr/gdbstub.c | 85 + target/avr/helper.c | 354 ++++ target/avr/helper.h | 29 + target/avr/insn.decode | 175 ++ target/avr/machine.c | 121 ++ target/avr/translate.c | 3028 ++++++++++++++++++++++++++++++ tests/Makefile.include | 2 + tests/acceptance/machine_avr6.py | 36 + tests/boot-serial-test.c | 10 + tests/machine-none-test.c | 1 + 39 files changed, 6461 insertions(+), 1 deletion(-) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 gdb-xml/avr-cpu.xml create mode 100644 hw/avr/Kconfig create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c create mode 100644 hw/char/avr_usart.c create mode 100644 hw/misc/avr_mask.c create mode 100644 hw/timer/avr_timer16.c create mode 100644 include/hw/char/avr_usart.h create mode 100644 include/hw/misc/avr_mask.h create mode 100644 include/hw/timer/avr_timer16.h create mode 100644 target/avr/Makefile.objs create mode 100644 target/avr/cpu-param.h create mode 100644 target/avr/cpu-qom.h create mode 100644 target/avr/cpu.c create mode 100644 target/avr/cpu.h create mode 100644 target/avr/gdbstub.c create mode 100644 target/avr/helper.c create mode 100644 target/avr/helper.h create mode 100644 target/avr/insn.decode create mode 100644 target/avr/machine.c create mode 100644 target/avr/translate.c create mode 100644 tests/acceptance/machine_avr6.py--
2.17.2 (Apple Git-113)
Hi Aleksandar.
I appreciate it.
Regards,
Michael
Quoted 337 lines · Aleksandar Markovic
Quoted 2 lines · Michael Rolnik
This series of patches adds 8bit AVR cores to QEMU.
Hi Michael,
I am going to take more detailed look at your series as soon as these hectic days around softfreeze/hardfreeze days pass. It is definitely a series that needed a lot of hard work, and it deserves to be seriously considered.
Yours, Aleksandar
Quoted 322 lines
All instruction, except BREAK/DES/SPM/SPMX, are implemented. Not fully tested yet. However I was able to execute simple code with functions. e.g fibonacci calculation. This series of patches include a non real, sample board.
No fuses support yet. PC is set to 0 at reset.the patches include the following
1. just a basic 8bit AVR CPU, without instruction decoding or translation
2. CPU features which allow define the following 8bit AVR coresavr1 avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 xmega2 xmega4 xmega5 xmega6 xmega73. a definition of sample machine with SRAM, FLASH and CPU which allows to execute simple code
4. encoding for all AVR instructions
5. interrupt handling
6. helpers for IN, OUT, SLEEP, WBR & unsupported instructions
7. a decoder which given an opcode decides what istruction it is
8. translation of AVR instruction into TCG
9. all features togetherchanges since v3
1. rampD/X/Y/Z registers are encoded as0x00ff0000(instead of0x000000ff) for faster address manipulaton
2. ffs changed to ctz32
3. duplicate code removed atavr_cpu_do_interrupt
4. using andc instead of not + and
5. fixing V flag calculation in varios instructions
6. freeing local variables in PUSH
7.tcg_const_local_i32->tcg_const_i32
8. using sextract32 instead of my implementation
9. fixing BLD instruction
10.xor(r) instead of0xff- r at COM
11.fixing MULS/MULSU not to modify inputs' content
12.using SUB for NEG
13.fixing tcg_gen_qemu_ld/st call in XCHchanges since v4
1. target is now defined as big endian in order to optimize push_ret/pop_ret
2. all style warnings are fixed
3. adding cpu_set/get_sreg functions
4. simplifyinggen_goto_tbas there is no real paging
5.env->pc->env->pc_w
6. making flag dump more compact
7. more spacing
8. renaming CODE/DATA_INDEX -> MMU_CODE/DATA_IDX
9. removingavr_set_feature
10. SPL/SPH set bug fix
11. switchingstb_phystocpu_stb_data
12. cleaning upavr_decode
13. saving sreg, rampD/X/Y/Z, eind in HW format (savevm)
14. saving CPU features (savevm)changes since v5
1. BLD bug fix
2. decoder generator is addedchages since v6
1. using cpu_get_sreg/cpu_set_sreg in avr_cpu_gdb_read_register/avr_cpu_gdb_write_register
2. configure the target as little endian because otherwise GDB does not work
3. fixing and testing gen_push_ret/gen_pop_retchanges since v7
1. folding back v6
2. logging athelper_outbandhelper_inbare done for non supported yet registers only
3.MAINTAINERSupdatedchanges since v8
1. removing hw/avr from hw/Makefile.obj as it should not be built for all
2. making linux compilable
3. testing ona. Mac, Apple LLVM version 7.0.0 b. Ubuntu 12.04, gcc 4.9.2 c. Fedora 23, gcc 5.3.14. folding back some patches
5. translation bug fixes for ORI, CPI, XOR instructions
6. propper handling of cpu register writes though memorychanges since v9
1. removing forward declarations of static functions
2. disabling debug prints
3. switching to case range instead of if else if ...
4. LD/ST IN/OUT accessing CPU maintainder registers are not routed to any device
5. commenst about sample board and sample IO device added
6. sample board description is more descriptive now
7.memory_region_allocate_system_memoryis used to create RAM
8. now there arehelper_fullrd&helper_fullwrwhen LD/ST try to access registerschanges since v10
1. movig back fullwr & fullrd into the commit where outb and inb were introduced
2. changingtlb_fillfunction signature
3. adding empty line between functions
4. adding newline on the last line of the file
5. usingtb->flagsto generae full access ST/LD instructions
6. fixing SBRC bug
7. folding back 10th commit
8. whenever a new file is introduced it's added to Makefile.objschanges since v11
1. updating to v2.7.0-rc
2. removing assignment toenv->fullaccfromgen_intermediate_codechanges since v12
1. fixing spacing
2. fixing get/put_segment functions
3. removingtarget-avr/machine.hfile
4.VMSTATE_SINGLE_TEST->VMSTATE_SINGLE
5. comment spelling
6. removinghw/avr/sample_io.c
7. char const* -> const char*
8. proper ram allocation
9. fixing breakpoint functionality.
10.env1 -> env
11.fixingavr_cpu_gdb_write_register&avr_cpu_gdb_read_registerfunctions 12.any cpu is removed
12.feature bits are not saved into vm statechanges since v13
1. rebasing to v2.7.0-rc1changes since v14
1. I made self review with git gui tool. (I did not know such a thing exists)
2. removing all double/tripple spaces
3. removing comment reference to SampleIO
4. folding back some changes, so there is not deleted lines in my code
5. moving avr configuration, within configure file, before chrischanges since v15
1. removing IO registers cache from CPU
2. implementing CBI/SBI asread(helper_inb), modify,write(helper_outb)
3. implementing CBIC/SBIC asread(helper_inb), check, branch
4. adding missingtcg_temp_free_i32fortcg_const_i32changes since v16
1. removing EXT IO registers knoledge from CPU. These registers are accessible by LD/ST only. CPU has no interest in themchanges since v17 (by Richard Henderson)
This is Michael's v17, with some adjustments of my own:1. Fix the whitespace errors reported by "git am",
2. Replace the utf-8 characters with normal ascii,
3. Ditch the separate compilation oftranslate.c.I retained the two separate files that could be regenerated from the included cpugen program, but merged in
translate-insn.c. Not that it matters, but the code generated is about 3k smaller.changes since v18
1. moving target-avr into target/avr 2. do not call cpu_exec_initfn function from avr_cpu_initfn 3. call cpu_exec_realizefn avr_cpu_realizefn 4. do not fail sample machine creation if no rom is suplied 5. add tcg_gen_exit_tb(0) for BS_BRANCH in gen_intermediate_code 6. fix a register getters/setters in machine.c 7. changing QEMU_ARCH_AVR from 1<<17 to 1<<18changes since v19
1. use decodetree.py tool to decode instructions 2. adding USART 3. adding 16 bit timer peripherals 4. changing QEMU_ARCH_AVR from 1<<18 to 1<<20 5. renaming tlb_fill to avr_cpu_tlb_fillchanges since v20
1. use one CPU naming convention 2. merging insn16.decode & insn32.decode files 3. modifying skip next instruction mechanizm 4. translate BREAK as NOP for nowchanges since v21
1. Reorganize bstate.
This will make transition to <exec/translator.h> easier, and fixes a couple of bugs wrt single stepping by [email protected]
2. Drop cpc and fix page cross condition.
by [email protected]
3. Refactor checking supported/unsupported instructions
4. Addgdb-xml/avr-cpu.xmlchanges since v22
1. Rebase
2. Split long commentchanges since v23
1. remove avr_cpu_list_compare function 2. modify avr_cpu_class_by_name function 3. modify avr_cpu_list_entry function 4. modify avr_cpu_list functionchanges since v24
1. removeAVR_CPU_TYPE_NAMEmacrochanges since v25
1. fix patches. every file belong to one patch only 2. change copyright year from 2016 to 2019 3. create mask device to emulate prr0/prr1changes since v26
1. add avocado acceptence test
2. add boot serial testchanges since v27
1. list atmel2560 devices as unimplemented
2. fix sram base/sizechanges since v28
1. rebase
2. fix includes & buildchanges since v29
1. fixing ownership
2. using 'since' instread of 'added in'changes since v30
1. rebasechanges since v31
1. splitting 'Add instruction translation' commit 2. fixing typo in qapi/machine.json sicne -> since 3. removing unintended changes in configure file 4. adding Richard Henderson as a co developer to 'Add instruction translation - CPU main translation funcions' commitchanges since v32
1. modifycpu_get_sregto treat sreg C as other flags, except sreg Zchanges since v33
1. ensure flag C is always calculated as one bit
2. calculate flag Z as one bit, without using inverse logicchanges since v34
1. rebaseMichael Rolnik (12):
target/avr: Add outward facing interfaces and core CPU logic target/avr: Add instruction helpers
target/avr: Add instruction decoding
target/avr: Add instruction translation - Registers definition target/avr: Add instruction translation - Arithmetic and Logic
Instructions
target/avr: Add instruction translation - Branch Instructions target/avr: Add instruction translation - Bit and Bit-test
Instructions
target/avr: Add instruction translation - MCU Control Instructions target/avr: Add instruction translation - CPU main translation
function
target/avr: Add example board configuration
target/avr: Register AVR support with the rest of QEMU, the build
system, and the WMAINTAINERS file
target/avr: Add testsSarah Harris (1):
target/avr: Add limited support for USART and 16 bit timer peripheralsMAINTAINERS | 9 + arch_init.c | 2 + configure | 7 + default-configs/avr-softmmu.mak | 5 + gdb-xml/avr-cpu.xml | 49 + hw/Kconfig | 1 + hw/avr/Kconfig | 6 + hw/avr/Makefile.objs | 1 + hw/avr/sample.c | 282 +++ hw/char/Kconfig | 3 + hw/char/Makefile.objs | 1 + hw/char/avr_usart.c | 324 ++++ hw/misc/Kconfig | 3 + hw/misc/Makefile.objs | 2 + hw/misc/avr_mask.c | 112 ++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 2 + hw/timer/avr_timer16.c | 605 ++++++ include/disas/dis-asm.h | 6 + include/hw/char/avr_usart.h | 97 + include/hw/misc/avr_mask.h | 47 + include/hw/timer/avr_timer16.h | 97 + include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 +- target/avr/Makefile.objs | 33 + target/avr/cpu-param.h | 37 + target/avr/cpu-qom.h | 54 + target/avr/cpu.c | 576 ++++++ target/avr/cpu.h | 253 +++ target/avr/gdbstub.c | 85 + target/avr/helper.c | 354 ++++ target/avr/helper.h | 29 + target/avr/insn.decode | 175 ++ target/avr/machine.c | 121 ++ target/avr/translate.c | 3028 ++++++++++++++++++++++++++++++ tests/Makefile.include | 2 + tests/acceptance/machine_avr6.py | 36 + tests/boot-serial-test.c | 10 + tests/machine-none-test.c | 1 + 39 files changed, 6461 insertions(+), 1 deletion(-) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 gdb-xml/avr-cpu.xml create mode 100644 hw/avr/Kconfig create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c create mode 100644 hw/char/avr_usart.c create mode 100644 hw/misc/avr_mask.c create mode 100644 hw/timer/avr_timer16.c create mode 100644 include/hw/char/avr_usart.h create mode 100644 include/hw/misc/avr_mask.h create mode 100644 include/hw/timer/avr_timer16.h create mode 100644 target/avr/Makefile.objs create mode 100644 target/avr/cpu-param.h create mode 100644 target/avr/cpu-qom.h create mode 100644 target/avr/cpu.c create mode 100644 target/avr/cpu.h create mode 100644 target/avr/gdbstub.c create mode 100644 target/avr/helper.c create mode 100644 target/avr/helper.h create mode 100644 target/avr/insn.decode create mode 100644 target/avr/machine.c create mode 100644 target/avr/translate.c create mode 100644 tests/acceptance/machine_avr6.py--
2.17.2 (Apple Git-113)
Signature · 2 lines
Best Regards, Michael Rolnik
Hi Michael, Joaquin.
Michael: Joaquin asked at the KVM Forum how he can start contributing to QEMU, having an electronic background, and being custom the the AVR microprocessor. I told him about your ongoing work. Joaquin is interested in adding a new board to QEMU, and the Arduino would be his board of choice.
Joaquin: This is the series I was tell you about. This series will likely be merged during the 5.0 development window. It lacks a real hardware model. Michael and Sarah didn't wrote one because they focus on the architecture part, which is enough for them (to test that AVR GCC).
See below for more comments about the codebase organization.
Quoted 23 lines · Michael Rolnik
This series of patches adds 8bit AVR cores to QEMU.
All instruction, except BREAK/DES/SPM/SPMX, are implemented. Not fully tested yet. However I was able to execute simple code with functions. e.g fibonacci calculation. This series of patches include a non real, sample board.
No fuses support yet. PC is set to 0 at reset.the patches include the following
1. just a basic 8bit AVR CPU, without instruction decoding or translation
2. CPU features which allow define the following 8bit AVR coresavr1 avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 xmega2 xmega4 xmega5 xmega6 xmega73. a definition of sample machine with SRAM, FLASH and CPU which allows to execute simple code
4. encoding for all AVR instructions
5. interrupt handling
6. helpers for IN, OUT, SLEEP, WBR & unsupported instructions
7. a decoder which given an opcode decides what istruction it is
8. translation of AVR instruction into TCG
9. all features together
[...]
Quoted 5 lines
MAINTAINERS | 9 + arch_init.c | 2 + configure | 7 + default-configs/avr-softmmu.mak | 5 + gdb-xml/avr-cpu.xml | 49 +
The part under hw/avr/ is the 'board' part.
You can take a AVR cpu, glue it with peripherals (mapping blocks and wiring IRQ), put it on a PCB ('board') and connect external devices.
You get a QEMU machine. You can load a ELF program directly to memory and execute it, or you can load a firmware from ROM/flash.
Quoted 10 lines
hw/Kconfig | 1 + > hw/avr/Kconfig | 6 + hw/avr/Makefile.objs | 1 + hw/avr/sample.c | 282 +++ hw/char/Kconfig | 3 + hw/char/Makefile.objs | 1 + hw/char/avr_usart.c | 324 ++++ hw/misc/Kconfig | 3 + hw/misc/Makefile.objs | 2 + hw/misc/avr_mask.c | 112 ++ hw/timer/Kconfig | 3 +
Quoted 8 lines
hw/timer/Makefile.objs | 2 + hw/timer/avr_timer16.c | 605 ++++++ include/disas/dis-asm.h | 6 + include/hw/char/avr_usart.h | 97 + include/hw/misc/avr_mask.h | 47 + include/hw/timer/avr_timer16.h | 97 + include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 +-
The files under target/avr/ are the architecture part.
Michael and Sarah run the GCC test suite on this, so this part should be quite correct and you shouldn't worry about looking here, except if some instruction behaves incorrectly. I strongly suggest you to stay focused with the files under hw/ and include/hw/.
Quoted 8 lines
target/avr/Makefile.objs | 33 + target/avr/cpu-param.h | 37 + target/avr/cpu-qom.h | 54 + target/avr/cpu.c | 576 ++++++ target/avr/cpu.h | 253 +++ target/avr/gdbstub.c | 85 + target/avr/helper.c | 354 ++++ target/avr/helper.h | 29 +
Quoted 8 lines
target/avr/insn.decode | 175 ++ target/avr/machine.c | 121 ++ target/avr/translate.c | 3028 ++++++++++++++++++++++++++++++ tests/Makefile.include | 2 + tests/acceptance/machine_avr6.py | 36 + tests/boot-serial-test.c | 10 + tests/machine-none-test.c | 1 + 39 files changed, 6461 insertions(+), 1 deletion(-)
Hope this helps a bit to start looking at QEMU.
You are welcome to ask any question on this list or on IRC.
Regards,
Phil.
Quoted 17 lines · Michael Rolnik
This series of patches adds 8bit AVR cores to QEMU.
All instruction, except BREAK/DES/SPM/SPMX, are implemented. Not fully tested yet. However I was able to execute simple code with functions. e.g fibonacci calculation. This series of patches include a non real, sample board.
No fuses support yet. PC is set to 0 at reset.the patches include the following
1. just a basic 8bit AVR CPU, without instruction decoding or translation
2. CPU features which allow define the following 8bit AVR coresavr1 avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 xmega2 xmega4 xmega5 xmega6 xmega7
Quoted 8 lines
3. a definition of sample machine with SRAM, FLASH and CPU which allows to execute simple code
4. encoding for all AVR instructions
5. interrupt handling
6. helpers for IN, OUT, SLEEP, WBR & unsupported instructions
7. a decoder which given an opcode decides what istruction it is
8. translation of AVR instruction into TCG
9. all features together
Hello Michael.
I noticed some imperfection in your patches: If your patch contains changes in, let's say, cpu.h and cpu.c files, your diff orders the chunks like this: first changes to cpu.c, and after that, cpu.h (sa, alphabetically), making the review of the patch a little unegronomic. Could you please run the script scrpits/git.orderfile in your dev directory, so that your git diffs are organized better?
Thanks,
Aleksandar
P.S. The entire script content:
#
# order file for git, to produce patches which are easier to review # by diffing the important stuff like interface changes first. # # one-off usage: # git diff -O scripts/git.orderfile ... # # add to git config: # git config diff.orderFile scripts/git.orderfile #
# Documentation
docs/*
*.texi
# build system configure Makefile* *.mak
# qapi schema qapi/*.json qga/*.json
# headers *.h
# code *.c
Quoted 298 lines
changes since v3
1. rampD/X/Y/Z registers are encoded as0x00ff0000(instead of0x000000ff) for faster address manipulaton
2. ffs changed to ctz32
3. duplicate code removed atavr_cpu_do_interrupt
4. using andc instead of not + and
5. fixing V flag calculation in varios instructions
6. freeing local variables in PUSH
7.tcg_const_local_i32->tcg_const_i32
8. using sextract32 instead of my implementation
9. fixing BLD instruction
10.xor(r) instead of0xff- r at COM
11.fixing MULS/MULSU not to modify inputs' content
12.using SUB for NEG
13.fixing tcg_gen_qemu_ld/st call in XCHchanges since v4
1. target is now defined as big endian in order to optimize push_ret/pop_ret
2. all style warnings are fixed
3. adding cpu_set/get_sreg functions
4. simplifyinggen_goto_tbas there is no real paging
5.env->pc->env->pc_w
6. making flag dump more compact
7. more spacing
8. renaming CODE/DATA_INDEX -> MMU_CODE/DATA_IDX
9. removingavr_set_feature
10. SPL/SPH set bug fix
11. switchingstb_phystocpu_stb_data
12. cleaning upavr_decode
13. saving sreg, rampD/X/Y/Z, eind in HW format (savevm)
14. saving CPU features (savevm)changes since v5
1. BLD bug fix
2. decoder generator is addedchages since v6
1. using cpu_get_sreg/cpu_set_sreg in avr_cpu_gdb_read_register/avr_cpu_gdb_write_register
2. configure the target as little endian because otherwise GDB does not work
3. fixing and testing gen_push_ret/gen_pop_retchanges since v7
1. folding back v6
2. logging athelper_outbandhelper_inbare done for non supported yet registers only
3.MAINTAINERSupdatedchanges since v8
1. removing hw/avr from hw/Makefile.obj as it should not be built for all
2. making linux compilable
3. testing ona. Mac, Apple LLVM version 7.0.0 b. Ubuntu 12.04, gcc 4.9.2 c. Fedora 23, gcc 5.3.14. folding back some patches
5. translation bug fixes for ORI, CPI, XOR instructions
6. propper handling of cpu register writes though memorychanges since v9
1. removing forward declarations of static functions
2. disabling debug prints
3. switching to case range instead of if else if ...
4. LD/ST IN/OUT accessing CPU maintainder registers are not routed to any device
5. commenst about sample board and sample IO device added
6. sample board description is more descriptive now
7.memory_region_allocate_system_memoryis used to create RAM
8. now there arehelper_fullrd&helper_fullwrwhen LD/ST try to access registerschanges since v10
1. movig back fullwr & fullrd into the commit where outb and inb were introduced
2. changingtlb_fillfunction signature
3. adding empty line between functions
4. adding newline on the last line of the file
5. usingtb->flagsto generae full access ST/LD instructions
6. fixing SBRC bug
7. folding back 10th commit
8. whenever a new file is introduced it's added to Makefile.objschanges since v11
1. updating to v2.7.0-rc
2. removing assignment toenv->fullaccfromgen_intermediate_codechanges since v12
1. fixing spacing
2. fixing get/put_segment functions
3. removingtarget-avr/machine.hfile
4.VMSTATE_SINGLE_TEST->VMSTATE_SINGLE
5. comment spelling
6. removinghw/avr/sample_io.c
7. char const* -> const char*
8. proper ram allocation
9. fixing breakpoint functionality.
10.env1 -> env
11.fixingavr_cpu_gdb_write_register&avr_cpu_gdb_read_registerfunctions 12.any cpu is removed
12.feature bits are not saved into vm statechanges since v13
1. rebasing to v2.7.0-rc1changes since v14
1. I made self review with git gui tool. (I did not know such a thing exists)
2. removing all double/tripple spaces
3. removing comment reference to SampleIO
4. folding back some changes, so there is not deleted lines in my code
5. moving avr configuration, within configure file, before chrischanges since v15
1. removing IO registers cache from CPU
2. implementing CBI/SBI asread(helper_inb), modify,write(helper_outb)
3. implementing CBIC/SBIC asread(helper_inb), check, branch
4. adding missingtcg_temp_free_i32fortcg_const_i32changes since v16
1. removing EXT IO registers knoledge from CPU. These registers are accessible by LD/ST only. CPU has no interest in themchanges since v17 (by Richard Henderson)
This is Michael's v17, with some adjustments of my own:1. Fix the whitespace errors reported by "git am",
2. Replace the utf-8 characters with normal ascii,
3. Ditch the separate compilation oftranslate.c.I retained the two separate files that could be regenerated from the included cpugen program, but merged in
translate-insn.c. Not that it matters, but the code generated is about 3k smaller.changes since v18
1. moving target-avr into target/avr 2. do not call cpu_exec_initfn function from avr_cpu_initfn 3. call cpu_exec_realizefn avr_cpu_realizefn 4. do not fail sample machine creation if no rom is suplied 5. add tcg_gen_exit_tb(0) for BS_BRANCH in gen_intermediate_code 6. fix a register getters/setters in machine.c 7. changing QEMU_ARCH_AVR from 1<<17 to 1<<18changes since v19
1. use decodetree.py tool to decode instructions 2. adding USART 3. adding 16 bit timer peripherals 4. changing QEMU_ARCH_AVR from 1<<18 to 1<<20 5. renaming tlb_fill to avr_cpu_tlb_fillchanges since v20
1. use one CPU naming convention 2. merging insn16.decode & insn32.decode files 3. modifying skip next instruction mechanizm 4. translate BREAK as NOP for nowchanges since v21
1. Reorganize bstate.
This will make transition to <exec/translator.h> easier, and fixes a couple of bugs wrt single stepping by [email protected]
2. Drop cpc and fix page cross condition.
by [email protected]
3. Refactor checking supported/unsupported instructions
4. Addgdb-xml/avr-cpu.xmlchanges since v22
1. Rebase
2. Split long commentchanges since v23
1. remove avr_cpu_list_compare function 2. modify avr_cpu_class_by_name function 3. modify avr_cpu_list_entry function 4. modify avr_cpu_list functionchanges since v24
1. removeAVR_CPU_TYPE_NAMEmacrochanges since v25
1. fix patches. every file belong to one patch only 2. change copyright year from 2016 to 2019 3. create mask device to emulate prr0/prr1changes since v26
1. add avocado acceptence test
2. add boot serial testchanges since v27
1. list atmel2560 devices as unimplemented
2. fix sram base/sizechanges since v28
1. rebase
2. fix includes & buildchanges since v29
1. fixing ownership
2. using 'since' instread of 'added in'changes since v30
1. rebasechanges since v31
1. splitting 'Add instruction translation' commit 2. fixing typo in qapi/machine.json sicne -> since 3. removing unintended changes in configure file 4. adding Richard Henderson as a co developer to 'Add instruction translation - CPU main translation funcions' commitchanges since v32
1. modifycpu_get_sregto treat sreg C as other flags, except sreg Zchanges since v33
1. ensure flag C is always calculated as one bit
2. calculate flag Z as one bit, without using inverse logicchanges since v34
1. rebaseMichael Rolnik (12):
target/avr: Add outward facing interfaces and core CPU logic target/avr: Add instruction helpers
target/avr: Add instruction decoding
target/avr: Add instruction translation - Registers definition target/avr: Add instruction translation - Arithmetic and Logic
Instructions
target/avr: Add instruction translation - Branch Instructions target/avr: Add instruction translation - Bit and Bit-test
Instructions
target/avr: Add instruction translation - MCU Control Instructions target/avr: Add instruction translation - CPU main translation
function
target/avr: Add example board configuration
target/avr: Register AVR support with the rest of QEMU, the build
system, and the WMAINTAINERS file
target/avr: Add testsSarah Harris (1):
target/avr: Add limited support for USART and 16 bit timer peripheralsMAINTAINERS | 9 + arch_init.c | 2 + configure | 7 + default-configs/avr-softmmu.mak | 5 + gdb-xml/avr-cpu.xml | 49 + hw/Kconfig | 1 + hw/avr/Kconfig | 6 + hw/avr/Makefile.objs | 1 + hw/avr/sample.c | 282 +++ hw/char/Kconfig | 3 + hw/char/Makefile.objs | 1 + hw/char/avr_usart.c | 324 ++++ hw/misc/Kconfig | 3 + hw/misc/Makefile.objs | 2 + hw/misc/avr_mask.c | 112 ++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 2 + hw/timer/avr_timer16.c | 605 ++++++ include/disas/dis-asm.h | 6 + include/hw/char/avr_usart.h | 97 + include/hw/misc/avr_mask.h | 47 + include/hw/timer/avr_timer16.h | 97 + include/sysemu/arch_init.h | 1 + qapi/machine.json | 3 +- target/avr/Makefile.objs | 33 + target/avr/cpu-param.h | 37 + target/avr/cpu-qom.h | 54 + target/avr/cpu.c | 576 ++++++ target/avr/cpu.h | 253 +++ target/avr/gdbstub.c | 85 + target/avr/helper.c | 354 ++++ target/avr/helper.h | 29 + target/avr/insn.decode | 175 ++ target/avr/machine.c | 121 ++ target/avr/translate.c | 3028 ++++++++++++++++++++++++++++++ tests/Makefile.include | 2 + tests/acceptance/machine_avr6.py | 36 + tests/boot-serial-test.c | 10 + tests/machine-none-test.c | 1 + 39 files changed, 6461 insertions(+), 1 deletion(-) create mode 100644 default-configs/avr-softmmu.mak create mode 100644 gdb-xml/avr-cpu.xml create mode 100644 hw/avr/Kconfig create mode 100644 hw/avr/Makefile.objs create mode 100644 hw/avr/sample.c create mode 100644 hw/char/avr_usart.c create mode 100644 hw/misc/avr_mask.c create mode 100644 hw/timer/avr_timer16.c create mode 100644 include/hw/char/avr_usart.h create mode 100644 include/hw/misc/avr_mask.h create mode 100644 include/hw/timer/avr_timer16.h create mode 100644 target/avr/Makefile.objs create mode 100644 target/avr/cpu-param.h create mode 100644 target/avr/cpu-qom.h create mode 100644 target/avr/cpu.c create mode 100644 target/avr/cpu.h create mode 100644 target/avr/gdbstub.c create mode 100644 target/avr/helper.c create mode 100644 target/avr/helper.h create mode 100644 target/avr/insn.decode create mode 100644 target/avr/machine.c create mode 100644 target/avr/translate.c create mode 100644 tests/acceptance/machine_avr6.py--
2.17.2 (Apple Git-113)