Subversion Repositories Games.Carmageddon

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 pmbaty 1
#include "fwsetup.h"
2
 
3
#include "CORE/FW/brlists.h"
4
#include "CORE/FW/file.h"
5
#include "CORE/FW/image.h"
6
#include "CORE/FW/object.h"
7
#include "CORE/FW/register.h"
8
#include "CORE/FW/resource.h"
9
#include "CORE/FW/resreg.h"
10
#include "CORE/FW/sys_conf.h"
11
#include "CORE/FW/token.h"
12
#include "CORE/STD/brstddiag.h"
13
#include "CORE/STD/brstdfile.h"
14
#include "CORE/STD/brstdlib.h"
15
#include "CORE/STD/brstdmem.h"
16
#include "harness/trace.h"
17
#include <stddef.h>
18
#include <stdio.h>
19
 
20
br_framework_state fw;
21
void* functionPointers_BRCORE1[185];
22
char* namePointers_BRCORE1[185];
23
br_resource_class fw_resourceClasses[25] = {
24
    { 0u, "REGISTRY", BR_MEMORY_REGISTRY, NULL, 0u },
25
    { 0u, "ANCHOR", BR_MEMORY_ANCHOR, NULL, 0u },
26
    { 0u, "RESOURCE_CLASS", BR_MEMORY_RESOURCE_CLASS, NULL, 0u },
27
    { 0u, "SCRATCH,", BR_MEMORY_SCRATCH, NULL, 16u },
28
    { 0u, "STRING", BR_MEMORY_STRING, NULL, 1u },
29
    { 0u, "FILE", BR_MEMORY_FILE, &_BrFileFree, 0u },
30
    { 0u, "POOL", BR_MEMORY_POOL, NULL, 16u },
31
    { 0u, "EXCEPTION_HANDLER", BR_MEMORY_EXCEPTION_HANDLER, NULL, 0u },
32
    { 0u, "TOKEN", BR_MEMORY_TOKEN, NULL, 0u },
33
    { 0u, "TOKEN_MAP", BR_MEMORY_TOKEN_MAP, NULL, 8u },
34
    { 0u, "DATAFILE", BR_MEMORY_DATAFILE, NULL, 0u },
35
    { 0u, "LEXER", BR_MEMORY_LEXER, NULL, 0u },
36
    { 0u, "OBJECT_LIST", BR_MEMORY_OBJECT_LIST, NULL, 0u },
37
    { 0u, "OBJECT_LIST_ENTRY", BR_MEMORY_OBJECT_LIST_ENTRY, NULL, 0u },
38
    { 0u, "APPLICATION", BR_MEMORY_APPLICATION, NULL, 0u },
39
    { 0u, "IMAGE", BR_MEMORY_IMAGE, &_BrImageFree, 0u },
40
    { 0u, "IMAGE_ARENA", BR_MEMORY_IMAGE_ARENA, NULL, 0u },
41
    { 0u, "IMAGE_SECTIONS", BR_MEMORY_IMAGE_SECTIONS, NULL, 0u },
42
    { 0u, "IMAGE_NAMES", BR_MEMORY_IMAGE_NAMES, NULL, 0u },
43
    { 0u, "OBJECT", BR_MEMORY_OBJECT, &_BrObjectFree, 16u },
44
    { 0u, "OBJECT_DATA", BR_MEMORY_OBJECT_DATA, NULL, 16u },
45
    { 0u, "DRIVER", BR_MEMORY_DRIVER, NULL, 0u },
46
    { 0u, "FMT_RESULTS", BR_MEMORY_FMT_RESULTS, NULL, 0u },
47
    { 0u, "TOKEN_VALUE", BR_MEMORY_TOKEN_VALUE, NULL, 0u },
48
    { 0u, "TOKEN_TEMPLATE", BR_MEMORY_TOKEN_TEMPLATE, NULL, 0u }
49
};
50
 
51
br_uint_16 nameOrdinals_BRCORE1[185];
52
 
