Move granuale allocator and page allocator from mm/. to mm/mm_gran/.

This commit is contained in:
Gregory Nutt 2014-09-22 10:33:23 -06:00
parent 81c3237ad2
commit 907e45752b
10 changed files with 83 additions and 33 deletions

View file

@ -48,10 +48,17 @@ else
endif endif
endif endif
# Core allocator logic # Sources and paths
ASRCS = ASRCS =
CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c CSRCS =
DEPPATH = --dep-path .
VPATH = .
# Core allocator logic
CSRCS += mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c
CSRCS += mm_shrinkchunk.c CSRCS += mm_shrinkchunk.c
CSRCS += mm_brkaddr.c mm_calloc.c mm_extend.c mm_free.c mm_mallinfo.c CSRCS += mm_brkaddr.c mm_calloc.c mm_extend.c mm_free.c mm_mallinfo.c
CSRCS += mm_malloc.c mm_memalign.c mm_realloc.c mm_zalloc.c CSRCS += mm_malloc.c mm_memalign.c mm_realloc.c mm_zalloc.c
@ -88,16 +95,7 @@ endif
# An optional granule allocator # An optional granule allocator
ifeq ($(CONFIG_GRAN),y) include mm_gran/Make.defs
CSRCS += mm_graninit.c mm_granreserve.c mm_granalloc.c mm_granmark.c
CSRCS += mm_granfree.c mm_grancritical.c
# A page allocator based on the granule allocator
ifeq ($(CONFIG_MM_PGALLOC),y)
CSRCS += mm_pgalloc.c
endif
endif
BINDIR ?= bin BINDIR ?= bin
@ -145,10 +143,10 @@ endif
.depend: Makefile $(SRCS) .depend: Makefile $(SRCS)
ifeq ($(CONFIG_BUILD_PROTECTED),y) ifeq ($(CONFIG_BUILD_PROTECTED),y)
$(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep $(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep
$(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) $(KDEFINE) -- $(SRCS) >Make_kbin.dep $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) $(KDEFINE) -- $(SRCS) >Make_kbin.dep
else else
$(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep
endif endif
$(Q) touch $@ $(Q) touch $@

52
mm/mm_gran/Make.defs Normal file
View file

@ -0,0 +1,52 @@
############################################################################
# mm/mm_gran/Make.defs
#
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
# An optional granule allocator
ifeq ($(CONFIG_GRAN),y)
CSRCS += mm_graninit.c mm_granreserve.c mm_granalloc.c mm_granmark.c
CSRCS += mm_granfree.c mm_grancritical.c
# A page allocator based on the granule allocator
ifeq ($(CONFIG_MM_PGALLOC),y)
CSRCS += mm_pgalloc.c
endif
# Add the granule directory to the build
DEPPATH += --dep-path mm_gran
VPATH += :mm_gran
endif

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_gran.h * mm/mm_gran/mm_gran.h
* *
* Copyright (C) 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -33,8 +33,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __MM_MM_GRAN_H #ifndef __MM_MM_GRAN_MM_GRAHN_H
#define __MM_MM_GRAN_H #define __MM_MM_GRAN_MM_GRAHN_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -148,4 +148,4 @@ void gran_leave_critical(FAR struct gran_s *priv);
void gran_mark_allocated(FAR struct gran_s *priv, uintptr_t alloc, void gran_mark_allocated(FAR struct gran_s *priv, uintptr_t alloc,
unsigned int ngranules); unsigned int ngranules);
#endif /* __MM_MM_GRAN_H */ #endif /* __MM_MM_GRAN_MM_GRAHN_H */

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_granalloc.c * mm/mm_gran/mm_granalloc.c
* *
* Copyright (C) 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -43,7 +43,7 @@
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_GRAN #ifdef CONFIG_GRAN

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_grancritical.c * mm/mm_gran/mm_grancritical.c
* *
* Copyright (C) 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -46,7 +46,7 @@
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_GRAN #ifdef CONFIG_GRAN

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_granfree.c * mm/mm_gran/mm_granfree.c
* *
* Copyright (C) 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -43,7 +43,7 @@
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_GRAN #ifdef CONFIG_GRAN

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_graninit.c * mm/mm_gran/mm_graninit.c
* *
* Copyright (C) 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -45,7 +45,7 @@
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_GRAN #ifdef CONFIG_GRAN

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_granmark.c * mm/mm_gran/mm_granmark.c
* *
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -43,7 +43,7 @@
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_GRAN #ifdef CONFIG_GRAN

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_granreserve.c * mm/mm_gran/mm_granreserve.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -43,7 +43,7 @@
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_GRAN #ifdef CONFIG_GRAN

View file

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* mm/mm_pgalloc.c * mm/mm_gran/mm_pgalloc.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -44,7 +44,7 @@
#include <nuttx/gran.h> #include <nuttx/gran.h>
#include <nuttx/pgalloc.h> #include <nuttx/pgalloc.h>
#include "mm_gran.h" #include "mm_gran/mm_gran.h"
#ifdef CONFIG_MM_PGALLOC #ifdef CONFIG_MM_PGALLOC