13 #define DBG_MAGIC (0x47114711L)
15 static void DI_register (void *arg);
16 static void DI_deregister (pDbgHandle hDbg);
17 static void DI_format (int do_lock, word id, int type, char *format, va_list argument_list);
18 static void DI_format_locked (word id, int type, char *format, va_list argument_list);
19 static void DI_format_old (word id, char *format, va_list ap) { }
20 static void DiProcessEventLog (unsigned short id, unsigned long msgID, va_list ap) { }
21 static void single_p (byte * P, word * PLength, byte Id);
22 static void diva_maint_xdi_cb (ENTITY* e);
23 static word SuperTraceCreateReadReq (byte* P, const char* path);
24 static int diva_mnt_cmp_nmbr (const char* nmbr);
25 static void diva_free_dma_descriptor (IDI_CALL request, int nr);
26 static int diva_get_dma_descriptor (IDI_CALL request, dword *dma_magic);
27 void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...);
29 static dword MaxDumpSize = 256 ;
30 static dword MaxXlogSize = 2 + 128 ;
31 static char TraceFilter[DIVA_MAX_SELECTIVE_FILTER_LENGTH+1];
32 static int TraceFilterIdent = -1;
33 static int TraceFilterChannel = -1;
35 typedef struct _diva_maint_client {
46 diva_strace_library_interface_t* pIdiLib;
48 char xbuffer[2048+512];
52 } diva_maint_client_t;
53 static diva_maint_client_t clients[MAX_DESCRIPTORS];
55 static void diva_change_management_debug_mask (diva_maint_client_t* pC, dword old_mask);
57 static void diva_maint_error (void* user_context,
58 diva_strace_library_interface_t* hLib,
63 static void diva_maint_state_change_notify (void* user_context,
64 diva_strace_library_interface_t* hLib,
66 diva_trace_line_state_t* channel,
68 static void diva_maint_trace_notify (void* user_context,
69 diva_strace_library_interface_t* hLib,
76 typedef struct MSG_QUEUE {
77 dword Size; /* total size of queue (constant) */
78 byte *Base; /* lowest address (constant) */
79 byte *High; /* Base + Size (constant) */
80 byte *Head; /* first message in queue (if any) */
81 byte *Tail; /* first free position */
82 byte *Wrap; /* current wraparound position */
83 dword Count; /* current no of bytes in queue */
86 typedef struct MSG_HEAD {
87 volatile dword Size; /* size of data following MSG_HEAD */
88 #define MSG_INCOMPLETE 0x8000 /* ored to Size until queueCompleteMsg */
91 #define queueCompleteMsg(p) do{ ((MSG_HEAD *)p - 1)->Size &= ~MSG_INCOMPLETE; }while(0)
92 #define queueCount(q) ((q)->Count)
93 #define MSG_NEED(size) \
94 ( (sizeof(MSG_HEAD) + size + sizeof(dword) - 1) & ~(sizeof(dword) - 1) )
96 static void queueInit (MSG_QUEUE *Q, byte *Buffer, dword sizeBuffer) {
98 Q->Base = Q->Head = Q->Tail = Buffer;
99 Q->High = Buffer + sizeBuffer;
104 static byte *queueAllocMsg (MSG_QUEUE *Q, word size) {
105 /* Allocate 'size' bytes at tail of queue which will be filled later
106 * directly with callers own message header info and/or message.
107 * An 'alloced' message is marked incomplete by oring the 'Size' field
108 * with MSG_INCOMPLETE.
109 * This must be reset via queueCompleteMsg() after the message is filled.
110 * As long as a message is marked incomplete queuePeekMsg() will return
111 * a 'queue empty' condition when it reaches such a message. */
114 word need = MSG_NEED(size);
116 if (Q->Tail == Q->Head) {
117 if (Q->Wrap || need > Q->Size) {
118 return NULL; /* full */
120 goto alloc; /* empty */
123 if (Q->Tail > Q->Head) {
124 if (Q->Tail + need <= Q->High) goto alloc; /* append */
125 if (Q->Base + need > Q->Head) {
126 return NULL; /* too much */
128 /* wraparound the queue (but not the message) */
134 if (Q->Tail + need > Q->Head) {
135 return NULL; /* too much */
139 Msg = (MSG_HEAD *)Q->Tail;
141 Msg->Size = size | MSG_INCOMPLETE;
148 return ((byte*)(Msg + 1));
151 static void queueFreeMsg (MSG_QUEUE *Q) {
152 /* Free the message at head of queue */
154 word size = ((MSG_HEAD *)Q->Head)->Size & ~MSG_INCOMPLETE;
156 Q->Head += MSG_NEED(size);
160 if (Q->Head >= Q->Wrap) {
164 } else if (Q->Head >= Q->Tail) {
165 Q->Head = Q->Tail = Q->Base;
169 static byte *queuePeekMsg (MSG_QUEUE *Q, word *size) {
170 /* Show the first valid message in queue BUT DON'T free the message.
171 * After looking on the message contents it can be freed queueFreeMsg()
172 * or simply remain in message queue. */
174 MSG_HEAD *Msg = (MSG_HEAD *)Q->Head;
176 if (((byte *)Msg == Q->Tail && !Q->Wrap) ||
177 (Msg->Size & MSG_INCOMPLETE)) {
181 return ((byte *)(Msg + 1));
188 static MSG_QUEUE* dbg_queue;
189 static byte* dbg_base;
190 static int external_dbg_queue;
191 static diva_os_spin_lock_t dbg_q_lock;
192 static diva_os_spin_lock_t dbg_adapter_lock;
193 static int dbg_q_busy;
194 static volatile dword dbg_sequence;
195 static dword start_sec;
196 static dword start_usec;
200 Initialize run time queue structures.
201 base: base of the message queue
202 length: length of the message queue
203 do_init: perfor queue reset
205 return: zero on success, -1 on error
207 int diva_maint_init (byte* base, unsigned long length, int do_init) {
208 if (dbg_queue || (!base) || (length < (4096*4))) {
213 TraceFilterIdent = -1;
214 TraceFilterChannel = -1;
218 diva_os_get_time (&start_sec, &start_usec);
220 *(dword*)base = (dword)DBG_MAGIC; /* Store Magic */
221 base += sizeof(dword);
222 length -= sizeof(dword);
224 *(dword*)base = 2048; /* Extension Field Length */
225 base += sizeof(dword);
226 length -= sizeof(dword);
228 strcpy (base, "KERNEL MODE BUFFER\n");
232 *(dword*)base = 0; /* Terminate extension */
233 base += sizeof(dword);
234 length -= sizeof(dword);
236 *(void**)base = (void*)(base+sizeof(void*)); /* Store Base */
237 base += sizeof(void*);
238 length -= sizeof(void*);
240 dbg_queue = (MSG_QUEUE*)base;
241 queueInit (dbg_queue, base + sizeof(MSG_QUEUE), length - sizeof(MSG_QUEUE) - 512);
242 external_dbg_queue = 0;
245 external_dbg_queue = 1; /* memory was located on the external device */
249 if (diva_os_initialize_spin_lock (&dbg_q_lock, "dbg_init")) {
252 external_dbg_queue = 0;
256 if (diva_os_initialize_spin_lock (&dbg_adapter_lock, "dbg_init")) {
257 diva_os_destroy_spin_lock(&dbg_q_lock, "dbg_init");
260 external_dbg_queue = 0;
270 return address of internal queue or zero if queue
273 void* diva_maint_finit (void) {
274 void* ret = (void*)dbg_base;
281 diva_os_destroy_spin_lock(&dbg_q_lock, "dbg_finit");
282 diva_os_destroy_spin_lock(&dbg_adapter_lock, "dbg_finit");
285 if (external_dbg_queue) {
288 external_dbg_queue = 0;
290 for (i = 1; i < ARRAY_SIZE(clients); i++) {
291 if (clients[i].pmem) {
292 diva_os_free (0, clients[i].pmem);
301 Return amount of messages in debug queue
303 dword diva_dbg_q_length (void) {
304 return (dbg_queue ? queueCount(dbg_queue) : 0);
309 Lock message queue and return the pointer to the first
312 diva_dbg_entry_head_t* diva_maint_get_message (word* size,
313 diva_os_spin_lock_magic_t* old_irql) {
314 diva_dbg_entry_head_t* pmsg = NULL;
316 diva_os_enter_spin_lock (&dbg_q_lock, old_irql, "read");
318 diva_os_leave_spin_lock (&dbg_q_lock, old_irql, "read_busy");
323 if (!(pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, size))) {
325 diva_os_leave_spin_lock (&dbg_q_lock, old_irql, "read_empty");
333 acknowledge last message and unlock queue
335 void diva_maint_ack_message (int do_release,
336 diva_os_spin_lock_magic_t* old_irql) {
341 queueFreeMsg (dbg_queue);
344 diva_os_leave_spin_lock (&dbg_q_lock, old_irql, "read_ack");
350 PRT COMP function used to register
351 with MAINT adapter or log in compatibility
352 mode in case older driver version is connected too
354 void diva_maint_prtComp (char *format, ...) {
361 va_start(ap, format);
364 register to new log driver functions
366 if ((format[0] == 0) && ((unsigned char)format[1] == 255)) {
367 hDbg = va_arg(ap, void *); /* ptr to DbgHandle */
374 static void DI_register (void *arg) {
375 diva_os_spin_lock_magic_t old_irql;
378 int id, free_id = -1, best_id = 0;
380 diva_os_get_time (&sec, &usec);
382 hDbg = (pDbgHandle)arg ;
384 Check for bad args, specially for the old obsolete debug handle
386 if ((hDbg == NULL) ||
387 ((hDbg->id == 0) && (((_OldDbgHandle_ *)hDbg)->id == -1)) ||
388 (hDbg->Registered != 0)) {
392 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "register");
394 for (id = 1; id < ARRAY_SIZE(clients); id++) {
395 if (clients[id].hDbg == hDbg) {
397 driver already registered
399 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register");
402 if (clients[id].hDbg) { /* slot is busy */
406 if (!strcmp (clients[id].drvName, hDbg->drvName)) {
408 This driver was already registered with this name
409 and slot is still free - reuse it
414 if (!clients[id].hDbg) { /* slot is busy */
420 diva_dbg_entry_head_t* pmsg = NULL;
426 Register new driver with id == free_id
428 clients[free_id].hDbg = hDbg;
429 clients[free_id].sec = sec;
430 clients[free_id].usec = usec;
431 strcpy (clients[free_id].drvName, hDbg->drvName);
433 clients[free_id].dbgMask = hDbg->dbgMask;
435 hDbg->dbgMask |= clients[free_id].last_dbgMask;
437 clients[free_id].last_dbgMask = 0;
440 hDbg->Registered = DBG_HANDLE_REG_NEW ;
441 hDbg->id = (byte)free_id;
442 hDbg->dbg_end = DI_deregister;
443 hDbg->dbg_prt = DI_format_locked;
444 hDbg->dbg_ev = DiProcessEventLog;
445 hDbg->dbg_irq = DI_format_locked;
446 if (hDbg->Version > 0) {
447 hDbg->dbg_old = DI_format_old;
449 hDbg->next = (pDbgHandle)DBG_MAGIC;
452 Log driver register, MAINT driver ID is '0'
454 len = sprintf (tmp, "DIMAINT - drv # %d = '%s' registered",
455 free_id, hDbg->drvName);
457 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
458 (word)(len+1+sizeof(*pmsg))))) {
459 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
460 queueFreeMsg (dbg_queue);
467 pmsg->sequence = dbg_sequence++;
468 pmsg->time_sec = sec;
469 pmsg->time_usec = usec;
470 pmsg->facility = MSG_TYPE_STRING;
472 pmsg->drv_id = 0; /* id 0 - DIMAINT */
474 pmsg->data_length = len+1;
476 memcpy (&pmsg[1], tmp, len+1);
477 queueCompleteMsg (pmsg);
478 diva_maint_wakeup_read();
482 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register");
485 static void DI_deregister (pDbgHandle hDbg) {
486 diva_os_spin_lock_magic_t old_irql, old_irql1;
492 diva_os_get_time (&sec, &usec);
494 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "read");
495 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "read");
497 for (i = 1; i < ARRAY_SIZE(clients); i++) {
498 if (clients[i].hDbg == hDbg) {
499 diva_dbg_entry_head_t* pmsg;
503 clients[i].hDbg = NULL;
507 hDbg->dbg_end = NULL;
508 hDbg->dbg_prt = NULL;
509 hDbg->dbg_irq = NULL;
510 if (hDbg->Version > 0)
511 hDbg->dbg_old = NULL;
512 hDbg->Registered = 0;
515 if (clients[i].pIdiLib) {
516 (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib);
517 clients[i].pIdiLib = NULL;
519 pmem = clients[i].pmem;
520 clients[i].pmem = NULL;
524 Log driver register, MAINT driver ID is '0'
526 len = sprintf (tmp, "DIMAINT - drv # %d = '%s' de-registered",
529 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
530 (word)(len+1+sizeof(*pmsg))))) {
531 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
532 queueFreeMsg (dbg_queue);
539 pmsg->sequence = dbg_sequence++;
540 pmsg->time_sec = sec;
541 pmsg->time_usec = usec;
542 pmsg->facility = MSG_TYPE_STRING;
544 pmsg->drv_id = 0; /* id 0 - DIMAINT */
546 pmsg->data_length = len+1;
548 memcpy (&pmsg[1], tmp, len+1);
549 queueCompleteMsg (pmsg);
550 diva_maint_wakeup_read();
557 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "read_ack");
558 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "read_ack");
561 diva_os_free (0, pmem);
565 static void DI_format_locked (unsigned short id,
568 va_list argument_list) {
569 DI_format (1, id, type, format, argument_list);
572 static void DI_format (int do_lock,
577 diva_os_spin_lock_magic_t old_irql;
579 diva_dbg_entry_head_t* pmsg = NULL;
582 static char fmtBuf[MSG_FRAME_MAX_SIZE+sizeof(*pmsg)+1];
586 if (diva_os_in_irq()) {
592 ((TraceFilter[0] != 0) && ((TraceFilterIdent < 0) || (TraceFilterChannel < 0)))) {
598 diva_os_get_time (&sec, &usec);
601 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "format");
609 if (!(length = va_arg(ap, unsigned long))) {
612 if (length > MaxDumpSize) {
613 length = MaxDumpSize;
615 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
616 (word)length+sizeof(*pmsg)))) {
617 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
618 queueFreeMsg (dbg_queue);
624 memcpy (&pmsg[1], format, length);
625 pmsg->sequence = dbg_sequence++;
626 pmsg->time_sec = sec;
627 pmsg->time_usec = usec;
628 pmsg->facility = MSG_TYPE_BINARY ;
629 pmsg->dli = type; /* DLI_XXX */
630 pmsg->drv_id = id; /* driver MAINT id */
632 pmsg->data_length = length;
633 queueCompleteMsg (pmsg);
639 data = va_arg(ap, char*);
640 code = (unsigned short)va_arg(ap, unsigned int);
641 length = (unsigned long) va_arg(ap, unsigned int);
643 if (length > MaxXlogSize)
644 length = MaxXlogSize;
646 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
647 (word)length+sizeof(*pmsg)+2))) {
648 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
649 queueFreeMsg (dbg_queue);
656 p[0] = (char)(code) ;
657 p[1] = (char)(code >> 8) ;
658 if (data && length) {
659 memcpy (&p[2], &data[0], length) ;
663 pmsg->sequence = dbg_sequence++;
664 pmsg->time_sec = sec;
665 pmsg->time_usec = usec;
666 pmsg->facility = MSG_TYPE_BINARY ;
667 pmsg->dli = type; /* DLI_XXX */
668 pmsg->drv_id = id; /* driver MAINT id */
670 pmsg->data_length = length;
671 queueCompleteMsg (pmsg);
692 if ((length = (unsigned long)vsprintf (&fmtBuf[0], format, ap)) > 0) {
693 length += (sizeof(*pmsg)+1);
695 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
697 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
698 queueFreeMsg (dbg_queue);
704 pmsg->sequence = dbg_sequence++;
705 pmsg->time_sec = sec;
706 pmsg->time_usec = usec;
707 pmsg->facility = MSG_TYPE_STRING;
708 pmsg->dli = type; /* DLI_XXX */
709 pmsg->drv_id = id; /* driver MAINT id */
711 pmsg->data_length = length - sizeof(*pmsg);
713 memcpy (&pmsg[1], fmtBuf, pmsg->data_length);
714 queueCompleteMsg (pmsg);
721 if (queueCount(dbg_queue)) {
722 diva_maint_wakeup_read();
726 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "format");
731 Write driver ID and driver revision to callers buffer
733 int diva_get_driver_info (dword id, byte* data, int data_length) {
734 diva_os_spin_lock_magic_t old_irql;
738 if (!data || !id || (data_length < 17) ||
739 (id >= ARRAY_SIZE(clients))) {
743 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "driver info");
745 if (clients[id].hDbg) {
747 *p++ = (byte)clients[id].sec; /* save seconds */
748 *p++ = (byte)(clients[id].sec >> 8);
749 *p++ = (byte)(clients[id].sec >> 16);
750 *p++ = (byte)(clients[id].sec >> 24);
752 *p++ = (byte)(clients[id].usec/1000); /* save mseconds */
753 *p++ = (byte)((clients[id].usec/1000) >> 8);
754 *p++ = (byte)((clients[id].usec/1000) >> 16);
755 *p++ = (byte)((clients[id].usec/1000) >> 24);
759 if ((to_copy = min(strlen(clients[id].drvName), (size_t)(data_length-1)))) {
760 memcpy (p, clients[id].drvName, to_copy);
762 data_length -= to_copy;
763 if ((data_length >= 4) && clients[id].hDbg->drvTag[0]) {
766 if ((to_copy = min(strlen(clients[id].hDbg->drvTag), (size_t)(data_length-2)))) {
767 memcpy (p, clients[id].hDbg->drvTag, to_copy);
769 data_length -= to_copy;
770 if (data_length >= 2) {
780 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "driver info");
785 int diva_get_driver_dbg_mask (dword id, byte* data) {
786 diva_os_spin_lock_magic_t old_irql;
789 if (!data || !id || (id >= ARRAY_SIZE(clients))) {
792 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "driver info");
794 if (clients[id].hDbg) {
796 *data++= (byte)(clients[id].hDbg->dbgMask);
797 *data++= (byte)(clients[id].hDbg->dbgMask >> 8);
798 *data++= (byte)(clients[id].hDbg->dbgMask >> 16);
799 *data++= (byte)(clients[id].hDbg->dbgMask >> 24);
802 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "driver info");
807 int diva_set_driver_dbg_mask (dword id, dword mask) {
808 diva_os_spin_lock_magic_t old_irql, old_irql1;
812 if (!id || (id >= ARRAY_SIZE(clients))) {
816 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask");
817 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "dbg mask");
819 if (clients[id].hDbg) {
820 dword old_mask = clients[id].hDbg->dbgMask;
822 clients[id].hDbg->dbgMask = mask;
823 clients[id].last_dbgMask = (clients[id].hDbg->dbgMask | clients[id].dbgMask);
825 diva_change_management_debug_mask (&clients[id], old_mask);
829 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "dbg mask");
831 if (clients[id].request_pending) {
832 clients[id].request_pending = 0;
833 (*(clients[id].request))((ENTITY*)(*(clients[id].pIdiLib->DivaSTraceGetHandle))(clients[id].pIdiLib->hLib));
836 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask");
841 static int diva_get_idi_adapter_info (IDI_CALL request, dword* serial, dword* logical) {
842 IDI_SYNC_REQ sync_req;
844 sync_req.xdi_logical_adapter_number.Req = 0;
845 sync_req.xdi_logical_adapter_number.Rc = IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER;
846 (*request)((ENTITY *)&sync_req);
847 *logical = sync_req.xdi_logical_adapter_number.info.logical_adapter_number;
849 sync_req.GetSerial.Req = 0;
850 sync_req.GetSerial.Rc = IDI_SYNC_REQ_GET_SERIAL;
851 sync_req.GetSerial.serial = 0;
852 (*request)((ENTITY *)&sync_req);
853 *serial = sync_req.GetSerial.serial;
859 Register XDI adapter as MAINT compatible driver
861 void diva_mnt_add_xdi_adapter (const DESCRIPTOR* d) {
862 diva_os_spin_lock_magic_t old_irql, old_irql1;
863 dword sec, usec, logical, serial, org_mask;
864 int id, best_id = 0, free_id = -1;
866 diva_dbg_entry_head_t* pmsg = NULL;
871 diva_os_get_time (&sec, &usec);
872 diva_get_idi_adapter_info (d->request, &serial, &logical);
873 if (serial & 0xff000000) {
874 sprintf (tmp, "ADAPTER:%d SN:%u-%d",
877 (byte)(((serial & 0xff000000) >> 24) + 1));
879 sprintf (tmp, "ADAPTER:%d SN:%u", (int)logical, serial);
882 if (!(pmem = diva_os_malloc (0, DivaSTraceGetMemotyRequirement (d->channels)))) {
885 memset (pmem, 0x00, DivaSTraceGetMemotyRequirement (d->channels));
887 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "register");
888 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "register");
890 for (id = 1; id < ARRAY_SIZE(clients); id++) {
891 if (clients[id].hDbg && (clients[id].request == d->request)) {
892 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register");
893 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register");
894 diva_os_free(0, pmem);
897 if (clients[id].hDbg) { /* slot is busy */
903 if (!strcmp (clients[id].drvName, tmp)) {
905 This driver was already registered with this name
906 and slot is still free - reuse it
915 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register");
916 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register");
917 diva_os_free (0, pmem);
922 clients[id].request = d->request;
923 clients[id].request_pending = 0;
924 clients[id].hDbg = &clients[id].Dbg;
925 clients[id].sec = sec;
926 clients[id].usec = usec;
927 strcpy (clients[id].drvName, tmp);
928 strcpy (clients[id].Dbg.drvName, tmp);
929 clients[id].Dbg.drvTag[0] = 0;
930 clients[id].logical = (int)logical;
931 clients[id].channels = (int)d->channels;
932 clients[id].dma_handle = -1;
934 clients[id].Dbg.dbgMask = 0;
935 clients[id].dbgMask = clients[id].Dbg.dbgMask;
937 clients[id].Dbg.dbgMask |= clients[free_id].last_dbgMask;
939 clients[id].last_dbgMask = 0;
941 clients[id].Dbg.Registered = DBG_HANDLE_REG_NEW;
942 clients[id].Dbg.id = (byte)id;
943 clients[id].Dbg.dbg_end = DI_deregister;
944 clients[id].Dbg.dbg_prt = DI_format_locked;
945 clients[id].Dbg.dbg_ev = DiProcessEventLog;
946 clients[id].Dbg.dbg_irq = DI_format_locked;
947 clients[id].Dbg.next = (pDbgHandle)DBG_MAGIC;
950 diva_trace_library_user_interface_t diva_maint_user_ifc = { &clients[id],
951 diva_maint_state_change_notify,
952 diva_maint_trace_notify,
956 Attach to adapter management interface
958 if ((clients[id].pIdiLib =
959 DivaSTraceLibraryCreateInstance ((int)logical, &diva_maint_user_ifc, pmem))) {
960 if (((*(clients[id].pIdiLib->DivaSTraceLibraryStart))(clients[id].pIdiLib->hLib))) {
961 diva_mnt_internal_dprintf (0, DLI_ERR, "Adapter(%d) Start failed", (int)logical);
962 (*(clients[id].pIdiLib->DivaSTraceLibraryFinit))(clients[id].pIdiLib->hLib);
963 clients[id].pIdiLib = NULL;
966 diva_mnt_internal_dprintf (0, DLI_ERR, "A(%d) management init failed", (int)logical);
970 if (!clients[id].pIdiLib) {
971 clients[id].request = NULL;
972 clients[id].request_pending = 0;
973 clients[id].hDbg = NULL;
974 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register");
975 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register");
976 diva_os_free (0, pmem);
981 Log driver register, MAINT driver ID is '0'
983 len = sprintf (tmp, "DIMAINT - drv # %d = '%s' registered",
984 id, clients[id].Dbg.drvName);
986 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
987 (word)(len+1+sizeof(*pmsg))))) {
988 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
989 queueFreeMsg (dbg_queue);
996 pmsg->sequence = dbg_sequence++;
997 pmsg->time_sec = sec;
998 pmsg->time_usec = usec;
999 pmsg->facility = MSG_TYPE_STRING;
1000 pmsg->dli = DLI_REG;
1001 pmsg->drv_id = 0; /* id 0 - DIMAINT */
1003 pmsg->data_length = len+1;
1005 memcpy (&pmsg[1], tmp, len+1);
1006 queueCompleteMsg (pmsg);
1007 diva_maint_wakeup_read();
1010 org_mask = clients[id].Dbg.dbgMask;
1011 clients[id].Dbg.dbgMask = 0;
1013 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register");
1015 if (clients[id].request_pending) {
1016 clients[id].request_pending = 0;
1017 (*(clients[id].request))((ENTITY*)(*(clients[id].pIdiLib->DivaSTraceGetHandle))(clients[id].pIdiLib->hLib));
1020 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register");
1022 diva_set_driver_dbg_mask (id, org_mask);
1026 De-Register XDI adapter
1028 void diva_mnt_remove_xdi_adapter (const DESCRIPTOR* d) {
1029 diva_os_spin_lock_magic_t old_irql, old_irql1;
1035 diva_os_get_time (&sec, &usec);
1037 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "read");
1038 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "read");
1040 for (i = 1; i < ARRAY_SIZE(clients); i++) {
1041 if (clients[i].hDbg && (clients[i].request == d->request)) {
1042 diva_dbg_entry_head_t* pmsg;
1046 if (clients[i].pIdiLib) {
1047 (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib);
1048 clients[i].pIdiLib = NULL;
1050 pmem = clients[i].pmem;
1051 clients[i].pmem = NULL;
1054 clients[i].hDbg = NULL;
1055 clients[i].request_pending = 0;
1056 if (clients[i].dma_handle >= 0) {
1060 diva_free_dma_descriptor (clients[i].request, clients[i].dma_handle);
1061 clients[i].dma_handle = -1;
1063 clients[i].request = NULL;
1066 Log driver register, MAINT driver ID is '0'
1068 len = sprintf (tmp, "DIMAINT - drv # %d = '%s' de-registered",
1069 i, clients[i].Dbg.drvName);
1071 memset (&clients[i].Dbg, 0x00, sizeof(clients[i].Dbg));
1073 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
1074 (word)(len+1+sizeof(*pmsg))))) {
1075 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
1076 queueFreeMsg (dbg_queue);
1083 pmsg->sequence = dbg_sequence++;
1084 pmsg->time_sec = sec;
1085 pmsg->time_usec = usec;
1086 pmsg->facility = MSG_TYPE_STRING;
1087 pmsg->dli = DLI_REG;
1088 pmsg->drv_id = 0; /* id 0 - DIMAINT */
1090 pmsg->data_length = len+1;
1092 memcpy (&pmsg[1], tmp, len+1);
1093 queueCompleteMsg (pmsg);
1094 diva_maint_wakeup_read();
1101 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "read_ack");
1102 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "read_ack");
1105 diva_os_free (0, pmem);
1109 /* ----------------------------------------------------------------
1110 Low level interface for management interface client
1111 ---------------------------------------------------------------- */
1113 Return handle to client structure
1115 void* SuperTraceOpenAdapter (int AdapterNumber) {
1118 for (i = 1; i < ARRAY_SIZE(clients); i++) {
1119 if (clients[i].hDbg && clients[i].request && (clients[i].logical == AdapterNumber)) {
1120 return (&clients[i]);
1127 int SuperTraceCloseAdapter (void* AdapterHandle) {
1131 int SuperTraceReadRequest (void* AdapterHandle, const char* name, byte* data) {
1132 diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle;
1134 if (pC && pC->pIdiLib && pC->request) {
1135 ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib);
1136 byte* xdata = (byte*)&pC->xbuffer[0];
1140 if (!strcmp(name, "\\")) { /* Read ROOT */
1143 length = SuperTraceCreateReadReq (xdata, name);
1144 single_p (xdata, &length, 0); /* End Of Message */
1148 e->X->PLength = length;
1149 e->X->P = (byte*)xdata;
1151 pC->request_pending = 1;
1159 int SuperTraceGetNumberOfChannels (void* AdapterHandle) {
1160 if (AdapterHandle) {
1161 diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle;
1163 return (pC->channels);
1169 int SuperTraceASSIGN (void* AdapterHandle, byte* data) {
1170 diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle;
1172 if (pC && pC->pIdiLib && pC->request) {
1173 ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib);
1175 char buffer[((sizeof(preq->xdi_extended_features)+4) > sizeof(ENTITY)) ? (sizeof(preq->xdi_extended_features)+4) : sizeof(ENTITY)];
1177 word assign_data_length = 1;
1181 preq = (IDI_SYNC_REQ*)&buffer[0];
1182 preq->xdi_extended_features.Req = 0;
1183 preq->xdi_extended_features.Rc = IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES;
1184 preq->xdi_extended_features.info.buffer_length_in_bytes = sizeof(features);
1185 preq->xdi_extended_features.info.features = &features[0];
1187 (*(pC->request))((ENTITY*)preq);
1189 if ((features[0] & DIVA_XDI_EXTENDED_FEATURES_VALID) &&
1190 (features[0] & DIVA_XDI_EXTENDED_FEATURE_MANAGEMENT_DMA)) {
1191 dword uninitialized_var(rx_dma_magic);
1192 if ((pC->dma_handle = diva_get_dma_descriptor (pC->request, &rx_dma_magic)) >= 0) {
1193 pC->xbuffer[0] = LLI;
1195 pC->xbuffer[2] = 0x40;
1196 pC->xbuffer[3] = (byte)pC->dma_handle;
1197 pC->xbuffer[4] = (byte)rx_dma_magic;
1198 pC->xbuffer[5] = (byte)(rx_dma_magic >> 8);
1199 pC->xbuffer[6] = (byte)(rx_dma_magic >> 16);
1200 pC->xbuffer[7] = (byte)(rx_dma_magic >> 24);
1201 pC->xbuffer[8] = (byte)(DIVA_MAX_MANAGEMENT_TRANSFER_SIZE & 0xFF);
1202 pC->xbuffer[9] = (byte)(DIVA_MAX_MANAGEMENT_TRANSFER_SIZE >> 8);
1203 pC->xbuffer[10] = 0;
1205 assign_data_length = 11;
1208 pC->dma_handle = -1;
1212 e->callback = diva_maint_xdi_cb;
1217 e->X->PLength = assign_data_length;
1218 e->X->P = (byte*)&pC->xbuffer[0];
1220 pC->request_pending = 1;
1228 int SuperTraceREMOVE (void* AdapterHandle) {
1229 diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle;
1231 if (pC && pC->pIdiLib && pC->request) {
1232 ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib);
1239 e->X->P = (byte*)&pC->xbuffer[0];
1242 pC->request_pending = 1;
1250 int SuperTraceTraceOnRequest(void* hAdapter, const char* name, byte* data) {
1251 diva_maint_client_t* pC = (diva_maint_client_t*)hAdapter;
1253 if (pC && pC->pIdiLib && pC->request) {
1254 ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib);
1255 byte* xdata = (byte*)&pC->xbuffer[0];
1259 if (!strcmp(name, "\\")) { /* Read ROOT */
1262 length = SuperTraceCreateReadReq (xdata, name);
1263 single_p (xdata, &length, 0); /* End Of Message */
1264 e->Req = MAN_EVENT_ON;
1266 e->X->PLength = length;
1267 e->X->P = (byte*)xdata;
1269 pC->request_pending = 1;
1277 int SuperTraceWriteVar (void* AdapterHandle,
1283 diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle;
1285 if (pC && pC->pIdiLib && pC->request) {
1286 ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib);
1287 diva_man_var_header_t* pVar = (diva_man_var_header_t*)&pC->xbuffer[0];
1288 word length = SuperTraceCreateReadReq ((byte*)pVar, name);
1290 memcpy (&pC->xbuffer[length], var, var_length);
1291 length += var_length;
1292 pVar->length += var_length;
1293 pVar->value_length = var_length;
1295 single_p ((byte*)pVar, &length, 0); /* End Of Message */
1299 e->X->PLength = length;
1300 e->X->P = (byte*)pVar;
1302 pC->request_pending = 1;
1310 int SuperTraceExecuteRequest (void* AdapterHandle,
1313 diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle;
1315 if (pC && pC->pIdiLib && pC->request) {
1316 ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib);
1317 byte* xdata = (byte*)&pC->xbuffer[0];
1320 length = SuperTraceCreateReadReq (xdata, name);
1321 single_p (xdata, &length, 0); /* End Of Message */
1323 e->Req = MAN_EXECUTE;
1325 e->X->PLength = length;
1326 e->X->P = (byte*)xdata;
1328 pC->request_pending = 1;
1336 static word SuperTraceCreateReadReq (byte* P, const char* path) {
1340 var_length = (byte)strlen (path);
1344 *P++ = 0x80; /* MAN_IE */
1345 *P++ = 0x00; /* Type */
1346 *P++ = 0x00; /* Attribute */
1347 *P++ = 0x00; /* Status */
1348 *P++ = 0x00; /* Variable Length */
1350 memcpy (P, path, var_length);
1352 *plen = var_length + 0x06;
1354 return ((word)(var_length + 0x08));
1357 static void single_p (byte * P, word * PLength, byte Id) {
1358 P[(*PLength)++] = Id;
1361 static void diva_maint_xdi_cb (ENTITY* e) {
1362 diva_strace_context_t* pLib = DIVAS_CONTAINING_RECORD(e,diva_strace_context_t,e);
1363 diva_maint_client_t* pC;
1364 diva_os_spin_lock_magic_t old_irql, old_irql1;
1367 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "xdi_cb");
1368 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "xdi_cb");
1370 pC = (diva_maint_client_t*)pLib->hAdapter;
1372 if ((e->complete == 255) || (pC->dma_handle < 0)) {
1373 if ((*(pLib->instance.DivaSTraceMessageInput))(&pLib->instance)) {
1374 diva_mnt_internal_dprintf (0, DLI_ERR, "Trace internal library error");
1378 Process combined management interface indication
1380 if ((*(pLib->instance.DivaSTraceMessageInput))(&pLib->instance)) {
1381 diva_mnt_internal_dprintf (0, DLI_ERR, "Trace internal library error (DMA mode)");
1385 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "xdi_cb");
1388 if (pC->request_pending) {
1389 pC->request_pending = 0;
1390 (*(pC->request))(e);
1393 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "xdi_cb");
1397 static void diva_maint_error (void* user_context,
1398 diva_strace_library_interface_t* hLib,
1403 diva_mnt_internal_dprintf (0, DLI_ERR,
1404 "Trace library error(%d) A(%d) %s %d", error, Adapter, file, line);
1407 static void print_ie (diva_trace_ie_t* ie, char* buffer, int length) {
1413 for (i = 0; ((i < ie->length) && (length > 3)); i++) {
1414 sprintf (buffer, "%02x", ie->data[i]);
1417 if (i < (ie->length-1)) {
1418 strcpy (buffer, " ");
1426 static void diva_maint_state_change_notify (void* user_context,
1427 diva_strace_library_interface_t* hLib,
1429 diva_trace_line_state_t* channel,
1430 int notify_subject) {
1431 diva_maint_client_t* pC = (diva_maint_client_t*)user_context;
1432 diva_trace_fax_state_t* fax = &channel->fax;
1433 diva_trace_modem_state_t* modem = &channel->modem;
1440 switch (notify_subject) {
1441 case DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE: {
1442 int view = (TraceFilter[0] == 0);
1444 Process selective Trace
1446 if (channel->Line[0] == 'I' && channel->Line[1] == 'd' &&
1447 channel->Line[2] == 'l' && channel->Line[3] == 'e') {
1448 if ((TraceFilterIdent == pC->hDbg->id) && (TraceFilterChannel == (int)channel->ChannelNumber)) {
1449 (*(hLib->DivaSTraceSetBChannel))(hLib, (int)channel->ChannelNumber, 0);
1450 (*(hLib->DivaSTraceSetAudioTap))(hLib, (int)channel->ChannelNumber, 0);
1451 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, "Selective Trace OFF for Ch=%d",
1452 (int)channel->ChannelNumber);
1453 TraceFilterIdent = -1;
1454 TraceFilterChannel = -1;
1457 } else if (TraceFilter[0] && (TraceFilterIdent < 0) && !(diva_mnt_cmp_nmbr (&channel->RemoteAddress[0]) &&
1458 diva_mnt_cmp_nmbr (&channel->LocalAddress[0]))) {
1460 if ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0) { /* Activate B-channel trace */
1461 (*(hLib->DivaSTraceSetBChannel))(hLib, (int)channel->ChannelNumber, 1);
1463 if ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0) { /* Activate AudioTap Trace */
1464 (*(hLib->DivaSTraceSetAudioTap))(hLib, (int)channel->ChannelNumber, 1);
1467 TraceFilterIdent = pC->hDbg->id;
1468 TraceFilterChannel = (int)channel->ChannelNumber;
1470 if (TraceFilterIdent >= 0) {
1471 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, "Selective Trace ON for Ch=%d",
1472 (int)channel->ChannelNumber);
1476 if (view && (pC->hDbg->dbgMask & DIVA_MGT_DBG_LINE_EVENTS)) {
1477 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Ch = %d",
1478 (int)channel->ChannelNumber);
1479 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Status = <%s>", &channel->Line[0]);
1480 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Layer1 = <%s>", &channel->Framing[0]);
1481 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Layer2 = <%s>", &channel->Layer2[0]);
1482 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Layer3 = <%s>", &channel->Layer3[0]);
1483 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L RAddr = <%s>",
1484 &channel->RemoteAddress[0]);
1485 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L RSAddr = <%s>",
1486 &channel->RemoteSubAddress[0]);
1487 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L LAddr = <%s>",
1488 &channel->LocalAddress[0]);
1489 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L LSAddr = <%s>",
1490 &channel->LocalSubAddress[0]);
1491 print_ie(&channel->call_BC, tmp, sizeof(tmp));
1492 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L BC = <%s>", tmp);
1493 print_ie(&channel->call_HLC, tmp, sizeof(tmp));
1494 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L HLC = <%s>", tmp);
1495 print_ie(&channel->call_LLC, tmp, sizeof(tmp));
1496 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L LLC = <%s>", tmp);
1497 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L CR = 0x%x", channel->CallReference);
1498 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Disc = 0x%x",
1499 channel->LastDisconnecCause);
1500 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Owner = <%s>", &channel->UserID[0]);
1505 case DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE:
1506 if (pC->hDbg->dbgMask & DIVA_MGT_DBG_MDM_PROGRESS) {
1508 int ch = TraceFilterChannel;
1509 int id = TraceFilterIdent;
1511 if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) &&
1512 (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) {
1513 if (ch != (int)modem->ChannelNumber) {
1516 } else if (TraceFilter[0] != 0) {
1522 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Ch = %lu",
1523 (int)modem->ChannelNumber);
1524 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Event = %lu", modem->Event);
1525 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Norm = %lu", modem->Norm);
1526 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Opts. = 0x%08x", modem->Options);
1527 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Tx = %lu Bps", modem->TxSpeed);
1528 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Rx = %lu Bps", modem->RxSpeed);
1529 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RT = %lu mSec",
1530 modem->RoundtripMsec);
1531 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Sr = %lu", modem->SymbolRate);
1532 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Rxl = %d dBm", modem->RxLeveldBm);
1533 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM El = %d dBm", modem->EchoLeveldBm);
1534 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM SNR = %lu dB", modem->SNRdb);
1535 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM MAE = %lu", modem->MAE);
1536 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM LRet = %lu",
1537 modem->LocalRetrains);
1538 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RRet = %lu",
1539 modem->RemoteRetrains);
1540 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM LRes = %lu", modem->LocalResyncs);
1541 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RRes = %lu",
1542 modem->RemoteResyncs);
1543 if (modem->Event == 3) {
1544 diva_mnt_internal_dprintf(pC->hDbg->id,DLI_STAT,"MDM Disc = %lu", modem->DiscReason);
1547 if ((modem->Event == 3) && (pC->hDbg->dbgMask & DIVA_MGT_DBG_MDM_STATISTICS)) {
1548 (*(pC->pIdiLib->DivaSTraceGetModemStatistics))(pC->pIdiLib);
1552 case DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE:
1553 if (pC->hDbg->dbgMask & DIVA_MGT_DBG_FAX_PROGRESS) {
1555 int ch = TraceFilterChannel;
1556 int id = TraceFilterIdent;
1558 if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) &&
1559 (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) {
1560 if (ch != (int)fax->ChannelNumber) {
1563 } else if (TraceFilter[0] != 0) {
1568 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Ch = %lu",(int)fax->ChannelNumber);
1569 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Event = %lu", fax->Event);
1570 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Pages = %lu", fax->Page_Counter);
1571 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Feat. = 0x%08x", fax->Features);
1572 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX ID = <%s>", &fax->Station_ID[0]);
1573 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Saddr = <%s>", &fax->Subaddress[0]);
1574 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Pwd = <%s>", &fax->Password[0]);
1575 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Speed = %lu", fax->Speed);
1576 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Res. = 0x%08x", fax->Resolution);
1577 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Width = %lu", fax->Paper_Width);
1578 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Length= %lu", fax->Paper_Length);
1579 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX SLT = %lu", fax->Scanline_Time);
1580 if (fax->Event == 3) {
1581 diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Disc = %lu", fax->Disc_Reason);
1584 if ((fax->Event == 3) && (pC->hDbg->dbgMask & DIVA_MGT_DBG_FAX_STATISTICS)) {
1585 (*(pC->pIdiLib->DivaSTraceGetFaxStatistics))(pC->pIdiLib);
1589 case DIVA_SUPER_TRACE_INTERFACE_CHANGE:
1590 if (pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_EVENTS) {
1591 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT,
1592 "Layer 1 -> [%s]", channel->pInterface->Layer1);
1593 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT,
1594 "Layer 2 -> [%s]", channel->pInterface->Layer2);
1598 case DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE:
1599 if (pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_STATISTICS) {
1603 if (channel->pInterfaceStat->inc.Calls) {
1604 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1605 "Inc Calls =%lu", channel->pInterfaceStat->inc.Calls);
1607 if (channel->pInterfaceStat->inc.Connected) {
1608 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1609 "Inc Connected =%lu", channel->pInterfaceStat->inc.Connected);
1611 if (channel->pInterfaceStat->inc.User_Busy) {
1612 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1613 "Inc Busy =%lu", channel->pInterfaceStat->inc.User_Busy);
1615 if (channel->pInterfaceStat->inc.Call_Rejected) {
1616 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1617 "Inc Rejected =%lu", channel->pInterfaceStat->inc.Call_Rejected);
1619 if (channel->pInterfaceStat->inc.Wrong_Number) {
1620 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1621 "Inc Wrong Nr =%lu", channel->pInterfaceStat->inc.Wrong_Number);
1623 if (channel->pInterfaceStat->inc.Incompatible_Dst) {
1624 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1625 "Inc Incomp. Dest =%lu", channel->pInterfaceStat->inc.Incompatible_Dst);
1627 if (channel->pInterfaceStat->inc.Out_of_Order) {
1628 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1629 "Inc Out of Order =%lu", channel->pInterfaceStat->inc.Out_of_Order);
1631 if (channel->pInterfaceStat->inc.Ignored) {
1632 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1633 "Inc Ignored =%lu", channel->pInterfaceStat->inc.Ignored);
1639 if (channel->pInterfaceStat->outg.Calls) {
1640 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1641 "Outg Calls =%lu", channel->pInterfaceStat->outg.Calls);
1643 if (channel->pInterfaceStat->outg.Connected) {
1644 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1645 "Outg Connected =%lu", channel->pInterfaceStat->outg.Connected);
1647 if (channel->pInterfaceStat->outg.User_Busy) {
1648 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1649 "Outg Busy =%lu", channel->pInterfaceStat->outg.User_Busy);
1651 if (channel->pInterfaceStat->outg.No_Answer) {
1652 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1653 "Outg No Answer =%lu", channel->pInterfaceStat->outg.No_Answer);
1655 if (channel->pInterfaceStat->outg.Wrong_Number) {
1656 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1657 "Outg Wrong Nr =%lu", channel->pInterfaceStat->outg.Wrong_Number);
1659 if (channel->pInterfaceStat->outg.Call_Rejected) {
1660 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1661 "Outg Rejected =%lu", channel->pInterfaceStat->outg.Call_Rejected);
1663 if (channel->pInterfaceStat->outg.Other_Failures) {
1664 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1665 "Outg Other Failures =%lu", channel->pInterfaceStat->outg.Other_Failures);
1670 case DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE:
1671 if (channel->pInterfaceStat->mdm.Disc_Normal) {
1672 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1673 "MDM Disc Normal = %lu", channel->pInterfaceStat->mdm.Disc_Normal);
1675 if (channel->pInterfaceStat->mdm.Disc_Unspecified) {
1676 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1677 "MDM Disc Unsp. = %lu", channel->pInterfaceStat->mdm.Disc_Unspecified);
1679 if (channel->pInterfaceStat->mdm.Disc_Busy_Tone) {
1680 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1681 "MDM Disc Busy Tone = %lu", channel->pInterfaceStat->mdm.Disc_Busy_Tone);
1683 if (channel->pInterfaceStat->mdm.Disc_Congestion) {
1684 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1685 "MDM Disc Congestion = %lu", channel->pInterfaceStat->mdm.Disc_Congestion);
1687 if (channel->pInterfaceStat->mdm.Disc_Carr_Wait) {
1688 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1689 "MDM Disc Carrier Wait = %lu", channel->pInterfaceStat->mdm.Disc_Carr_Wait);
1691 if (channel->pInterfaceStat->mdm.Disc_Trn_Timeout) {
1692 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1693 "MDM Disc Trn. T.o. = %lu", channel->pInterfaceStat->mdm.Disc_Trn_Timeout);
1695 if (channel->pInterfaceStat->mdm.Disc_Incompat) {
1696 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1697 "MDM Disc Incompatible = %lu", channel->pInterfaceStat->mdm.Disc_Incompat);
1699 if (channel->pInterfaceStat->mdm.Disc_Frame_Rej) {
1700 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1701 "MDM Disc Frame Reject = %lu", channel->pInterfaceStat->mdm.Disc_Frame_Rej);
1703 if (channel->pInterfaceStat->mdm.Disc_V42bis) {
1704 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1705 "MDM Disc V.42bis = %lu", channel->pInterfaceStat->mdm.Disc_V42bis);
1709 case DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE:
1710 if (channel->pInterfaceStat->fax.Disc_Normal) {
1711 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1712 "FAX Disc Normal = %lu", channel->pInterfaceStat->fax.Disc_Normal);
1714 if (channel->pInterfaceStat->fax.Disc_Not_Ident) {
1715 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1716 "FAX Disc Not Ident. = %lu", channel->pInterfaceStat->fax.Disc_Not_Ident);
1718 if (channel->pInterfaceStat->fax.Disc_No_Response) {
1719 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1720 "FAX Disc No Response = %lu", channel->pInterfaceStat->fax.Disc_No_Response);
1722 if (channel->pInterfaceStat->fax.Disc_Retries) {
1723 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1724 "FAX Disc Max Retries = %lu", channel->pInterfaceStat->fax.Disc_Retries);
1726 if (channel->pInterfaceStat->fax.Disc_Unexp_Msg) {
1727 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1728 "FAX Unexp. Msg. = %lu", channel->pInterfaceStat->fax.Disc_Unexp_Msg);
1730 if (channel->pInterfaceStat->fax.Disc_No_Polling) {
1731 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1732 "FAX Disc No Polling = %lu", channel->pInterfaceStat->fax.Disc_No_Polling);
1734 if (channel->pInterfaceStat->fax.Disc_Training) {
1735 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1736 "FAX Disc Training = %lu", channel->pInterfaceStat->fax.Disc_Training);
1738 if (channel->pInterfaceStat->fax.Disc_Unexpected) {
1739 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1740 "FAX Disc Unexpected = %lu", channel->pInterfaceStat->fax.Disc_Unexpected);
1742 if (channel->pInterfaceStat->fax.Disc_Application) {
1743 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1744 "FAX Disc Application = %lu", channel->pInterfaceStat->fax.Disc_Application);
1746 if (channel->pInterfaceStat->fax.Disc_Incompat) {
1747 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1748 "FAX Disc Incompatible = %lu", channel->pInterfaceStat->fax.Disc_Incompat);
1750 if (channel->pInterfaceStat->fax.Disc_No_Command) {
1751 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1752 "FAX Disc No Command = %lu", channel->pInterfaceStat->fax.Disc_No_Command);
1754 if (channel->pInterfaceStat->fax.Disc_Long_Msg) {
1755 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1756 "FAX Disc Long Msg. = %lu", channel->pInterfaceStat->fax.Disc_Long_Msg);
1758 if (channel->pInterfaceStat->fax.Disc_Supervisor) {
1759 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1760 "FAX Disc Supervisor = %lu", channel->pInterfaceStat->fax.Disc_Supervisor);
1762 if (channel->pInterfaceStat->fax.Disc_SUB_SEP_PWD) {
1763 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1764 "FAX Disc SUP SEP PWD = %lu", channel->pInterfaceStat->fax.Disc_SUB_SEP_PWD);
1766 if (channel->pInterfaceStat->fax.Disc_Invalid_Msg) {
1767 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1768 "FAX Disc Invalid Msg. = %lu", channel->pInterfaceStat->fax.Disc_Invalid_Msg);
1770 if (channel->pInterfaceStat->fax.Disc_Page_Coding) {
1771 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1772 "FAX Disc Page Coding = %lu", channel->pInterfaceStat->fax.Disc_Page_Coding);
1774 if (channel->pInterfaceStat->fax.Disc_App_Timeout) {
1775 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1776 "FAX Disc Appl. T.o. = %lu", channel->pInterfaceStat->fax.Disc_App_Timeout);
1778 if (channel->pInterfaceStat->fax.Disc_Unspecified) {
1779 diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG,
1780 "FAX Disc Unspec. = %lu", channel->pInterfaceStat->fax.Disc_Unspecified);
1787 Receive trace information from the Management Interface and store it in the
1788 internal trace buffer with MSG_TYPE_MLOG as is, without any filtering.
1789 Event Filtering and formatting is done in Management Interface self.
1791 static void diva_maint_trace_notify (void* user_context,
1792 diva_strace_library_interface_t* hLib,
1796 diva_maint_client_t* pC = (diva_maint_client_t*)user_context;
1797 diva_dbg_entry_head_t* pmsg;
1800 int ch = TraceFilterChannel;
1801 int id = TraceFilterIdent;
1806 if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) &&
1807 (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) {
1808 const char* p = NULL;
1810 MI_XLOG_HDR *TrcData = (MI_XLOG_HDR *)xlog_buffer;
1812 if (Adapter != clients[id].logical) {
1813 return; /* Ignore all trace messages from other adapters */
1816 if (TrcData->code == 24) {
1817 p = (char*)&TrcData->code;
1822 All L1 messages start as [dsp,ch], so we can filter this information
1823 and filter out all messages that use different channel
1825 if (p && p[0] == '[') {
1828 ch_value = *p - '0';
1829 } else if (p[3] == ',') {
1831 ch_value = *p - '0';
1833 if (ch_value >= 0) {
1835 ch_value = ch_value * 10 + p[1] - '0';
1837 if (ch_value != ch) {
1838 return; /* Ignore other channels */
1843 } else if (TraceFilter[0] != 0) {
1844 return; /* Ignore trace if trace filter is activated, but idle */
1847 diva_os_get_time (&sec, &usec);
1849 while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue,
1850 (word)length+sizeof(*pmsg)))) {
1851 if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) {
1852 queueFreeMsg (dbg_queue);
1858 memcpy (&pmsg[1], xlog_buffer, length);
1859 pmsg->sequence = dbg_sequence++;
1860 pmsg->time_sec = sec;
1861 pmsg->time_usec = usec;
1862 pmsg->facility = MSG_TYPE_MLOG;
1863 pmsg->dli = pC->logical;
1864 pmsg->drv_id = pC->hDbg->id;
1866 pmsg->data_length = length;
1867 queueCompleteMsg (pmsg);
1868 if (queueCount(dbg_queue)) {
1869 diva_maint_wakeup_read();
1876 Convert MAINT trace mask to management interface trace mask/work/facility and
1877 issue command to management interface
1879 static void diva_change_management_debug_mask (diva_maint_client_t* pC, dword old_mask) {
1880 if (pC->request && pC->hDbg && pC->pIdiLib) {
1881 dword changed = pC->hDbg->dbgMask ^ old_mask;
1883 if (changed & DIVA_MGT_DBG_TRACE) {
1884 (*(pC->pIdiLib->DivaSTraceSetInfo))(pC->pIdiLib,
1885 (pC->hDbg->dbgMask & DIVA_MGT_DBG_TRACE) != 0);
1887 if (changed & DIVA_MGT_DBG_DCHAN) {
1888 (*(pC->pIdiLib->DivaSTraceSetDChannel))(pC->pIdiLib,
1889 (pC->hDbg->dbgMask & DIVA_MGT_DBG_DCHAN) != 0);
1891 if (!TraceFilter[0]) {
1892 if (changed & DIVA_MGT_DBG_IFC_BCHANNEL) {
1893 int i, state = ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0);
1895 for (i = 0; i < pC->channels; i++) {
1896 (*(pC->pIdiLib->DivaSTraceSetBChannel))(pC->pIdiLib, i+1, state);
1899 if (changed & DIVA_MGT_DBG_IFC_AUDIO) {
1900 int i, state = ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0);
1902 for (i = 0; i < pC->channels; i++) {
1903 (*(pC->pIdiLib->DivaSTraceSetAudioTap))(pC->pIdiLib, i+1, state);
1911 void diva_mnt_internal_dprintf (dword drv_id, dword type, char* fmt, ...) {
1915 DI_format (0, (word)drv_id, (int)type, fmt, ap);
1920 Shutdown all adapters before driver removal
1922 int diva_mnt_shutdown_xdi_adapters (void) {
1923 diva_os_spin_lock_magic_t old_irql, old_irql1;
1928 for (i = 1; i < ARRAY_SIZE(clients); i++) {
1931 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "unload");
1932 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "unload");
1934 if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request) {
1935 if ((*(clients[i].pIdiLib->DivaSTraceLibraryStop))(clients[i].pIdiLib) == 1) {
1937 Adapter removal complete
1939 if (clients[i].pIdiLib) {
1940 (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib);
1941 clients[i].pIdiLib = NULL;
1943 pmem = clients[i].pmem;
1944 clients[i].pmem = NULL;
1946 clients[i].hDbg = NULL;
1947 clients[i].request_pending = 0;
1949 if (clients[i].dma_handle >= 0) {
1953 diva_free_dma_descriptor (clients[i].request, clients[i].dma_handle);
1954 clients[i].dma_handle = -1;
1956 clients[i].request = NULL;
1962 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "unload");
1963 if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request && clients[i].request_pending) {
1964 clients[i].request_pending = 0;
1965 (*(clients[i].request))((ENTITY*)(*(clients[i].pIdiLib->DivaSTraceGetHandle))(clients[i].pIdiLib->hLib));
1966 if (clients[i].dma_handle >= 0) {
1967 diva_free_dma_descriptor (clients[i].request, clients[i].dma_handle);
1968 clients[i].dma_handle = -1;
1971 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "unload");
1974 diva_os_free (0, pmem);
1982 Set/Read the trace filter used for selective tracing.
1983 Affects B- and Audio Tap trace mask at run time
1985 int diva_set_trace_filter (int filter_length, const char* filter) {
1986 diva_os_spin_lock_magic_t old_irql, old_irql1;
1987 int i, ch, on, client_b_on, client_atap_on;
1989 diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask");
1990 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "write_filter");
1992 if (filter_length <= DIVA_MAX_SELECTIVE_FILTER_LENGTH) {
1993 memcpy (&TraceFilter[0], filter, filter_length);
1994 if (TraceFilter[filter_length]) {
1995 TraceFilter[filter_length] = 0;
1997 if (TraceFilter[0] == '*') {
2004 TraceFilterIdent = -1;
2005 TraceFilterChannel = -1;
2007 on = (TraceFilter[0] == 0);
2009 for (i = 1; i < ARRAY_SIZE(clients); i++) {
2010 if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request) {
2011 client_b_on = on && ((clients[i].hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0);
2012 client_atap_on = on && ((clients[i].hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0);
2013 for (ch = 0; ch < clients[i].channels; ch++) {
2014 (*(clients[i].pIdiLib->DivaSTraceSetBChannel))(clients[i].pIdiLib->hLib, ch+1, client_b_on);
2015 (*(clients[i].pIdiLib->DivaSTraceSetAudioTap))(clients[i].pIdiLib->hLib, ch+1, client_atap_on);
2020 for (i = 1; i < ARRAY_SIZE(clients); i++) {
2021 if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request && clients[i].request_pending) {
2022 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "write_filter");
2023 clients[i].request_pending = 0;
2024 (*(clients[i].request))((ENTITY*)(*(clients[i].pIdiLib->DivaSTraceGetHandle))(clients[i].pIdiLib->hLib));
2025 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "write_filter");
2029 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "write_filter");
2030 diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask");
2032 return (filter_length);
2035 int diva_get_trace_filter (int max_length, char* filter) {
2036 diva_os_spin_lock_magic_t old_irql;
2039 diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "read_filter");
2040 len = strlen (&TraceFilter[0]) + 1;
2041 if (max_length >= len) {
2042 memcpy (filter, &TraceFilter[0], len);
2044 diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "read_filter");
2049 static int diva_dbg_cmp_key (const char* ref, const char* key) {
2050 while (*key && (*ref++ == *key++));
2051 return (!*key && !*ref);
2055 In case trace filter starts with "C" character then
2056 all following characters are interpreted as command.
2057 Followings commands are available:
2058 - single, trace single call at time, independent from CPN/CiPN
2060 static int diva_mnt_cmp_nmbr (const char* nmbr) {
2061 const char* ref = &TraceFilter[0];
2062 int ref_len = strlen(&TraceFilter[0]), nmbr_len = strlen(nmbr);
2064 if (ref[0] == 'C') {
2065 if (diva_dbg_cmp_key (&ref[1], "single")) {
2071 if (!ref_len || (ref_len > nmbr_len)) {
2075 nmbr = nmbr + nmbr_len - 1;
2076 ref = ref + ref_len - 1;
2079 if (*nmbr-- != *ref--) {
2087 static int diva_get_dma_descriptor (IDI_CALL request, dword *dma_magic) {
2089 IDI_SYNC_REQ* pReq = (IDI_SYNC_REQ*)&e;
2095 pReq->xdi_dma_descriptor_operation.Req = 0;
2096 pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION;
2098 pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC;
2099 pReq->xdi_dma_descriptor_operation.info.descriptor_number = -1;
2100 pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL;
2101 pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0;
2103 (*request)((ENTITY*)pReq);
2105 if (!pReq->xdi_dma_descriptor_operation.info.operation &&
2106 (pReq->xdi_dma_descriptor_operation.info.descriptor_number >= 0) &&
2107 pReq->xdi_dma_descriptor_operation.info.descriptor_magic) {
2108 *dma_magic = pReq->xdi_dma_descriptor_operation.info.descriptor_magic;
2109 return (pReq->xdi_dma_descriptor_operation.info.descriptor_number);
2115 static void diva_free_dma_descriptor (IDI_CALL request, int nr) {
2117 IDI_SYNC_REQ* pReq = (IDI_SYNC_REQ*)&e;
2119 if (!request || (nr < 0)) {
2123 pReq->xdi_dma_descriptor_operation.Req = 0;
2124 pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION;
2126 pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE;
2127 pReq->xdi_dma_descriptor_operation.info.descriptor_number = nr;
2128 pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL;
2129 pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0;
2131 (*request)((ENTITY*)pReq);