CFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_YAFFS2 -DCONFIG_YAFFS_DEFINES_TYPES
CFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
+CFLAGS += -DCONFIG_YAFFS_MONITOR_MALLOC
CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing -Werror
#CFLAGS += -fno-strict-aliasing
CFLAGS += -O0
try_rmdir("/nand/z/");
}
+
+void dump_yaffs_malloc_usage(void)
+{
+ unsigned current;
+ unsigned high_water;
+
+ yaffsfs_get_malloc_values(¤t, &high_water);
+
+ printf("\n"
+ "***************************************\n"
+ "Dump of yaffs malloc usage during run\n"
+ "Currently allocated : %u bytes\n"
+ "High water allocated : %u bytes\n"
+ "Note, this is not accurate on all platforms\n",
+ current, high_water);
+
+}
+
+
int random_seed;
int simulate_power_failure;
int main(int argc, char *argv[])
{
+
+ atexit(dump_yaffs_malloc_usage);
+
(void) argc;
(void) argv;
//long_test_on_path("/ram2k");
// long_test_on_path("/flash");
//simple_rw_test("/flash/flash");
- //fill_disk_test("/flash/flash");
+ //fill_disk_test("/nand");
// rename_over_test("/flash");
//lookup_test("/flash");
//freespace_test("/flash/flash");
* Functions to allocate and free memory.
*/
+
+static unsigned malloc_high_water;
+static unsigned malloc_currently_allocated;
+
+#ifdef CONFIG_YAFFS_MONITOR_MALLOC
+
+#include <malloc.h>
+static void yaffsfs_malloc_add(void *ptr)
+{
+ unsigned this_size = malloc_usable_size(ptr);
+ malloc_currently_allocated += this_size;
+
+ if (malloc_currently_allocated > malloc_high_water)
+ malloc_high_water = malloc_currently_allocated;
+}
+
+static void yaffsfs_malloc_remove(void *ptr)
+{
+ unsigned this_size = malloc_usable_size(ptr);
+ malloc_currently_allocated -= this_size;
+}
+#else
+static void yaffsfs_malloc_add(void *ptr)
+{
+ (void)ptr;
+}
+
+static void yaffsfs_malloc_remove(void *ptr)
+{
+ (void)ptr;
+}
+#endif
+
+void yaffsfs_get_malloc_values(unsigned *current, unsigned *high_water)
+{
+ if (current)
+ *current = malloc_currently_allocated;
+ if(high_water)
+ *high_water = malloc_high_water;
+}
+
+
#ifdef CONFIG_YAFFS_TEST_MALLOC
static int yaffs_kill_alloc = 0;
this = malloc(size);
if(this)
total_malloced += size;
+ yaffsfs_malloc_add(this);
return this;
}
void *yaffsfs_malloc(size_t size)
{
- return malloc(size);
+ void *this = malloc(size);
+ yaffsfs_malloc_add(this);
+ return this;
}
#endif
+
+
+
void yaffsfs_free(void *ptr)
{
+ yaffsfs_malloc_remove(ptr);
free(ptr);
}
void *yaffsfs_malloc(size_t size);
void yaffsfs_free(void *ptr);
+void yaffsfs_get_malloc_values(unsigned *current, unsigned *high_water);
+
+
int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request);
void yaffsfs_OSInitialisation(void);