RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / tidspbridge / include / dspbridge / rmm.h
blobbaea536681e97966986258144cdcd5eb5f7daac7
1 /*
2 * rmm.h
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * This memory manager provides general heap management and arbitrary
7 * alignment for any number of memory segments, and management of overlay
8 * memory.
10 * Copyright (C) 2005-2006 Texas Instruments, Inc.
12 * This package is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 #ifndef RMM_
22 #define RMM_
25 * ======== rmm_addr ========
26 * DSP address + segid
28 struct rmm_addr {
29 u32 addr;
30 s32 segid;
34 * ======== rmm_segment ========
35 * Memory segment on the DSP available for remote allocations.
37 struct rmm_segment {
38 u32 base; /* Base of the segment */
39 u32 length; /* Size of the segment (target MAUs) */
40 s32 space; /* Code or data */
41 u32 number; /* Number of Allocated Blocks */
45 * ======== RMM_Target ========
47 struct rmm_target_obj;
50 * ======== rmm_alloc ========
52 * rmm_alloc is used to remotely allocate or reserve memory on the DSP.
54 * Parameters:
55 * target - Target returned from rmm_create().
56 * segid - Memory segment to allocate from.
57 * size - Size (target MAUS) to allocate.
58 * align - alignment.
59 * dsp_address - If reserve is FALSE, the location to store allocated
60 * address on output, otherwise, the DSP address to
61 * reserve.
62 * reserve - If TRUE, reserve the memory specified by dsp_address.
63 * Returns:
64 * 0: Success.
65 * -ENOMEM: Memory allocation on GPP failed.
66 * -ENXIO: Cannot "allocate" overlay memory because it's
67 * already in use.
68 * Requires:
69 * RMM initialized.
70 * Valid target.
71 * dsp_address != NULL.
72 * size > 0
73 * reserve || target->num_segs > 0.
74 * Ensures:
76 extern int rmm_alloc(struct rmm_target_obj *target, u32 segid, u32 size,
77 u32 align, u32 *dsp_address, bool reserve);
80 * ======== rmm_create ========
81 * Create a target object with memory segments for remote allocation. If
82 * seg_tab == NULL or num_segs == 0, memory can only be reserved through
83 * rmm_alloc().
85 * Parameters:
86 * target_obj: - Location to store target on output.
87 * seg_tab: - Table of memory segments.
88 * num_segs: - Number of memory segments.
89 * Returns:
90 * 0: Success.
91 * -ENOMEM: Memory allocation failed.
92 * Requires:
93 * RMM initialized.
94 * target_obj != NULL.
95 * num_segs == 0 || seg_tab != NULL.
96 * Ensures:
97 * Success: Valid *target_obj.
98 * Failure: *target_obj == NULL.
100 extern int rmm_create(struct rmm_target_obj **target_obj,
101 struct rmm_segment seg_tab[], u32 num_segs);
104 * ======== rmm_delete ========
105 * Delete target allocated in rmm_create().
107 * Parameters:
108 * target - Target returned from rmm_create().
109 * Returns:
110 * Requires:
111 * RMM initialized.
112 * Valid target.
113 * Ensures:
115 extern void rmm_delete(struct rmm_target_obj *target);
118 * ======== rmm_exit ========
119 * Exit the RMM module
121 * Parameters:
122 * Returns:
123 * Requires:
124 * rmm_init successfully called.
125 * Ensures:
127 extern void rmm_exit(void);
130 * ======== rmm_free ========
131 * Free or unreserve memory allocated through rmm_alloc().
133 * Parameters:
134 * target: - Target returned from rmm_create().
135 * segid: - Segment of memory to free.
136 * dsp_address: - Address to free or unreserve.
137 * size: - Size of memory to free or unreserve.
138 * reserved: - TRUE if memory was reserved only, otherwise FALSE.
139 * Returns:
140 * Requires:
141 * RMM initialized.
142 * Valid target.
143 * reserved || segid < target->num_segs.
144 * reserve || [dsp_address, dsp_address + size] is a valid memory range.
145 * Ensures:
147 extern bool rmm_free(struct rmm_target_obj *target, u32 segid, u32 dsp_addr,
148 u32 size, bool reserved);
151 * ======== rmm_init ========
152 * Initialize the RMM module
154 * Parameters:
155 * Returns:
156 * TRUE: Success.
157 * FALSE: Failure.
158 * Requires:
159 * Ensures:
161 extern bool rmm_init(void);
164 * ======== rmm_stat ========
165 * Obtain memory segment status
167 * Parameters:
168 * segid: Segment ID of the dynamic loading segment.
169 * mem_stat_buf: Pointer to allocated buffer into which memory stats are
170 * placed.
171 * Returns:
172 * TRUE: Success.
173 * FALSE: Failure.
174 * Requires:
175 * segid < target->num_segs
176 * Ensures:
178 extern bool rmm_stat(struct rmm_target_obj *target, enum dsp_memtype segid,
179 struct dsp_memstat *mem_stat_buf);
181 #endif /* RMM_ */