changeset 210:1d87b335fc50

gsm-fw/services/ffs: cfgffs.c integrated
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 26 Dec 2013 04:37:10 +0000
parents 6f4a12b4582f
children 847e2585a0f2
files gsm-fw/services/ffs/Makefile gsm-fw/services/ffs/cfgffs.c
diffstat 2 files changed, 105 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/services/ffs/Makefile	Thu Dec 26 03:59:59 2013 +0000
+++ b/gsm-fw/services/ffs/Makefile	Thu Dec 26 04:37:10 2013 +0000
@@ -2,7 +2,7 @@
 CFLAGS=	-O2 -fno-builtin -mthumb-interwork -mthumb
 LD=	arm-elf-ld
 
-OBJS=	drv.o
+OBJS=	cfgffs.o drv.o
 
 HDRS=	core.h drv.h ffs.h ffs_api.h ffs_env.h ffs_pool_size.h ffstrace.h \
 	intctl.h ramffs.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gsm-fw/services/ffs/cfgffs.c	Thu Dec 26 04:37:10 2013 +0000
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * Flash File System (ffs)
+ * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
+ *
+ * FFS configuration
+ *
+ * $Id: cfgffs.c 1.27 Fri, 19 Dec 2003 12:00:13 +0100 tsj $
+ *
+ ******************************************************************************/
+
+#include "../../include/config.h"
+#include "ffs.h"
+#include "drv.h"
+#include "ramffs.h"
+#include <string.h>
+
+#if FFS_IN_RAM
+
+extern struct block_info_s ramffs_block_info[RAMFFS_NBLOCKS];
+
+struct dev_s dev = {
+    .base	   = _RAMFFS_area,
+    .binfo	   = ramffs_block_info,
+    .blocksize	   = RAMFFS_BLKSIZE_BYTES,
+    .blocksize_ld  = RAMFFS_BLKSIZE_LOG2,
+    .driver	   = FFS_DRIVER_RAM,
+    .numblocks	   = RAMFFS_NBLOCKS,
+};
+
+#elif CONFIG_MOKOFFS
+
+static struct block_info_s mokoffs_blocks[7] = {
+    { 0x00000, 16 },
+    { 0x10000, 16 },
+    { 0x20000, 16 },
+    { 0x30000, 16 },
+    { 0x40000, 16 },
+    { 0x50000, 16 },
+    { 0x60000, 16 }
+};
+
+struct dev_s dev = {
+    .base	   = (char *) 0x380000,
+    .binfo	   = mokoffs_blocks,
+    .blocksize	   = 0x10000,
+    .blocksize_ld  = 16,
+    .driver	   = FFS_DRIVER_AMD,
+    .numblocks	   = 7,
+};
+
+#elif CONFIG_PIRHACK_FFS
+
+/* see ../../cfgmagic/feature.pirhack-ffs */
+
+static struct block_info_s pirhack_ffs_blocks[7] = {
+    { 0x600000, 18 },
+    { 0x640000, 18 },
+    { 0x680000, 18 },
+    { 0x6C0000, 18 },
+    { 0x700000, 18 },
+    { 0x740000, 18 },
+    { 0x780000, 18 }
+};
+
+struct dev_s dev = {
+    .base	   = (char *) FLASH2_BASE_ADDR,
+    .binfo	   = pirhack_ffs_blocks,
+    .blocksize	   = 0x40000,
+    .blocksize_ld  = 18,
+    .driver	   = FFS_DRIVER_AMD,
+    .numblocks	   = 7,
+};
+
+#else
+
+#error "No valid FFS configuration defined"
+
+#endif
+
+/******************************************************************************
+ * ffs_is_modify_valid()
+ ******************************************************************************/
+
+// This is function to be implemented by the application programmer. It is
+// called by ffs when a read-only object is about to be modified or
+// removed. It should return zero if the operation should be
+// disallowed. Returning non-zero means go ahead.
+effs_t ffs_is_modifiable(const char *name)
+{
+    // default is to allow any modification of read-only objects.
+
+/*
+ * TI's original code (conditioned out below) disallowed changing the
+ * IMEI of a device.  FreeCalypso follows a different philosophy:
+ * 100% user empowerment, hence no artificial obstacles to hacking.
+ */
+#if 0
+    // example of how to disallow modifying a specific object...
+    if (strcmp("IMEI", &name[strlen(name) - 4]) == 0)
+        return 0;
+#endif
+
+    return 1;
+}