53
br_image Image_BRCORE1 = {
54
    { 0 },
55
    "BRCORE1",
56
    2,
57
    0,
58
    1,
59
    185,
60
    functionPointers_BRCORE1,
61
    185,
62
    namePointers_BRCORE1,
63
    nameOrdinals_BRCORE1,
64
    0,
65
    NULL,
66
    0,
67
    NULL,
68
    NULL
69
};
70
 
71
#define NBR_DEV_SLOTS 16
72
 
73
// IDA: br_error __cdecl BrFwBegin()
74
br_error BrFwBegin(void) {
75
    int i;
76
 
77
    if (fw.active) {
78
        return 4103;
79
    }
80
 
81
    if (fw.diag == NULL)
82
        fw.diag = _BrDefaultDiagHandler;
83
    if (fw.fsys == NULL)
84
        fw.fsys = _BrDefaultFilesystem;
85
    if (fw.mem == NULL)
86
        fw.mem = _BrDefaultAllocator;
87
    fw.open_mode = 0;
88
    BrRegistryNew(&fw.reg_resource_classes);
89
 
90
    fw.resource_class_index[BR_MEMORY_REGISTRY] = &fw_resourceClasses[0];
91
    fw.resource_class_index[BR_MEMORY_ANCHOR] = &fw_resourceClasses[1];
92
    fw.res = BrResAllocate(NULL, 0, BR_MEMORY_ANCHOR);
93
    for (i = 0; i < BR_ASIZE(fw_resourceClasses); i++) {
94
        BrResClassAdd(&fw_resourceClasses[i]);
95
    }
96
    BrNewList(&fw.images);
97
    fw.dev_slots = (br_open_device*)BrResAllocate(fw.res, sizeof(br_open_device) * NBR_DEV_SLOTS, BR_MEMORY_OBJECT_DATA);
98
    fw.ndev_slots = NBR_DEV_SLOTS;
99
    fw.active = 1;
100
    BrTokenBegin();
101
    BrSystemConfigBegin();
102
    fw.bAlreadyLoadedDrivers = 0;
103
    BrImageAdd(&Image_BRCORE1);
104
 
105
    return 0;
106
}
107
 
108
// IDA: br_error __cdecl BrFwEnd()
109
br_error BrFwEnd(void) {
110
    LOG_TRACE("()");
111
 
112
    if (fw.active == 0) {
113
        return 4102;
114
    }
115
    BrImageRemove(&Image_BRCORE1);
116
    BrResFree(fw.res);
117
    BrMemSet(&fw, 0, sizeof(fw));
118
    return 0;
119
}
120
 
121
// IDA: br_diaghandler* __cdecl BrDiagHandlerSet(br_diaghandler *newdh)
122
br_diaghandler* BrDiagHandlerSet(br_diaghandler* newdh) {
123
    br_diaghandler* old;
124
    LOG_TRACE("(%p)", newdh);
125
 
126
    old = fw.diag;
127
    if (newdh == NULL) {
128
        newdh = _BrDefaultDiagHandler;
129
    }
130
    fw.diag = newdh;
131
    return old;
132
}
133
 
134
// IDA: br_filesystem* __cdecl BrFilesystemSet(br_filesystem *newfs)
135
br_filesystem* BrFilesystemSet(br_filesystem* newfs) {
136
    br_filesystem* old;
137
 
138
    old = fw.fsys;
139
    if (newfs == NULL) {
140
        newfs = _BrDefaultFilesystem;
141
    }
142
    fw.fsys = newfs;
143
    return old;
144
}
145
 
146
// IDA: br_allocator* __cdecl BrAllocatorSet(br_allocator *newal)
147
br_allocator* BrAllocatorSet(br_allocator* newal) {
148
    br_allocator* old;
149
    LOG_TRACE("(%p)", newal);
150
 
151
    old = fw.mem;
152
    if (newal == NULL) {
153
        newal = _BrDefaultAllocator;
154
    }
155
    fw.mem = newal;
156
 
157
    return old;
158
}