comparison src/aci2/aci/db_int.h @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : PHB
4 | Modul : DBM
5 +-----------------------------------------------------------------------------
6 | Copyright 2005 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : Internal declarations for DBM module
18 +-----------------------------------------------------------------------------
19 */
20 #ifndef DB_INT_H
21 #define DB_INT_H
22
23 #include "db.h"
24
25 /* This macro allows us to close the file before
26 returning from function */
27 #define FFS_OPEN_PROBLEM_PATCH
28
29 /* If this macro is activated, we close earlier activated file
30 before opening next file */
31 #define FFS_CLOSE_BEFORE_OPEN
32
33 /* Mutually exclusive macros */
34 #ifdef FFS_CLOSE_BEFORE_OPEN
35 #undef FFS_OPEN_PROBLEM_PATCH
36 #endif
37
38 #ifdef FFS_CLOSE_BEFORE_OPEN
39
40 #define MAX_OPEN_READ_PER_DB 2
41 #define MAX_OPEN_WRITE_PER_DB 1
42
43 #endif
44
45 #ifdef _SIMULATION_
46 #include "ffs_pc_api.h"
47 #else
48 #include "ffs/ffs.h"
49 #endif
50
51 #include "vsi.h"
52 #include "aci_mem.h"
53
54 #define RECORD_BITMAP_SIZE 32 /* Based on MAX_NUM_RECORDS
55 RECORD_BITMAP_SIZE = MAX_NUM_RECORDS/8*/
56 #define MAX_LEN_DIRECTORY 16 /* Assumed to be max 16 characters */
57
58
59 /*
60 DBM state
61 */
62 typedef enum
63 {
64
65 DBM_NOT_INITIALISED = 0,
66 DBM_INITIALISED
67
68 } T_DBM_STATE;
69
70 /*
71 Database state
72 */
73 typedef enum
74 {
75
76 CLOSED = 0,
77 OPEN,
78 IN_USE,
79 UNUSED_ENTRY = 0xFF
80
81 } T_DB_STATE;
82
83 #ifdef FFS_CLOSE_BEFORE_OPEN
84
85 typedef struct
86 {
87
88 UBYTE fld_ctr;
89 T_FFS_FD filehandle;
90
91 } FileHandleRecord;
92
93 #endif
94
95 /*
96 Field record
97 */
98 typedef struct
99 {
100
101 USHORT FieldID; /* Elementary file identifier */
102 T_DB_TYPE DBType; /* database type (UNMANAGED, FREELIST) */
103 USHORT RecordSize; /* Size of data in data base record */
104 UBYTE NumOfRecords; /* Number of records */
105 UBYTE UsedRecords; /* Number of used records */
106 UBYTE RecordBitMap [RECORD_BITMAP_SIZE]; /* Bitmap representing whether record is present or not */
107 UBYTE Clean; /* File consistency: 0x01 => Clean, 0x00 => Not Clean */
108 UBYTE SortIndexList [MAX_NUM_OF_SORT_INDEXS]; /* Number of associated index files */
109 UBYTE* SortedLists [MAX_NUM_OF_SORT_INDEXS]; /* Sorted lists */
110
111 #ifndef FFS_CLOSE_BEFORE_OPEN
112 T_FFS_FD FFSFileHandle; /* FFS File Handle for User file */
113 #endif
114
115 UBYTE NextRecordNum; /* To take care of non-seqential write */
116
117 } T_DBM_FIELDRECORD;
118
119
120 typedef struct
121 {
122
123 UBYTE DBDirectory[MAX_LEN_DIRECTORY]; /* Directory path */
124 UBYTE NumOfFiles; /* Maximum files in that database */
125 UBYTE UsedFiles; /* Number of used files */
126 UBYTE Tracked_Clean; /* Tracked: History log to be maintained or not
127 Clean: Database is consistent or not */
128 T_DB_STATE DBState; /* Database state */
129
130 T_FFS_FD FFSFileHandle; /* FFS File Handle for DD_<db_handle> */
131
132 #ifdef FFS_CLOSE_BEFORE_OPEN
133 FileHandleRecord READ_OPEN_FIELDS [MAX_OPEN_READ_PER_DB]; /* fields opened for read only */
134 FileHandleRecord WRITE_OPEN_FIELDS [MAX_OPEN_WRITE_PER_DB]; /* fields opened for read/write both */
135 UBYTE old_read; /* remeber oldest open */
136 UBYTE old_write; /* remeber oldest read */
137 #endif
138
139 T_DBM_FIELDRECORD* ptrFieldRecord; /* pointer to fields */
140
141 } T_DBM_MASTERRECORD;
142
143
144 /*
145 Which sort ?
146 */
147 typedef enum
148 {
149
150 QUICK_SORT = 0,
151
152 #ifdef INSERTION_SORT
153 INCREMENTAL_SORT
154 #endif
155
156 } T_DB_SORT;
157
158 #endif
159