/[PAMELA software]/quicklook/dataToXML/Data/compilationInfo/src/FileManager/FileSystem/FS_FileSystem_op.c
ViewVC logotype

Contents of /quicklook/dataToXML/Data/compilationInfo/src/FileManager/FileSystem/FS_FileSystem_op.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Apr 25 09:00:20 2006 UTC (19 years, 2 months ago) by kusanagi
Branch: MAIN
CVS Tags: dataToXML1_02/01, dataToXML1_02/00, dataToXML1_03/00, dataToXML1_03/01, dataToXML1_00/00, firstRelease, dataToXML1_01/00, dataToXML1_03_02, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
These program extract in an XML format the info contained into the ROOT files generated by YODA from the PAMELA data. To visualize the XML files in a more human readable format a collection of XSL files are given in the Data subfolder.

1 /****************************************************************************
2 /* F i l e D a t a
3 /*
4 /* Module : FileManager
5 /* C.I. No. :
6 /* $Revision: 1.17 $
7 /* $Date: 2005/02/21 08:58:28 $
8 /* Belonging to :
9 /* :
10 /* $RCSfile: FS_FileSystem_op.c,v $
11 /* Program Type :
12 /* Sub-modules :
13 /*
14 /****************************************************************************
15 /* S W D e v e l o p m e n t E n v i r o n m e n t
16 /*
17 /* Host system :
18 /* SW Compiler :
19 /* $Author: sebastiani $
20 /* :
21 /****************************************************************************
22 /* U p d a t i n g
23 /*
24 /* $Log: FS_FileSystem_op.c,v $
25 /* Revision 1.17 2005/02/21 08:58:28 sebastiani
26 /* all log comments completed
27 /*
28 /* Revision 1.16 2004/09/17 15:01:00 faber
29 /* LU_INFN_LOG flags fixing
30 /*
31 /* Revision 1.15 2004/07/28 17:18:45 sebastiani
32 /* better loggin status
33 /*
34 /* Revision 1.14 2004/07/08 16:23:37 sebastiani
35 /* *** empty log message ***
36 /*
37 /* Revision 1.13 2004/06/15 08:12:25 sebastiani
38 /* no warning MaxSize any more
39 /*
40 /* Revision 1.12 2004/01/29 18:07:06 sebastiani
41 /* important bug fix (no mass memory store for big packet):
42 /* // fix: commented out due a BIG for long packet
43 /* > // FS_WrittenFile = FileId;
44 /* > // FS_CurrentSaveSize = WriteSize;
45 /* > *WriteAddr = FS_Files[FS_ERC32].WriteAddr;
46 /*
47 /* Revision 1.11 2003/11/10 12:11:52 sebastiani
48 /* more complete log info
49 /*
50 /* Revision 1.10 2003/11/05 08:16:36 sebastiani
51 /* new filesystem %size in 100*100 instead 100 units
52 /*
53 /* Revision 1.9 2003/11/04 11:56:53 sebastiani
54 /* new log status sequence
55 /*
56 /* Revision 1.8 2003/10/30 10:09:30 sebastiani
57 /* MM size definitions fixed
58 /*
59 /* Revision 1.7 2003/10/29 17:41:48 sebastiani
60 /* *** empty log message ***
61 /*
62 /* Revision 1.6 2003/10/29 08:32:26 sebastiani
63 /* *** empty log message ***
64 /*
65 /* Revision 1.5 2003/10/17 08:18:48 sebastiani
66 /* FileID <-- FILE1 bugfix
67 /*
68 /* Revision 1.4 2003/09/10 13:38:13 laben
69 /* New File System Model:
70 /* jusy one file used like a circular buffer.
71 /*
72 /* Revision 1.3 2003/08/27 09:49:17 wizard
73 /* Fix last sector in donwload.
74 /* Set Sector size to 1024*1015
75 /* Fix Donwload procedure... ( set size set lastsector flag.....)
76 /* bye
77 /*
78 /* Revision 1.2 2003/08/07 08:44:14 wizard
79 /* SIMULATOR bugs ifdef/ifndef corrected
80 /* laben bug "GetFileInfo" for FS_ERC32 id accepted in order to fix SM_pi_GetPacket
81 /*
82 /* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani
83 /* Imported sources laben rel. 19.06.2003 integrated with pam2
84 /*
85 /* Revision 1.8 2003/06/09 10:22:10 aurora
86 /* introduced a new file called FS_ERC32.
87 /* It stores the data in ERC32 memory
88 /*
89 /* Revision 1.7 2003/05/09 08:51:10 aurora
90 /* correct race on write of regular file and, after, cmd
91 /*
92 /* Revision 1.6 2002/05/09 08:16:34 zulia
93 /* * acceptance release
94 /*
95 /*
96 /*****************************************************************************/
97
98 /*============================= Include File ================================*/
99
100 #include <src/INFN/LU_SourceFileID_INFN.h>
101 #define __FILEID__ _FS_FileSystem_op__c
102 #include <src/INFN/PRH_ParamHandler_INFN.h>
103 #include <src/INFN/LU_LogUtility_INFN.h>
104 #include <src/INFN/PRH_ParamHandler_INFN_auto.h>
105 LU_DECL_MASK();
106
107
108 #include <src/FileManager/FileSystem/FS_FileSystem_op.h>
109 #include <src/FileManager/MMSUManager/FT_MMSUManager_p.h>
110
111 /*============================== global define ==============================*/
112
113 /*======================== Object Internal variables ========================*/
114
115 /*****************************************************************************/
116 /* @Variable: FS_Files */
117 /* @Purpose : */
118 /* Mass memory files */
119 /* @@ */
120 /*****************************************************************************/
121 static FS_FILE_DESCR FS_Files[FS_MAXID+1];
122
123 /*****************************************************************************/
124 /* @Variable: FS_CurrentSaveSize */
125 /* @Purpose : */
126 /* Size of the last store operation */
127 /* @@ */
128 /*****************************************************************************/
129 static UINT32 FS_CurrentSaveSize;
130
131 /*****************************************************************************/
132 /* @Variable: FS_WrittenFile */
133 /* @Purpose : */
134 /* Last Written file */
135 /* @@ */
136 /*****************************************************************************/
137 static UINT32 FS_WrittenFile;
138
139 /*****************************************************************************/
140 /* @Variable: FS_SecList */
141 /* @Purpose : */
142 /* Sector chain used for download operation */
143 /* @@ */
144 /*****************************************************************************/
145 static FS_SECT_DESCR FS_SecList[FT_MAXSECTORS];
146
147 /*****************************************************************************/
148 /* @Variable: FS_ReadSectorCount */
149 /* @Purpose : */
150 /* Read sector counter */
151 /* @@ */
152 /*****************************************************************************/
153 static UINT32 FS_ReadSectorCount;
154
155 /*****************************************************************************/
156 /* @Variable: FS_CurrentImageSector */
157 /* @Purpose : */
158 /* Index of the current first sector of the chain */
159 /* @@ */
160 /*****************************************************************************/
161 static UINT32 FS_CurrentImageSector;
162
163 /*****************************************************************************/
164 /* @Variable: FS_LastImageSector */
165 /* @Purpose : */
166 /* Index of the last sector in the chain */
167 /* @@ */
168 /*****************************************************************************/
169 static UINT32 FS_LastImageSector;
170
171 /*****************************************************************************/
172 /* @Variable: FS_PktBuf */
173 /* @Purpose : */
174 /* Buffer used to tranfer packets from SRAM to microprocessor RAM */
175 /* and viceversa */
176 /* @@ */
177 /*****************************************************************************/
178 static BYTE FS_PktBuf[SM_DAQPKTSIZE];
179
180
181 /*****************************************************************************/
182 /* @Variable: FS_LastSectorDwn */
183 /* @Purpose : */
184 /* last sector downlinked pointer */
185 /* */
186 /* @@ */
187 /*****************************************************************************/
188 static UINT32 FS_LastSectorDwn;
189
190
191 /*****************************************************************************/
192
193 /*=== F S _ F i l e S y s t e m O P E R A T I O N A L F U N C T I O N S ==*/
194
195 /*****************************************************************************/
196 /* @Function: FS_opInitFileSystem */
197 /* @Purpose : */
198 /* The function initializes the File System structures. */
199 /* The -Fat- parameter specifies which FAT initialize Local, Remote, or */
200 /* both (FAT_LOCAL,FAT_REMOTE,FAT_ALL). In FAT_ALL modality is also */
201 /* initialized the File Description Table */
202 /* */
203 /* @@ */
204 /* @Parameter Name @Mode @Description */
205 /* IN */
206 /* status_code OUT Return code */
207 /* @@ */
208 /*****************************************************************************/
209
210 FS_EXITCODE FS_opInitFileSystem(void)
211 {
212 FS_EXITCODE status = FS_SUCCESS;
213
214 // Hardcoded file setup
215 FS_Files[FS_FILE1].Size = 0;
216 FS_Files[FS_FILE1].WriteAddr = 0; // 64byte gran addres
217 FS_Files[FS_FILE1].MaxSize = (FT_MAXSECTORS*FT_SECTSIZE)/FT_SAMPLESIZE;
218 FS_Files[FS_FILE1].MaxAddr = (FT_MAXSECTORS*FT_SECTSIZE)/FT_MEMGRANUL;
219
220 // dummy values; the FS_HK is FS_FILE1
221 FS_Files[FS_HK].Size = 0;
222 FS_Files[FS_HK].WriteAddr = 0;
223 FS_Files[FS_HK].MaxSize = 0;
224 FS_Files[FS_HK].MaxAddr = 0;
225
226 // Special file used for the ERC32
227 FS_Files[FS_ERC32].Size = 0;
228 FS_Files[FS_ERC32].WriteAddr = (unsigned int) FS_PktBuf;
229 FS_Files[FS_ERC32].MaxSize = SM_DAQPKTSIZE;
230 // unused
231 FS_Files[FS_ERC32].MaxAddr = FS_Files[FS_ERC32].WriteAddr + SM_DAQPKTSIZE;
232 // Special file used for the CMD I/F
233 FS_Files[FS_CMD].Size = 0;
234 FS_Files[FS_CMD].WriteAddr = 0;
235 FS_Files[FS_CMD].MaxSize = 0xFFFFFFFF;
236 // unused
237 FS_Files[FS_CMD].MaxAddr = FS_Files[FS_CMD].WriteAddr + FS_Files[FS_CMD].MaxSize;
238 // Dummy files
239 FS_Files[FS_REGFILES].Size = 0;
240 FS_Files[FS_REGFILES].WriteAddr = 0;
241 FS_Files[FS_REGFILES].MaxSize = 0x00000000;
242 // unused
243 FS_Files[FS_REGFILES].MaxAddr = FS_Files[FS_REGFILES].WriteAddr + FS_Files[FS_REGFILES].MaxSize;
244
245 FS_Files[FS_MAXID].Size = 0;
246 FS_Files[FS_MAXID].WriteAddr = 0;
247 FS_Files[FS_MAXID].MaxSize = 0x00000000;
248 // unused
249 FS_Files[FS_MAXID].MaxAddr = FS_Files[FS_MAXID].WriteAddr + FS_Files[FS_MAXID].MaxSize;
250
251 FS_LastSectorDwn = 0;
252
253 return (status);
254 }
255
256 /*****************************************************************************/
257 /* @Function: FS_opGetFileInfo */
258 /* @Purpose : */
259 /* Provided Interface to get the status of the selected file */
260 /* */
261 /* @@ */
262 /* @Parameter Name @Mode @Description */
263 /* FileId IN File ID */
264 /* *FileInfo OUT File status */
265 /* FS_EXITCODE OUT Return code */
266 /* @@ */
267 /*****************************************************************************/
268
269 FS_EXITCODE FS_opGetFileInfo(FS_FILEID FileId, FS_FILE_DESCR* FileInfo)
270 {
271 FS_EXITCODE status;
272 unsigned int intLevel;
273
274 /* File info are available only for regular files */
275 /* INFN BugFix: FS_ERC32 is needed by PM_pi_GetPacket(...) */
276 if(FileId >= FS_REGFILES && FileId != FS_ERC32)
277 status = FS_WRONGFILEID;
278 else {
279 OS_piInterDisable(&intLevel);
280 /* Retrive selected file info */
281 FileInfo->Size = FS_Files[FileId].Size;
282 FileInfo->WriteAddr = FS_Files[FileId].WriteAddr;
283 FileInfo->MaxSize = FS_Files[FileId].MaxSize;
284 OS_piInterEnable(intLevel);
285 status = FS_SUCCESS;
286 }
287 return (status);
288 }
289
290 void FS_opLogInfo() {
291 unsigned short used = (FS_Files[FS_FILE1].Size*100) / FS_Files[FS_FILE1].MaxSize;
292 unsigned short size_mega = (unsigned short)((FS_Files[FS_FILE1].Size*FT_SAMPLESIZE)/(1024*1024));
293 /*@LOG Size */
294 LU_INFN_LOG(LU_NORMAL_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,FS_Files[FS_FILE1].Size);
295 /*@LOG WriteAddress */
296 LU_INFN_LOG(LU_NORMAL_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,FS_Files[FS_FILE1].WriteAddr);
297 /*@LOG Used Ratio % */
298 LU_INFN_LOG(LU_NORMAL_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,used);
299 /*@LOG Size in MB */
300 LU_INFN_LOG(LU_NORMAL_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,size_mega);
301 /*@LOG Last Sector Downlink */
302 LU_INFN_LOG(LU_NORMAL_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,FS_LastSectorDwn);
303
304 }
305
306 /*****************************************************************************/
307 /* @Function: FS_opWriteFile */
308 /* @Purpose : */
309 /* Provided Interface to check if a file could be written. The status of the*/
310 /* selected file is not updated until the UpdateFile operation is called */
311 /* */
312 /* @@ */
313 /* @Parameter Name @Mode @Description */
314 /* FileId IN File ID */
315 /* WriteSize IN Size of the data to be saved (in samples) */
316 /* WriteAddr OUT Address where to store data in the file */
317 /* FS_EXITCODE OUT Return code */
318 /* @@ */
319 /*****************************************************************************/
320
321 FS_EXITCODE FS_opWriteFile(FS_FILEID FileId, UINT32 WriteSize,
322 UINT32 *WriteAddr)
323 {
324 FS_EXITCODE status = FS_SUCCESS;
325 UINT32 algn;
326 UINT32 StartNextDownlinkAddr;
327 UINT32 granInc;
328 UINT32 granWordInc;
329
330 /*
331 * if(FileId < FS_REGFILES)
332 * dobbiamo controllare che:
333 * ci si spazio nel file (che WriteAddress+WriteSize non si maggiore di StartDonwlinkAddress)
334 * che WriteAddress + WriteSize non oltrepassi la fine del file
335 * non bisogna fare reset del file
336 *
337 */
338
339 if (FileId == FS_CMD)
340 return(status);
341
342 if ((FileId == FS_REGFILES) || (FileId == FS_MAXID))
343 return(FS_WRONGFILEID);
344
345 if(FileId < FS_REGFILES) // PUO' ESSERE SOLO FILE1
346 {
347 FileId = FS_FILE1;
348
349 algn = WriteSize % FT_SAMPLESIZE;
350 if(algn)
351 {
352 WriteSize += (FT_SAMPLESIZE - algn);
353 }
354
355 // graninc: write size in blocchi da 64byte!
356 granInc = WriteSize / FT_MEMGRANUL;
357 if( (WriteSize % FT_MEMGRANUL) ) granInc++;
358 // granwordinc: size realmente occupata nel file in bloacchi da 4 byte!
359 granWordInc = ( granInc * FT_MEMGRANUL ) / FT_SAMPLESIZE;
360
361 // WriteSize: size in blocchi da 4 byte realmente da downloadare!
362 WriteSize /= FT_SAMPLESIZE;
363
364 // controllo se vado oltre la fine del file!
365 if((FS_Files[FileId].WriteAddr + granInc) > FS_Files[FileId].MaxAddr)
366 {
367 // spazio non sufficiente ( alla fine del file) mi metto all'inizio del file e aggiorno la size
368 UINT32 LostByte = ( ( FS_Files[FileId].MaxAddr - FS_Files[FileId].WriteAddr) * FT_MEMGRANUL );
369 FS_Files[FileId].Size += ( LostByte / FT_SAMPLESIZE);
370 FS_Files[FileId].WriteAddr = 0;
371 }
372
373 if(FS_Files[FileId].Size + granWordInc > FS_Files[FileId].MaxSize )
374 {
375 /* There is not enough space on the device */
376 FS_WrittenFile = FS_MAXID;
377 FS_CurrentSaveSize = 0;
378 return(FS_FILEISFULL);
379 }
380
381 /* Puo' bastare il controllo precedente
382
383 // se sono arrivato dove ho gia' scritto il file e' pieno!!!!
384 StartNextDownlinkAddr = (FS_Files[FileId].StartDwnlnkSec*FT_SECTSIZE/FT_MEMGRANUL );
385 if((FS_Files[FileId].WriteAddr+granInc) > StartNextDownlinkAddr )
386 {
387 FS_WrittenFile = FS_MAXID;
388 FS_CurrentSaveSize = 0;
389 return(FS_FILEISFULL);
390 }
391 */
392
393 FS_WrittenFile = FileId;
394 FS_CurrentSaveSize = WriteSize;
395 *WriteAddr = FS_Files[FS_WrittenFile].WriteAddr;
396 }
397
398 if ( FileId == FS_ERC32)
399 {
400 // fix: commented out due a BIG for long packet
401 // FS_WrittenFile = FileId;
402 // FS_CurrentSaveSize = WriteSize;
403 *WriteAddr = FS_Files[FS_ERC32].WriteAddr;
404 }
405
406 return (status);
407 }
408
409 /*****************************************************************************/
410 /* @Function: FS_opUpdateFile */
411 /* @Purpose : */
412 /* Provided Interface to update file size after a store operation */
413 /* */
414 /* @@ */
415 /* @Parameter Name @Mode @Description */
416 /* FS_EXITCODE OUT Return code */
417 /* @@ */
418 /*****************************************************************************/
419
420 FS_EXITCODE FS_opUpdateFile(void)
421 {
422 FS_EXITCODE status = FS_SUCCESS;
423 UINT32 granInc;
424
425 /* Update the size/appendAddress info for regular files */
426 if(FS_WrittenFile < FS_REGFILES) {
427 /* Evaluate the minimum necessary FT_MEMGRANUL sized chunks of memory */
428 /* to hold the new data stored in the file */
429 granInc = (FS_CurrentSaveSize * FT_SAMPLESIZE) / FT_MEMGRANUL;
430 if(((FS_CurrentSaveSize * FT_SAMPLESIZE) % FT_MEMGRANUL)) granInc++;
431 /* Evaluate the new filesize in samples */
432
433 FS_Files[FS_FILE1].Size += (granInc * FT_MEMGRANUL) / FT_SAMPLESIZE;
434 /* Increment the file append address */
435 FS_Files[FS_FILE1].WriteAddr += granInc;
436 }
437 return (status);
438 }
439
440 /*****************************************************************************/
441 /* @Function: FS_opMakeFileImage */
442 /* @Purpose : */
443 /* Provided Interface to build the sector chain for the download operation */
444 /* */
445 /* @@ */
446 /* @Parameter Name @Mode @Description */
447 /* StartSector IN First sector of the partition to add to the */
448 /* sector chain */
449 /* Size IN Size of the partition (in sample) */
450 /* New IN This flag is used to build a new chain or to */
451 /* append a partition to an existing chain */
452 /* nsect OUT Number of sectors added to the chain */
453 /* FS_EXITCODE OUT Return code */
454 /* @@ */
455 /*****************************************************************************/
456
457 FS_EXITCODE FS_opMakeFileImage(UINT32 StartSector, UINT32 Size, UINT32* nsect, BOOL New)
458 {
459 FS_EXITCODE status = FS_SUCCESS;
460 UINT32 sectors;
461 UINT32 lastSectSize;
462 UINT32 halfSector = 0;
463 UINT32 sectorAddress;
464 UINT32 idx;
465
466 // Find the number entierly data filled sectors
467 sectors = Size / (FT_SECTSIZE / FT_SAMPLESIZE);
468 // Find the last sector size
469 lastSectSize = Size % (FT_SECTSIZE / FT_SAMPLESIZE);
470 if(lastSectSize > 0) halfSector = 1;
471 *nsect = sectors + halfSector;
472
473 /* Check if the sectors exceeds the maximum length of the sector chain */
474 if(Size == 0 || (StartSector + sectors + halfSector) > FT_MAXSECTORS ) {
475 status = FS_WRONGPARAMS;
476 }
477 else {
478 /* Create a new sector chain */
479 if(New) {
480 FS_CurrentImageSector = StartSector;
481 FS_ReadSectorCount = 0;
482 }
483 else {
484 /* Append another sector chain to an exsisting one */
485 FS_SecList[FS_LastImageSector].LastSectLength = FS_ONEMB_SECTOR_SIZE;
486 FS_SecList[FS_LastImageSector].NextSect = StartSector;
487 FS_SecList[FS_LastImageSector].LastSectFlag = FALSE;
488 }
489 /* Evaluate the address of the fist sector of the chain */
490
491 sectorAddress = StartSector * (FT_SECTSIZE / FT_MEMGRANUL);
492
493 for(idx = 0; idx < sectors; idx++) {
494 /* Create a chain record */
495 /* for all the entierly data filled sectors */
496 FS_SecList[StartSector + idx].LastSectLength = FS_ONEMB_SECTOR_SIZE;
497 FS_SecList[StartSector + idx].NextSect = StartSector + idx + 1;
498 FS_SecList[StartSector + idx].LastSectFlag = FALSE;
499 FS_SecList[StartSector + idx].SectAddr = sectorAddress;
500
501 sectorAddress += (FT_SECTSIZE / FT_MEMGRANUL);
502 }
503 if(lastSectSize > 0) {
504 /* Create a chain record for the last half filled sector */
505 /* and close the chain tail by wrapping it ovet itself */
506 FS_SecList[StartSector + sectors].LastSectLength = lastSectSize;
507 FS_SecList[StartSector + sectors].NextSect = StartSector + sectors;
508 FS_SecList[StartSector + sectors].LastSectFlag = TRUE;
509 FS_SecList[StartSector + sectors].SectAddr = sectorAddress;
510 FS_LastImageSector = StartSector + sectors;
511 }
512 else {
513 /* Close the chain tail by wrapping it ovet itself */
514 FS_SecList[StartSector + sectors - 1].NextSect = StartSector + sectors - 1;
515 FS_SecList[StartSector + sectors - 1].LastSectFlag = TRUE;
516 FS_LastImageSector = StartSector + sectors - 1;
517 }
518 }
519 return (status);
520 }
521
522
523 /*****************************************************************************/
524 /* @Function: FS_opGetNextSector */
525 /* @Purpose : */
526 /* Provided Interface to retrive the next sector information to be used */
527 /* in a downlink sequence */
528 /* */
529 /* @@ */
530 /* @Parameter Name @Mode @Description */
531 /* *SectorInfo OUT Next sector information */
532 /* FS_EXITCODE OUT Return code */
533 /* @@ */
534 /*****************************************************************************/
535
536 FS_EXITCODE FS_opGetCurrentSector(FS_SECT_DESCR *SectorInfo)
537 {
538 /* Retrive the selected sector info */
539
540 // SectorInfo->SectAddr = FS_ONEMB_SECTOR_SIZE*FS_LastSectorDwn;
541 // The Sector Address is in 64byte unit
542 SectorInfo->SectAddr = FS_LastSectorDwn * (FT_SECTSIZE / FT_MEMGRANUL);
543 /* If a minimum number of sectors have not been read yet, then */
544 /* return the last sector info but with the last sector flag=FALSE */
545 SectorInfo->LastSectLength = FS_ONEMB_SECTOR_SIZE;
546 SectorInfo->LastSectFlag = FALSE;
547
548 return(FS_SUCCESS);
549 }
550
551 FS_EXITCODE FS_opGetNextSector(FS_SECT_DESCR *SectorInfo)
552 {
553 FS_EXITCODE status;
554
555 /* Increment the sector chain index and retrive the next sector information */
556 // FS_CurrentImageSector = FS_SecList[FS_CurrentImageSector].NextSect;
557
558 if(FS_Files[FS_FILE1].Size>=FS_ONEMB_SECTOR_SIZE)
559 FS_Files[FS_FILE1].Size -= FS_ONEMB_SECTOR_SIZE;
560 else{
561 FS_Files[FS_FILE1].Size = 0 ;
562 // Ho donwloadato tutta la memoria scritta!!!
563 }
564 FS_LastSectorDwn++;
565 if(FS_LastSectorDwn >= FT_MAXSECTORS){
566 FS_LastSectorDwn=0;
567 }
568
569
570 status = FS_piGetCurrentSector(SectorInfo);
571
572 return (status);
573 }
574
575 FS_EXITCODE FS_opUpdateSectorPointer()
576 {
577 UINT32 FileWriteSector;
578 UINT32 LastSectorDwnl;
579 FS_EXITCODE status = FS_SUCCESS;
580
581 if(! FS_Files[FS_FILE1].Size){
582 // l'ultimo settore dove ho scritto!
583 FileWriteSector = 1 + (FS_Files[FS_FILE1].WriteAddr * FT_MEMGRANUL / FT_SECTSIZE);
584 FS_LastSectorDwn = FileWriteSector;
585 FS_Files[FS_FILE1].WriteAddr = FileWriteSector * (FT_SECTSIZE / FT_MEMGRANUL);
586 }
587 return (status);
588 }
589
590
591 /*****************************************************************************/
592 /* @Function: FS_opResetFile */
593 /* @Purpose : */
594 /* Provided Interface to reset the status of a file. By now it means that */
595 /* the size is set to 0 */
596 /* in a downlink sequence */
597 /* */
598 /* @@ */
599 /* @Parameter Name @Mode @Description */
600 /* *SectorInfo OUT Next sector information */
601 /* FS_EXITCODE OUT Return code */
602 /* @@ */
603 /*****************************************************************************/
604
605 FS_EXITCODE FS_opResetFile(FS_FILEID FileId)
606 {
607 FS_EXITCODE status = FS_SUCCESS;
608
609 /* Reset a file by setting its size equal to zero */
610 /* and its append address to the address of the first */
611 /* sector of the file */
612 FS_Files[FileId].Size = 0;
613 FS_Files[FileId].WriteAddr = 0;
614
615 return (status);
616 }

  ViewVC Help
Powered by ViewVC 1.1.23