source: soft/giet_vm/giet_common/kernel_malloc.h @ 594

Last change on this file since 594 was 594, checked in by alain, 9 years ago

1) Fix a bug in the _free() function in kernel_malloc.c
2) Introduce a strlen() function in utils.c

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : kernel_malloc.h
3// Date     : 05/12/2014
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6//////////////////////////////////////////////////////////////////////////////////
7// The kernel_malloc.c and kernel_malloc.h files are part of the giet_vm kernel.
8//////////////////////////////////////////////////////////////////////////////////
9
10#ifndef KERNEL_MALLOC_H_
11#define KERNEL_MALLOC_H_
12
13#include "kernel_locks.h"
14#include "hard_config.h"
15
16
17#define MIN_BLOCK_SIZE      0x40
18
19
20//////////////////////////////////////////////////////////////////////////////////
21//             heap descriptor (one per cluster)
22//////////////////////////////////////////////////////////////////////////////////
23
24typedef struct kernel_heap_s
25{
26    spin_lock_t    lock;            // lock protecting exclusive access
27    unsigned int   heap_base;       // heap base address
28    unsigned int   heap_size;       // heap size (bytes)
29    unsigned int   alloc_base;      // alloc[] array base address
30    unsigned int   alloc_size;      // alloc[] array size (bytes)
31    unsigned int   free[32];        // array of base addresses of free blocks
32                                    // (address of first block of a given size)
33} kernel_heap_t;
34
35//////////////////////////////////////////////////////////////////////////////////
36//             global variables
37//////////////////////////////////////////////////////////////////////////////////
38
39extern kernel_heap_t  kernel_heap[X_SIZE][Y_SIZE];
40
41//////////////////////////////////////////////////////////////////////////////////
42//  access functions
43//////////////////////////////////////////////////////////////////////////////////
44
45extern void* _malloc( unsigned int size );
46
47extern void* _remote_malloc( unsigned int size, 
48                             unsigned int x,
49                             unsigned int y );
50
51extern void _free( void* ptr );
52
53extern void _heap_init();
54
55
56#endif
57
58// Local Variables:
59// tab-width: 4
60// c-basic-offset: 4
61// c-file-offsets:((innamespace . 0)(inline-open . 0))
62// indent-tabs-mode: nil
63// End:
64// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
65
Note: See TracBrowser for help on using the repository browser.