[Lguest] [PATCH 0/6] virtio with config abstraction and ring implementation
Rusty Russell
rusty at rustcorp.com.au
Fri Sep 21 13:20:11 EST 2007
On Thu, 2007-09-20 at 15:43 +0200, Dor Laor wrote:
> Rusty Russell wrote:
> > Drivers now unpack their own configuration: their probe() methods are
> > uniform. The configuration mechanism is extensible and can be backed by
> > PCI, a string of bytes, or something else.
> I like the separation of the ring code, the improved descriptors and
> the notify too.
> Regarding the pci config space, I rather see config_ops type of
> operations to let
> the 390/xen/other implementations jump on our wagon.
It's possible to abstract at the find_config() level, but it's also not
too bad to linearize any existing configuration. I chose to change the
lguest device page to use a linearized format, but I could have adapted
the old device info struct in the kernel without too much hassle:
FYI, here's the lguest snippet, for example:
+struct lguest_config {
+ struct virtio_config_space v;
+
+ /* Status pointer: 4 bytes, then comes the config space itself. */
+ u8 *status;
+};
...
+static void lguest_writeb(struct virtio_config_space *v, unsigned off, u8 b)
+{
+ struct lguest_config *c = container_of(v, struct lguest_config, v);
+
+ c->status[4 + off] = b;
+}
+
+static u8 lguest_readb(struct virtio_config_space *v, unsigned off)
+{
+ struct lguest_config *c = container_of(v, struct lguest_config, v);
+
+ return c->status[4 + off];
+}
+
+static void lguest_set_status(struct virtio_config_space *v, u32 status)
+{
+ struct lguest_config *c = container_of(v, struct lguest_config, v);
+
+ memcpy(c->status, &status, sizeof(status));
+}
+
+static u32 lguest_get_status(struct virtio_config_space *v)
+{
+ struct lguest_config *c = container_of(v, struct lguest_config, v);
+ u32 status;
+
+ memcpy(&status, c->status, sizeof(status));
+ return status;
+}
More information about the Lguest
mailing list