Browse Source

Fix MMC/SD support for Wildfire board; Granule allocator can now be used from intrrupt handler

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5134 7fd9a85b-ad96-42d3-883c-3090e2eb8679
sbg
patacongo 13 years ago
parent
commit
eac15a4720
  1. 7
      nuttx/Documentation/NuttxPortingGuide.html
  2. 5
      nuttx/configs/README.txt
  3. 2
      nuttx/configs/fire-stm32v2/src/fire-internal.h
  4. 8
      nuttx/configs/fire-stm32v2/src/up_mmcsd.c
  5. 7
      nuttx/include/nuttx/gran.h
  6. 11
      nuttx/mm/Kconfig
  7. 4
      nuttx/mm/Makefile
  8. 14
      nuttx/mm/mm_gran.h
  9. 6
      nuttx/mm/mm_granalloc.c
  10. 4
      nuttx/mm/mm_granfree.c
  11. 39
      nuttx/mm/mm_graninit.c

7
nuttx/Documentation/NuttxPortingGuide.html

@ -3948,6 +3948,13 @@ build @@ -3948,6 +3948,13 @@ build
are a few optimizations that can can be done and (2) the GRAN_HANDLE
is not needed.
</li>
<li>
<code>CONFIG_GRAN_INTR</code>:
Normally mutual exclusive access to granule allocator data is assured using a semaphore.
If this option is set then, instead, mutual exclusion logic will disable interrupts.
While this options is more invasive to system performance, it will also support use of the
granule allocator from interrupt level logic.
</li>
<li>
<code>CONFIG_DEBUG_GRAM</code>:
Just like <code>CONFIG_DEBUG_MM</code>, but only generates ouput from the gran

5
nuttx/configs/README.txt

@ -299,6 +299,11 @@ defconfig -- This is a configuration file similar to the Linux @@ -299,6 +299,11 @@ defconfig -- This is a configuration file similar to the Linux
gran_initialize will be called only once. In this case, (1) there
are a few optimizations that can can be done and (2) the GRAN_HANDLE
is not needed.
CONFIG_GRAN_INTR - Normally mutual exclusive access to granule allocator
data is assured using a semaphore. If this option is set then, instead,
mutual exclusion logic will disable interrupts. While this options is
more invasive to system performance, it will also support use of the
granule allocator from interrupt level logic.
CONFIG_DEBUG_GRAM
Just like CONFIG_DEBUG_MM, but only generates ouput from the gran
allocation logic.

2
nuttx/configs/fire-stm32v2/src/fire-internal.h

@ -296,7 +296,7 @@ void stm32_selectlcd(void); @@ -296,7 +296,7 @@ void stm32_selectlcd(void);
*
* Description:
* Initialize the SPI-based SD card. Requires CONFIG_DISABLE_MOUNTPOINT=n
* and CONFIG_STM32_SPI1=y
* and CONFIG_STM32_SDIO=y
*
****************************************************************************/

8
nuttx/configs/fire-stm32v2/src/up_mmcsd.c

@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
/* Can't support MMC/SD features if mountpoints are disabled */
#ifndef CONFIG_DISABLE_MOUNTPOINT
#ifdef CONFIG_DISABLE_MOUNTPOINT
# undef HAVE_MMCSD
#endif
@ -78,7 +78,7 @@ @@ -78,7 +78,7 @@
*
* Description:
* Initialize the SPI-based SD card. Requires CONFIG_DISABLE_MOUNTPOINT=n
* and CONFIG_STM32_SPI1=y
* and CONFIG_STM32_SDIO=y
*
****************************************************************************/
@ -93,7 +93,7 @@ int stm32_sdinitialize(int minor) @@ -93,7 +93,7 @@ int stm32_sdinitialize(int minor)
sdio = sdio_initialize(STM32_MMCSDSLOTNO);
if (!sdio)
{
message("Failed to initialize SDIO slot %d\n", STM32_MMCSDSLOTNO);
fdbg("Failed to initialize SDIO slot %d\n", STM32_MMCSDSLOTNO);
return -ENODEV;
}
@ -104,7 +104,7 @@ int stm32_sdinitialize(int minor) @@ -104,7 +104,7 @@ int stm32_sdinitialize(int minor)
ret = mmcsd_slotinitialize(minor, sdio);
if (ret != OK)
{
message("Failed to bind SDIO slot %d to the MMC/SD driver, minor=%d\n",
fdbg("Failed to bind SDIO slot %d to the MMC/SD driver, minor=%d\n",
STM32_MMCSDSLOTNO, minor);
}

7
nuttx/include/nuttx/gran.h

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
* include/nuttx/gran.h
* General purpose granule memory allocator.
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -57,6 +57,11 @@ @@ -57,6 +57,11 @@
* granule allocator (i.e., gran_initialize will be called only once.
* In this case, (1) there are a few optimizations that can can be done
* and (2) the GRAN_HANDLE is not needed.
* CONFIG_GRAN_INTR - Normally mutual exclusive access to granule allocator
* data is assured using a semaphore. If this option is set then, instead,
* mutual exclusion logic will disable interrupts. While this options is
* more invasive to system performance, it will also support use of the
* granule allocator from interrupt level logic.
* CONFIG_DEBUG_GRAN - Just like CONFIG_DEBUG_MM, but only generates ouput
* from the gran allocation logic.
*/

11
nuttx/mm/Kconfig

@ -65,6 +65,17 @@ config GRAN_SINGLE @@ -65,6 +65,17 @@ config GRAN_SINGLE
are a few optimizations that can can be done and (2) the GRAN_HANDLE
is not needed.
config GRAN_INTR
bool "Interrupt level support"
default n
depends on GRAN
---help---
Normally mutual exclusive access to granule allocator data is assured
using a semaphore. If this option is set then, instead, mutual
exclusion logic will disable interrupts. While this options is more
invasive to system performance, it will also support use of the granule
allocator from interrupt level logic.
config DEBUG_GRAN
bool "Granule Allocator Debug"
default n

4
nuttx/mm/Makefile

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
############################################################################
# mm/Makefile
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Copyright (C) 2007, 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -41,7 +41,7 @@ CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c mm_shrinkchunk @@ -41,7 +41,7 @@ CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c mm_shrinkchunk
mm_memalign.c mm_free.c mm_mallinfo.c
ifeq ($(CONFIG_GRAN),y)
CSRCS += mm_graninit.c mm_granalloc.c mm_granfree.c
CSRCS += mm_graninit.c mm_granalloc.c mm_granfree.c mm_grancritical.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))

