Lines Matching refs:bufUsed

229 static int finalizeAndWrite(uint8_t *buf, uint32_t bufUsed, uint32_t bufSz, FILE *out, uint32_t lay…  in finalizeAndWrite()  argument
257 assertMem(bufUsed + hdrDiff, bufSz); in finalizeAndWrite()
259 memmove(buf + dataOffset, buf + sizeof(*bin), bufUsed - sizeof(*bin)); in finalizeAndWrite()
260 bufUsed += hdrDiff; in finalizeAndWrite()
266 if (bufUsed) { in finalizeAndWrite()
272 fprintf(stderr,"Final binary size %" PRIu32 " bytes\n", bufUsed); in finalizeAndWrite()
284 ret = fwrite(buf, bufUsed, 1, out) == 1 ? 0 : 2; in finalizeAndWrite()
291 static int handleApp(uint8_t **pbuf, uint32_t bufUsed, FILE *out, uint32_t layoutFlags, uint64_t ap… in handleApp() argument
303 uint32_t bufSz = bufUsed * 3 /2; in handleApp()
311 if (bufUsed < sizeof(*bin)) { in handleApp()
330 numSyms = (bufUsed + FLASH_BASE - sect->rel_end) / sizeof(struct SymtabEntry); in handleApp()
337 if (numSyms * sizeof(struct SymtabEntry) + sect->rel_end != bufUsed + FLASH_BASE) { in handleApp()
343 fprintf(stderr, "\nRead %" PRIu32 " bytes of binary.\n", bufUsed); in handleApp()
501 bufUsed -= sizeof(struct RelocEntry[numRelocs]); in handleApp()
502 bufUsed -= sizeof(struct SymtabEntry[numSyms]); in handleApp()
503 bufUsed += packedNanoRelocSz; in handleApp()
504 assertMem(bufUsed, bufSz); in handleApp()
508 if (sect->rel_end - FLASH_BASE != bufUsed) { in handleApp()
535 ret = finalizeAndWrite(buf, bufUsed, bufSz, out, layoutFlags, appId, chreApi); in handleApp()
834 static int handleKey(uint8_t **pbuf, uint32_t bufUsed, FILE *out, uint32_t layoutFlags, uint64_t ap… in handleKey() argument
856 good = good && fwrite(buf, bufUsed, 1, out) == 1; in handleKey()
861 static int handleOs(uint8_t **pbuf, uint32_t bufUsed, FILE *out, uint32_t layoutFlags, bool bare) in handleOs() argument
869 .size = bufUsed in handleOs()
889 good = good && fwrite(buf, bufUsed, 1, out) == 1; in handleOs()
896 uint32_t bufUsed = 0; in main() local
995 buf = loadFile(posArg[0], &bufUsed); in main()
996 fprintf(stderr, "Read %" PRIu32 " bytes\n", bufUsed); in main()
1011 ret = handleApp(&buf, bufUsed, out, layoutFlags, appId, appVer, chreApi, verbose); in main()
1015 ret = handleKey(&buf, bufUsed, out, layoutFlags, appId, keyId); in main()
1018 ret = handleOs(&buf, bufUsed, out, layoutFlags, bareData); in main()