FreeCalypso > hg > fc-magnetite
comparison src/g23m-fad/ra/ra_shm.c @ 174:90eb61ecd093
src/g23m-fad: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Oct 2016 05:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
173:bf64d785238a | 174:90eb61ecd093 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-F&D (8411) | |
4 | Modul : RA_SHM | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Modul defines the functions for accessing the | |
18 | shared memory segment between MCU and DSP | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef RA_SHM_C | |
23 #define RA_SHM_C | |
24 #endif | |
25 | |
26 #define ENTITY_RA | |
27 | |
28 /*==== INCLUDES ===================================================*/ | |
29 | |
30 #include <string.h> | |
31 #include "typedefs.h" | |
32 #include "pconst.cdg" | |
33 #include "vsi.h" | |
34 #include "custom.h" | |
35 #include "gsm.h" | |
36 #include "cnf_ra.h" | |
37 #include "prim.h" | |
38 #include "pei.h" | |
39 #include "tok.h" | |
40 #include "ccdapi.h" | |
41 #include "ra.h" | |
42 | |
43 /*==== CONST ======================================================*/ | |
44 /*==== TYPES ======================================================*/ | |
45 /*==== VARIABLES ==================================================*/ | |
46 /*==== FUNCTIONS ==================================================*/ | |
47 | |
48 /* | |
49 +--------------------------------------------------------------------+ | |
50 | PROJECT : GSM-F&D (8411) MODULE : RA_SHM | | |
51 | STATE : code ROUTINE : shm_set_dsp_buffer | | |
52 +--------------------------------------------------------------------+ | |
53 | |
54 PURPOSE : | |
55 */ | |
56 | |
57 GLOBAL USHORT shm_set_dsp_buffer(T_FRAME_DESC *data, register USHORT *buffer, USHORT offs, USHORT free) | |
58 { | |
59 register UBYTE *b; | |
60 USHORT len, segment; | |
61 | |
62 buffer = (USHORT*) ( ( (UBYTE*) buffer ) + offs ); | |
63 /* | |
64 * write the both segments specified by the frame descriptor data to the DSP mem. | |
65 */ | |
66 for (segment = 0; segment < 2; segment++) | |
67 { | |
68 /* | |
69 * limitate the length fields; | |
70 */ | |
71 len = free; | |
72 | |
73 if (len > data->Len[segment]) | |
74 len = data->Len[segment]; | |
75 | |
76 if (len) | |
77 { | |
78 data->Len[segment] -= len; | |
79 b = data->Adr[segment]; | |
80 { | |
81 memcpy( (UBYTE*) buffer, (UBYTE*) b, (USHORT) len ); | |
82 buffer = (USHORT*) ( ( (UBYTE*) buffer ) + len ); | |
83 free -= len; | |
84 offs += len; | |
85 } | |
86 } | |
87 } | |
88 return offs; | |
89 } | |
90 | |
91 GLOBAL U8 shm_set_dsp_buffer_new(T_FD *pFD, USHORT *buffer, U8 offs, U8 free) | |
92 { | |
93 U8 len; | |
94 | |
95 buffer = (USHORT*)(((UBYTE*)buffer) + offs); | |
96 /* | |
97 * limitate the length fields; | |
98 */ | |
99 len = MINIMUM(free, pFD->len); | |
100 if (len) | |
101 { | |
102 memcpy((UBYTE*)buffer, (UBYTE*)pFD->buf, (USHORT)len); | |
103 buffer = (USHORT*)(((UBYTE*)buffer) + len); | |
104 } | |
105 return len; | |
106 } | |
107 | |
108 /* | |
109 +--------------------------------------------------------------------+ | |
110 | PROJECT : GSM-F&D (8411) MODULE : RA_SHM | | |
111 | STATE : code ROUTINE : shm_get_dsp_buffer | | |
112 +--------------------------------------------------------------------+ | |
113 | |
114 PURPOSE : | |
115 | |
116 */ | |
117 GLOBAL USHORT shm_get_dsp_buffer(T_FRAME_DESC *data, register USHORT *buffer, USHORT bytes_to_read) | |
118 { | |
119 register UBYTE *b; | |
120 USHORT offs = 0; | |
121 USHORT len, segment; | |
122 /* | |
123 * read the both segments specified by the frame descriptor data from the DSP mem | |
124 */ | |
125 for (segment = 0; segment < 2; segment++) | |
126 { | |
127 len = MINIMUM(data->Len[segment], bytes_to_read); | |
128 if (len) | |
129 { | |
130 data->Len[segment] -= len; | |
131 b = data->Adr[segment]; | |
132 #ifdef TI_PS_16BIT_CPY | |
133 api_memcpy((UBYTE*)b, (UBYTE*)buffer, (USHORT)len ); | |
134 #else | |
135 memcpy((UBYTE*)b, (UBYTE*)buffer, (USHORT)len ); | |
136 #endif | |
137 buffer = (USHORT*)(((UBYTE*)buffer) + len); | |
138 bytes_to_read -= len; | |
139 offs += len; | |
140 } | |
141 } | |
142 return offs; | |
143 } | |
144 | |
145 GLOBAL U8 shm_get_dsp_buffer_new(USHORT *buffer, U8 bytes_to_read, T_FD *pFD) | |
146 { | |
147 U8 len = MINIMUM(pFD->len, bytes_to_read); | |
148 if (len) | |
149 { | |
150 pFD->len = len; | |
151 #ifdef TI_PS_16BIT_CPY | |
152 api_memcpy(pFD->buf, (UBYTE*)buffer, len); | |
153 #else | |
154 memcpy(pFD->buf, (UBYTE*)buffer, len); | |
155 #endif | |
156 } | |
157 return len; | |
158 } | |
159 |