Commit b845d086 authored by Armin Schindler's avatar Armin Schindler Committed by Linus Torvalds

[PATCH] Eicon driver: remove unused code

Remove code from platform independent code, which is not used
in Linux.
Signed-off-by: default avatarArmin Schindler <armin@melware.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 240b7934
...@@ -227,10 +227,6 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e) ...@@ -227,10 +227,6 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e)
if (pI->descriptor_number >= 0) { if (pI->descriptor_number >= 0) {
dword dma_magic; dword dma_magic;
void* local_addr; void* local_addr;
#if 0
DBG_TRC(("A(%d) dma_alloc(%d)",
IoAdapter->ANum, pI->descriptor_number))
#endif
diva_get_dma_map_entry (\ diva_get_dma_map_entry (\
(struct _diva_dma_map_entry*)IoAdapter->dma_map, (struct _diva_dma_map_entry*)IoAdapter->dma_map,
pI->descriptor_number, pI->descriptor_number,
...@@ -243,9 +239,6 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e) ...@@ -243,9 +239,6 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e)
} }
} else if ((pI->operation == IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE) && } else if ((pI->operation == IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE) &&
(pI->descriptor_number >= 0)) { (pI->descriptor_number >= 0)) {
#if 0
DBG_TRC(("A(%d) dma_free(%d)", IoAdapter->ANum, pI->descriptor_number))
#endif
diva_free_dma_map_entry((struct _diva_dma_map_entry*)IoAdapter->dma_map, diva_free_dma_map_entry((struct _diva_dma_map_entry*)IoAdapter->dma_map,
pI->descriptor_number); pI->descriptor_number);
pI->descriptor_number = -1; pI->descriptor_number = -1;
...@@ -369,9 +362,6 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e) ...@@ -369,9 +362,6 @@ void request(PISDN_ADAPTER IoAdapter, ENTITY * e)
} }
if ( IoAdapter ) if ( IoAdapter )
{ {
#if 0
DBG_FTL(("xdi: unknown Req 0 / Rc %d !", e->Rc))
#endif
return ; return ;
} }
} }
......
...@@ -359,506 +359,9 @@ int qBri_FPGA_download (PISDN_ADAPTER IoAdapter) { ...@@ -359,506 +359,9 @@ int qBri_FPGA_download (PISDN_ADAPTER IoAdapter) {
return (1) ; return (1) ;
} }
#if !defined(DIVA_USER_MODE_CARD_CONFIG) /* { */
/* --------------------------------------------------------------------------
Download protocol code to the adapter
-------------------------------------------------------------------------- */
static int qBri_protocol_load (PISDN_ADAPTER BaseIoAdapter, PISDN_ADAPTER IoAdapter) {
PISDN_ADAPTER HighIoAdapter;
byte *p;
dword FileLength ;
dword *sharedRam, *File;
dword Addr, ProtOffset, SharedRamOffset, i;
dword tasks = BaseIoAdapter->tasks ;
int factor = (tasks == 1) ? 1 : 2;
if (!(File = (dword *)xdiLoadArchive (IoAdapter, &FileLength, 0))) {
return (0) ;
}
IoAdapter->features = diva_get_protocol_file_features ((byte*)File,
OFFS_PROTOCOL_ID_STRING,
IoAdapter->ProtocolIdString,
sizeof(IoAdapter->ProtocolIdString)) ;
IoAdapter->a.protocol_capabilities = IoAdapter->features ;
DBG_LOG(("Loading %s", IoAdapter->ProtocolIdString))
ProtOffset = IoAdapter->ControllerNumber * (IoAdapter->MemorySize >> factor);
SharedRamOffset = (IoAdapter->MemorySize >> factor) - MQ_SHARED_RAM_SIZE;
Addr = ((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR]))
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 1])) << 8)
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 2])) << 16)
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 3])) << 24) ;
if ( Addr != 0 )
{
IoAdapter->DspCodeBaseAddr = (Addr + 3) & (~3) ;
IoAdapter->MaxDspCodeSize = (MQ_UNCACHED_ADDR (ProtOffset + SharedRamOffset) -
IoAdapter->DspCodeBaseAddr) & ((IoAdapter->MemorySize >> factor) - 1);
i = 0 ;
while ( BaseIoAdapter->QuadroList->QuadroAdapter[i]->ControllerNumber != tasks - 1 )
i++ ;
HighIoAdapter = BaseIoAdapter->QuadroList->QuadroAdapter[i] ;
Addr = HighIoAdapter->DspCodeBaseAddr ;
if (tasks == 1) {
((byte *) File)[OFFS_DIVA_INIT_TASK_COUNT] =(byte)1;
((byte *) File)[OFFS_DIVA_INIT_TASK_COUNT+1] = (byte)BaseIoAdapter->cardType;
}
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR] = (byte) Addr ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 1] = (byte)(Addr >> 8) ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 2] = (byte)(Addr >> 16) ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 3] = (byte)(Addr >> 24) ;
IoAdapter->InitialDspInfo = 0x80 ;
}
else
{
if ( IoAdapter->features & PROTCAP_VOIP )
{
IoAdapter->DspCodeBaseAddr = MQ_CACHED_ADDR (ProtOffset + SharedRamOffset - MQ_VOIP_MAX_DSP_CODE_SIZE) ;
IoAdapter->MaxDspCodeSize = MQ_VOIP_MAX_DSP_CODE_SIZE ;
}
else if ( IoAdapter->features & PROTCAP_V90D )
{
IoAdapter->DspCodeBaseAddr = MQ_CACHED_ADDR (ProtOffset + SharedRamOffset - MQ_V90D_MAX_DSP_CODE_SIZE) ;
IoAdapter->MaxDspCodeSize = (IoAdapter->ControllerNumber == tasks - 1) ? MQ_V90D_MAX_DSP_CODE_SIZE : 0 ;
}
else
{
IoAdapter->DspCodeBaseAddr = MQ_CACHED_ADDR (ProtOffset + SharedRamOffset - MQ_ORG_MAX_DSP_CODE_SIZE) ;
IoAdapter->MaxDspCodeSize = (IoAdapter->ControllerNumber == tasks - 1) ? MQ_ORG_MAX_DSP_CODE_SIZE : 0 ;
}
IoAdapter->InitialDspInfo = (MQ_CACHED_ADDR (ProtOffset + SharedRamOffset -
MQ_ORG_MAX_DSP_CODE_SIZE) - IoAdapter->DspCodeBaseAddr) >> 14 ;
}
DBG_LOG(("%d: DSP code base 0x%08lx, max size 0x%08lx (%08lx,%02x)",
IoAdapter->ControllerNumber,
IoAdapter->DspCodeBaseAddr, IoAdapter->MaxDspCodeSize,
Addr, IoAdapter->InitialDspInfo))
if (FileLength > ((IoAdapter->DspCodeBaseAddr - MQ_CACHED_ADDR (ProtOffset)) & (IoAdapter->MemorySize - 1)) )
{
xdiFreeFile (File) ;
DBG_FTL(("Protocol code '%s' too long (%ld)",
&IoAdapter->Protocol[0], FileLength))
return (0) ;
}
IoAdapter->downloadAddr = 0 ;
p = DIVA_OS_MEM_ATTACH_RAM(IoAdapter);
sharedRam = (dword *)&p[IoAdapter->downloadAddr & (IoAdapter->MemorySize - 1)];
memcpy (sharedRam, File, FileLength) ;
DBG_TRC(("Download addr 0x%08x len %ld - virtual 0x%08x",
IoAdapter->downloadAddr, FileLength, sharedRam))
if ( memcmp (sharedRam, File, FileLength) )
{
DBG_FTL(("%s: Memory test failed!", IoAdapter->Properties.Name))
DBG_FTL(("File=0x%x, sharedRam=0x%x", File, sharedRam))
DBG_BLK(( (char *)File, 256))
DBG_BLK(( (char *)sharedRam, 256))
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
xdiFreeFile (File) ;
return (0) ;
}
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
xdiFreeFile (File) ;
return (1) ;
}
/* --------------------------------------------------------------------------
DSP Code download
-------------------------------------------------------------------------- */
static long qBri_download_buffer (OsFileHandle *fp, long length, void **addr) {
PISDN_ADAPTER BaseIoAdapter = (PISDN_ADAPTER)fp->sysLoadDesc ;
PISDN_ADAPTER IoAdapter;
word i ;
dword *sharedRam ;
byte *p;
i = 0 ;
do
{
IoAdapter = BaseIoAdapter->QuadroList->QuadroAdapter[i++] ;
} while ( (i < BaseIoAdapter->tasks)
&& (((dword) length) > IoAdapter->DspCodeBaseAddr +
IoAdapter->MaxDspCodeSize - IoAdapter->downloadAddr) );
*addr = (void *)IoAdapter->downloadAddr ;
if ( ((dword) length) > IoAdapter->DspCodeBaseAddr +
IoAdapter->MaxDspCodeSize - IoAdapter->downloadAddr )
{
DBG_FTL(("%s: out of card memory during DSP download (0x%X)",
IoAdapter->Properties.Name,
IoAdapter->downloadAddr + length))
return (-1) ;
}
p = DIVA_OS_MEM_ATTACH_RAM(BaseIoAdapter);
sharedRam = (dword*)&p[IoAdapter->downloadAddr & (IoAdapter->MemorySize - 1)];
if ( fp->sysFileRead (fp, sharedRam, length) != length ) {
DIVA_OS_MEM_DETACH_RAM(BaseIoAdapter, p);
return (-1) ;
}
DIVA_OS_MEM_DETACH_RAM(BaseIoAdapter, p);
IoAdapter->downloadAddr += length ;
IoAdapter->downloadAddr = (IoAdapter->downloadAddr + 3) & (~3) ;
return (0) ;
}
/******************************************************************************/
static dword qBri_telindus_load (PISDN_ADAPTER BaseIoAdapter) {
PISDN_ADAPTER IoAdapter = 0;
PISDN_ADAPTER HighIoAdapter = NULL ;
char *error ;
OsFileHandle *fp ;
t_dsp_portable_desc download_table[DSP_MAX_DOWNLOAD_COUNT] ;
word download_count, i ;
dword *sharedRam ;
dword FileLength ;
byte *p;
if ( !(fp = OsOpenFile (DSP_TELINDUS_FILE)) ) {
DBG_FTL(("qBri_telindus_load: %s not found!", DSP_TELINDUS_FILE))
return (0) ;
}
for ( i = 0 ; i < BaseIoAdapter->tasks ; ++i )
{
IoAdapter = BaseIoAdapter->QuadroList->QuadroAdapter[i] ;
IoAdapter->downloadAddr = IoAdapter->DspCodeBaseAddr ;
if ( IoAdapter->ControllerNumber == BaseIoAdapter->tasks - 1 )
{
HighIoAdapter = IoAdapter ;
HighIoAdapter->downloadAddr = (HighIoAdapter->downloadAddr
+ sizeof(dword) + sizeof(download_table) + 3) & (~3) ;
}
}
FileLength = fp->sysFileSize ;
fp->sysLoadDesc = (void *)BaseIoAdapter ;
fp->sysCardLoad = qBri_download_buffer ;
download_count = DSP_MAX_DOWNLOAD_COUNT ;
memset (&download_table[0], '\0', sizeof(download_table)) ;
/*
* set start address for download
*/
error = dsp_read_file (fp, (word)(IoAdapter->cardType),
&download_count, NULL, &download_table[0]) ;
if ( error )
{
DBG_FTL(("download file error: %s", error))
OsCloseFile (fp) ;
return (0) ;
}
OsCloseFile (fp) ;
/*
* store # of download files extracted from the archive and download table
*/
HighIoAdapter->downloadAddr = HighIoAdapter->DspCodeBaseAddr ;
p = DIVA_OS_MEM_ATTACH_RAM(BaseIoAdapter);
sharedRam = (dword *)&p[HighIoAdapter->downloadAddr & (IoAdapter->MemorySize - 1)];
WRITE_DWORD(&(sharedRam[0]), (dword)download_count);
memcpy (&sharedRam[1], &download_table[0], sizeof(download_table)) ;
/* memory check */
if ( memcmp (&sharedRam[1], &download_table, download_count) ) {
DBG_FTL(("%s: Dsp Memory test failed!", IoAdapter->Properties.Name))
}
DIVA_OS_MEM_DETACH_RAM(BaseIoAdapter, p);
return (FileLength) ;
}
/*
Load SDP tasks to the card
Return start address of image on succesful load
Return zero in case of problem
INPUT:
task -> name of the image containing this task
link_addr -> pointer to start of previous task
*/
static byte* qBri_sdp_load (PISDN_ADAPTER BaseIoAdapter,
char* task,
byte* link_addr) {
OsFileHandle *fp;
dword FileLength;
byte tmp[sizeof(dword)];
dword gp_addr;
dword entry_addr;
dword start_addr = 0;
dword phys_start_addr;
dword end_addr;
byte* sharedRam = 0;
byte *p;
if (task) {
if (!(fp = OsOpenFile (task))) {
DBG_ERR(("Can't open [%s] image", task))
return (0);
}
if ((FileLength = fp->sysFileSize) < DIVA_MIPS_TASK_IMAGE_ID_STRING_OFFS) {
OsCloseFile (fp) ;
DBG_ERR(("Image [%s] too short", task))
return (0);
}
fp->sysFileSeek (fp, DIVA_MIPS_TASK_IMAGE_GP_OFFS, OS_SEEK_SET);
if (fp->sysFileRead (fp, tmp, sizeof(dword)) != sizeof(dword)) {
OsCloseFile (fp) ;
DBG_ERR(("Can't read image [%s]", task))
return (0);
}
gp_addr = ((dword)tmp[0]) |
(((dword)tmp[1]) << 8) |
(((dword)tmp[2]) << 16) |
(((dword)tmp[3]) << 24);
DBG_TRC(("Image [%s] GP = %08lx", task, gp_addr))
fp->sysFileSeek (fp, DIVA_MIPS_TASK_IMAGE_ENTRY_OFFS, OS_SEEK_SET);
if (fp->sysFileRead (fp, tmp, sizeof(dword)) != sizeof(dword)) {
OsCloseFile (fp) ;
DBG_ERR(("Can't read image [%s]", task))
return (0);
}
entry_addr = ((dword)tmp[0]) |
(((dword)tmp[1]) << 8) |
(((dword)tmp[2]) << 16) |
(((dword)tmp[3]) << 24);
DBG_TRC(("Image [%s] entry = %08lx", task, entry_addr))
fp->sysFileSeek (fp, DIVA_MIPS_TASK_IMAGE_LOAD_ADDR_OFFS, OS_SEEK_SET);
if (fp->sysFileRead (fp, tmp, sizeof(dword)) != sizeof(dword)) {
OsCloseFile (fp) ;
DBG_ERR(("Can't read image [%s]", task))
return (0);
}
start_addr = ((dword)tmp[0]) |
(((dword)tmp[1]) << 8) |
(((dword)tmp[2]) << 16) |
(((dword)tmp[3]) << 24);
DBG_TRC(("Image [%s] start = %08lx", task, start_addr))
fp->sysFileSeek (fp, DIVA_MIPS_TASK_IMAGE_END_ADDR_OFFS, OS_SEEK_SET);
if (fp->sysFileRead (fp, tmp, sizeof(dword)) != sizeof(dword)) {
OsCloseFile (fp) ;
DBG_ERR(("Can't read image [%s]", task))
return (0);
}
end_addr = ((dword)tmp[0]) |
(((dword)tmp[1]) << 8) |
(((dword)tmp[2]) << 16) |
(((dword)tmp[3]) << 24);
DBG_TRC(("Image [%s] end = %08lx", task, end_addr))
phys_start_addr = start_addr & 0x1fffffff;
if ((phys_start_addr + FileLength) >= BaseIoAdapter->MemorySize) {
OsCloseFile (fp) ;
DBG_ERR(("Image [%s] too long", task))
return (0);
}
fp->sysFileSeek (fp, 0, OS_SEEK_SET);
p = DIVA_OS_MEM_ATTACH_RAM(BaseIoAdapter);
sharedRam = &p[phys_start_addr];
if ((dword)fp->sysFileRead (fp, sharedRam, FileLength) != FileLength) {
DIVA_OS_MEM_DETACH_RAM(BaseIoAdapter, p);
OsCloseFile (fp) ;
DBG_ERR(("Can't read image [%s]", task))
return (0);
}
DIVA_OS_MEM_DETACH_RAM(BaseIoAdapter, p);
OsCloseFile (fp) ;
}
p = DIVA_OS_MEM_ATTACH_RAM(BaseIoAdapter);
if (!link_addr) {
link_addr = &p[OFFS_DSP_CODE_BASE_ADDR];
}
DBG_TRC(("Write task [%s] link %08lx at %08lx",
task ? task : "none",
start_addr,
link_addr - (byte*)&BaseIoAdapter->ram[0]))
link_addr[0] = (byte)(start_addr & 0xff);
link_addr[1] = (byte)((start_addr >> 8) & 0xff);
link_addr[2] = (byte)((start_addr >> 16) & 0xff);
link_addr[3] = (byte)((start_addr >> 24) & 0xff);
DIVA_OS_MEM_DETACH_RAM(BaseIoAdapter, p);
return (task ? &sharedRam[DIVA_MIPS_TASK_IMAGE_LINK_OFFS] : 0);
}
/* --------------------------------------------------------------------------
Load Card
-------------------------------------------------------------------------- */
static int load_qBri_hardware (PISDN_ADAPTER IoAdapter) {
dword i, offset, controller ;
word *signature ;
int factor = (IoAdapter->tasks == 1) ? 1 : 2;
byte *p;
PISDN_ADAPTER Slave ;
if (
!IoAdapter->QuadroList
|| ( (IoAdapter->cardType != CARDTYPE_DIVASRV_Q_8M_PCI)
&& (IoAdapter->cardType != CARDTYPE_DIVASRV_VOICE_Q_8M_PCI)
&& (IoAdapter->cardType != CARDTYPE_DIVASRV_Q_8M_V2_PCI)
&& (IoAdapter->cardType != CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI)
&& (IoAdapter->cardType != CARDTYPE_DIVASRV_B_2M_V2_PCI)
&& (IoAdapter->cardType != CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI)
&& (IoAdapter->cardType != CARDTYPE_DIVASRV_B_2F_PCI) ) )
{
return (0) ;
}
/*
* Check for first instance
*/
if ( IoAdapter->ControllerNumber > 0 )
return (1) ;
/*
* first initialize the onboard FPGA
*/
if ( !qBri_FPGA_download (IoAdapter) )
return (0) ;
for ( i = 0; i < IoAdapter->tasks; i++ )
{
Slave = IoAdapter->QuadroList->QuadroAdapter[i] ;
Slave->fpga_features = IoAdapter->fpga_features ;
}
/*
* download protocol code for all instances
*/
controller = IoAdapter->tasks;
do
{
controller-- ;
i = 0 ;
while ( IoAdapter->QuadroList->QuadroAdapter[i]->ControllerNumber != controller )
i++ ;
/*
* calculate base address for instance
*/
Slave = IoAdapter->QuadroList->QuadroAdapter[i] ;
offset = Slave->ControllerNumber * (IoAdapter->MemorySize >> factor) ;
Slave->Address = &IoAdapter->Address[offset] ;
Slave->ram = &IoAdapter->ram[offset] ;
Slave->reset = IoAdapter->reset ;
Slave->ctlReg = IoAdapter->ctlReg ;
Slave->prom = IoAdapter->prom ;
Slave->Config = IoAdapter->Config ;
Slave->Control = IoAdapter->Control ;
if ( !qBri_protocol_load (IoAdapter, Slave) )
return (0) ;
} while (controller != 0) ;
/*
* download only one copy of the DSP code
*/
if (IoAdapter->cardType != CARDTYPE_DIVASRV_B_2F_PCI) {
if ( !qBri_telindus_load (IoAdapter) )
return (0) ;
} else {
byte* link_addr = 0;
link_addr = qBri_sdp_load (IoAdapter, DIVA_BRI2F_SDP_1_NAME, link_addr);
link_addr = qBri_sdp_load (IoAdapter, DIVA_BRI2F_SDP_2_NAME, link_addr);
if (!link_addr) {
qBri_sdp_load (IoAdapter, 0, link_addr);
}
}
/*
* copy configuration parameters
*/
for ( i = 0 ; i < IoAdapter->tasks ; ++i )
{
Slave = IoAdapter->QuadroList->QuadroAdapter[i] ;
Slave->ram += (IoAdapter->MemorySize >> factor) - MQ_SHARED_RAM_SIZE ;
p = DIVA_OS_MEM_ATTACH_RAM(Slave);
DBG_TRC(("Configure instance %d shared memory @ 0x%08lx",
Slave->ControllerNumber, p))
memset (p, '\0', 256) ;
DIVA_OS_MEM_DETACH_RAM(Slave, p);
diva_configure_protocol (Slave);
}
/*
* start adapter
*/
start_qBri_hardware (IoAdapter) ;
p = DIVA_OS_MEM_ATTACH_RAM(IoAdapter);
signature = (word *)(&p[0x1E]) ;
/*
* wait for signature in shared memory (max. 3 seconds)
*/
for ( i = 0 ; i < 300 ; ++i )
{
diva_os_wait (10) ;
if ( signature[0] == 0x4447 )
{
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
DBG_TRC(("Protocol startup time %d.%02d seconds",
(i / 100), (i % 100) ))
return (1) ;
}
}
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
DBG_FTL(("%s: Adapter selftest failed (0x%04X)!",
IoAdapter->Properties.Name, signature[0] >> 16))
qBri_cpu_trapped (IoAdapter) ;
return (FALSE) ;
}
#else /* } { */
static int load_qBri_hardware (PISDN_ADAPTER IoAdapter) { static int load_qBri_hardware (PISDN_ADAPTER IoAdapter) {
return (0); return (0);
} }
#endif /* } */
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Card ISR Card ISR
......
...@@ -119,356 +119,9 @@ static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -119,356 +119,9 @@ static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) {
outpp (p, 0x00) ; /* clear int, halt cpu */ outpp (p, 0x00) ; /* clear int, halt cpu */
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
} }
#if !defined(DIVA_USER_MODE_CARD_CONFIG) /* { */
/* ---------------------------------------------------------------------
Load protocol on the card
--------------------------------------------------------------------- */
static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
dword FileLength ;
word test, *File = NULL ;
byte* addrHi, *addrLo, *ioaddr ;
char *FileName = &IoAdapter->Protocol[0] ;
dword Addr, i ;
byte *Port;
/* -------------------------------------------------------------------
Try to load protocol code. 'File' points to memory location
that does contain entire protocol code
------------------------------------------------------------------- */
if ( !(File = (word *)xdiLoadArchive (IoAdapter, &FileLength, 0)) )
return (0) ;
/* -------------------------------------------------------------------
Get protocol features and calculate load addresses
------------------------------------------------------------------- */
IoAdapter->features = diva_get_protocol_file_features ((byte*)File,
OFFS_PROTOCOL_ID_STRING,
IoAdapter->ProtocolIdString,
sizeof(IoAdapter->ProtocolIdString));
IoAdapter->a.protocol_capabilities = IoAdapter->features ;
DBG_LOG(("Loading %s", IoAdapter->ProtocolIdString))
Addr = ((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR]))
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 1])) << 8)
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 2])) << 16)
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 3])) << 24) ;
if ( Addr != 0 )
{
IoAdapter->DspCodeBaseAddr = (Addr + 3) & (~3) ;
IoAdapter->MaxDspCodeSize = (BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + IoAdapter->MemorySize -
BRI_SHARED_RAM_SIZE)
- IoAdapter->DspCodeBaseAddr) & (IoAdapter->MemorySize - 1) ;
Addr = IoAdapter->DspCodeBaseAddr ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR] = (byte) Addr ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 1] = (byte)(Addr >> 8) ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 2] = (byte)(Addr >> 16) ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 3] = (byte)(Addr >> 24) ;
IoAdapter->InitialDspInfo = 0x80 ;
}
else
{
if ( IoAdapter->features & PROTCAP_V90D )
IoAdapter->MaxDspCodeSize = BRI_V90D_MAX_DSP_CODE_SIZE ;
else
IoAdapter->MaxDspCodeSize = BRI_ORG_MAX_DSP_CODE_SIZE ;
IoAdapter->DspCodeBaseAddr = BRI_CACHED_ADDR (IoAdapter->MemoryBase + IoAdapter->MemorySize -
BRI_SHARED_RAM_SIZE - IoAdapter->MaxDspCodeSize);
IoAdapter->InitialDspInfo = (IoAdapter->MaxDspCodeSize - BRI_ORG_MAX_DSP_CODE_SIZE) >> 14 ;
}
DBG_LOG(("DSP code base 0x%08lx, max size 0x%08lx (%08lx,%02x)",
IoAdapter->DspCodeBaseAddr, IoAdapter->MaxDspCodeSize,
Addr, IoAdapter->InitialDspInfo))
if ( FileLength > ((IoAdapter->DspCodeBaseAddr -
BRI_CACHED_ADDR (IoAdapter->MemoryBase)) & (IoAdapter->MemorySize - 1)) )
{
xdiFreeFile (File);
DBG_FTL(("Protocol code '%s' too big (%ld)", FileName, FileLength))
return (0) ;
}
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ;
addrLo = Port + ADDR ;
ioaddr = Port + DATA ;
/*
* set start address for download (use autoincrement mode !)
*/
outpp (addrHi, 0) ;
outppw (addrLo, 0) ;
for ( i = 0 ; i < FileLength ; i += 2 )
{
if ( (i & 0x0000FFFF) == 0 )
{
outpp (addrHi, (byte)(i >> 16)) ;
}
outppw (ioaddr, File[i/2]) ;
}
/*
* memory test without second load of file
*/
outpp (addrHi, 0) ;
outppw (addrLo, 0) ;
for ( i = 0 ; i < FileLength ; i += 2 )
{
if ( (i & 0x0000FFFF) == 0 )
{
outpp (addrHi, (byte)(i >> 16)) ;
}
test = inppw (ioaddr) ;
if ( test != File[i/2] )
{
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_FTL(("%s: Memory test failed! (%d - 0x%04X/0x%04X)",
IoAdapter->Properties.Name, i, test, File[i/2]))
xdiFreeFile (File);
return (0) ;
}
}
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
xdiFreeFile (File);
return (FileLength) ;
}
/******************************************************************************/
typedef struct
{
PISDN_ADAPTER IoAdapter ;
byte* AddrLo ;
byte* AddrHi ;
word* Data ;
dword DownloadPos ;
} bri_download_info ;
static long bri_download_buffer (OsFileHandle *fp, long length, void **addr) {
int buffer_size = 2048*sizeof(word);
word *buffer = (word*)diva_os_malloc (0, buffer_size);
bri_download_info *info ;
word test ;
long i, len, page ;
if (!buffer) {
DBG_ERR(("A: out of memory, s_bri at %d", __LINE__))
return (-1);
}
info = (bri_download_info *)fp->sysLoadDesc ;
*addr = (void *)info->DownloadPos ;
if ( ((dword) length) > info->IoAdapter->DspCodeBaseAddr +
info->IoAdapter->MaxDspCodeSize - info->DownloadPos )
{
DBG_FTL(("%s: out of card memory during DSP download (0x%X)",
info->IoAdapter->Properties.Name,
info->DownloadPos + length))
diva_os_free (0, buffer);
return (-1) ;
}
for ( len = 0 ; length > 0 ; length -= len )
{
len = (length > buffer_size ? buffer_size : length) ;
page = ((long)(info->DownloadPos) + len) & 0xFFFF0000 ;
if ( page != (long)(info->DownloadPos & 0xFFFF0000) )
{
len = 0x00010000 - (((long)info->DownloadPos) & 0x0000FFFF) ;
}
if ( fp->sysFileRead (fp, &buffer[0], len) != len ) {
diva_os_free (0, buffer);
return (-1) ;
}
outpp (info->AddrHi, (byte)(info->DownloadPos >> 16)) ;
outppw (info->AddrLo, (word)info->DownloadPos) ;
outppw_buffer (info->Data, &buffer[0], (len + 1)) ;
/*
* memory test without second load of file
*/
outpp (info->AddrHi, (byte)(info->DownloadPos >> 16)) ;
outppw (info->AddrLo, (word)info->DownloadPos) ;
for ( i = 0 ; i < len ; i += 2 )
{
if ( (test = inppw (info->Data)) != buffer[i/2] )
{
DBG_FTL(("%s: Memory test failed! (0x%lX - 0x%04X/0x%04X)",
info->IoAdapter->Properties.Name,
info->DownloadPos + i, test, buffer[i/2]))
diva_os_free (0, buffer);
return (-2) ;
}
}
info->DownloadPos += len ;
}
info->DownloadPos = (info->DownloadPos + 3) & (~3) ;
diva_os_free (0, buffer);
return (0) ;
}
/******************************************************************************/
static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
{
bri_download_info *pinfo =\
(bri_download_info*)diva_os_malloc(0, sizeof(*pinfo));
char *error ;
OsFileHandle *fp ;
t_dsp_portable_desc download_table[DSP_MAX_DOWNLOAD_COUNT] ;
word download_count ;
dword FileLength ;
byte *Port;
if (!pinfo) {
DBG_ERR (("A: out of memory s_bri at %d", __LINE__))
return (0);
}
if (!(fp = OsOpenFile (DspTelindusFile))) {
diva_os_free (0, pinfo);
return (0) ;
}
FileLength = fp->sysFileSize ;
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
pinfo->IoAdapter = IoAdapter ;
pinfo->AddrLo = Port + ADDR ;
pinfo->AddrHi = Port + (IoAdapter->Properties.Bus == BUS_PCI ? M_PCI_ADDRH : ADDRH);
pinfo->Data = (word*)(Port + DATA) ;
pinfo->DownloadPos = (IoAdapter->DspCodeBaseAddr +\
sizeof(dword) + sizeof(download_table) + 3) & (~3) ;
fp->sysLoadDesc = (void *)pinfo;
fp->sysCardLoad = bri_download_buffer ;
download_count = DSP_MAX_DOWNLOAD_COUNT ;
memset (&download_table[0], '\0', sizeof(download_table)) ;
/*
* set start address for download (use autoincrement mode !)
*/
error = dsp_read_file (fp, (word)(IoAdapter->cardType),
&download_count, NULL, &download_table[0]) ;
if ( error )
{
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_FTL(("download file error: %s", error))
OsCloseFile (fp) ;
diva_os_free (0, pinfo);
return (0) ;
}
OsCloseFile (fp) ;
/*
* store # of separate download files extracted from archive
*/
pinfo->DownloadPos = IoAdapter->DspCodeBaseAddr ;
outpp (pinfo->AddrHi, (byte)(pinfo->DownloadPos >> 16)) ;
outppw (pinfo->AddrLo, (word)pinfo->DownloadPos) ;
outppw (pinfo->Data, (word)download_count) ;
outppw (pinfo->Data, (word)0) ;
/*
* copy download table to board
*/
outppw_buffer (pinfo->Data, &download_table[0], sizeof(download_table)) ;
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
diva_os_free (0, pinfo);
return (FileLength) ;
}
/******************************************************************************/
static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
dword i ;
byte* addrHi, *addrLo, *ioaddr, *p ;
dword test ;
byte *Port;
if ( IoAdapter->Properties.Card != CARD_MAE )
{
return (FALSE) ;
}
reset_bri_hardware (IoAdapter) ;
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port + ((IoAdapter->Properties.Bus==BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = Port + ADDR ;
ioaddr = Port + DATA ;
diva_os_wait (100);
/*
* recover
*/
outpp (addrHi, (byte) 0) ;
outppw (addrLo, (word) 0) ;
outppw (ioaddr, (word) 0) ;
/*
* clear shared memory
*/
outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + \
IoAdapter->MemorySize - BRI_SHARED_RAM_SIZE)) >> 16)) ;
outppw (addrLo, 0) ;
for ( i = 0 ; i < 0x8000 ; outppw (ioaddr, 0), ++i ) ;
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
diva_os_wait (100) ;
/*
* download protocol and dsp files
*/
switch ( IoAdapter->protocol_id ) {
default:
if ( !xdiSetProtocol (IoAdapter, IoAdapter->ProtocolSuffix) )
return (FALSE) ;
if ( !bri_protocol_load (IoAdapter) )
return (FALSE) ;
if ( !bri_telindus_load (IoAdapter, DSP_TELINDUS_FILE) )
return (FALSE) ;
break ;
case PROTTYPE_QSIG:
case PROTTYPE_CORNETN:
if ( !xdiSetProtocol (IoAdapter, IoAdapter->ProtocolSuffix) )
return (FALSE) ;
if (IoAdapter->ProtocolSuffix && *IoAdapter->ProtocolSuffix) {
sprintf (&IoAdapter->Protocol[0],
"TE_QSIG.%s", IoAdapter->ProtocolSuffix) ;
}
DBG_TRC(("xdiSetProtocol: %s firmware '%s' archive '%s'",
IoAdapter->Properties.Name,
&IoAdapter->Protocol[0], &IoAdapter->Archive[0]))
if ( !bri_protocol_load (IoAdapter) )
return (FALSE) ;
if ( !bri_telindus_load (IoAdapter, DSP_QSIG_TELINDUS_FILE) )
return (FALSE) ;
break ;
}
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port + ((IoAdapter->Properties.Bus==BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = Port + ADDR ;
ioaddr = Port + DATA ;
/*
* clear signature
*/
outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + \
IoAdapter->MemorySize - BRI_SHARED_RAM_SIZE)) >> 16)) ;
outppw (addrLo, 0x1e) ;
outpp (ioaddr, 0) ;
outpp (ioaddr, 0) ;
/*
* copy parameters
*/
diva_configure_protocol (IoAdapter);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/*
* start the protocol code
*/
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
outpp (p, 0x08) ;
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
/*
* wait for signature (max. 3 seconds)
*/
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port + ((IoAdapter->Properties.Bus==BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = Port + ADDR ;
ioaddr = Port + DATA ;
for ( i = 0 ; i < 300 ; ++i )
{
diva_os_wait (10) ;
outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + \
IoAdapter->MemorySize - BRI_SHARED_RAM_SIZE)) >> 16)) ;
outppw (addrLo, 0x1e) ;
test = (dword)inppw (ioaddr) ;
if ( test == 0x4447 )
{
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_TRC(("Protocol startup time %d.%02d seconds",
(i / 100), (i % 100) ))
return (TRUE) ;
}
}
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_FTL(("%s: Adapter selftest failed (0x%04X)!",
IoAdapter->Properties.Name, test))
bri_cpu_trapped (IoAdapter) ;
return (FALSE) ;
}
#else /* } { */
static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
return (0); return (0);
} }
#endif /* } */
/******************************************************************************/ /******************************************************************************/
static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) { static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
byte __iomem *p; byte __iomem *p;
......
...@@ -122,371 +122,9 @@ static void stop_pri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -122,371 +122,9 @@ static void stop_pri_hardware (PISDN_ADAPTER IoAdapter) {
WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2); WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2);
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
} }
#if !defined(DIVA_USER_MODE_CARD_CONFIG) /* { */
/* -------------------------------------------------------------------------
Load protocol code to the PRI Card
------------------------------------------------------------------------- */
#define DOWNLOAD_ADDR(IoAdapter) (IoAdapter->downloadAddr & (IoAdapter->MemorySize - 1))
static int pri_protocol_load (PISDN_ADAPTER IoAdapter) {
dword FileLength ;
dword *File ;
dword *sharedRam ;
dword Addr ;
byte *p;
if (!(File = (dword *)xdiLoadArchive (IoAdapter, &FileLength, 0))) {
return (0) ;
}
IoAdapter->features = diva_get_protocol_file_features ((byte*)File,
OFFS_PROTOCOL_ID_STRING,
IoAdapter->ProtocolIdString,
sizeof(IoAdapter->ProtocolIdString)) ;
IoAdapter->a.protocol_capabilities = IoAdapter->features ;
DBG_LOG(("Loading %s", IoAdapter->ProtocolIdString))
Addr = ((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR]))
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 1])) << 8)
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 2])) << 16)
| (((dword)(((byte *) File)[OFFS_PROTOCOL_END_ADDR + 3])) << 24) ;
if ( Addr != 0 )
{
IoAdapter->DspCodeBaseAddr = (Addr + 3) & (~3) ;
IoAdapter->MaxDspCodeSize = (MP_UNCACHED_ADDR (IoAdapter->MemorySize)
- IoAdapter->DspCodeBaseAddr) & (IoAdapter->MemorySize - 1) ;
Addr = IoAdapter->DspCodeBaseAddr ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR] = (byte) Addr ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 1] = (byte)(Addr >> 8) ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 2] = (byte)(Addr >> 16) ;
((byte *) File)[OFFS_DSP_CODE_BASE_ADDR + 3] = (byte)(Addr >> 24) ;
IoAdapter->InitialDspInfo = 0x80 ;
}
else
{
if ( IoAdapter->features & PROTCAP_VOIP )
IoAdapter->MaxDspCodeSize = MP_VOIP_MAX_DSP_CODE_SIZE ;
else if ( IoAdapter->features & PROTCAP_V90D )
IoAdapter->MaxDspCodeSize = MP_V90D_MAX_DSP_CODE_SIZE ;
else
IoAdapter->MaxDspCodeSize = MP_ORG_MAX_DSP_CODE_SIZE ;
IoAdapter->DspCodeBaseAddr = MP_CACHED_ADDR (IoAdapter->MemorySize -
IoAdapter->MaxDspCodeSize) ;
IoAdapter->InitialDspInfo = (IoAdapter->MaxDspCodeSize
- MP_ORG_MAX_DSP_CODE_SIZE) >> 14 ;
}
DBG_LOG(("DSP code base 0x%08lx, max size 0x%08lx (%08lx,%02x)",
IoAdapter->DspCodeBaseAddr, IoAdapter->MaxDspCodeSize,
Addr, IoAdapter->InitialDspInfo))
if ( FileLength > ((IoAdapter->DspCodeBaseAddr -
MP_CACHED_ADDR (MP_PROTOCOL_OFFSET)) & (IoAdapter->MemorySize - 1)) )
{
xdiFreeFile (File);
DBG_FTL(("Protocol code '%s' too long (%ld)",
&IoAdapter->Protocol[0], FileLength))
return (0) ;
}
IoAdapter->downloadAddr = MP_UNCACHED_ADDR (MP_PROTOCOL_OFFSET) ;
p = DIVA_OS_MEM_ATTACH_RAM(IoAdapter);
sharedRam = (dword *)(&p[DOWNLOAD_ADDR(IoAdapter)]);
memcpy (sharedRam, File, FileLength) ;
if ( memcmp (sharedRam, File, FileLength) )
{
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
DBG_FTL(("%s: Memory test failed!", IoAdapter->Properties.Name))
xdiFreeFile (File);
return (0) ;
}
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
xdiFreeFile (File);
return (1) ;
}
/******************************************************************************/
/*------------------------------------------------------------------
Dsp related definitions
------------------------------------------------------------------ */
#define DSP_SIGNATURE_PROBE_WORD 0x5a5a
/*
** Checks presence of DSP on board
*/
static int
dsp_check_presence (volatile byte* addr, volatile byte* data, int dsp)
{
word pattern;
*(volatile word*)addr = 0x4000;
*(volatile word*)data = DSP_SIGNATURE_PROBE_WORD;
*(volatile word*)addr = 0x4000;
pattern = *(volatile word*)data;
if (pattern != DSP_SIGNATURE_PROBE_WORD) {
DBG_TRC(("W: DSP[%d] %04x(is) != %04x(should)",
dsp, pattern, DSP_SIGNATURE_PROBE_WORD))
return (-1);
}
*(volatile word*)addr = 0x4000;
*(volatile word*)data = ~DSP_SIGNATURE_PROBE_WORD;
*(volatile word*)addr = 0x4000;
pattern = *(volatile word*)data;
if (pattern != (word)~DSP_SIGNATURE_PROBE_WORD) {
DBG_ERR(("A: DSP[%d] %04x(is) != %04x(should)",
dsp, pattern, (word)~DSP_SIGNATURE_PROBE_WORD))
return (-2);
}
DBG_TRC (("DSP[%d] present", dsp))
return (0);
}
/*
** Check if DSP's are present and operating
** Information about detected DSP's is returned as bit mask
** Bit 0 - DSP1
** ...
** ...
** ...
** Bit 29 - DSP30
*/
static dword
diva_pri_detect_dsps (PISDN_ADAPTER IoAdapter)
{
byte* base;
byte* p;
dword ret = 0, DspCount = 0 ;
dword row_offset[] = {
0x00000000,
0x00000800, /* 1 - ROW 1 */
0x00000840, /* 2 - ROW 2 */
0x00001000, /* 3 - ROW 3 */
0x00001040, /* 4 - ROW 4 */
0x00000000 /* 5 - ROW 0 */
};
byte *dsp_addr_port, *dsp_data_port, row_state;
int dsp_row = 0, dsp_index, dsp_num;
IoAdapter->InitialDspInfo &= 0xffff ;
p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
if (!p)
{
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
return (0);
}
*(volatile byte*)(p) = _MP_RISC_RESET | _MP_DSP_RESET;
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
diva_os_wait (5) ;
base = DIVA_OS_MEM_ATTACH_CONTROL(IoAdapter);
for (dsp_num = 0; dsp_num < 30; dsp_num++) {
dsp_row = dsp_num / 7 + 1;
dsp_index = dsp_num % 7;
dsp_data_port = base;
dsp_addr_port = base;
dsp_data_port += row_offset[dsp_row];
dsp_addr_port += row_offset[dsp_row];
dsp_data_port += (dsp_index * 8);
dsp_addr_port += (dsp_index * 8) + 0x80;
if (!dsp_check_presence (dsp_addr_port, dsp_data_port, dsp_num+1)) {
ret |= (1 << dsp_num);
DspCount++ ;
}
}
DIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base);
p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
*(volatile byte*)(p) = _MP_RISC_RESET | _MP_LED1 | _MP_LED2;
diva_os_wait (50) ;
/*
Verify modules
*/
for (dsp_row = 0; dsp_row < 4; dsp_row++) {
row_state = (byte)((ret >> (dsp_row*7)) & 0x7F);
if (row_state && (row_state != 0x7F)) {
for (dsp_index = 0; dsp_index < 7; dsp_index++) {
if (!(row_state & (1 << dsp_index))) {
DBG_ERR (("A: MODULE[%d]-DSP[%d] failed", dsp_row+1, dsp_index+1))
}
}
}
}
if (!(ret & 0x10000000)) {
DBG_ERR (("A: ON BOARD-DSP[1] failed"))
}
if (!(ret & 0x20000000)) {
DBG_ERR (("A: ON BOARD-DSP[2] failed"))
}
/*
Print module population now
*/
DBG_LOG(("+-----------------------+"))
DBG_LOG(("| DSP MODULE POPULATION |"))
DBG_LOG(("+-----------------------+"))
DBG_LOG(("| 1 | 2 | 3 | 4 |"))
DBG_LOG(("+-----------------------+"))
DBG_LOG(("| %s | %s | %s | %s |",
((ret >> (0*7)) & 0x7F) ? "Y" : "N",
((ret >> (1*7)) & 0x7F) ? "Y" : "N",
((ret >> (2*7)) & 0x7F) ? "Y" : "N",
((ret >> (3*7)) & 0x7F) ? "Y" : "N"))
DBG_LOG(("+-----------------------+"))
DBG_LOG(("DSP's(present-absent):%08x-%08x", ret, ~ret & 0x3fffffff))
*(volatile byte*)(p) = 0 ;
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
diva_os_wait (50) ;
IoAdapter->InitialDspInfo |= DspCount << 16 ;
return (ret);
}
/* -------------------------------------------------------------------------
helper used to download dsp code toi PRI Card
------------------------------------------------------------------------- */
static long pri_download_buffer (OsFileHandle *fp, long length, void **addr) {
PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)fp->sysLoadDesc ;
dword *sharedRam ;
byte *p;
*addr = (void *)IoAdapter->downloadAddr ;
if ( ((dword) length) > IoAdapter->DspCodeBaseAddr +
IoAdapter->MaxDspCodeSize - IoAdapter->downloadAddr )
{
DBG_FTL(("%s: out of card memory during DSP download (0x%X)",
IoAdapter->Properties.Name,
IoAdapter->downloadAddr + length))
return (-1) ;
}
p = DIVA_OS_MEM_ATTACH_RAM(IoAdapter);
sharedRam = (dword *)(&p[DOWNLOAD_ADDR(IoAdapter)]);
if ( fp->sysFileRead (fp, sharedRam, length) != length ) {
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
return (-1) ;
}
IoAdapter->downloadAddr += length ;
IoAdapter->downloadAddr = (IoAdapter->downloadAddr + 3) & (~3) ;
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
return (0) ;
}
/* -------------------------------------------------------------------------
Download DSP code to PRI Card
------------------------------------------------------------------------- */
static dword pri_telindus_load (PISDN_ADAPTER IoAdapter) {
char *error ;
OsFileHandle *fp ;
t_dsp_portable_desc download_table[DSP_MAX_DOWNLOAD_COUNT] ;
word download_count ;
dword *sharedRam ;
dword FileLength ;
byte *p;
if ( !(fp = OsOpenFile (DSP_TELINDUS_FILE)) )
return (0) ;
IoAdapter->downloadAddr = (IoAdapter->DspCodeBaseAddr
+ sizeof(dword) + sizeof(download_table) + 3) & (~3) ;
FileLength = fp->sysFileSize ;
fp->sysLoadDesc = (void *)IoAdapter ;
fp->sysCardLoad = pri_download_buffer ;
download_count = DSP_MAX_DOWNLOAD_COUNT ;
memset (&download_table[0], '\0', sizeof(download_table)) ;
/*
* set start address for download (use autoincrement mode !)
*/
error = dsp_read_file (fp, (word)(IoAdapter->cardType),
&download_count, NULL, &download_table[0]) ;
if ( error )
{
DBG_FTL(("download file error: %s", error))
OsCloseFile (fp) ;
return (0) ;
}
OsCloseFile (fp) ;
/*
* store # of separate download files extracted from archive
*/
IoAdapter->downloadAddr = IoAdapter->DspCodeBaseAddr ;
p = DIVA_OS_MEM_ATTACH_RAM(IoAdapter);
sharedRam = (dword *)(&p[DOWNLOAD_ADDR(IoAdapter)]);
WRITE_DWORD(&(sharedRam[0]), (dword)download_count);
memcpy (&sharedRam[1], &download_table[0], sizeof(download_table)) ;
DIVA_OS_MEM_DETACH_RAM(IoAdapter, p);
return (FileLength) ;
}
/* -------------------------------------------------------------------------
Download PRI Card
------------------------------------------------------------------------- */
#define MIN_DSPS 0x30000000
static int load_pri_hardware (PISDN_ADAPTER IoAdapter) {
dword i ;
struct mp_load *boot = (struct mp_load *)DIVA_OS_MEM_ATTACH_RAM(IoAdapter);
if ( IoAdapter->Properties.Card != CARD_MAEP ) {
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
return (0) ;
}
boot->err = 0 ;
#if 0
IoAdapter->rstFnc (IoAdapter) ;
#else
if ( MIN_DSPS != (MIN_DSPS & diva_pri_detect_dsps(IoAdapter)) ) { /* makes reset */
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
DBG_FTL(("%s: DSP error!", IoAdapter->Properties.Name))
return (0) ;
}
#endif
/*
* check if CPU is alive
*/
diva_os_wait (10) ;
i = boot->live ;
diva_os_wait (10) ;
if ( i == boot->live )
{
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
DBG_FTL(("%s: CPU is not alive!", IoAdapter->Properties.Name))
return (0) ;
}
if ( boot->err )
{
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
DBG_FTL(("%s: Board Selftest failed!", IoAdapter->Properties.Name))
return (0) ;
}
/*
* download protocol and dsp files
*/
if ( !xdiSetProtocol (IoAdapter, IoAdapter->ProtocolSuffix) ) {
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
return (0) ;
}
if ( !pri_protocol_load (IoAdapter) ) {
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
return (0) ;
}
if ( !pri_telindus_load (IoAdapter) ) {
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
return (0) ;
}
/*
* copy configuration parameters
*/
IoAdapter->ram += MP_SHARED_RAM_OFFSET ;
memset (boot + MP_SHARED_RAM_OFFSET, '\0', 256) ;
diva_configure_protocol (IoAdapter);
/*
* start adapter
*/
boot->addr = MP_UNCACHED_ADDR (MP_PROTOCOL_OFFSET) ;
boot->cmd = 3 ;
/*
* wait for signature in shared memory (max. 3 seconds)
*/
for ( i = 0 ; i < 300 ; ++i )
{
diva_os_wait (10) ;
if ( (boot->signature >> 16) == 0x4447 )
{
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
DBG_TRC(("Protocol startup time %d.%02d seconds",
(i / 100), (i % 100) ))
return (1) ;
}
}
DIVA_OS_MEM_DETACH_RAM(IoAdapter, boot);
DBG_FTL(("%s: Adapter selftest failed (0x%04X)!",
IoAdapter->Properties.Name, boot->signature >> 16))
pri_cpu_trapped (IoAdapter) ;
return (0) ;
}
#else /* } { */
static int load_pri_hardware (PISDN_ADAPTER IoAdapter) { static int load_pri_hardware (PISDN_ADAPTER IoAdapter) {
return (0); return (0);
} }
#endif /* } */
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
PRI Adapter interrupt Service Routine PRI Adapter interrupt Service Routine
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment