annotate gsm-fw/services/ffs/task.c @ 223:0848c7f419fd

gsm-fw/configs: checking some configurations into source control, now that we have some selectable features
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 07 Jan 2014 05:58:11 +0000
parents 842c9fd828fd
children 4d706a4134b0
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"
219
2beb88a3d528 gsm-fw links with FFS included
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
16 #include "intctl.h"
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 #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
18
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 * Globals and function prototypes
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 extern UINT8 pcm_init(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 void ffs_task(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 static effs_t ffs_init_status;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 req_id_t request_id_last = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 T_OS_MB_ID ffs_mb_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 UINT16 ffs_addr_id;
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 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 * FFS Test Task
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 // For this to work, change:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 // 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
38
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 // 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
40 // 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
41
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 #if (WITH_TFFS == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 #define FFS_TEST_STACK_SIZE 1024
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 #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
47
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 void ffs_test_task(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 void test_init(int keepgoing);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 int test_run(char *testname);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 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
53
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 // 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
55 // string as written to from tmffs module.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 char ffs_test_string[128];
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 // Delay for <delay> milliseconds
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 void tffs_delay(int delay)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 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
62 OS_DELAY(delay);
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 UINT32 rvf_get_tick_count(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 // Timer functions for benchmarking
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 UINT32 tffs_timer_begin(void)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 return rvf_get_tick_count();
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 UINT32 tffs_timer_end(UINT32 time_begin)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 // return current time minus time_begin
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 UINT32 ticks;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 ticks = rvf_get_tick_count();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 return (ticks - time_begin) * 60 / 13;
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 void ffs_test_task(void)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 effs_t error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 OS_DELAY(217); // wait approx. 1000ms
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 ttw(str(TTrTest, "ffs_test_task()" NL));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 while (1) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 OS_DELAY(217); // wait approx. 1000ms
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 // 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
94 // 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
95 // written when we reach here.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 if (*ffs_test_string) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 test_init(0);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 error = test_run(ffs_test_string);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 *ffs_test_string = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 if (error == 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 ttw(str(TTrTest, "TEST succeeded" NL));
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 else
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 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
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 #endif // End of WITH_TFFS
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 /******************************************************************************
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 * Target Platform Abstraction Functions
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
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 req_id_t request_id_get(void)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 {
219
2beb88a3d528 gsm-fw links with FFS included
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
117 uint32 cpsr;
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 // We disable interrupt to avoid any other tasks to get the same id.
219
2beb88a3d528 gsm-fw links with FFS included
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
120 cpsr = int_disable();
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 request_id_last++;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 if (request_id_last < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 request_id_last = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125
219
2beb88a3d528 gsm-fw links with FFS included
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 218
diff changeset
126 int_enable(cpsr);
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 return request_id_last;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 }
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 void *target_malloc(unsigned int size)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 char *buf;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 #if (_RVF == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 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
137 return 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 else
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 return buf;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 #else
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 return 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 }
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 void target_free(void *buf)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 int error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 #if (_RVF == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 if ((error = OS_FREE(buf)) != OS_OK)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 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
152 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 }
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 * FFS Blocking Call Handling
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 ******************************************************************************/
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 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
161 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 effs_t error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 if ((error = rvf_initialize_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 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
168 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 fb->result = result;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 fb->mutex = mutex;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 return EFFS_OK;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 }
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 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
177 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 effs_t error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 // 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
181 if (result >= 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 // 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
183 if ((error = rvf_lock_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 if ((error = rvf_unlock_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 if ((error = rvf_delete_mutex(mutex)) < 0)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 return error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 return EFFS_OK;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 }
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 * FFS Task
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 ******************************************************************************/
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 /* 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
199 * 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
200
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 void ffs_main_init()
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 extern int TCD_Interrupt_Level;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 int tmp_int_level;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 ttr_init(TTrTask|TTrTest|TTrTestInfo);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 //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
207
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 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
209 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
210 #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
211 ffsdrv_ram_init();
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
212 #endif
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 ffs_init_status = ffs_initialize();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 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
215
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 #if 0
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 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
218 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 }
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 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
222 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 int error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 ffs_mb_id = mbid;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 ffs_addr_id = addr_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 #if (WITH_TFFS == 1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 error =
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 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
231 ffs_test_stack, FFS_TEST_STACK_SIZE,
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 249, // priority
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 4, // ET4_TASK type
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 0, // no time slicing
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235 RUNNING); // start state
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 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
238 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 }
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 void ffs_task()
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 extern int etm_ffs_init(void);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 struct ffs_req_s *request;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 T_FFS_FILE_CNF *confirm_file;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 T_FFS_STREAM_CNF *confirm_stream;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 T_RVF_MUTEX *mutex_p;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 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
249 uint16 revision, manufacturer_id, device_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 uint32 base;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 fd_t fdi;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 char *temp_path;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 req_id_t temp_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254
218
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
255 #if FFS_IN_RAM
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 // Non formatted FFS should be formatted
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 // 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
258 if (fs.initerror == EFFS_NOFORMAT)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 ffs_format_nb("/", 0x2BAD, 0);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262
218
fee45482aa2a FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 212
diff changeset
263 /* ffs_InitRFCap(); */
212
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 #endif
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266 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
267
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 ffs_query(Q_FFS_REVISION, &revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 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
270
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 ffs_query(Q_DEV_MANUFACTURER, &manufacturer_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 ffs_query(Q_DEV_DEVICE, &device_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 ffs_query(Q_DEV_DRIVER, &revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 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
275 manufacturer_id, device_id, revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277 ffs_query(Q_DEV_BASE, &base);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 ffs_query(Q_DEV_BLOCKS, &revision);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279 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
280
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 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
282 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
283 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
284 manufacturer_id, device_id);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 // 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
287 blocks_reclaim();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 // 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
290 // otherwise mkdir("pcm") will fail.
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 error = ffs_mkdir_nb("/pcm", 0);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 // Register FFS to ETM database
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 error = etm_ffs_init();
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 while (1)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 OS_MAIL_WAIT(OS_MAIL_EVENT_MASK);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 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
300
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 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
302 switch (request->cmd) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 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
304 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
305 // 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
306 // 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
307 fdi = (fd_t)request->fdi;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 default:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 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
311 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313 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
314 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
315
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 if (tr_query(TTrTaskDelays))
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 OS_DELAY(5);
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 switch (request->cmd) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 case NOP: error = EFFS_OK; break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 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
322 case SYMLINK: error = task_symlink(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 case MKDIR: error = task_mkdir(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 case REMOVE: error = task_remove(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 case RENAME: error = task_rename(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 case FCONTROL: error = task_fcontrol(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 case PREFORMAT: error = task_preformat(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 case FORMAT: error = task_format(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 case OPEN: error = task_open(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 case WRITE: error = task_write(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 case SEEK: error = task_seek(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 case CLOSE: error = task_close(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 case TRUNC: error = task_trunc(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 case FTRUNC: error = task_ftrunc(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 case FDATASYNC: error = task_fdatasync(request); break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 default:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 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
338 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 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
342 if (tr_query(TTrTaskDelays))
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 OS_DELAY(5);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 // Call-back to caller
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 mutex_p = 0;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 if (request->cp) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 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
349 // 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
350 // 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
351 // 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
352 // 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
353
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 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
355 switch (request->cmd) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 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
357 confirm_stream = (T_FFS_STREAM_CNF *) request;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 confirm_stream->error = error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 confirm_stream->request_id = temp_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 confirm_stream->fdi = fdi;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 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
362
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363 if (request->cp->callback_func) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 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
365 confirm_stream);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 else if (request->cp->addr_id) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 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
369 confirm_stream);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 else {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 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
373 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 default:
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 temp_path = (char *) request->path;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 confirm_file = (T_FFS_FILE_CNF *) request;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 confirm_file->error = error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 confirm_file->request_id = temp_id;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 confirm_file->path = temp_path;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 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
383
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 if (request->cp->callback_func) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 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
386 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 else if (request->cp->addr_id) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 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
390 confirm_file);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392 else {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 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
394 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 break;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 }
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 if (os_error != OS_OK)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 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
401 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403 // Blocking handling / unlocking mutex
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 else if (request->fb) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405 // 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
406 // 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
407 mutex_p = request->fb->mutex;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 *request->fb->result = error;
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412 else {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 // 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
414 free_mail = 1; // free mail
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 // 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
418 // 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
419 if (free_mail == 1) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 os_error = OS_FREE(request);
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 if (os_error != OS_OK)
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422 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
423 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425 // Blocking handling / unlocking mutex
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426 if (mutex_p) {
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427 // Wake up the caller task
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428 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
429 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
430 }
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431
3ebe6409e8bc gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432 tr_bstat();
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 }