[LinuxBIOS] On flashrom architecture
Darmawan Salihun
darmawan.salihun at gmail.com
Thu Apr 26 10:14:21 CEST 2007
On 4/25/07, Peter Stuge <stuge-linuxbios at cdy.org> wrote:
>
> On Tue, Apr 24, 2007 at 11:15:24PM +0700, Darmawan Salihun wrote:
> > >Do we need a wrapper for those "map-physical-memory" functions?
> >
> > I think we don't need it because it has an "equivalent" in Windows'
> > kernel mode driver, i.e.
> >
> > PVOID MmGetSystemAddressForMdlSafe(IN PMDL Mdl, IN
> > MM_PAGE_PRIORITY Priority);
>
> Is MmMapIoSpace() strictly for io? Otherwise it may also be a
> candidate.
>
...ah, you're right Peter. It was in the midnight back then when I wrote
mail. It should've been
MmMapIoSpace(..), not MmGetSystemAddressForMdlSafe(..) function. I have
something in the works right now for the porting of flashrom to Windows.
Below is the snippet (in case you are curious about it ;)
----------
//
// We have obtained a free mapZone, map the physical address range.
//
pUsermodeMem = (MMIO_MAP*) MmGetSystemAddressForMdlSafe(
pIrp->MdlAddress, NormalPagePriority );
if( NULL == pUsermodeMem) {
return STATUS_INVALID_USER_BUFFER;
}
phyAddr.HighPart = 0;
phyAddr.LowPart = pUsermodeMem->phyAddrStart;
pDevExt->mapZone[free_idx].sysAddrBase = MmMapIoSpace( phyAddr,
pUsermodeMem->size, MmNonCached);
if(NULL == pDevExt->mapZone[free_idx].sysAddrBase)
{
return STATUS_BUFFER_TOO_SMALL;
}
pDevExt->mapZone[free_idx].pMdl =
IoAllocateMdl(pDevExt->mapZone[free_idx].sysAddrBase,
pUsermodeMem->size, FALSE, FALSE, NULL);
if(NULL == pDevExt->mapZone[free_idx].pMdl)
{
MmUnmapIoSpace(pDevExt->mapZone[free_idx].sysAddrBase,
pUsermodeMem->size);
pDevExt->mapZone[free_idx].sysAddrBase = NULL;
return STATUS_BUFFER_TOO_SMALL;
}
pDevExt->mapZone[free_idx].size = pUsermodeMem->size;
//
// Map the system virtual address to usermode virtual address
//
MmBuildMdlForNonPagedPool(pDevExt->mapZone[free_idx].pMdl);
pDevExt->mapZone[free_idx].usermodeAddrBase =
MmMapLockedPagesSpecifyCache( pDevExt->mapZone[free_idx].pMdl,
UserMode, MmNonCached,
NULL, FALSE,
NormalPagePriority);
if(NULL == pDevExt->mapZone[free_idx].usermodeAddrBase)
{
IoFreeMdl(pDevExt->mapZone[free_idx].pMdl);
MmUnmapIoSpace(pDevExt->mapZone[free_idx].sysAddrBase,
pDevExt->mapZone[free_idx].size);
pDevExt->mapZone[free_idx].sysAddrBase = NULL;
pDevExt->mapZone[free_idx].size = 0;
return STATUS_BUFFER_TOO_SMALL;
}
-----------------
>
It seems an MDL is always specified with a virtual address but I
> can't find a phystovirt() in the Mm functions. Admittedly I didn't
> look very hard so you may already have found it. :)
>
Basically, the conversion to User mode virtual address is in the code
snippet above ;-)
> > The main problem is the mechanism will be a bit different because
> > flashrom will be divided into kernel mode driver and user mode
> > application in Windows.
>
> I think I like having more of the logic in the kernel driver for
> once, this is because the algorithms can benefit in speed, and
> because the system will be more stable as long as the kernel driver
> is bug free. ;)
>
> Letting the app drive everything is less intrusive of course, but
> could also put the system into an unknown state if the app is aborted
> halfway through something.
>
I'll look forward this issue. Thanks.
--Darmawan
--------------------------------------------------------------------
-= Human knowledge belongs to the world =-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20070426/365a89d3/attachment.html>
More information about the coreboot
mailing list