1
0
Fork 0
forked from nuttx/nuttx-update

mm/heap: Move semaphore related declaration to private header

since other subsystem doesn't need call these function anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Idfb217c412db62d9f17f427310b75bb78785dc50
This commit is contained in:
Xiang Xiao 2021-03-08 21:59:32 +08:00 committed by Abdelatif Guettouche
parent 0f44e9539e
commit e14c458747
19 changed files with 11 additions and 270 deletions

View file

@ -69,28 +69,5 @@ void up_idle(void)
*/
nxsched_process_timer();
#else
/* This would be an appropriate place to put some MCU-specific logic to
* sleep in a reduced power mode until an interrupt occurs to save power
*/
/* This is a kludge that I still don't understand. The call to kmm_trysemaphore()
* in the nx_start.c IDLE loop seems necessary for the good health of the IDLE
* loop. When the work queue is enabled, this logic is removed from the IDLE
* loop and it appears that we are somehow left idling with interrupts non-
* functional. The following should be no-op, it just disables then re-enables
* interrupts. But it fixes the problem and will stay here until I understand
* the problem/fix better.
*
* And no, the contents of the CP0 status register are not incorrect. But for
* some reason the status register needs to be re-written again on this thread
* for it to take effect. This might be a PIC32-only issue?
*/
#ifdef CONFIG_SCHED_WORKQUEUE
irqstate_t flags = enter_critical_section();
leave_critical_section(flags);
#endif
#endif
}

View file

@ -69,26 +69,5 @@ void up_idle(void)
*/
nxsched_process_timer();
#else
/* This would be an appropriate place to put some MCU-specific logic to
* sleep in a reduced power mode until an interrupt occurs to save power
*
* This is a kludge that I still don't understand. The call to
* kmm_trysemaphore() in the nx_start.c IDLE loop seems necessary for the
* good health of the IDLE loop. When the work queue is enabled, this logic
* is removed from the IDLE loop and it appears that we are somehow left
* idling with interrupts non- functional. The following should be no-op,
* it just disables then re-enables interrupts. But it fixes the problem
* and will stay here until I understand the problem/fix better. And no,
* the contents of the CP0 status register are not incorrect. But for some
* reason the status register needs to be re-written again on this thread
* for it to take effect.
*/
#ifdef CONFIG_SCHED_WORKQUEUE
irqstate_t flags = enter_critical_section();
leave_critical_section(flags);
#endif
#endif
}

View file

@ -68,24 +68,4 @@ void up_idle(void)
*/
nxsched_process_timer();
#else
/* This would be an appropriate place to put some MCU-specific logic to
* sleep in a reduced power mode until an interrupt occurs to save power
*/
/* This is a kludge that I still don't understand. The call to
* kmm_trysemaphore() in the nx_start.c IDLE loop seems necessary for the
* good health of the IDLE loop. When the work queue is enabled, this
* logic is removed from the IDLE loop and it appears that we are somehow
* left idling with interrupts non-functional. The following should be
* no-op, it just disables then re-enables interrupts. But it fixes the
* problem and will stay here until I understand the problem/fix better.
*/
#ifdef CONFIG_SCHED_WORKQUEUE
irqstate_t flags = enter_critical_section();
leave_critical_section(flags);
#endif
#endif
}

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -45,8 +45,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -29,8 +29,6 @@
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(umm_trysemaphore)
EXTERN(umm_givesemaphore)
EXTERN(malloc)
EXTERN(realloc)

View file

@ -70,8 +70,6 @@ extern "C"
#define kumm_initialize(h,s) umm_initialize(h,s)
#define kumm_addregion(h,s) umm_addregion(h,s)
#define kumm_trysemaphore() umm_trysemaphore()
#define kumm_givesemaphore() umm_givesemaphore()
#define kumm_calloc(n,s) calloc(n,s);
#define kumm_malloc(s) malloc(s)
@ -91,8 +89,6 @@ extern "C"
# 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_calloc(n,s) calloc(n,s);
# define kmm_malloc(s) malloc(s)

View file

@ -29,8 +29,6 @@
#include <sys/types.h>
#include <stdbool.h>
#include <string.h>
#include <semaphore.h>
/****************************************************************************
* Pre-processor Definitions
@ -185,25 +183,6 @@ void umm_addregion(FAR void *heapstart, size_t heapsize);
void kmm_addregion(FAR void *heapstart, size_t heapsize);
#endif
/* Functions contained in mm_sem.c ******************************************/
void mm_seminitialize(FAR struct mm_heap_s *heap);
void mm_takesemaphore(FAR struct mm_heap_s *heap);
int mm_trysemaphore(FAR struct mm_heap_s *heap);
void mm_givesemaphore(FAR struct mm_heap_s *heap);
/* Functions contained in umm_sem.c *****************************************/
int umm_trysemaphore(void);
void umm_givesemaphore(void);
/* Functions contained in kmm_sem.c *****************************************/
#ifdef CONFIG_MM_KERNEL_HEAP
int kmm_trysemaphore(void);
void kmm_givesemaphore(void);
#endif
/* Functions contained in mm_malloc.c ***************************************/
FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size);

