Lines Matching refs:buf

52 static void readAppName(MessageBuf &buf, hub_app_name_t &name)  in readAppName()  argument
54 name.id = buf.readU64(); in readAppName()
57 static void writeAppName(MessageBuf &buf, const hub_app_name_t &name) in writeAppName() argument
59 buf.writeU64(name.id); in writeAppName()
62 static void readNanohubMemInfo(MessageBuf &buf, NanohubMemInfo &mi) in readNanohubMemInfo() argument
83 while (buf.getRoom() >= 2) { in readNanohubMemInfo()
84 type = buf.readU8(); in readNanohubMemInfo()
85 len = buf.readU8(); in readNanohubMemInfo()
86 if (buf.getRoom() >= len) { in readNanohubMemInfo()
90 ramFree = buf.readU32(); in readNanohubMemInfo()
92 buf.readRaw(len); in readNanohubMemInfo()
96 mi.ramSz = buf.readU32(); in readNanohubMemInfo()
98 buf.readRaw(len); in readNanohubMemInfo()
102 mi.eeSz = buf.readU32(); in readNanohubMemInfo()
104 buf.readRaw(len); in readNanohubMemInfo()
108 eeFree = buf.readU32(); in readNanohubMemInfo()
110 buf.readRaw(len); in readNanohubMemInfo()
114 mi.osSz = buf.readU32(); in readNanohubMemInfo()
116 buf.readRaw(len); in readNanohubMemInfo()
120 osFree = buf.readU32(); in readNanohubMemInfo()
122 buf.readRaw(len); in readNanohubMemInfo()
126 mi.sharedSz = buf.readU32(); in readNanohubMemInfo()
128 buf.readRaw(len); in readNanohubMemInfo()
132 sharedFree = buf.readU32(); in readNanohubMemInfo()
134 buf.readRaw(len); in readNanohubMemInfo()
137 if (len != 0 || buf.getRoom() != 0) { in readNanohubMemInfo()
144 buf.readRaw(len); in readNanohubMemInfo()
153 if (buf.getRoom() != 0) { in readNanohubMemInfo()
168 NanohubRsp::NanohubRsp(MessageBuf &buf, uint32_t transactionId, bool chre) in NanohubRsp() argument
171 buf.reset(); in NanohubRsp()
172 if (buf.getSize() < 5) { in NanohubRsp()
175 mCmd = buf.readU8(); in NanohubRsp()
176 mStatus = buf.readU32(); in NanohubRsp()
237 MessageBuf buf(data, sizeof(data)); in setup() local
238 buf.writeU8(NANOHUB_HAL_SYS_INFO); in setup()
239 buf.writeRaw(sys_info_tags, sizeof(sys_info_tags)); in setup()
242 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
245 int SystemComm::MemInfoSession::handleRx(MessageBuf &buf, uint32_t transactionId, AppManager &, boo… in handleRx() argument
248 NanohubRsp rsp(buf, transactionId, chre); in handleRx()
253 size_t len = buf.getRoom(); in handleRx()
264 readNanohubMemInfo(buf, mi); in handleRx()
314 MessageBuf buf(data, sizeof(data)); in setup() local
345 buf.writeU8(NANOHUB_HAL_START_UPLOAD); in setup()
346 buf.writeU8(0); in setup()
347 buf.writeU32(mLen); in setup()
349 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
356 buf.writeU8(NANOHUB_HAL_APP_MGMT); in setup()
357 writeAppName(buf, mAppName); in setup()
358 buf.writeU8(NANOHUB_HAL_APP_MGMT_STOP); in setup()
360 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
364 buf.writeU8(NANOHUB_HAL_APP_MGMT); in setup()
365 writeAppName(buf, mAppName); in setup()
366 buf.writeU8(NANOHUB_HAL_APP_MGMT_START); in setup()
368 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
378 buf.writeU8(NANOHUB_HAL_APP_MGMT); in setup()
379 writeAppName(buf, mAppName); in setup()
380 buf.writeU8(NANOHUB_HAL_APP_MGMT_STOP); in setup()
382 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
386 buf.writeU8(NANOHUB_HAL_START_UPLOAD); in setup()
387 buf.writeU8(0); in setup()
388 buf.writeU32(mLen); in setup()
390 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
398 buf.writeU8(NANOHUB_HAL_SYS_MGMT); in setup()
399 buf.writeU8(NANOHUB_HAL_SYS_MGMT_REBOOT); in setup()
401 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
409 buf.writeU8(NANOHUB_HAL_APP_INFO); in setup()
410 buf.writeU32(0); in setup()
411 buf.writeRaw(app_info_tags, sizeof(app_info_tags)); in setup()
413 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setup()
448 MessageBuf buf(data, sizeof(data)); in setupMgmt() local
449 buf.writeU8(NANOHUB_HAL_APP_MGMT); in setupMgmt()
450 writeAppName(buf, appName); in setupMgmt()
451 buf.writeU8(cmd); in setupMgmt()
454 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in setupMgmt()
457 int SystemComm::AppMgmtSession::handleRx(MessageBuf &buf, uint32_t transactionId, AppManager &appMa… in handleRx() argument
461 NanohubRsp rsp(buf, transactionId, chre); in handleRx()
465 ret = handleTransfer(rsp, buf, appManager); in handleRx()
468 ret = handleStopTransfer(rsp, buf, appManager); in handleRx()
471 ret = handleQueryStart(rsp, buf, appManager); in handleRx()
474 ret = handleStart(rsp, buf, appManager); in handleRx()
477 ret = handleFinish(rsp, buf, appManager); in handleRx()
480 ret = handleRun(rsp, buf, appManager); in handleRx()
483 ret = handleStopRun(rsp, buf, appManager); in handleRx()
486 ret = handleReboot(rsp, buf, appManager); in handleRx()
489 ret = handleEraseTransfer(rsp, buf, appManager); in handleRx()
492 ret = handleMgmt(rsp, buf, appManager); in handleRx()
495 ret = handleInfo(rsp, buf, appManager); in handleRx()
508 MessageBuf buf(data, sizeof(data)); in handleTransfer() local
531 buf.writeU8(NANOHUB_HAL_SYS_MGMT); in handleTransfer()
532 buf.writeU8(NANOHUB_HAL_SYS_MGMT_ERASE); in handleTransfer()
534 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleTransfer()
555 buf.writeU8(NANOHUB_HAL_CONT_UPLOAD); in handleTransfer()
556 buf.writeU32(mPos); in handleTransfer()
557 buf.writeRaw(&mData[mPos], chunkSize); in handleTransfer()
560 buf.writeU8(NANOHUB_HAL_FINISH_UPLOAD); in handleTransfer()
564 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleTransfer()
567 int SystemComm::AppMgmtSession::handleStopTransfer(NanohubRsp &rsp, MessageBuf &buf, AppManager &) in handleStopTransfer() argument
572 uint8_t cmd = buf.readU8(); in handleStopTransfer()
577 MgmtStatus sts = { .value = buf.readU32() }; in handleStopTransfer()
582 MessageBuf buf(data, sizeof(data)); in handleStopTransfer() local
585 buf.writeU8(NANOHUB_HAL_START_UPLOAD); in handleStopTransfer()
586 buf.writeU8(0); in handleStopTransfer()
587 buf.writeU32(mLen); in handleStopTransfer()
588 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleStopTransfer()
598 int SystemComm::AppMgmtSession::handleQueryStart(NanohubRsp &rsp, MessageBuf &buf, AppManager &appM… in handleQueryStart() argument
604 size_t len = buf.getRoom(); in handleQueryStart()
606 uint32_t nextAddr = appManager.readNanohubAppInfo(buf); in handleQueryStart()
610 MessageBuf buf(data, sizeof(data)); in handleQueryStart() local
612 buf.writeU8(NANOHUB_HAL_APP_INFO); in handleQueryStart()
613 buf.writeU32(nextAddr); in handleQueryStart()
614 buf.writeRaw(app_info_tags, sizeof(app_info_tags)); in handleQueryStart()
616 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleQueryStart()
627 MessageBuf buf(data, sizeof(data)); in handleQueryStart() local
632 buf.writeU8(NANOHUB_HAL_APP_MGMT); in handleQueryStart()
633 writeAppName(buf, mAppName); in handleQueryStart()
634 buf.writeU8(NANOHUB_HAL_APP_MGMT_START); in handleQueryStart()
635 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleQueryStart()
639 int SystemComm::AppMgmtSession::handleStart(NanohubRsp &rsp, MessageBuf &buf, AppManager &) in handleStart() argument
644 uint8_t cmd = buf.readU8(); in handleStart()
649 MgmtStatus sts = { .value = buf.readU32() }; in handleStart()
658 MessageBuf buf(data, sizeof(data)); in handleStart() local
662 buf.writeU8(NANOHUB_HAL_APP_MGMT); in handleStart()
663 writeAppName(buf, mAppName); in handleStart()
664 buf.writeU8(NANOHUB_HAL_APP_MGMT_START); in handleStart()
665 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleStart()
669 int SystemComm::AppMgmtSession::handleFinish(NanohubRsp &rsp, MessageBuf &buf, AppManager &appManag… in handleFinish() argument
674 mFlashAddr = buf.readU32(); in handleFinish()
675 uint32_t crc = buf.readU32(); in handleFinish()
681 MessageBuf buf(data, sizeof(data)); in handleFinish() local
684 buf.writeU8(NANOHUB_HAL_APP_MGMT); in handleFinish()
685 writeAppName(buf, mAppName); in handleFinish()
686 buf.writeU8(NANOHUB_HAL_APP_MGMT_START); in handleFinish()
687 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleFinish()
698 int SystemComm::AppMgmtSession::handleRun(NanohubRsp &rsp, MessageBuf &buf, AppManager &appManager) in handleRun() argument
703 uint8_t cmd = buf.readU8(); in handleRun()
708 MgmtStatus sts = { .value = buf.readU32() }; in handleRun()
714 MessageBuf buf(data, sizeof(data)); in handleRun() local
717 buf.writeU8(NANOHUB_HAL_APP_INFO); in handleRun()
718 buf.writeU32(mFlashAddr); in handleRun()
719 buf.writeRaw(app_info_tags, sizeof(app_info_tags)); in handleRun()
721 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleRun()
731 int SystemComm::AppMgmtSession::handleInfo(NanohubRsp &rsp, MessageBuf &buf, AppManager &appManager) in handleInfo() argument
736 size_t len = buf.getRoom(); in handleInfo()
738 appManager.readNanohubAppInfo(buf); in handleInfo()
746 int SystemComm::AppMgmtSession::handleStopRun(NanohubRsp &rsp, MessageBuf &buf, AppManager &) in handleStopRun() argument
751 uint8_t cmd = buf.readU8(); in handleStopRun()
756 MgmtStatus sts = { .value = buf.readU32() }; in handleStopRun()
761 MessageBuf buf(data, sizeof(data)); in handleStopRun() local
764 buf.writeU8(NANOHUB_HAL_APP_MGMT); in handleStopRun()
765 writeAppName(buf, mAppName); in handleStopRun()
766 buf.writeU8(NANOHUB_HAL_APP_MGMT_START); in handleStopRun()
767 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleStopRun()
778 int SystemComm::AppMgmtSession::handleReboot(NanohubRsp &rsp, MessageBuf &buf, AppManager &) in handleReboot() argument
783 uint8_t cmd = buf.readU8(); in handleReboot()
794 int SystemComm::AppMgmtSession::handleEraseTransfer(NanohubRsp &rsp, MessageBuf &buf, AppManager &a… in handleEraseTransfer() argument
799 uint8_t cmd = buf.readU8(); in handleEraseTransfer()
803 MessageBuf buf(data, sizeof(data)); in handleEraseTransfer() local
807 buf.writeU8(NANOHUB_HAL_START_UPLOAD); in handleEraseTransfer()
808 buf.writeU8(0); in handleEraseTransfer()
809 buf.writeU32(mLen); in handleEraseTransfer()
810 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleEraseTransfer()
820 int SystemComm::AppMgmtSession::handleMgmt(NanohubRsp &rsp, MessageBuf &buf, AppManager &appManager) in handleMgmt() argument
825 uint8_t cmd = buf.readU8(); in handleMgmt()
826 MgmtStatus sts = { .value = buf.readU32() }; in handleMgmt()
846 MessageBuf buf(data, sizeof(data)); in handleMgmt() local
849 buf.writeU8(NANOHUB_HAL_APP_INFO); in handleMgmt()
850 buf.writeU32(appManager.getFlashAddr(mAppName)); in handleMgmt()
851 buf.writeRaw(app_info_tags, sizeof(app_info_tags)); in handleMgmt()
853 return sendToSystem(buf.getData(), buf.getPos(), rsp.mTransactionId); in handleMgmt()
886 int SystemComm::KeyInfoSession::handleRx(MessageBuf &buf, uint32_t transactionId, AppManager &, boo… in handleRx() argument
889 NanohubRsp rsp(buf, transactionId, chre); in handleRx()
897 uint32_t keyLen = buf.readU32(); in handleRx()
898 uint32_t dataLen = buf.getRoom(); in handleRx()
902 buf.getData() + buf.getPos(), in handleRx()
903 buf.getData() + buf.getSize()); in handleRx()
921 MessageBuf buf(data, sizeof(data)); in requestRsaKeys() local
923 buf.writeU8(NANOHUB_HAL_KEY_INFO); in requestRsaKeys()
924 buf.writeU32(mKeyNum); in requestRsaKeys()
925 buf.writeU32(mKeyOffset); in requestRsaKeys()
927 return sendToSystem(buf.getData(), buf.getPos(), transactionId); in requestRsaKeys()
1048 char *buf = (char *)malloc(size); in restoreApps() local
1049 CHECK_EQ(saved_apps_file.read(buf, size), (ssize_t)size); in restoreApps()
1051 std::string str(buf); in restoreApps()
1055 free(buf); in restoreApps()
1170 void *buf = malloc(len); in cmpApp() local
1171 … if (buf != nullptr && read(fd, buf, sb.st_size) == sb.st_size && memcmp(data, buf, len) == 0) in cmpApp()
1173 free(buf); in cmpApp()
1180 uint32_t SystemComm::AppManager::readNanohubAppInfo(MessageBuf &buf) in readNanohubAppInfo() argument
1189 if (buf.getRoom() < 2 + sizeof(name.id)) { in readNanohubAppInfo()
1194 tag = buf.readU8(); in readNanohubAppInfo()
1195 len = buf.readU8(); in readNanohubAppInfo()
1201 readAppName(buf, name); in readNanohubAppInfo()
1211 while (buf.getRoom() >= 2) { in readNanohubAppInfo()
1212 tag = buf.readU8(); in readNanohubAppInfo()
1213 len = buf.readU8(); in readNanohubAppInfo()
1214 if (buf.getRoom() >= len) { in readNanohubAppInfo()
1220 app->crc = buf.readU32(); in readNanohubAppInfo()
1222 buf.readRaw(len); in readNanohubAppInfo()
1231 app->tid = buf.readU32(); in readNanohubAppInfo()
1235 buf.readRaw(len); in readNanohubAppInfo()
1239 app->version = buf.readU32(); in readNanohubAppInfo()
1241 buf.readRaw(len); in readNanohubAppInfo()
1245 app->flashAddr = buf.readU32(); in readNanohubAppInfo()
1247 buf.readRaw(len); in readNanohubAppInfo()
1253 app->flashUse = buf.readU32(); in readNanohubAppInfo()
1255 buf.readRaw(len); in readNanohubAppInfo()
1263 ramUse += buf.readU32(); in readNanohubAppInfo()
1265 buf.readRaw(len); in readNanohubAppInfo()
1272 app->chre_major = buf.readU8(); in readNanohubAppInfo()
1274 buf.readRaw(len); in readNanohubAppInfo()
1281 app->chre_minor = buf.readU8(); in readNanohubAppInfo()
1283 buf.readRaw(len); in readNanohubAppInfo()
1286 if (len != 0 || buf.getRoom() != 0) { in readNanohubAppInfo()
1293 buf.readRaw(len); in readNanohubAppInfo()
1302 if (buf.getRoom() != 0) { in readNanohubAppInfo()
1380 MessageBuf buf(data, len); in doHandleRx() local
1382 dumpBuffer("SYS -> HAL", mHostIfAppName, transactionId, 0, buf.getData(), buf.getSize()); in doHandleRx()
1384 int status = mSessions.handleRx(buf, transactionId, mAppManager, chre, reboot, rebootStatus); in doHandleRx()
1388 mHostIfAppName, transactionId, 0, buf.getData(), buf.getSize(), status); in doHandleRx()
1411 int SystemComm::SessionManager::handleRx(MessageBuf &buf, uint32_t transactionId, AppManager &appMa… in handleRx() argument
1423 status = session->handleRx(buf, transactionId, appManager, chre); in handleRx()
1429 NanohubRsp rsp(buf, transactionId, chre); in handleRx()
1431 uint8_t cmd = buf.readU8(); in handleRx()