static int xhwicap_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct xhwicap_instance *inst; XStatus status; /* FIXME! Assume instance is first in list - this is bogus */ inst = inst_list; if(!inst) return -ENODEV; switch (cmd) { case XHWICAP_IOCCMDDESYNC: DBPRINTK("desynch()\n"); status = XHwIcap_CommandDesync(&(inst->HwIcap)); if(status==XST_DEVICE_BUSY) return -EBUSY; break; case XHWICAP_IOCCMDCAPTURE: DBPRINTK("capture()\n"); status = XHwIcap_CommandCapture(&(inst->HwIcap)); if(status==XST_DEVICE_BUSY) return -EBUSY; break; case XHWICAP_IOCGETINST: DBPRINTK("getinst()\n"); copy_to_user((void *)arg, (void *)(&(inst->HwIcap)), sizeof(XHwIcap)); default: return -ENOIOCTLCMD; } return 0; }
/** * * This function does a test on the BRAM FF as an example. * * @param DeviceId is the XPAR_<HWICAP_INSTANCE>_DEVICE_ID value from * xparameters.h * * @return XST_SUCCESS if successful, otherwise XST_FAILURE * * @note None * ****************************************************************************/ int HwIcapBramFfExample(u16 DeviceId) { u32 SrMode=0; int Status; u32 Row; u32 Col; u32 Slice; u32 Loop; u32 Value; u8 Contents[1]; XHwIcap_Config *CfgPtr; /* * Initialize the HwIcap instance. */ CfgPtr = XHwIcap_LookupConfig(DeviceId); if (CfgPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(&HwIcap, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Identify the FF to change: FFX in SLICE_X0Y0. */ Col = XHwIcap_SliceX2Col(HWICAP_EXAMPLE_TEST_COL); Row = XHwIcap_SliceY2Row(&HwIcap, HWICAP_EXAMPLE_TEST_ROW); Slice = XHwIcap_SliceXY2Slice(HWICAP_EXAMPLE_TEST_COL, HWICAP_EXAMPLE_TEST_ROW); printf("Setting the SRMODE -> SRHIGH. \r\n"); Status = XHwIcap_SetClbBits(&HwIcap, Row, Col, XHI_CLB_FF.SRMODE[Slice][XHI_CLB_XQ], XHI_CLB_FF.SRHIGH, 1); if (Status != XST_SUCCESS) { printf("Failed to Set SRMODE->SRHIGH: %d \r\n", Status); return XST_FAILURE; } printf("Setting the SRMODE -> SRLOW. \r\n"); Status = XHwIcap_SetClbBits(&HwIcap, Row, Col, XHI_CLB_FF.SRMODE[Slice][XHI_CLB_XQ], XHI_CLB_FF.SRLOW, 1); if (Status != XST_SUCCESS) { printf("Failed to Set SRMODE->SRLOW: %d \r\n", Status); return XST_FAILURE; } printf("Set SRINV to SR \r\n"); Status = XHwIcap_SetClbBits(&HwIcap, Row, Col, XHI_CLB_SRINV.RES[Slice], XHI_CLB_SRINV.SR, 1); if (Status != XST_SUCCESS) { printf("Failed to Set SRINV->SR: %d \r\n", Status); return XST_FAILURE; } /* * Set it back */ printf("Set SRINV to SR_B \r\n"); Status = XHwIcap_SetClbBits(&HwIcap, Row, Col, XHI_CLB_SRINV.RES[Slice], XHI_CLB_SRINV.SR_B, 1); if (Status != XST_SUCCESS) { printf("Failed to Set SRINV->SR_B: %d \r\n", Status); return XST_FAILURE; } /* * Capture the FF states. If the CAPTURE block is instantiated in * the design then the XHwIcap_CommandCapture() is not necessary. */ printf("Capture the FF state. \r\n"); Status = XHwIcap_CommandCapture(&HwIcap); if (Status != XST_SUCCESS) { printf("Failed to capture FF states: %d \r\n", Status); return XST_FAILURE; } /* * Read the FF Contents */ Status = XHwIcap_GetClbBits(&HwIcap, Row, Col, XHI_CLB_FF.CONTENTS[Slice][XHI_CLB_XQ], Contents, 1); if (Status != XST_SUCCESS) { printf("Failed to Get FF Contents: %d \r\n", Status); return XST_FAILURE; } /* * The readback value of the FF is inverted from its true value. */ Value = ~Contents[0] & 0x1; printf("FF Contents: %d \r\n", Value); printf("HwicapBramFFExample Passed Successfully ... \r\n\r\n"); return XST_SUCCESS; }