source: umon/apps/common/tfs.h @ 87db514

Last change on this file since 87db514 was 87db514, checked in by Amar Takhar <amar@…>, on 04/16/15 at 19:26:21

Initial commit of the umon repository.

Prior to this three changes were made:

  • Remove umon_ prefix from parent directories.
  • Collapse main/target/ into main/
  • Remove ports/template/flashtest.scr.ucon script.
  • Property mode set to 100644
File size: 6.7 KB
Line 
1/* tfs.h:
2 *      Header file for TFS transactions, used by both application and monitor.
3 *
4 *      General notice:
5 *      This code is part of a boot-monitor package developed as a generic base
6 *      platform for embedded system designs.  As such, it is likely to be
7 *      distributed to various projects beyond the control of the original
8 *      author.  Please notify the author of any enhancements made or bugs found
9 *      so that all may benefit from the changes.  In addition, notification back
10 *      to the author will allow the new user to pick up changes that may have
11 *      been made by other users after this version of the code was distributed.
12 *
13 *      Note1: the majority of this code was edited with 4-space tabs.
14 *      Note2: as more and more contributions are accepted, the term "author"
15 *                 is becoming a mis-representation of credit.
16 *
17 *      Original author:        Ed Sutter
18 *      Email:                          esutter@lucent.com
19 *      Phone:                          908-582-2351
20 */
21#ifndef _tfs_h
22#define _tfs_h
23
24#define TFSINFOSIZE             23              /* Max size of info string (mod4-1). */
25
26#ifndef TFSNAMESIZE                             /* This specifies the maximum size of a file */
27#define TFSNAMESIZE             23              /* name that can be used in TFS. */
28#endif                                                  /* This MUST be some value mod4 - 1. */
29
30#ifndef TFS_CHANGELOG_FILE              /* Information used for change-log */
31#define TFS_CHANGELOG_SIZE      0       /* facility within tfs. */
32#define TFS_CHANGELOG_FILE      ".tfschlog"
33#endif
34
35#ifndef SYMFILE                                 /* This specifies the default filename */
36#define SYMFILE         "symtbl"        /* used by the monitor for the symbol */
37#endif                                                  /* table. */
38
39#define MINUSRLEVEL             0               /* Minimum user level supported. */
40#define MAXUSRLEVEL             3               /* Maximum user level supported. */
41
42#ifndef TFS_RESERVED
43#define TFS_RESERVED    4               /* Number of "reserved" entries (ulong) */
44#endif                                                  /* in the TFS header. */
45
46
47/* Flags: */
48#define TFS_EXEC        0x00000001      /* 'e': Executable script. */
49#define TFS_BRUN        0x00000002      /* 'b': To be executed at boot. */
50#define TFS_QRYBRUN     0x00000004      /* 'B': To be executed at boot if */
51                                                                /*      query passes. */
52#define TFS_SYMLINK     0x00000008      /* 'l': Symbolic link file. */
53#define TFS_EBIN        0x00000010      /* 'E': Executable binary (coff/elf/a.out). */
54#define TFS_CPRS        0x00000040      /* 'c': File is compressed. */
55#define TFS_IPMOD       0x00000080      /* 'i': File is in-place modifiable. */
56#define TFS_UNREAD      0x00000100      /* 'u': File is not even readable if the */
57                                                                /*              user-level requirement is not met; */
58                                                                /*              else, it is read-only. */
59#define TFS_ULVLMSK     0x00000600      /*      User level mask defines 4 access levels: */
60#define TFS_ULVL0       0x00000000      /* '0'  level 0 */
61#define TFS_ULVL1       0x00000200      /* '1'  level 1 */
62#define TFS_ULVL2       0x00000400      /* '2'  level 2 */
63#define TFS_ULVL3       0x00000600      /* '3'  level 3 */
64#define TFS_NSTALE      0x00000800      /* File is NOT stale, invisible to user.
65                                                                 * When this bit is clear, the file is
66                                                                 * considered stale (see notes in tfsadd()).
67                                                                 * See notes in tfsclose() for this.
68                                                                 */
69#define TFS_ACTIVE      0x00008000      /* Used to indicate that file is not deleted. */
70
71#define TFS_ULVLMAX     TFS_ULVL3
72#define TFS_USRLVL(f)   ((f->flags & TFS_ULVLMSK) >> 9)
73
74/* Open modes */
75#define TFS_RDONLY              0x00010000      /* File is opened for reading. */
76#define TFS_CREATE              0x00020000      /* File is to be created. Error if file */
77                                                                        /* with the same name already exists. */
78#define TFS_APPEND              0x00040000      /* Append to existing file.  If OR'ed */
79                                                                        /* with TFS_CREATE, then create if */
80                                                                        /* necessary. */
81#define TFS_ALLFFS              0x00080000      /* File is created with all FFs. */
82#define TFS_CREATERM    0x00100000      /* File is to be created. If file with */
83                                                                        /* same name already exists, then allow */
84                                                                        /* tfsadd() to remove it if necessary. */
85
86/* The function tfsrunrc() will search through the current file set and */
87/* if the file defined by TFS_RCFILE exists, it will be executed. */
88/* If this file exists, it will NOT be run by tfsrunboot(). */
89#define TFS_RCFILE              "monrc"
90
91/* Requests that can be made to tfsctrl(): */
92#define TFS_ERRMSG              1
93#define TFS_MEMUSE              2
94#define TFS_MEMDEAD             3
95#define TFS_DEFRAG              4
96#define TFS_TELL                5
97#define TFS_UNOPEN              7
98#define TFS_FATOB               8
99#define TFS_FBTOA               9
100#define TFS_MEMAVAIL    10
101#define TFS_TIMEFUNCS   11
102#define TFS_DOCOMMAND   12
103#define TFS_INITDEV             13
104#define TFS_CHECKDEV    14
105#define TFS_DEFRAGDEV   15
106#define TFS_DEFRAGOFF   16
107#define TFS_DEFRAGON    17
108#define TFS_HEADROOM    18
109#define TFS_FCOUNT              19
110
111/* struct tfshdr:
112 *      It is in FLASH as part of the file system to record the attributes of
113 *      the file at the time of creation.
114 */
115struct tfshdr {
116        unsigned short  hdrsize;                /* Size of this header.                                 */
117        unsigned short  hdrvrsn;                /* Header version #.                                    */
118        long    filsize;                                /* Size of the file.                                    */
119        long    flags;                                  /* Flags describing the file.                   */
120        unsigned long filcrc;                   /* 32 bit CRC of file.                                  */
121        unsigned long hdrcrc;                   /* 32 bit CRC of the header.                    */
122        unsigned long   modtime;                /* Time when file was last modified.    */
123        struct  tfshdr  *next;                  /* Pointer to next file in list.                */
124        char    name[TFSNAMESIZE+1];    /* Name of file.                                                */
125        char    info[TFSINFOSIZE+1];    /* Miscellaneous info field.                    */
126#if TFS_RESERVED
127        unsigned long   rsvd[TFS_RESERVED];
128#endif
129};
130
131#define TFSHDRSIZ       sizeof(struct tfshdr)
132
133/* TFS error returns. */
134#define TFS_OKAY                                0
135#define TFSERR_NOFILE                   -1
136#define TFSERR_NOSLOT                   -2
137#define TFSERR_EOF                              -3
138#define TFSERR_BADARG                   -4
139#define TFSERR_NOTEXEC                  -5
140#define TFSERR_BADCRC                   -6
141#define TFSERR_FILEEXISTS               -7
142#define TFSERR_FLASHFAILURE             -8
143#define TFSERR_WRITEMAX                 -9
144#define TFSERR_RDONLY                   -10
145#define TFSERR_BADFD                    -11
146#define TFSERR_BADHDR                   -12
147#define TFSERR_CORRUPT                  -13
148#define TFSERR_MEMFAIL                  -14
149#define TFSERR_NOTIPMOD                 -16
150#define TFSERR_MUTEXFAILURE             -17
151#define TFSERR_FLASHFULL                -18
152#define TFSERR_USERDENIED               -19
153#define TFSERR_NAMETOOBIG               -20
154#define TFSERR_FILEINUSE                -21
155#define TFSERR_NOTCPRS                  -22
156#define TFSERR_NOTAVAILABLE             -23
157#define TFSERR_BADFLAG                  -24
158#define TFSERR_CLEANOFF                 -25
159#define TFSERR_FLAKEYSOURCE             -26
160#define TFSERR_BADEXTENSION             -27
161#define TFSERR_MIN                              -100
162
163/* TFS seek options. */
164#define TFS_BEGIN               1
165#define TFS_CURRENT             2
166#define TFS_END                 3
167
168/* Macros: */
169#define TFS_DELETED(fp)         (!((fp)->flags & TFS_ACTIVE))
170#define TFS_FILEEXISTS(fp)      ((fp)->flags & TFS_ACTIVE)
171#define TFS_ISCPRS(fp)          ((fp)->flags & TFS_CPRS)
172#define TFS_ISEXEC(fp)          ((fp)->flags & TFS_EXEC)
173#define TFS_ISBOOT(fp)          ((fp)->flags & TFS_BRUN)
174#define TFS_ISLINK(fp)          ((fp)->flags & TFS_SYMLINK)
175#define TFS_STALE(fp)           (!((fp)->flags & TFS_NSTALE))
176#define TFS_FLAGS(fp)           ((fp)->flags)
177#define TFS_NAME(fp)            ((fp)->name)
178#define TFS_SIZE(fp)            ((fp)->filsize)
179#define TFS_TIME(fp)            ((fp)->modtime)
180#define TFS_INFO(fp)            ((fp)->info)
181#define TFS_NEXT(fp)            ((fp)->next)
182#define TFS_CRC(fp)                     ((fp)->filcrc)
183#define TFS_ENTRY(fp)           ((fp)->entry)
184#define TFS_BASE(fp)            ((char *)(fp)+(fp)->hdrsize)
185
186typedef struct tfshdr TFILE;
187#endif
Note: See TracBrowser for help on using the repository browser.