| 545 | } |
| 546 | |
| 547 | void SendCounterPacket::SendCounterDirectoryPacket(const ICounterDirectory& counterDirectory) |
| 548 | { |
| 549 | // Get the amount of data that needs to be put into the packet |
| 550 | const uint16_t categoryCount = counterDirectory.GetCategoryCount(); |
| 551 | const uint16_t deviceCount = counterDirectory.GetDeviceCount(); |
| 552 | const uint16_t counterSetCount = counterDirectory.GetCounterSetCount(); |
| 553 | |
| 554 | // Utils |
| 555 | const size_t uint32_t_size = sizeof(uint32_t); |
| 556 | const size_t packetHeaderSize = 2u; |
| 557 | const size_t bodyHeaderSize = 6u; |
| 558 | const uint32_t bodyHeaderSizeBytes = bodyHeaderSize * uint32_t_size; |
| 559 | |
| 560 | // Initialize the offset for the pointer tables |
| 561 | uint32_t pointerTableOffset = 0; |
| 562 | |
| 563 | // -------------- |
| 564 | // Device records |
| 565 | // -------------- |
| 566 | |
| 567 | // Process device records |
| 568 | std::vector<DeviceRecord> deviceRecords(deviceCount); |
| 569 | const Devices& devices = counterDirectory.GetDevices(); |
| 570 | std::vector<uint32_t> deviceRecordOffsets(deviceCount, 0); // device_records_pointer_table |
| 571 | size_t deviceRecordsSize = 0; |
| 572 | size_t deviceIndex = 0; |
| 573 | size_t deviceRecordOffsetIndex = 0; |
| 574 | |
| 575 | pointerTableOffset = arm::pipe::numeric_cast<uint32_t>(deviceCount * uint32_t_size + |
| 576 | counterSetCount * uint32_t_size + |
| 577 | categoryCount * uint32_t_size); |
| 578 | for (auto it = devices.begin(); it != devices.end(); it++) |
| 579 | { |
| 580 | const DevicePtr& device = it->second; |
| 581 | DeviceRecord& deviceRecord = deviceRecords.at(deviceIndex); |
| 582 | |
| 583 | std::string errorMessage; |
| 584 | if (!CreateDeviceRecord(device, deviceRecord, errorMessage)) |
| 585 | { |
| 586 | CancelOperationAndThrow<arm::pipe::ProfilingException>(errorMessage); |
| 587 | } |
| 588 | |
| 589 | // Update the total size in words of the device records |
| 590 | deviceRecordsSize += deviceRecord.size(); |
| 591 | |
| 592 | // Add the device record offset to the device records pointer table offset field |
| 593 | deviceRecordOffsets[deviceRecordOffsetIndex] = pointerTableOffset; |
| 594 | pointerTableOffset += arm::pipe::numeric_cast<uint32_t>(deviceRecord.size() * uint32_t_size); |
| 595 | |
| 596 | deviceIndex++; |
| 597 | deviceRecordOffsetIndex++; |
| 598 | } |
| 599 | |
| 600 | // ------------------- |
| 601 | // Counter set records |
| 602 | // ------------------- |
| 603 | |
| 604 | // Process counter set records |
no test coverage detected