From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KZma4-0004KS-Sc for qemu-devel@nongnu.org; Sun, 31 Aug 2008 09:03:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KZma3-0004K3-F6 for qemu-devel@nongnu.org; Sun, 31 Aug 2008 09:03:00 -0400 Received: from [199.232.76.173] (port=44316 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZma3-0004Jx-7W for qemu-devel@nongnu.org; Sun, 31 Aug 2008 09:02:59 -0400 Received: from il.qumranet.com ([212.179.150.194]:10261) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KZma2-0000nl-GB for qemu-devel@nongnu.org; Sun, 31 Aug 2008 09:02:58 -0400 Received: from gleb-debian.qumranet.com (gleb-debian.qumranet.com.qumranet.com [172.16.15.143]) by il.qumranet.com (Postfix) with ESMTP id 97911250EDA for ; Sun, 31 Aug 2008 16:02:56 +0300 (IDT) Date: Sun, 31 Aug 2008 16:02:56 +0300 From: Gleb Natapov Subject: Re: [Qemu-devel] [PATCH v3 1/6] Use IO port for qemu<->guest BIOS communication. Message-ID: <20080831130256.GG6192@minantech.com> References: <20080828165232.22851.77678.stgit@gleb-debian.qumranet.com.qumranet.com> <20080828165237.22851.1532.stgit@gleb-debian.qumranet.com.qumranet.com> <20080829190041.GA18301@minantech.com> <20080831111206.GF6192@minantech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Sun, Aug 31, 2008 at 03:45:36PM +0300, Blue Swirl wrote: > > > I made an updated version of the patch 1/6, with explicit little > > > endian conversions. I'm not very happy with that. Another way would be > > > to add functions just to put different size numbers into device and > > > they would hide the conversion. > > > > > > > So what approach we should go with? We can go with the second one (add > > functions for each type) and extend interface as needed. > > This version adds the functions, now the interface is much better. I > updated the other patches too. > +static int fw_cfg_select(FWCfgState *s, uint16_t key) > +{ > + int ret; > + > + s->cur_offset = 0; > + if ((key & ~FW_CFG_ARCH_LOCAL) >= FW_CFG_MAX_ENTRY) { > + s->cur_entry = 0; Here we select valid entry on incorrect input. Perhaps set 0xffff here and return 0 on read if cur_entry == 0xffff ? > +static uint8_t fw_cfg_read(FWCfgState *s) > +{ > + int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL); > + FWCfgEntry *e = &s->entries[arch][s->cur_entry]; This should be: FWCfgEntry *e = &s->entries[arch][s->cur_entry & ~FW_CFG_ARCH_LOCAL]; > + uint8_t ret; > + > + if (!e || !e->data || s->cur_offset >= e->len) Like this: if (s->cur_entry == 0xffff || !e->data || s->cur_offset >= e->len) > + ret = 0; > + else > + ret = e->data[s->cur_offset++]; > + > + FW_CFG_DPRINTF("read %d\n", ret); > + > + return ret; > +} > + Other then that looks great to me. -- Gleb.