int i;
if (!pLib) {
- return (0);
+ return NULL;
}
- pmem += sizeof(*pLib);
+ pmem += sizeof(*pLib);
memset(pLib, 0x00, sizeof(*pLib));
pLib->Adapter = Adapter;
if (!(pLib->hAdapter = SuperTraceOpenAdapter (Adapter))) {
diva_mnt_internal_dprintf (0, DLI_ERR, "Can not open XDI adapter");
- return (0);
+ return NULL;
}
pLib->Channels = SuperTraceGetNumberOfChannels (pLib->hAdapter);
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, "Unknon 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);
}
static int process_idi_event (diva_strace_context_t* pLib,
- diva_man_var_header_t* pVar) {
+ diva_man_var_header_t* pVar) {
const char* path = (char*)&pVar->path_length+1;
char name[64];
int i;
byte* start;
int msg_length;
- if (*msg != ESC) return (0);
+ if (*msg != ESC) return NULL;
start = msg + 2;
msg_length = *(msg+1);
msg = (start+msg_length);
- if (*msg != ESC) return (0);
+ if (*msg != ESC) return NULL;
return ((diva_man_var_header_t*)msg);
}
break;
case 2:
- value = (short)READ_WORD(ptr);
+ value = (short)GET_WORD(ptr);
break;
case 4:
- value = (int)READ_DWORD(ptr);
+ value = (int)GET_DWORD(ptr);
break;
default:
break;
case 2:
- value = (word)READ_WORD(ptr);
+ value = (word)GET_WORD(ptr);
break;
case 3:
- value = (dword)READ_DWORD(ptr);
+ value = (dword)GET_DWORD(ptr);
value &= 0x00ffffff;
break;
case 4:
- value = (dword)READ_DWORD(ptr);
+ value = (dword)GET_DWORD(ptr);
break;
default: