diff options
-rw-r--r-- | sys/kern/subr_hibernate.c | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c index c5b1d39918f..a3007fe591e 100644 --- a/sys/kern/subr_hibernate.c +++ b/sys/kern/subr_hibernate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_hibernate.c,v 1.49 2013/01/17 02:36:45 deraadt Exp $ */ +/* $OpenBSD: subr_hibernate.c,v 1.50 2013/01/17 02:51:08 pirofti Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -693,7 +693,8 @@ get_hibernate_info(union hibernate_info *hiber_info, int suspend) return (0); fail: if (suspend) - uvm_pmr_free_piglet(hiber_info->piglet_va, HIBERNATE_CHUNK_SIZE*3); + uvm_pmr_free_piglet(hiber_info->piglet_va, + HIBERNATE_CHUNK_SIZE * 3); return (1); } @@ -701,12 +702,13 @@ fail: /* * Allocate nitems*size bytes from the hiballoc area presently in use */ -void -*hibernate_zlib_alloc(void *unused, int nitems, int size) +void * +hibernate_zlib_alloc(void *unused, int nitems, int size) { struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; return hib_alloc(&hibernate_state->hiballoc_arena, nitems*size); } @@ -720,7 +722,8 @@ hibernate_zlib_free(void *unused, void *addr) { struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; hib_free(&hibernate_state->hiballoc_arena, addr); } @@ -734,7 +737,8 @@ hibernate_get_next_rle(void) int rle, i; struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; /* Read RLE code */ hibernate_state->hib_stream.next_out = (char *)&rle; @@ -768,7 +772,8 @@ hibernate_inflate_page(void) struct hibernate_zlib_state *hibernate_state; int i; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; /* Set up the stream for inflate */ hibernate_state->hib_stream.next_out = (char *)HIBERNATE_INFLATE_PAGE; @@ -807,7 +812,8 @@ hibernate_inflate_region(union hibernate_info *hiber_info, paddr_t dest, int end_stream = 0 ; struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; hibernate_state->hib_stream.next_in = (char *)src; hibernate_state->hib_stream.avail_in = size; @@ -850,7 +856,8 @@ hibernate_deflate(union hibernate_info *hiber_info, paddr_t src, vaddr_t hibernate_io_page = hiber_info->piglet_va + PAGE_SIZE; struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; /* Set up the stream for deflate */ hibernate_state->hib_stream.next_in = (caddr_t)src; @@ -1167,7 +1174,8 @@ hibernate_unpack_image(union hibernate_info *hiber_info) char *pva = (char *)hiber_info->piglet_va; struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; /* Mask off based on arch-specific piglet page size */ pva = (char *)((paddr_t)pva & (PIGLET_PAGE_MASK)); @@ -1277,7 +1285,8 @@ hibernate_write_chunks(union hibernate_info *hiber_info) int i; struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; hiber_info->chunk_ctr = 0; @@ -1364,18 +1373,22 @@ hibernate_write_chunks(union hibernate_info *hiber_info) pmap_activate(curproc); bcopy((caddr_t)hibernate_temp_page, - (caddr_t)hibernate_copy_page, PAGE_SIZE); + (caddr_t)hibernate_copy_page, + PAGE_SIZE); inaddr += hibernate_deflate(hiber_info, temp_inaddr, &out_remaining); } if (out_remaining == 0) { /* Filled up the page */ - nblocks = PAGE_SIZE / hiber_info->secsize; + nblocks = + PAGE_SIZE / hiber_info->secsize; - if (hiber_info->io_func(hiber_info->device, + if (hiber_info->io_func( + hiber_info->device, blkctr, (vaddr_t)hibernate_io_page, - PAGE_SIZE, HIB_W, hiber_info->io_page)) + PAGE_SIZE, HIB_W, + hiber_info->io_page)) return (1); blkctr += nblocks; @@ -1444,7 +1457,8 @@ hibernate_zlib_reset(union hibernate_info *hiber_info, int deflate) char *pva = (char *)hiber_info->piglet_va; struct hibernate_zlib_state *hibernate_state; - hibernate_state = (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; + hibernate_state = + (struct hibernate_zlib_state *)HIBERNATE_HIBALLOC_PAGE; if(!deflate) pva = (char *)((paddr_t)pva & (PIGLET_PAGE_MASK)); @@ -1510,7 +1524,8 @@ hibernate_read_image(union hibernate_info *hiber_info) /* Read the chunktable from disk into the piglet chunktable */ for (i = 0; i < HIBERNATE_CHUNK_TABLE_SIZE; i += PAGE_SIZE, blkctr += PAGE_SIZE/hiber_info->secsize) { - pmap_kenter_pa(chunktable + i, piglet_chunktable + i, VM_PROT_ALL); + pmap_kenter_pa(chunktable + i, piglet_chunktable + i, + VM_PROT_ALL); pmap_update(pmap_kernel()); hibernate_block_io(hiber_info, blkctr, PAGE_SIZE, chunktable + i, 0); @@ -1687,10 +1702,12 @@ hibernate_read_chunks(union hibernate_info *hib_info, paddr_t pig_start, j = i; while (copy_start < copy_end && j < nochunks) { - piglet_cur += chunks[ochunks[j]].compressed_size; + piglet_cur += + chunks[ochunks[j]].compressed_size; pchunks[npchunks] = ochunks[j]; npchunks++; - copy_start += chunks[ochunks[j]].compressed_size; + copy_start += + chunks[ochunks[j]].compressed_size; img_index += chunks[ochunks[j]].compressed_size; i++; j++; @@ -1698,9 +1715,11 @@ hibernate_read_chunks(union hibernate_info *hib_info, paddr_t pig_start, piglet_cur = piglet_base; for (j = 0; j < npchunks; j++) { - piglet_cur += chunks[pchunks[j]].compressed_size; + piglet_cur += + chunks[pchunks[j]].compressed_size; fchunks[nfchunks] = pchunks[j]; - chunks[pchunks[j]].flags |= HIBERNATE_CHUNK_USED; + chunks[pchunks[j]].flags |= + HIBERNATE_CHUNK_USED; nfchunks++; } } else { @@ -1710,7 +1729,8 @@ hibernate_read_chunks(union hibernate_info *hib_info, paddr_t pig_start, if ((chunks[ochunks[i]].flags & HIBERNATE_CHUNK_USED) == 0) { fchunks[nfchunks] = ochunks[i]; - chunks[ochunks[i]].flags |= HIBERNATE_CHUNK_USED; + chunks[ochunks[i]].flags |= + HIBERNATE_CHUNK_USED; nfchunks++; } img_index += chunks[ochunks[i]].compressed_size; |