On Mon, 2012-06-18 at 19:59 +0000, Blue Swirl wrote:
[snip]
> > +
> > +#define PUV3_DMA_CH_NR (6)
> > +#define PUV3_DMA_CH_MASK (0xff)
> > +#define PUV3_DMA_CH(offset) ((offset) >> 8)
> > +
> > +typedef struct {
> > + SysBusDevice busdev;
> > + MemoryRegion iomem;
> > + uint32_t reg_CFG[PUV3_DMA_CH_NR];
> > +} PUV3DMAState;
> > +
> > +static uint64_t puv3_dma_read(void *opaque, target_phys_addr_t offset,
> > + unsigned size)
> > +{
> > + PUV3DMAState *s = (PUV3DMAState *) opaque;
>
> These casts from void pointer are not needed in C.
I see. Thanks.
> > + uint32_t ret;
> > +
> > + assert(PUV3_DMA_CH(offset) < PUV3_DMA_CH_NR);
> > +
> > + switch (offset & PUV3_DMA_CH_MASK) {
> > + case 0x10:
> > + ret = s->reg_CFG[PUV3_DMA_CH(offset)];
> > + break;
> > + default:
> > + hw_error("%s: Bad offset 0x%x\n", __func__, offset);
>
> hw_error() also aborts, it would be nice to avoid that. However, the
> situation is somewhat different from the instruction case, since only
> privileged guest code (kernel) can write to hardware. The kernel can
> also for example power off the machine.
It's the same problem as cpu_abort. Warning information is enough here.
Is there a global and simple way to do it, g_warning()?
Guan Xuetao