Re: [PATCH v8 1/4] firmware: introduce sysfs driver for QEMU's fw_cfg device
From: Gabriel L. Somlo
Date: Sun Feb 21 2016 - 12:21:02 EST
On Sun, Feb 21, 2016 at 03:10:30PM +0200, Michael S. Tsirkin wrote:
> On Sun, Feb 21, 2016 at 08:06:17AM -0500, Gabriel L. Somlo wrote:
> >
> > >
> > > > +#if !(defined(FW_CFG_CTRL_OFF) && defined(FW_CTRL_DATA_OFF))
> > > > +# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
> > > > +# define FW_CFG_CTRL_OFF 0x08
> > > > +# define FW_CFG_DATA_OFF 0x00
> > > > +# elif (defined(CONFIG_PPC_PMAC) || defined(CONFIG_SPARC32)) /* ppc/mac,sun4m */
> > > > +# define FW_CFG_CTRL_OFF 0x00
> > > > +# define FW_CFG_DATA_OFF 0x02
> > > > +# elif (defined(CONFIG_X86) || defined(CONFIG_SPARC64)) /* x86, sun4u */
> > > > +# define FW_CFG_CTRL_OFF 0x00
> > > > +# define FW_CFG_DATA_OFF 0x01
> > > > +# else
> > > > +# warning "QEMU FW_CFG may not be available on this architecture!"
> > > > +# define FW_CFG_CTRL_OFF 0x00
> > > > +# define FW_CFG_DATA_OFF 0x01
> > >
> > > Better not try hacks like this, they are hard
> > > to support down the road. Please only list what is tested and
> > > actually exposed by QEMU.
> >
> > I was looking for a standard way to advertise register offsets within
> > the ioport or mmio region assigned to fw_cfg, but right now the answer
> > is "there isn't one", and "register offsets are an arch specific
> > detail". As such, the only reasonable way I saw was to copy the same
> > values used in the QEMU source.
> >
> > See also:
> > https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg05037.html
> >
> > Thanks much,
> > --Gabriel
>
> My point is you don't know what will qemu do on these
> other arches which do not at the moment have fw cfg.
> So don't try to guess!
Oh, you mean for the "else". I originally wanted to be able to compile
this on any architecture and wanted some dummy defaults I could
override on the command line. But now we're already restricting this
to known architectures only, so I'll send a patch turning the warning
into an error, and removing the #defines for the "else" branch above.
Sorry I misunderstood you the first time around :)
Thanks,
--Gabriel