FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/services/ffs/task.c @ 861:6ffebb8cec78
implemented feature mokoffs copy; made it part of the gtamodem-gsm config
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 03 May 2015 05:10:58 +0000 |
parents | d779078abe40 |
children |
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" |
226
4d706a4134b0
FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
221
diff
changeset
|
17 #include "ramffs.h" |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 #include "../../riviera/rvm/rvm_use_id_list.h" |
226
4d706a4134b0
FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
221
diff
changeset
|
19 #include <string.h> |
212
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 * Globals and function prototypes |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 ******************************************************************************/ |
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 extern UINT8 pcm_init(void); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 void ffs_task(void); |
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 static effs_t ffs_init_status; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 req_id_t request_id_last = 0; |
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 T_OS_MB_ID ffs_mb_id; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 UINT16 ffs_addr_id; |
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 * FFS Test Task |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 ******************************************************************************/ |
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 // For this to work, change: |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 // 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
|
40 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 // 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
|
42 // 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
|
43 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 #if (WITH_TFFS == 1) |
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_STACK_SIZE 1024 |
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 #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
|
49 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 void ffs_test_task(void); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 void test_init(int keepgoing); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 int test_run(char *testname); |
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 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
|
55 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 // 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
|
57 // string as written to from tmffs module. |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 char ffs_test_string[128]; |
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 for <delay> milliseconds |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 void tffs_delay(int 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 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
|
64 OS_DELAY(delay); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 UINT32 rvf_get_tick_count(void); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 // Timer functions for benchmarking |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 UINT32 tffs_timer_begin(void) |
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 return rvf_get_tick_count(); |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 UINT32 tffs_timer_end(UINT32 time_begin) |
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 // return current time minus time_begin |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 UINT32 ticks; |
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 ticks = rvf_get_tick_count(); |
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 return (ticks - time_begin) * 60 / 13; |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 void ffs_test_task(void) |
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 effs_t error; |
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 OS_DELAY(217); // wait approx. 1000ms |
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 ttw(str(TTrTest, "ffs_test_task()" NL)); |
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 while (1) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 OS_DELAY(217); // wait approx. 1000ms |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 // 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
|
96 // 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
|
97 // written when we reach here. |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 if (*ffs_test_string) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 test_init(0); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 error = test_run(ffs_test_string); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 *ffs_test_string = 0; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 if (error == 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 ttw(str(TTrTest, "TEST succeeded" NL)); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 else |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 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
|
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 } |
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 #endif // End of WITH_TFFS |
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 * Target Platform Abstraction Functions |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 req_id_t request_id_get(void) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 { |
219
2beb88a3d528
gsm-fw links with FFS included
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
218
diff
changeset
|
119 uint32 cpsr; |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 // 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
|
122 cpsr = int_disable(); |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 request_id_last++; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 if (request_id_last < 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 request_id_last = 0; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 |
219
2beb88a3d528
gsm-fw links with FFS included
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
218
diff
changeset
|
128 int_enable(cpsr); |
212
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 return request_id_last; |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 void *target_malloc(unsigned int size) |
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 char *buf; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 #if (_RVF == 1) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 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
|
139 return 0; |
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 buf; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 #else |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 return 0; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 #endif |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 void target_free(void *buf) |
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 int error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 #if (_RVF == 1) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 if ((error = OS_FREE(buf)) != OS_OK) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 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
|
154 #endif |
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 /****************************************************************************** |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 * FFS Blocking Call Handling |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 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
|
163 { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 effs_t error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 if ((error = rvf_initialize_mutex(mutex)) < 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 return error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 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
|
170 return error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 fb->result = result; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 fb->mutex = mutex; |
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 return EFFS_OK; |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 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
|
179 { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 effs_t error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 // 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
|
183 if (result >= 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 // 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
|
185 if ((error = rvf_lock_mutex(mutex)) < 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 return error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 if ((error = rvf_unlock_mutex(mutex)) < 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 return error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 if ((error = rvf_delete_mutex(mutex)) < 0) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 return error; |
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 return EFFS_OK; |
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 /****************************************************************************** |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 * FFS Task |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 ******************************************************************************/ |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 /* 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
|
201 * 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
|
202 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 void ffs_main_init() |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 extern int TCD_Interrupt_Level; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 int tmp_int_level; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 ttr_init(TTrTask|TTrTest|TTrTestInfo); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 //ttr_init(TTrTask|TTrTest|TTrTestInfo|TTrDrvErase|TTrDrvWrite|TTrTaskLow|TTrApi); |
643
d779078abe40
PCM integration: pcm_init() call
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
226
diff
changeset
|
209 |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 tmp_int_level = TCD_Interrupt_Level; // Backup Int level |
226
4d706a4134b0
FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
221
diff
changeset
|
211 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
|
212 #if FFS_IN_RAM |
861
6ffebb8cec78
implemented feature mokoffs copy; made it part of the gtamodem-gsm config
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
643
diff
changeset
|
213 #if CONFIG_MOKOFFS_COPY |
6ffebb8cec78
implemented feature mokoffs copy; made it part of the gtamodem-gsm config
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
643
diff
changeset
|
214 bcopy_32byte_chunks(0x380000, _RAMFFS_area, 0x70000); |
6ffebb8cec78
implemented feature mokoffs copy; made it part of the gtamodem-gsm config
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
643
diff
changeset
|
215 #else |
226
4d706a4134b0
FFS in gsm-fw: generate the legacy block info table at run time
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
221
diff
changeset
|
216 memset(_RAMFFS_area, 0xFF, RAMFFS_TOTAL_SIZE); |
218
fee45482aa2a
FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
212
diff
changeset
|
217 #endif |
861
6ffebb8cec78
implemented feature mokoffs copy; made it part of the gtamodem-gsm config
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
643
diff
changeset
|
218 #endif |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 ffs_init_status = ffs_initialize(); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 TCD_Interrupt_Level = tmp_int_level; // Restore Int level |
643
d779078abe40
PCM integration: pcm_init() call
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
226
diff
changeset
|
221 |
d779078abe40
PCM integration: pcm_init() call
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
226
diff
changeset
|
222 #if 0 // moved to Application_Initialize() - FreeCalypso change |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 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
|
224 #endif |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 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
|
228 { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 int error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 ffs_mb_id = mbid; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 ffs_addr_id = addr_id; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 #if (WITH_TFFS == 1) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 error = |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 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
|
237 ffs_test_stack, FFS_TEST_STACK_SIZE, |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 249, // priority |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 4, // ET4_TASK type |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 0, // no time slicing |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 RUNNING); // start state |
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 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
|
244 #endif |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 void ffs_task() |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 extern int etm_ffs_init(void); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 struct ffs_req_s *request; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 T_FFS_FILE_CNF *confirm_file; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 T_FFS_STREAM_CNF *confirm_stream; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 T_RVF_MUTEX *mutex_p; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 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
|
255 uint16 revision, manufacturer_id, device_id; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 uint32 base; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 fd_t fdi; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 char *temp_path; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 req_id_t temp_id; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 |
861
6ffebb8cec78
implemented feature mokoffs copy; made it part of the gtamodem-gsm config
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
643
diff
changeset
|
261 #if FFS_IN_RAM && !CONFIG_MOKOFFS_COPY |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 // Non formatted FFS should be formatted |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 // 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
|
264 if (fs.initerror == EFFS_NOFORMAT) |
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 ffs_format_nb("/", 0x2BAD, 0); |
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 |
218
fee45482aa2a
FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
212
diff
changeset
|
269 /* ffs_InitRFCap(); */ |
212
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 #endif |
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 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
|
273 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 ffs_query(Q_FFS_REVISION, &revision); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
275 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
|
276 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
277 ffs_query(Q_DEV_MANUFACTURER, &manufacturer_id); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
278 ffs_query(Q_DEV_DEVICE, &device_id); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 ffs_query(Q_DEV_DRIVER, &revision); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
280 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
|
281 manufacturer_id, device_id, revision); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 ffs_query(Q_DEV_BASE, &base); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 ffs_query(Q_DEV_BLOCKS, &revision); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 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
|
286 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 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
|
288 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
|
289 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
|
290 manufacturer_id, device_id); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
291 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
292 // 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
|
293 blocks_reclaim(); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 // 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
|
296 // otherwise mkdir("pcm") will fail. |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 error = ffs_mkdir_nb("/pcm", 0); |
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 // Register FFS to ETM database |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
300 error = etm_ffs_init(); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 while (1) |
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 OS_MAIL_WAIT(OS_MAIL_EVENT_MASK); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
305 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
|
306 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 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
|
308 switch (request->cmd) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 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
|
310 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
|
311 // 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
|
312 // 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
|
313 fdi = (fd_t)request->fdi; |
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 default: |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 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
|
317 break; |
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 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
|
320 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
|
321 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 if (tr_query(TTrTaskDelays)) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 OS_DELAY(5); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 switch (request->cmd) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 case NOP: error = EFFS_OK; break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
327 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
|
328 case SYMLINK: error = task_symlink(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
329 case MKDIR: error = task_mkdir(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
330 case REMOVE: error = task_remove(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 case RENAME: error = task_rename(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 case FCONTROL: error = task_fcontrol(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 case PREFORMAT: error = task_preformat(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 case FORMAT: error = task_format(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 case OPEN: error = task_open(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 case WRITE: error = task_write(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 case SEEK: error = task_seek(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 case CLOSE: error = task_close(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 case TRUNC: error = task_trunc(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 case FTRUNC: error = task_ftrunc(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 case FDATASYNC: error = task_fdatasync(request); break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 default: |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
343 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
|
344 break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
346 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 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
|
348 if (tr_query(TTrTaskDelays)) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 OS_DELAY(5); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 // Call-back to caller |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 mutex_p = 0; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 if (request->cp) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 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
|
355 // 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
|
356 // 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
|
357 // 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
|
358 // 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
|
359 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
360 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
|
361 switch (request->cmd) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 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
|
363 confirm_stream = (T_FFS_STREAM_CNF *) request; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 confirm_stream->error = error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 confirm_stream->request_id = temp_id; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 confirm_stream->fdi = fdi; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 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
|
368 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 if (request->cp->callback_func) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
370 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
|
371 confirm_stream); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 else if (request->cp->addr_id) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 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
|
375 confirm_stream); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 else { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
378 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
|
379 free_mail = 1; // free mail |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
380 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 default: |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 temp_path = (char *) request->path; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 confirm_file = (T_FFS_FILE_CNF *) request; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 confirm_file->error = error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
386 confirm_file->request_id = temp_id; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 confirm_file->path = temp_path; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
388 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
|
389 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 if (request->cp->callback_func) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
391 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
|
392 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
393 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 else if (request->cp->addr_id) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 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
|
396 confirm_file); |
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 else { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 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
|
400 free_mail = 1; // free mail |
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 break; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 } |
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 if (os_error != OS_OK) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 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
|
407 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
409 // Blocking handling / unlocking mutex |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
410 else if (request->fb) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
411 // 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
|
412 // 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
|
413 mutex_p = request->fb->mutex; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
414 *request->fb->result = error; |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
415 free_mail = 1; // free mail |
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 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 else { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 // 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
|
420 free_mail = 1; // free mail |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
423 // 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
|
424 // 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
|
425 if (free_mail == 1) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
426 os_error = OS_FREE(request); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
427 if (os_error != OS_OK) |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
428 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
|
429 } |
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 // Blocking handling / unlocking mutex |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
432 if (mutex_p) { |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
433 // Wake up the caller task |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
434 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
|
435 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
|
436 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
437 |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 tr_bstat(); |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
439 } |
3ebe6409e8bc
gsm-fw/services/ffs: task.c integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
440 } |