summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2013-05-30 01:19:02 +0000
committerbrooks <brooks@FreeBSD.org>2013-05-30 01:19:02 +0000
commiteeccce259710f21dd4331291eca8fc9fdfc64b33 (patch)
treec0dc4418ff074c0c5b850ce03d4d99f57bfb58b5
parentf463a4083c29543a7119bf2b1872530b83f819f1 (diff)
downloadFreeBSD-src-eeccce259710f21dd4331291eca8fc9fdfc64b33.zip
FreeBSD-src-eeccce259710f21dd4331291eca8fc9fdfc64b33.tar.gz
MFP4 @222836
Add support for partitioning CFI disks from FDT using geom_flashmap. Sponsored by: DARPA, AFRL
-rw-r--r--sys/dev/cfi/cfi_disk.c28
-rw-r--r--sys/geom/geom_flashmap.c7
2 files changed, 33 insertions, 2 deletions
diff --git a/sys/dev/cfi/cfi_disk.c b/sys/dev/cfi/cfi_disk.c
index 55f78ea..723d1ae 100644
--- a/sys/dev/cfi/cfi_disk.c
+++ b/sys/dev/cfi/cfi_disk.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <dev/cfi/cfi_var.h>
+#include <geom/geom.h>
#include <geom/geom_disk.h>
struct cfi_disk_softc {
@@ -64,6 +65,7 @@ static int cfi_disk_detach(device_t);
static int cfi_disk_open(struct disk *);
static int cfi_disk_close(struct disk *);
static void cfi_io_proc(void *, int);
+static int cfi_disk_getattr(struct bio *);
static void cfi_disk_strategy(struct bio *);
static int cfi_disk_ioctl(struct disk *, u_long, void *, int, struct thread *);
@@ -95,6 +97,7 @@ cfi_disk_attach(device_t dev)
sc->disk->d_strategy = cfi_disk_strategy;
sc->disk->d_ioctl = cfi_disk_ioctl;
sc->disk->d_dump = NULL; /* NB: no dumps */
+ sc->disk->d_getattr = cfi_disk_getattr;
sc->disk->d_sectorsize = CFI_DISK_SECSIZE;
sc->disk->d_mediasize = sc->parent->sc_size;
sc->disk->d_maxsize = CFI_DISK_MAXIOSIZE;
@@ -275,6 +278,31 @@ cfi_io_proc(void *arg, int pending)
}
}
+static int
+cfi_disk_getattr(struct bio *bp)
+{
+ struct cfi_disk_softc *dsc;
+ struct cfi_softc *sc;
+ device_t dev;
+
+ if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL)
+ return (ENXIO);
+
+ dsc = bp->bio_disk->d_drv1;
+ sc = dsc->parent;
+ dev = sc->sc_dev;
+
+ do {
+ if (g_handleattr(bp, "CFI::device", &dev, sizeof(device_t)))
+ break;
+
+ return (ERESTART);
+ } while(0);
+
+ return (EJUSTRETURN);
+}
+
+
static void
cfi_disk_strategy(struct bio *bp)
{
diff --git a/sys/geom/geom_flashmap.c b/sys/geom/geom_flashmap.c
index 11e25b4..58d0b65 100644
--- a/sys/geom/geom_flashmap.c
+++ b/sys/geom/geom_flashmap.c
@@ -186,8 +186,11 @@ g_flashmap_taste(struct g_class *mp, struct g_provider *pp, int flags)
do {
size = sizeof(device_t);
- if (g_io_getattr("NAND::device", cp, &size, &dev))
- break;
+ if (g_io_getattr("NAND::device", cp, &size, &dev)) {
+ size = sizeof(device_t);
+ if (g_io_getattr("CFI::device", cp, &size, &dev))
+ break;
+ }
nslices = g_flashmap_load(dev, &head);
if (nslices == 0)
OpenPOWER on IntegriCloud