diff options
Diffstat (limited to 'drivers/isdn/hardware/eicon/maintidi.c')
-rw-r--r-- | drivers/isdn/hardware/eicon/maintidi.c | 2277 |
1 files changed, 1138 insertions, 1139 deletions
diff --git a/drivers/isdn/hardware/eicon/maintidi.c b/drivers/isdn/hardware/eicon/maintidi.c index 534978bdf38..2ee789f9586 100644 --- a/drivers/isdn/hardware/eicon/maintidi.c +++ b/drivers/isdn/hardware/eicon/maintidi.c @@ -1,25 +1,25 @@ /* * - Copyright (c) Eicon Networks, 2000. + Copyright (c) Eicon Networks, 2000. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 1.9 + Eicon File Revision : 1.9 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. * - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -30,7 +30,7 @@ #include "man_defs.h" -extern void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...); +extern void diva_mnt_internal_dprintf(dword drv_id, dword type, char *p, ...); #define MODEM_PARSE_ENTRIES 16 /* amount of variables of interest */ #define FAX_PARSE_ENTRIES 12 /* amount of variables of interest */ @@ -38,77 +38,77 @@ extern void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...); #define STAT_PARSE_ENTRIES 70 /* amount of variables of interest */ /* - LOCAL FUNCTIONS - */ -static int DivaSTraceLibraryStart (void* hLib); -static int DivaSTraceLibraryStop (void* hLib); -static int SuperTraceLibraryFinit (void* hLib); -static void* SuperTraceGetHandle (void* hLib); -static int SuperTraceMessageInput (void* hLib); -static int SuperTraceSetAudioTap (void* hLib, int Channel, int on); -static int SuperTraceSetBChannel (void* hLib, int Channel, int on); -static int SuperTraceSetDChannel (void* hLib, int on); -static int SuperTraceSetInfo (void* hLib, int on); -static int SuperTraceClearCall (void* hLib, int Channel); -static int SuperTraceGetOutgoingCallStatistics (void* hLib); -static int SuperTraceGetIncomingCallStatistics (void* hLib); -static int SuperTraceGetModemStatistics (void* hLib); -static int SuperTraceGetFaxStatistics (void* hLib); -static int SuperTraceGetBLayer1Statistics (void* hLib); -static int SuperTraceGetBLayer2Statistics (void* hLib); -static int SuperTraceGetDLayer1Statistics (void* hLib); -static int SuperTraceGetDLayer2Statistics (void* hLib); + LOCAL FUNCTIONS +*/ +static int DivaSTraceLibraryStart(void *hLib); +static int DivaSTraceLibraryStop(void *hLib); +static int SuperTraceLibraryFinit(void *hLib); +static void *SuperTraceGetHandle(void *hLib); +static int SuperTraceMessageInput(void *hLib); +static int SuperTraceSetAudioTap(void *hLib, int Channel, int on); +static int SuperTraceSetBChannel(void *hLib, int Channel, int on); +static int SuperTraceSetDChannel(void *hLib, int on); +static int SuperTraceSetInfo(void *hLib, int on); +static int SuperTraceClearCall(void *hLib, int Channel); +static int SuperTraceGetOutgoingCallStatistics(void *hLib); +static int SuperTraceGetIncomingCallStatistics(void *hLib); +static int SuperTraceGetModemStatistics(void *hLib); +static int SuperTraceGetFaxStatistics(void *hLib); +static int SuperTraceGetBLayer1Statistics(void *hLib); +static int SuperTraceGetBLayer2Statistics(void *hLib); +static int SuperTraceGetDLayer1Statistics(void *hLib); +static int SuperTraceGetDLayer2Statistics(void *hLib); /* - LOCAL FUNCTIONS - */ -static int ScheduleNextTraceRequest (diva_strace_context_t* pLib); -static int process_idi_event (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar); -static int process_idi_info (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar); -static int diva_modem_event (diva_strace_context_t* pLib, int Channel); -static int diva_fax_event (diva_strace_context_t* pLib, int Channel); -static int diva_line_event (diva_strace_context_t* pLib, int Channel); -static int diva_modem_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar); -static int diva_fax_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar); -static int diva_line_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar); -static int diva_ifc_statistics (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar); -static diva_man_var_header_t* get_next_var (diva_man_var_header_t* pVar); -static diva_man_var_header_t* find_var (diva_man_var_header_t* pVar, - const char* name); -static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var); -static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var); -static int diva_strace_read_asz (diva_man_var_header_t* pVar, char* var); -static int diva_strace_read_asc (diva_man_var_header_t* pVar, char* var); -static int diva_strace_read_ie (diva_man_var_header_t* pVar, - diva_trace_ie_t* var); -static void diva_create_parse_table (diva_strace_context_t* pLib); -static void diva_trace_error (diva_strace_context_t* pLib, - int error, const char* file, int line); -static void diva_trace_notify_user (diva_strace_context_t* pLib, - int Channel, - int notify_subject); -static int diva_trace_read_variable (diva_man_var_header_t* pVar, - void* variable); + LOCAL FUNCTIONS +*/ +static int ScheduleNextTraceRequest(diva_strace_context_t *pLib); +static int process_idi_event(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar); +static int process_idi_info(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar); +static int diva_modem_event(diva_strace_context_t *pLib, int Channel); +static int diva_fax_event(diva_strace_context_t *pLib, int Channel); +static int diva_line_event(diva_strace_context_t *pLib, int Channel); +static int diva_modem_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar); +static int diva_fax_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar); +static int diva_line_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar); +static int diva_ifc_statistics(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar); +static diva_man_var_header_t *get_next_var(diva_man_var_header_t *pVar); +static diva_man_var_header_t *find_var(diva_man_var_header_t *pVar, + const char *name); +static int diva_strace_read_int(diva_man_var_header_t *pVar, int *var); +static int diva_strace_read_uint(diva_man_var_header_t *pVar, dword *var); +static int diva_strace_read_asz(diva_man_var_header_t *pVar, char *var); +static int diva_strace_read_asc(diva_man_var_header_t *pVar, char *var); +static int diva_strace_read_ie(diva_man_var_header_t *pVar, + diva_trace_ie_t *var); +static void diva_create_parse_table(diva_strace_context_t *pLib); +static void diva_trace_error(diva_strace_context_t *pLib, + int error, const char *file, int line); +static void diva_trace_notify_user(diva_strace_context_t *pLib, + int Channel, + int notify_subject); +static int diva_trace_read_variable(diva_man_var_header_t *pVar, + void *variable); /* - Initialize the library and return context - of the created trace object that will represent - the IDI adapter. - Return 0 on error. - */ -diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, - const diva_trace_library_user_interface_t* user_proc, - byte* pmem) { - diva_strace_context_t* pLib = (diva_strace_context_t*)pmem; + Initialize the library and return context + of the created trace object that will represent + the IDI adapter. + Return 0 on error. +*/ +diva_strace_library_interface_t *DivaSTraceLibraryCreateInstance(int Adapter, + const diva_trace_library_user_interface_t *user_proc, + byte *pmem) { + diva_strace_context_t *pLib = (diva_strace_context_t *)pmem; int i; if (!pLib) { @@ -121,11 +121,11 @@ diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, pLib->Adapter = Adapter; /* - Set up Library Interface - */ + Set up Library Interface + */ pLib->instance.hLib = pLib; - pLib->instance.DivaSTraceLibraryStart = DivaSTraceLibraryStart; - pLib->instance.DivaSTraceLibraryStop = DivaSTraceLibraryStop; + pLib->instance.DivaSTraceLibraryStart = DivaSTraceLibraryStart; + pLib->instance.DivaSTraceLibraryStop = DivaSTraceLibraryStop; pLib->instance.DivaSTraceLibraryFinit = SuperTraceLibraryFinit; pLib->instance.DivaSTraceMessageInput = SuperTraceMessageInput; pLib->instance.DivaSTraceGetHandle = SuperTraceGetHandle; @@ -134,21 +134,21 @@ diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, pLib->instance.DivaSTraceSetDChannel = SuperTraceSetDChannel; pLib->instance.DivaSTraceSetInfo = SuperTraceSetInfo; pLib->instance.DivaSTraceGetOutgoingCallStatistics = \ - SuperTraceGetOutgoingCallStatistics; + SuperTraceGetOutgoingCallStatistics; pLib->instance.DivaSTraceGetIncomingCallStatistics = \ - SuperTraceGetIncomingCallStatistics; + SuperTraceGetIncomingCallStatistics; pLib->instance.DivaSTraceGetModemStatistics = \ - SuperTraceGetModemStatistics; + SuperTraceGetModemStatistics; pLib->instance.DivaSTraceGetFaxStatistics = \ - SuperTraceGetFaxStatistics; + SuperTraceGetFaxStatistics; pLib->instance.DivaSTraceGetBLayer1Statistics = \ - SuperTraceGetBLayer1Statistics; + SuperTraceGetBLayer1Statistics; pLib->instance.DivaSTraceGetBLayer2Statistics = \ - SuperTraceGetBLayer2Statistics; + SuperTraceGetBLayer2Statistics; pLib->instance.DivaSTraceGetDLayer1Statistics = \ - SuperTraceGetDLayer1Statistics; + SuperTraceGetDLayer1Statistics; pLib->instance.DivaSTraceGetDLayer2Statistics = \ - SuperTraceGetDLayer2Statistics; + SuperTraceGetDLayer2Statistics; pLib->instance.DivaSTraceClearCall = SuperTraceClearCall; @@ -159,272 +159,272 @@ diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, pLib->user_proc_table.error_notify_proc = user_proc->error_notify_proc; } - if (!(pLib->hAdapter = SuperTraceOpenAdapter (Adapter))) { - diva_mnt_internal_dprintf (0, DLI_ERR, "Can not open XDI adapter"); + if (!(pLib->hAdapter = SuperTraceOpenAdapter(Adapter))) { + diva_mnt_internal_dprintf(0, DLI_ERR, "Can not open XDI adapter"); return NULL; } - pLib->Channels = SuperTraceGetNumberOfChannels (pLib->hAdapter); + pLib->Channels = SuperTraceGetNumberOfChannels(pLib->hAdapter); /* - Calculate amount of parte table entites necessary to translate - information from all events of onterest - */ + Calculate amount of parte table entites necessary to translate + information from all events of onterest + */ pLib->parse_entries = (MODEM_PARSE_ENTRIES + FAX_PARSE_ENTRIES + \ - STAT_PARSE_ENTRIES + \ - LINE_PARSE_ENTRIES + 1) * pLib->Channels; - pLib->parse_table = (diva_strace_path2action_t*)pmem; + STAT_PARSE_ENTRIES + \ + LINE_PARSE_ENTRIES + 1) * pLib->Channels; + pLib->parse_table = (diva_strace_path2action_t *)pmem; for (i = 0; i < 30; i++) { pLib->lines[i].pInterface = &pLib->Interface; pLib->lines[i].pInterfaceStat = &pLib->InterfaceStat; } - pLib->e.R = &pLib->RData; + pLib->e.R = &pLib->RData; pLib->req_busy = 1; pLib->rc_ok = ASSIGN_OK; - diva_create_parse_table (pLib); + diva_create_parse_table(pLib); - return ((diva_strace_library_interface_t*)pLib); + return ((diva_strace_library_interface_t *)pLib); } -static int DivaSTraceLibraryStart (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int DivaSTraceLibraryStart(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; - return (SuperTraceASSIGN (pLib->hAdapter, pLib->buffer)); + return (SuperTraceASSIGN(pLib->hAdapter, pLib->buffer)); } /* Return (-1) on error Return (0) if was initiated or pending Return (1) if removal is complete - */ -static int DivaSTraceLibraryStop (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +*/ +static int DivaSTraceLibraryStop(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; - if (!pLib->e.Id) { /* Was never started/assigned */ - return (1); - } + if (!pLib->e.Id) { /* Was never started/assigned */ + return (1); + } - switch (pLib->removal_state) { - case 0: - pLib->removal_state = 1; - ScheduleNextTraceRequest(pLib); - break; + switch (pLib->removal_state) { + case 0: + pLib->removal_state = 1; + ScheduleNextTraceRequest(pLib); + break; - case 3: - return (1); - } + case 3: + return (1); + } - return (0); + return (0); } -static int SuperTraceLibraryFinit (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceLibraryFinit(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if (pLib) { if (pLib->hAdapter) { - SuperTraceCloseAdapter (pLib->hAdapter); + SuperTraceCloseAdapter(pLib->hAdapter); } return (0); } return (-1); } -static void* SuperTraceGetHandle (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static void *SuperTraceGetHandle(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; - return (&pLib->e); + return (&pLib->e); } /* - After library handle object is gone in signaled state - this function should be called and will pick up incoming - IDI messages (return codes and indications). - */ -static int SuperTraceMessageInput (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; + After library handle object is gone in signaled state + this function should be called and will pick up incoming + IDI messages (return codes and indications). +*/ +static int SuperTraceMessageInput(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; int ret = 0; - byte Rc, Ind; + byte Rc, Ind; - if (pLib->e.complete == 255) { - /* - Process return code - */ - pLib->req_busy = 0; - Rc = pLib->e.Rc; - pLib->e.Rc = 0; + if (pLib->e.complete == 255) { + /* + Process return code + */ + pLib->req_busy = 0; + Rc = pLib->e.Rc; + pLib->e.Rc = 0; - if (pLib->removal_state == 2) { - pLib->removal_state = 3; - return (0); - } + if (pLib->removal_state == 2) { + pLib->removal_state = 3; + return (0); + } if (Rc != pLib->rc_ok) { - int ignore = 0; - /* - Auto-detect amount of events/channels and features - */ - if (pLib->general_b_ch_event == 1) { - pLib->general_b_ch_event = 2; - ignore = 1; - } else if (pLib->general_fax_event == 1) { - pLib->general_fax_event = 2; - ignore = 1; - } else if (pLib->general_mdm_event == 1) { - pLib->general_mdm_event = 2; - ignore = 1; - } else if ((pLib->ChannelsTraceActive < pLib->Channels) && pLib->ChannelsTraceActive) { - pLib->ChannelsTraceActive = pLib->Channels; - ignore = 1; - } else if (pLib->ModemTraceActive < pLib->Channels) { - pLib->ModemTraceActive = pLib->Channels; - ignore = 1; - } else if (pLib->FaxTraceActive < pLib->Channels) { - pLib->FaxTraceActive = pLib->Channels; - ignore = 1; - } else if (pLib->audio_trace_init == 2) { - ignore = 1; - pLib->audio_trace_init = 1; - } else if (pLib->eye_pattern_pending) { + int ignore = 0; + /* + Auto-detect amount of events/channels and features + */ + if (pLib->general_b_ch_event == 1) { + pLib->general_b_ch_event = 2; + ignore = 1; + } else if (pLib->general_fax_event == 1) { + pLib->general_fax_event = 2; + ignore = 1; + } else if (pLib->general_mdm_event == 1) { + pLib->general_mdm_event = 2; + ignore = 1; + } else if ((pLib->ChannelsTraceActive < pLib->Channels) && pLib->ChannelsTraceActive) { + pLib->ChannelsTraceActive = pLib->Channels; + ignore = 1; + } else if (pLib->ModemTraceActive < pLib->Channels) { + pLib->ModemTraceActive = pLib->Channels; + ignore = 1; + } else if (pLib->FaxTraceActive < pLib->Channels) { + pLib->FaxTraceActive = pLib->Channels; + ignore = 1; + } else if (pLib->audio_trace_init == 2) { + ignore = 1; + pLib->audio_trace_init = 1; + } else if (pLib->eye_pattern_pending) { pLib->eye_pattern_pending = 0; ignore = 1; } else if (pLib->audio_tap_pending) { pLib->audio_tap_pending = 0; ignore = 1; - } - - if (!ignore) { - return (-1); /* request failed */ - } - } else { - if (pLib->general_b_ch_event == 1) { - pLib->ChannelsTraceActive = pLib->Channels; - pLib->general_b_ch_event = 2; - } else if (pLib->general_fax_event == 1) { - pLib->general_fax_event = 2; - pLib->FaxTraceActive = pLib->Channels; - } else if (pLib->general_mdm_event == 1) { - pLib->general_mdm_event = 2; - pLib->ModemTraceActive = pLib->Channels; - } - } - if (pLib->audio_trace_init == 2) { - pLib->audio_trace_init = 1; - } - pLib->rc_ok = 0xff; /* default OK after assign was done */ - if ((ret = ScheduleNextTraceRequest(pLib))) { - return (-1); - } - } else { - /* - Process indication - Always 'RNR' indication if return code is pending - */ - Ind = pLib->e.Ind; - pLib->e.Ind = 0; - if (pLib->removal_state) { - pLib->e.RNum = 0; - pLib->e.RNR = 2; - } else if (pLib->req_busy) { - pLib->e.RNum = 0; - pLib->e.RNR = 1; - } else { - if (pLib->e.complete != 0x02) { - /* - Look-ahead call, set up buffers - */ - pLib->e.RNum = 1; - pLib->e.R->P = (byte*)&pLib->buffer[0]; - pLib->e.R->PLength = (word)(sizeof(pLib->buffer) - 1); - - } else { - /* - Indication reception complete, process it now - */ - byte* p = (byte*)&pLib->buffer[0]; - pLib->buffer[pLib->e.R->PLength] = 0; /* terminate I.E. with zero */ - - switch (Ind) { - case MAN_COMBI_IND: { - int total_length = pLib->e.R->PLength; - word this_ind_length; - - while (total_length > 3 && *p) { - Ind = *p++; - this_ind_length = (word)p[0] | ((word)p[1] << 8); - p += 2; - - switch (Ind) { - case MAN_INFO_IND: - if (process_idi_info (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_EVENT_IND: - if (process_idi_event (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_TRACE_IND: - if (pLib->trace_on == 1) { - /* - Ignore first trace event that is result of - EVENT_ON operation - */ - pLib->trace_on++; - } else { - /* - Delivery XLOG buffer to application - */ - if (pLib->user_proc_table.trace_proc) { - (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, - &pLib->instance, pLib->Adapter, - p, this_ind_length); - } - } - break; - default: - diva_mnt_internal_dprintf (0, DLI_ERR, "Unknown IDI Ind (DMA mode): %02x", Ind); - } - p += (this_ind_length+1); - total_length -= (4 + this_ind_length); - } - } break; - case MAN_INFO_IND: - if (process_idi_info (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_EVENT_IND: - if (process_idi_event (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_TRACE_IND: - if (pLib->trace_on == 1) { - /* - Ignore first trace event that is result of - EVENT_ON operation - */ - pLib->trace_on++; - } else { - /* - Delivery XLOG buffer to application - */ - if (pLib->user_proc_table.trace_proc) { - (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, - &pLib->instance, pLib->Adapter, - p, pLib->e.R->PLength); - } - } - break; - default: - diva_mnt_internal_dprintf (0, DLI_ERR, "Unknown IDI Ind: %02x", Ind); - } - } - } - } + } + + if (!ignore) { + return (-1); /* request failed */ + } + } else { + if (pLib->general_b_ch_event == 1) { + pLib->ChannelsTraceActive = pLib->Channels; + pLib->general_b_ch_event = 2; + } else if (pLib->general_fax_event == 1) { + pLib->general_fax_event = 2; + pLib->FaxTraceActive = pLib->Channels; + } else if (pLib->general_mdm_event == 1) { + pLib->general_mdm_event = 2; + pLib->ModemTraceActive = pLib->Channels; + } + } + if (pLib->audio_trace_init == 2) { + pLib->audio_trace_init = 1; + } + pLib->rc_ok = 0xff; /* default OK after assign was done */ + if ((ret = ScheduleNextTraceRequest(pLib))) { + return (-1); + } + } else { + /* + Process indication + Always 'RNR' indication if return code is pending + */ + Ind = pLib->e.Ind; + pLib->e.Ind = 0; + if (pLib->removal_state) { + pLib->e.RNum = 0; + pLib->e.RNR = 2; + } else if (pLib->req_busy) { + pLib->e.RNum = 0; + pLib->e.RNR = 1; + } else { + if (pLib->e.complete != 0x02) { + /* + Look-ahead call, set up buffers + */ + pLib->e.RNum = 1; + pLib->e.R->P = (byte *)&pLib->buffer[0]; + pLib->e.R->PLength = (word)(sizeof(pLib->buffer) - 1); + + } else { + /* + Indication reception complete, process it now + */ + byte *p = (byte *)&pLib->buffer[0]; + pLib->buffer[pLib->e.R->PLength] = 0; /* terminate I.E. with zero */ + + switch (Ind) { + case MAN_COMBI_IND: { + int total_length = pLib->e.R->PLength; + word this_ind_length; + + while (total_length > 3 && *p) { + Ind = *p++; + this_ind_length = (word)p[0] | ((word)p[1] << 8); + p += 2; + + switch (Ind) { + case MAN_INFO_IND: + if (process_idi_info(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_EVENT_IND: + if (process_idi_event(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_TRACE_IND: + if (pLib->trace_on == 1) { + /* + Ignore first trace event that is result of + EVENT_ON operation + */ + pLib->trace_on++; + } else { + /* + Delivery XLOG buffer to application + */ + if (pLib->user_proc_table.trace_proc) { + (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, + &pLib->instance, pLib->Adapter, + p, this_ind_length); + } + } + break; + default: + diva_mnt_internal_dprintf(0, DLI_ERR, "Unknown IDI Ind (DMA mode): %02x", Ind); + } + p += (this_ind_length + 1); + total_length -= (4 + this_ind_length); + } + } break; + case MAN_INFO_IND: + if (process_idi_info(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_EVENT_IND: + if (process_idi_event(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_TRACE_IND: + if (pLib->trace_on == 1) { + /* + Ignore first trace event that is result of + EVENT_ON operation + */ + pLib->trace_on++; + } else { + /* + Delivery XLOG buffer to application + */ + if (pLib->user_proc_table.trace_proc) { + (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, + &pLib->instance, pLib->Adapter, + p, pLib->e.R->PLength); + } + } + break; + default: + diva_mnt_internal_dprintf(0, DLI_ERR, "Unknown IDI Ind: %02x", Ind); + } + } + } + } if ((ret = ScheduleNextTraceRequest(pLib))) { return (-1); @@ -434,9 +434,9 @@ static int SuperTraceMessageInput (void* hLib) { } /* - Internal state machine responsible for scheduling of requests - */ -static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { + Internal state machine responsible for scheduling of requests +*/ +static int ScheduleNextTraceRequest(diva_strace_context_t *pLib) { char name[64]; int ret = 0; int i; @@ -445,50 +445,50 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { return (0); } - if (pLib->removal_state == 1) { - if (SuperTraceREMOVE (pLib->hAdapter)) { - pLib->removal_state = 3; - } else { - pLib->req_busy = 1; - pLib->removal_state = 2; - } - return (0); - } + if (pLib->removal_state == 1) { + if (SuperTraceREMOVE(pLib->hAdapter)) { + pLib->removal_state = 3; + } else { + pLib->req_busy = 1; + pLib->removal_state = 2; + } + return (0); + } - if (pLib->removal_state) { - return (0); - } + if (pLib->removal_state) { + return (0); + } - if (!pLib->general_b_ch_event) { + if (!pLib->general_b_ch_event) { if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\B Event", pLib->buffer))) { - return (-1); - } - pLib->general_b_ch_event = 1; + return (-1); + } + pLib->general_b_ch_event = 1; pLib->req_busy = 1; return (0); - } + } - if (!pLib->general_fax_event) { + if (!pLib->general_fax_event) { if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\FAX Event", pLib->buffer))) { - return (-1); - } - pLib->general_fax_event = 1; + return (-1); + } + pLib->general_fax_event = 1; pLib->req_busy = 1; return (0); - } + } - if (!pLib->general_mdm_event) { + if (!pLib->general_mdm_event) { if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\Modem Event", pLib->buffer))) { - return (-1); - } - pLib->general_mdm_event = 1; + return (-1); + } + pLib->general_mdm_event = 1; pLib->req_busy = 1; return (0); - } + } if (pLib->ChannelsTraceActive < pLib->Channels) { pLib->ChannelsTraceActive++; - sprintf (name, "State\\B%d\\Line", pLib->ChannelsTraceActive); + sprintf(name, "State\\B%d\\Line", pLib->ChannelsTraceActive); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->ChannelsTraceActive--; return (-1); @@ -499,7 +499,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (pLib->ModemTraceActive < pLib->Channels) { pLib->ModemTraceActive++; - sprintf (name, "State\\B%d\\Modem\\Event", pLib->ModemTraceActive); + sprintf(name, "State\\B%d\\Modem\\Event", pLib->ModemTraceActive); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->ModemTraceActive--; return (-1); @@ -510,7 +510,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (pLib->FaxTraceActive < pLib->Channels) { pLib->FaxTraceActive++; - sprintf (name, "State\\B%d\\FAX\\Event", pLib->FaxTraceActive); + sprintf(name, "State\\B%d\\FAX\\Event", pLib->FaxTraceActive); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->FaxTraceActive--; return (-1); @@ -521,12 +521,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->trace_mask_init) { word tmp = 0x0000; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\Event Enable", - &tmp, - 0x87, /* MI_BITFLD */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\Event Enable", + &tmp, + 0x87, /* MI_BITFLD */ + sizeof(tmp))) { return (-1); } pLib->trace_mask_init = 1; @@ -536,12 +536,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->audio_trace_init) { dword tmp = 0x00000000; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\AudioCh# Enable", - &tmp, - 0x87, /* MI_BITFLD */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\AudioCh# Enable", + &tmp, + 0x87, /* MI_BITFLD */ + sizeof(tmp))) { return (-1); } pLib->audio_trace_init = 2; @@ -551,12 +551,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->bchannel_init) { dword tmp = 0x00000000; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\B-Ch# Enable", - &tmp, - 0x87, /* MI_BITFLD */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\B-Ch# Enable", + &tmp, + 0x87, /* MI_BITFLD */ + sizeof(tmp))) { return (-1); } pLib->bchannel_init = 1; @@ -566,12 +566,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->trace_length_init) { word tmp = 30; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\Max Log Length", - &tmp, - 0x82, /* MI_UINT */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\Max Log Length", + &tmp, + 0x82, /* MI_UINT */ + sizeof(tmp))) { return (-1); } pLib->trace_length_init = 1; @@ -580,9 +580,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->trace_on) { - if (SuperTraceTraceOnRequest (pLib->hAdapter, - "Trace\\Log Buffer", - pLib->buffer)) { + if (SuperTraceTraceOnRequest(pLib->hAdapter, + "Trace\\Log Buffer", + pLib->buffer)) { return (-1); } pLib->trace_on = 1; @@ -591,12 +591,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->trace_event_mask != pLib->current_trace_event_mask) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\Event Enable", - &pLib->trace_event_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->trace_event_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\Event Enable", + &pLib->trace_event_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->trace_event_mask))) { return (-1); } pLib->current_trace_event_mask = pLib->trace_event_mask; @@ -605,12 +605,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if ((pLib->audio_tap_pending >= 0) && (pLib->audio_tap_mask != pLib->current_audio_tap_mask)) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\AudioCh# Enable", - &pLib->audio_tap_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->audio_tap_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\AudioCh# Enable", + &pLib->audio_tap_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->audio_tap_mask))) { return (-1); } pLib->current_audio_tap_mask = pLib->audio_tap_mask; @@ -620,12 +620,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if ((pLib->eye_pattern_pending >= 0) && (pLib->audio_tap_mask != pLib->current_eye_pattern_mask)) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\EyeCh# Enable", - &pLib->audio_tap_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->audio_tap_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\EyeCh# Enable", + &pLib->audio_tap_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->audio_tap_mask))) { return (-1); } pLib->current_eye_pattern_mask = pLib->audio_tap_mask; @@ -635,12 +635,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->bchannel_trace_mask != pLib->current_bchannel_trace_mask) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\B-Ch# Enable", - &pLib->bchannel_trace_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->bchannel_trace_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\B-Ch# Enable", + &pLib->bchannel_trace_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->bchannel_trace_mask))) { return (-1); } pLib->current_bchannel_trace_mask = pLib->bchannel_trace_mask; @@ -649,9 +649,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->trace_events_down) { - if (SuperTraceTraceOnRequest (pLib->hAdapter, - "Events Down", - pLib->buffer)) { + if (SuperTraceTraceOnRequest(pLib->hAdapter, + "Events Down", + pLib->buffer)) { return (-1); } pLib->trace_events_down = 1; @@ -660,9 +660,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->l1_trace) { |