- KernelBootArgs_t * bootArgs = (KernelBootArgs_t *)PE_state.bootArgs;
- MemoryRange * mptr;
- uint32_t bank;
- uint32_t page, count;
-
- for (bank = 0, mptr = bootArgs->memoryMap; bank < bootArgs->memoryMapCount; bank++, mptr++) {
-
- if (kMemoryRangeNVS != mptr->type) continue;
- kprintf("Base NVS region 0x%x + 0x%x\n", (vm_offset_t)mptr->base, (vm_size_t)mptr->length);
- /* Round to page size. Hopefully this does not overlap any reserved areas. */
- page = atop_32(trunc_page((vm_offset_t)mptr->base));
- count = atop_32(round_page((vm_offset_t)mptr->base + (vm_size_t)mptr->length)) - page;
- kprintf("Rounded NVS region 0x%x size 0x%x\n", page, count);
-
- hibernate_set_page_state(page_list, page_list_wired, page, count, 1);
- pagesOut -= count;
+}
+
+// mark pages not to be saved and not for scratch usage during restore
+void
+hibernate_page_list_set_volatile( hibernate_page_list_t * page_list,
+ hibernate_page_list_t * page_list_wired,
+ uint32_t * pagesOut)
+{
+ boot_args * args = (boot_args *) PE_state.bootArgs;
+
+#if !defined(x86_64)
+ hibernate_set_page_state(page_list, page_list_wired,
+ I386_HIB_PAGETABLE, I386_HIB_PAGETABLE_COUNT,
+ kIOHibernatePageStateFree);
+ *pagesOut -= I386_HIB_PAGETABLE_COUNT;
+#endif
+
+ if (args->efiRuntimeServicesPageStart)
+ {
+ hibernate_set_page_state(page_list, page_list_wired,
+ args->efiRuntimeServicesPageStart, args->efiRuntimeServicesPageCount,
+ kIOHibernatePageStateFree);
+ *pagesOut -= args->efiRuntimeServicesPageCount;