blob: 8120864f1c51e0355cb8b20fde8e6e53c2cc40e2 [file] [log] [blame]
Jason Samse4a06c52011-03-16 16:29:28 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#include "rsdCore.h"
19#include "rsdBcc.h"
Jason Samsfcf72312011-04-20 15:09:01 -070020#include "rsdRuntime.h"
Jason Samse4a06c52011-03-16 16:29:28 -070021
22#include "rsContext.h"
23#include "rsScriptC.h"
24
25#include "utils/Timers.h"
26#include "utils/StopWatch.h"
27extern "C" {
28#include "libdex/ZipArchive.h"
29}
30
31
32using namespace android;
33using namespace android::renderscript;
34
35struct DrvScript {
36 int (*mRoot)();
37 void (*mInit)();
38
39 BCCScriptRef mBccScript;
40
41 uint32_t mInvokeFunctionCount;
42 InvokeFunc_t *mInvokeFunctions;
43 uint32_t mFieldCount;
44 void ** mFieldAddress;
45 bool * mFieldIsObject;
46
47 const uint8_t * mScriptText;
48 uint32_t mScriptTextLength;
49
50 //uint32_t * mObjectSlots;
51 //uint32_t mObjectSlotCount;
52
53 uint32_t mPragmaCount;
54 const char ** mPragmaKeys;
55 const char ** mPragmaValues;
56
57};
58
Jason Samsbe8ac6a2011-04-21 11:46:50 -070059
Jason Sams55d2a252011-03-17 16:12:47 -070060static Script * setTLS(Script *sc) {
Jason Samsbe8ac6a2011-04-21 11:46:50 -070061 ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey);
Jason Sams55d2a252011-03-17 16:12:47 -070062 rsAssert(tls);
63 Script *old = tls->mScript;
64 tls->mScript = sc;
65 return old;
66}
67
68
Jason Samse4a06c52011-03-16 16:29:28 -070069// Input: cacheDir
70// Input: resName
71// Input: extName
72//
73// Note: cacheFile = resName + extName
74//
75// Output: Returns cachePath == cacheDir + cacheFile
76static char *genCacheFileName(const char *cacheDir,
77 const char *resName,
78 const char *extName) {
79 char cachePath[512];
80 char cacheFile[sizeof(cachePath)];
81 const size_t kBufLen = sizeof(cachePath) - 1;
82
83 cacheFile[0] = '\0';
84 // Note: resName today is usually something like
85 // "/com.android.fountain:raw/fountain"
86 if (resName[0] != '/') {
87 // Get the absolute path of the raw/***.bc file.
88
89 // Generate the absolute path. This doesn't do everything it
90 // should, e.g. if resName is "./out/whatever" it doesn't crunch
91 // the leading "./" out because this if-block is not triggered,
92 // but it'll make do.
93 //
94 if (getcwd(cacheFile, kBufLen) == NULL) {
95 LOGE("Can't get CWD while opening raw/***.bc file\n");
96 return NULL;
97 }
98 // Append "/" at the end of cacheFile so far.
99 strncat(cacheFile, "/", kBufLen);
100 }
101
102 // cacheFile = resName + extName
103 //
104 strncat(cacheFile, resName, kBufLen);
105 if (extName != NULL) {
106 // TODO(srhines): strncat() is a bit dangerous
107 strncat(cacheFile, extName, kBufLen);
108 }
109
110 // Turn the path into a flat filename by replacing
111 // any slashes after the first one with '@' characters.
112 char *cp = cacheFile + 1;
113 while (*cp != '\0') {
114 if (*cp == '/') {
115 *cp = '@';
116 }
117 cp++;
118 }
119
120 // Tack on the file name for the actual cache file path.
121 strncpy(cachePath, cacheDir, kBufLen);
122 strncat(cachePath, cacheFile, kBufLen);
123
124 LOGV("Cache file for '%s' '%s' is '%s'\n", resName, extName, cachePath);
125 return strdup(cachePath);
126}
127
128bool rsdScriptInit(const Context *rsc,
129 ScriptC *script,
130 char const *resName,
131 char const *cacheDir,
132 uint8_t const *bitcode,
133 size_t bitcodeSize,
Jason Samsfcf72312011-04-20 15:09:01 -0700134 uint32_t flags) {
Jason Samse4a06c52011-03-16 16:29:28 -0700135 //LOGE("rsdScriptCreate %p %p %p %p %i %i %p", rsc, resName, cacheDir, bitcode, bitcodeSize, flags, lookupFunc);
136
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700137 pthread_mutex_lock(&rsdgInitMutex);
Jason Samse4a06c52011-03-16 16:29:28 -0700138 char *cachePath = NULL;
139 uint32_t objectSlotCount = 0;
140
141 DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
142 if (drv == NULL) {
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700143 goto error;
Jason Samse4a06c52011-03-16 16:29:28 -0700144 }
145 script->mHal.drv = drv;
146
147 drv->mBccScript = bccCreateScript();
148 script->mHal.info.isThreadable = true;
149 drv->mScriptText = bitcode;
150 drv->mScriptTextLength = bitcodeSize;
151
152 //LOGE("mBccScript %p", script->mBccScript);
153
Jason Samsfcf72312011-04-20 15:09:01 -0700154 if (bccRegisterSymbolCallback(drv->mBccScript, &rsdLookupRuntimeStub, script) != 0) {
Jason Samse4a06c52011-03-16 16:29:28 -0700155 LOGE("bcc: FAILS to register symbol callback");
156 goto error;
157 }
158
159 if (bccReadBC(drv->mBccScript,
160 resName,
161 (char const *)drv->mScriptText,
162 drv->mScriptTextLength, 0) != 0) {
163 LOGE("bcc: FAILS to read bitcode");
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700164 goto error;
Jason Samse4a06c52011-03-16 16:29:28 -0700165 }
166
167#if 1
168 if (bccLinkFile(drv->mBccScript, "/system/lib/libclcore.bc", 0) != 0) {
169 LOGE("bcc: FAILS to link bitcode");
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700170 goto error;
Jason Samse4a06c52011-03-16 16:29:28 -0700171 }
172#endif
173 cachePath = genCacheFileName(cacheDir, resName, ".oBCC");
174
175 if (bccPrepareExecutable(drv->mBccScript, cachePath, 0) != 0) {
176 LOGE("bcc: FAILS to prepare executable");
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700177 goto error;
Jason Samse4a06c52011-03-16 16:29:28 -0700178 }
179
180 free(cachePath);
181
182 drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root"));
183 drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init"));
184
185 drv->mInvokeFunctionCount = bccGetExportFuncCount(drv->mBccScript);
186 if (drv->mInvokeFunctionCount <= 0)
187 drv->mInvokeFunctions = NULL;
188 else {
189 drv->mInvokeFunctions = (InvokeFunc_t*) calloc(drv->mInvokeFunctionCount, sizeof(InvokeFunc_t));
190 bccGetExportFuncList(drv->mBccScript, drv->mInvokeFunctionCount, (void **) drv->mInvokeFunctions);
191 }
192
193 drv->mFieldCount = bccGetExportVarCount(drv->mBccScript);
194 if (drv->mFieldCount <= 0) {
195 drv->mFieldAddress = NULL;
196 drv->mFieldIsObject = NULL;
197 } else {
198 drv->mFieldAddress = (void **) calloc(drv->mFieldCount, sizeof(void *));
199 drv->mFieldIsObject = (bool *) calloc(drv->mFieldCount, sizeof(bool));
200 bccGetExportVarList(drv->mBccScript, drv->mFieldCount, (void **) drv->mFieldAddress);
201 }
202
203 objectSlotCount = bccGetObjectSlotCount(drv->mBccScript);
204 if (objectSlotCount) {
205 uint32_t * slots = new uint32_t[objectSlotCount];
206 bccGetObjectSlotList(drv->mBccScript, objectSlotCount, slots);
207 for (uint32_t ct=0; ct < objectSlotCount; ct++) {
208 drv->mFieldIsObject[slots[ct]] = true;
209 }
210 delete [] slots;
211 }
212
213 uint32_t mPragmaCount;
214 const char ** mPragmaKeys;
215 const char ** mPragmaValues;
216
217 const static int pragmaMax = 16;
218 drv->mPragmaCount = bccGetPragmaCount(drv->mBccScript);
219 if (drv->mPragmaCount <= 0) {
220 drv->mPragmaKeys = NULL;
221 drv->mPragmaValues = NULL;
222 } else {
223 drv->mPragmaKeys = (const char **) calloc(drv->mFieldCount, sizeof(const char *));
224 drv->mPragmaValues = (const char **) calloc(drv->mFieldCount, sizeof(const char *));
225 bccGetPragmaList(drv->mBccScript, drv->mPragmaCount, drv->mPragmaKeys, drv->mPragmaValues);
226 }
227
228
229
230 // Copy info over to runtime
231 script->mHal.info.exportedFunctionCount = drv->mInvokeFunctionCount;
232 script->mHal.info.exportedVariableCount = drv->mFieldCount;
233 script->mHal.info.exportedPragmaCount = drv->mPragmaCount;
234 script->mHal.info.exportedPragmaKeyList = drv->mPragmaKeys;
235 script->mHal.info.exportedPragmaValueList = drv->mPragmaValues;
236 script->mHal.info.root = drv->mRoot;
237
238
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700239 pthread_mutex_unlock(&rsdgInitMutex);
Jason Samse4a06c52011-03-16 16:29:28 -0700240 return true;
241
242error:
243
Jason Samsbe8ac6a2011-04-21 11:46:50 -0700244 pthread_mutex_unlock(&rsdgInitMutex);
Jason Samse4a06c52011-03-16 16:29:28 -0700245 free(drv);
246 return false;
247
248}
249
Jason Sams55d2a252011-03-17 16:12:47 -0700250typedef struct {
251 Context *rsc;
252 Script *script;
253 const Allocation * ain;
254 Allocation * aout;
255 const void * usr;
Jason Samse4a06c52011-03-16 16:29:28 -0700256
Jason Sams55d2a252011-03-17 16:12:47 -0700257 uint32_t mSliceSize;
258 volatile int mSliceNum;
259
260 const uint8_t *ptrIn;
261 uint32_t eStrideIn;
262 uint8_t *ptrOut;
263 uint32_t eStrideOut;
264
265 uint32_t xStart;
266 uint32_t xEnd;
267 uint32_t yStart;
268 uint32_t yEnd;
269 uint32_t zStart;
270 uint32_t zEnd;
271 uint32_t arrayStart;
272 uint32_t arrayEnd;
273
274 uint32_t dimX;
275 uint32_t dimY;
276 uint32_t dimZ;
277 uint32_t dimArray;
278} MTLaunchStruct;
279typedef int (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
280
281static void wc_xy(void *usr, uint32_t idx) {
282 MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
283
284 while (1) {
285 uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
286 uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize;
287 uint32_t yEnd = yStart + mtls->mSliceSize;
288 yEnd = rsMin(yEnd, mtls->yEnd);
289 if (yEnd <= yStart) {
290 return;
291 }
292
293 //LOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd);
294 //LOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut);
295 for (uint32_t y = yStart; y < yEnd; y++) {
296 uint32_t offset = mtls->dimX * y;
297 uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * offset);
298 const uint8_t *xPtrIn = mtls->ptrIn + (mtls->eStrideIn * offset);
299
300 for (uint32_t x = mtls->xStart; x < mtls->xEnd; x++) {
301 ((rs_t)mtls->script->mHal.info.root) (xPtrIn, xPtrOut, mtls->usr, x, y, 0, 0);
302 xPtrIn += mtls->eStrideIn;
303 xPtrOut += mtls->eStrideOut;
304 }
305 }
306 }
Jason Samse4a06c52011-03-16 16:29:28 -0700307}
308
Jason Sams55d2a252011-03-17 16:12:47 -0700309static void wc_x(void *usr, uint32_t idx) {
310 MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
311
312 while (1) {
313 uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
314 uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize;
315 uint32_t xEnd = xStart + mtls->mSliceSize;
316 xEnd = rsMin(xEnd, mtls->xEnd);
317 if (xEnd <= xStart) {
318 return;
319 }
320
321 //LOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd);
322 //LOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut);
323 uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * xStart);
324 const uint8_t *xPtrIn = mtls->ptrIn + (mtls->eStrideIn * xStart);
325 for (uint32_t x = xStart; x < xEnd; x++) {
326 ((rs_t)mtls->script->mHal.info.root) (xPtrIn, xPtrOut, mtls->usr, x, 0, 0, 0);
327 xPtrIn += mtls->eStrideIn;
328 xPtrOut += mtls->eStrideOut;
329 }
330 }
331}
332
333void rsdScriptInvokeForEach(const Context *rsc,
334 Script *s,
335 const Allocation * ain,
336 Allocation * aout,
337 const void * usr,
338 uint32_t usrLen,
339 const RsScriptCall *sc) {
340
Jason Samsfcf72312011-04-20 15:09:01 -0700341 RsdHal * dc = (RsdHal *)rsc->mHal.drv;
Jason Sams55d2a252011-03-17 16:12:47 -0700342
343 MTLaunchStruct mtls;
344 memset(&mtls, 0, sizeof(mtls));
345
346 if (ain) {
347 mtls.dimX = ain->getType()->getDimX();
348 mtls.dimY = ain->getType()->getDimY();
349 mtls.dimZ = ain->getType()->getDimZ();
350 //mtls.dimArray = ain->getType()->getDimArray();
351 } else if (aout) {
352 mtls.dimX = aout->getType()->getDimX();
353 mtls.dimY = aout->getType()->getDimY();
354 mtls.dimZ = aout->getType()->getDimZ();
355 //mtls.dimArray = aout->getType()->getDimArray();
356 } else {
357 rsc->setError(RS_ERROR_BAD_SCRIPT, "rsForEach called with null allocations");
358 return;
359 }
360
361 if (!sc || (sc->xEnd == 0)) {
362 mtls.xEnd = mtls.dimX;
363 } else {
364 rsAssert(sc->xStart < mtls.dimX);
365 rsAssert(sc->xEnd <= mtls.dimX);
366 rsAssert(sc->xStart < sc->xEnd);
367 mtls.xStart = rsMin(mtls.dimX, sc->xStart);
368 mtls.xEnd = rsMin(mtls.dimX, sc->xEnd);
369 if (mtls.xStart >= mtls.xEnd) return;
370 }
371
372 if (!sc || (sc->yEnd == 0)) {
373 mtls.yEnd = mtls.dimY;
374 } else {
375 rsAssert(sc->yStart < mtls.dimY);
376 rsAssert(sc->yEnd <= mtls.dimY);
377 rsAssert(sc->yStart < sc->yEnd);
378 mtls.yStart = rsMin(mtls.dimY, sc->yStart);
379 mtls.yEnd = rsMin(mtls.dimY, sc->yEnd);
380 if (mtls.yStart >= mtls.yEnd) return;
381 }
382
383 mtls.xEnd = rsMax((uint32_t)1, mtls.xEnd);
384 mtls.yEnd = rsMax((uint32_t)1, mtls.yEnd);
385 mtls.zEnd = rsMax((uint32_t)1, mtls.zEnd);
386 mtls.arrayEnd = rsMax((uint32_t)1, mtls.arrayEnd);
387
Stephen Hines97837c92011-04-11 14:02:22 -0700388 rsAssert(!ain || (ain->getType()->getDimZ() == 0));
Jason Sams55d2a252011-03-17 16:12:47 -0700389
390 Context *mrsc = (Context *)rsc;
391 Script * oldTLS = setTLS(s);
392
393 mtls.rsc = mrsc;
394 mtls.ain = ain;
395 mtls.aout = aout;
396 mtls.script = s;
397 mtls.usr = usr;
398 mtls.mSliceSize = 10;
399 mtls.mSliceNum = 0;
400
401 mtls.ptrIn = NULL;
402 mtls.eStrideIn = 0;
403 if (ain) {
404 mtls.ptrIn = (const uint8_t *)ain->getPtr();
405 mtls.eStrideIn = ain->getType()->getElementSizeBytes();
406 }
407
408 mtls.ptrOut = NULL;
409 mtls.eStrideOut = 0;
410 if (aout) {
411 mtls.ptrOut = (uint8_t *)aout->getPtr();
412 mtls.eStrideOut = aout->getType()->getElementSizeBytes();
413 }
414
415 if ((dc->mWorkers.mCount > 1) && s->mHal.info.isThreadable) {
416 if (mtls.dimY > 1) {
417 rsdLaunchThreads(mrsc, wc_xy, &mtls);
418 } else {
419 rsdLaunchThreads(mrsc, wc_x, &mtls);
420 }
421
422 //LOGE("launch 1");
423 } else {
424 //LOGE("launch 3");
425 for (uint32_t ar = mtls.arrayStart; ar < mtls.arrayEnd; ar++) {
426 for (uint32_t z = mtls.zStart; z < mtls.zEnd; z++) {
427 for (uint32_t y = mtls.yStart; y < mtls.yEnd; y++) {
428 uint32_t offset = mtls.dimX * mtls.dimY * mtls.dimZ * ar +
429 mtls.dimX * mtls.dimY * z +
430 mtls.dimX * y;
431 uint8_t *xPtrOut = mtls.ptrOut + (mtls.eStrideOut * offset);
432 const uint8_t *xPtrIn = mtls.ptrIn + (mtls.eStrideIn * offset);
433
434 for (uint32_t x = mtls.xStart; x < mtls.xEnd; x++) {
435 ((rs_t)s->mHal.info.root) (xPtrIn, xPtrOut, usr, x, y, z, ar);
436 xPtrIn += mtls.eStrideIn;
437 xPtrOut += mtls.eStrideOut;
438 }
439 }
440 }
441 }
442 }
443
444 setTLS(oldTLS);
445}
446
447
448int rsdScriptInvokeRoot(const Context *dc, Script *script) {
449 DrvScript *drv = (DrvScript *)script->mHal.drv;
450
451 Script * oldTLS = setTLS(script);
452 int ret = drv->mRoot();
453 setTLS(oldTLS);
454
455 return ret;
456}
457
458void rsdScriptInvokeInit(const Context *dc, Script *script) {
Jason Samse4a06c52011-03-16 16:29:28 -0700459 DrvScript *drv = (DrvScript *)script->mHal.drv;
460
461 if (drv->mInit) {
462 drv->mInit();
463 }
464}
465
466
Jason Sams55d2a252011-03-17 16:12:47 -0700467void rsdScriptInvokeFunction(const Context *dc, Script *script,
Jason Samse4a06c52011-03-16 16:29:28 -0700468 uint32_t slot,
469 const void *params,
470 size_t paramLength) {
471 DrvScript *drv = (DrvScript *)script->mHal.drv;
472 //LOGE("invoke %p %p %i %p %i", dc, script, slot, params, paramLength);
473
Jason Sams55d2a252011-03-17 16:12:47 -0700474 Script * oldTLS = setTLS(script);
Jason Samse4a06c52011-03-16 16:29:28 -0700475 ((void (*)(const void *, uint32_t))
476 drv->mInvokeFunctions[slot])(params, paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -0700477 setTLS(oldTLS);
Jason Samse4a06c52011-03-16 16:29:28 -0700478}
479
480void rsdScriptSetGlobalVar(const Context *dc, const Script *script,
481 uint32_t slot, void *data, size_t dataLength) {
482 DrvScript *drv = (DrvScript *)script->mHal.drv;
483 //rsAssert(!script->mFieldIsObject[slot]);
484 //LOGE("setGlobalVar %p %p %i %p %i", dc, script, slot, data, dataLength);
485
486 int32_t *destPtr = ((int32_t **)drv->mFieldAddress)[slot];
487 if (!destPtr) {
488 //LOGV("Calling setVar on slot = %i which is null", slot);
489 return;
490 }
491
492 memcpy(destPtr, data, dataLength);
493}
494
495void rsdScriptSetGlobalBind(const Context *dc, const Script *script, uint32_t slot, void *data) {
496 DrvScript *drv = (DrvScript *)script->mHal.drv;
497 //rsAssert(!script->mFieldIsObject[slot]);
498 //LOGE("setGlobalBind %p %p %i %p", dc, script, slot, data);
499
500 int32_t *destPtr = ((int32_t **)drv->mFieldAddress)[slot];
501 if (!destPtr) {
502 //LOGV("Calling setVar on slot = %i which is null", slot);
503 return;
504 }
505
506 memcpy(destPtr, &data, sizeof(void *));
507}
508
509void rsdScriptSetGlobalObj(const Context *dc, const Script *script, uint32_t slot, ObjectBase *data) {
510 DrvScript *drv = (DrvScript *)script->mHal.drv;
511 //rsAssert(script->mFieldIsObject[slot]);
512 //LOGE("setGlobalObj %p %p %i %p", dc, script, slot, data);
513
514 int32_t *destPtr = ((int32_t **)drv->mFieldAddress)[slot];
515 if (!destPtr) {
516 //LOGV("Calling setVar on slot = %i which is null", slot);
517 return;
518 }
519
Jason Samsfcf72312011-04-20 15:09:01 -0700520 rsrSetObject(dc, script, (ObjectBase **)destPtr, data);
Jason Samse4a06c52011-03-16 16:29:28 -0700521}
522
523void rsdScriptDestroy(const Context *dc, Script *script) {
524 DrvScript *drv = (DrvScript *)script->mHal.drv;
525
526 if (drv->mFieldAddress) {
527 for (size_t ct=0; ct < drv->mFieldCount; ct++) {
528 if (drv->mFieldIsObject[ct]) {
Stephen Hines623cb952011-03-24 20:03:49 -0700529 // The field address can be NULL if the script-side has
530 // optimized the corresponding global variable away.
531 if (drv->mFieldAddress[ct]) {
Jason Samsfcf72312011-04-20 15:09:01 -0700532 rsrClearObject(dc, script, (ObjectBase **)drv->mFieldAddress[ct]);
Stephen Hines623cb952011-03-24 20:03:49 -0700533 }
Jason Samse4a06c52011-03-16 16:29:28 -0700534 }
535 }
536 delete [] drv->mFieldAddress;
537 delete [] drv->mFieldIsObject;
538 drv->mFieldAddress = NULL;
539 drv->mFieldIsObject = NULL;
540 drv->mFieldCount = 0;
541 }
542
543 if (drv->mInvokeFunctions) {
544 delete [] drv->mInvokeFunctions;
545 drv->mInvokeFunctions = NULL;
546 drv->mInvokeFunctionCount = 0;
547 }
548 free(drv);
549 script->mHal.drv = NULL;
550
551}
552
553