diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ata/ata_wdc.c | 12 | ||||
-rw-r--r-- | sys/kern/subr_hibernate.c | 14 | ||||
-rw-r--r-- | sys/sys/hibernate.h | 5 |
3 files changed, 20 insertions, 11 deletions
diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c index 83c4e61b9db..88bc1a51b85 100644 --- a/sys/dev/ata/ata_wdc.c +++ b/sys/dev/ata/ata_wdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ata_wdc.c,v 1.41 2011/09/22 22:12:45 deraadt Exp $ */ +/* $OpenBSD: ata_wdc.c,v 1.42 2011/11/13 23:13:28 mlarkin Exp $ */ /* $NetBSD: ata_wdc.c,v 1.21 1999/08/09 09:43:11 bouyer Exp $ */ /* @@ -77,6 +77,10 @@ #include <dev/ic/wdcvar.h> #include <dev/ata/wdvar.h> +#ifdef HIBERNATE +#include <sys/hibernate.h> +#endif + #define DEBUG_INTR 0x01 #define DEBUG_XFERS 0x02 #define DEBUG_STATUS 0x04 @@ -109,8 +113,9 @@ int wdc_ata_err(struct ata_drive_datas *, struct ata_bio *); #define WDC_ATA_RECOV 0x01 /* There was a recovered error */ #define WDC_ATA_ERR 0x02 /* Drive reports an error */ +#ifdef HIBERNATE int -wd_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int wr, void *page) +wd_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int op, void *page) { struct { struct wd_softc wd; @@ -144,7 +149,7 @@ wd_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int wr, voi /* Fill the request and submit it */ wd->sc_wdc_bio.blkno = blkno; wd->sc_wdc_bio.flags = ATA_POLL | ATA_LBA48; - if (wr == 0) + if (op == HIB_R) wd->sc_wdc_bio.flags |= ATA_READ; wd->sc_wdc_bio.bcount = size; wd->sc_wdc_bio.databuf = (caddr_t)addr; @@ -163,6 +168,7 @@ wd_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int wr, voi wdc_exec_xfer(chp, xfer); return (ata_bio->flags & ATA_ITSDONE) ? 0 : 1; } +#endif /* HIBERNATE */ /* * Handle block I/O operation. Return WDC_COMPLETE, WDC_QUEUED, or diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c index dafc5e1fea0..4a0e0f72c8d 100644 --- a/sys/kern/subr_hibernate.c +++ b/sys/kern/subr_hibernate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_hibernate.c,v 1.20 2011/11/13 22:36:27 mlarkin Exp $ */ +/* $OpenBSD: subr_hibernate.c,v 1.21 2011/11/13 23:13:29 mlarkin Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -794,7 +794,7 @@ hibernate_write_signature(union hibernate_info *hiber_info) /* Write hibernate info to disk */ if (hiber_info->io_func(hiber_info->device, hiber_info->sig_offset, - (vaddr_t)hiber_info, hiber_info->secsize, 1, io_page)) + (vaddr_t)hiber_info, hiber_info->secsize, HIB_W, io_page)) result = 1; free(io_page, M_DEVBUF); @@ -836,7 +836,7 @@ hibernate_write_chunktable(union hibernate_info *hiber_info) if (hiber_info->io_func(hiber_info->device, chunkbase + (i/hiber_info->secsize), (vaddr_t)(hibernate_chunk_table_start + i), - MAXPHYS, 1, io_page)) { + MAXPHYS, HIB_W, io_page)) { free(io_page, M_DEVBUF); return (1); } @@ -870,7 +870,7 @@ hibernate_clear_signature(void) /* Write (zeroed) hibernate info to disk */ /* XXX - use regular kernel write routine for this */ if (hiber_info.io_func(hiber_info.device, hiber_info.sig_offset, - (vaddr_t)&blank_hiber_info, hiber_info.secsize, 1, io_page)) + (vaddr_t)&blank_hiber_info, hiber_info.secsize, HIB_W, io_page)) panic("error hibernate write 6\n"); free(io_page, M_DEVBUF); @@ -1027,7 +1027,7 @@ hibernate_resume(void) /* XXX use regular kernel read routine here */ if (hiber_info.io_func(hiber_info.device, hiber_info.sig_offset, - (vaddr_t)&disk_hiber_info, hiber_info.secsize, 0, io_page)) + (vaddr_t)&disk_hiber_info, hiber_info.secsize, HIB_R, io_page)) panic("error in hibernate read\n"); free(io_page, M_DEVBUF); @@ -1316,7 +1316,7 @@ hibernate_write_chunks(union hibernate_info *hiber_info) if (hiber_info->io_func(hiber_info->device, blkctr, (vaddr_t)hibernate_io_page, - PAGE_SIZE, 1, (void *)hibernate_alloc_page)) + PAGE_SIZE, HIB_W, (void *)hibernate_alloc_page)) return (1); blkctr += nblocks; @@ -1356,7 +1356,7 @@ hibernate_write_chunks(union hibernate_info *hiber_info) /* Write final block(s) for this chunk */ if (hiber_info->io_func(hiber_info->device, blkctr, (vaddr_t)hibernate_io_page, nblocks*hiber_info->secsize, - 1, (void *)hibernate_alloc_page)) + HIB_W, (void *)hibernate_alloc_page)) return (1); blkctr += nblocks; diff --git a/sys/sys/hibernate.h b/sys/sys/hibernate.h index dd7b00bf0b0..9d0a1bd4023 100644 --- a/sys/sys/hibernate.h +++ b/sys/sys/hibernate.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate.h,v 1.15 2011/11/13 22:36:27 mlarkin Exp $ */ +/* $OpenBSD: hibernate.h,v 1.16 2011/11/13 23:13:29 mlarkin Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -65,6 +65,9 @@ struct hibernate_disk_chunk { short flags; /* Flags */ }; +#define HIB_INIT -1 +#define HIB_R 0 +#define HIB_W 1 typedef int (*hibio_fn)(dev_t, daddr_t, vaddr_t, size_t, int, void *); /* |