-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-static void
-hibernate_page_list_zero(hibernate_page_list_t *list)
-{
- uint32_t bank;
- hibernate_bitmap_t * bitmap;
-
- bitmap = &list->bank_bitmap[0];
- for (bank = 0; bank < list->bank_count; bank++)
- {
- uint32_t bit, last_bit;
- uint32_t *bitmap_word;
-
- bzero((void *) &bitmap->bitmap[0], bitmap->bitmapwords << 2);
-
- // Set out-of-bound bits at end of bitmap.
- bitmap_word = &bitmap->bitmap[bitmap->bitmapwords - 1];
- last_bit = ((bitmap->last_page - bitmap->first_page) & 31);
- for (bit = 31; bit > last_bit; bit--) {
- *bitmap_word |= (0x80000000 >> bit);
- }
-
- bitmap = (hibernate_bitmap_t *) &bitmap->bitmap[bitmap->bitmapwords];
- }
-}
-
-
-static boolean_t
-consider_discard(vm_page_t m)
-{
- register vm_object_t object = 0;
- int refmod_state;
- boolean_t discard = FALSE;
-
- do
- {
- if(m->private)
- panic("consider_discard: private");
-
- if (!vm_object_lock_try(m->object))
- break;
-
- object = m->object;
-
- if (m->wire_count != 0)
- break;
- if (m->precious)
- break;
-
- if (m->busy || !object->alive)
- /*
- * Somebody is playing with this page.
- */
- break;
-
- if (m->absent || m->unusual || m->error)
- /*
- * If it's unusual in anyway, ignore it
- */
- break;
-
- if (m->cleaning)
- break;
-
- if (!m->dirty)
- {
- refmod_state = pmap_get_refmod(m->phys_page);
-
- if (refmod_state & VM_MEM_REFERENCED)
- m->reference = TRUE;
- if (refmod_state & VM_MEM_MODIFIED)
- m->dirty = TRUE;
- }
-
- /*
- * If it's clean we can discard the page on wakeup.
- */
- discard = !m->dirty;
- }
- while (FALSE);
-
- if (object)
- vm_object_unlock(object);
-
- return (discard);
-}
-
-
-static void
-discard_page(vm_page_t m)
-{
- if (m->absent || m->unusual || m->error)
- /*
- * If it's unusual in anyway, ignore
- */
- return;
-
- if (!m->no_isync)
- {
- int refmod_state = pmap_disconnect(m->phys_page);
-
- if (refmod_state & VM_MEM_REFERENCED)
- m->reference = TRUE;
- if (refmod_state & VM_MEM_MODIFIED)
- m->dirty = TRUE;
- }
-
- if (m->dirty)
- panic("discard_page(%p) dirty", m);
- if (m->laundry)
- panic("discard_page(%p) laundry", m);
- if (m->private)
- panic("discard_page(%p) private", m);
- if (m->fictitious)
- panic("discard_page(%p) fictitious", m);
-
- vm_page_free(m);
-}
-
-/*
- Bits zero in the bitmaps => needs to be saved. All pages default to be saved,
- pages known to VM to not need saving are subtracted.
- Wired pages to be saved are present in page_list_wired, pageable in page_list.
-*/
-
-void
-hibernate_page_list_setall(hibernate_page_list_t * page_list,
- hibernate_page_list_t * page_list_wired,
- uint32_t * pagesOut)