annotate gsm-fw/services/pcm/pcmcode.c @ 948:c73516dd50bb

c139explore: delay before greeting printf to work around defect in fc-compalram
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 02 Nov 2015 22:11:06 +0000
parents aed920085e59
children
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 #include <string.h>
640
aed920085e59 PCM integration: pcmcode.c compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 638
diff changeset
12 #include "pcm.h"
aed920085e59 PCM integration: pcmcode.c compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 638
diff changeset
13 #include "../ffs/ffs.h"
aed920085e59 PCM integration: pcmcode.c compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 638
diff changeset
14 #include "../ffs/ffstrace.h"
638
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 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
17 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
18 extern UBYTE pcm_mem [];
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
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 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 *
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 ******************************************************************************/
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 // 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
26 // 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
27 // 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
28 // 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
29
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 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
31 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 return PCM_INITIALIZED;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 // 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
37 // 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
38 // (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
39 // 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
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 // look up a PCM file
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 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
44 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 int i = 0;
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 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
48 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 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
50 return i;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 i++;
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 return -1; // not found.
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 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
57 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 int i = 0;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 effs_t error;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 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
62
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 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
64 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 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
66 &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
67 (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
68
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 if (error < EFFS_OK) {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 // copy defaults to pcm_mem
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 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
72 &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
73 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
74 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 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
76 i++;
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
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 return PCM_INITIALIZED;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 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
83 pcm_FileInfo_Type * out_FileInfoPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 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
86
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 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
88
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 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
93 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
94 // 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
95 // hardwire exactly that!
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 // 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
97 out_FileInfoPtr->Version = 1;
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 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 }
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 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 * Normal read/write functions
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
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 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
108 USHORT in_BufferSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 UBYTE * out_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 UBYTE * out_VersionPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 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
113
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 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
115
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 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
120 return PCM_INVALID_SIZE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 // 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
123
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 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
125 *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
126
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 }
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 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
131 USHORT in_FileSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 UBYTE * in_BufferPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 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
135
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 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
137
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 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
142 return PCM_INVALID_SIZE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 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
145
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 // 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
147 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
148 &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
149 in_FileSize);
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
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 /******************************************************************************
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 * Record read/write functions
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
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 /* 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
160 * 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
161
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 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
163 USHORT in_Record,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 USHORT in_BufferSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 UBYTE * out_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 UBYTE * out_VersionPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 USHORT * out_MaxRecordsPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 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
170
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 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
172
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 return PCM_INVALID_FILE;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 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
177 return PCM_INVALID_SIZE;
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 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
180 return PCM_INVALID_RECORD;
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 memcpy (out_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 &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
184 in_BufferSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 *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
186 *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
187
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 }
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 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
192 USHORT in_Record,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 USHORT in_BufferSize,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 UBYTE * in_BufferPtr)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 {
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 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
197
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 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
199
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 if (i == -1)
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 return PCM_INVALID_FILE;
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_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
204 return PCM_INVALID_SIZE;
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 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
207 return PCM_INVALID_RECORD;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 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
210 in_BufferPtr,
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 in_BufferSize);
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 // 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
214 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
215 &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
216 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
217
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 return PCM_OK;
0b5f226bfdf4 gsm-fw/services/pcm: import from Leonardo source (FFS)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 }