diff --git a/fs/procfs/Kconfig b/fs/procfs/Kconfig index d5595c9f971..9ea109c1bd8 100644 --- a/fs/procfs/Kconfig +++ b/fs/procfs/Kconfig @@ -115,5 +115,10 @@ config FS_PROCFS_EXCLUDE_SMARTFS depends on FS_SMARTFS default n +config FS_PROCFS_EXCLUDE_UMM + bool "Exclude umm" + depends on !BUILD_KERNEL + default n + endmenu # endif # FS_PROCFS diff --git a/fs/procfs/Make.defs b/fs/procfs/Make.defs index 31dbf7b8180..41408dbb0b5 100644 --- a/fs/procfs/Make.defs +++ b/fs/procfs/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # fs/procfs/Make.defs # -# Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. +# Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -40,6 +40,10 @@ ASRCS += CSRCS += fs_procfs.c fs_procfsutil.c fs_procfsproc.c fs_procfsuptime.c CSRCS += fs_procfscpuload.c fs_procfskmm.c +ifneq ($(CONFIG_BUILD_KERNEL),y) +CSRCS += fs_procfsumm.c +endif + ifeq ($(CONFIG_ARCH_HAVE_PROGMEM),y) CSRCS += fs_procfsprogmem.c endif diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 3c1d4809e45..e5eb05f9a72 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -79,6 +79,7 @@ extern const struct procfs_operations proc_operations; extern const struct procfs_operations cpuload_operations; extern const struct procfs_operations kmm_operations; +extern const struct procfs_operations umm_operations; extern const struct procfs_operations progmem_operations; extern const struct procfs_operations module_operations; extern const struct procfs_operations uptime_operations; @@ -170,6 +171,10 @@ static const struct procfs_entry_s g_procfs_entries[] = { "progmem", &progmem_operations, PROCFS_FILE_TYPE }, #endif +#if !defined(CONFIG_FS_PROCFS_EXCLUDE_UMM) && !defined(CONFIG_BUILD_KERNEL) + { "umm", &umm_operations, PROCFS_FILE_TYPE }, +#endif + #if !defined(CONFIG_FS_PROCFS_EXCLUDE_UPTIME) { "uptime", &uptime_operations, PROCFS_FILE_TYPE }, #endif diff --git a/fs/procfs/fs_procfskmm.c b/fs/procfs/fs_procfskmm.c index d3c8699d19f..0627ddb3ca0 100644 --- a/fs/procfs/fs_procfskmm.c +++ b/fs/procfs/fs_procfskmm.c @@ -240,7 +240,7 @@ static ssize_t kmm_read(FAR struct file *filep, FAR char *buffer, #endif linesize = snprintf(procfile->line, KMM_LINELEN, - "Mem: %11d%11d%11d%11d\n", + "Kmem: %11d%11d%11d%11d\n", mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk); copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index 4734a264f61..4809b849aba 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -61,11 +61,11 @@ #undef KMALLOC_EXTERN #if defined(__cplusplus) -# define KMALLOC_EXTERN extern "C" +# define KMALLOC_EXTERN extern "C" extern "C" { #else -# define KMALLOC_EXTERN extern +# define KMALLOC_EXTERN extern #endif /**************************************************************************** @@ -94,6 +94,11 @@ extern "C" #define kumm_realloc(p,s) realloc(p,s) #define kumm_memalign(a,s) memalign(a,s) #define kumm_free(p) free(p) +#ifdef CONFIG_CAN_PASS_STRUCTS +# define kumm_mallinfo() mallinfo() +#else +# define kumm_mallinfo(i) mallinfo(i) +#endif /* This family of allocators is used to manage kernel protected memory */ @@ -102,16 +107,21 @@ extern "C" * as were used for the user-mode function. */ -# define kmm_initialize(h,s) /* Initialization done by kumm_initialize */ -# define kmm_addregion(h,s) umm_addregion(h,s) -# define kmm_trysemaphore() umm_trysemaphore() -# define kmm_givesemaphore() umm_givesemaphore() +# define kmm_initialize(h,s) /* Initialization done by kumm_initialize */ +# define kmm_addregion(h,s) umm_addregion(h,s) +# define kmm_trysemaphore() umm_trysemaphore() +# define kmm_givesemaphore() umm_givesemaphore() -# define kmm_malloc(s) malloc(s) -# define kmm_zalloc(s) zalloc(s) -# define kmm_realloc(p,s) realloc(p,s) -# define kmm_memalign(a,s) memalign(a,s) -# define kmm_free(p) free(p) +# define kmm_malloc(s) malloc(s) +# define kmm_zalloc(s) zalloc(s) +# define kmm_realloc(p,s) realloc(p,s) +# define kmm_memalign(a,s) memalign(a,s) +# define kmm_free(p) free(p) +#ifdef CONFIG_CAN_PASS_STRUCTS +# define kmm_mallinfo() mallinfo() +#else +# define kmm_mallinfo(i) mallinfo(i) +#endif #elif !defined(CONFIG_MM_KERNEL_HEAP) /* If this the kernel phase of a kernel build, and there are only user-space @@ -119,16 +129,21 @@ extern "C" * call into user-space via a header at the beginning of the user-space blob. */ -# define kmm_initialize(h,s) /* Initialization done by kumm_initialize */ -# define kmm_addregion(h,s) umm_addregion(h,s) -# define kmm_trysemaphore() umm_trysemaphore() -# define kmm_givesemaphore() umm_givesemaphore() +# define kmm_initialize(h,s) /* Initialization done by kumm_initialize */ +# define kmm_addregion(h,s) umm_addregion(h,s) +# define kmm_trysemaphore() umm_trysemaphore() +# define kmm_givesemaphore() umm_givesemaphore() -# define kmm_malloc(s) umm_malloc(s) -# define kmm_zalloc(s) umm_zalloc(s) -# define kmm_realloc(p,s) umm_realloc(p,s) -# define kmm_memalign(a,s) umm_memalign(a,s) -# define kmm_free(p) umm_free(p) +# define kmm_malloc(s) malloc(s) +# define kmm_zalloc(s) zalloc(s) +# define kmm_realloc(p,s) realloc(p,s) +# define kmm_memalign(a,s) memalign(a,s) +# define kmm_free(p) free(p) +#ifdef CONFIG_CAN_PASS_STRUCTS +# define kmm_mallinfo() mallinfo() +#else +# define kmm_mallinfo(i) mallinfo(i) +#endif #else /* Otherwise, the kernel-space allocators are declared in include/nuttx/mm/mm.h diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index 40e777907dd..70d4f3cceae 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/mm/mm.h * - * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013-2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -49,6 +49,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ /* If the MCU has a small (16-bit) address capability, then we will use * a smaller chunk header that contains 16-bit size/offset information.