summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2015-07-19 16:12:11 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2015-07-19 16:12:11 +0000
commita1e6d89b0067d68adc48bbc68959c3287d104561 (patch)
tree68a5cb55cbcd6d7bedb048efc39a8f8f4733432d /sys/arch
parentba4d3248f452954f0223beb7f47812a30527289d (diff)
Use DEV_BSIZE instead of 512 where appropriate. Use DL_SECTOBLK()
where appropriate. Noop for disks with 512-byte sectors. i.e. the only kind currently allowed in softraid volumes. But starts laying the groundwork to allow disks with other sector sizes. ok jsing@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/stand/libsa/softraid.c11
-rw-r--r--sys/arch/i386/stand/libsa/softraid.c11
-rw-r--r--sys/arch/sparc64/stand/ofwboot/softraid.c21
3 files changed, 23 insertions, 20 deletions
diff --git a/sys/arch/amd64/stand/libsa/softraid.c b/sys/arch/amd64/stand/libsa/softraid.c
index 16582514cd4..89fea751496 100644
--- a/sys/arch/amd64/stand/libsa/softraid.c
+++ b/sys/arch/amd64/stand/libsa/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.9 2015/05/29 13:54:26 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.10 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -150,7 +150,7 @@ srprobe(void)
SLIST_INIT(&sr_volumes);
SLIST_INIT(&sr_keydisks);
- md = alloc(SR_META_SIZE * 512);
+ md = alloc(SR_META_SIZE * DEV_BSIZE);
TAILQ_FOREACH(dip, &disklist, list) {
@@ -170,8 +170,9 @@ srprobe(void)
continue;
/* Read softraid metadata. */
- bzero(md, SR_META_SIZE * 512);
- off = DL_GETPOFFSET(pp) + SR_META_OFFSET;
+ bzero(md, SR_META_SIZE * DEV_BSIZE);
+ off = DL_SECTOBLK(&dip->disklabel, DL_GETPOFFSET(pp));
+ off += SR_META_OFFSET;
error = biosd_io(F_READ, &dip->bios_info, off,
SR_META_SIZE, md);
if (error)
@@ -314,7 +315,7 @@ srprobe(void)
bv->sbv_flags & BIOC_SCBOOTABLE ? "*" : "");
}
- explicit_bzero(md, SR_META_SIZE * 512);
+ explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
free(md, 0);
}
diff --git a/sys/arch/i386/stand/libsa/softraid.c b/sys/arch/i386/stand/libsa/softraid.c
index 16582514cd4..89fea751496 100644
--- a/sys/arch/i386/stand/libsa/softraid.c
+++ b/sys/arch/i386/stand/libsa/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.9 2015/05/29 13:54:26 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.10 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -150,7 +150,7 @@ srprobe(void)
SLIST_INIT(&sr_volumes);
SLIST_INIT(&sr_keydisks);
- md = alloc(SR_META_SIZE * 512);
+ md = alloc(SR_META_SIZE * DEV_BSIZE);
TAILQ_FOREACH(dip, &disklist, list) {
@@ -170,8 +170,9 @@ srprobe(void)
continue;
/* Read softraid metadata. */
- bzero(md, SR_META_SIZE * 512);
- off = DL_GETPOFFSET(pp) + SR_META_OFFSET;
+ bzero(md, SR_META_SIZE * DEV_BSIZE);
+ off = DL_SECTOBLK(&dip->disklabel, DL_GETPOFFSET(pp));
+ off += SR_META_OFFSET;
error = biosd_io(F_READ, &dip->bios_info, off,
SR_META_SIZE, md);
if (error)
@@ -314,7 +315,7 @@ srprobe(void)
bv->sbv_flags & BIOC_SCBOOTABLE ? "*" : "");
}
- explicit_bzero(md, SR_META_SIZE * 512);
+ explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
free(md, 0);
}
diff --git a/sys/arch/sparc64/stand/ofwboot/softraid.c b/sys/arch/sparc64/stand/ofwboot/softraid.c
index 9308a8475ef..296c1016dc9 100644
--- a/sys/arch/sparc64/stand/ofwboot/softraid.c
+++ b/sys/arch/sparc64/stand/ofwboot/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.1 2014/11/26 19:50:03 stsp Exp $ */
+/* $OpenBSD: softraid.c,v 1.2 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -151,7 +151,7 @@ srprobe(void)
SLIST_INIT(&sr_volumes);
SLIST_INIT(&sr_keydisks);
- md = alloc(SR_META_SIZE * 512);
+ md = alloc(SR_META_SIZE * DEV_BSIZE);
diskno = 0;
ihandle = -1;
TAILQ_FOREACH(dip, &disklist, list) {
@@ -168,13 +168,14 @@ srprobe(void)
continue;
/* Read softraid metadata. */
- bzero(md, SR_META_SIZE * 512);
- ofdev.partoff = DL_GETPOFFSET(pp);
+ bzero(md, SR_META_SIZE * DEV_BSIZE);
+ ofdev.partoff = DL_SECTOBLK(&dip->disklabel,
+ DL_GETPOFFSET(pp));
error = strategy(&ofdev, F_READ, SR_META_OFFSET,
- SR_META_SIZE * 512, md, &read);
- if (error || read != SR_META_SIZE * 512)
+ SR_META_SIZE * DEV_BSIZE, md, &read);
+ if (error || read != SR_META_SIZE * DEV_BSIZE)
continue;
-
+
/* Is this valid softraid metadata? */
if (md->ssdi.ssd_magic != SR_MAGIC)
continue;
@@ -315,8 +316,8 @@ srprobe(void)
bv->sbv_flags & BIOC_SCBOOTABLE ? "*" : "");
}
- explicit_bzero(md, SR_META_SIZE * 512);
- free(md, SR_META_SIZE * 512);
+ explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
+ free(md, SR_META_SIZE * DEV_BSIZE);
}
int
@@ -334,7 +335,7 @@ sr_strategy(struct sr_boot_volume *bv, int rw, daddr32_t blk, size_t size,
u_char *bp;
int err;
int ihandle;
-
+
/* We only support read-only softraid. */
if (rw != F_READ)
return ENOTSUP;