TEST(GetRegisters, GetCID_FailCommand_ShouldFail) { uint8_t cid[16]; initSDHC(); // CMD10 input data. setupDataForCmd("04"); // Clear buffer to 0x00 before reading into it. memset(cid, 0, sizeof(cid)); LONGS_EQUAL(RES_ERROR, m_sd.getCID(cid, sizeof(cid))); validateSelect(); // Should send CMD10 to start read. validateCmdPacket(10); validateDeselect(); // Verify that register contents weren't modified. validateBuffer(cid, 16, 0x00); // Verify error log output. m_sd.dumpErrorLog(stderr); char expectedOutput[256]; snprintf(expectedOutput, sizeof(expectedOutput), "sendCommandAndReceiveDataBlock(CMD10,0,%08X,16) - CMD10 returned 0x04\n" "getCID(%08X,16) - Register read failed\n", (uint32_t)(size_t)cid, (uint32_t)(size_t)cid); STRCMP_EQUAL(expectedOutput, printfSpy_GetLastOutput()); }
// *************** // getCSD() tests // *************** TEST(GetRegisters, GetCSD_SuccessfulRead) { uint8_t csd[16]; initSDHC(); // CMD9 input data. setupDataForCmd("00"); // 0xFE starts read data block. m_sd.spi().setInboundFromString("FE"); // Data block will contain 16 bytes of 0xAD + valid CRC. setupDataBlock(0xAD, 16); // Clear buffer to 0x00 before reading into it. memset(csd, 0, sizeof(csd)); LONGS_EQUAL(RES_OK, m_sd.getCSD(csd, sizeof(csd))); validateSelect(); // Should send CMD9 to start read. validateCmdPacket(9); // Should send multiple FF bytes to read in register data block: // 1 to read in header. // 16 to read data. // 2 to read CRC. validateFFBytes(1+16+2); validateDeselect(); // Verify that register contents were read into supplied buffer. validateBuffer(csd, 16, 0xAD); }
void append(Logging *logging, const char *text) { efiAssertVoid(text != NULL, "append NULL"); uint32_t extraLen = efiStrlen(text); int isError = validateBuffer(logging, extraLen); if (isError) { return; } strcpy(logging->linePointer, text); logging->linePointer += extraLen; }
void append(Logging *logging, const char *text) { efiAssertVoid(text != NULL, "append NULL"); uint32_t extraLen = efiStrlen(text); bool isError = validateBuffer(logging, extraLen); if (isError) { return; } strcpy(logging->linePointer, text); /** * And now we are pointing at the zero char at the end of the buffer again */ logging->linePointer += extraLen; }