1 2 3 4 5 6 7 8 9 10 11 12
13 14 15 16 17
18
19 /*!
20 * ======== IHeap ========
21 * Interface to heap functions.
22 *
23 * All heap implementations inherit from this interface.
24 * The implementations can have additional configuration
25 * parmeters and functions.
26 *
27 */
28 @DirectCall
29
30 interface IHeap {
31
32 instance:
33
34 /*!
35 * ======== alloc ========
36 * Allocates a block of memory from the heap.
37 *
38 * This method returns a block of memory from the heap.
39 * It is called by the `{@link xdc.runtime.Memory#alloc()}` function.
40 *
41 * @param(size) size (in MADUs) of the block
42 * @param(align) alignment (in MADUs) of the block
43 * @param(eb) pointer to error block
44 *
45 * @a(returns) Returns the address of the allocated memory.
46 */
47 Ptr alloc(SizeT size, SizeT align, Error.Block *eb);
48
49 /*!
50 * ======== create ========
51 * Create a heap.
52 *
53 * See specific `IHeap` implementation for parameters used.
54 */
55 create();
56
57 /*!
58 * ======== free ========
59 * Free a block of memory back to the heap.
60 *
61 * This method gives back a block of memory to a heap.
62 * It is called by the `{@link xdc.runtime.Memory#free()}` function.
63 *
64 * @param(block) non-`NULL` address of allocated block to free
65 * @param(size) size (in MADUs) of the block of memory to free
66 */
67 Void free(Ptr block, SizeT size);
68
69 /*!
70 * ======== isBlocking ========
71 * Returns whether the heap may block during an `{@link #alloc()}` or
72 * `{@link #free()}`.
73 *
74 * @a(returns) If the heap might block, `TRUE` is returned.
75 * If the heap does not block, `FALSE` is returned.
76 */
77 Bool isBlocking();
78
79 /*!
80 * ======== getStats ========
81 * Retrieve the statistics from the heap.
82 *
83 * The caller passes in a pointer to a `{@link xdc.runtime.Memory#Stats}`
84 * structure and `getStats` fills in this structure.
85 *
86 * This function is called by the `{@link xdc.runtime.Memory#getStats()}`
87 * function.
88 *
89 * @param(stats) non-`NULL` pointer to an output buffer
90 */
91 Void getStats(Memory.Stats *stats);
92 }
93 94 95
96