Received: from eggs.gnu.org ([208.118.235.92]:37838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShAOl-0005mo-Tg for qemu-devel@nongnu.org; Tue, 19 Jun 2012 22:12:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ShAOk-0004wi-9e for qemu-devel@nongnu.org; Tue, 19 Jun 2012 22:11:59 -0400 Received: from mprc.pku.edu.cn ([162.105.203.9]:59938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShAOj-0004wM-Fu for qemu-devel@nongnu.org; Tue, 19 Jun 2012 22:11:58 -0400 Message-ID: <1340158243.1748.38.camel@ubuntu.ubuntu-domain> From: Guan Xuetao Date: Wed, 20 Jun 2012 10:10:43 +0800 In-Reply-To: References: <7d89289dcd15f1644f3e0260c6a218a3ddb0c51c.1340010818.git.gxt@mprc.pku.edu.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCHv3 12/14] unicore32-softmmu: Add puv3 dma support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org, chenwj@iis.sinica.edu.tw, afaerber@suse.de 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