📄 fdi_pckt.c
字号:
} while (TotalPacketObjSize > 0);
/*
* wait for FDI_Write be executed by BKGD_Task
* Check FDI Queue status. If Queue status is empty, then continue; or
* else wait for Queue become empty using the Task Delay function in the
* Tornado lib.
*/
FDI_WAIT_FORQUEUE_EMPTY(queuestatus);
/* After the space for packet object have been reseved,
invoke close the packet ID */
/*
* Parameters needed for FDI_Close:
* cmd_cntrl.identifier
* cmd_cntrl.type
*/
FDI_Close(&cmd_cntrl); /* may have ERR_NONE,ERR_PARAM,ERR_NOTOPEN */
/* Set the FDI_Pckt InProg TRUE */
FDI_Pckt.InProg = (BYTE)TRUE ;
/* Unlock the SEM_APIMutexSemaphore. */
SEM_MTX_POST(SEM_APIMutexSemaphore);
#ifdef TIMING
/* Get timestamp for start of update */
COMM_getTimestamp(&Pckt_End);
#ifdef writeToFile
fprintf(rw,"time to write Packetdata of size %d is %1.0f usecs \n",
(int) (count * fragsize),
((float)(Pckt_End.low - Pckt_Start.low)) * 163.84);
#endif
logMsg("time to write Packetdata of size %d is %d ticks\n",
(int) (count * fragsize),
(int) (Pckt_End.low - Pckt_Start.low), 0, 0, 0, 0);
#endif
return ERR_NONE;
}
/*
#############################################################################
### FDI_ReleasePacket()
###
### DESCRIPTION:
### FDI_ReleasePacket end the packet data session after the FDI_InitPacket
### initilization and WritePacket write. Firstly, FDI_ReleasePacket advance
### packet data group table status from the 'allocting' to 'allocted', and make
### the sequence table status into valid, at last finialize the group table
### status into valid. At the processing, FDI_ReleasePacket would process
### the failure case.
###
### PARAMETERS:
### IN: None
###
### OUT:
### error: a descriptive error code
###
### Global:
### FDI_Pckt: a global structure to be accessed by the API,
### Background and Reclaim tasks
###
### RETURNS:
### ERR_NONE ERR_SYSTEM HW_ERR_NONE HW_ERR_PARAM RD_ERR_EMPTY_LKUP
### ERR_READ ERR_WRITE ERR_INIT ERR_OPEN
###
### Note: call function ScanPcktDataEntryTable (identifier,type)
###########################################################################
*/
ERR_CODE
FDI_ReleasePacket(void)
{
ERR_CODE status;
WORD identifier;
BYTE type;
#ifdef TIMING
/* Get timestamp for start of update */
COMM_getTimestamp((COMM_TIMESTAMP *) & Pckt_Start);
#endif
/*
* Check for completion of Initialization and if not yet complete return
* the proper error code.
*/
if (FDI_InitComplete != TRUE)
return ERR_INIT;
/* lock the SEM_APIMutexSemaphore */
SEM_MTX_WAIT(SEM_APIMutexSemaphore);
/* check FDI_Pckt.ID */
if( FDI_Pckt.ID == WORDMAX )
{
SEM_MTX_POST(SEM_APIMutexSemaphore);
return ERR_OPEN;
}
identifier = FDI_Pckt.ID;
/* lock the SEM_LookupTable */
/*SEM_MTX_WAIT(SEM_LookupTable);
type = LOOKUP_TABLE_TYPE(identifier);*/
/* Unlock the SEM_LookupTable */
/*SEM_MTX_POST(SEM_LookupTable);*/
type = FDI_Pckt.type;
status = ScanPcktDataEntryTable (identifier,type);
if (status != ERR_NONE )
{
#ifdef TEST_MSGS
logMsg ("Error in ReleasePacket calling ScanPcktDataEntryTable\n", 0, 0, 0, 0, 0, 0);
#endif
}
/* Set the FDI_Pckt NULL */
FDI_Pckt.InProg = (BYTE) FALSE;
FDI_Pckt.ID = WORDMAX ;
/* Unlock SEM_APIMutexSemaphore */
SEM_MTX_POST(SEM_APIMutexSemaphore);
#ifdef TIMING
/* Get timestamp for start of update */
COMM_getTimestamp(&Pckt_End);
#ifdef writeToFile
fprintf(rw,"time to release Packetdata of id %d is %1.0f usecs \n",
(int) identifier,
((float)(Pckt_End.low - Pckt_Start.low)) * 163.84);
#endif
logMsg("time to release Packetdata of id %d is %d ticks\n",
(int) identifier,
(int) (Pckt_End.low - Pckt_Start.low), 0, 0, 0, 0);
#endif
return status;
}
/*
#############################################################################
### ScanPcktDataEntryTable
###
### DESCRIPTION:
### ScanPcktDataEntryTable only is used in the packet data processing.
### ScanPcktDataEntryTable advance packet data group table status from
### allocting to allocted, and make the sequence table and fragment status
### valid by calling ScanEntryTable,
### at last make the group table into valid status.
###
### PARAMETERS:
### IN:
### identifier: the user identifier of the packet object to be written.
### type: the user type of the object to be written.
###
### OUT:
### error: a descriptive error code
###
### Global:
### FDI_Pckt: a global structure to be accessed by the API,
### Background and Reclaim tasks
###
### RETURNS:
### ERR_NONE ERR_SYSTEM ERR_READ ERR_WRITE
### HW_ERR_NONE HW_ERR_PARAM RD_ERR_EMPTY_LKUP
###
### Note: called by function FDI_ReleasePacket
###########################################################################
*/
static ERR_CODE ScanPcktDataEntryTable (WORD identifier,BYTE type)
{
ERR_CODE status=ERR_NONE;
ERR_CODE status1=ERR_NONE;
WORD current_index;
DWORD block_address;
DWORD unit_address;
DWORD header_offset;
UNIT_HEADER unit_header_buffer;
WORD logical_blk;
/* Get Lookup Group Table Header */
if ( LookupToHeader(&block_address, &unit_address,
&header_offset, &unit_header_buffer,
&logical_blk, identifier,type)
!= HW_ERR_NONE )
{
status = ERR_SYSTEM;
}
if (status == ERR_NONE )
{
/* Advance Group table header status to allocated */
status1 = WriteUnitHeaderStatus (block_address + header_offset,
HDR_ALLOCATED,
HDR_ALLOCATING,
0,0);
mDEBUG_CHECK_ERRCODE(status1)
if(status1 != ERR_NONE)
status = ERR_SYSTEM;
}
if (status == ERR_NONE )
{
/* invoke the ScanEntryTables */
current_index = (header_offset-FIRST_HEADER_OFFSET) /
sizeof(UNIT_HEADER);
status = ScanEntryTables(&unit_header_buffer,
header_offset + block_address, current_index,
logical_blk, 0);
}
if (status == ERR_NONE)
{
/* Advance Group table header status to VALID */
status1 = WriteUnitHeaderStatus (block_address + header_offset,
HDR_VALID, HDR_ALLOCATED, 0, 0);
mDEBUG_CHECK_ERRCODE(status1)
if(status1 != ERR_NONE)
status = ERR_SYSTEM;
}
return status;
}
/*
#############################################################################
### DeletePcktData
###
### DESCRIPTION:
### Only used in the FDI_InitPacket when meeting the failure case.
### Use SearchForIdentifier to find out, then mark status to INVALID.
###
### PARAMETERS:
### IN:
### identifier: the user identifier of the object to be written.
### type: the user type of the object to be written.
###
### OUT:
### error: a descriptive error code
###
### Global:
### FDI_Pckt: a global structure to be accessed by the API,
### Background and Reclaim tasks
###
### RETURNS:
### ERR_INIT ERR_OPEN ERR_SYSTEM
###
### Note: called by function FDI_InitPacket
###########################################################################
*/
static ERR_CODE DeletePcktData (WORD identifier,BYTE type)
{
BYTE queuestatus;
ERR_CODE status;
HW_ERROR hw_status;
DWORD block_address;
DWORD unit_address;
DWORD header_offset;
UNIT_HEADER unit_header_buffer;
DWORD invalidating_hdr_addr;
WORD logical_blk;
FDI_WAIT_FORQUEUE_EMPTY(queuestatus);
/* Get Lookup Group Table Header */
hw_status = LookupToHeader(&block_address, &unit_address,
&header_offset, &unit_header_buffer,
&logical_blk, identifier, type);
if ( hw_status == HW_ERR_DELETE ) {
return ERR_NONE;
}
else if ( hw_status == HW_ERR_EMPTY_LKUP ) {
SEM_MTX_WAIT(SEM_LookupTable);
INIT_LOOKUP_TABLE(type, identifier);
SEM_MTX_POST(SEM_LookupTable);
return ERR_NONE;
}
else if (hw_status == HW_ERR_NONE ) {
status = ERR_NONE;
/* pass in HDR_INVALIDATING as an arguement to SearchForIdentifier
in order to get all the sequence tables and fragments of that
type and ID invalidated. */
unit_header_buffer.status = HDR_INVALIDATING;
status = SearchForIdentifier (&unit_header_buffer,&invalidating_hdr_addr,
WORDMAX,WORDMAX,0);
/* mark group table invalid */
if ((status = WriteUnitHeaderStatus (block_address + header_offset,
HDR_INVALID, HDR_VALID_HDR,
unit_header_buffer.g_unit_size, 0)) != ERR_NONE )
{
mDEBUG_CHECK_ERRCODE(status)
status = ERR_SYSTEM;
}
SEM_MTX_WAIT(SEM_LookupTable);
INIT_LOOKUP_TABLE(type, identifier);
SEM_MTX_POST(SEM_LookupTable);
}
else /* ERR_PARAM or ERR_SYSTEM */
{
status = ERR_SYSTEM;
}
return status;
}
#endif /* PACKET_DATA */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -