📄 ac48drhi.c
字号:
if(LastBlockFlag)
{ /* Set DSP to read/write back to LSB first */
Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
LastBlockFlag=0;
if(BlockStructureFile)
fprintf(BlockStructureFile,
" LAST_STAGE_COMPLETED\n");
return LAST_STAGE_COMPLETED;
}
LastBlockFlag = (Download[0] & 0x80);
BlockLength = ((int)(Download[4])<<8)
|(int)((unsigned char)Download[5]);
BlockLength += 5; /* as is */
if(BlockStructureFile)
fprintf(BlockStructureFile, "%.6X: %.2X%.2X %.2X%.2X %.2X%.2X %.2X%.2X %.2X%.2X \n",
(int)(Download - ProgramDownloadStructure),
Download[0], Download[1],
Download[2], Download[3],
Download[4], Download[5], /* BlockLength - 5 */
Download[6], Download[7],
Download[8], Download[9]);
/* HPIA <= AC48_PROGRAM_ADDRESS-1 */
Ac48xxHostWrite((char)((AC48_PROGRAM_ADDRESS-1)>>8),
DeviceIndex, HPIA, First);
Ac48xxHostWrite((char)(AC48_PROGRAM_ADDRESS-1),
DeviceIndex, HPIA, Second);
for(i=0; i<BlockLength; i++) /* copy block */
{
Ac48xxHostWrite(*Download++, DeviceIndex, HPID, First);
Ac48xxHostWrite(*Download++, DeviceIndex, HPID, Second);
}
/* write "packet full" */
/* HPIA <= BOOT_STATUS_REGISTER */
Ac48xxHostWrite((char)(AC48_BOOT_STATUS_REGISTER>>8),
DeviceIndex, HPIA, First);
Ac48xxHostWrite((char)AC48_BOOT_STATUS_REGISTER,
DeviceIndex, HPIA, Second);
/* HPID <= PACKET_FULL */
Ac48xxHostWrite((char)0 , DeviceIndex, HPIDL, First);
Ac48xxHostWrite((char)PACKET_FULL, DeviceIndex, HPIDL, Second);
/* send interupt to DSP */
Ac48xxHostWrite((SET_DSPINT | CLEAR_HINT | MSB_FIRST),
DeviceIndex, HPIC, First);
Ac48xxHostWrite((SET_DSPINT | CLEAR_HINT | MSB_FIRST),
DeviceIndex, HPIC, Second);
}
}
/*======================================================================*/
/* Name : Ac48xxBoot */
/*======================================================================*/
/* Purpose : Download software into the AC48 Device. */
/* */
/* Inputs : int DeviceIndex: */
/* Device index to be initialized. */
/* const char *KernelDownload: */
/* Pointer to the AC48 boot kernel download software */
/* to be downloaded. */
/* int KernelSize: */
/* This value can vary according to kernel version. */
/* const char **ProgramDownload: */
/* Address of Pointer to the AC48 operational software */
/* to be downloaded. This Pointer muves with the */
/* Download. */
/* int Stage: */
/* This parameter is relevant only when WaitMode equal */
/* to "DONT_WAIT_PACKET_EMPTY". This parameter helps */
/* the watch-dog mechanism to let the AC48 complete */
/* the booting */
/* TWaitMode WaitMode: */
/* Wait / don't wait to "packet-empty". */
/* Output : int: */
/* (LAST_STAGE_COMPLETED) - for successful operation */
/* (ERROR) - Program Download failed */
/* (-1) - the Program Download proccess did not */
/* complete, yet. In edition, the pointer to */
/* the Program Download Blocks, updated. */
/*======================================================================*/
int Ac48xxBoot(int DeviceIndex, const char *KernelDownload, int KernelSize,
const char **ProgramDownload, int Stage, TWaitMode WaitMode)
{
int Status;
if(Stage != (-1))
Ac48xxKernelDownload(DeviceIndex, KernelDownload, KernelSize);
do
Status = Ac48xxProgramDownload(DeviceIndex, ProgramDownload);
while((WaitMode == WAIT_PACKET_EMPTY) && (Status == (-1)));
return Status; /* ERROR( 1 ) / (-1) / LAST_STAGE_COMPLETED( 0 ) */
}
/*======================================================================*/
/* Name : Ac48xxBootCompletely */
/*======================================================================*/
/* Purpose : Download software into the AC48 Device. */
/* */
/* Inputs : int DeviceIndex: */
/* Device index to be initialized. */
/* const char *KernelDownload: */
/* Pointer to the AC48 boot kernel download software */
/* to be downloaded. */
/* int KernelSize: */
/* This value can vary according to kernel version. */
/* const char *ProgramDownload: */
/* Pointer to the AC48 operational software */
/* to be downloaded. */
/* Output : int: */
/* 0 - (AC_OK) Boot Complete successfully */
/* after (AC48_TIME_OUT-TimeOut) iterations */
/* 1 - (AC_ERROR) Program Download failed */
/* 999 - TIME_OUT_ERROR (Failed after AC48_TIME_OUT */
/* iterations) */
/*======================================================================*/
int Ac48xxBootCompletely(int DeviceIndex, const char *KernelDownload,
int KernelSize, const char *ProgramDownload)
{
int Status;
int TimeOut = AC48_TIME_OUT;
Ac48xxKernelDownload(DeviceIndex, KernelDownload, KernelSize);
while(TimeOut)
{
Status = Ac48xxProgramDownload(DeviceIndex, &ProgramDownload);
if(Status != (-1))
return Status;
TimeOut--;
Ac48xxResponseDelay();
}
return TIME_OUT_ERROR; /* Boot Time-out Error */
}
/*======================================================================*/
/* Name : Ac48xxBootForDebugging */
/*======================================================================*/
/* Purpose : Same as Ac48xxBoot, plus debugging report of Program */
/* download. */
/* Inputs : Same as at Ac48xxBoot function, plus two parameters: */
/* ProgramDownloadStructure: */
/* A pointer to the begining of the first Block of */
/* Program Download Structure. */
/* BlockStructureFile: */
/* A text file Handle. The function writes to this */
/* file a list of Downloaded-Block's length and */
/* offset. This File reflects the Program Download */
/* process, include re'entrances, as a result of */
/* 'PACKET_FULL', end, finally 'LAST_STAGE_COMPLETED'. */
/*======================================================================*/
int Ac48xxBootForDebugging(int DeviceIndex, const char *KernelDownload,
int KernelSize, const char **ProgramDownload,
const char *ProgramDownloadStructure,
int Stage, TWaitMode WaitMode,
FILE *BlockStructureFile)
{
int Status;
if((Stage == FIRST_STAGE) && BlockStructureFile)
fprintf(BlockStructureFile, "<Block Offset>: <Word[0]> <Word[1]> <W0rd[2](BlockLength-5)> <W0rd[3]> <W0rd[4]> \n\n");
if(Stage != (-1))
Ac48xxKernelDownload(DeviceIndex, KernelDownload, KernelSize);
do
Status = Ac48xxProgramDownloadForDebugging(DeviceIndex,
ProgramDownload,
ProgramDownloadStructure,
BlockStructureFile);
while((WaitMode == WAIT_PACKET_EMPTY) && (Status == (-1)));
return Status; /* ERROR( 1 ) / (-1) / LAST_STAGE_COMPLETED( 0 ) */
}
/*======================================================================*/
/* Name : Ac48xxBootCompletelyForDebugging */
/*======================================================================*/
/* Purpose : Same as Ac48xxBoot, plus debugging report of Program */
/* download. */
/* Inputs : int DeviceIndex: */
/* Device index to be initialized. */
/* const char *KernelDownload: */
/* Pointer to the AC48 boot kernel download software */
/* to be downloaded. */
/* int KernelSize: */
/* This value can vary according to kernel version. */
/* const char *ProgramDownload: */
/* Pointer to the AC48 operational software */
/* to be downloaded. */
/* BlocksStructureFile: */
/* A text file Handle. The function writes to this */
/* file a list of Downloaded-Block's length and */
/* offset. This File reflects the Program Download */
/* process, include re'entrances, as a result of */
/* 'PACKET_FULL', end, finally 'LAST_STAGE_COMPLETED'. */
/* Output : int: */
/* 0 - (AC_OK) Boot Complete successfully */
/* after (AC48_TIME_OUT-TimeOut) iterations */
/* 1 - (AC_ERROR) Program Download failed */
/* 999 - TIME_OUT_ERROR (Failed after AC48_TIME_OUT */
/* iterations) */
/*======================================================================*/
int Ac48xxBootCompletelyForDebugging(int DeviceIndex, const char *KernelDownload,
int KernelSize, const char *ProgramDownload,
FILE *BlocksStructureFile)
{
int Status;
int TimeOut = AC48_TIME_OUT;
const char *ProgramDownloadPointer = ProgramDownload;
if(BlocksStructureFile)
fprintf(BlocksStructureFile, "<Block Offset>: <Word[0]> <Word[1]> <W0rd[2](BlockLength-5)> <W0rd[3]> <W0rd[4]> \n\n");
Ac48xxKernelDownload(DeviceIndex, KernelDownload, KernelSize);
while(TimeOut)
{
Status = Ac48xxProgramDownloadForDebugging(DeviceIndex, &ProgramDownloadPointer,
ProgramDownload, BlocksStructureFile);
if(Status == AC_OK)
{
fprintf(BlocksStructureFile, " Boot Complete successfully after %X iterations", (AC48_TIME_OUT-TimeOut));
return AC_OK;
}
if(Status == AC_ERROR)
{
fprintf(BlocksStructureFile, " Boot Failed !!!");
return AC_ERROR;
}
TimeOut--;
Ac48xxResponseDelay();
}
fprintf(BlocksStructureFile, " Boot Time-out Error (Failed after %X iterations)", AC48_TIME_OUT);
return TIME_OUT_ERROR;
}
/*======================================================================*/
/* Name : Ac48xxBIT */
/*======================================================================*/
/* Purpose : Perform Memory Test for the AC48. */
/* */
/* Inputs : int DeviceIndex: */
/* Device index to be tested. */
/* const char *KernelDownload: */
/* Pointer to the AC48 boot kernel download software */
/* to be downloaded. */
/* int KernelSize: */
/* This value can vary according to kernel version. */
/* const char **BITDownload: */
/* Address of Pointer to the AC48 'Built In Test' */
/* software to be downloaded. */
/* int Stage: */
/* This parameter is relevant only when WaitMode equal */
/* to "DONT_WAIT_PACKET_EMPTY". This parameter helps */
/* the watch-dog mechanism to let the AC48 complete */
/* the Memory Test. */
/* TWaitMode WaitMode: */
/* Wait / don't wait to "packet-empty". */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -