#include <hal_proc.h>
#define TRACE_MAPS 0
-#define TRACE_COW 1
+#define TRACE_COW 0
#define AP_KRW_ONLY 1 // Kernel page
#define AP_KRO_ONLY 5 // Kernel RO page
}
// --- Exports ---
-tPAddr MM_GetPhysAddr(const void *Ptr)
+tPAddr MM_GetPhysAddr(volatile const void *Ptr)
{
tMM_PageInfo pi;
if( MM_int_GetPageInfo((tVAddr)Ptr, &pi) )
MM_Deallocate(VAddr);
}
-tVAddr MM_MapHWPages(tPAddr PAddr, Uint NPages)
+void *MM_MapHWPages(tPAddr PAddr, Uint NPages)
{
tVAddr ret;
int i;
MM_Map(ret+i*PAGE_SIZE, PAddr+i*PAGE_SIZE);
// and return
LEAVE('p', ret);
- return ret;
+ return (void*)ret;
}
Log_Warning("MMVirt", "MM_MapHWPages: No space for a %i page block", NPages);
LEAVE('p', 0);
return 0;
}
-tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PAddr)
+void *MM_AllocDMA(int Pages, int MaxBits, tPAddr *PAddr)
{
tPAddr phys;
- tVAddr ret;
+ void *ret;
phys = MM_AllocPhysRange(Pages, MaxBits);
if(!phys) {
}
ret = MM_MapHWPages(phys, Pages);
- *PAddr = phys;
+ if( !ret ) {
+ MM_DerefPhys(phys);
+ return NULL;
+ }
+ if( PAddr )
+ *PAddr = phys;
return ret;
}