*** empty log message ***
[yaffs2.git] / yaffs_packedtags2.c
1 #include "yaffs_packedtags2.h"
2 #include "yportenv.h"
3
4
5
6 void yaffs_PackTags2(yaffs_PackedTags2 *pt, yaffs_ExtendedTags *t)
7 {
8         pt->t.chunkId = t->chunkId;
9         pt->t.sequenceNumber = t->sequenceNumber;
10         pt->t.byteCount = t->byteCount;
11         pt->t.objectId = t->objectId;
12         
13         yaffs_ECCCalculateOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&pt->ecc);
14         
15 }
16
17 void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
18 {
19
20         
21         if(pt->t.sequenceNumber == 0xFFFFFFFF)
22         {
23                 memset(t,0,sizeof(yaffs_ExtendedTags));
24                 
25         }
26         else
27         {
28                 // Page is in use
29                 yaffs_ECCOther ecc;
30                 yaffs_ECCCalculateOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&ecc);
31                 t->eccResult = yaffs_ECCCorrectOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&pt->ecc,&ecc);
32                 t->blockBad = 0;
33                 t->chunkUsed = 1;
34                 t->objectId = pt->t.objectId;
35                 t->chunkId =  pt->t.chunkId;
36                 t->byteCount = pt->t.byteCount;
37                 t->chunkDeleted = 0;
38                 t->serialNumber = 0;
39                 t->sequenceNumber = pt->t.sequenceNumber;
40         }
41 }
42