qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V2 04/10] qemu-clk: introduce an init array to h


From: Cédric Le Goater
Subject: Re: [Qemu-devel] [PATCH V2 04/10] qemu-clk: introduce an init array to help the device construction
Date: Mon, 6 Feb 2017 17:02:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

On 01/26/2017 10:47 AM, address@hidden wrote:
> From: KONRAD Frederic <address@hidden>
> 
> This introduces a clock init array to ease the clock tree construction.

I think this belongs to the zynqmp-crf model.

Thanks,

C. 

 
> 
> Signed-off-by: KONRAD Frederic <address@hidden>
> ---
>  include/qemu/qemu-clock.h | 23 +++++++++++++++++++++++
>  qemu-clock.c              | 17 +++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/include/qemu/qemu-clock.h b/include/qemu/qemu-clock.h
> index 6d30299..45f8766 100644
> --- a/include/qemu/qemu-clock.h
> +++ b/include/qemu/qemu-clock.h
> @@ -49,6 +49,29 @@ struct ClkList {
>      QLIST_ENTRY(ClkList) node;
>  };
>  
> +typedef struct ClockInitElement {
> +    const char *name;      /* Name to give to the clock. */
> +    size_t offset;         /* Offset of the qemu_clk field in the object. */
> +    QEMUClkRateUpdateCallback *cb;
> +} ClockInitElement;
> +
> +#define DEVICE_CLOCK(_state, _field, _cb) {                                  
> \
> +    .name = #_field,                                                         
> \
> +    .offset = offsetof(_state, _field),                                      
> \
> +    .cb = _cb                                                                
> \
> +}
> +
> +#define DEVICE_CLOCK_END() {                                                 
> \
> +    .name = NULL                                                             
> \
> +}
> +
> +/**
> + * qemu_clk_init_device:
> + * @obj: the Object which need to be initialized.
> + * @array: the array of ClockInitElement to be used.
> + */
> +void qemu_clk_init_device(Object *obj, ClockInitElement *array);
> +
>  /**
>   * qemu_clk_device_add_clock:
>   * @dev: the device on which the clock needs to be added.
> diff --git a/qemu-clock.c b/qemu-clock.c
> index 8c12368..300e38f 100644
> --- a/qemu-clock.c
> +++ b/qemu-clock.c
> @@ -26,6 +26,7 @@
>  #include "hw/hw.h"
>  #include "qemu/log.h"
>  #include "qapi/error.h"
> +#include "hw/qdev-core.h"
>  
>  #ifndef DEBUG_QEMU_CLOCK
>  #define DEBUG_QEMU_CLOCK 0
> @@ -37,6 +38,22 @@
>      }                                                                        
> \
>  } while (0);
>  
> +void qemu_clk_init_device(Object *obj, ClockInitElement *array)
> +{
> +    qemu_clk *cur = NULL;
> +
> +    while (array->name != NULL) {
> +        DPRINTF("init clock named %s\n", array->name);
> +        cur = (((void *)obj) + array->offset);
> +        *cur = QEMU_CLOCK(object_new(TYPE_CLOCK));
> +        qemu_clk_device_add_clock(DEVICE(obj), *cur, array->name);
> +        if (array->cb) {
> +            qemu_clk_set_callback(*cur, array->cb, obj);
> +        }
> +        array++;
> +    }
> +}
> +
>  void qemu_clk_refresh(qemu_clk clk)
>  {
>      qemu_clk_update_rate(clk, clk->in_rate);
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]