changeset 3388:77f93339ffd8

io/nand include/nand_internal.h: Create header to expose internal functions to NAND drivers.
author Ross Younger <wry@ecoscentric.com>
date Sat, 27 Sep 2014 12:35:37 +1200
parents c1cbf062a826
children 1ee7927cc736
files packages/io/nand/current/ChangeLog packages/io/nand/current/include/nand_internal.h packages/io/nand/current/src/nand.c packages/io/nand/current/src/nand_bbt.c packages/io/nand/current/src/nand_bbt.h
diffstat 5 files changed, 96 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/nand/current/ChangeLog
+++ b/packages/io/nand/current/ChangeLog
@@ -3,6 +3,8 @@ 2014-09-27  Ross Younger  <wry@ecoscentr
 	tests/nand_readwrite.c tests/nand_rwbenchmark.c:
 	Create CYGINT_IO_NAND_TEST_PARTITION to specify which partition the
 	tests should use.
+	* include/nand_internal.h: Create header to expose internal
+	functions to NAND drivers.
 
 2014-09-26  Ross Younger  <wry@ecoscentric.com>
 
new file mode 100644
--- /dev/null
+++ b/packages/io/nand/current/include/nand_internal.h
@@ -0,0 +1,90 @@
+#ifndef CYGONCE_NAND_INTERNAL_H
+# define CYGONCE_NAND_INTERNAL_H
+//=============================================================================
+//
+//      nand_internal.h
+//
+//      NAND library internal calls, for use by drivers and the BBT.
+//      This file should not be included by application code.
+//
+//=============================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2009 eCosCentric Limited.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later
+// version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with eCos; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+// As a special exception, if other files instantiate templates or use
+// macros or inline functions from this file, or you compile this file
+// and link it with other works to produce a work based on this file,
+// this file does not by itself cause the resulting work to be covered by
+// the GNU General Public License. However the source code for this file
+// must still be made available in accordance with section (3) of the GNU
+// General Public License v2.
+//
+// This exception does not invalidate any other reasons why a work based
+// on this file might be covered by the GNU General Public License.
+// -------------------------------------------
+// ####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):   wry
+// Date:        2009-03-11
+//
+//####DESCRIPTIONEND####
+//=============================================================================
+
+#ifndef CYG_NAND_ALLOW_INTERNALS
+/* BEWARE!
+ *
+ * Applications should not include this file.
+ * All the contents are internal interfaces and subject to
+ * change without notice.
+ */
+#error "Applications should not include this file directly."
+#endif
+
+
+#include <cyg/nand/nand_device.h>
+#include <cyg/nand/nand.h>
+#include <pkgconf/io_nand.h>
+
+/* Raw unchecked NAND access, for use by the BBT and drivers ========= */
+
+/* Takes a DEVICE address. Caller must hold the devlock! */
+int nandi_read_whole_page_raw(cyg_nand_device *dev, cyg_nand_page_addr page,
+                              CYG_BYTE * dest,
+                              CYG_BYTE * spare, size_t spare_size,
+                              int check_ecc);
+
+/* Takes a DEVICE address. Caller must hold the devlock! */
+int nandi_write_page_raw(cyg_nand_device *dev, cyg_nand_page_addr page,
+                         const CYG_BYTE * src,
+                         const CYG_BYTE * spare, size_t spare_size);
+
+/* NOTE for driver authors:
+ * If calling these functions from within a plf_partition_setup function,
+ * i.e. within the cyg_nand_lookup call chain, the device lock is
+ * irrelevant as it has not yet been set up. */
+
+/* Code outside of the BBT can use the pagebuffer ==================== */
+CYG_BYTE* nandi_grab_pagebuf(void);
+void nandi_release_pagebuf(void);
+
+/* =================================================================== */
+
+#endif
--- a/packages/io/nand/current/src/nand.c
+++ b/packages/io/nand/current/src/nand.c
@@ -52,6 +52,8 @@
 #include <cyg/nand/nand.h>
 #include <cyg/nand/nand_device.h>
 #include <cyg/nand/nand_devtab.h>
+#define CYG_NAND_ALLOW_INTERNALS
+#include <cyg/nand/nand_internal.h>
 #include <cyg/nand/util.h>
 #include "nand_bbt.h"
 #include CYGBLD_ISO_ERRNO_CODES_HEADER
--- a/packages/io/nand/current/src/nand_bbt.c
+++ b/packages/io/nand/current/src/nand_bbt.c
@@ -53,6 +53,8 @@
 #include <cyg/infra/cyg_ass.h>
 #include <cyg/infra/diag.h>
 #include <cyg/nand/nand.h>
+#define CYG_NAND_ALLOW_INTERNALS
+#include <cyg/nand/nand_internal.h>
 #include <cyg/nand/util.h>
 #include "nand_bbt.h"
 #include CYGBLD_ISO_ERRNO_CODES_HEADER
--- a/packages/io/nand/current/src/nand_bbt.h
+++ b/packages/io/nand/current/src/nand_bbt.h
@@ -120,23 +120,6 @@ int cyg_nand_bbti_build_tables(cyg_nand_
  */
 #endif
 
-/* Raw unchecked NAND access, for use by the BBT ===================== */
-
-/* Takes a DEVICE address. Caller must hold the devlock! */
-int nandi_read_whole_page_raw(cyg_nand_device *dev, cyg_nand_page_addr page,
-                              CYG_BYTE * dest,
-                              CYG_BYTE * spare, size_t spare_size,
-                              int check_ecc);
-
-/* Takes a DEVICE address. Caller must hold the devlock! */
-int nandi_write_page_raw(cyg_nand_device *dev, cyg_nand_page_addr page,
-                         const CYG_BYTE * src,
-                         const CYG_BYTE * spare, size_t spare_size);
-
-/* Code outside of the BBT can use the pagebuffer ==================== */
-CYG_BYTE* nandi_grab_pagebuf(void);
-void nandi_release_pagebuf(void);
-
 /* =================================================================== */
 
 #endif