1 /* $OpenBSD: hibernate_var.h,v 1.6 2013/06/04 16:21:23 mlarkin Exp $ */ 2 3 /* 4 * Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /* amd64 hibernate support definitions */ 20 21 #define PAGE_MASK_2M (NBPD_L2 - 1) 22 #define PAGE_MASK_1G (NBPD_L3 - 1) 23 #define PAGE_MASK_512G (NBPD_L4 - 1) 24 25 #define PIGLET_PAGE_MASK ~((paddr_t)PAGE_MASK_2M) 26 27 /* 28 * PML4 table for resume 29 */ 30 #define HIBERNATE_PML4T (PAGE_SIZE * 5) 31 32 /* 33 * amd64 uses a PDPT to map the first 512GB phys mem plus one more 34 * to map any ranges of phys mem past 512GB (if needed) 35 */ 36 #define HIBERNATE_PDPT_LOW (PAGE_SIZE * 6) 37 #define HIBERNATE_PDPT_HI (PAGE_SIZE * 7) 38 39 /* 40 * amd64 uses one PD to map the first 1GB phys mem plus one more to map any 41 * other 1GB ranges within the first 512GB phys, plus one more to map any 42 * 1GB range in any subsequent 512GB range 43 */ 44 #define HIBERNATE_PD_LOW (PAGE_SIZE * 8) 45 #define HIBERNATE_PD_LOW2 (PAGE_SIZE * 9) 46 #define HIBERNATE_PD_HI (PAGE_SIZE * 10) 47 48 /* 49 * amd64 uses one PT to map the first 2MB phys mem plus one more to map any 50 * other 2MB range within the first 1GB, plus one more to map any 2MB range 51 * in any subsequent 512GB range. 52 */ 53 #define HIBERNATE_PT_LOW (PAGE_SIZE * 11) 54 #define HIBERNATE_PT_LOW2 (PAGE_SIZE * 12) 55 #define HIBERNATE_PT_HI (PAGE_SIZE * 13) 56 57 #define HIBERNATE_SELTABLE (PAGE_SIZE * 14) 58 59 /* 3 pages for stack */ 60 #define HIBERNATE_STACK_PAGE (PAGE_SIZE * 17) 61 62 #define HIBERNATE_INFLATE_PAGE (PAGE_SIZE * 18) 63 /* HIBERNATE_HIBALLOC_PAGE must be the last stolen page (see machdep.c) */ 64 #define HIBERNATE_HIBALLOC_PAGE (PAGE_SIZE * 19) 65 66 /* Use 4MB hibernation chunks */ 67 #define HIBERNATE_CHUNK_SIZE 0x400000 68 69 #define HIBERNATE_CHUNK_TABLE_SIZE 0x100000 70 71 #define HIBERNATE_STACK_OFFSET 0x0F00 72