diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-10-01 19:41:07 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-10-01 19:41:07 +0000 |
commit | 95191566ee44da1185220414cc037649100ef2d0 (patch) | |
tree | f6542ca00a949eb6e046a2f6997775bef9aa4b9a /sys | |
parent | 9d4a1503dea09860c97621368f5ccdef8eab6415 (diff) |
Move some hibernate #defines to pte.h and eliminate some duplicate defines
from hibernate code that were already defined in pte.h (with different
names). No functional change.
ok sf@, deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/hibernate_machdep.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/include/hibernate_var.h | 10 | ||||
-rw-r--r-- | sys/arch/amd64/include/pte.h | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/hibernate_machdep.c | 12 | ||||
-rw-r--r-- | sys/arch/i386/include/hibernate_var.h | 12 | ||||
-rw-r--r-- | sys/arch/i386/include/pte.h | 4 |
6 files changed, 20 insertions, 28 deletions
diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c index be69a7ebb96..bea8a7c60f1 100644 --- a/sys/arch/amd64/amd64/hibernate_machdep.c +++ b/sys/arch/amd64/amd64/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.28 2014/07/20 19:47:53 deraadt Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.29 2014/10/01 19:41:06 mlarkin Exp $ */ /* * Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org> @@ -329,8 +329,8 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, /* * Map current kernel VA range using 2MB pages */ - kern_start_2m_va = (paddr_t)&start & ~(PAGE_MASK_2M); - kern_end_2m_va = (paddr_t)&end & ~(PAGE_MASK_2M); + kern_start_2m_va = (paddr_t)&start & ~(PAGE_MASK_L2); + kern_end_2m_va = (paddr_t)&end & ~(PAGE_MASK_L2); /* amd64 kernels load at 16MB phys (on the 8th 2mb page) */ phys_page_number = 8; diff --git a/sys/arch/amd64/include/hibernate_var.h b/sys/arch/amd64/include/hibernate_var.h index c822f195357..bc63cff9b59 100644 --- a/sys/arch/amd64/include/hibernate_var.h +++ b/sys/arch/amd64/include/hibernate_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_var.h,v 1.8 2014/01/05 23:06:54 mlarkin Exp $ */ +/* $OpenBSD: hibernate_var.h,v 1.9 2014/10/01 19:41:06 mlarkin Exp $ */ /* * Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org> @@ -16,13 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* amd64 hibernate support definitions */ - -#define PAGE_MASK_2M (NBPD_L2 - 1) -#define PAGE_MASK_1G (NBPD_L3 - 1) -#define PAGE_MASK_512G (NBPD_L4 - 1) - -#define PIGLET_PAGE_MASK ~((paddr_t)PAGE_MASK_2M) +#define PIGLET_PAGE_MASK (L2_FRAME) /* * PML4 table for resume diff --git a/sys/arch/amd64/include/pte.h b/sys/arch/amd64/include/pte.h index acdb7535c62..96207c265e3 100644 --- a/sys/arch/amd64/include/pte.h +++ b/sys/arch/amd64/include/pte.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pte.h,v 1.10 2014/04/21 11:58:48 guenther Exp $ */ +/* $OpenBSD: pte.h,v 1.11 2014/10/01 19:41:06 mlarkin Exp $ */ /* $NetBSD: pte.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */ /* @@ -97,6 +97,8 @@ typedef u_int64_t pt_entry_t; /* PTE */ #define L2_FRAME (L3_FRAME|L2_MASK) #define L1_FRAME (L2_FRAME|L1_MASK) +#define PAGE_MASK_L2 (NBPD_L2 - 1) + #define x86_round_pdr(x) \ ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) diff --git a/sys/arch/i386/i386/hibernate_machdep.c b/sys/arch/i386/i386/hibernate_machdep.c index b9817d5e99d..e87484d031d 100644 --- a/sys/arch/i386/i386/hibernate_machdep.c +++ b/sys/arch/i386/i386/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.38 2014/07/20 19:47:53 deraadt Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.39 2014/10/01 19:41:06 mlarkin Exp $ */ /* * Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org> @@ -193,7 +193,7 @@ hibernate_enter_resume_4m_pde(vaddr_t va, paddr_t pa) pt_entry_t *pde, npde; pde = s4pde_4m(va); - npde = (pa & PMAP_PA_MASK_4M) | PG_RW | PG_V | PG_M | PG_PS; + npde = (pa & PD_MASK) | PG_RW | PG_V | PG_M | PG_PS; *pde = npde; } @@ -261,8 +261,8 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, /* * Map current kernel VA range using 4M pages */ - kern_start_4m_va = (paddr_t)&start & ~(PAGE_MASK_4M); - kern_end_4m_va = (paddr_t)&end & ~(PAGE_MASK_4M); + kern_start_4m_va = (paddr_t)&start & ~(PAGE_MASK_L2); + kern_end_4m_va = (paddr_t)&end & ~(PAGE_MASK_L2); /* i386 kernels load at 2MB phys (on the 0th 4mb page) */ phys_page_number = 0; @@ -277,8 +277,8 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, * Identity map the image (pig) area */ phys_page_number = image_start / NBPD; - image_start &= ~(PAGE_MASK_4M); - image_end &= ~(PAGE_MASK_4M); + image_start &= ~(PAGE_MASK_L2); + image_end &= ~(PAGE_MASK_L2); for (page = image_start; page <= image_end ; page += NBPD, phys_page_number++) { pa = (paddr_t)(phys_page_number * NBPD); diff --git a/sys/arch/i386/include/hibernate_var.h b/sys/arch/i386/include/hibernate_var.h index 34c589d37d7..df8839de34b 100644 --- a/sys/arch/i386/include/hibernate_var.h +++ b/sys/arch/i386/include/hibernate_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_var.h,v 1.9 2014/01/05 20:23:57 mlarkin Exp $ */ +/* $OpenBSD: hibernate_var.h,v 1.10 2014/10/01 19:41:06 mlarkin Exp $ */ /* * Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org> @@ -16,13 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* i386 hibernate support definitions */ - -#define PAGE_SHIFT_4M 22 -#define PAGE_MASK_4M (NBPD - 1) -#define PMAP_PA_MASK_4M ~((paddr_t)PAGE_MASK_4M) - -#define PIGLET_PAGE_MASK ~((paddr_t)PAGE_MASK_4M) +#define PIGLET_PAGE_MASK (PD_MASK) #define HIBERNATE_PD_PAGE (PAGE_SIZE * 18) #define HIBERNATE_PT_PAGE (PAGE_SIZE * 19) @@ -39,7 +33,7 @@ #define HIBERNATE_STACK_OFFSET 0x0F00 -#define atop_4m(x) ((x) >> PAGE_SHIFT_4M) +#define atop_4m(x) ((x) >> PDSHIFT) #define atop_4k(x) ((x) >> PAGE_SHIFT) #define s4pde_4m(va) ((pt_entry_t *)HIBERNATE_PD_PAGE + atop_4m(va)) #define s4pde_4k(va) ((pt_entry_t *)HIBERNATE_PD_PAGE + atop_4k(va)) diff --git a/sys/arch/i386/include/pte.h b/sys/arch/i386/include/pte.h index 207540737fd..b8f8a419ebc 100644 --- a/sys/arch/i386/include/pte.h +++ b/sys/arch/i386/include/pte.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pte.h,v 1.15 2014/07/11 16:35:40 jsg Exp $ */ +/* $OpenBSD: pte.h,v 1.16 2014/10/01 19:41:06 mlarkin Exp $ */ /* $NetBSD: pte.h,v 1.11 1998/02/06 21:58:05 thorpej Exp $ */ /* @@ -147,6 +147,8 @@ typedef u_int32_t pt_entry_t; /* PTE */ #define PD_MASK 0xffc00000 /* page directory address bits */ #define PT_MASK 0x003ff000 /* page table address bits */ +#define PAGE_MASK_L2 (NBPD - 1) + #define i386_round_pdr(x) ((((unsigned)(x)) + PDOFSET) & ~PDOFSET) /* |