WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 2/2] ioemu: Enable guest OS to program D0-D3hot s

To: Yuji Shimada <shimada-yxb@xxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 2/2] ioemu: Enable guest OS to program D0-D3hot states of an assigned device
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Fri, 6 Feb 2009 11:45:29 +0900
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Delivery-date: Thu, 05 Feb 2009 18:45:58 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090205191651.2F5A.SHIMADA-YXB@xxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090204101439.GN25835%yamahata@xxxxxxxxxxxxx> <20090205162655.2F57.SHIMADA-YXB@xxxxxxxxxxxxxxx> <20090205191651.2F5A.SHIMADA-YXB@xxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
On Thu, Feb 05, 2009 at 07:23:11PM +0900, Yuji Shimada wrote:
> We can clean up the existing code in pass-through.c in the same
> manner. I will submit the patch to clean up the code.

Thank you for clean up.
There are another logic duplications with mask operations.
I suppose helper functions like the following will help
to reduce the code more.

thanks,

static void __pt_read_{byte, word, long}(uint{8, 16, 32}_t *value,
                                         uint{8, 16, 32}_t dev_value,
                                         uint{8, 16, 32}_t emu_mask,
                                         uint{8, 16, 32}_t valid_mask)
{
    uint{8, 16, 32}_t valid_emu_mask = emu_mask & valid_mask;
    *value = ((*value & ~valid_emu_mask) | (dev_data & valid_emu_mask));
}

static void __pt_write_cfg_{byte, word, long}(struct pt_reg_tbl *cfg_entry,
                                              uint{8, 16, 32}_t value
                                              uint{8, 16, 32}_t emu_mask,
                                              uint{8, 16, 32}_t ro_mask,
                                              uint{8, 16, 32}_t valid_mask)
{
    uint{8, 16, 32}_t writable_mask = emu_mask & ~ro_mask & valid_mask;
    cfg_entry->data = ((value & writable_mask) |
                       (cfg_entry->data & ~writable_mask));
}

static void __pt_write_{byte, word, long}(uint{8, 16, 32}_t *value,
                                          uint{8, 16, 32}_t dev_value,
                                          uint{8, 16, 32}_t emu_mask,
                                          uint{8, 16, 32}_t valid_mask)
{
    uint{8, 16, 32}_t throughable_mask = ~emu_mask & valid_mask;
    *value = ((*value & throughable_mask) | (dev_value & ~throughable_mask));
}


-- 
yamahata

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>