Index: sys/dev/fdt/fdt_slicer.c =================================================================== --- sys/dev/fdt/fdt_slicer.c +++ sys/dev/fdt/fdt_slicer.c @@ -43,7 +43,7 @@ #endif int -flash_fill_slices(device_t dev, struct flash_slice *slices, int *slices_num) +fdt_flash_fill_slices(device_t dev, struct flash_slice *slices, int *slices_num) { char *slice_name; phandle_t dt_node, dt_child; Index: sys/dev/nand/nfc_rb.c =================================================================== --- sys/dev/nand/nfc_rb.c +++ sys/dev/nand/nfc_rb.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,7 @@ #include #include +#include #include #include @@ -111,6 +113,39 @@ }; #endif +/* Slicer operates on the controller, so we have to find the chip. */ +static int +rb_nand_slicer(device_t dev, struct flash_slice *slices, int *nslices) +{ + struct nand_chip *chip; + device_t *children; + int n; + + if (device_get_children(dev, &children, &n) != 0) { + panic("Slicer called on controller with no child!"); + } + dev = children[0]; + free(children, M_TEMP); + + if (device_get_children(dev, &children, &n) != 0) { + panic("Slicer called on controller with nandbus but no child!"); + } + dev = children[0]; + free(children, M_TEMP); + + chip = device_get_softc(dev); + *nslices = 2; + slices[0].base = 0; + slices[0].size = 4 * 1024 * 1024; + slices[0].label = "boot"; + + slices[1].base = 4 * 1024 * 1024; + slices[1].size = chip->ndisk->d_mediasize - slices[0].size; + slices[1].label = "rootfs"; + + return (0); +} + static int rb_nand_probe(device_t dev) { @@ -180,6 +215,7 @@ return (ENXIO); } + flash_register_slicer(rb_nand_slicer); nand_init(&sc->nand_dev, dev, NAND_ECC_SOFT, 0, 0, NULL, NULL); err = nandbus_create(dev); Index: sys/geom/geom_flashmap.c =================================================================== --- sys/geom/geom_flashmap.c +++ sys/geom/geom_flashmap.c @@ -70,6 +70,8 @@ static void g_flashmap_config(struct gctl_req *, struct g_class *, const char *); static int g_flashmap_load(device_t, struct g_flashmap_head *); +static int (*flash_fill_slices)(device_t, struct flash_slice *, int *) = + fdt_flash_fill_slices; MALLOC_DECLARE(M_FLASHMAP); MALLOC_DEFINE(M_FLASHMAP, "geom_flashmap", "GEOM flash memory slicer class"); @@ -230,7 +232,8 @@ buf_size = sizeof(struct flash_slice) * FLASH_SLICES_MAX_NUM; slices = malloc(buf_size, M_FLASHMAP, M_WAITOK | M_ZERO); - if (flash_fill_slices(dev, slices, &nslices) == 0) { + if (flash_fill_slices && + flash_fill_slices(dev, slices, &nslices) == 0) { for (i = 0; i < nslices; i++) { slice = malloc(sizeof(struct g_flashmap_slice), M_FLASHMAP, M_WAITOK); @@ -247,6 +250,12 @@ return (nslices); } +void flash_register_slicer(int (*slicer)(device_t, struct flash_slice *, int *)) +{ + + flash_fill_slices = slicer; +} + static struct g_class g_flashmap_class = { .name = FLASHMAP_CLASS_NAME, .version = G_VERSION, Index: sys/sys/slicer.h =================================================================== --- sys/sys/slicer.h +++ sys/sys/slicer.h @@ -45,7 +45,8 @@ }; #ifdef _KERNEL -int flash_fill_slices(device_t, struct flash_slice *, int *); +int fdt_flash_fill_slices(device_t, struct flash_slice *, int *) __weak_symbol; +void flash_register_slicer(int (*)(device_t, struct flash_slice *, int *)); #endif /* _KERNEL */ #endif /* _FLASH_SLICER_H_ */