Trivial patches, mostly PC-related
cover Trivial patches, mostly PC-related
This series mostly contains PC-related patches I came up with when doing "virtual retrocomputing" on my via-apollo-pro-133t branch [1] which includes improved tracing and type safety. The remaining patch resolves duplicate code in the test of DS1338 RTC which is used in e500 machines.
[1] https://github.com/shentok/qemu/tree/via-apollo-pro-133t
Bernhard Beschow (8):
hw/timer/i8254: Add I/O trace events hw/audio/pcspk: Add I/O trace events hw/rtc/mc146818rtc: Convert CMOS_DPRINTF() into trace events hw/rtc/mc146818rtc: Use ARRAY_SIZE macro hw/rtc/mc146818rtc: Assert correct usage of
mc146818rtc_set_cmos_data()
hw/i386/apic: Prefer APICCommonState over DeviceState hw/ide/ide-internal: Move dma_buf_commit() into ide "namespace" tests/qtest/ds1338-test: Reuse from_bcd()
hw/ide/ide-internal.h | 2 +- include/hw/i386/apic.h | 33 +++++------ include/hw/i386/apic_internal.h | 7 +-- target/i386/cpu.h | 4 +- target/i386/kvm/kvm_i386.h | 2 +- target/i386/whpx/whpx-internal.h | 2 +- hw/audio/pcspk.c | 10 +++- hw/i386/kvm/apic.c | 3 +- hw/i386/vapic.c | 2 +- hw/i386/x86-cpu.c | 2 +- hw/ide/ahci.c | 8 +-- hw/ide/core.c | 10 ++-- hw/intc/apic.c | 97 +++++++++++++------------------- hw/intc/apic_common.c | 56 +++++++----------- hw/rtc/mc146818rtc.c | 20 ++----- hw/timer/i8254.c | 6 ++ target/i386/cpu-apic.c | 4 +- target/i386/cpu.c | 2 +- target/i386/kvm/kvm.c | 2 +- target/i386/whpx/whpx-apic.c | 3 +- tests/qtest/ds1338-test.c | 12 ++-- hw/audio/trace-events | 4 ++ hw/rtc/trace-events | 4 ++ hw/timer/trace-events | 4 ++ 24 files changed, 136 insertions(+), 163 deletions(-)
Signature · 1 line
2.51.1.dirty
PATCH 1/8 hw/timer/i8254: Add I/O trace events
Allows to see how the guest interacts with the device.
--- hw/timer/i8254.c | 6 ++++++ hw/timer/trace-events | 4 ++++ 2 files changed, 10 insertions(+)
hw/timer/i8254.c +6 -0
@@ -29,6 +29,7 @@#include "hw/timer/i8254.h" #include "hw/timer/i8254_internal.h" #include "qom/object.h" +#include "trace.h" //#define DEBUG_PIT
@@ -130,6 +131,8 @@ static void pit_ioport_write(void *opaque, hwaddr addr,int channel, access;PITChannelState *s; +trace_pit_ioport_write (addr, val); + addr &=3 ;if (addr ==3 ) { channel = val >>6 ;
@@ -248,6 +251,9 @@ static uint64_t pit_ioport_read(void *opaque, hwaddr addr,break ; } } + +trace_pit_ioport_read (addr, ret); +return ret; }
hw/timer/trace-events +4 -0
@@ -49,6 +49,10 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" +# i8254.c +pit_ioport_read(uint8_t addr, uint32_t value) "[0x%" PRIx8 "] -> 0x%" PRIx32 +pit_ioport_write(uint8_t addr, uint32_t value) "[0x%" PRIx8 "] <- 0x%" PRIx32 + # imx_gpt.c imx_gpt_set_freq(uint32_t clksrc, uint32_t freq) "Setting clksrc %u to %u Hz" imx_gpt_read(const char *name, uint64_t value) "%s -> 0x%08" PRIx64
Signature · 1 line
2.51.1.dirty
PATCH 2/8 hw/audio/pcspk: Add I/O trace events
In reply to Bernhard BeschowAllows to see how the guest interacts with the device.
--- hw/audio/pcspk.c | 10 +++++++++- hw/audio/trace-events | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-)
hw/audio/pcspk.c +9 -1
@@ -34,6 +34,7 @@#include "hw/audio/pcspk.h" #include "qapi/error.h" #include "qom/object.h" +#include "trace.h" #define PCSPK_BUF_LEN 1792#define PCSPK_SAMPLE_RATE 32000
@@ -137,13 +138,18 @@ static uint64_t pcspk_io_read(void *opaque, hwaddr addr, {PCSpkState *s = opaque;PITChannelInfo ch; +uint8_t val;pit_get_channel_info (s->pit,2 , &ch); s->dummy_refresh_clock ^= (1 <<4 ); -return ch.gate | (s->data_on <<1 ) | s->dummy_refresh_clock | + val = ch.gate | (s->data_on <<1 ) | s->dummy_refresh_clock | (ch.out <<5 ); + +trace_pcspk_io_read (s->iobase, val); + +return val; } static void pcspk_io_write(void *opaque, hwaddr addr, uint64_t val,
@@ -152,6 +158,8 @@ static void pcspk_io_write(void *opaque, hwaddr addr, uint64_t val,PCSpkState *s = opaque;const int gate = val &1 ; +trace_pcspk_io_write (s->iobase, val); + s->data_on = (val >>1 ) &1 ;pit_set_gate (s->pit,2 , gate);if (s->voice) {
hw/audio/trace-events +4 -0
@@ -23,6 +23,10 @@ hda_audio_format(const char *stream, int chan, const char *fmt, int freq) "st %s hda_audio_adjust(const char *stream, int pos) "st %s, pos %d" hda_audio_overrun(const char *stream) "st %s" +# pcspk.c +pcspk_io_read(uint16_t addr, uint8_t val) "[0x%"PRIx16"] -> 0x%"PRIx8 +pcspk_io_write(uint16_t addr, uint8_t val) "[0x%"PRIx16"] <- 0x%"PRIx8 + #via-ac97.c via_ac97_codec_write(uint8_t addr, uint16_t val) "0x%x <- 0x%x" via_ac97_sgd_fetch(uint32_t curr, uint32_t addr, char stop, char eol, char flag, uint32_t len) "curr=0x%x addr=0x%x %c%c%c len=%d"
Signature · 1 line
2.51.1.dirty
PATCH 3/8 hw/rtc/mc146818rtc: Convert CMOS_DPRINTF() into trace events
In reply to Bernhard Beschow--- hw/rtc/mc146818rtc.c | 14 +++----------- hw/rtc/trace-events | 4 ++++ 2 files changed, 7 insertions(+), 11 deletions(-)
hw/rtc/mc146818rtc.c +3 -11
@@ -43,16 +43,10 @@#include "qapi/error.h" #include "qapi/qapi-events-misc.h" #include "qapi/visitor.h" +#include "trace.h" -//#define DEBUG_CMOS //#define DEBUG_COALESCED -#ifdef DEBUG_CMOS -# define CMOS_DPRINTF (format, ...) printf(format, ## __VA_ARGS__) -#else -# define CMOS_DPRINTF (format, ...) do { } while (0) -#endif -#ifdef DEBUG_COALESCED # define DPRINTF_C (format, ...) printf(format, ## __VA_ARGS__)#else
@@ -439,8 +433,7 @@ static void cmos_ioport_write(void *opaque, hwaddr addr,if ((addr &1 ) ==0 ) { s->cmos_index = data &0x7f ; }else { -CMOS_DPRINTF ("cmos: write index=0x%02x val=0x%02" PRIx64"\n" , - s->cmos_index, data); +trace_mc146818_rtc_ioport_write (s->cmos_index, data);switch (s->cmos_index) {case RTC_SECONDS_ALARM :case RTC_MINUTES_ALARM :
@@ -726,8 +719,7 @@ static uint64_t cmos_ioport_read(void *opaque, hwaddr addr, ret = s->cmos_data[s->cmos_index];break ; } -CMOS_DPRINTF ("cmos: read index=0x%02x val=0x%02x\n" , - s->cmos_index, ret); +trace_mc146818_rtc_ioport_read (s->cmos_index, ret);return ret; } }
hw/rtc/trace-events +4 -0
@@ -32,6 +32,10 @@ m48txx_nvram_io_write(uint64_t addr, uint64_t value) "io write addr:0x%04" PRIx6 m48txx_nvram_mem_read(uint32_t addr, uint32_t value) "mem read addr:0x%04x value:0x%02x" m48txx_nvram_mem_write(uint32_t addr, uint32_t value) "mem write addr:0x%04x value:0x%02x" +# mc146818rtc.c +mc146818_rtc_ioport_read(uint8_t addr, uint8_t value) "[0x%02" PRIx8 "] -> 0x%02" PRIx8 +mc146818_rtc_ioport_write(uint8_t addr, uint8_t value) "[0x%02" PRIx8 "] <- 0x%02" PRIx8 + # goldfish_rtc.c goldfish_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 goldfish_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
Signature · 1 line
2.51.1.dirty
PATCH 4/8 hw/rtc/mc146818rtc: Use ARRAY_SIZE macro
In reply to Bernhard BeschowAvoids the error-prone repetition of the array size.
--- hw/rtc/mc146818rtc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/rtc/mc146818rtc.c +3 -2
@@ -726,13 +726,14 @@ static uint64_t cmos_ioport_read(void *opaque, hwaddr addr,void mc146818rtc_set_cmos_data (MC146818RtcState *s,int addr,int val) { -if (addr >=0 && addr <=127 ) +if (addr >=0 && addr <ARRAY_SIZE (s->cmos_data)) { s->cmos_data[addr] = val; + } }int mc146818rtc_get_cmos_data (MC146818RtcState *s,int addr) { -assert (addr >=0 && addr <=127 ); +assert (addr >=0 && addr <ARRAY_SIZE (s->cmos_data));return s->cmos_data[addr]; }
Signature · 1 line
2.51.1.dirty
PATCH 5/8 hw/rtc/mc146818rtc: Assert correct usage of mc146818rtc_set_cmos_data()
In reply to Bernhard BeschowThe offset is never controlled by the guest, so any misuse constitutes a programming error and shouldn't be silently ignored. Fix this by using assert().
--- hw/rtc/mc146818rtc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/rtc/mc146818rtc.c +2 -3
@@ -726,9 +726,8 @@ static uint64_t cmos_ioport_read(void *opaque, hwaddr addr,void mc146818rtc_set_cmos_data (MC146818RtcState *s,int addr,int val) { -if (addr >=0 && addr <ARRAY_SIZE (s->cmos_data)) { - s->cmos_data[addr] = val; - } +assert (addr >=0 && addr <ARRAY_SIZE (s->cmos_data)); + s->cmos_data[addr] = val; }int mc146818rtc_get_cmos_data (MC146818RtcState *s,int addr)
Signature · 1 line
2.51.1.dirty
PATCH 6/8 hw/i386/apic: Prefer APICCommonState over DeviceState
In reply to Bernhard BeschowMakes the APIC API more type-safe by resolving quite a few APIC_COMMON downcasts.
Like PICCommonState, the APICCommonState is now a public typedef while staying an abstract datatype.
--- include/hw/i386/apic.h | 33 +++++------ include/hw/i386/apic_internal.h | 7 +-- target/i386/cpu.h | 4 +- target/i386/kvm/kvm_i386.h | 2 +- target/i386/whpx/whpx-internal.h | 2 +- hw/i386/kvm/apic.c | 3 +- hw/i386/vapic.c | 2 +- hw/i386/x86-cpu.c | 2 +- hw/intc/apic.c | 97 +++++++++++++------------------- hw/intc/apic_common.c | 56 +++++++----------- target/i386/cpu-apic.c | 4 +- target/i386/cpu.c | 2 +- target/i386/kvm/kvm.c | 2 +- target/i386/whpx/whpx-apic.c | 3 +- 14 files changed, 89 insertions(+), 130 deletions(-)
include/hw/i386/apic.h +17 -16
@@ -1,28 +1,29 @@#ifndef APIC_H #define APIC_H +typedef struct APICCommonState APICCommonState ;/* apic.c */ void apic_set_max_apic_id (uint32_t max_apic_id); -int apic_accept_pic_intr (DeviceState *s); -void apic_deliver_pic_intr (DeviceState *s,int level); -void apic_deliver_nmi (DeviceState *d); -int apic_get_interrupt (DeviceState *s); -int cpu_set_apic_base (DeviceState *s,uint64_t val); -uint64_t cpu_get_apic_base (DeviceState *s); -bool cpu_is_apic_enabled (DeviceState *s); -void cpu_set_apic_tpr (DeviceState *s,uint8_t val); -uint8_t cpu_get_apic_tpr (DeviceState *s); -void apic_init_reset (DeviceState *s); -void apic_sipi (DeviceState *s); -void apic_poll_irq (DeviceState *d); -void apic_designate_bsp (DeviceState *d,bool bsp); -int apic_get_highest_priority_irr (DeviceState *dev); +int apic_accept_pic_intr (APICCommonState *s); +void apic_deliver_pic_intr (APICCommonState *s,int level); +void apic_deliver_nmi (APICCommonState *s); +int apic_get_interrupt (APICCommonState *s); +int cpu_set_apic_base (APICCommonState *s,uint64_t val); +uint64_t cpu_get_apic_base (APICCommonState *s); +bool cpu_is_apic_enabled (APICCommonState *s); +void cpu_set_apic_tpr (APICCommonState *s,uint8_t val); +uint8_t cpu_get_apic_tpr (APICCommonState *s); +void apic_init_reset (APICCommonState *s); +void apic_sipi (APICCommonState *s); +void apic_poll_irq (APICCommonState *s); +void apic_designate_bsp (APICCommonState *s,bool bsp); +int apic_get_highest_priority_irr (APICCommonState *s);int apic_msr_read (int index,uint64_t *val);int apic_msr_write (int index,uint64_t val); -bool is_x2apic_mode (DeviceState *d); +bool is_x2apic_mode (APICCommonState *s);/* pc.c */ -DeviceState *cpu_get_current_apic (void ); +APICCommonState *cpu_get_current_apic (void );#endif
include/hw/i386/apic_internal.h +3 -4
@@ -22,6 +22,7 @@#define QEMU_APIC_INTERNAL_H #include "cpu.h" +#include "hw/i386/apic.h" #include "system/memory.h" #include "qemu/timer.h" #include "target/i386/cpu-qom.h"
@@ -125,8 +126,6 @@#define VAPIC_ENABLE_BIT 0#define VAPIC_ENABLE_MASK (1 << VAPIC_ENABLE_BIT) -typedef struct APICCommonState APICCommonState ; -#define TYPE_APIC_COMMON "apic-common"typedef struct APICCommonClass APICCommonClass ; DECLARE_OBJ_CHECKERS(APICCommonState, APICCommonClass,
@@ -203,8 +202,8 @@ typedef struct VAPICState {extern bool apic_report_tpr_access;bool apic_next_timer (APICCommonState *s,int64_t current_time); -void apic_enable_tpr_access_reporting (DeviceState *d,bool enable); -void apic_enable_vapic (DeviceState *d,hwaddr paddr); +void apic_enable_tpr_access_reporting (APICCommonState *s,bool enable); +void apic_enable_vapic (APICCommonState *s,hwaddr paddr);void vapic_report_tpr_access (DeviceState *dev,CPUState *cpu,target_ulong ip,TPRAccess access);
target/i386/cpu.h +2 -2
@@ -2349,7 +2349,7 @@ struct ArchCPU {/* in order to simplify APIC support, we leave this pointer to the user */ -struct DeviceState *apic_state; +struct APICCommonState *apic_state;struct MemoryRegion *cpu_as_root, *cpu_as_mem, *smram;Notifier machine_done;
@@ -2830,7 +2830,7 @@ bool cpu_svm_has_intercept(CPUX86State *env, uint32_t type);/* apic.c */ void cpu_report_tpr_access (CPUX86State *env,TPRAccess access); -void apic_handle_tpr_access_report (DeviceState *d,target_ulong ip, +void apic_handle_tpr_access_report (APICCommonState *s,target_ulong ip,TPRAccess access);/* Special values for X86CPUVersion: */
target/i386/kvm/kvm_i386.h +1 -1
@@ -56,7 +56,7 @@ bool kvm_has_adjust_clock_stable(void);bool kvm_has_exception_payload (void );void kvm_synchronize_all_tsc (void ); -void kvm_get_apic_state (DeviceState *d,struct kvm_lapic_state *kapic); +void kvm_get_apic_state (APICCommonState *s,struct kvm_lapic_state *kapic);void kvm_put_apicbase (X86CPU *cpu,uint64_t value);bool kvm_has_x2apic_api (void );
target/i386/whpx/whpx-internal.h +1 -1
@@ -44,7 +44,7 @@ struct whpx_state { };extern struct whpx_state whpx_global; -void whpx_apic_get (DeviceState *s); +void whpx_apic_get (struct APICCommonState *s);#define WHV_E_UNKNOWN_CAPABILITY 0x80370300L
hw/i386/kvm/apic.c +1 -2
@@ -60,9 +60,8 @@ static void kvm_put_apic_state(APICCommonState *s, struct kvm_lapic_state *kapickvm_apic_set_reg (kapic,0x3e , s->divide_conf); } -void kvm_get_apic_state (DeviceState *dev,struct kvm_lapic_state *kapic) +void kvm_get_apic_state (APICCommonState *s,struct kvm_lapic_state *kapic) { -APICCommonState *s =APIC_COMMON (dev);int i, v;if (kvm_has_x2apic_api () && s->apicbase &MSR_IA32_APICBASE_EXTD ) {
hw/i386/vapic.c +1 -1
@@ -490,7 +490,7 @@ void vapic_report_tpr_access(DeviceState *dev, CPUState *cs, target_ulong ip, }typedef struct VAPICEnableTPRReporting { -DeviceState *apic; +APICCommonState *apic;bool enable; }VAPICEnableTPRReporting ;
hw/i386/x86-cpu.c +1 -1
@@ -86,7 +86,7 @@ int cpu_get_pic_interrupt(CPUX86State *env)return intno; } -DeviceState *cpu_get_current_apic (void ) +APICCommonState *cpu_get_current_apic (void ) {if (current_cpu) {X86CPU *cpu =X86_CPU (current_cpu);
hw/intc/apic.c +38 -59
293 lines not on this page · raw message
hw/intc/apic_common.c +19 -37
155 lines not on this page · raw message
target/i386/cpu-apic.c +2 -2
@@ -48,7 +48,7 @@ void x86_cpu_apic_create(X86CPU *cpu, Error **errp)return ; } - cpu->apic_state =DEVICE (object_new_with_class (OBJECT_CLASS (apic_class))); + cpu->apic_state =APIC_COMMON (object_new_with_class (OBJECT_CLASS (apic_class)));object_property_add_child (OBJECT (cpu),"lapic" ,OBJECT (cpu->apic_state));object_unref (OBJECT (cpu->apic_state));
@@ -63,7 +63,7 @@ void x86_cpu_apic_create(X86CPU *cpu, Error **errp)* feature in case APIC ID >= 255, so we need to set apic->cpu * before setting APIC ID */ -qdev_prop_set_uint32 (cpu->apic_state,"id" , cpu->apic_id); +qdev_prop_set_uint32 (DEVICE (cpu->apic_state),"id" , cpu->apic_id); }void x86_cpu_apic_realize (X86CPU *cpu,Error **errp)
target/i386/cpu.c +1 -1
@@ -8789,7 +8789,7 @@ void x86_cpu_after_reset(X86CPU *cpu) }if (cpu->apic_state) { -device_cold_reset (cpu->apic_state); +device_cold_reset (DEVICE (cpu->apic_state)); }#endif }
target/i386/kvm/kvm.c +1 -1
@@ -5029,7 +5029,7 @@ static int kvm_get_mp_state(X86CPU *cpu)static int kvm_get_apic (X86CPU *cpu) { -DeviceState *apic = cpu->apic_state; +APICCommonState *apic = cpu->apic_state;struct kvm_lapic_state kapic;int ret;
target/i386/whpx/whpx-apic.c +1 -2
@@ -151,9 +151,8 @@ static void whpx_apic_put(CPUState *cs, run_on_cpu_data data) } } -void whpx_apic_get (DeviceState *dev) +void whpx_apic_get (APICCommonState *s) { -APICCommonState *s =APIC_COMMON (dev);CPUState *cpu =CPU (s->cpu);struct whpx_lapic_state kapic;
Signature · 1 line
2.51.1.dirty
PATCH 7/8 hw/ide/ide-internal: Move dma_buf_commit() into ide "namespace"
In reply to Bernhard BeschowThe identifier suggests that it is a generic DMA function while it is tied to IDE. Fix this by adding an "ide_" prefix.
--- hw/ide/ide-internal.h | 2 +- hw/ide/ahci.c | 8 ++++---- hw/ide/core.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-)
hw/ide/ide-internal.h +1 -1
@@ -398,7 +398,7 @@ int64_t ide_get_sector(IDEState *s);void ide_set_sector (IDEState *s,int64_t sector_num);void ide_start_dma (IDEState *s,BlockCompletionFunc *cb); -void dma_buf_commit (IDEState *s,uint32_t tx_bytes); +void ide_dma_buf_commit (IDEState *s,uint32_t tx_bytes);void ide_dma_error (IDEState *s);void ide_abort_command (IDEState *s);
hw/ide/ahci.c +4 -4
@@ -1417,7 +1417,7 @@ static void ahci_pio_transfer(const IDEDMA *dma) }/* Update number of transferred bytes, destroy sglist */ -dma_buf_commit (s, size); +ide_dma_buf_commit (s, size); out:/* declare that we processed everything */
@@ -1482,8 +1482,8 @@ static int32_t ahci_dma_prepare_buf(const IDEDMA *dma, int32_t limit)/** * Updates the command header with a bytes-read value. -* Called via dma_buf_commit, for both DMA and PIO paths. -* sglist destruction is handled within dma_buf_commit. +* Called via ide_dma_buf_commit, for both DMA and PIO paths. +* sglist destruction is handled within ide_dma_buf_commit. */ static void ahci_commit_buf (const IDEDMA *dma,uint32_t tx_bytes) {
@@ -1511,7 +1511,7 @@ static int ahci_dma_rw_buf(const IDEDMA *dma, bool is_write) }/* free sglist, update byte count */ -dma_buf_commit (s, l); +ide_dma_buf_commit (s, l); s->io_buffer_index += l;trace_ahci_dma_rw_buf (ad->hba, ad->port_no, l);
hw/ide/core.c +5 -5
@@ -827,7 +827,7 @@ static void ide_sector_read(IDEState *s) ide_sector_read_cb, s); } -void dma_buf_commit (IDEState *s,uint32_t tx_bytes) +void ide_dma_buf_commit (IDEState *s,uint32_t tx_bytes) {if (s->bus->dma->ops->commit_buf) { s->bus->dma->ops->commit_buf (s->bus->dma, tx_bytes);
@@ -848,7 +848,7 @@ void ide_set_inactive(IDEState *s, bool more)void ide_dma_error (IDEState *s) { -dma_buf_commit (s,0 ); +ide_dma_buf_commit (s,0 );ide_abort_command (s);ide_set_inactive (s, false);ide_bus_set_irq (s->bus);
@@ -893,7 +893,7 @@ static void ide_dma_cb(void *opaque, int ret)if (ret <0 ) {if (ide_handle_rw_error (s, -ret,ide_dma_cmd_to_retry (s->dma_cmd))) { s->bus->dma->aiocb =NULL ; -dma_buf_commit (s,0 ); +ide_dma_buf_commit (s,0 );return ; } }
@@ -912,7 +912,7 @@ static void ide_dma_cb(void *opaque, int ret) sector_num =ide_get_sector (s);if (n >0 ) {assert (n *512 == s->sg.size); -dma_buf_commit (s, s->sg.size); +ide_dma_buf_commit (s, s->sg.size); sector_num += n;ide_set_sector (s, sector_num); s->nsector -= n;
@@ -944,7 +944,7 @@ static void ide_dma_cb(void *opaque, int ret)* Reset the Active bit and don't raise the interrupt. */ s->status =READY_STAT |SEEK_STAT ; -dma_buf_commit (s,0 ); +ide_dma_buf_commit (s,0 ); goto eot; }
Signature · 1 line
2.51.1.dirty
PATCH 8/8 tests/qtest/ds1338-test: Reuse from_bcd()
In reply to Bernhard Beschowfrom_bcd() is a public API function which can be unit-tested. Reuse it to avoid code duplication.
--- tests/qtest/ds1338-test.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
tests/qtest/ds1338-test.c +4 -8
@@ -18,16 +18,12 @@*/ #include "qemu/osdep.h" +#include "qemu/bcd.h" #include "libqtest.h" #include "libqos/i2c.h" #define DS1338_ADDR 0x68 -static inline uint8_t bcd2bin (uint8_t x) -{ -return ((x) &0x0f ) + ((x) >>4 ) *10 ; -} -static void send_and_receive (void *obj,void *data,QGuestAllocator *alloc) {QI2CDevice *i2cdev = (QI2CDevice *)obj;
@@ -39,9 +35,9 @@ static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc)i2c_read_block (i2cdev,0 , resp,sizeof (resp));/* check retrieved time against local time */ - g_assert_cmpuint(bcd2bin(resp[4]), == , tm_ptr->tm_mday); - g_assert_cmpuint(bcd2bin(resp[5]), == , 1 + tm_ptr->tm_mon); - g_assert_cmpuint(2000 + bcd2bin(resp[6]), == , 1900 + tm_ptr->tm_year); + g_assert_cmpuint(from_bcd(resp[4]), == , tm_ptr->tm_mday); + g_assert_cmpuint(from_bcd(resp[5]), == , 1 + tm_ptr->tm_mon); + g_assert_cmpuint(2000 + from_bcd(resp[6]), == , 1900 + tm_ptr->tm_year); }static void ds1338_register_nodes (void )
Signature · 1 line
2.51.1.dirty
Re: [PATCH 8/8] tests/qtest/ds1338-test: Reuse from_bcd()
Quoted 4 lines · Bernhard Beschow
from_bcd()is a public API function which can be unit-tested. Reuse it to avoid code duplication.Signed-off-by Bernhard Beschow <[email protected]>