ISIX-RTOS - small operating system for ARM microcontrollers 1.2
|
#include <isix/memory.h>
#include <isix/types.h>
#include <isix/semaphore.h>
#include <prv/semaphore.h>
#include <prv/scheduler.h>
#include <isix/printk.h>
Go to the source code of this file.
Data Structures | |
struct | header |
Defines | |
#define | ISIX_DEBUG_MEMORY ISIX_DBG_OFF |
#define | MAGIC 0x19790822 |
#define | ALIGN_TYPE void * |
#define | ALIGN_MASK (sizeof(ALIGN_TYPE) - 1) |
#define | ALIGN_SIZE(p) (((size_t)(p) + ALIGN_MASK) & ~ALIGN_MASK) |
#define | LIMIT(p) |
Functions | |
static void | mem_lock_init (void) |
Lock the memory. | |
static void | mem_lock (void) |
Lock the memory. | |
static void | mem_unlock (void) |
Unlock the memory. | |
void | isix_alloc_init (void) |
Initialize global heap. | |
void * | isix_alloc (size_t size) |
void | isix_free (void *p) |
size_t | isix_heap_free (int *fragments) |
Variables | |
struct { | |
struct header free | |
} | heap |
static sem_t | mem_sem |
Semaphore for locking the memory allocator. |
#define ALIGN_SIZE | ( | p | ) | (((size_t)(p) + ALIGN_MASK) & ~ALIGN_MASK) |
Definition at line 32 of file memory.c.
Referenced by isix_alloc().
#define LIMIT | ( | p | ) |
#define MAGIC 0x19790822 |
Definition at line 29 of file memory.c.
Referenced by isix_alloc().
void* isix_alloc | ( | size_t | size | ) |
Allocate the memory from the global heap
[in] | size | Allocated size |
Definition at line 99 of file memory.c.
References ALIGN_SIZE, header::h, header::h_magic, header::h_next, header::h_size, heap, MAGIC, mem_lock(), mem_unlock(), and NULL.
Referenced by isix_fifo_create(), isix_init(), isix_sem_create_limited(), isix_task_create(), and isix_vtimer_create().
void isix_alloc_init | ( | void | ) |
Initialize global heap.
Definition at line 80 of file memory.c.
References header::h, header::h_next, header::h_size, heap, mem_lock_init(), and NULL.
Referenced by isix_init().
void isix_free | ( | void * | mem | ) |
Free alocated earlier memory area param[in] mem Pointer to the allocated memory
Definition at line 142 of file memory.c.
References header::h, header::h_next, header::h_size, heap, LIMIT, mem_lock(), mem_unlock(), and NULL.
Referenced by cleanup_tasks(), isix_fifo_create(), isix_fifo_destroy(), isix_sem_destroy(), isix_task_create(), and isix_vtimer_destroy().
size_t isix_heap_free | ( | int * | fragments | ) |
Function display current memory usage
[out] | fragments | - return number of fragments mem |
Definition at line 185 of file memory.c.
References heap, mem_lock(), and mem_unlock().
static void mem_lock | ( | void | ) | [static] |
Lock the memory.
Definition at line 64 of file memory.c.
References isix_scheduler_running, isix_sem_wait(), isix::ISIX_TIME_INFINITE, and mem_sem.
Referenced by isix_alloc(), isix_free(), and isix_heap_free().
static void mem_lock_init | ( | void | ) | [static] |
Lock the memory.
Definition at line 57 of file memory.c.
References isix::isix_sem_create(), and mem_sem.
Referenced by isix_alloc_init().
static void mem_unlock | ( | void | ) | [static] |
Unlock the memory.
Definition at line 72 of file memory.c.
References isix_scheduler_running, isix::isix_sem_signal(), and mem_sem.
Referenced by isix_alloc(), isix_free(), and isix_heap_free().
Definition at line 46 of file memory.c.
Referenced by port_cleanup_task().
struct { ... } heap [static] |
Referenced by isix_alloc(), isix_alloc_init(), isix_free(), and isix_heap_free().
sem_t mem_sem [static] |
Semaphore for locking the memory allocator.
Definition at line 52 of file memory.c.
Referenced by mem_lock(), mem_lock_init(), and mem_unlock().