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
No related merge requests found
......@@ -72,10 +72,10 @@ IDI_CALL Requests[MAX_ADAPTER] =
*/
static byte extended_xdi_features[DIVA_XDI_EXTENDED_FEATURES_MAX_SZ+1] = {
(DIVA_XDI_EXTENDED_FEATURES_VALID |
DIVA_XDI_EXTENDED_FEATURE_CMA |
DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR |
DIVA_XDI_EXTENDED_FEATURE_CAPI_PRMS |
#if defined(DIVA_IDI_RX_DMA)
DIVA_XDI_EXTENDED_FEATURE_CMA |
DIVA_XDI_EXTENDED_FEATURE_RX_DMA |
#endif
DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC),
......@@ -156,7 +156,8 @@ void
dump_trap_frame (PISDN_ADAPTER IoAdapter, byte *exceptionFrame)
{
MP_XCPTC *xcept = (MP_XCPTC *)exceptionFrame ;
dword *regs = &xcept->regs[0] ;
dword *regs;
regs = &xcept->regs[0] ;
DBG_FTL(("%s: ***************** CPU TRAPPED *****************",
&IoAdapter->Name[0]))
DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0]))
......@@ -567,26 +568,38 @@ pcm_req (PISDN_ADAPTER IoAdapter, ENTITY *e)
/*------------------------------------------------------------------*/
byte mem_in (ADAPTER *a, void *addr)
{
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
return (*Base) ;
byte val;
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* Base = (word*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
return (READ_WORD(Base)) ;
word val;
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)
{
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--) {
*data++ = READ_DWORD(Base);
Base++;
*data++ = READ_DWORD((Base + (unsigned long)addr));
addr+=4;
}
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
}
void mem_in_buffer (ADAPTER *a, void *addr, void *buffer, word length)
{
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
memcpy (buffer, Base, length) ;
volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
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)
{
......@@ -598,99 +611,130 @@ void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e)
}
void mem_out (ADAPTER *a, void *addr, byte data)
{
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
*Base = data ;
volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
*(Base + (unsigned long)addr) = data ;
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
}
void mem_outw (ADAPTER *a, void *addr, word data)
{
word* Base = (word*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
WRITE_WORD(Base, data);
volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
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)
{
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--) {
WRITE_DWORD(Base, *data);
Base++;
WRITE_DWORD((Base + (unsigned long)addr), *data);
addr+=4;
data++;
}
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
}
void mem_out_buffer (ADAPTER *a, void *addr, void *buffer, word length)
{
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
memcpy (Base, buffer, length) ;
volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
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)
{
byte* Base = (byte*)&((PISDN_ADAPTER)a->io)->ram[(unsigned long)addr] ;
byte x = *Base ;
*Base = x + 1 ;
volatile byte* Base = (volatile byte*)DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io);
byte x = *(Base + (unsigned long)addr);
*(Base + (unsigned long)addr) = x + 1 ;
DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base);
}
/*------------------------------------------------------------------*/
/* ram access functions for io-mapped cards */
/*------------------------------------------------------------------*/
byte io_in(ADAPTER * a, void * adr)
{
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
return inpp(((PISDN_ADAPTER)a->io)->port);
byte val;
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)
{
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
return inppw(((PISDN_ADAPTER)a->io)->port);
word val;
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)
{
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
byte* P = (byte*)buffer;
if ((long)adr & 1) {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
*P = inpp(((PISDN_ADAPTER)a->io)->port);
outppw(Port+4, (word)(unsigned long)adr);
*P = inpp(Port);
P++;
adr = ((byte *) adr) + 1;
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);
inppw_buffer (((PISDN_ADAPTER)a->io)->port, P, len+1);
}
outppw(Port+4, (word)(unsigned long)adr);
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)
{
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)RBuffer);
((PISDN_ADAPTER)a->io)->RBuffer.length = inppw(((PISDN_ADAPTER)a->io)->port);
inppw_buffer (((PISDN_ADAPTER)a->io)->port, ((PISDN_ADAPTER)a->io)->RBuffer.P, ((PISDN_ADAPTER)a->io)->RBuffer.length + 1);
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
outppw(Port+4, (word)(unsigned long)RBuffer);
((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);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
}
void io_out(ADAPTER * a, void * adr, byte data)
{
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
outpp(((PISDN_ADAPTER)a->io)->port, data);
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
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)
{
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
outppw(((PISDN_ADAPTER)a->io)->port, data);
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
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)
{
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
byte* P = (byte*)buffer;
if ((long)adr & 1) {
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
outpp(((PISDN_ADAPTER)a->io)->port, *P);
outppw(Port+4, (word)(unsigned long)adr);
outpp(Port, *P);
P++;
adr = ((byte *) adr) + 1;
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_buffer (((PISDN_ADAPTER)a->io)->port, P, len+1);
outppw(Port+4, (word)(unsigned long)adr);
outppw_buffer (Port, P, len+1);
DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port);
}
void io_inc(ADAPTER * a, void * adr)
{
byte x;
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
x = inpp(((PISDN_ADAPTER)a->io)->port);
outppw(((PISDN_ADAPTER)a->io)->port+4, (word)(unsigned long)adr);
outpp(((PISDN_ADAPTER)a->io)->port, x+1);
byte *Port = (byte*)DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io);
outppw(Port+4, (word)(unsigned long)adr);
x = inpp(Port);
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 */
......
......@@ -39,14 +39,6 @@ typedef struct {
DEVICE_NAME DeviceName[4] ;
PISDN_ADAPTER QuadroAdapter[4] ;
} 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
-------------------------------------------------------------------------- */
......@@ -71,7 +63,6 @@ struct _ISDN_ADAPTER {
/*
remember mapped memory areas
*/
ADAPTER_MEMORY MappedMemory[MAX_MAPPED_ENTRIES] ;
CARD_PROPERTIES Properties ;
dword cardType ;
dword protocol_id ; /* configured protocol identifier */
......@@ -97,6 +88,8 @@ struct _ISDN_ADAPTER {
dword MemoryBase ;
dword MemorySize ;
byte *Address ;
byte *Config ;
byte *Control ;
byte *reset ;
byte *port ;
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 "debuglib.h"
......@@ -46,6 +46,27 @@ static int diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
dword start_address, dword features);
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
** BAR1 - I/O Addr - 0x80
......@@ -58,6 +79,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
word cmd = 0, cmd_org;
byte Bus, Slot;
void *hdev;
byte *p;
/*
Set properties
......@@ -123,7 +145,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
Map and register resources
*/
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]))) {
DBG_ERR(("A: BRI, can't map BAR[0]"))
diva_bri_cleanup_adapter(a);
......@@ -133,8 +155,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a)
sprintf(&a->port_name[0], "BRI %02x:%02x",
a->resources.pci.bus, a->resources.pci.func);
if (diva_os_register_io_port(1, a->resources.pci.bar[1],
bri_bar_length[1], &a->port_name[0])) {
if (diva_os_register_io_port(a, 1, a->resources.pci.bar[1],
bri_bar_length[1], &a->port_name[0], 1)) {
DBG_ERR(("A: BRI, can't register BAR[1]"))
diva_bri_cleanup_adapter(a);
return (-1);
......@@ -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.length[1] = bri_bar_length[1];
if (diva_os_register_io_port(1, a->resources.pci.bar[2],
bar2_length, &a->port_name[0])) {
if (diva_os_register_io_port(a, 1, a->resources.pci.bar[2],
bar2_length, &a->port_name[0], 2)) {
DBG_ERR(("A: BRI, can't register BAR[2]"))
diva_bri_cleanup_adapter(a);
return (-1);
......@@ -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.length[2] = bar2_length;
/*
Set all memory areas
*/
diva_bri_set_addresses(a);
/*
Get Serial Number
*/
......@@ -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.cmd_proc = diva_bri_cmd_card_proc;
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 !! */
outpp(a->xdi_adapter.reset, 0x41);
p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
outpp(p, 0x41);
DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
prepare_maestra_functions(&a->xdi_adapter);
......@@ -268,11 +289,11 @@ static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a)
for (i = 1; i < 3; 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.
length[i],
&a->port_name[0]);
&a->port_name[0], i);
a->resources.pci.addr[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)
byte *confIO;
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);
serLo = (word) (inppw(&confIO[0x26]) & 0x0FFF);
serNo = ((dword) serHi << 16) | (dword) serLo;
DIVA_OS_MEM_DETACH_CFG(&a->xdi_adapter, confIO);
if ((serNo == 0) || (serNo == 0xFFFFFFFF)) {
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);
serLo = (word) (READ_WORD(&confMem[0x13]) & 0x0FFF);
serNo = (((dword) serHi) << 16) | ((dword) serLo);
DIVA_OS_MEM_DETACH_RAM(&a->xdi_adapter, confMem);
}
DBG_LOG(("Serial Number=%ld", serNo))
......@@ -342,9 +365,9 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a)
int 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->port_name[0]);
&a->port_name[0], i);
a->resources.pci.addr[i] = 0;
}
......@@ -352,9 +375,9 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a)
(long) a->xdi_adapter.serialNo);
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->port_name[0])) {
&a->port_name[0], i)) {
DBG_ERR(("A: failed to reregister BAR[%d]", i))
return (-1);
}
......@@ -493,6 +516,7 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter)
{
byte *addrHi, *addrLo, *ioaddr;
dword i;
byte *Port;
if (!IoAdapter->port) {
return (-1);
......@@ -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",
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);
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
*/
......@@ -540,6 +564,8 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter)
outppw(addrLo, (word) 0);
outppw(ioaddr, (word) 0);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/*
Forget all outstanding entities
*/
......@@ -578,16 +604,17 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter,
dword address, const byte * data, dword length)
{
byte *addrHi, *addrLo, *ioaddr;
byte *Port;
if (!IoAdapter->port) {
return (-1);
}
addrHi =
IoAdapter->port +
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = IoAdapter->port + ADDR;
ioaddr = IoAdapter->port + DATA;
addrLo = Port + ADDR;
ioaddr = Port + DATA;
while (length--) {
outpp(addrHi, (word) (address >> 16));
......@@ -596,6 +623,7 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter,
address++;
}
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
return (0);
}
......@@ -603,6 +631,7 @@ static int
diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
dword start_address, dword features)
{
byte *Port;
dword i, test;
byte *addrHi, *addrLo, *ioaddr;
int started = 0;
......@@ -621,11 +650,11 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
sprintf(IoAdapter->Name, "A(%d)", (int) IoAdapter->ANum);
DBG_LOG(("A(%d) start BRI", IoAdapter->ANum))
addrHi =
IoAdapter->port +
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port +
((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH);
addrLo = IoAdapter->port + ADDR;
ioaddr = IoAdapter->port + DATA;
addrLo = Port + ADDR;
ioaddr = Port + DATA;
outpp(addrHi,
(byte) (
......@@ -633,12 +662,20 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
BRI_SHARED_RAM_SIZE) >> 16));
outppw(addrLo, 0x1e);
outppw(ioaddr, 0x00);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/*
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)
*/
......@@ -659,6 +696,7 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
break;
}
}
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
if (!started) {
DBG_FTL(("A: A(%d) %s: Adapter selftest failed 0x%04X",
......@@ -677,7 +715,9 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
a->ReadyInt = 1;
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);
......
This diff is collapsed.
......@@ -106,6 +106,36 @@
#define _cdecl
#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)
#define DIM(array) (sizeof (array)/sizeof ((array)[0]))
#endif
......
This diff is collapsed.
......@@ -45,15 +45,16 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
word *Xlog ;
dword regs[4], i, size ;
Xdesc xlogDesc ;
byte *Port;
/*
* first read pointers and trap frame
*/
if ( !(Xlog = (word *)diva_os_malloc (0, MAX_XLOG_SIZE)) )
return ;
addrHi = IoAdapter->port
+ ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ;
addrLo = IoAdapter->port + ADDR ;
ioaddr = IoAdapter->port + DATA ;
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
addrHi = Port + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ;
addrLo = Port + ADDR ;
ioaddr = Port + DATA ;
outpp (addrHi, 0) ;
outppw (addrLo, 0) ;
for ( i = 0 ; i < 0x100 ; Xlog[i++] = inppw(ioaddr) ) ;
......@@ -95,21 +96,28 @@ static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) {
outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + IoAdapter->MemorySize -
BRI_SHARED_RAM_SIZE)) >> 16)) ;
outppw (addrLo, 0x00) ;
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
}
/* ---------------------------------------------------------------------
Reset hardware
--------------------------------------------------------------------- */
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
--------------------------------------------------------------------- */
static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) {
if (IoAdapter->reset) {
outpp (IoAdapter->reset, 0x00) ; /* disable interrupts ! */
byte *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
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) /* { */
/* ---------------------------------------------------------------------
......@@ -121,6 +129,7 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
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
......@@ -173,10 +182,10 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
DBG_FTL(("Protocol code '%s' too big (%ld)", FileName, FileLength))
return (0) ;
}
addrHi = IoAdapter->port
+ ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ;
addrLo = IoAdapter->port + ADDR ;
ioaddr = IoAdapter->port + DATA ;
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 !)
*/
......@@ -204,12 +213,14 @@ static dword bri_protocol_load (PISDN_ADAPTER IoAdapter) {
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) ;
}
......@@ -290,6 +301,7 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
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);
......@@ -299,11 +311,11 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
return (0) ;
}
FileLength = fp->sysFileSize ;
Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter);
pinfo->IoAdapter = IoAdapter ;
pinfo->AddrLo = IoAdapter->port + ADDR ;
pinfo->AddrHi = IoAdapter->port +\
(IoAdapter->Properties.Bus == BUS_PCI ? M_PCI_ADDRH : ADDRH);
pinfo->Data = (word*)(IoAdapter->port + DATA) ;
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;
......@@ -317,6 +329,7 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
&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);
......@@ -335,23 +348,25 @@ static dword bri_telindus_load (PISDN_ADAPTER IoAdapter, char *DspTelindusFile)
* 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 ;
byte* addrHi, *addrLo, *ioaddr, *p ;
dword test ;
byte *Port;
if ( IoAdapter->Properties.Card != CARD_MAE )
{
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) ;
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
......@@ -366,6 +381,7 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
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
......@@ -396,6 +412,11 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
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
*/
......@@ -408,13 +429,20 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
* copy parameters
*/
diva_configure_protocol (IoAdapter);
DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port);
/*
* 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)
*/
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) ;
......@@ -424,11 +452,13 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
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) ;
......@@ -441,12 +471,18 @@ static int load_bri_hardware (PISDN_ADAPTER IoAdapter) {
#endif /* } */
/******************************************************************************/
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) ;
}
/*
clear interrupt line
*/
outpp (IoAdapter->ctlReg, 0x08) ;
outpp (p, 0x08) ;
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
IoAdapter->IrqCount++ ;
if ( IoAdapter->Initialized ) {
diva_os_schedule_soft_isr (&IoAdapter->isr_soft_isr);
......@@ -457,11 +493,16 @@ static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) {
Disable IRQ in the card hardware
-------------------------------------------------------------------------- */
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
......
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