• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/staging/tidspbridge/include/dspbridge/
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 */
28struct rmm_addr {
29	u32 addr;
30	s32 segid;
31};
32
33/*
34 *  ======== rmm_segment ========
35 *  Memory segment on the DSP available for remote allocations.
36 */
37struct 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 */
47struct 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 */
76extern 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 */
100extern 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 */
115extern void rmm_delete(struct rmm_target_obj *target);
116
117/*
118 *  ======== rmm_exit ========
119 *  Exit the RMM module
120 *
121 *  Parameters:
122 *  Returns:
123 *  Requires:
124 *      rmm_init successfully called.
125 *  Ensures:
126 */
127extern void rmm_exit(void);
128
129/*
130 *  ======== rmm_free ========
131 *  Free or unreserve memory allocated through rmm_alloc().
132 *
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:
146 */
147extern bool rmm_free(struct rmm_target_obj *target, u32 segid, u32 dsp_addr,
148		     u32 size, bool reserved);
149
150/*
151 *  ======== rmm_init ========
152 *  Initialize the RMM module
153 *
154 *  Parameters:
155 *  Returns:
156 *      TRUE:   Success.
157 *      FALSE:  Failure.
158 *  Requires:
159 *  Ensures:
160 */
161extern bool rmm_init(void);
162
163/*
164 *  ======== rmm_stat ========
165 *  Obtain  memory segment status
166 *
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:
177 */
178extern bool rmm_stat(struct rmm_target_obj *target, enum dsp_memtype segid,
179		     struct dsp_memstat *mem_stat_buf);
180
181#endif /* RMM_ */
182