3.4.3 Writing to string registers

Writing to string registers works differently to writing to an integer or a floating-point register, and to reading a string register. In contrast to other types of registers, a string register does not have a fixed bitwidth.

A CADIRegWrite to a string register using nonzero offset128 could extend, truncate, or update a string. To avoid ambiguity, string updates must allocate an array of n CADIReg_t elements with enough buffer space to store the entire string, including a terminating null character. The offset128 parameter in each CADIReg_t must have the value n and the bytes buffer must contain the nth 16 byte chunk of the string. The caller performs a single CADIRegWrite, updating the string register atomically, if successful.

Writing string registers
eslapi::CADIReturn_t status;
// "register_info" contains information on a string register.
std::string writeString("Pneumonoultramicroscopicsilicovolcanoconiosis");
const char *s = writeString.c_str();
uint32_t bytes  = strlen(s) + 1;
uint32_t chunks = (bytes + 15) / 16; // The number of 128-bit chunks required to hold the null terminated string.
uint32_t numRegsWritten = 0;
eslapi::CADIReg_t *regs = new eslapi::CADIReg_t[chunks];
for(uint32_t i = 0; i < chunks; i++)
   regs[i].regNumber = register_info.regNumber;
   regs[i].offset128 = i;
   uint32_t remaining = bytes - i*16;
   memset(regs[i].bytes, 0, 16);
   memcpy(regs[i].bytes, &s[i*16], remaining > 16 ? 16 : remaining);
status = cadi->CADIRegWrite(chunks, regs, &numRegsWritten, 0); 
delete[] regs;
if (status != eslapi::CADI_STATUS_OK || numRegsWritten != chunks)
   printf("ERROR: Writing register failed\n");
Non-ConfidentialPDF file icon PDF versionARM 100963_0200_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.