#ifndef _PPC_PMAP_H_
#define _PPC_PMAP_H_
#include <mach/vm_types.h>
#include <mach/machine/vm_types.h>
#include <mach/vm_prot.h>
#include <mach/vm_statistics.h>
#include <kern/queue.h>
#include <vm/pmap.h>
#define maxPPage32 0x000FFFFF
typedef uint32_t shexlock;
#pragma pack(4)
struct sgc {
uint64_t sgcESID;
#define sgcESmsk 0xFFFFFFFFF0000000ULL
uint64_t sgcVSID;
#define sgcVSmsk 0xFFFFFFFFFFFFF000ULL
#define sgcVSKeys 0x0000000000000C00ULL
#define sgcVSKeyUsr 53
#define sgcVSNoEx 0x0000000000000200ULL
};
#pragma pack()
typedef struct sgc sgc;
#pragma pack(4)
struct pmap {
queue_head_t pmap_link;
addr64_t pmapvr;
shexlock pmapSXlk;
unsigned int space;
#define invalSpace 0x00000001
int ref_count;
unsigned int pmapFlags;
#define pmapKeys 0x00000007
#define pmapKeyDef 0x00000006
#define pmapVMhost 0x00000010
unsigned int spaceNum;
unsigned int pmapCCtl;
#define pmapCCtlVal 0xFFFF0000
#define pmapCCtlLck 0x00008000
#define pmapCCtlLckb 16
#define pmapCCtlGen 0x00007FFF
#define pmapSegCacheCnt 16
#define pmapSegCacheUse 16
struct pmap *freepmap;
unsigned int pmapRsv1[3];
uint64_t pmapSCSubTag;
sgc pmapSegCache[pmapSegCacheCnt];
#define kSkipListFanoutShift 1
#define kSkipListMaxLists 12
unsigned char pmapCurLists;
unsigned char pmapRsv2[3];
uint32_t pmapRandNum;
addr64_t pmapSkipLists[kSkipListMaxLists];
uint64_t pmapSearchVisits;
uint32_t pmapSearchCnt;
unsigned int pmapRsv3[3];
struct pmap_statistics stats;
decl_simple_lock_data(,lock)
#define pmapSize 512
};
#pragma pack()
#pragma pack(4)
struct pmapTransTab {
addr64_t pmapPAddr;
unsigned int pmapVAddr;
};
#pragma pack()
typedef struct pmapTransTab pmapTransTab;
#define PMAP_NULL ((pmap_t) 0)
extern pmap_t kernel_pmap;
extern pmap_t cursor_pmap;
extern pmap_t sharedPmap;
extern unsigned int sharedPage;
extern int ppc_max_adrsp;
extern addr64_t vm_max_address;
extern addr64_t vm_max_physical;
extern pmapTransTab *pmapTrans;
#define PMAP_SWITCH_USER(th, map, my_cpu) th->map = map;
#define PMAP_ACTIVATE(pmap, th, cpu)
#define PMAP_DEACTIVATE(pmap, th, cpu)
#define PMAP_CONTEXT(pmap,th)
#define pmap_kernel_va(VA) \
(((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= vm_last_addr))
#define PPC_SID_KERNEL 0
#define maxAdrSp 16384
#define maxAdrSpb 14
#define copyIOaddr 0x00000000E0000000ULL
#define pmap_kernel() (kernel_pmap)
#define pmap_resident_count(pmap) ((pmap)->stats.resident_count)
#define pmap_remove_attributes(pmap,start,end)
#define pmap_copy(dpmap,spmap,da,len,sa)
#define pmap_update()
#define PMAP_DEFAULT_CACHE 0
#define PMAP_INHIBIT_CACHE 1
#define PMAP_GUARDED_CACHE 2
#define PMAP_ACTIVATE_CACHE 4
#define PMAP_NO_GUARD_CACHE 8
#define VM_WIMG_DEFAULT (VM_MEM_COHERENT)
#define VM_WIMG_COPYBACK (VM_MEM_COHERENT)
#define VM_WIMG_IO (VM_MEM_COHERENT | \
VM_MEM_NOT_CACHEABLE | VM_MEM_GUARDED)
#define VM_WIMG_WTHRU (VM_MEM_WRITE_THROUGH | VM_MEM_COHERENT | VM_MEM_GUARDED)
#define VM_WIMG_WCOMB (VM_MEM_NOT_CACHEABLE | VM_MEM_COHERENT)
extern vm_offset_t phystokv(vm_offset_t pa);
extern vm_offset_t kvtophys(vm_offset_t va);
extern vm_offset_t pmap_map(vm_offset_t va,
vm_offset_t spa,
vm_offset_t epa,
vm_prot_t prot);
extern kern_return_t pmap_add_physical_memory(vm_offset_t spa,
vm_offset_t epa,
boolean_t available,
unsigned int attr);
extern void pmap_bootstrap(uint64_t msize,
vm_offset_t *first_avail,
unsigned int kmapsize);
extern void pmap_switch(pmap_t);
extern vm_offset_t pmap_extract(pmap_t pmap,
vm_offset_t va);
extern void pmap_remove_all(vm_offset_t pa);
extern boolean_t pmap_verify_free(ppnum_t pa);
extern void sync_cache(vm_offset_t pa, unsigned length);
extern void sync_cache64(addr64_t pa, unsigned length);
extern void sync_ppage(ppnum_t pa);
extern void sync_cache_virtual(vm_offset_t va, unsigned length);
extern void flush_dcache(vm_offset_t va, unsigned length, boolean_t phys);
extern void flush_dcache64(addr64_t va, unsigned length, boolean_t phys);
extern void invalidate_dcache(vm_offset_t va, unsigned length, boolean_t phys);
extern void invalidate_dcache64(addr64_t va, unsigned length, boolean_t phys);
extern void invalidate_icache(vm_offset_t va, unsigned length, boolean_t phys);
extern void invalidate_icache64(addr64_t va, unsigned length, boolean_t phys);
extern void pmap_sync_caches_phys(ppnum_t pa);
extern void pmap_map_block(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags);
extern int pmap_map_block_rc(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags);
extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, addr64_t vstart, addr64_t nstart, uint64_t size);
extern ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va);
extern addr64_t MapUserAddressSpace(vm_map_t map, addr64_t va, unsigned int size);
extern void ReleaseUserAddressSpace(addr64_t kva);
extern kern_return_t pmap_attribute_cache_sync(ppnum_t pp, vm_size_t size,
vm_machine_attribute_t attribute,
vm_machine_attribute_val_t* value);
extern int pmap_canExecute(ppnum_t pa);
#endif