[abb18dc] | 1 | /* |
---|
| 2 | * BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR |
---|
| 3 | * |
---|
| 4 | * Workspace Handler |
---|
| 5 | * |
---|
[a2aad55] | 6 | * COPYRIGHT (c) 1989-2013. |
---|
[abb18dc] | 7 | * On-Line Applications Research Corporation (OAR). |
---|
| 8 | * |
---|
| 9 | * The license and distribution terms for this file may be |
---|
| 10 | * found in the file LICENSE in this distribution or at |
---|
| 11 | * http://www.rtems.com/license/LICENSE. |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | #if HAVE_CONFIG_H |
---|
| 15 | #include "config.h" |
---|
| 16 | #endif |
---|
| 17 | |
---|
| 18 | #include <rtems/system.h> |
---|
| 19 | #include <rtems/score/wkspace.h> |
---|
| 20 | #include <rtems/score/interr.h> |
---|
| 21 | |
---|
| 22 | #include <stdlib.h> |
---|
| 23 | |
---|
| 24 | #if defined(DEBUG_WORKSPACE) |
---|
| 25 | #include <stdio.h> |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | /* |
---|
| 29 | * _Workspace_Handler_initialization |
---|
| 30 | */ |
---|
[957ce33] | 31 | void _Workspace_Handler_initialization( |
---|
| 32 | Heap_Area *areas, |
---|
| 33 | size_t area_count, |
---|
| 34 | Heap_Initialization_or_extend_handler extend |
---|
| 35 | ) |
---|
[abb18dc] | 36 | { |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | /* |
---|
| 40 | * _Workspace_Allocate |
---|
| 41 | */ |
---|
| 42 | void *_Workspace_Allocate( |
---|
| 43 | size_t size |
---|
| 44 | ) |
---|
| 45 | { |
---|
| 46 | void *memory; |
---|
| 47 | |
---|
| 48 | memory = calloc( 1, size ); |
---|
| 49 | #if defined(DEBUG_WORKSPACE) |
---|
| 50 | fprintf( |
---|
| 51 | stderr, |
---|
| 52 | "Workspace_Allocate(%d) from %p/%p -> %p\n", |
---|
| 53 | size, |
---|
| 54 | __builtin_return_address( 0 ), |
---|
| 55 | __builtin_return_address( 1 ), |
---|
| 56 | memory |
---|
| 57 | ); |
---|
| 58 | #endif |
---|
| 59 | return memory; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | /* |
---|
| 63 | * _Workspace_Free |
---|
| 64 | */ |
---|
| 65 | void _Workspace_Free( |
---|
| 66 | void *block |
---|
| 67 | ) |
---|
| 68 | { |
---|
| 69 | #if defined(DEBUG_WORKSPACE) |
---|
| 70 | fprintf( |
---|
| 71 | stderr, |
---|
| 72 | block, |
---|
| 73 | __builtin_return_address( 0 ), |
---|
| 74 | __builtin_return_address( 1 ) |
---|
| 75 | ); |
---|
| 76 | #endif |
---|
| 77 | free( block ); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /* |
---|
| 81 | * _Workspace_Allocate_or_fatal_error |
---|
| 82 | */ |
---|
| 83 | void *_Workspace_Allocate_or_fatal_error( |
---|
| 84 | size_t size |
---|
| 85 | ) |
---|
| 86 | { |
---|
| 87 | void *memory; |
---|
| 88 | |
---|
| 89 | memory = calloc( 1, size ); |
---|
| 90 | #if defined(DEBUG_WORKSPACE) |
---|
| 91 | fprintf( |
---|
| 92 | stderr, |
---|
| 93 | "Workspace_Allocate_or_fatal_error(%d) from %p/%p -> %p\n", |
---|
| 94 | size, |
---|
| 95 | __builtin_return_address( 0 ), |
---|
| 96 | __builtin_return_address( 1 ), |
---|
| 97 | memory |
---|
| 98 | ); |
---|
| 99 | #endif |
---|
| 100 | |
---|
| 101 | return memory; |
---|
| 102 | } |
---|