summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-09-22 22:12:46 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-09-22 22:12:46 +0000
commitcbfe53647e23e1ec9eb393d4716a2493ea70e874 (patch)
treecbcb43993ee11357f99af6cb8eed17f7d2537609 /sys/arch/i386
parentd1243ba8ce6a798b9298f8d2c2cb737608c5c2e8 (diff)
KNF of mlarkin's code, requested by him. Some improvements to the interface
for talking to the disk driver snuck in. ok mlarkin
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/hibernate_machdep.c67
1 files changed, 29 insertions, 38 deletions
diff --git a/sys/arch/i386/i386/hibernate_machdep.c b/sys/arch/i386/i386/hibernate_machdep.c
index 21af80dde9b..cc409067b68 100644
--- a/sys/arch/i386/i386/hibernate_machdep.c
+++ b/sys/arch/i386/i386/hibernate_machdep.c
@@ -34,9 +34,6 @@
#include <machine/kcore.h>
#include <machine/pmap.h>
-#include <dev/ata/atavar.h>
-#include <dev/ata/wdvar.h>
-
#ifdef MULTIPROCESSOR
#include <machine/mpbiosvar.h>
#endif /* MULTIPROCESSOR */
@@ -44,6 +41,11 @@
#include "acpi.h"
#include "wd.h"
+#if NWD > 0
+#include <dev/ata/atavar.h>
+#include <dev/ata/wdvar.h>
+#endif
+
/* Hibernate support */
void hibernate_enter_resume_4k_pte(vaddr_t, paddr_t);
void hibernate_enter_resume_4k_pde(vaddr_t);
@@ -54,7 +56,6 @@ extern vaddr_t hibernate_inflate_page;
extern void hibernate_resume_machdep(void);
extern void hibernate_flush(void);
-extern char *disk_readlabel(struct disklabel *, dev_t, char *, size_t);
extern caddr_t start, end;
extern int ndumpmem;
extern struct dumpmem dumpmem[];
@@ -66,20 +67,16 @@ extern struct hibernate_state *hibernate_state;
/*
* Returns the hibernate write I/O function to use on this machine
- *
*/
-void *
-get_hibernate_io_function()
+hibio_fn
+get_hibernate_io_function(void)
{
#if NWD > 0
/* XXX - Only support wd hibernate presently */
if (strcmp(findblkname(major(swdevt[0].sw_dev)), "wd") == 0)
return wd_hibernate_io;
- else
- return NULL;
-#else
- return NULL;
#endif
+ return NULL;
}
/*
@@ -94,26 +91,26 @@ get_hibernate_info_md(union hibernate_info *hiber_info)
hiber_info->nranges = ndumpmem;
hiber_info->image_size = 0;
- for(i=0; i<ndumpmem; i++) {
+ for(i = 0; i < ndumpmem; i++) {
hiber_info->ranges[i].base = dumpmem[i].start * PAGE_SIZE;
hiber_info->ranges[i].end = dumpmem[i].end * PAGE_SIZE;
hiber_info->image_size += hiber_info->ranges[i].end -
- hiber_info->ranges[i].base;
+ hiber_info->ranges[i].base;
}
#if NACPI > 0
hiber_info->ranges[hiber_info->nranges].base = ACPI_TRAMPOLINE;
- hiber_info->ranges[hiber_info->nranges].end =
- hiber_info->ranges[hiber_info->nranges].base + PAGE_SIZE;
+ hiber_info->ranges[hiber_info->nranges].end =
+ hiber_info->ranges[hiber_info->nranges].base + PAGE_SIZE;
hiber_info->image_size += PAGE_SIZE;
hiber_info->nranges ++;
#endif
#ifdef MULTIPROCESSOR
hiber_info->ranges[hiber_info->nranges].base = MP_TRAMPOLINE;
- hiber_info->ranges[hiber_info->nranges].end =
- hiber_info->ranges[hiber_info->nranges].base + PAGE_SIZE;
+ hiber_info->ranges[hiber_info->nranges].end =
+ hiber_info->ranges[hiber_info->nranges].base + PAGE_SIZE;
hiber_info->image_size += PAGE_SIZE;
-#endif
+#endif
return (0);
}
@@ -130,9 +127,8 @@ hibernate_enter_resume_mapping(vaddr_t va, paddr_t pa, int size)
{
if (size)
return hibernate_enter_resume_4m_pde(va, pa);
- else {
- return hibernate_enter_resume_4k_pte(va, pa);
- }
+ else
+ return hibernate_enter_resume_4k_pte(va, pa);
}
/*
@@ -182,7 +178,7 @@ hibernate_enter_resume_4k_pde(vaddr_t va)
*/
void
hibernate_populate_resume_pt(union hibernate_info *hib_info,
- paddr_t image_start, paddr_t image_end)
+ paddr_t image_start, paddr_t image_end)
{
int phys_page_number, i;
paddr_t pa, piglet_start, piglet_end;
@@ -204,10 +200,10 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info,
hibernate_enter_resume_4k_pde(0);
/*
- * Identity map first 640KB physical for tramps and special utility
+ * Identity map first 640KB physical for tramps and special utility
* pages using 4KB mappings
*/
- for (i=0; i < 160; i ++) {
+ for (i = 0; i < 160; i ++) {
hibernate_enter_resume_mapping(i*PAGE_SIZE, i*PAGE_SIZE, 0);
}
@@ -216,11 +212,10 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info,
*/
kern_start_4m_va = (paddr_t)&start & ~(PAGE_MASK_4M);
kern_end_4m_va = (paddr_t)&end & ~(PAGE_MASK_4M);
- phys_page_number = 0;
+ phys_page_number = 0;
- for (page = kern_start_4m_va ; page <= kern_end_4m_va ;
+ for (page = kern_start_4m_va; page <= kern_end_4m_va;
page += NBPD, phys_page_number++) {
-
pa = (paddr_t)(phys_page_number * NBPD);
hibernate_enter_resume_mapping(page, pa, 1);
}
@@ -233,7 +228,6 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info,
image_end &= ~(PAGE_MASK_4M);
for (page = image_start; page <= image_end ;
page += NBPD, phys_page_number++) {
-
pa = (paddr_t)(phys_page_number * NBPD);
hibernate_enter_resume_mapping(page, pa, 1);
}
@@ -284,24 +278,22 @@ hibernate_prepare_resume_machdep(union hibernate_info *hib_info)
* kernel, but the vaddrs used by the suspending kernel
* may or may not be available to us here in the
* resuming kernel, so we allocate a new range of VAs
- * for the piglet. Those VAs will be temporary and will
+ * for the piglet. Those VAs will be temporary and will
* cease to exist as soon as we switch to the resume
* PT, so we need to ensure that any VAs required during
- * inflate are also entered into that map.
+ * inflate are also entered into that map.
*/
hib_info->piglet_va = (vaddr_t)km_alloc(HIBERNATE_CHUNK_SIZE*3,
- &kv_any, &kp_none, &kd_nowait);
+ &kv_any, &kp_none, &kd_nowait);
if (!hib_info->piglet_va)
panic("Unable to allocate vaddr for hibernate resume piglet\n");
piglet_end = hib_info->piglet_pa + HIBERNATE_CHUNK_SIZE*3;
- for (pa = hib_info->piglet_pa,
- va = hib_info->piglet_va;
- pa <= piglet_end;
- pa += PAGE_SIZE, va += PAGE_SIZE)
- pmap_kenter_pa(va, pa, VM_PROT_ALL);
+ for (pa = hib_info->piglet_pa,va = hib_info->piglet_va;
+ pa <= piglet_end; pa += PAGE_SIZE, va += PAGE_SIZE)
+ pmap_kenter_pa(va, pa, VM_PROT_ALL);
pmap_activate(curproc);
}
@@ -321,5 +313,4 @@ hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest)
return (1);
return (0);
-}
-
+}