/* * linux/kernel/power/snapshot.c * * This file provide system snapshot/restore functionality. * * Copyright (C) 1998-2005 Pavel Machek <pavel@suse.cz> * * This file is released under the GPLv2, and is based on swsusp.c. * */#include<linux/version.h>#include<linux/module.h>#include<linux/mm.h>#include<linux/suspend.h>#include<linux/smp_lock.h>#include<linux/delay.h>#include<linux/bitops.h>#include<linux/spinlock.h>#include<linux/kernel.h>#include<linux/pm.h>#include<linux/device.h>#include<linux/bootmem.h>#include<linux/syscalls.h>#include<linux/console.h>#include<linux/highmem.h>#include<asm/uaccess.h>#include<asm/mmu_context.h>#include<asm/pgtable.h>#include<asm/tlbflush.h>#include<asm/io.h>#include"power.h"/* List of PBEs used for creating and restoring the suspend image */structpbe*restore_pblist;staticunsignedintnr_copy_pages;staticunsignedintnr_meta_pages;staticvoid*buffer;#ifdef CONFIG_HIGHMEMunsignedintcount_highmem_pages(void){structzone*zone;unsignedlongzone_pfn;unsignedintn=0;for_each_zone(zone)if(is_highmem(zone)){mark_free_pages(zone);for(zone_pfn=0;zone_pfn<zone->spanned_pages;zone_pfn++){structpage*page;unsignedlongpfn=zone_pfn+zone->zone_start_pfn;if(!pfn_valid(pfn))continue;page=pfn_to_page(pfn);if(PageReserved(page))continue;if(PageNosaveFree(page))continue;n++;}}returnn;}structhighmem_page{char*data;structpage*page;structhighmem_page*next;};staticstructhighmem_page*highmem_copy;staticintsave_highmem_zone(structzone*zone){unsignedlongzone_pfn;mark_free_pages(zone);for(zone_pfn=0;zone_pfn<zone->spanned_pages;++zone_pfn){structpage*page;structhighmem_page*save;void*kaddr;unsignedlongpfn=zone_pfn+zone->zone_start_pfn;if(!(pfn%10000))