annotate gsm-fw/services/ffs/tmffs.c @ 639:c07f9df9f6af

gsm-fw/services/pcm/pcm.h: basic preen
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 03 Sep 2014 16:32:11 +0000
parents 842c9fd828fd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Flash File System (ffs)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * ffs testmode interface
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 *
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * $Id: tmffs.c 1.51 Thu, 18 Dec 2003 10:50:52 +0100 tsj $
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 *
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "../../include/config.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "../../riviera/rv/rv_defined_swe.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #ifdef RVM_ETM_SWE
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "../etm/etm.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include "../etm/etm_api.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 #include "ffs.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 #include "task.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 #include "ffstrace.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 #include "tmffs.h"
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 #include <string.h>
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 * Local globals for all protocols
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 #if TMFFS1 || TMFFS2
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 static int32 bufsize, tmpsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 static uint8 stringsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 effs_t ffs_initialize(void);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 effs_t ffs_exit(void);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 #define tmffs_put8(x) *outp++ = x;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 #define tmffs_put16(x) *outp++ = (x & 0xff); *outp++ = (x>>8);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 // Not in use
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 //#define tmffs_put32(x) tmffs_put16(x); tmffs_put16(x >> 16);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 #ifdef RVM_ETM_SWE
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 int etm_ffs2(T_ETM_PKT *pkt, unsigned char *inp, int insize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 * TM FFS registration to ETM database
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 *****************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 /* Callback function registered in ETM database */
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 int etm_ffs1_pkt_receive(uint8 *data, int size)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 int mid;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 T_ETM_PKT *pkt;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 ttw(ttr(TTrTmffs, "etm_ffs1_pkt_receive(*, %d)" NL, size));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 /* Create TestMode return Packet */
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 if ((pkt = (T_ETM_PKT *) target_malloc(sizeof(T_ETM_PKT))) == NULL) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 ttw(ttr(TTrTmffs, "etm_ffs1_pkt_receive(): Limit of memory bank reached" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 return ETM_NOMEM;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 // Max packet size for TM3 is 128 bytes
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 size = tm_ffs(pkt->data, TM3_PACKET_SIZE, data, size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 pkt->size = size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 pkt->status = ETM_OK;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 pkt->mid = ETM_FFS1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 etm_pkt_send(pkt);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 target_free(pkt);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 return ETM_OK;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 /* Callback function registered in ETM database */
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 int etm_ffs2_pkt_receive(uint8 *data, int size)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 int status;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 T_ETM_PKT *pkt = NULL;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 ttw(ttr(TTrTmffs, "etm_ffs2_pkt_receive(*, %d)" NL, size));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 /* Create TestMode return Packet */
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 if ((pkt = (T_ETM_PKT *) target_malloc(sizeof(T_ETM_PKT))) == NULL) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 ttw(ttr(TTrTmffs, "etm_ffs2_pkt_receive(): Limit of memory bank reached" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 return ETM_NOMEM;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 status = etm_ffs2(pkt, data, size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 return status;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 /* Init of FFS in the ETM database */
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 int etm_ffs_init(void)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 int status;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 #ifdef RVM_ETM_SWE
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 status = etm_register("FFS1", ETM_FFS1, 0, 0, etm_ffs1_pkt_receive);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 status = etm_register("FFS2", ETM_FFS2, 0, 0, etm_ffs2_pkt_receive);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 #else
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 status = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 return status;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 * FFS1 Protocol
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 #ifndef TMFFS1
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 int tm_ffs(unsigned char *outp, int outsize, unsigned char *inp, int insize)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 return -1; // FIXME handle error better
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 // Note these functions must be presented because ffs_query() use them but
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 // they are only valid if FFS1_PROTOCOL is used.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 int tmffs_bufsize(void)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 return EFFS_NOSYS;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 unsigned char *tmffs_bufaddr(void)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 return 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 #else
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 #if (GSMLITE == 1)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 #define TMFFS1_BUFFER_SIZE 4000 //previously 8192
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 #else
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 #define TMFFS1_BUFFER_SIZE 8192
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 #define TMFFS1_STRING_SIZE 127
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 * Macros
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 #define tmffs1_putdata(outp, src, size) \
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 tmffs_put8(FPI_DATA); \
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 tmffs_put16(size); \
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 memcpy(outp, src, size); \
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 outp += size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 * Local globals
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 static unsigned char buffer[TMFFS1_BUFFER_SIZE];
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 static bufindex;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 static char string[TMFFS1_STRING_SIZE];
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 static effs_t tm_ffs_overflowck(void)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 if (bufsize > TMFFS1_BUFFER_SIZE ||
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 stringsize > TMFFS1_STRING_SIZE)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 return EFFS_TOOBIG;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 return EFFS_OK;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 * tm_ffs
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 /**
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 * NOTEME: This has been introduced when the ffs 1MB device limit was
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 * broken. This made location_t go from uint16 to uint32, messing up
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 * with PCTM.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 *
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 * This makes the xstat_s look the same to PCTM PC side, though
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 * location will be forced to 0.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 */
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 void hack_xstat_2_look_like_old_xstat(struct xstat_s *xstat)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 int i;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 char *location;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 xstat->location = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 for (location = (char *) &(xstat->location) + 2; location <= (char *) &(xstat->sequence); location++)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 *location = location[2];
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 // Parse input message and execute function. Then fill output buffer with
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 // return values from the called function and transmit the message. Return
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 // number of bytes inserted into output buffer. If return value is negative,
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 // it represents an error code.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 int tm_ffs(unsigned char *outp, int outsize, unsigned char *inp, int insize)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 int error;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 tmffs_cid_t fid;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 unsigned char *outp_start = outp;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 unsigned char *inp_start = inp;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 static uint8 i8[2]; static uint16 i8i;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 static uint16 i16[2]; static uint16 i16i;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 static uint32 i32[2]; static uint16 i32i;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 tw(tr(TR_BEGIN, TrTmffs, "TMFFS:\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 while((fid = *inp++) != FPI_END)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 switch(fid)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 /**********************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 * Generic Protocol Functions
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 **********************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 case FPI_BEGIN:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 // for (i8i = 0; i8i < TMFFS1_STRING_SIZE; i8i++) // DEBUG
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 // string[i8i] = '#';
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 // for (i8i = 0; i8i < TMFFS1_BUFFER_SIZE; i8i++) // DEBUG
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 // buffer[i8i] = '$';
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 i8i = i16i = i32i = bufsize = stringsize = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 bufindex = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 i8[0] = i8[1] = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 i16[0] = i16[1] = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 i32[0] = i32[1] = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 string[0] = buffer[0] = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 tw(tr(TR_FUNC, TrTmffs, "FPI_BEGIN\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 ttw(ttr(TTrTmffs, "tm1" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 case FPI_TMFFS_VERSION:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 // NULL -> UINT16
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 tmffs_put16(TMFFS1_VERSION);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 case FPI_INT8:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 i8[i8i++] = inp[0]; inp += 1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 tw(tr(TR_FUNC, TrTmffs, "FPI_INT8(%d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 i8[i8i-1], i8[i8i-1]));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 ttw(ttr(TTrTmffs, "tm_i8" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 case FPI_INT16:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 i16[i16i++] = (inp[0]) | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 tw(tr(TR_FUNC, TrTmffs, "FPI_INT16(%d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 i16[i16i-1], i16[i16i-1]));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 ttw(ttr(TTrTmffs, "tm_i16" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 case FPI_INT32:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 i32[i32i++] = inp[0] | (inp[1] << 8)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 | (inp[2] << 16) | (inp[3] << 24);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 inp += 4;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 tw(tr(TR_FUNC, TrTmffs, "FPI_INT32(%d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 i32[i32i-1], i32[i32i-1]));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 ttw(ttr(TTrTmffs, "tm_i32" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 case FPI_BUFFER:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 bufsize = inp[0] | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263 tw(tr(TR_FUNC, TrTmffs, "FPI_BUFFER(%d)\n", bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 ttw(ttr(TTrTmffs, "tm_buf" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 case FPI_DATA:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 bufsize = inp[0] | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 memcpy(buffer, inp, bufsize); inp += bufsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 tw(tr(TR_FUNC, TrTmffs, "FPI_DATA(%d)\n", bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 ttw(ttr(TTrTmffs, "tm_data" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 case FPI_STRBUF:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 // string buffer size MUST include null-terminator!
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 stringsize = inp[0]; inp += 1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 tw(tr(TR_FUNC, TrTmffs, "FPI_STRBUF(%d)\n", stringsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276 ttw(ttr(TTrTmffs, "tm_sbuf" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 case FPI_STRING:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279 // stringsize MUST include null-terminator!
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280 // <INT8>, <BYTES> -> NULL (or ERROR)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 stringsize = inp[0]; inp += 1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282 if (stringsize <= TMFFS1_STRING_SIZE)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 memcpy(string, inp, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 inp += stringsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 tw(tr(TR_FUNC, TrTmffs, "FPI_STRING(%d,'%s')\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 stringsize, string));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 ttw(ttr(TTrTmffs, "tm_s" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290 case FPI_BUFREAD:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 // <INT16> -> DATA
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292 tmpsize = inp[0] | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 tw(tr(TR_FUNC, TrTmffs, "FPI_BUF_READ(%d)\n", tmpsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 tmffs1_putdata(outp, &buffer[bufindex], tmpsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295 bufindex += tmpsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 ttw(ttr(TTrTmffs, "tm_bufrd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 case FPI_BUFWRITE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 // <INT16>, <BYTES> -> NULL (or ERROR)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 tmpsize = inp[0] | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 tw(tr(TR_FUNC, TrTmffs, "FPI_BUF_WRITE(%d)\n", tmpsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302 if (bufsize + tmpsize <= TMFFS1_BUFFER_SIZE)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 memcpy(&buffer[bufsize], inp, tmpsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 inp += tmpsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305 bufsize += tmpsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 ttw(ttr(TTrTmffs, "tm_bufwr" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 case FPI_BUFSET:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 bufindex = inp[0] | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 tw(tr(TR_FUNC, TrTmffs, "FPI_BUF_SET(%d)\n", bufindex));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311 ttw(ttr(TTrTmffs, "tm_bufset" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314 /**********************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 * FFS Functions
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 **********************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 case FPI_PREFORMAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 // NULL -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 error = ffs_preformat_nb(i16[0], 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 tw(tr(TR_FUNC, TrTmffs, "FPI_PREFORMAT(0x%x)\n", i16[0]));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 ttw(ttr(TTrTmffs, "tm_pfmt" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 case FPI_FORMAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 // STRING -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 error = ffs_format_nb(&string[0], i16[0], 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 tw(tr(TR_FUNC, TrTmffs, "FPI_FORMAT(0x%x)\n", i16[0]));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 ttw(ttr(TTrTmffs, "tm_fmt" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 case FPI_FCREATE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 // STRING, DATA -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 error = ffs_fcreate_nb(string, buffer, bufsize, 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 tw(tr(TR_FUNC, TrTmffs, "FPI_FCREATE('%s', 0x%x, %d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 string, buffer, bufsize, bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 ttw(ttr(TTrTmffs, "tm_fcr" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 case FPI_FUPDATE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 // STRING, DATA -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 error = ffs_fupdate_nb(string, buffer, bufsize, 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 tw(tr(TR_FUNC, TrTmffs, "FPI_FUPDATE('%s', 0x%x, %d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 string, buffer, bufsize, bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 ttw(ttr(TTrTmffs, "tm_fup" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 case FPI_FWRITE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363 // STRING, DATA -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
365 error = ffs_fwrite_nb(string, buffer, bufsize, 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 tw(tr(TR_FUNC, TrTmffs, "FPI_FWRITE('%s', 0x%x, %d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 string, buffer, bufsize, bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 ttw(ttr(TTrTmffs, "tm_fwr" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 case FPI_FREAD:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 // STRING, BUFFER -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 error = ffs_file_read(string, buffer, TMFFS1_BUFFER_SIZE);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 // Because a 32-bit integer is returned, we have to saturate it
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 // into an 8-bit value.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 error = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 tw(tr(TR_FUNC, TrTmffs, "FPI_FREAD('%s', 0x%x, %d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 string, buffer, bufsize, bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 ttw(ttr(TTrTmffs, "tm_frd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386 case FPI_REMOVE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 // STRING -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 error = ffs_remove_nb(string, 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 tw(tr(TR_FUNC, TrTmffs, "FPI_REMOVE()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394 ttw(ttr(TTrTmffs, "tm_rm" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 case FPI_MKDIR:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 // STRING -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401 error = ffs_mkdir_nb(string, 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405 tw(tr(TR_FUNC, TrTmffs, "FPI_MKDIR()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
406 ttw(ttr(TTrTmffs, "tm_mkd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 case FPI_OPENDIR:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409 // STRING, BUFFER -> ERROR, DATA
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 error = ffs_opendir(string, (struct dir_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412 // Because a 32-bit integer is returned, we have to saturate it
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 // into an 8-bit value.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 error = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 tmffs1_putdata(outp, buffer, sizeof(struct dir_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
418 tw(tr(TR_FUNC, TrTmffs, "FPI_OPENDIR()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419 ttw(ttr(TTrTmffs, "tm_od" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 case FPI_READDIR:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422 // DATA, STRBUF -> ERROR, DATA, STRING
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 string[0] = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425 error = ffs_readdir((struct dir_s *) buffer, string, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427 // Saturate error(i) in order to let it fit in type int8.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428 if (error > 127)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
429 error = 127;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
430 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431 tmffs1_putdata(outp, buffer, sizeof(struct dir_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432 stringsize = strlen(string) + 1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
433 tmffs_put8(FPI_STRING); // put directory entry's name...
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
434 tmffs_put8(stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
435 memcpy(outp, string, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 outp += stringsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
437 tw(tr(TR_FUNC, TrTmffs, "FPI_READDIR()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
438 ttw(ttr(TTrTmffs, "tm_rdd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
439 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
440
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
441
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
442 case FPI_STAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
443 // STRING, BUFFER -> ERROR, DATA
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
444 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
445 error = ffs_stat(&string[0], (struct stat_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
446 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
447 tmffs1_putdata(outp, buffer, sizeof(struct stat_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
448 tw(tr(TR_FUNC, TrTmffs, "FPI_STAT()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
449 ttw(ttr(TTrTmffs, "tm_st" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
450 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
451 case FPI_LINKSTAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
452 // STRING, BUFFER -> ERROR, DATA
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
453 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
454 error = ffs_xlstat(&string[0], (struct xstat_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
455 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
456
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
457 hack_xstat_2_look_like_old_xstat((struct xstat_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
458
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
459 tmffs1_putdata(outp, buffer, sizeof(struct xstat_s) - 2);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
460 tw(tr(TR_FUNC, TrTmffs, "FPI_()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
461 ttw(ttr(TTrTmffs, "tm_lst" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
462 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
463
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
464
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
465 case FPI_SYMLINK:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
466 // STRING, DATA -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
467 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
468 error = ffs_symlink_nb(string, (char *) buffer, 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
469 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
470 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
471 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
472 tw(tr(TR_FUNC, TrTmffs, "FPI_SYMLINK()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
473 ttw(ttr(TTrTmffs, "tm_sym" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
474 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
475 case FPI_READLINK:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
476 // STRING, BUFFER -> ERROR, DATA
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
477 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
478 error = ffs_readlink(string, (char *) buffer, TMFFS1_BUFFER_SIZE);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
479 // Because a 32-bit integer is returned, we have to saturate it
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
480 // into an 8-bit value.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
481 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
482 error = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
483 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
484 tmffs1_putdata(outp, buffer, bufsize); // put link contents
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
485 tw(tr(TR_FUNC, TrTmffs, "FPI_READLINK()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
486 ttw(ttr(TTrTmffs, "tm_rdl" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
487 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
488
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
489
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
490 case FPI_QUERY:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
491 // INT8 -> ERROR, DATA
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
492 error = ffs_query(i8[0], buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
493 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
494 tmffs1_putdata(outp, buffer, 16);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
495 tw(tr(TR_FUNC, TrTmffs, "FPI_QUERY()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
496 ttw(ttr(TTrTmffs, "tm_q" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
497 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
498 case FPI_FCONTROL:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
499 // STRING INT8 INT32 -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
500 if ((error = tm_ffs_overflowck()) == EFFS_OK)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
501 error = ffs_fcontrol_nb(string, i8[0], i32[0], 0);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
502 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
503 error = 0; // ignore request id
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
504 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
505 tw(tr(TR_FUNC, TrTmffs, "FPI_FCONTROL()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
506 ttw(ttr(TTrTmffs, "tm_fc" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
507 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
508
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
509 case FPI_INIT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
510 // NULL -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
511 error =ffs_initialize();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
512 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
513 tw(tr(TR_FUNC, TrTmffs, "FPI_INIT()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
514 ttw(ttr(TTrTmffs, "tm_init" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
515 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
516 case FPI_EXIT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
517 // NULL -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
518 error = ffs_exit();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
519 tmffs_put8(error);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
520 tw(tr(TR_FUNC, TrTmffs, "FPI_EXIT()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
521 ttw(ttr(TTrTmffs, "tm_exit" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
522 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
523
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
524
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
525 case FPI_TFFS:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
526 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
527 // STRING -> ERROR
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
528 #if (WITH_TFFS == 1)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
529 extern char ffs_test_string[]; // defined in task.c
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
530
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
531 memcpy(ffs_test_string, string, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
532 tw(tr(TR_FUNC, TrTmffs, "FPI_TFFS()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
533 ttw(ttr(TTrTmffs, "tm_tffs" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
534 #else
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
535 tmffs_put8(EFFS_NOSYS);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
536 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
537 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
538 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
539 default:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
540 tw(tr(TR_FUNC, TrTmffs, "ERROR: Unknown tmffs protocol code\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
541 ttw(ttr(TTrTmffs, "tm?" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
542 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
543 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
544 // check if we read beyond buffer end
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
545 if (inp > inp_start + insize) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
546 tw(tr(TR_FUNC, TrTmffs, "ERROR: Read beyond end of input buffer\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
547 ttw(ttr(TTrTmffs, "tm_fatal" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
548 // NOTEME: We really should reset output buffer and put a return
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
549 // code that tells us what went wrong!
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
550 return 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
551 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
552 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
553
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
554 tw(tr(TR_END, TrTmffs, ""));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
555
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
556 return outp - outp_start;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
557 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
558
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
559 int tmffs_bufsize(void)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
560 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
561 return TMFFS1_BUFFER_SIZE;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
562 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
563
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
564 unsigned char *tmffs_bufaddr(void)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
565 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
566 return buffer;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
567 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
568
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
569 #endif // TMFFS1
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
570
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
571 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
572 * FFS2 protocol
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
573 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
574
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
575 #ifndef TMFFS2
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
576
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
577 #ifdef RVM_ETM_SWE
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
578 int etm_ffs2(T_ETM_PKT *pkt, unsigned char *inp, int insize)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
579 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
580 int error;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
581
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
582 tw(tr(TR_BEGIN, TrTmffs, "FFS2 protocol not represented in target\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
583 error = -1; // FIXME other error?
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
584
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
585 // We return a packet instead of waiting for timeout.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
586 pkt->size = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
587 pkt->status = -error;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
588 pkt->mid = ETM_FFS2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
589 etm_pkt_send(pkt);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
590
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
591 target_free(pkt);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
592 tw(tr(TR_END, TrTmffs, ""));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
593
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
594 return error;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
595 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
596 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
597
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
598 #else
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
599
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
600 #define TMFFS_BUFFER_SIZE 256 // FIXME change to packet size
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
601 #define TMFFS_STRING_SIZE 127
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
602
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
603 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
604 * Macros
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
605 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
606
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
607 #define tmffs_get8() inp[0]; inp += 1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
608 #define tmffs_get16() (inp[0]) | (inp[1] << 8); inp += 2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
609 #define tmffs_get32() inp[0] | (inp[1] << 8) | (inp[2] << 16)\
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
610 | (inp[3] << 24); inp += 4;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
611
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
612 #define tmffs_getdata() bufsize = inp[0]; inp += 1; \
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
613 memcpy(buffer, inp, bufsize); inp += bufsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
614
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
615
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
616 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
617 * Helper function
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
618 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
619
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
620 // If size is less than zero it is because of a error and we dont have to put any
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
621 // data if size is returned in status.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
622 int tmffs_putdata(unsigned char **buf, unsigned char *src, int size)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
623 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
624 unsigned char *p = *buf;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
625
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
626 if (size > 0) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
627 *p++ = size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
628 memcpy(p, src, size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
629 *buf += 1 + size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
630 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
631 return size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
632 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
633
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
634 int tmffs_putstring(unsigned char **buf, char *src, int size)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
635 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
636 unsigned char *p = *buf;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
637
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
638 if (size > 0) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
639 *p++ = size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
640 memcpy(p, src, size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
641 *buf += 1 + size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
642 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
643 return size;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
644 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
645
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
646 int tmffs_getstring(unsigned char ** buf, char *string)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
647 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
648 unsigned char *p = *buf;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
649
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
650 stringsize = *p++;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
651
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
652 if (stringsize > TMFFS_STRING_SIZE)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
653 return EFFS_TOOBIG;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
654
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
655 memcpy(string, p, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
656 *buf += 1 + stringsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
657
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
658 return stringsize;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
659 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
660
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
661 /******************************************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
662 * tm_ffs
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
663 ******************************************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
664
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
665 // Parse input message and execute function. Then fill output buffer with
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
666 // return values from the called function and transmit the message. Return
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
667 // number of bytes inserted into output buffer. If return value is negative,
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
668 // it represents an error code.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
669 int etm_ffs2(T_ETM_PKT *pkt, unsigned char *inp, int insize)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
670 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
671 tmffs2_cid_t fid;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
672 unsigned char buffer[TMFFS_BUFFER_SIZE];
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
673 char string[TMFFS_STRING_SIZE];
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
674
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
675 unsigned char *outp_start;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
676 unsigned char *inp_start = inp;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
677 unsigned char *outp;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
678
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
679 int error = 0, i, fdi, size, param, flags;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
680 uint8 type;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
681
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
682 bufsize = stringsize = tmpsize = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
683
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
684 tw(tr(TR_BEGIN, TrTmffs, "TmFFS2\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
685
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
686 outp_start = outp = pkt->data;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
687
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
688 fid = *inp++;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
689 ttw(ttr(TTrTmffs, "etm_ffs2 0x%x" NL, fid));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
690 switch(fid)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
691 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
692 /**********************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
693 * Generic Protocol Functions
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
694 **********************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
695
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
696 case TMFFS_VERSION:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
697 tmffs_put16(TMFFS2_VERSION);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
698 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
699
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
700 /**********************************************************
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
701 * FFS Functions
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
702 **********************************************************/
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
703
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
704 case TMFFS_PREFORMAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
705 param = tmffs_get16();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
706 error = ffs_preformat(param);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
707 tw(tr(TR_FUNC, TrTmffs, "TMFFS_PREFORMAT(0x%x)\n", param));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
708 ttw(ttr(TTrTmffs, "tm_pfmt" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
709 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
710 case TMFFS_FORMAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
711 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
712 param = tmffs_get16();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
713 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
714 error = ffs_format(&string[0], param);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
715 tw(tr(TR_FUNC, TrTmffs, "TMFFS_FORMAT(0x%x)\n", param));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
716 ttw(ttr(TTrTmffs, "tm_fmt" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
717 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
718
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
719
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
720 case TMFFS_FILE_WRITE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
721 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
722 tmffs_getdata();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
723 flags = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
724 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
725 error = ffs_file_write(string, buffer, bufsize, flags);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
726 ttw(ttr(TTrTmffs, "tm_fwr" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
727 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
728
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
729
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
730 case TMFFS_FILE_READ:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
731 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
732 bufsize = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
733 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
734 size = ffs_file_read(string, buffer, bufsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
735 error = tmffs_putdata(&outp, &buffer[0], size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
736 tw(tr(TR_FUNC, TrTmffs, "TMFFS_FREAD('%s', 0x%x, %d/0x%x)\n",
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
737 string, buffer, bufsize, bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
738 ttw(ttr(TTrTmffs, "tm_frd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
739 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
740 case TMFFS_REMOVE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
741 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
742 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
743 error = ffs_remove(string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
744 tw(tr(TR_FUNC, TrTmffs, "TMFFS_REMOVE()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
745 ttw(ttr(TTrTmffs, "tm_rm" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
746 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
747
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
748
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
749 case TMFFS_OPEN:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
750 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
751 flags = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
752 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
753 error = ffs_open(string, flags);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
754 tmffs_put8(error); // fdi
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
755 tw(tr(TR_FUNC, TrTmffs, "TMFFS_OPEN('%s', %d)\n", string, flags));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
756 ttw(ttr(TTrTmffs, "tm_open" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
757 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
758 case TMFFS_CLOSE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
759 fdi = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
760 error = ffs_close(fdi);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
761 tw(tr(TR_FUNC, TrTmffs, "TMFFS_CLOSE(%d)\n", fdi));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
762 ttw(ttr(TTrTmffs, "tm_close" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
763 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
764 case TMFFS_WRITE:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
765 fdi = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
766 tmffs_getdata();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
767 error = ffs_write(fdi, buffer, bufsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
768 tmffs_put8(error); // put size
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
769 tw(tr(TR_FUNC, TrTmffs, "TMFFS_WRITE(%d, %d)\n", fdi, bufsize));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
770 ttw(ttr(TTrTmffs, "tm_write" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
771 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
772 case TMFFS_READ:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
773 fdi = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
774 size = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
775 size = ffs_read(fdi, &buffer[0], size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
776 error = tmffs_putdata(&outp, &buffer[0], size);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
777 tw(tr(TR_FUNC, TrTmffs, "TMFFS_READ(%d, %d)\n", fdi, size));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
778 ttw(ttr(TTrTmffs, "tm_read" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
779 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
780
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
781
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
782 case TMFFS_MKDIR:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
783 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
784 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
785 error = ffs_mkdir(string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
786 tw(tr(TR_FUNC, TrTmffs, "TMFFS_MKDIR()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
787 ttw(ttr(TTrTmffs, "tm_mkd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
788 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
789 case TMFFS_OPENDIR:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
790 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
791 if (error >= 0) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
792 error = ffs_opendir(string, (struct dir_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
793 tmffs_put8(error); // Note: we must put error/number of objects.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
794 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
795 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
796 tmffs_putdata(&outp, buffer, sizeof(struct dir_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
797
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
798 tw(tr(TR_FUNC, TrTmffs, "TMFFS_OPENDIR()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
799 ttw(ttr(TTrTmffs, "tm_od" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
800 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
801 case TMFFS_READDIR:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
802 tmffs_getdata();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
803 stringsize = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
804 error = ffs_readdir((struct dir_s *) buffer, string, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
805 tmffs_put8(error); // Note: we have to return bytes read.
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
806 if (error >= 0) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
807 tmffs_putdata(&outp, buffer, sizeof(struct dir_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
808 stringsize = strlen(string) + 1;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
809 tmffs_putstring(&outp, string, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
810 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
811 tw(tr(TR_FUNC, TrTmffs, "TMFFS_READDIR()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
812 ttw(ttr(TTrTmffs, "tm_rdd" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
813 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
814
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
815 case TMFFS_STAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
816 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
817 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
818 error = ffs_stat(string, (struct stat_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
819 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
820 tmffs_putdata(&outp, buffer, sizeof(struct stat_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
821
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
822 tw(tr(TR_FUNC, TrTmffs, "TMFFS_STAT()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
823 ttw(ttr(TTrTmffs, "tm_st" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
824 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
825 case TMFFS_XLSTAT:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
826 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
827 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
828 error = ffs_xlstat(&string[0], (struct xstat_s *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
829 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
830 tmffs_putdata(&outp, buffer, sizeof(struct xstat_s));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
831 tw(tr(TR_FUNC, TrTmffs, "TMFFS_()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
832 ttw(ttr(TTrTmffs, "tm_xlst" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
833 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
834
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
835
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
836 case TMFFS_SYMLINK:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
837 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
838 tmffs_getdata();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
839 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
840 error = ffs_symlink(string, (char *) buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
841 tw(tr(TR_FUNC, TrTmffs, "TMFFS_SYMLINK()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
842 ttw(ttr(TTrTmffs, "tm_sym" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
843 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
844 case TMFFS_READLINK:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
845 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
846 tmffs_getdata();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
847 if (error >= 0) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
848 size = ffs_readlink(string, (char *) buffer, TMFFS_BUFFER_SIZE);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
849 error = tmffs_putdata(&outp, buffer, size); // put link contents
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
850 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
851 tw(tr(TR_FUNC, TrTmffs, "TMFFS_READLINK()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
852 ttw(ttr(TTrTmffs, "tm_rdl" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
853 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
854
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
855
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
856 case TMFFS_QUERY:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
857 param = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
858 error = ffs_query(param, buffer);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
859 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
860 tmffs_putdata(&outp, buffer, 16);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
861 tw(tr(TR_FUNC, TrTmffs, "TMFFS_QUERY(%d)\n", param));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
862 ttw(ttr(TTrTmffs, "tm_q" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
863 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
864 case TMFFS_FCONTROL:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
865 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
866 type = tmffs_get8();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
867 param = tmffs_get32();
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
868 if (error >= 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
869 error = ffs_fcontrol(string, type, param);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
870 tw(tr(TR_FUNC, TrTmffs, "TMFFS_FCONTROL()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
871 ttw(ttr(TTrTmffs, "tm_fc" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
872 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
873
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
874 case TMFFS_TFFS:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
875 {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
876 #if (WITH_TFFS == 1)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
877 extern char ffs_test_string[]; // defined in task.c
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
878 error = tmffs_getstring(&inp, string);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
879 memcpy(ffs_test_string, string, stringsize);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
880 tw(tr(TR_FUNC, TrTmffs, "TMFFS_TFFS()\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
881 ttw(ttr(TTrTmffs, "tm_tffs" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
882 tmffs_put8(EFFS_OK);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
883 #else
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
884 tmffs_put8(EFFS_NOSYS);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
885 #endif
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
886 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
887 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
888 default:
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
889 error = EFFS_NOSYS;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
890 tmffs_put8(EFFS_NOSYS);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
891 tw(tr(TR_FUNC, TrTmffs, "ERROR: Unknown tmffs protocol code\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
892 ttw(ttr(TTrTmffs, "tm?" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
893 break;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
894 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
895
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
896 // check if we read beyond buffer end
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
897 if (inp > inp_start + insize) {
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
898 tw(tr(TR_FUNC, TrTmffs, "ERROR: Read beyond end of input buffer\n"));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
899 ttw(ttr(TTrTmffs, "tm_fatal" NL));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
900 ttw(ttr(TTrTmffs, "insize: %d, diff: %d" NL, insize,
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
901 inp - (inp_start + insize)));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
902 // NOTEME: We really should reset output buffer and put a return
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
903 // code that tells us what went wrong!
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
904 error = ETM_PACKET; // FIXME find another error
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
905 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
906
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
907 ttw(ttr(TTrTmffs, "error %d" NL, error));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
908 if (error > 0)
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
909 error = 0;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
910
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
911 pkt->mid = ETM_FFS2;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
912 pkt->size = outp - outp_start;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
913 pkt->status = -error;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
914
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
915 etm_pkt_send(pkt);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
916 etm_free(pkt);
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
917
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
918 tw(tr(TR_END, TrTmffs, ""));
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
919
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
920 return ETM_OK;
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
921 }
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
922
842c9fd828fd gsm-fw: TMFFS integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
923 #endif // TMFFS2