+MmUnlockPages()
authorshort <>
Wed, 6 Nov 2002 13:59:39 +0000 (13:59 +0000)
committershort <>
Wed, 6 Nov 2002 13:59:39 +0000 (13:59 +0000)
+MmMapLockedPages()
+MmUnmapLockedPages()

src/libcaptive/mm/mdl.c

index bfb446e..6658133 100644 (file)
 
 /**
  * MmProbeAndLockPages:
- * @MemoryDescriptorList: Pointer to the #MDL specification structure to probe and lock.
+ * @Mdl: Pointer to the #MDL specification structure to probe and lock.
  * %NULL value is forbidden.
- * @AccessMode: Access at which to probe the pages.
+ * @AccessMode: Access at which to probe the pages. Ignored by libcaptive.
  * @Operation: One of %IoReadAccess, %IoWriteAccess or %IoModifyAccess.
  *
- * Probles the specified @AccessMode and locks those pages to memory
+ * Probles the specified @AccessMode and locks those pages specified by @Mdl to memory
  * with the desired @AccessMode.
- * libcaptive does NOP here as it just ses the %MDL_PAGES_LOCKED flag.
+ * libcaptive does NOP here as it just sets the %MDL_PAGES_LOCKED flag.
  */
-VOID MmProbeAndLockPages(PMDL MemoryDescriptorList,KPROCESSOR_MODE AccessMode,LOCK_OPERATION Operation)
+VOID MmProbeAndLockPages(PMDL Mdl,KPROCESSOR_MODE AccessMode,LOCK_OPERATION Operation)
 {
-       g_return_if_fail(MemoryDescriptorList!=NULL);
+       g_return_if_fail(Mdl!=NULL);
 
-       MemoryDescriptorList->MdlFlags|=MDL_PAGES_LOCKED;
+       Mdl->MdlFlags|=MDL_PAGES_LOCKED;
+}
+
+
+/**
+ * MmUnlockPages:
+ * @Mdl: Pointer to the #MDL specification structure to unlock.
+ * %NULL value is forbidden.
+ *
+ * Unlock the pages specified by @Mdl from memory.
+ * libcaptive does NOP here as it just clears the %MDL_PAGES_LOCKED flag.
+ */
+VOID MmUnlockPages(PMDL Mdl)
+{
+       g_return_if_fail(Mdl!=NULL);
+
+       Mdl->MdlFlags&=~MDL_PAGES_LOCKED;
+}
+
+
+/**
+ * MmMapLockedPages:
+ * @Mdl: Pointer to the #MDL specification structure to map.
+ * %NULL value is forbidden.
+ * @AccessMode: Access at which to lock the pages. Ignored by libcaptive.
+ *
+ * Leaves the pages at their original location as they are never moved anyway
+ * by libcaptive.
+ *
+ * Returns: Address of the mapped pages base.
+ * This offset does not neet to be %PAGE_SIZE aligned.
+ */
+PVOID MmMapLockedPages(PMDL Mdl,KPROCESSOR_MODE AccessMode)
+{
+       g_return_val_if_fail(Mdl!=NULL,NULL);
+       g_assert(Mdl->StartVa!=NULL);
+
+       if (Mdl->MdlFlags&MDL_MAPPED_TO_SYSTEM_VA) {
+               /* already mapped */
+               g_assert(Mdl->MappedSystemVa==Mdl->StartVa+Mdl->ByteOffset);
+               }
+       else {
+               /* new mapping */
+               Mdl->MappedSystemVa=Mdl->StartVa+Mdl->ByteOffset;
+               Mdl->MdlFlags|=MDL_MAPPED_TO_SYSTEM_VA;
+               }
+
+       return Mdl->MappedSystemVa;
+}
+
+
+/**
+ * @MmUnmapLockedPages:
+ * BaseAddress: Address of the mapped pages base.
+ * This offset does not neet to be %PAGE_SIZE aligned.
+ * @Mdl: Pointer to the #MDL specification structure to unmap.
+ *
+ * Declares the specified @Mdl pages as unmapped. @BaseAddress
+ * is required to be previously returned by MmMapLockedPages().
+ * You must not call this function twice without MmMapLockedPages() between.
+ */
+VOID MmUnmapLockedPages(PVOID BaseAddress,PMDL Mdl)
+{
+       g_return_if_fail(BaseAddress!=NULL);
+       g_return_if_fail(Mdl!=NULL);
+       g_return_if_fail(Mdl->MdlFlags&MDL_MAPPED_TO_SYSTEM_VA);
+       g_return_if_fail(BaseAddress!=Mdl->MappedSystemVa);
+
+       Mdl->MappedSystemVa=NULL;
+       Mdl->MdlFlags&=~MDL_MAPPED_TO_SYSTEM_VA;
 }