14
nuttx/mm/mm_gran.h

@ -45,6 +45,7 @@ @@ -45,6 +45,7 @@
#include <stdint.h>
#include <semaphore.h>
#include <arch/types.h>
#include <nuttx/gran.h>
/****************************************************************************
@ -88,7 +89,11 @@ struct gran_s @@ -88,7 +89,11 @@ struct gran_s
{
uint8_t log2gran; /* Log base 2 of the size of one granule */
uint16_t ngranules; /* The total number of (aligned) granules in the heap */
#ifdef CONFIG_GRAN_INTR
irqstate_t irqstate; /* For exclusive access to the GAT */
#else
sem_t exclsem; /* For exclusive access to the GAT */
#endif
uintptr_t heapstart; /* The aligned start of the granule heap */
uint32_t gat[1]; /* Start of the granule allocation table */
};
@ -108,11 +113,10 @@ extern FAR struct gran_s *g_graninfo; @@ -108,11 +113,10 @@ extern FAR struct gran_s *g_graninfo;
****************************************************************************/
/****************************************************************************
* Name: gran_semtake and gran_semgive
* Name: gran_enter_critical and gran_leave_critical
*
* Description:
* Managed semaphore for the granule allocator. gran_semgive is
* implemented as a macro.
* Critical section management for the granule allocator.
*
* Input Parameters:
* priv - Pointer to the gran state
@ -122,7 +126,7 @@ extern FAR struct gran_s *g_graninfo; @@ -122,7 +126,7 @@ extern FAR struct gran_s *g_graninfo;
*
****************************************************************************/
void gran_semtake(FAR struct gran_s *priv);
#define gran_semgive(p) sem_post(&(p)->exclsem);
void gran_enter_critical(FAR struct gran_s *priv);
void gran_leave_critical(FAR struct gran_s *priv);
#endif /* __MM_MM_GRAN_H */

6
nuttx/mm/mm_granalloc.c

@ -140,7 +140,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) @@ -140,7 +140,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size)
{
/* Get exclusive access to the GAT */
gran_semtake(priv);
gran_enter_critical(priv);
/* How many contiguous granules we we need to find? */
@ -199,7 +199,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) @@ -199,7 +199,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size)
/* And return the allocation address */
gran_semgive(priv);
gran_leave_critical(priv);
return (FAR void *)alloc;
}
@ -221,7 +221,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) @@ -221,7 +221,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size)
}
}
gran_semgive(priv);
gran_leave_critical(priv);
return NULL;
}

4
nuttx/mm/mm_granfree.c

@ -81,7 +81,7 @@ static inline void gran_common_free(FAR struct gran_s *priv, @@ -81,7 +81,7 @@ static inline void gran_common_free(FAR struct gran_s *priv,
/* Get exclusive access to the GAT */
gran_semtake(priv);
gran_enter_critical(priv);
/* Determine the granule number of the first granule in the allocation */
@ -121,7 +121,7 @@ static inline void gran_common_free(FAR struct gran_s *priv, @@ -121,7 +121,7 @@ static inline void gran_common_free(FAR struct gran_s *priv,
priv->gat[gatidx] &= ~(gatmask << gatbit);
}
gran_semgive(priv);
gran_leave_critical(priv);
}
/****************************************************************************

39
nuttx/mm/mm_graninit.c

@ -119,7 +119,12 @@ static inline FAR struct gran_s *gran_common_initialize(FAR void *heapstart, @@ -119,7 +119,12 @@ static inline FAR struct gran_s *gran_common_initialize(FAR void *heapstart,
priv->log2gran = log2gran;
priv->ngranules = ngranules;
priv->heapstart = alignedstart;
/* Initialize mutual exclusion support */
#ifndef CONFIG_GRAN_INTR
sem_init(&priv->exclsem, 0, 1);
#endif
}
return priv;
@ -172,38 +177,4 @@ GRAN_HANDLE gran_initialize(FAR void *heapstart, size_t heapsize, uint8_t log2gr @@ -172,38 +177,4 @@ GRAN_HANDLE gran_initialize(FAR void *heapstart, size_t heapsize, uint8_t log2gr
}
#endif
/****************************************************************************
* Name: gran_semtake and gran_semgive
*
* Description:
* Managed semaphore for the granule allocator. gran_semgive is
* implemented as a macro.
*
* Input Parameters:
* priv - Pointer to the gran state
*
* Returned Value:
* None
*
****************************************************************************/
void gran_semtake(FAR struct gran_s *priv)
{
int ret;
/* Continue waiting if we are awakened by a signal */
do
{
ret = sem_wait(&priv->exclsem);
if (ret < 0)
{
DEBUGASSERT(errno == EINTR);
}
}
while (ret < 0);
}
#endif /* CONFIG_GRAN */

Loading…
Cancel
Save