[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2/2] ioemu: Enable guest OS to program D0-D3hot states of an assigned device
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |