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