From owner-p4-projects@FreeBSD.ORG Sun Mar 7 15:28:17 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D44581065673; Sun, 7 Mar 2010 15:28:16 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F2B8106564A for ; Sun, 7 Mar 2010 15:28:16 +0000 (UTC) (envelope-from raj@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7C4ED8FC16 for ; Sun, 7 Mar 2010 15:28:16 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o27FSG0E086083 for ; Sun, 7 Mar 2010 15:28:16 GMT (envelope-from raj@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o27FSGSn086081 for perforce@freebsd.org; Sun, 7 Mar 2010 15:28:16 GMT (envelope-from raj@freebsd.org) Date: Sun, 7 Mar 2010 15:28:16 GMT Message-Id: <201003071528.o27FSGSn086081@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to raj@freebsd.org using -f From: Rafal Jaworowski To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 175448 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2010 15:28:17 -0000 http://p4web.freebsd.org/chv.cgi?CH=175448 Change 175448 by raj@raj_nand on 2010/03/07 15:27:19 Initial import of the NAND Flash framework. This provides a set of KOBJ interfaces inside the kernel, which allow for uniform and flexible management of the NAND devices: - NAND Flash Controller (NFC) layer, into which back-end drivers for individual controllers plug in (implementing low-level routines specific to a given NAND controller) - Generic (common) NAND layer which provides means to perform operations on the flash devices in an abstract way (read, program, erase, get status etc.). - NAND character device, which exports chip device as a standard character devices and allows to read/write directly to a device, as well as perform other specific operations by using ioctl. - GEOM NAND class for basic access through GEOM. Obtained from: Juniper Networks, Semihalf Affected files ... .. //depot/projects/nand2/etc/mtree/BSD.include.dist#2 edit .. //depot/projects/nand2/include/Makefile#2 edit .. //depot/projects/nand2/sys/dev/nand/nand.c#1 add .. //depot/projects/nand2/sys/dev/nand/nand.h#1 add .. //depot/projects/nand2/sys/dev/nand/nand_bbt.c#1 add .. //depot/projects/nand2/sys/dev/nand/nand_cdev.c#1 add .. //depot/projects/nand2/sys/dev/nand/nand_cdev.h#1 add .. //depot/projects/nand2/sys/dev/nand/nand_ecc_pos.h#1 add .. //depot/projects/nand2/sys/dev/nand/nand_geom.c#1 add .. //depot/projects/nand2/sys/dev/nand/nand_id.c#1 add .. //depot/projects/nand2/sys/dev/nand/nand_if.m#1 add .. //depot/projects/nand2/sys/dev/nand/nandbus.c#1 add .. //depot/projects/nand2/sys/dev/nand/nandbus.h#1 add .. //depot/projects/nand2/sys/dev/nand/nfc_generic.c#1 add .. //depot/projects/nand2/sys/dev/nand/nfc_if.m#1 add .. //depot/projects/nand2/sys/geom/geom_dev.c#2 edit .. //depot/projects/nand2/sys/geom/geom_disk.c#2 edit .. //depot/projects/nand2/sys/geom/geom_disk.h#2 edit .. //depot/projects/nand2/sys/geom/geom_nand.c#1 add .. //depot/projects/nand2/sys/geom/geom_nand.h#1 add .. //depot/projects/nand2/sys/sys/bio.h#2 edit .. //depot/projects/nand2/sys/sys/disk.h#2 edit Differences ... ==== //depot/projects/nand2/etc/mtree/BSD.include.dist#2 (text+ko) ==== @@ -110,6 +110,8 @@ mpilib .. .. + nand + .. ofw .. pbio ==== //depot/projects/nand2/include/Makefile#2 (text+ko) ==== @@ -40,7 +40,7 @@ LSUBDIRS= cam/ata cam/scsi \ dev/acpica dev/an dev/bktr dev/firewire dev/hwpmc \ - dev/ic dev/iicbus ${_dev_ieee488} dev/lmc dev/mfi dev/ofw \ + dev/ic dev/iicbus ${_dev_ieee488} dev/lmc dev/mfi dev/nand dev/ofw \ dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ fs/devfs fs/fdescfs fs/fifofs fs/msdosfs fs/nfs fs/ntfs fs/nullfs \ @@ -150,7 +150,7 @@ done .endif .endfor -.for i in ${LDIRS} ${LSUBDIRS:Ndev/acpica:Ndev/bktr} ${LSUBSUBDIRS} +.for i in ${LDIRS} ${LSUBDIRS:Ndev/acpica:Ndev/bktr:Ndev/nand} ${LSUBSUBDIRS} cd ${.CURDIR}/../sys; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \ ${DESTDIR}${INCLUDEDIR}/$i @@ -161,6 +161,11 @@ cd ${.CURDIR}/../sys/dev/bktr; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \ ${DESTDIR}${INCLUDEDIR}/dev/bktr + cd ${.CURDIR}/../sys/dev/nand; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \ + ${DESTDIR}${INCLUDEDIR}/dev/nand; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_cdev.h \ + ${DESTDIR}${INCLUDEDIR}/dev/nand cd ${.CURDIR}/../sys/contrib/altq/altq; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \ ${DESTDIR}${INCLUDEDIR}/altq @@ -215,7 +220,7 @@ ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ done .endfor -.for i in ${LSUBDIRS:Ndev/acpica:Ndev/bktr} +.for i in ${LSUBDIRS:Ndev/acpica:Ndev/bktr:Ndev/nand} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ @@ -231,6 +236,11 @@ ln -fs ../../../../sys/dev/bktr/$$h \ ${DESTDIR}${INCLUDEDIR}/dev/bktr; \ done + cd ${.CURDIR}/../sys/dev/nand; \ + for h in nandsim.h nand_cdev.h; do \ + ln -fs ../../../../sys/dev/nand/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/nand; \ + done .for i in ${LSUBSUBDIRS} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ ==== //depot/projects/nand2/sys/geom/geom_dev.c#2 (text+ko) ==== @@ -267,6 +267,16 @@ if (error == 0 && *(u_int *)data == 0) error = ENOENT; break; + case DIOCNOOBSIZE: + error = g_io_getattr("NAND::oobsize", cp, &i, data); + if (error == 0 && *(u_int *)data == 0) + error = ENOENT; + break; + case DIOCNPGSIZE: + error = g_io_getattr("NAND::pagesize", cp, &i, data); + if (error == 0 && *(u_int *)data == 0) + error = ENOENT; + break; case DIOCGFRONTSTUFF: error = g_io_getattr("GEOM::frontstuff", cp, &i, data); break; ==== //depot/projects/nand2/sys/geom/geom_disk.c#2 (text+ko) ==== @@ -301,6 +301,10 @@ break; else if (g_handleattr_int(bp, "GEOM::fwheads", dp->d_fwheads)) break; + else if (g_handleattr_int(bp, "NAND::oobsize", dp->n_oobsize)) + break; + else if (g_handleattr_int(bp, "NAND::pagesize", dp->n_pagesize)) + break; else if (g_handleattr_off_t(bp, "GEOM::frontstuff", 0)) break; else if (g_handleattr_str(bp, "GEOM::ident", dp->d_ident)) ==== //depot/projects/nand2/sys/geom/geom_disk.h#2 (text+ko) ==== @@ -84,6 +84,8 @@ u_int d_maxsize; u_int d_stripeoffset; u_int d_stripesize; + u_int n_oobsize; + u_int n_pagesize; char d_ident[DISK_IDENT_SIZE]; /* Fields private to the driver */ ==== //depot/projects/nand2/sys/sys/bio.h#2 (text+ko) ==== @@ -64,6 +64,7 @@ typedef void bio_task_t(void *); + /* * The bio structure describes an I/O operation in the kernel. */ @@ -73,7 +74,10 @@ uint8_t bio_cflags; /* Private use by the consumer. */ uint8_t bio_pflags; /* Private use by the provider. */ struct cdev *bio_dev; /* Device to do I/O on. */ - struct disk *bio_disk; /* Valid below geom_disk.c only */ + union { + struct disk *bio_disk; /* Valid below geom_disk.c only */ + struct gnand *bio_nand; /* Valid below geom_disk.c only */ + } bio_source; off_t bio_offset; /* Offset into file. */ long bio_bcount; /* Valid bytes in buffer. */ caddr_t bio_data; /* Memory, superblocks, indirect etc. */ @@ -111,6 +115,24 @@ daddr_t bio_pblkno; /* physical block number */ }; +#define bio_disk bio_source.bio_disk +#define bio_nand bio_source.bio_nand + +/* bio_cmd */ +#define BIO_READ 0x01 +#define BIO_WRITE 0x02 +#define BIO_DELETE 0x04 +#define BIO_GETATTR 0x08 +#define BIO_FLUSH 0x10 +#define BIO_CMD0 0x20 /* Available for local hacks */ +#define BIO_CMD1 0x40 /* Available for local hacks */ +#define BIO_CMD2 0x80 /* Available for local hacks */ + +/* bio_flags */ +#define BIO_ERROR 0x01 +#define BIO_DONE 0x02 +#define BIO_ONQUEUE 0x04 + struct uio; struct devstat; ==== //depot/projects/nand2/sys/sys/disk.h#2 (text+ko) ==== @@ -116,4 +116,7 @@ * This should be a multiple of the sectorsize. */ +#define DIOCNOOBSIZE _IOR('d', 141, u_int) /* Get oob size */ +#define DIOCNPGSIZE _IOR('d', 142, u_int) /* Get page size */ + #endif /* _SYS_DISK_H_ */