annotate gsm-fw/services/pcm/pcmcode.c @ 638:0b5f226bfdf4

gsm-fw/services/pcm: import from Leonardo source (FFS)
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 03 Sep 2014 16:26:27 +0000
parents
children aed920085e59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
638
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Flash File System (ffs)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * Condat PCM Compatibility Support
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 *
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * $Id: pcmcode.c 1.46 Tue, 06 Nov 2001 11:55:21 +0100 tsj $
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 *
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 ******************************************************************************/
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #ifndef TARGET
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "board.cfg"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "ffs.cfg"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #endif
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include <string.h>
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #include "ffs/pcm.h"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 #include "ffs/ffs.h"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 #include "ffs/board/ffstrace.h"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 #if (TARGET == 1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 #include "sys.cfg"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 #if (BOARD == 34)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 #include "ffs/board/ffspcm.h"
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 #endif
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 #else
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 #define STD 6
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 #define NULL 0
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 #endif
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 extern const T_PCM_DESCRIPTION pcm_table[];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 extern const UBYTE pcm_default_values[];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 extern UBYTE pcm_mem [];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 extern UBYTE std;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 *
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 ******************************************************************************/
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 // pcm_Init() has been renamed to pcm_init() so that it is not called
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 // anywhere else than it should. The old pcm_Init() is now empty. This new
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 // pcm_init() scans through the pcm file table and attempts to read each
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 // file from ffs into the pcm RAM image.
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 drv_Return_Type pcm_Init(void)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 return PCM_INITIALIZED;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 // Note that PCM file data chunks start with one byte for the file data
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 // checksum, followed by another byte for the version. The third byte
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 // (offset 2) is the start of the actual filedata. We ignore these first two
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 // bytes e.g. we only read/write the actual file data!
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 // look up a PCM file
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 int pcm_lookup(char *pcm_name)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 int i = 0;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 while (pcm_table[i].identifier != NULL)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 if (!strcmp((char *) pcm_name, pcm_table[i].identifier + 5))
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 return i;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 i++;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 return -1; // not found.
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 drv_Return_Type pcm_init(void)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 int i = 0;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 effs_t error;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 ttw(ttr(TTrInit, "pcm_init" NL));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 // Avenger 2 tri band radio
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 #if (BOARD==34)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 std = ffs_GetBand();
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 #else
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 std = STD;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 #endif
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 while (pcm_table[i].identifier != NULL)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 error = ffs_fread(pcm_table[i].identifier,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 &pcm_mem[pcm_table[i].start + 2],
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 (pcm_table[i].length - 2) * pcm_table[i].records);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 if (error < EFFS_OK) {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 // copy defaults to pcm_mem
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 memcpy (&pcm_mem[pcm_table[i].start] + 2,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 &pcm_default_values[pcm_table[i].start - 2*i],
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 pcm_table[i].records * (pcm_table[i].length - 2));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 pcm_mem[pcm_table[i].start + 1] = 1; // file version
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 i++;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 return PCM_INITIALIZED;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 drv_Return_Type pcm_GetFileInfo(UBYTE * in_FileName,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 pcm_FileInfo_Type * out_FileInfoPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 int i = pcm_lookup((char*)in_FileName);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 ttw(ttr(TTrPcmRead, "pcm_gfi(%s)" NL, in_FileName));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 out_FileInfoPtr->FileLocation = &pcm_mem [pcm_table[i].start+2];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 out_FileInfoPtr->FileSize = pcm_table[i].length -2;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 // As Condat has determined that all files is version 1, we just
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 // hardwire exactly that!
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 // out_FileInfoPtr->Version = pcm_mem [pcm_table[i].start + 1];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 out_FileInfoPtr->Version = 1;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 * Normal read/write functions
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 ******************************************************************************/
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 drv_Return_Type pcm_ReadFile(UBYTE * in_FileName,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 USHORT in_BufferSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 UBYTE * out_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 UBYTE * out_VersionPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 int i = pcm_lookup((char*)in_FileName);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 ttw(ttr(TTrPcmRead, "pcm_rf(%s)" NL, in_FileName));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 if (in_BufferSize + 2 != pcm_table[i].length)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 return PCM_INVALID_SIZE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 // checksum check removed --- it is redundant!
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 memcpy (out_BufferPtr, &pcm_mem[pcm_table[i].start+2], in_BufferSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 *out_VersionPtr = pcm_mem[pcm_table[i].start+1];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 drv_Return_Type pcm_WriteFile(UBYTE * in_FileName,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 USHORT in_FileSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 UBYTE * in_BufferPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 int i = pcm_lookup((char*)in_FileName);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 ttw(ttr(TTrPcmWrite, "pcm_wf(%s)" NL, in_FileName));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 if (in_FileSize + 2 != pcm_table[i].length)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 return PCM_INVALID_SIZE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 memcpy (&pcm_mem[pcm_table[i].start+2], in_BufferPtr, in_FileSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 // write the whole file to ffs! (ignoring errors)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 ffs_fwrite(pcm_table[i].identifier,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 &pcm_mem[pcm_table[i].start + 2],
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 in_FileSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 * Record read/write functions
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 ******************************************************************************/
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 /* Record files are implemented by having the first two bytes of a
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 * file be equal to the record size. */
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 drv_Return_Type pcm_ReadRecord(UBYTE * in_FileName,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 USHORT in_Record,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 USHORT in_BufferSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 UBYTE * out_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 UBYTE * out_VersionPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 USHORT * out_MaxRecordsPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 int i = pcm_lookup((char*)in_FileName);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 ttw(ttr(TTrPcmRead, "pcm_rr(%s)" NL, in_FileName));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 if (in_BufferSize + 2 != pcm_table[i].length)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 return PCM_INVALID_SIZE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 if (in_Record == 0 || in_Record > pcm_table[i].records)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 return PCM_INVALID_RECORD;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 memcpy (out_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 &pcm_mem[pcm_table[i].start + 2 + (in_Record-1) * in_BufferSize],
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 in_BufferSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 *out_MaxRecordsPtr = pcm_table[i].records;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 *out_VersionPtr = pcm_mem [pcm_table[i].start + 1];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 drv_Return_Type pcm_WriteRecord(UBYTE * in_FileName,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 USHORT in_Record,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 USHORT in_BufferSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 UBYTE * in_BufferPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 int i = pcm_lookup((char*)in_FileName);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 ttw(ttr(TTrPcmWrite, "pcm_wr(%s)" NL, in_FileName));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 if (in_BufferSize + 2 != pcm_table[i].length)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 return PCM_INVALID_SIZE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 if (in_Record == 0 || in_Record > pcm_table[i].records)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 return PCM_INVALID_RECORD;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 memcpy (&pcm_mem [pcm_table[i].start + 2 + (in_Record-1) * in_BufferSize],
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 in_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 in_BufferSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 // write the whole file to ffs! (ignoring errors)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 ffs_fwrite(pcm_table[i].identifier,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 &pcm_mem [pcm_table[i].start + 2],
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 pcm_table[i].records * (pcm_table[i].length - 2));
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 }