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

[PATCH] eicon ISDN driver: memory attach

Access to cards memory now uses macros to attach
to the correct memory area of the card.
parent 6f4d1d80
...@@ -72,10 +72,10 @@ IDI_CALL Requests[MAX_ADAPTER] = ...@@ -72,10 +72,10 @@ IDI_CALL Requests[MAX_ADAPTER] =
*/ */
static byte extended_xdi_features[DIVA_XDI_EXTENDED_FEATURES_MAX_SZ+1] = { static byte extended_xdi_features[DIVA_XDI_EXTENDED_FEATURES_MAX_SZ+1] = {
(DIVA_XDI_EXTENDED_FEATURES_VALID | (DIVA_XDI_EXTENDED_FEATURES_VALID |
DIVA_XDI_EXTENDED_FEATURE_CMA |
DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR | DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR |
DIVA_XDI_EXTENDED_FEATURE_CAPI_PRMS | DIVA_XDI_EXTENDED_FEATURE_CAPI_PRMS |
#if defined(DIVA_IDI_RX_DMA) #if defined(DIVA_IDI_RX_DMA)
DIVA_XDI_EXTENDED_FEATURE_CMA |
DIVA_XDI_EXTENDED_FEATURE_RX_DMA | DIVA_XDI_EXTENDED_FEATURE_RX_DMA |
#endif #endif
DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC), DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC),
...@@ -156,7 +156,8 @@ void ...@@ -156,7 +156,8 @@ void
dump_trap_frame (PISDN_ADAPTER IoAdapter, byte *exceptionFrame) dump_trap_frame (PISDN_ADAPTER IoAdapter, byte *exceptionFrame)
{ {
MP_XCPTC *xcept = (MP_XCPTC *)exceptionFrame ; MP_XCPTC *xcept = (MP_XCPTC *)exceptionFrame ;
dword *regs = &xcept->regs[0] ; dword *regs;
regs = &xcept->regs[0] ;
DBG_FTL(("%s: ***************** CPU TRAPPED *****************", DBG_FTL(("%s: ***************** CPU TRAPPED *****************",
&IoAdapter->Name[0])) &IoAdapter->Name[0]))
DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0])) DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0]))
...@@ -567,26 +568,38 @@ pcm_req (PISDN_ADAPTER IoAdapter, ENTITY *e) ...@@ -567,26 +568,38 @@ pcm_req (PISDN_ADAPTER IoAdapter, ENTITY *e)
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
byte mem_in (ADAPTER *a, void *addr) byte mem_in (ADAPTER *a, void *addr)
{ {
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; byte val;
return (*Base) ; volatile byte* Base;
Base = (volatile byte *)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
val = *(Base + (unsigned long)addr);
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
return (val);
} }
word mem_inw (ADAPTER *a, void *addr) word mem_inw (ADAPTER *a, void *addr)
{ {
word* Base = (word*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; word val;
return (READ_WORD(Base)) ; volatile byte* Base;
Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
val = READ_WORD((Base + (unsigned long)addr));
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
return (val);
} }
void mem_in_dw (ADAPTER *a, void *addr, dword* data, int dwords) void mem_in_dw (ADAPTER *a, void *addr, dword* data, int dwords)
{ {
volatile dword* Base = (dword*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
while (dwords--) { while (dwords--) {
*data++ = READ_DWORD(Base); *data++ = READ_DWORD((Base + (unsigned long)addr));
Base++; addr+=4;
} }
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
void mem_in_buffer (ADAPTER *a, void *addr, void *buffer, word length) void mem_in_buffer (ADAPTER *a, void *addr, void *buffer, word length)
{ {
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
memcpy (buffer, Base, length) ; memcpy (buffer, (void *)(Base + (unsigned long)addr), length);
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e)
{ {
...@@ -598,99 +611,130 @@ void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) ...@@ -598,99 +611,130 @@ void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e)
} }
void mem_out (ADAPTER *a, void *addr, byte data) void mem_out (ADAPTER *a, void *addr, byte data)
{ {
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
*Base = data ; *(Base + (unsigned long)addr) = data ;
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
void mem_outw (ADAPTER *a, void *addr, word data) void mem_outw (ADAPTER *a, void *addr, word data)
{ {
word* Base = (word*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
WRITE_WORD(Base, data); WRITE_WORD((Base + (unsigned long)addr), data);
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
void mem_out_dw (ADAPTER *a, void *addr, const dword* data, int dwords) void mem_out_dw (ADAPTER *a, void *addr, const dword* data, int dwords)
{ {
volatile dword* Base = (dword*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
while (dwords--) { while (dwords--) {
WRITE_DWORD(Base, *data); WRITE_DWORD((Base + (unsigned long)addr), *data);
Base++; addr+=4;
data++; data++;
} }
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
void mem_out_buffer (ADAPTER *a, void *addr, void *buffer, word length) void mem_out_buffer (ADAPTER *a, void *addr, void *buffer, word length)
{ {
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
memcpy (Base, buffer, length) ; memcpy ((void *)(Base + (unsigned long)addr), buffer, length) ;
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
void mem_inc (ADAPTER *a, void *addr) void mem_inc (ADAPTER *a, void *addr)
{ {
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ; volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
byte x = *Base ; byte x = *(Base + (unsigned long)addr);
*Base = x + 1 ; *(Base + (unsigned long)addr) = x + 1 ;
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
} }
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* ram access functions for io-mapped cards */ /* ram access functions for io-mapped cards */
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
byte io_in(ADAPTER * a, void * adr) byte io_in(ADAPTER * a, void * adr)
{ {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); byte val;
return inpp(((PISDN_ADAPTER)a->io)->port); byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
outppw(Port + 4, (word)(unsigned long)adr);
val = inpp(Port);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
return(val);
} }
word io_inw(ADAPTER * a, void * adr) word io_inw(ADAPTER * a, void * adr)
{ {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); word val;
return inppw(((PISDN_ADAPTER)a->io)->port); byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
outppw(Port + 4, (word)(unsigned long)adr);
val = inppw(Port);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
return(val);
} }
void io_in_buffer(ADAPTER * a, void * adr, void * buffer, word len) void io_in_buffer(ADAPTER * a, void * adr, void * buffer, word len)
{ {
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
byte* P = (byte*)buffer; byte* P = (byte*)buffer;
if ((long)adr & 1) { if ((long)adr & 1) {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); outppw(Port+4, (word)(unsigned long)adr);
*P = inpp(((PISDN_ADAPTER)a->io)->port); *P = inpp(Port);
P++; P++;
adr = ((byte *) adr) + 1; adr = ((byte *) adr) + 1;
len--; len--;
if (!len) return; if (!len) {
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
return;
}
} }
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); outppw(Port+4, (word)(unsigned long)adr);
inppw_buffer (((PISDN_ADAPTER)a->io)->port, P, len+1); inppw_buffer (Port, P, len+1);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
} }
void io_look_ahead(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e) void io_look_ahead(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e)
{ {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)RBuffer); byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
((PISDN_ADAPTER)a->io)->RBuffer.length = inppw(((PISDN_ADAPTER)a->io)->port); outppw(Port+4, (word)(unsigned long)RBuffer);
inppw_buffer (((PISDN_ADAPTER)a->io)->port, ((PISDN_ADAPTER)a->io)->RBuffer.P, ((PISDN_ADAPTER)a->io)->RBuffer.length + 1); ((PISDN_ADAPTER)a->io)->RBuffer.length = inppw(Port);
inppw_buffer (Port, ((PISDN_ADAPTER)a->io)->RBuffer.P, ((PISDN_ADAPTER)a->io)->RBuffer.length + 1);
e->RBuffer = (DBUFFER *) &(((PISDN_ADAPTER)a->io)->RBuffer); e->RBuffer = (DBUFFER *) &(((PISDN_ADAPTER)a->io)->RBuffer);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
} }
void io_out(ADAPTER * a, void * adr, byte data) void io_out(ADAPTER * a, void * adr, byte data)
{ {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
outpp(((PISDN_ADAPTER)a->io)->port, data); outppw(Port+4, (word)(unsigned long)adr);
outpp(Port, data);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
} }
void io_outw(ADAPTER * a, void * adr, word data) void io_outw(ADAPTER * a, void * adr, word data)
{ {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
outppw(((PISDN_ADAPTER)a->io)->port, data); outppw(Port+4, (word)(unsigned long)adr);
outppw(Port, data);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
} }
void io_out_buffer(ADAPTER * a, void * adr, void * buffer, word len) void io_out_buffer(ADAPTER * a, void * adr, void * buffer, word len)
{ {
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
byte* P = (byte*)buffer; byte* P = (byte*)buffer;
if ((long)adr & 1) { if ((long)adr & 1) {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); outppw(Port+4, (word)(unsigned long)adr);
outpp(((PISDN_ADAPTER)a->io)->port, *P); outpp(Port, *P);
P++; P++;
adr = ((byte *) adr) + 1; adr = ((byte *) adr) + 1;
len--; len--;
if (!len) return; if (!len) {
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
return;
}
} }
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); outppw(Port+4, (word)(unsigned long)adr);
outppw_buffer (((PISDN_ADAPTER)a->io)->port, P, len+1); outppw_buffer (Port, P, len+1);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
} }
void io_inc(ADAPTER * a, void * adr) void io_inc(ADAPTER * a, void * adr)
{ {
byte x; byte x;
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
x = inpp(((PISDN_ADAPTER)a->io)->port); outppw(Port+4, (word)(unsigned long)adr);
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr); x = inpp(Port);
outpp(((PISDN_ADAPTER)a->io)->port, x+1); outppw(Port+4, (word)(unsigned long)adr);
outpp(Port, x+1);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
} }
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* OS specific functions related to queuing of entities */ /* OS specific functions related to queuing of entities */
......
...@@ -39,14 +39,6 @@ typedef struct { ...@@ -39,14 +39,6 @@ typedef struct {
DEVICE_NAME DeviceName[4] ; DEVICE_NAME DeviceName[4] ;
PISDN_ADAPTER QuadroAdapter[4] ; PISDN_ADAPTER QuadroAdapter[4] ;
} ADAPTER_LIST_ENTRY, *PADAPTER_LIST_ENTRY ; } ADAPTER_LIST_ENTRY, *PADAPTER_LIST_ENTRY ;
/* --------------------------------------------------------------------------
Special OS memory support structures
-------------------------------------------------------------------------- */
#define MAX_MAPPED_ENTRIES 8
typedef struct {
void * Address;
dword Length;
} ADAPTER_MEMORY ;
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Configuration of XDI clients carried by XDI Configuration of XDI clients carried by XDI
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -71,7 +63,6 @@ struct _ISDN_ADAPTER { ...@@ -71,7 +63,6 @@ struct _ISDN_ADAPTER {
/* /*
remember mapped memory areas remember mapped memory areas
*/ */
ADAPTER_MEMORY MappedMemory[MAX_MAPPED_ENTRIES] ;
CARD_PROPERTIES Properties ; CARD_PROPERTIES Properties ;
dword cardType ; dword cardType ;
dword protocol_id ; /* configured protocol identifier */ dword protocol_id ; /* configured protocol identifier */
...@@ -97,6 +88,8 @@ struct _ISDN_ADAPTER { ...@@ -97,6 +88,8 @@ struct _ISDN_ADAPTER {
dword MemoryBase ; dword MemoryBase ;
dword MemorySize ; dword MemorySize ;
byte *Address ; byte *Address ;
byte *Config ;
byte *Control ;
byte *reset ; byte *reset ;
byte *port ; byte *port ;
byte *ram ; byte *ram ;
......
This diff is collapsed.
/* $Id: os_bri.c,v 1.1.2.2 2001/02/12 20:23:46 armin Exp $ */ /* $Id: os_bri.c,v 1.18 2003/06/21 17:10:29 schindler Exp $ */
#include "platform.h" #include "platform.h"
#include "debuglib.h" #include "debuglib.h"
...@@ -46,6 +46,27 @@ static int diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, ...@@ -46,6 +46,27 @@ static int diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
dword start_address, dword features); dword start_address, dword features);
static int diva_bri_stop_adapter(diva_os_xdi_adapter_t * a); static int diva_bri_stop_adapter(diva_os_xdi_adapter_t * a);
static void diva_bri_set_addresses(diva_os_xdi_adapter_t * a)
{
a->resources.pci.mem_type_id[MEM_TYPE_RAM] = 0;
a->resources.pci.mem_type_id[MEM_TYPE_CFG] = 1;
a->resources.pci.mem_type_id[MEM_TYPE_ADDRESS] = 2;
a->resources.pci.mem_type_id[MEM_TYPE_RESET] = 1;
a->resources.pci.mem_type_id[MEM_TYPE_PORT] = 2;
a->resources.pci.mem_type_id[MEM_TYPE_CTLREG] = 2;
a->xdi_adapter.ram = a->resources.pci.addr[0];
a->xdi_adapter.cfg = a->resources.pci.addr[1];
a->xdi_adapter.Address = a->resources.pci.addr[2];
a->xdi_adapter.reset = a->xdi_adapter.cfg;
a->xdi_adapter.port = a->xdi_adapter.Address;
a->xdi_adapter.ctlReg = a->xdi_adapter.port + M_PCI_RESET;
a->xdi_adapter.reset += 0x4C; /* PLX 9050 !! */
}
/* /*
** BAR0 - MEM Addr - 0x80 - NOT USED ** BAR0 - MEM Addr - 0x80 - NOT USED
** BAR1 - I/O Addr - 0x80 ** BAR1 - I/O Addr - 0x80
...@@ -58,6 +79,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) ...@@ -58,6 +79,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
word cmd = 0, cmd_org; word cmd = 0, cmd_org;
byte Bus, Slot; byte Bus, Slot;
void *hdev; void *hdev;
byte *p;
/* /*
Set properties Set properties
...@@ -123,7 +145,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) ...@@ -123,7 +145,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
Map and register resources Map and register resources
*/ */
if (!(a->resources.pci.addr[0] = if (!(a->resources.pci.addr[0] =
divasa_remap_pci_bar(a->resources.pci.bar[0], divasa_remap_pci_bar(a, 0, a->resources.pci.bar[0],
bri_bar_length[0]))) { bri_bar_length[0]))) {
DBG_ERR(("A: BRI, can't map BAR[0]")) DBG_ERR(("A: BRI, can't map BAR[0]"))
diva_bri_cleanup_adapter(a); diva_bri_cleanup_adapter(a);
...@@ -133,8 +155,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) ...@@ -133,8 +155,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
sprintf(&a->port_name[0], "BRI %02x:%02x", sprintf(&a->port_name[0], "BRI %02x:%02x",
a->resources.pci.bus, a->resources.pci.func); a->resources.pci.bus, a->resources.pci.func);
if (diva_os_register_io_port(1, a->resources.pci.bar[1], if (diva_os_register_io_port(a, 1, a->resources.pci.bar[1],
bri_bar_length[1], &a->port_name[0])) { bri_bar_length[1], &a->port_name[0], 1)) {
DBG_ERR(("A: BRI, can't register BAR[1]")) DBG_ERR(("A: BRI, can't register BAR[1]"))
diva_bri_cleanup_adapter(a); diva_bri_cleanup_adapter(a);
return (-1); return (-1);
...@@ -142,8 +164,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) ...@@ -142,8 +164,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
a->resources.pci.addr[1] = (void *) (unsigned long) a->resources.pci.bar[1]; a->resources.pci.addr[1] = (void *) (unsigned long) a->resources.pci.bar[1];
a->resources.pci.length[1] = bri_bar_length[1]; a->resources.pci.length[1] = bri_bar_length[1];
if (diva_os_register_io_port(1, a->resources.pci.bar[2], if (diva_os_register_io_port(a, 1, a->resources.pci.bar[2],
bar2_length, &a->port_name[0])) { bar2_length, &a->port_name[0], 2)) {
DBG_ERR(("A: BRI, can't register BAR[2]")) DBG_ERR(("A: BRI, can't register BAR[2]"))
diva_bri_cleanup_adapter(a); diva_bri_cleanup_adapter(a);
return (-1); return (-1);
...@@ -151,6 +173,11 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) ...@@ -151,6 +173,11 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
a->resources.pci.addr[2] = (void *) (unsigned long) a->resources.pci.bar[2]; a->resources.pci.addr[2] = (void *) (unsigned long) a->resources.pci.bar[2];
a->resources.pci.length[2] = bar2_length; a->resources.pci.length[2] = bar2_length;
/*
Set all memory areas
*/
diva_bri_set_addresses(a);
/* /*
Get Serial Number Get Serial Number
*/ */
...@@ -210,15 +237,9 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) ...@@ -210,15 +237,9 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
a->interface.cleanup_adapter_proc = diva_bri_cleanup_adapter; a->interface.cleanup_adapter_proc = diva_bri_cleanup_adapter;
a->interface.cmd_proc = diva_bri_cmd_card_proc; a->interface.cmd_proc = diva_bri_cmd_card_proc;
a->xdi_adapter.cfg = a->resources.pci.addr[1]; p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
a->xdi_adapter.Address = a->resources.pci.addr[2]; outpp(p, 0x41);
DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
a->xdi_adapter.reset = a->xdi_adapter.cfg;
a->xdi_adapter.port = a->xdi_adapter.Address;
a->xdi_adapter.ctlReg = a->xdi_adapter.port + M_PCI_RESET;
a->xdi_adapter.reset += 0x4C; /* PLX 9050 !! */
outpp(a->xdi_adapter.reset, 0x41);
prepare_maestra_functions(&a->xdi_adapter); prepare_maestra_functions(&a->xdi_adapter);
...@@ -268,11 +289,11 @@ static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a) ...@@ -268,11 +289,11 @@ static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a)
for (i = 1; i < 3; i++) { for (i = 1; i < 3; i++) {
if (a->resources.pci.addr[i] && a->resources.pci.bar[i]) { if (a->resources.pci.addr[i] && a->resources.pci.bar[i]) {
diva_os_register_io_port(0, diva_os_register_io_port(a, 0,
a->resources.pci.bar[i], a->resources.pci.bar[i],
a->resources.pci. a->resources.pci.
length[i], length[i],
&a->port_name[0]); &a->port_name[0], i);
a->resources.pci.addr[i] = 0; a->resources.pci.addr[i] = 0;
a->resources.pci.bar[i] = 0; a->resources.pci.bar[i] = 0;
} }
...@@ -314,18 +335,20 @@ static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a) ...@@ -314,18 +335,20 @@ static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a)
byte *confIO; byte *confIO;
word serHi, serLo, *confMem; word serHi, serLo, *confMem;
confIO = (byte *) a->resources.pci.addr[1]; confIO = (byte *) DIVA_OS_MEM_ATTACH_CFG(&a->xdi_adapter);
serHi = (word) (inppw(&confIO[0x22]) & 0x0FFF); serHi = (word) (inppw(&confIO[0x22]) & 0x0FFF);
serLo = (word) (inppw(&confIO[0x26]) & 0x0FFF); serLo = (word) (inppw(&confIO[0x26]) & 0x0FFF);
serNo = ((dword) serHi << 16) | (dword) serLo; serNo = ((dword) serHi << 16) | (dword) serLo;
DIVA_OS_MEM_DETACH_CFG(&a->xdi_adapter, confIO);
if ((serNo == 0) || (serNo == 0xFFFFFFFF)) { if ((serNo == 0) || (serNo == 0xFFFFFFFF)) {
DBG_FTL(("W: BRI use BAR[0] to get card serial number")) DBG_FTL(("W: BRI use BAR[0] to get card serial number"))
confMem = (word *) a->resources.pci.addr[0]; confMem = (word *) DIVA_OS_MEM_ATTACH_RAM(&a->xdi_adapter);
serHi = (word) (READ_WORD(&confMem[0x11]) & 0x0FFF); serHi = (word) (READ_WORD(&confMem[0x11]) & 0x0FFF);
serLo = (word) (READ_WORD(&confMem[0x13]) & 0x0FFF); serLo = (word) (READ_WORD(&confMem[0x13]) & 0x0FFF);
serNo = (((dword) serHi) << 16) | ((dword) serLo); serNo = (((dword) serHi) << 16) | ((dword) serLo);
DIVA_OS_MEM_DETACH_RAM(&a->xdi_adapter, confMem);
} }
DBG_LOG(("Serial Number=%ld", serNo)) DBG_LOG(("Serial Number=%ld", serNo))
...@@ -342,9 +365,9 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a) ...@@ -342,9 +365,9 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a)
int i; int i;
for (i = 1; i < 3; i++) { for (i = 1; i < 3; i++) {
diva_os_register_io_port(0, a->resources.pci.bar[i], diva_os_register_io_port(a, 0, a->resources.pci.bar[i],
a->resources.pci.length[i], a->resources.pci.length[i],
&a->port_name[0]); &a->port_name[0], i);
a->resources.pci.addr[i] = 0; a->resources.pci.addr[i] = 0;
} }
...@@ -352,9 +375,9 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a) ...@@ -352,9 +375,9 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a)
(long) a->xdi_adapter.serialNo); (long) a->xdi_adapter.serialNo);
for (i = 1; i < 3; i++) { for (i = 1; i < 3; i++) {
if (diva_os_register_io_port(1, a->resources.pci.bar[i], if (diva_os_register_io_port(a, 1, a->resources.pci.bar[i],
a->resources.pci.length[i], a->resources.pci.length[i],
&a->port_name[0])) { &a->port_name[0], i)) {
DBG_ERR(("A: failed to reregister BAR[%d]", i)) DBG_ERR(("A: failed to reregister BAR[%d]", i))
return (-1); return (-1);
} }
...@@ -493,6 +516,7 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) ...@@ -493,6 +516,7 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter)
{ {
byte *addrHi, *addrLo, *ioaddr; byte *addrHi, *addrLo, *ioaddr;
dword i; dword i;
byte *Port;
if (!IoAdapter->port) { if (!IoAdapter->port) {
return (-1); return (-1);
...@@ -501,13 +525,13 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) ...@@ -501,13 +525,13 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter)
DBG_ERR(("A: A(%d) can't reset BRI adapter - please stop first", DBG_ERR(("A: A(%d) can't reset BRI adapter - please stop first",
IoAdapter->ANum)) return (-1); IoAdapter->ANum)) return (-1);
} }
addrHi =
IoAdapter->port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = IoAdapter->port + ADDR;
ioaddr = IoAdapter->port + DATA;
(*(IoAdapter->rstFnc)) (IoAdapter); (*(IoAdapter->rstFnc)) (IoAdapter);
diva_os_wait(100); diva_os_wait(100);
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = Port + ADDR;
ioaddr = Port + DATA;
/* /*
recover recover
*/ */
...@@ -540,6 +564,8 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) ...@@ -540,6 +564,8 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter)
outppw(addrLo, (word) 0); outppw(addrLo, (word) 0);
outppw(ioaddr, (word) 0); outppw(ioaddr, (word) 0);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/* /*
Forget all outstanding entities Forget all outstanding entities
*/ */
...@@ -578,16 +604,17 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter, ...@@ -578,16 +604,17 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter,
dword address, const byte * data, dword length) dword address, const byte * data, dword length)
{ {
byte *addrHi, *addrLo, *ioaddr; byte *addrHi, *addrLo, *ioaddr;
byte *Port;
if (!IoAdapter->port) { if (!IoAdapter->port) {
return (-1); return (-1);
} }
addrHi = Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
IoAdapter->port + addrHi = Port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = IoAdapter->port + ADDR; addrLo = Port + ADDR;
ioaddr = IoAdapter->port + DATA; ioaddr = Port + DATA;
while (length--) { while (length--) {
outpp(addrHi, (word) (address >> 16)); outpp(addrHi, (word) (address >> 16));
...@@ -596,6 +623,7 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter, ...@@ -596,6 +623,7 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter,
address++; address++;
} }
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
return (0); return (0);
} }
...@@ -603,6 +631,7 @@ static int ...@@ -603,6 +631,7 @@ static int
diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
dword start_address, dword features) dword start_address, dword features)
{ {
byte *Port;
dword i, test; dword i, test;
byte *addrHi, *addrLo, *ioaddr; byte *addrHi, *addrLo, *ioaddr;
int started = 0; int started = 0;
...@@ -621,11 +650,11 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, ...@@ -621,11 +650,11 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
sprintf(IoAdapter->Name, "A(%d)", (int) IoAdapter->ANum); sprintf(IoAdapter->Name, "A(%d)", (int) IoAdapter->ANum);
DBG_LOG(("A(%d) start BRI", IoAdapter->ANum)) DBG_LOG(("A(%d) start BRI", IoAdapter->ANum))
addrHi = Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
IoAdapter->port + addrHi = Port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = IoAdapter->port + ADDR; addrLo = Port + ADDR;
ioaddr = IoAdapter->port + DATA; ioaddr = Port + DATA;
outpp(addrHi, outpp(addrHi,
(byte) ( (byte) (
...@@ -633,12 +662,20 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, ...@@ -633,12 +662,20 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
BRI_SHARED_RAM_SIZE) >> 16)); BRI_SHARED_RAM_SIZE) >> 16));
outppw(addrLo, 0x1e); outppw(addrLo, 0x1e);
outppw(ioaddr, 0x00); outppw(ioaddr, 0x00);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/* /*
start the protocol code start the protocol code
*/ */
outpp(IoAdapter->ctlReg, 0x08); Port = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
outpp(Port, 0x08);
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, Port);
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = Port + ADDR;
ioaddr = Port + DATA;
/* /*
wait for signature (max. 3 seconds) wait for signature (max. 3 seconds)
*/ */
...@@ -659,6 +696,7 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, ...@@ -659,6 +696,7 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
break; break;
} }
} }
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
if (!started) { if (!started) {
DBG_FTL(("A: A(%d) %s: Adapter selftest failed 0x%04X", DBG_FTL(("A: A(%d) %s: Adapter selftest failed 0x%04X",
...@@ -677,7 +715,9 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, ...@@ -677,7 +715,9 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
a->ReadyInt = 1; a->ReadyInt = 1;
if (IoAdapter->reset) { if (IoAdapter->reset) {
outpp(IoAdapter->reset, 0x41); Port = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
outpp(Port, 0x41);
DIVA_OS_MEM_DETACH_RESET(IoAdapter, Port);
} }
a->ram_out(a, &PR_RAM->ReadyInt, 1); a->ram_out(a, &PR_RAM->ReadyInt, 1);
......
This diff is collapsed.
...@@ -106,6 +106,36 @@ ...@@ -106,6 +106,36 @@
#define _cdecl #define _cdecl
#endif #endif
#define MEM_TYPE_RAM 0
#define MEM_TYPE_PORT 1
#define MEM_TYPE_PROM 2
#define MEM_TYPE_CTLREG 3
#define MEM_TYPE_RESET 4
#define MEM_TYPE_CFG 5
#define MEM_TYPE_ADDRESS 6
#define MEM_TYPE_CONFIG 7
#define MEM_TYPE_CONTROL 8
#define DIVA_OS_MEM_ATTACH_RAM(a) ((a)->ram)
#define DIVA_OS_MEM_ATTACH_PORT(a) ((a)->port)
#define DIVA_OS_MEM_ATTACH_PROM(a) ((a)->prom)
#define DIVA_OS_MEM_ATTACH_CTLREG(a) ((a)->ctlReg)
#define DIVA_OS_MEM_ATTACH_RESET(a) ((a)->reset)
#define DIVA_OS_MEM_ATTACH_CFG(a) ((a)->cfg)
#define DIVA_OS_MEM_ATTACH_ADDRESS(a) ((a)->Address)
#define DIVA_OS_MEM_ATTACH_CONFIG(a) ((a)->Config)
#define DIVA_OS_MEM_ATTACH_CONTROL(a) ((a)->Control)
#define DIVA_OS_MEM_DETACH_RAM(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_PORT(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_PROM(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_CTLREG(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_RESET(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_CFG(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_ADDRESS(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_CONFIG(a, x) do { } while(0)
#define DIVA_OS_MEM_DETACH_CONTROL(a, x) do { } while(0)
#if !defined(DIM) #if !defined(DIM)
#define DIM(array) (sizeof (array)/sizeof ((array)[0])) #define DIM(array) (sizeof (array)/sizeof ((array)[0]))
#endif #endif
......
This diff is collapsed.
...@@ -45,15 +45,16 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) { ...@@ -45,15 +45,16 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
word *Xlog ; word *Xlog ;
dword regs[4], i, size ; dword regs[4], i, size ;
Xdesc xlogDesc ; Xdesc xlogDesc ;
byte *Port;
/* /*
* first read pointers and trap frame * first read pointers and trap frame
*/ */
if ( !(Xlog = (word *)diva_os_malloc (0, MAX_XLOG_SIZE)) ) if ( !(Xlog = (word *)diva_os_malloc (0, MAX_XLOG_SIZE)) )
return ; return ;
addrHi = IoAdapter->port Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
+ ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ; addrHi = Port + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ;
addrLo = IoAdapter->port + ADDR ; addrLo = Port + ADDR ;
ioaddr = IoAdapter->port + DATA ; ioaddr = Port + DATA ;
outpp (addrHi, 0) ; outpp (addrHi, 0) ;
outppw (addrLo, 0) ; outppw (addrLo, 0) ;
for ( i = 0 ; i < 0x100 ; Xlog[i++] = inppw(ioaddr) ) ; for ( i = 0 ; i < 0x100 ; Xlog[i++] = inppw(ioaddr) ) ;
...@@ -95,21 +96,28 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) { ...@@ -95,21 +96,28 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + IoAdapter->MemorySize - outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + IoAdapter->MemorySize -
BRI_SHARED_RAM_SIZE)) >> 16)) ; BRI_SHARED_RAM_SIZE)) >> 16)) ;
outppw (addrLo, 0x00) ; outppw (addrLo, 0x00) ;
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
} }
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
Reset hardware Reset hardware
--------------------------------------------------------------------- */ --------------------------------------------------------------------- */
static void reset_bri_hardware (PISDN_ADAPTER IoAdapter) { static void reset_bri_hardware (PISDN_ADAPTER IoAdapter) {
outpp (IoAdapter->ctlReg, 0x00) ; byte *p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
outpp (p, 0x00) ;
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
} }
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
Halt system Halt system
--------------------------------------------------------------------- */ --------------------------------------------------------------------- */
static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) { static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) {
if (IoAdapter->reset) { byte *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
outpp (IoAdapter->reset, 0x00) ; /* disable interrupts ! */ if (p) {
outpp (p, 0x00) ; /* disable interrupts ! */
} }
outpp (IoAdapter->ctlReg, 0x00) ; /* clear int, halt cpu */ DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
outpp (p, 0x00) ; /* clear int, halt cpu */
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
} }
#if !defined(DIVA_USER_MODE_CARD_CONFIG) /* { */ #if !defined(DIVA_USER_MODE_CARD_CONFIG) /* { */
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
...@@ -121,6 +129,7 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) { ...@@ -121,6 +129,7 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
byte* addrHi, *addrLo, *ioaddr ; byte* addrHi, *addrLo, *ioaddr ;
char *FileName = &IoAdapter->Protocol[0] ; char *FileName = &IoAdapter->Protocol[0] ;
dword Addr, i ; dword Addr, i ;
byte *Port;
/* ------------------------------------------------------------------- /* -------------------------------------------------------------------
Try to load protocol code. 'File' points to memory location Try to load protocol code. 'File' points to memory location
that does contain entire protocol code that does contain entire protocol code
...@@ -173,10 +182,10 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) { ...@@ -173,10 +182,10 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
DBG_FTL(("Protocol code '%s' too big (%ld)", FileName, FileLength)) DBG_FTL(("Protocol code '%s' too big (%ld)", FileName, FileLength))
return (0) ; return (0) ;
} }
addrHi = IoAdapter->port Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
+ ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ; addrHi = Port + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ;
addrLo = IoAdapter->port + ADDR ; addrLo = Port + ADDR ;
ioaddr = IoAdapter->port + DATA ; ioaddr = Port + DATA ;
/* /*
* set start address for download (use autoincrement mode !) * set start address for download (use autoincrement mode !)
*/ */
...@@ -204,12 +213,14 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) { ...@@ -204,12 +213,14 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
test = inppw (ioaddr) ; test = inppw (ioaddr) ;
if ( test != File[i/2] ) if ( test != File[i/2] )
{ {
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_FTL(("%s: Memory test failed! (%d - 0x%04X/0x%04X)", DBG_FTL(("%s: Memory test failed! (%d - 0x%04X/0x%04X)",
IoAdapter->Properties.Name, i, test, File[i/2])) IoAdapter->Properties.Name, i, test, File[i/2]))
xdiFreeFile (File); xdiFreeFile (File);
return (0) ; return (0) ;
} }
} }
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
xdiFreeFile (File); xdiFreeFile (File);
return (FileLength) ; return (FileLength) ;
} }
...@@ -290,6 +301,7 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile) ...@@ -290,6 +301,7 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
t_dsp_portable_desc download_table[DSP_MAX_DOWNLOAD_COUNT] ; t_dsp_portable_desc download_table[DSP_MAX_DOWNLOAD_COUNT] ;
word download_count ; word download_count ;
dword FileLength ; dword FileLength ;
byte *Port;
if (!pinfo) { if (!pinfo) {
DBG_ERR (("A: out of memory s_bri at %d", __LINE__)) DBG_ERR (("A: out of memory s_bri at %d", __LINE__))
return (0); return (0);
...@@ -299,11 +311,11 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile) ...@@ -299,11 +311,11 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
return (0) ; return (0) ;
} }
FileLength = fp->sysFileSize ; FileLength = fp->sysFileSize ;
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
pinfo->IoAdapter = IoAdapter ; pinfo->IoAdapter = IoAdapter ;
pinfo->AddrLo = IoAdapter->port + ADDR ; pinfo->AddrLo = Port + ADDR ;
pinfo->AddrHi = IoAdapter->port +\ pinfo->AddrHi = Port + (IoAdapter->Properties.Bus == BUS_PCI ? M_PCI_ADDRH : ADDRH);
(IoAdapter->Properties.Bus == BUS_PCI ? M_PCI_ADDRH : ADDRH); pinfo->Data = (word*)(Port + DATA) ;
pinfo->Data = (word*)(IoAdapter->port + DATA) ;
pinfo->DownloadPos = (IoAdapter->DspCodeBaseAddr +\ pinfo->DownloadPos = (IoAdapter->DspCodeBaseAddr +\
sizeof(dword) + sizeof(download_table) + 3) & (~3) ; sizeof(dword) + sizeof(download_table) + 3) & (~3) ;
fp->sysLoadDesc = (void *)pinfo; fp->sysLoadDesc = (void *)pinfo;
...@@ -317,6 +329,7 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile) ...@@ -317,6 +329,7 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
&download_count, NULL, &download_table[0]) ; &download_count, NULL, &download_table[0]) ;
if ( error ) if ( error )
{ {
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_FTL(("download file error: %s", error)) DBG_FTL(("download file error: %s", error))
OsCloseFile (fp) ; OsCloseFile (fp) ;
diva_os_free (0, pinfo); diva_os_free (0, pinfo);
...@@ -335,23 +348,25 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile) ...@@ -335,23 +348,25 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
* copy download table to board * copy download table to board
*/ */
outppw_buffer (pinfo->Data, &download_table[0], sizeof(download_table)) ; outppw_buffer (pinfo->Data, &download_table[0], sizeof(download_table)) ;
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
diva_os_free (0, pinfo); diva_os_free (0, pinfo);
return (FileLength) ; return (FileLength) ;
} }
/******************************************************************************/ /******************************************************************************/
static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
dword i ; dword i ;
byte* addrHi, *addrLo, *ioaddr ; byte* addrHi, *addrLo, *ioaddr, *p ;
dword test ; dword test ;
byte *Port;
if ( IoAdapter->Properties.Card != CARD_MAE ) if ( IoAdapter->Properties.Card != CARD_MAE )
{ {
return (FALSE) ; return (FALSE) ;
} }
addrHi = IoAdapter->port \
+ ((IoAdapter->Properties.Bus==BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = IoAdapter->port + ADDR ;
ioaddr = IoAdapter->port + DATA ;
reset_bri_hardware (IoAdapter) ; 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); diva_os_wait (100);
/* /*
* recover * recover
...@@ -366,6 +381,7 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -366,6 +381,7 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
IoAdapter->MemorySize - BRI_SHARED_RAM_SIZE)) >> 16)) ; IoAdapter->MemorySize - BRI_SHARED_RAM_SIZE)) >> 16)) ;
outppw (addrLo, 0) ; outppw (addrLo, 0) ;
for ( i = 0 ; i < 0x8000 ; outppw (ioaddr, 0), ++i ) ; for ( i = 0 ; i < 0x8000 ; outppw (ioaddr, 0), ++i ) ;
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
diva_os_wait (100) ; diva_os_wait (100) ;
/* /*
* download protocol and dsp files * download protocol and dsp files
...@@ -396,6 +412,11 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -396,6 +412,11 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
return (FALSE) ; return (FALSE) ;
break ; 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 * clear signature
*/ */
...@@ -408,13 +429,20 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -408,13 +429,20 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
* copy parameters * copy parameters
*/ */
diva_configure_protocol (IoAdapter); diva_configure_protocol (IoAdapter);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/* /*
* start the protocol code * start the protocol code
*/ */
outpp (IoAdapter->ctlReg, 0x08) ; p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
outpp (p, 0x08) ;
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
/* /*
* wait for signature (max. 3 seconds) * 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 ) for ( i = 0 ; i < 300 ; ++i )
{ {
diva_os_wait (10) ; diva_os_wait (10) ;
...@@ -424,11 +452,13 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -424,11 +452,13 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
test = (dword)inppw (ioaddr) ; test = (dword)inppw (ioaddr) ;
if ( test == 0x4447 ) if ( test == 0x4447 )
{ {
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_TRC(("Protocol startup time %d.%02d seconds", DBG_TRC(("Protocol startup time %d.%02d seconds",
(i / 100), (i % 100) )) (i / 100), (i % 100) ))
return (TRUE) ; return (TRUE) ;
} }
} }
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
DBG_FTL(("%s: Adapter selftest failed (0x%04X)!", DBG_FTL(("%s: Adapter selftest failed (0x%04X)!",
IoAdapter->Properties.Name, test)) IoAdapter->Properties.Name, test))
bri_cpu_trapped (IoAdapter) ; bri_cpu_trapped (IoAdapter) ;
...@@ -441,12 +471,18 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { ...@@ -441,12 +471,18 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
#endif /* } */ #endif /* } */
/******************************************************************************/ /******************************************************************************/
static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) { static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
if ( !(inpp (IoAdapter->ctlReg) & 0x01) ) byte *p;
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
if ( !(inpp (p) & 0x01) ) {
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
return (0) ; return (0) ;
}
/* /*
clear interrupt line clear interrupt line
*/ */
outpp (IoAdapter->ctlReg, 0x08) ; outpp (p, 0x08) ;
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
IoAdapter->IrqCount++ ; IoAdapter->IrqCount++ ;
if ( IoAdapter->Initialized ) { if ( IoAdapter->Initialized ) {
diva_os_schedule_soft_isr (&IoAdapter->isr_soft_isr); diva_os_schedule_soft_isr (&IoAdapter->isr_soft_isr);
...@@ -457,11 +493,16 @@ static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) { ...@@ -457,11 +493,16 @@ static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
Disable IRQ in the card hardware Disable IRQ in the card hardware
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
static void disable_bri_interrupt (PISDN_ADAPTER IoAdapter) { static void disable_bri_interrupt (PISDN_ADAPTER IoAdapter) {
if ( IoAdapter->reset ) byte *p;
p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
if ( p )
{ {
outpp (IoAdapter->reset, 0x00) ; /* disable interrupts ! */ outpp (p, 0x00) ; /* disable interrupts ! */
} }
outpp (IoAdapter->ctlReg, 0x00) ; /* clear int, halt cpu */ DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
outpp (p, 0x00) ; /* clear int, halt cpu */
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
} }
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
Fill card entry points Fill card entry points
......
This diff is collapsed.
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