Beispiel #1
0
kern_return_t 
hibernate_setup(IOHibernateImageHeader * header,
                        uint32_t  free_page_ratio,
                        uint32_t  free_page_time,
                        boolean_t vmflush,
			hibernate_page_list_t ** page_list_ret,
			hibernate_page_list_t ** page_list_wired_ret,
                        boolean_t * encryptedswap)
{
    hibernate_page_list_t * page_list = NULL;
    hibernate_page_list_t * page_list_wired = NULL;
    uint32_t    	    gobble_count;

    *page_list_ret       = NULL;
    *page_list_wired_ret = NULL;
    
    if (vmflush)
        hibernate_flush_memory();

    page_list = hibernate_page_list_allocate();
    if (!page_list)
        return (KERN_RESOURCE_SHORTAGE);
    page_list_wired = hibernate_page_list_allocate();
    if (!page_list_wired)
    {
        kfree(page_list, page_list->list_size);
        return (KERN_RESOURCE_SHORTAGE);
    }

    *encryptedswap = dp_encryption;

    // pages we could force out to reduce hibernate image size
    gobble_count = (uint32_t)((((uint64_t) page_list->page_count) * ((uint64_t) free_page_ratio)) / 100);

    // no failures hereafter

    hibernate_processor_setup(header);

    HIBLOG("hibernate_alloc_pages flags %08x, gobbling %d pages\n", 
	    header->processorFlags, gobble_count);

    if (gobble_count)
	hibernate_gobble_pages(gobble_count, free_page_time);

    *page_list_ret       = page_list;
    *page_list_wired_ret = page_list_wired;

    return (KERN_SUCCESS);
}
Beispiel #2
0
kern_return_t 
hibernate_alloc_page_lists(
		hibernate_page_list_t ** page_list_ret,
		hibernate_page_list_t ** page_list_wired_ret,
		hibernate_page_list_t ** page_list_pal_ret)
{
    kern_return_t	retval = KERN_SUCCESS;

    hibernate_page_list_t * page_list = NULL;
    hibernate_page_list_t * page_list_wired = NULL;
    hibernate_page_list_t * page_list_pal = NULL;

    page_list = hibernate_page_list_allocate(TRUE);
    if (!page_list) {

	    retval = KERN_RESOURCE_SHORTAGE;
	    goto done;
    }
    page_list_wired = hibernate_page_list_allocate(FALSE);
    if (!page_list_wired)
    {
	    kfree(page_list, page_list->list_size);

	    retval = KERN_RESOURCE_SHORTAGE;
	    goto done;
    }
    page_list_pal = hibernate_page_list_allocate(FALSE);
    if (!page_list_pal)
    {
	    kfree(page_list, page_list->list_size);
	    kfree(page_list_wired, page_list_wired->list_size);

	    retval = KERN_RESOURCE_SHORTAGE;
	    goto done;
    }
    *page_list_ret        = page_list;
    *page_list_wired_ret  = page_list_wired;
    *page_list_pal_ret    = page_list_pal;

done:
    return (retval);

}