#include <mach_kdp.h>
#include <mach/vm_param.h>
#include <arm/lowglobals.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
extern vm_offset_t vm_kernel_stext;
extern void *version;
extern void *kmod;
extern void *kdp_trans_off;
extern void *osversion;
extern void *flag_kdp_trigger_reboot;
extern void *manual_pkt;
extern struct vm_object pmap_object_store;
lowglo lowGlo __attribute__ ((aligned(PAGE_MAX_SIZE))) = {
.lgVerCode = { 'O','c','t','o','p','u','s',' ' },
.lgLayoutMajorVersion = 3,
.lgLayoutMinorVersion = 0,
.lgLayoutMagic = LOWGLO_LAYOUT_MAGIC,
.lgVersion = (uint32_t)&version,
.lgKmodptr = (uint32_t)&kmod,
.lgPageShift = PAGE_SHIFT,
#if MACH_KDP
.lgTransOff = (uint32_t)&kdp_trans_off,
#endif
.lgOSVersion = (uint32_t)&osversion,
#if MACH_KDP && CONFIG_KDP_INTERACTIVE_DEBUGGING
.lgRebootFlag = (uint32_t)&flag_kdp_trigger_reboot,
.lgManualPktAddr = (uint32_t)&manual_pkt,
#endif
.lgPmapMemQ = (uint32_t)&(pmap_object_store.memq),
.lgPmapMemPageOffset = offsetof(struct vm_page_with_ppnum, phys_page),
.lgPmapMemChainOffset = offsetof(struct vm_page, listq),
.lgPmapMemPagesize = (uint32_t)sizeof(struct vm_page),
.lgPmapMemStartAddr = -1,
.lgPmapMemEndAddr = -1,
.lgPmapMemFirstppnum = -1
};
void patch_low_glo(void)
{
lowGlo.lgStext = (uint32_t)vm_kernel_stext;
}
void patch_low_glo_static_region(uint32_t address, uint32_t size)
{
lowGlo.lgStaticAddr = address;
lowGlo.lgStaticSize = size;
}
void patch_low_glo_vm_page_info(void * start_addr, void * end_addr, uint32_t first_ppnum)
{
lowGlo.lgPmapMemStartAddr = (uint32_t)start_addr;
lowGlo.lgPmapMemEndAddr = (uint32_t)end_addr;
lowGlo.lgPmapMemFirstppnum = first_ppnum;
}