View file

@ -22,7 +22,7 @@
ifeq ($(CONFIG_MM_KERNEL_HEAP),y)
CSRCS += kmm_initialize.c kmm_addregion.c kmm_sem.c
CSRCS += kmm_initialize.c kmm_addregion.c
CSRCS += kmm_brkaddr.c kmm_calloc.c kmm_extend.c kmm_free.c kmm_mallinfo.c
CSRCS += kmm_malloc.c kmm_memalign.c kmm_realloc.c kmm_zalloc.c kmm_heapmember.c

View file

@ -1,73 +0,0 @@
/****************************************************************************
* mm/kmm_heap/kmm_sem.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm/mm.h>
#ifdef CONFIG_MM_KERNEL_HEAP
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kmm_trysemaphore
*
* Description:
* Try to take the kernel heap semaphore.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/
int kmm_trysemaphore(void)
{
return mm_trysemaphore(&g_kmmheap);
}
/****************************************************************************
* Name: kmm_givesemaphore
*
* Description:
* Give the kernel heap semaphore.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/
void kmm_givesemaphore(void)
{
return mm_givesemaphore(&g_kmmheap);
}
#endif /* CONFIG_MM_KERNEL_HEAP */

View file

@ -111,6 +111,8 @@
* Public Types
****************************************************************************/
struct mm_heap_s;
/* Determines the size of the chunk size/offset type */
#ifdef CONFIG_MM_SMALL
@ -203,9 +205,14 @@ struct mm_heap_impl_s
FAR struct mm_delaynode_s *mm_delaylist;
};
/* Functions contained in mm_shrinkchunk.c **********************************/
/* Functions contained in mm_sem.c ******************************************/
struct mm_heap_s;
void mm_seminitialize(FAR struct mm_heap_s *heap);
void mm_takesemaphore(FAR struct mm_heap_s *heap);
int mm_trysemaphore(FAR struct mm_heap_s *heap);
void mm_givesemaphore(FAR struct mm_heap_s *heap);
/* Functions contained in mm_shrinkchunk.c **********************************/
void mm_shrinkchunk(FAR struct mm_heap_s *heap,
FAR struct mm_allocnode_s *node, size_t size);

View file

@ -20,7 +20,7 @@
# User heap allocator
CSRCS += umm_initialize.c umm_addregion.c umm_sem.c
CSRCS += umm_initialize.c umm_addregion.c
CSRCS += umm_brkaddr.c umm_calloc.c umm_extend.c umm_free.c umm_mallinfo.c
CSRCS += umm_malloc.c umm_memalign.c umm_realloc.c umm_zalloc.c umm_heapmember.c
CSRCS += umm_globals.c umm_valloc.c umm_aligned_alloc.c umm_posix_memalign.c

View file

@ -1,75 +0,0 @@
/****************************************************************************
* mm/umm_heap/umm_sem.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm/mm.h>
#include "umm_heap/umm_heap.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: umm_trysemaphore
*
* Description:
* This is a simple wrapper for the mm_trysemaphore() function. This
* function is exported from the user-space blob so that the kernel
* can manage the user-mode allocator.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/
int umm_trysemaphore(void)
{
return mm_trysemaphore(USR_HEAP);
}
/****************************************************************************
* Name: umm_givesemaphore
*
* Description:
* This is a simple wrapper for the mm_givesemaphore() function. This
* function is exported from the user-space blob so that the kernel
* can manage the user-mode allocator.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/
void umm_givesemaphore(void)
{
mm_givesemaphore(USR_HEAP);
}

View file

@ -762,12 +762,6 @@ void nx_start(void)
DEBUGASSERT(this_cpu() == 0 && CONFIG_MAX_TASKS > CONFIG_SMP_NCPUS);
/* Take the memory manager semaphore on this CPU so that it will not be
* available on the other CPUs until we have finished initialization.
*/
DEBUGVERIFY(kmm_trysemaphore());
/* Then start the other CPUs */
DEBUGVERIFY(nx_smp_start());
@ -784,13 +778,6 @@ void nx_start(void)
DEBUGVERIFY(nx_bringup());
#ifdef CONFIG_SMP
/* Let other threads have access to the memory manager */
kmm_givesemaphore();
#endif /* CONFIG_SMP */
/* The IDLE Loop **********************************************************/
/* When control is return to this point, the system is idle. */