/** * * Get the status of the FAT filesystem on the first valid partition of the * CompactFlash device such as the boot record and FAT types found. * * @param InstancePtr is a pointer to the XSysAce instance. * * @return A 16-bit mask of status values. These values are defined in * xsysace_l.h with the prefix XSA_FAT_*. * * @note None. * ******************************************************************************/ u16 XSysAce_GetFatStatus(XSysAce *InstancePtr) { Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); return XSysAce_RegRead16(InstancePtr->BaseAddress + XSA_FSR_OFFSET); }
/** * * Get the status of the FAT filesystem on the first valid partition of the * CompactFlash device such as the boot record and FAT types found. * * @param InstancePtr is a pointer to the XSysAce instance to be worked on. * * @return * * A 16-bit mask of status values. These values are defined in xsysace_l.h * with the prefix XSA_FAT_*. * * @note * * None. * ******************************************************************************/ u16 XSysAce_GetFatStatus(XSysAce * InstancePtr) { XASSERT_NONVOID(InstancePtr != NULL); XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); return XSysAce_RegRead16(InstancePtr->BaseAddress + XSA_FSR_OFFSET); }
/** * * Read the specified number of bytes from the data buffer of the ACE * controller. The data buffer, which is 32 bytes, can only be read two bytes * at a time. Once the data buffer is read, we wait for it to be filled again * before reading the next buffer's worth of data. * * @param BaseAddress is the base address of the device * @param BufferPtr is a pointer to a buffer in which to store data. * @param Size is the number of bytes to read * * @return * * The total number of bytes read, or 0 if an error occurred. * * @note * * If Size is not aligned with the size of the data buffer (32 bytes), this * function will read the entire data buffer, dropping the extra bytes on the * floor since the user did not request them. This is necessary to get the * data buffer to be ready again. * ******************************************************************************/ int XSysAce_ReadDataBuffer(Xuint32 BaseAddress, Xuint8 *BufferPtr, int Size) { int DataBytes; /* number of data bytes written */ int BufferBytes; Xuint16 Data; /* * Read data two bytes at a time. We need to wait for the data * buffer to be ready before reading the buffer. */ BufferBytes = 0; for (DataBytes = 0; DataBytes < Size;) { /* * If at any point during this read an error occurs, exit early */ if (XSysAce_mGetErrorReg(BaseAddress) != 0) { return 0; } if (BufferBytes == 0) { /* * Wait for CF data buffer to ready, then reset buffer byte count */ while ((XSysAce_mGetStatusReg(BaseAddress) & XSA_SR_DATABUFRDY_MASK) == 0); BufferBytes = XSA_DATA_BUFFER_SIZE; } /* * Need to read two bytes. Put the first one in the output buffer * because if we're here we know one more is needed. Put the second one * in the output buffer if there is still room, or just drop it on the * floor if the requested number of bytes have already been read. */ Data = XSysAce_RegRead16(BaseAddress + XSA_DBR_OFFSET); *BufferPtr++ = (Xuint8)Data; DataBytes++; if (DataBytes < Size) { /* Still more room in the output buffer */ *BufferPtr++ = (Xuint8)(Data >> 8); DataBytes++; } BufferBytes -= 2; }