Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rmm.h
Go to the documentation of this file.
1 /*
2  * rmm.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * This memory manager provides general heap management and arbitrary
7  * alignment for any number of memory segments, and management of overlay
8  * memory.
9  *
10  * Copyright (C) 2005-2006 Texas Instruments, Inc.
11  *
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.
15  *
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.
19  */
20 
21 #ifndef RMM_
22 #define RMM_
23 
24 /*
25  * ======== rmm_addr ========
26  * DSP address + segid
27  */
28 struct rmm_addr {
31 };
32 
33 /*
34  * ======== rmm_segment ========
35  * Memory segment on the DSP available for remote allocations.
36  */
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 */
42 };
43 
44 /*
45  * ======== RMM_Target ========
46  */
47 struct rmm_target_obj;
48 
49 /*
50  * ======== rmm_alloc ========
51  *
52  * rmm_alloc is used to remotely allocate or reserve memory on the DSP.
53  *
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:
75  */
76 extern int rmm_alloc(struct rmm_target_obj *target, u32 segid, u32 size,
77  u32 align, u32 *dsp_address, bool reserve);
78 
79 /*
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().
84  *
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.
99  */
100 extern int rmm_create(struct rmm_target_obj **target_obj,
101  struct rmm_segment seg_tab[], u32 num_segs);
102 
103 /*
104  * ======== rmm_delete ========
105  * Delete target allocated in rmm_create().
106  *
107  * Parameters:
108  * target - Target returned from rmm_create().
109  * Returns:
110  * Requires:
111  * RMM initialized.
112  * Valid target.
113  * Ensures:
114  */
115 extern void rmm_delete(struct rmm_target_obj *target);
116 
117 /*
118  * ======== rmm_free ========
119  * Free or unreserve memory allocated through rmm_alloc().
120  *
121  * Parameters:
122  * target: - Target returned from rmm_create().
123  * segid: - Segment of memory to free.
124  * dsp_address: - Address to free or unreserve.
125  * size: - Size of memory to free or unreserve.
126  * reserved: - TRUE if memory was reserved only, otherwise FALSE.
127  * Returns:
128  * Requires:
129  * RMM initialized.
130  * Valid target.
131  * reserved || segid < target->num_segs.
132  * reserve || [dsp_address, dsp_address + size] is a valid memory range.
133  * Ensures:
134  */
135 extern bool rmm_free(struct rmm_target_obj *target, u32 segid, u32 dsp_addr,
136  u32 size, bool reserved);
137 
138 /*
139  * ======== rmm_stat ========
140  * Obtain memory segment status
141  *
142  * Parameters:
143  * segid: Segment ID of the dynamic loading segment.
144  * mem_stat_buf: Pointer to allocated buffer into which memory stats are
145  * placed.
146  * Returns:
147  * TRUE: Success.
148  * FALSE: Failure.
149  * Requires:
150  * segid < target->num_segs
151  * Ensures:
152  */
153 extern bool rmm_stat(struct rmm_target_obj *target, enum dsp_memtype segid,
154  struct dsp_memstat *mem_stat_buf);
155 
156 #endif /* RMM_ */