libpciaccess x86 backend
Samuel Thibault
samuel.thibault at ens-lyon.org
Tue Jan 19 11:20:59 PST 2010
Tiago Vignatti, le Tue 19 Jan 2010 21:10:37 +0200, a écrit :
> But we have to go carefully with it and see if we will not be overlapping code
> with libx86 - which currently is only doing real mode calls, but has already a
> lot of IO related stuff:
>
> http://cgit.freedesktop.org/~vignatti/libx86/tree/src/lrmi/common_io.c
libpciaccess could use inb_local instead of relying on glibc's macros,
yes, but I don't see any overlap apart from that.
> > + * Read a VGA rom using the 0xc0000 mapping.
> > + */
> > +static int
> > +pci_device_x86_read_rom(struct pci_device *dev, void *buffer)
> > +{
> > + void *bios;
> > + int memfd;
> > +
> > + if ((dev->device_class & 0x00ffff00) !=
> > + ((PCIC_DISPLAY << 16) | ( PCIS_DISPLAY_VGA << 8))) {
> > + return ENOSYS;
> > + }
> > +
> > + memfd = open("/dev/mem", O_RDONLY);
> > + if (memfd == -1)
> > + return errno;
> > +
> > + bios = mmap(NULL, dev->rom_size, PROT_READ, 0, memfd, 0xc0000);
> > + if (bios == MAP_FAILED) {
> > + close(memfd);
> > + return errno;
> > + }
> > +
> > + memcpy(buffer, bios, dev->rom_size);
> > +
> > + munmap(bios, dev->rom_size);
> > + close(memfd);
> > +
> > + return 0;
> > +}
>
> for instance, with this one now, we'll have pretty much same implementations
> inside X, libpciacccess and libx86.
Ok, but could this factorization be done as a separate effort? I find
it really out of scope of my patch :)
Samuel
More information about the xorg-devel
mailing list