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: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 2/2] ioemu: Enable guest OS to program D0-D3hot states of an assigned device
From: Yuji Shimada <shimada-yxb@xxxxxxxxxxxxxxx>
Date: Fri, 06 Feb 2009 17:16:42 +0900
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Delivery-date: Fri, 06 Feb 2009 00:17:21 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090206024529.GA21269%yamahata@xxxxxxxxxxxxx>
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: <20090205191651.2F5A.SHIMADA-YXB@xxxxxxxxxxxxxxx> <20090206024529.GA21269%yamahata@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 6 Feb 2009 11:45:29 +0900
Isaku Yamahata <yamahata@xxxxxxxxxxxxx> wrote:

> 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));
> }

I realize the duplications with mask operations.
I have already introduced PT_MERGE_VALUE macro with the previous
patch. I'd like to create the new patch which cleanups them using
PT_MERGE_VALUE macro.
Is this acceptable?

These are examples.

Returned value to guest software on reading:
    *value = PT_MERGE_VALUE(*value, dev_value, emu_mask & valid_mask);

Emulated value on writing.
    cfg_entry->data = PT_MERGE_VALUE(value, cfg_entry->data,
        emu_mask & ~ro_mask & valid_mask)

Written value to actual device on writing:
*value = PT_MERGE_VALUE(*value, dev_value, ~emu_mask & valid_mask);

Thanks,
--
Yuji Shimada


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

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