annotate gsm-fw/services/ffs/task.c @ 218:fee45482aa2a

FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 06 Jan 2014 08:43:35 +0000
parents 3ebe6409e8bc
children 2beb88a3d528
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Flash File System (ffs)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * FFS task. ONLY for target!
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 *
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * $Id: task.c 1.48.1.1.1.24 Thu, 18 Dec 2003 10:50:52 +0100 tsj $
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 *
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "../../include/config.h"
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "ffs.h"
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "core.h"
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "task.h"
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "ffstrace.h"
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include "../../riviera/rvm/rvm_use_id_list.h"
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 * Globals and function prototypes
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 extern UINT8 pcm_init(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 void ffs_task(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 static effs_t ffs_init_status;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 req_id_t request_id_last = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 T_OS_MB_ID ffs_mb_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 UINT16 ffs_addr_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 * FFS Test Task
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 // For this to work, change:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 // 1. MAX_RVF_TASKS define in rvf_target.h
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 // Note that the FFS_TEST_TASK_ID is set one too low! We assume we are lucky
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 // that no other task has the same ID...
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 #if (WITH_TFFS == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 #define FFS_TEST_STACK_SIZE 1024
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 #define FFS_TEST_TASK_ID (MAX_RVF_TASKS - 1 - 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 void ffs_test_task(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 void test_init(int keepgoing);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 int test_run(char *testname);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 static uint8 ffs_test_stack[FFS_TEST_STACK_SIZE];
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 // This is the string of test cases to run by calling test_run(). This
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 // string as written to from tmffs module.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 char ffs_test_string[128];
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 // Delay for <delay> milliseconds
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 void tffs_delay(int delay)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 delay = 14 * delay / 64; // approx. same as division by 60/13
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 OS_DELAY(delay);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 UINT32 rvf_get_tick_count(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 // Timer functions for benchmarking
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 UINT32 tffs_timer_begin(void)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 return rvf_get_tick_count();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 UINT32 tffs_timer_end(UINT32 time_begin)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 // return current time minus time_begin
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 UINT32 ticks;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 ticks = rvf_get_tick_count();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 return (ticks - time_begin) * 60 / 13;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 void ffs_test_task(void)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 effs_t error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 OS_DELAY(217); // wait approx. 1000ms
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 ttw(str(TTrTest, "ffs_test_task()" NL));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 while (1) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 OS_DELAY(217); // wait approx. 1000ms
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 // Poll to see if we have tests to run... We know that the writer of
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 // ffs_test_string has a higher priority than us, so it is properly
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 // written when we reach here.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 if (*ffs_test_string) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 test_init(0);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 error = test_run(ffs_test_string);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 *ffs_test_string = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 if (error == 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 ttw(str(TTrTest, "TEST succeeded" NL));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 else
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 ttw(ttr(TTrTest, "TEST cases failed: %d" NL, error));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 #endif // End of WITH_TFFS
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 * Target Platform Abstraction Functions
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 req_id_t request_id_get(void)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 extern uint32 int_disable(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 extern void int_enable(uint32 tmp);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 uint32 cprs;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 // We disable interrupt to avoid any other tasks to get the same id.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 cprs = int_disable();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 request_id_last++;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 if (request_id_last < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 request_id_last = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 int_enable(cprs);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 return request_id_last;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 void *target_malloc(unsigned int size)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 char *buf;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 #if (_RVF == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 if ((rvf_get_buf(ffs_mb_id, size, (T_RVF_BUFFER*) &buf)) == RVF_RED)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 return 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 else
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 return buf;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 #else
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 return 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 void target_free(void *buf)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 int error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 #if (_RVF == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 if ((error = OS_FREE(buf)) != OS_OK)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 ttw(ttr(TTrFatal, "target_free() %d (FAILED)" NL, error));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 * FFS Blocking Call Handling
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 effs_t ffs_b_begin(struct ffs_blocking_s *fb, T_RVF_MUTEX *mutex, int *result)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 effs_t error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 if ((error = rvf_initialize_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 if ((error = rvf_lock_mutex(mutex)) < 0) // This will succeed
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 fb->result = result;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 fb->mutex = mutex;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 return EFFS_OK;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 effs_t ffs_b_end(T_RVF_MUTEX *mutex, int result)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 effs_t error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 // Do not lock the mutex if the message send operation failed
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 if (result >= 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 // This will block the task until the mutex has been released
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 if ((error = rvf_lock_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 if ((error = rvf_unlock_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 if ((error = rvf_delete_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 return EFFS_OK;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 * FFS Task
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 /* The below access to the intenal Nucleus variable "TCD_Interrupt_Level" is
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 * a workaround for a known Nucleus BUG (see CQ SWI-FIX-17560) */
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 void ffs_main_init()
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 extern int TCD_Interrupt_Level;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 int tmp_int_level;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 ttr_init(TTrTask|TTrTest|TTrTestInfo);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 //ttr_init(TTrTask|TTrTest|TTrTestInfo|TTrDrvErase|TTrDrvWrite|TTrTaskLow|TTrApi);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 tmp_int_level = TCD_Interrupt_Level; // Backup Int level
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 TCD_Interrupt_Level = 0xC0; // The Interrups are not yet enabled...
218
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
211 #if FFS_IN_RAM
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
212 ffsdrv_ram_init();
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
213 #endif
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 ffs_init_status = ffs_initialize();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 TCD_Interrupt_Level = tmp_int_level; // Restore Int level
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 #if 0
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218 pcm_init(); // We have to call pcm_init() before G23 starts.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 void ffs_task_init(T_OS_MB_ID mbid, T_RVF_ADDR_ID addr_id)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 int error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 ffs_mb_id = mbid;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 ffs_addr_id = addr_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 #if (WITH_TFFS == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 error =
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 OS_CREATE_TASK((TASKPTR) ffs_test_task, FFS_TEST_TASK_ID, "TFFS",
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 ffs_test_stack, FFS_TEST_STACK_SIZE,
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 249, // priority
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 4, // ET4_TASK type
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 0, // no time slicing
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 RUNNING); // start state
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 ttw(ttr(TTrTask, "os_create_task('TFFS') %d" NL, error));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 void ffs_task()
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 extern int etm_ffs_init(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 struct ffs_req_s *request;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 T_FFS_FILE_CNF *confirm_file;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 T_FFS_STREAM_CNF *confirm_stream;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 T_RVF_MUTEX *mutex_p;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 int error, free_mail, os_error = OS_OK;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 uint16 revision, manufacturer_id, device_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 uint32 base;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 fd_t fdi;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 char *temp_path;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 req_id_t temp_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255
218
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
256 #if FFS_IN_RAM
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 // Non formatted FFS should be formatted
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 // So we don't have to use PCTM to format it
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 if (fs.initerror == EFFS_NOFORMAT)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 ffs_format_nb("/", 0x2BAD, 0);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263
218
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
264 /* ffs_InitRFCap(); */
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 ttr(TTrTask, "ffs_init() %d" NL, ffs_init_status);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 ffs_query(Q_FFS_REVISION, &revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 ttr(TTrTask,"FFS revision: 0x%x" NL, revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 ffs_query(Q_DEV_MANUFACTURER, &manufacturer_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 ffs_query(Q_DEV_DEVICE, &device_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 ffs_query(Q_DEV_DRIVER, &revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 ttr(TTrTask,"FFS device, driver: 0x%02x, 0x%04x, %d" NL,
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276 manufacturer_id, device_id, revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 ffs_query(Q_DEV_BASE, &base);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279 ffs_query(Q_DEV_BLOCKS, &revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280 ttr(TTrTask,"FFS base, blocks: 0x%x, %d" NL, base, revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282 ffs_query(Q_FFS_FORMAT_READ, &manufacturer_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 ffs_query(Q_FFS_FORMAT_WRITE, &device_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 ttr(TTrTask,"FFS format read, write: 0x%x, 0x%x" NL NL,
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 manufacturer_id, device_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 // If some blocks has been marked for reclaim, reclaim them now...
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 blocks_reclaim();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290 // We can only mkdir("pcm") *after* our mailbox has been allocated
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 // otherwise mkdir("pcm") will fail.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292 error = ffs_mkdir_nb("/pcm", 0);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 #if 0
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295 // Register FFS to ETM database
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 error = etm_ffs_init();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 while (1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 OS_MAIL_WAIT(OS_MAIL_EVENT_MASK);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302 request = (struct ffs_req_s *) OS_MAIL_READ();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 ttw(ttr(TTrTaskLow, "ffs_task(%d):" NL, request->cmd));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305 switch (request->cmd) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 case WRITE: case SEEK: case CLOSE: case FTRUNC: case FDATASYNC:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 ttw(ttr(TTrTaskLow, " fdi = %d" NL, request->fdi));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 // Save a local copy of fdi because the task we call later can
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 // modify it and we have to use the fdi if a callback is used
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 fdi = (fd_t)request->fdi;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312 default:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313 ttw(ttr(TTrTaskLow, " name = %s" NL, request->path));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 ttw(ttr(TTrTaskLow, " src = 0x%x" NL, request->src));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 ttw(ttr(TTrTaskLow, " size = %d" NL, request->size));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 if (tr_query(TTrTaskDelays))
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 OS_DELAY(5);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 switch (request->cmd) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 case NOP: error = EFFS_OK; break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 case FILE_WRITE: error = task_file_write(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 case SYMLINK: error = task_symlink(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 case MKDIR: error = task_mkdir(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 case REMOVE: error = task_remove(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 case RENAME: error = task_rename(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 case FCONTROL: error = task_fcontrol(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 case PREFORMAT: error = task_preformat(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 case FORMAT: error = task_format(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 case OPEN: error = task_open(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 case WRITE: error = task_write(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 case SEEK: error = task_seek(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 case CLOSE: error = task_close(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 case TRUNC: error = task_trunc(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 case FTRUNC: error = task_ftrunc(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 case FDATASYNC: error = task_fdatasync(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339 default:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 ttr(TTrFatal, "FFS FATAL: bad request: %d" NL, request->cmd);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 ttw(ttr(TTrTaskLow, "ffs_task(%d) %d" NL, request->cmd, error));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 if (tr_query(TTrTaskDelays))
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 OS_DELAY(5);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 // Call-back to caller
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 mutex_p = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 if (request->cp) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 free_mail = 0; // don't free mail we will reuse it
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 // We reuse the mail we received for our call-back. Due to
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353 // this reuse, we must be careful with the order of
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 // assignments. If this is a stream modify function use
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 // ffs_stream_cnf else use ffs_file_cnf
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 temp_id = request->request_id; // Save id before we reuse the mail mem.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 switch (request->cmd) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 case WRITE: case SEEK: case CLOSE: case FTRUNC: case FDATASYNC:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 confirm_stream = (T_FFS_STREAM_CNF *) request;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 confirm_stream->error = error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 confirm_stream->request_id = temp_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363 confirm_stream->fdi = fdi;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 confirm_stream->header.msg_id = FFS_MESSAGE_OFFSET;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
365
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 if (request->cp->callback_func) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 request->cp->callback_func((T_FFS_STREAM_CNF *)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 confirm_stream);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 else if (request->cp->addr_id) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 os_error = OS_MAIL_SEND(request->cp->addr_id,
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 confirm_stream);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 else {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 ttr(TTrFatal, "FFS WARNING: empty return path" NL);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 default:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 temp_path = (char *) request->path;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 confirm_file = (T_FFS_FILE_CNF *) request;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 confirm_file->error = error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 confirm_file->request_id = temp_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 confirm_file->path = temp_path;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 confirm_file->header.msg_id = FFS_MESSAGE_OFFSET;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 if (request->cp->callback_func) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 request->cp->callback_func((T_FFS_FILE_CNF *) confirm_file);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 else if (request->cp->addr_id) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392 os_error = OS_MAIL_SEND(request->cp->addr_id,
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 confirm_file);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 else {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 ttr(TTrFatal, "FFS WARNING: empty return path" NL);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402 if (os_error != OS_OK)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403 ttr(TTrFatal, "FFS FATAL: os_send_msg() %d" NL, os_error);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
406 // Blocking handling / unlocking mutex
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 else if (request->fb) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 // Save the pointer to the mutex and the error value (allocated
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409 // on the stack by the macro FFS_BLOCKING_BEGIN)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410 mutex_p = request->fb->mutex;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 *request->fb->result = error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 else {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 // The task must have been a non blocking without any callback
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
418 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 // Free the mail memory. Note that we always free it, except when we
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 // have successfully reused it for sending a mail call-back.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422 if (free_mail == 1) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 os_error = OS_FREE(request);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 if (os_error != OS_OK)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425 ttr(TTrFatal, "FFS FATAL: os_free() %d" NL, os_error);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428 // Blocking handling / unlocking mutex
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
429 if (mutex_p) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
430 // Wake up the caller task
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431 if ((os_error = rvf_unlock_mutex(mutex_p)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432 ttr(TTrFatal, "FFS FATAL: rvf_unlock_mutex() %d" NL, os_error);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
433 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
434
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
435 tr_bstat();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
437 }