Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/geom_flashmap.c
Show All 37 Lines | |||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/slicer.h> | #include <sys/slicer.h> | ||||
#include <geom/geom.h> | #include <geom/geom.h> | ||||
#include <geom/geom_disk.h> | #include <geom/geom_disk.h> | ||||
#include <geom/geom_flashmap.h> | #include <geom/geom_flashmap.h> | ||||
#include <geom/geom_slice.h> | #include <geom/geom_slice.h> | ||||
#include <dev/nand/nand_dev.h> | |||||
struct g_flashmap_slice { | struct g_flashmap_slice { | ||||
off_t sl_start; | off_t sl_start; | ||||
off_t sl_end; | off_t sl_end; | ||||
const char *sl_name; | const char *sl_name; | ||||
STAILQ_ENTRY(g_flashmap_slice) sl_link; | STAILQ_ENTRY(g_flashmap_slice) sl_link; | ||||
}; | }; | ||||
STAILQ_HEAD(g_flashmap_head, g_flashmap_slice); | STAILQ_HEAD(g_flashmap_head, g_flashmap_slice); | ||||
static struct { | static struct { | ||||
const char *type; | const char *type; | ||||
flash_slicer_t slicer; | flash_slicer_t slicer; | ||||
} g_flashmap_slicers[] = { | } g_flashmap_slicers[] = { | ||||
{ "NAND::device", NULL }, | { "NAND::device", NULL }, | ||||
{ "CFI::device", NULL }, | { "CFI::device", NULL }, | ||||
{ "SPI::device", NULL }, | { "SPI::device", NULL }, | ||||
{ "MMC::device", NULL } | { "MMC::device", NULL } | ||||
}; | }; | ||||
static g_ioctl_t g_flashmap_ioctl; | |||||
static g_taste_t g_flashmap_taste; | static g_taste_t g_flashmap_taste; | ||||
static int g_flashmap_load(device_t dev, struct g_provider *pp, | static int g_flashmap_load(device_t dev, struct g_provider *pp, | ||||
flash_slicer_t slicer, struct g_flashmap_head *head); | flash_slicer_t slicer, struct g_flashmap_head *head); | ||||
static int g_flashmap_modify(struct g_flashmap *gfp, struct g_geom *gp, | static int g_flashmap_modify(struct g_flashmap *gfp, struct g_geom *gp, | ||||
const char *devname, int secsize, struct g_flashmap_head *slices); | const char *devname, int secsize, struct g_flashmap_head *slices); | ||||
static void g_flashmap_print(struct g_flashmap_slice *slice); | static void g_flashmap_print(struct g_flashmap_slice *slice); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | STAILQ_FOREACH(slice, slices, sl_link) { | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | |||||
g_flashmap_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, | |||||
struct thread *td) | |||||
{ | |||||
struct g_consumer *cp; | |||||
struct g_geom *gp; | |||||
if (cmd != NAND_IO_GET_CHIP_PARAM) | |||||
return (ENOIOCTL); | |||||
cp = LIST_FIRST(&pp->geom->consumer); | |||||
if (cp == NULL) | |||||
return (ENOIOCTL); | |||||
gp = cp->provider->geom; | |||||
if (gp->ioctl == NULL) | |||||
return (ENOIOCTL); | |||||
return (gp->ioctl(cp->provider, cmd, data, fflag, td)); | |||||
} | |||||
static struct g_geom * | static struct g_geom * | ||||
g_flashmap_taste(struct g_class *mp, struct g_provider *pp, int flags) | g_flashmap_taste(struct g_class *mp, struct g_provider *pp, int flags) | ||||
{ | { | ||||
struct g_geom *gp; | struct g_geom *gp; | ||||
struct g_consumer *cp; | struct g_consumer *cp; | ||||
struct g_flashmap_head head; | struct g_flashmap_head head; | ||||
struct g_flashmap_slice *slice, *slice_temp; | struct g_flashmap_slice *slice, *slice_temp; | ||||
struct g_flashmap *gfp; | struct g_flashmap *gfp; | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | if (g_flashmap_slicers[type].slicer == NULL || force == TRUE) | ||||
g_flashmap_slicers[type].slicer = slicer; | g_flashmap_slicers[type].slicer = slicer; | ||||
g_topology_unlock(); | g_topology_unlock(); | ||||
} | } | ||||
static struct g_class g_flashmap_class = { | static struct g_class g_flashmap_class = { | ||||
.name = FLASHMAP_CLASS_NAME, | .name = FLASHMAP_CLASS_NAME, | ||||
.version = G_VERSION, | .version = G_VERSION, | ||||
.taste = g_flashmap_taste, | .taste = g_flashmap_taste, | ||||
.ioctl = g_flashmap_ioctl, | |||||
}; | }; | ||||
DECLARE_GEOM_CLASS(g_flashmap_class, g_flashmap); | DECLARE_GEOM_CLASS(g_flashmap_class, g_flashmap); | ||||
MODULE_VERSION(g_flashmap, 0); | MODULE_VERSION(g_flashmap, 0); |