Linux Kernel
3.7.1
|
#include <linux/version.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/suspend.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/init.h>
#include <linux/bootmem.h>
#include <linux/syscalls.h>
#include <linux/console.h>
#include <linux/highmem.h>
#include <linux/list.h>
#include <linux/slab.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"
Go to the source code of this file.
Data Structures | |
struct | linked_page |
struct | chain_allocator |
struct | bm_block |
struct | bm_position |
struct | memory_bitmap |
struct | mem_extent |
struct | nosave_region |
Macros | |
#define | PG_ANY 0 |
#define | PG_SAFE 1 |
#define | PG_UNSAFE_CLEAR 1 |
#define | PG_UNSAFE_KEEP 0 |
#define | LINKED_PAGE_DATA_SIZE (PAGE_SIZE - sizeof(void *)) |
#define | BM_END_OF_MAP (~0UL) |
#define | BM_BITS_PER_BLOCK (PAGE_SIZE * BITS_PER_BYTE) |
#define | page_is_saveable(zone, pfn) saveable_page(zone, pfn) |
#define | GFP_IMAGE (GFP_KERNEL | __GFP_NOWARN) |
#define | PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe)) |
Functions | |
void __init | hibernate_reserved_size_init (void) |
void __init | hibernate_image_size_init (void) |
unsigned long | get_safe_page (gfp_t gfp_mask) |
struct linked_page | __attribute__ ((packed)) |
void __init | __register_nosave_region (unsigned long start_pfn, unsigned long end_pfn, int use_kmalloc) |
void | swsusp_set_page_free (struct page *page) |
void | swsusp_unset_page_free (struct page *page) |
int | swsusp_page_is_forbidden (struct page *page) |
int | create_basic_memory_bitmaps (void) |
void | free_basic_memory_bitmaps (void) |
unsigned int | snapshot_additional_pages (struct zone *zone) |
void | swsusp_free (void) |
int | hibernate_preallocate_memory (void) |
asmlinkage int | swsusp_save (void) |
unsigned long | snapshot_get_image_size (void) |
int | snapshot_read_next (struct snapshot_handle *handle) |
int | snapshot_write_next (struct snapshot_handle *handle) |
void | snapshot_write_finalize (struct snapshot_handle *handle) |
int | snapshot_image_loaded (struct snapshot_handle *handle) |
Variables | |
unsigned long | reserved_size |
unsigned long | image_size |
struct pbe * | restore_pblist |
struct linked_page * | next |
char | data [LINKED_PAGE_DATA_SIZE] |
struct chain_allocator | __attribute__ |
unsigned int | alloc_normal |
unsigned int | alloc_highmem |
#define BM_BITS_PER_BLOCK (PAGE_SIZE * BITS_PER_BYTE) |
Definition at line 254 of file snapshot.c.
#define BM_END_OF_MAP (~0UL) |
Data types related to memory bitmaps.
Memory bitmap is a structure consiting of many linked lists of objects. The main list's elements are of type struct zone_bitmap and each of them corresonds to one zone. For each zone bitmap object there is a list of objects of type struct bm_block that represent each blocks of bitmap in which information is stored.
struct memory_bitmap contains a pointer to the main list of zone bitmap objects, a struct bm_position used for browsing the bitmap, and a pointer to the list of pages used for allocating all of the zone bitmap objects and bitmap block objects.
NOTE: It has to be possible to lay out the bitmap in memory using only allocations of order 0. Additionally, the bitmap is designed to work with arbitrary number of zones (this is over the top for now, but let's avoid making unnecessary assumptions ;-).
struct zone_bitmap contains a pointer to a list of bitmap block objects and a pointer to the bitmap block object that has been most recently used for setting bits. Additionally, it contains the pfns that correspond to the start and end of the represented zone.
struct bm_block contains a pointer to the memory page in which information is stored (in the form of a block of bitmap) It also contains the pfns that correspond to the start and end of the represented memory area.
Definition at line 252 of file snapshot.c.
#define GFP_IMAGE (GFP_KERNEL | __GFP_NOWARN) |
Definition at line 1118 of file snapshot.c.
Definition at line 153 of file snapshot.c.
Definition at line 1024 of file snapshot.c.
#define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe)) |
prepare_image - use the memory bitmap to mark the pages that will be overwritten in the process of restoring the system memory state from the suspend image ("unsafe" pages) and allocate memory for the image.
The idea is to allocate a new memory bitmap first and then allocate as many pages as needed for the image data, but not to assign these pages to specific tasks initially. Instead, we just mark them as allocated and create a lists of "safe" pages that will be used later. On systems with high memory a list of "safe" highmem pages is also created.
Definition at line 2075 of file snapshot.c.
#define PG_ANY 0 |
- on resume, for storing the PBE list and the image, we can only use memory pages that do not conflict with the pages used before suspend. The unsafe pages have PageNosaveFree set and we count them using unsafe_pages.
Each allocated image page is marked as PageNosave and PageNosaveFree so that swsusp_free() can release it.
Definition at line 88 of file snapshot.c.
#define PG_SAFE 1 |
Definition at line 89 of file snapshot.c.
#define PG_UNSAFE_CLEAR 1 |
Definition at line 90 of file snapshot.c.
#define PG_UNSAFE_KEEP 0 |
Definition at line 91 of file snapshot.c.
|
read |
mcontroller : adapter info structure for old mimd_t apps
: base address : irq number : number of logical drives : pci bus : pci device : pci function : pci id : vendor id : slot number : unique id
Definition at line 171 of file esd_usb2.c.
void __init __register_nosave_region | ( | unsigned long | start_pfn, |
unsigned long | end_pfn, | ||
int | use_kmalloc | ||
) |
register_nosave_region - register a range of page frames the contents of which should not be saved during the suspend (to be used in the early initialization code)
Definition at line 617 of file snapshot.c.
create_basic_memory_bitmaps - create bitmaps needed for marking page frames that should not be saved and free page frames. The pointers forbidden_pages_map and free_pages_map are only modified if everything goes well, because we don't want the bits to be used before both bitmaps are set up.
Definition at line 740 of file snapshot.c.
free_basic_memory_bitmaps - free memory bitmaps allocated by create_basic_memory_bitmaps(). The auxiliary pointers are necessary so that the bitmaps themselves are not referred to while they are being freed.
Definition at line 787 of file snapshot.c.
Definition at line 114 of file snapshot.c.
Definition at line 63 of file snapshot.c.
hibernate_preallocate_memory - Preallocate memory for hibernation image
To create a hibernation image it is necessary to make a copy of every page frame in use. We also need a number of page frames to be free during hibernation for allocations made while saving the image and for device drivers, in case they need to allocate memory from their hibernation callbacks (these two numbers are given by PAGES_FOR_IO (which is a rough estimate) and reserverd_size divided by PAGE_SIZE (which is tunable through /sys/power/reserved_size, respectively). To make this happen, we compute the total number of available page frames and allocate at least
([page frames total] + PAGES_FOR_IO + [metadata pages]) / 2
of them, which corresponds to the maximum size of a hibernation image.
If image_size is set below the number following from the above formula, the preallocation of memory is continued until the total number of saveable pages in the system is below the requested image size or the minimum acceptable image size returned by minimum_image_size(), whichever is greater.
Definition at line 1305 of file snapshot.c.
Definition at line 50 of file snapshot.c.
Definition at line 1646 of file snapshot.c.
int snapshot_image_loaded | ( | struct snapshot_handle * | handle | ) |
Definition at line 2300 of file snapshot.c.
int snapshot_read_next | ( | struct snapshot_handle * | handle | ) |
snapshot_read_next - used for reading the system memory snapshot.
On the first call to it should point to a zeroed snapshot_handle structure. The structure gets updated and a pointer to it should be passed to this function every next time.
On success the function returns a positive number. Then, the caller is allowed to read up to the returned number of bytes from the memory location computed by the data_of() macro.
The function returns 0 to indicate the end of data stream condition, and a negative number is returned on error. In such cases the structure pointed to by is not updated and should not be used any more.
Definition at line 1698 of file snapshot.c.
void snapshot_write_finalize | ( | struct snapshot_handle * | handle | ) |
snapshot_write_finalize - must be called after the last call to snapshot_write_next() in case the last page in the image happens to be a highmem page and its contents should be stored in the highmem. Additionally, it releases the memory that will not be used any more.
Definition at line 2287 of file snapshot.c.
int snapshot_write_next | ( | struct snapshot_handle * | handle | ) |
snapshot_write_next - used for writing the system memory snapshot.
On the first call to it should point to a zeroed snapshot_handle structure. The structure gets updated and a pointer to it should be passed to this function every next time.
On success the function returns a positive number. Then, the caller is allowed to write up to the returned number of bytes to the memory location computed by the data_of() macro.
The function returns 0 to indicate the "end of file" condition, and a negative number is returned on error. In such cases the structure pointed to by is not updated and should not be used any more.
Definition at line 2213 of file snapshot.c.
swsusp_free - free pages allocated for the suspend.
Suspend pages are alocated before the atomic copy is made, so we need to release them after the resume.
Definition at line 1089 of file snapshot.c.
Definition at line 687 of file snapshot.c.
asmlinkage int swsusp_save | ( | void | ) |
Definition at line 1579 of file snapshot.c.
Definition at line 663 of file snapshot.c.
Definition at line 675 of file snapshot.c.
unsigned int alloc_highmem |
Definition at line 1066 of file snapshot.c.
unsigned int alloc_normal |
Definition at line 1066 of file snapshot.c.
Definition at line 160 of file snapshot.c.
unsigned long image_size |
Definition at line 61 of file snapshot.c.
struct linked_page* next |
Definition at line 159 of file snapshot.c.
unsigned long reserved_size |
Definition at line 48 of file snapshot.c.
Definition at line 73 of file snapshot.c.