The main loop of Cosmos+ firmware.
Do scheduling.
We need to execute the requests that were put on corresponding queue in prev part.
As described in the paper, Host DMA operations have the highest priority, so we should call the CheckDoneNvmeDmaReq first, then SchedulingNandReq.
   74{
   75    unsigned int exeLlr;
   76    unsigned int rstCnt = 0;
   77 
   78    xil_printf("!!! Wait until FTL reset complete !!! \r\n");
   79 
   81 
   82    xil_printf("\r\nFTL reset complete!!! \r\n");
   83    xil_printf("Turn on the host PC \r\n");
   84 
   93    while (1)
   94    {
   95        exeLlr = 1;
   96 
   98        {
   99            unsigned int ccEn;
  101            if (ccEn == 1)
  102            {
  106                xil_printf("\r\nNVMe ready!!!\r\n");
  107            }
  108        }
  110        {
  112            unsigned int cmdValid;
  113 
  115 
  129            if (cmdValid == 1)
  130            {
  131                rstCnt = 0;
  132                if (nvmeCmd.
qID == 0)
 
  133                {
  135                }
  136                else
  137                {
  140                    exeLlr = 0;
  141                }
  142            }
  143        }
  145        {
  148            if (nvmeReg.
ccShn != 0)
 
  149            {
  150                unsigned int qID;
  152 
  153                for (qID = 0; qID < 8; qID++)
  154                {
  157                }
  158 
  163 
  164                
  166 
  167                xil_printf("\r\nNVMe shutdown!!!\r\n");
  168            }
  169        }
  171        {
  172            unsigned int ccEn;
  174            if (ccEn == 0)
  175            {
  180                xil_printf("\r\nNVMe disable!!!\r\n");
  181            }
  182        }
  184        {
  185            unsigned int qID;
  186            for (qID = 0; qID < 8; qID++)
  187            {
  190            }
  191 
  192            if (rstCnt >= 5)
  193            {
  195                rstCnt = 0;
  196                xil_printf("\r\nPcie iink disable!!!\r\n");
  197                xil_printf("Wait few minute or reconnect the PCIe cable\r\n");
  198            }
  199            else
  200                rstCnt++;
  201 
  207 
  208            xil_printf("\r\nNVMe reset!!!\r\n");
  209        }
  210 
  221        {
  224        }
  225    }
  226}
void UpdateBadBlockTableForGrownBadBlock(unsigned int tempBufAddr)
Update the bad block table and persist to the specified block.
 
void InitFTL()
The entry function for FTL initialization.
 
void set_nvme_admin_queue(unsigned int sqValid, unsigned int cqValid, unsigned int cqIrqEn)
 
unsigned int check_nvme_cc_en()
 
void set_nvme_csts_shst(unsigned int shst)
 
void set_nvme_csts_rdy(unsigned int rdy)
 
void pcie_async_reset(unsigned int rstCnt)
 
unsigned int get_nvme_cmd(unsigned short *qID, unsigned short *cmdSlotTag, unsigned int *cmdSeqNum, unsigned int *cmdDword)
 
void set_io_sq(unsigned int ioSqIdx, unsigned int valid, unsigned int cqVector, unsigned int qSzie, unsigned int pcieBaseAddrL, unsigned int pcieBaseAddrH)
 
void set_io_cq(unsigned int ioCqIdx, unsigned int valid, unsigned int irqEn, unsigned int irqVector, unsigned int qSzie, unsigned int pcieBaseAddrL, unsigned int pcieBaseAddrH)
 
#define NVME_STATUS_REG_ADDR
 
#define RESERVED_DATA_BUFFER_BASE_ADDR
 
#define NVME_TASK_WAIT_RESET
 
#define NVME_TASK_WAIT_CC_EN
 
#define NVME_TASK_RUNNING
 
#define NVME_TASK_SHUTDOWN
 
void handle_nvme_admin_cmd(NVME_COMMAND *nvmeCmd)
 
void handle_nvme_io_cmd(NVME_COMMAND *nvmeCmd)
 
volatile NVME_CONTEXT g_nvmeTask
 
unsigned int blockedReqCnt
 
NVME_DMA_REQUEST_QUEUE nvmeDmaReqQ
 
unsigned int notCompletedNandReqCnt
 
#define REQ_SLOT_TAG_NONE
 
void SchedulingNandReq()
Iteratively do schedule on each channel by calling SchedulingNandReqPerCh.
 
unsigned short cmdSlotTag
 
unsigned int cmdDword[16]