src/ssx/ppc405/ppc405_mmu.c
/// Un-define a memory region for MMU protection purposes
///
/// \param map A pointer to a Ppc405MmuMap object created by ppc405_mmu_map()
/// when the memory region was mapped.  This map is used to invalidate the TLB
/// entries associated with the map, then the map itself is invalidated.
///
/// The caller is responsible for cache-correctness of this API.  If necessary
/// the caller should flush or invalidate memory areas whose protection
/// attributes have changed prior to and/or after invoking this API.
///
/// \retval 0 Success
///
/// \retval -PPC405_MMU_INVALID_ARGUMENT The \a map pointer is null (0).
Un-define a memory region for MMU protection purposes
\param map A pointer to a Ppc405MmuMap object created by ppc405_mmu_map()
when the memory region was mapped.  This map is used to invalidate the TLB
entries associated with the map, then the map itself is invalidated.

The caller is responsible for cache-correctness of this API.  If necessary
the caller should flush or invalidate memory areas whose protection
attributes have changed prior to and/or after invoking this API.

\retval 0 Success

\retval -PPC405_MMU_INVALID_ARGUMENT The \a map pointer is null (0).
Un - define a memory region for MMU protection purposes \ param map A pointer to a Ppc405MmuMap object created by ppc405_mmu_map () when the memory region was mapped . This map is used to invalidate the TLB entries associated with the map then the map itself is invalidated . The caller is responsible for cache - correctness of this API . If necessary the caller should flush or invalidate memory areas whose protection attributes have changed prior to and / or after invoking this API . \ retval 0 Success \ retval - PPC405_MMU_INVALID_ARGUMENT The \ a map pointer is null ( 0 ) .
int
ppc405_mmu_unmap(Ppc405MmuMap* map)
{
    int tlb_entry;
    uint64_t bit;
    SsxMachineContext ctx;
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF(map == 0, PPC405_MMU_INVALID_ARGUMENT);
    }
    while ((tlb_entry = cntlz64(*map)) != 64)
    {
        bit = 0x8000000000000000ull >> tlb_entry;
        *map &= ~bit;
        tlbwehi(tlb_entry, 0);
        isync();
        ssx_critical_section_enter(SSX_CRITICAL, &ctx);
        __ppc405_tlb_free |= bit;
        ssx_critical_section_exit(&ctx);
    }
    return 0;
}
int ppc405_mmu_unmap ( Ppc405MmuMap * map ) { int tlb_entry ; uint64_t bit ; SsxMachineContext ctx ; if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( map == 0 , PPC405_MMU_INVALID_ARGUMENT ) ; } while ( ( tlb_entry = cntlz64 ( * map ) ) != 64 ) { bit = 0x8000000000000000ull >> tlb_entry ; * map &= ~ bit ; tlbwehi ( tlb_entry , 0 ) ; isync ( ) ; ssx_critical_section_enter ( SSX_CRITICAL , & ctx ) ; __ppc405_tlb_free |= bit ; ssx_critical_section_exit ( & ctx ) ; } return 0 ; }
Un-define a memory region for MMU protection purposes
\param map A pointer to a Ppc405MmuMap object created by ppc405_mmu_map()
when the memory region was mapped.
Un - define a memory region for MMU protection purposes \ param map A pointer to a Ppc405MmuMap object created by ppc405_mmu_map () when the memory region was mapped .