Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
power.h File Reference
#include <linux/suspend.h>
#include <linux/suspend_ioctls.h>
#include <linux/utsname.h>
#include <linux/freezer.h>

Go to the source code of this file.

Data Structures

struct  swsusp_info
 
struct  snapshot_handle
 

Macros

#define power_attr(_name)
 
#define data_of(handle)   ((handle).buffer)
 
#define SF_PLATFORM_MODE   1
 
#define SF_NOCOMPRESS_MODE   2
 
#define SF_CRC32_MODE   4
 
#define TEST_FIRST   TEST_NONE
 
#define TEST_MAX   (__TEST_AFTER_LAST - 1)
 

Enumerations

enum  {
  TEST_NONE, TEST_CORE, TEST_CPUS, TEST_PLATFORM,
  TEST_DEVICES, TEST_FREEZER, __TEST_AFTER_LAST
}
 

Functions

struct swsusp_info __attribute__ ((aligned(PAGE_SIZE)))
 
int pfn_is_nosave (unsigned long)
 
asmlinkage int swsusp_arch_suspend (void)
 
asmlinkage int swsusp_arch_resume (void)
 
int create_basic_memory_bitmaps (void)
 
void free_basic_memory_bitmaps (void)
 
int hibernate_preallocate_memory (void)
 
unsigned int snapshot_additional_pages (struct zone *zone)
 
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)
 
sector_t alloc_swapdev_block (int swap)
 
void free_all_swap_pages (int swap)
 
int swsusp_swap_in_use (void)
 
int swsusp_check (void)
 
void swsusp_free (void)
 
int swsusp_read (unsigned int *flags_p)
 
int swsusp_write (unsigned int flags)
 
void swsusp_close (fmode_t)
 
int hib_bio_read_page (pgoff_t page_off, void *addr, struct bio **bio_chain)
 
int hib_bio_write_page (pgoff_t page_off, void *addr, struct bio **bio_chain)
 
int hib_wait_on_bio_chain (struct bio **bio_chain)
 
void swsusp_show_speed (struct timeval *, struct timeval *, unsigned int, char *)
 

Variables

struct new_utsname uts
 
u32 version_code
 
unsigned long num_physpages
 
int cpus
 
unsigned long image_pages
 
unsigned long pages
 
unsigned long size
 
unsigned long image_size
 
unsigned long reserved_size
 
int in_suspend
 
dev_t swsusp_resume_device
 
sector_t swsusp_resume_block
 
struct snapshot_handle __attribute__
 
atomic_t snapshot_device_available
 
struct block_devicehib_resume_bdev
 
int pm_test_level
 

Macro Definition Documentation

#define data_of (   handle)    ((handle).buffer)

Definition at line 129 of file power.h.

#define power_attr (   _name)
Value:
static struct kobj_attribute _name##_attr = { \
.attr = { \
.name = __stringify(_name), \
.mode = 0644, \
}, \
.show = _name##_show, \
.store = _name##_store, \
}

Definition at line 67 of file power.h.

#define SF_CRC32_MODE   4

Definition at line 151 of file power.h.

#define SF_NOCOMPRESS_MODE   2

Definition at line 150 of file power.h.

#define SF_PLATFORM_MODE   1

Definition at line 149 of file power.h.

#define TEST_FIRST   TEST_NONE

Definition at line 227 of file power.h.

#define TEST_MAX   (__TEST_AFTER_LAST - 1)

Definition at line 228 of file power.h.

Enumeration Type Documentation

anonymous enum
Enumerator:
TEST_NONE 
TEST_CORE 
TEST_CPUS 
TEST_PLATFORM 
TEST_DEVICES 
TEST_FREEZER 
__TEST_AFTER_LAST 

Definition at line 215 of file power.h.

Function Documentation

sector_t alloc_swapdev_block ( int  swap)

alloc_swapdev_block - allocate a swap page and register that it has been allocated, so that it can be freed in case of an error.

Definition at line 167 of file swap.c.

int create_basic_memory_bitmaps ( void  )

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.

void free_all_swap_pages ( int  swap)

free_all_swap_pages - free swap pages allocated for saving image data. It also frees the extents used to register which swap entries had been allocated.

Definition at line 187 of file swap.c.

void free_basic_memory_bitmaps ( void  )

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.

int hib_bio_read_page ( pgoff_t  page_off,
void addr,
struct bio **  bio_chain 
)

Definition at line 65 of file block_io.c.

int hib_bio_write_page ( pgoff_t  page_off,
void addr,
struct bio **  bio_chain 
)

Definition at line 71 of file block_io.c.

int hib_wait_on_bio_chain ( struct bio **  bio_chain)

Definition at line 77 of file block_io.c.

int hibernate_preallocate_memory ( void  )

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.

int pfn_is_nosave ( unsigned  long)

Definition at line 37 of file cpu.c.

unsigned int snapshot_additional_pages ( struct zone zone)

snapshot_additional_pages - estimate the number of additional pages be needed for setting up the suspend image data structures for given zone (usually the returned value is greater than the exact number)

Definition at line 811 of file snapshot.c.

unsigned long snapshot_get_image_size ( void  )

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.

asmlinkage int swsusp_arch_resume ( void  )

Definition at line 122 of file hibernate.c.

asmlinkage int swsusp_arch_suspend ( void  )
int swsusp_check ( void  )

swsusp_check - Check for swsusp signature in the resume device

Definition at line 1423 of file swap.c.

void swsusp_close ( fmode_t  mode)

swsusp_close - close swap device.

Definition at line 1465 of file swap.c.

void swsusp_free ( void  )

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.

int swsusp_read ( unsigned int flags_p)

swsusp_read - read the hibernation image. : flags passed by the "frozen" kernel in the image header should be written into this memory location

Definition at line 1388 of file swap.c.

void swsusp_show_speed ( struct timeval start,
struct timeval stop,
unsigned  nr_pages,
char msg 
)

swsusp_show_speed - Print time elapsed between two events during hibernation. : Starting event. : Final event. : Number of memory pages processed between and . : Additional diagnostic message to print.

Definition at line 227 of file hibernate.c.

int swsusp_swap_in_use ( void  )

Definition at line 204 of file swap.c.

int swsusp_write ( unsigned int  flags)

swsusp_write - Write entire image and metadata. : flags to pass to the "boot" kernel in the image header

It is important NOT to umount filesystems at this point. We want them synced (in case something goes wrong) but we DO not want to mark filesystem clean: it is not. (And it does not matter, if we resume correctly, we'll mark system clean, anyway.)

Definition at line 813 of file swap.c.

Variable Documentation

int cpus

Definition at line 18 of file power.h.

struct block_device* hib_resume_bdev

Definition at line 214 of file swap.c.

unsigned long image_pages

Definition at line 19 of file power.h.

unsigned long image_size

Definition at line 63 of file rbd_types.h.

int in_suspend
unsigned long num_physpages

Definition at line 17 of file power.h.

unsigned long pages

Definition at line 20 of file power.h.

int pm_test_level
unsigned long reserved_size

Definition at line 48 of file snapshot.c.

unsigned long size

Definition at line 21 of file power.h.

atomic_t snapshot_device_available

Definition at line 44 of file user.c.

sector_t swsusp_resume_block

Definition at line 41 of file hibernate.c.

dev_t swsusp_resume_device

Definition at line 40 of file hibernate.c.

Definition at line 15 of file power.h.

u32 version_code

Definition at line 16 of file power.h.