Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
stack_malloc.c File Reference
#include <string.h>
#include <stdlib.h>
#include "utils/blinker.h"
#include "utils/constants.hxx"

Go to the source code of this file.

Functions

void * usb_malloc (unsigned long length)
 Custom malloc function for USB space.
 
 DECLARE_CONST (use_separate_stack_segment)
 Set this to true to allocate stacks in a separate memory segment (usually ethernet RAM).
 
void * stack_malloc (unsigned long length)
 Custom malloc function for stack spaces.
 
void * buffer_malloc (size_t length)
 Allocates a buffer.
 

Variables

char __ETHRAM_segment_start__
 Linker symbol defining the address where the ethernet RAM segment starts in the 32-bit address space.
 
static char * sstack_start = &__ETHRAM_segment_start__
 Next byte that's free in the stack memory allocation segment.
 
char __stacks_min__
 Linker symbol defining the first byte that is used by the interrupt stack in the stack segment.
 
char __USBRAM_segment_start__
 Linker symbol defining the address where the USB RAM segment starts in the 32-bit address space.
 
char __USBRAM_segment_end__
 Linker symbol defining the address where the USB RAM segment ends in the 32-bit address space.
 
static char * ublock_start = &__USBRAM_segment_start__
 Pointer to the next free (unallocated) byte in the USB_RAM segment.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • 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.

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 HOLDER 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.

Overrides the stack malloc function to allocate from ethernet memory on the NXP LPCxx68 processors.

Author
Balazs Racz
Date
23 June 2014

Definition in file freertos_drivers/nxp/stack_malloc.c.

Function Documentation

◆ buffer_malloc()

void * buffer_malloc ( size_t  length)

Allocates a buffer.

malloc implementation used for allocating buffer space.

Overrides the (weak) definition to put it to a separate RAM segment and leave more heap space free.

Parameters
sizein bytes, how large chunk we should allocate.
Returns
a newly allocated buffer. Cannot be freed.

Definition at line 114 of file freertos_drivers/nxp/stack_malloc.c.

◆ DECLARE_CONST()

DECLARE_CONST ( use_separate_stack_segment  )

Set this to true to allocate stacks in a separate memory segment (usually ethernet RAM).

If false, stack will be allocated by malloc() on the heap.

◆ stack_malloc()

void * stack_malloc ( unsigned long  length)

Custom malloc function for stack spaces.

Parameters
lengththe length of block to allocate
Returns
a pointer to the newly allocated block.

There is currently no way to free blocks allocated with this function, so only suitable for stacks of threads that are running throughout the entire life of the application.

Definition at line 63 of file freertos_drivers/nxp/stack_malloc.c.

◆ usb_malloc()

void * usb_malloc ( unsigned long  length)

Custom malloc function for USB space.

Parameters
lengththe length of block to allocate
Returns
a pointer to the newly allocated block.

There is currently no way to free blocks allocated with this function, so only suitable for blocks that are running throughout the entire life of the application.

Definition at line 96 of file freertos_drivers/nxp/stack_malloc.c.

Variable Documentation

◆ sstack_start

char* sstack_start = &__ETHRAM_segment_start__
static

Next byte that's free in the stack memory allocation segment.

Definition at line 44 of file freertos_drivers/nxp/stack_malloc.c.

◆ ublock_start

char* ublock_start = &__USBRAM_segment_start__
static

Pointer to the next free (unallocated) byte in the USB_RAM segment.

Definition at line 86 of file freertos_drivers/nxp/stack_malloc.c.