hibernate_restore.c [plain text]
#include <i386/pmap.h>
#include <i386/proc_reg.h>
#include <IOKit/IOHibernatePrivate.h>
#include <vm/WKdm_new.h>
#include <machine/pal_hibernate.h>
extern pd_entry_t BootPTD[2048];
uintptr_t
hibernate_restore_phys_page(uint64_t src, uint64_t dst, uint32_t len, uint32_t procFlags)
{
(void)procFlags;
uint64_t * d;
uint64_t * s;
if (src == 0) {
return (uintptr_t)dst;
}
d = (uint64_t *)pal_hib_map(DEST_COPY_AREA, dst);
s = (uint64_t *) (uintptr_t)src;
__nosan_memcpy(d, s, len);
return (uintptr_t)d;
}
#undef hibprintf
void hibprintf(const char *fmt, ...);
uintptr_t
pal_hib_map(uintptr_t virt, uint64_t phys)
{
uintptr_t index;
switch (virt) {
case DEST_COPY_AREA:
case SRC_COPY_AREA:
case COPY_PAGE_AREA:
case BITMAP_AREA:
case IMAGE_AREA:
case IMAGE2_AREA:
case SCRATCH_AREA:
case WKDM_AREA:
break;
default:
asm("cli;hlt;");
break;
}
if (phys < WKDM_AREA) {
return phys;
}
index = (virt >> I386_LPGSHIFT);
virt += (uintptr_t)(phys & I386_LPGMASK);
phys = ((phys & ~((uint64_t)I386_LPGMASK)) | INTEL_PTE_PS | INTEL_PTE_VALID | INTEL_PTE_WRITE);
if (phys == BootPTD[index]) {
return virt;
}
BootPTD[index] = phys;
invlpg(virt);
BootPTD[index + 1] = (phys + I386_LPGBYTES);
invlpg(virt + I386_LPGBYTES);
return virt;
}
void
pal_hib_restore_pal_state(uint32_t *arg)
{
(void)arg;
}
void
pal_hib_resume_init(__unused pal_hib_ctx_t *ctx, __unused hibernate_page_list_t *map, __unused uint32_t *nextFree)
{
}
void
pal_hib_restored_page(__unused pal_hib_ctx_t *ctx, __unused pal_hib_restore_stage_t stage, __unused ppnum_t ppnum)
{
}
void
pal_hib_patchup(__unused pal_hib_ctx_t *ctx)
{
}
void
pal_hib_decompress_page(void *src, void *dst, void *scratch, unsigned int compressedSize)
{
WKdm_decompress_new((WK_word*)src, (WK_word*)dst, (WK_word*)scratch, compressedSize);
}