diff packages/io/flash/current/src/flash.c @ 1762:9c1d9e5039c2

Move dummy init/query/lock/unlock functions to the generic flash code, and use these in the V2 drivers where appropriate
author bartv
date Mon, 29 Nov 2004 00:43:48 +0000
parents 9abe5ac74a1a
children 42c8ea63b78d
line wrap: on
line diff
--- a/packages/io/flash/current/src/flash.c
+++ b/packages/io/flash/current/src/flash.c
@@ -862,4 +862,59 @@ cyg_flash_errmsg(const int err)
     }
 }
 
+// Dummy routines to put into the device function tables, to handle
+// unsupported/unnecessary functionality. For example not all devices
+// support block locking.
+//
+// A dummy initialization routine, for platforms where everything is
+// done statically and there is no need to check device ids or
+// anything similar.
+int
+cyg_flash_devfn_init_nop(struct cyg_flash_dev* dev)
+{
+    CYG_UNUSED_PARAM(struct cyg_flash_dev*, dev);
+    return CYG_FLASH_ERR_OK;
+}
+
+// A dummy query routine. The implementation of this is specific to
+// each device driver, so some device drivers may choose to do
+// nothing.
+size_t
+cyg_flash_devfn_query_nop(struct cyg_flash_dev* dev, void* data, size_t len)
+{
+    CYG_UNUSED_PARAM(struct cyg_flash_dev*, dev);
+    CYG_UNUSED_PARAM(void*, data);
+    CYG_UNUSED_PARAM(size_t, len);
+    return 0;
+}
+
+// Dummy lock/unlock routines
+int
+cyg_flash_devfn_lock_nop(struct cyg_flash_dev* dev, const cyg_flashaddr_t addr)
+{
+    CYG_UNUSED_PARAM(struct cyg_flash_dev*, dev);
+    CYG_UNUSED_PARAM(const cyg_flashaddr_t, addr);
+    return CYG_FLASH_ERR_DRV_WRONG_PART;
+}
+
+int
+cyg_flash_devfn_unlock_nop(struct cyg_flash_dev* dev, const cyg_flashaddr_t addr)
+{
+    CYG_UNUSED_PARAM(struct cyg_flash_dev*, dev);
+    CYG_UNUSED_PARAM(const cyg_flashaddr_t, addr);
+    return CYG_FLASH_ERR_DRV_WRONG_PART;
+}
+
+// On some architectures there are problems calling the .2ram
+// functions from the main ones. Specifically the compiler may issue a
+// short call, even though the flash and ram are too far apart. The
+// solution is to indirect via a function pointer, but the simplistic
+// approach is vulnerable to compiler optimization. Hence the function
+// pointer is passed through an anonymizer.
+void*
+cyg_flash_anonymizer(void* fn)
+{
+    return fn;
+}
+
 // EOF io/flash/..../flash.c