Пример #1
0
static int64_t opal_cec_reboot2(uint32_t reboot_type, char *diag)
{
	struct errorlog *buf;

	switch (reboot_type) {
	case OPAL_REBOOT_NORMAL:
		return opal_cec_reboot();
	case OPAL_REBOOT_PLATFORM_ERROR:
		prlog(PR_EMERG,
			  "OPAL: Reboot requested due to Platform error.");
		buf = opal_elog_create(&e_info(OPAL_RC_ABNORMAL_REBOOT), 0);
		if (buf) {
			log_append_msg(buf,
			  "OPAL: Reboot requested due to Platform error.");
			if (diag) {
				/* Add user section "DESC" */
				log_add_section(buf, 0x44455350);
				log_append_data(buf, diag, strlen(diag));
				log_commit(buf);
			}
		} else {
			prerror("OPAL: failed to log an error\n");
		}
		return xscom_trigger_xstop();
	default:
		printf("OPAL: Unsupported reboot request %d\n", reboot_type);
		return OPAL_UNSUPPORTED;
		break;
	}
	return OPAL_SUCCESS;
}
Пример #2
0
int __cdecl log_it(int level, const char *fmt, ...) {
   log_header   *lp;
   va_list  arglist;
   char        *dst;
   int           rc;
  
   mt_swlock();

   lp = log_alloc(LOG_PRINTSIZE);
   if (!lp) {
      static char buf[LOG_PRINTSIZE];
      hlp_seroutstr("log is locked: ");
      dst = &buf;
   } else
      dst = (char*)(lp+1);
   va_start(arglist,fmt);
   rc = _vsnprintf(dst,LOG_PRINTSIZE,fmt,arglist);
   va_end(arglist);
   hlp_seroutstr(dst);
   // commit new log entry
   if (lp) {
      lp->flags = lp->flags&~LOGIF_LEVELMASK|level&LOGIF_LEVELMASK;
      log_commit(lp);
   }
   mt_swunlock();
   return rc;
}
Пример #3
0
/*=================================================================================================
FUNCTION   ftm_nfc_log_send_msg
DESCRIPTION
This function will log the asynchronous messages(NTFs and data packets) to the logging subsystem
 of DIAG.
DEPENDENCIES
RETURN VALUE
TRUE if data logged successfully and FALSE if failed.
SIDE EFFECTS
  None
==================================================================================================*/
int ftm_nfc_log_send_msg(void)
{
    uint16 i = 0;
    ftm_nfc_log_pkt_type* ftm_nfc_log_pkt_ptr = NULL;
    asyncdata* node = NULL;
    uint8 arr[1]= {'\n'};
    if(log_status(LOG_NFC_FTM))
    {
        buff = start;
        if(buff != NULL)
        {
            do{
                  printf("buff->async_datalen : %d \n", buff->async_datalen);
                  ftm_nfc_log_pkt_ptr = (ftm_nfc_log_pkt_type *)log_alloc(LOG_NFC_FTM, (FTM_NFC_LOG_HEADER_SIZE + (buff->async_datalen)));
                  if(ftm_nfc_log_pkt_ptr)
                  {
                      memcpy((void *)ftm_nfc_log_pkt_ptr->data, (void *)buff->response_buff, buff->async_datalen);
                      printf("Async msg is = ");
                      for(i=0; i<buff->async_datalen; i++)
                      {
                          printf("%X ", ftm_nfc_log_pkt_ptr->data[i]);
                      }
                      printf("%c",arr[0]);
                      node = buff;
                      buff = buff->next;
                      free(node);
                      printf("Commiting the log message(async msg) \n");
                      log_commit(ftm_nfc_log_pkt_ptr);
                  }
                  else
                  {
                      printf("\nmem alloc failed in log_alloc \n");
                      return FALSE;
                  }
              }while(buff != NULL);
              printf("all msgs committed \n");
              async_msg_available = FALSE;
              return TRUE;
          }
          else
          {
              printf("No async message left to be logged \n");
          }
     }
     else
     {
         printf("LOG_NFC_FTM code is not enabled in logging subsystem \n");
     }
     return FALSE;
}
Пример #4
0
static int bisect_write(const char *state, const char *rev,
			const struct bisect_terms *terms, int nolog)
{
	struct strbuf tag = STRBUF_INIT;
	struct object_id oid;
	struct commit *commit;
	FILE *fp = NULL;
	int retval = 0;

	if (!strcmp(state, terms->term_bad)) {
		strbuf_addf(&tag, "refs/bisect/%s", state);
	} else if (one_of(state, terms->term_good, "skip", NULL)) {
		strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev);
	} else {
		retval = error(_("Bad bisect_write argument: %s"), state);
		goto finish;
	}

	if (get_oid(rev, &oid)) {
		retval = error(_("couldn't get the oid of the rev '%s'"), rev);
		goto finish;
	}

	if (update_ref(NULL, tag.buf, &oid, NULL, 0,
		       UPDATE_REFS_MSG_ON_ERR)) {
		retval = -1;
		goto finish;
	}

	fp = fopen(git_path_bisect_log(), "a");
	if (!fp) {
		retval = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log());
		goto finish;
	}

	commit = lookup_commit_reference(the_repository, &oid);
	log_commit(fp, "%s", state, commit);

	if (!nolog)
		fprintf(fp, "git bisect %s %s\n", state, rev);

finish:
	if (fp)
		fclose(fp);
	strbuf_release(&tag);
	return retval;
}
Пример #5
0
/*===========================================================================

FUNCTION DSRLP_LOG_RLP_STATISTICS

DESCRIPTION
  Logs the current values of the RLP statistics to the off-target diagnostic
  tool.  If we can't allocate space for the log packet on the DIAG ring
  buffer, we'll abort and try again next time.

  Input Parameters:
    sr_id: The Service ID for the particular service. Primary is usually 1
           and secondary is usually 2.
    
    callTerminated: True if we're logging at call termination, False if
           we're logging periodically during the call.

DEPENDENCIES
  Logging mask, dsrlp_log_stats_interval 

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
void dsrlp_log_rlp_statistics( byte sr_id_index, boolean callTerminated ) 
{

  log_rlp_stats_type      *rlp_stats_log_pkt = NULL;
  dsrlp_stats_info_type   *rlp_stats_ptr = NULL;
  word                     i; /* loop invariant */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

  /*-------------------------------------------------------------------------
    Should we log RLP statistics yet?     
  -------------------------------------------------------------------------*/
  if( log_status( LOG_RLP_STAT_C ) && ( dsrlp_log_stats_interval > 0 ) &&
      ( ++dsrlp_log_stats_frm_cnt >= dsrlp_log_stats_interval )) {
    
    /*-----------------------------------------------------------------------
      We'll try...   
    -----------------------------------------------------------------------*/
    rlp_stats_log_pkt = (log_rlp_stats_type*) log_alloc( LOG_RLP_STAT_C,
                                                 sizeof( log_rlp_stats_type ));
    if( rlp_stats_log_pkt != NULL ) {

       (void) dsrlp_get_stats_ex( sr_id_index,
                       0,//DSRSP_ROUTE_A,
                       &rlp_stats_ptr );

      rlp_stats_log_pkt->service_ID = dsrlp_get_sr_id(sr_id_index);
      rlp_stats_log_pkt->reset_time         = rlp_stats_ptr->reset_timestamp;

      rlp_stats_log_pkt->naks_received = rlp_stats_ptr->naks_received;
      rlp_stats_log_pkt->re_xmits_not_found = rlp_stats_ptr->re_xmits_not_found;
      rlp_stats_log_pkt->largest_contig_erasure = rlp_stats_ptr->largest_contig_erasure;
      rlp_stats_log_pkt->resets = rlp_stats_ptr->resets;
      rlp_stats_log_pkt->aborts = rlp_stats_ptr->aborts;
      rlp_stats_log_pkt->last_rtt = rlp_stats_ptr->last_rtt;
      rlp_stats_log_pkt->rlp_blob_used = rlp_stats_ptr->RLP_BLOB_used;

      rlp_stats_log_pkt->rx_rexmit_fr_cnt   = rlp_stats_ptr->rx_rexmit_fr_cnt;
      rlp_stats_log_pkt->rx_idle_fr_cnt     = rlp_stats_ptr->rx_idle_fr_cnt;
      rlp_stats_log_pkt->rx_fill_fr_cnt     = rlp_stats_ptr->rx_fill_fr_cnt;
      rlp_stats_log_pkt->rx_blank_fr_cnt    = rlp_stats_ptr->rx_blank_fr_cnt;
      rlp_stats_log_pkt->rx_null_fr_cnt     = rlp_stats_ptr->rx_null_fr_cnt;
      rlp_stats_log_pkt->rx_new_data_fr_cnt = rlp_stats_ptr->rx_new_data_fr_cnt;
      rlp_stats_log_pkt->rx_20ms_fr_cnt     = rlp_stats_ptr->rx_20ms_fr_cnt;
      rlp_stats_log_pkt->rx_total_bytes     = rlp_stats_ptr->rx_total_bytes;
      rlp_stats_log_pkt->rx_rlp_erasures    = rlp_stats_ptr->rx_rlp_erasures;
      rlp_stats_log_pkt->rx_mux_erasures    = rlp_stats_ptr->rx_mux_erasures;

      rlp_stats_log_pkt->tx_rexmit_fr_cnt   = rlp_stats_ptr->tx_rexmit_fr_cnt;
      rlp_stats_log_pkt->tx_idle_fr_cnt     = rlp_stats_ptr->tx_idle_fr_cnt;
      rlp_stats_log_pkt->tx_new_data_fr_cnt = rlp_stats_ptr->tx_new_data_fr_cnt;
      rlp_stats_log_pkt->tx_20ms_fr_cnt     = rlp_stats_ptr->tx_20ms_fr_cnt;
      rlp_stats_log_pkt->tx_total_bytes     = rlp_stats_ptr->tx_total_bytes;
      rlp_stats_log_pkt->tx_naks_cnt        = rlp_stats_ptr->curr_tx_nak_rounds;
      for( i = 0; i < rlp_stats_ptr->curr_tx_nak_rounds; i++ ) {
        rlp_stats_log_pkt->tx_naks[i]       = rlp_stats_ptr->tx_naks[i];
      }

      if( callTerminated ) 
      {
        /*-------------------------------------------------------------------
          TODO: Add a flag to indicate if a call is in progress 
        -------------------------------------------------------------------*/
      }

      log_commit( (log_type*) rlp_stats_log_pkt );
      dsrlp_log_stats_frm_cnt = 0;
    }
  }
}/* dsrlp_log_rlp_statistics() */
Пример #6
0
uint32_t
process_diagfw_msg(uint8_t *datap, uint16_t len, uint32_t optionflag,
      FILE *log_out, int32_t *record, int32_t max_records, int32_t version,
      int sock_fd)
{
    uint32_t count = 0, index = 0;
    uint32_t timestamp = 0;
    uint32_t diagid = 0, id = 0;
    uint32_t moduleid = 0, res = 0;
    uint32_t num_buf = 0, payloadlen = 0;
    uint16_t vdevid = 0, vdevlevel = 0;
    uint16_t numargs = 0;
    uint32_t *buffer;
    uint32_t header1 = 0, header2 = 0;
    int32_t  lrecord = 0;
    char *payload;
    char buf[BUF_SIZ], payload_buf[BUF_SIZ];
    char *start = buf;
    int32_t hashInd = 0, i =0, j =0;
    diag_entry *entry = NULL;
    int ret = 0, total_dump_len = 0;
    uint8_t *debugp = datap;
    char dump_buffer[BUF_SIZ];

    if (optionflag & DEBUG_FLAG) {
        memset(dump_buffer, 0, sizeof(dump_buffer));
        debug_printf("process_diagfw_msg hex dump start len %d", len);
        for (i = 0; i < len; i++) {
             ret = snprintf(dump_buffer + j, BUF_SIZ - j, "0x%x ", debugp[i]);
             j += ret;
             if (!(i % 16) && (i!=0)) {
                total_dump_len += 16;
                debug_printf("%s", dump_buffer);
                memset(dump_buffer, 0, sizeof(dump_buffer));
                j = 0;
             }
        }
        if (total_dump_len != len)
           debug_printf("%s", dump_buffer);
        debug_printf("process_diagfw_msg hex dump end");
    }

    if (!gisdiag_init) {
       /* If cnss_diag is started if WIFI already ON,
        * then turn on event not received hence
        * before throwing out error initialize again
        */
        diag_initialize(sock_fd, optionflag);
        if (!gisdiag_init) {
            diag_printf("**ERROR** Diag not Initialized",
                          0, 4, optionflag, 0, NULL);
            return -1;
        }

    }
    buffer = (uint32_t *)datap  ;
    buffer ++; /* increment 1 to skip dropped */
    num_buf = len - 4;
    debug_printf("\n --%s-- %d\n", __FUNCTION__, optionflag);

    while (num_buf  > count) {

        header1 = *(buffer + index);
        header2 = *(buffer + 1 + index);
        payload = (char *)(buffer + 2 + index);
        diagid  = DIAG_GET_TYPE(header1);
        timestamp = DIAG_GET_TIME_STAMP(header1);
        payloadlen = 0;
        debug_printf("\n diagid = %d  timestamp = %d"
                    " header1 = %x heade2 = %x\n",
                     diagid,  timestamp, header1, header2);
        switch (diagid) {
        case WLAN_DIAG_TYPE_EVENT:
        {
            id = DIAG_GET_ID(header2);
            payloadlen = DIAG_GET_PAYLEN16(header2);
            debug_printf("DIAG_TYPE_FW_EVENT: id = %d"
                         " payloadlen = %d \n", id, payloadlen);
            if (optionflag & QXDM_FLAG) {
                if (payloadlen)
                    event_report_payload(id, payloadlen, payload);
                else
                    event_report(id);
             }
        }
        break;
        case WLAN_DIAG_TYPE_LOG:
        {
            id = DIAG_GET_ID(header2);
            payloadlen = DIAG_GET_PAYLEN16(header2);
            debug_printf("DIAG_TYPE_FW_LOG: id = %d"
                         " payloadlen = %d \n", id,  payloadlen);
            if (optionflag & QXDM_FLAG) {
                /* Allocate a log buffer */
                uint8_t *logbuff = (uint8_t*) log_alloc(id,
                                    sizeof(log_hdr_type)+payloadlen);
                if ( logbuff != NULL ) {
                    /* Copy the log data */
                    memcpy(logbuff + sizeof(log_hdr_type), payload,
                              payloadlen);
                    /* Commit the log buffer */
                    log_commit(logbuff);
                }
                else
                    debug_printf("log_alloc failed for len = %d ", payloadlen);
            }
        }
        break;
        case WLAN_DIAG_TYPE_MSG:
        {
            id = DIAG_GET_ID(header2);
            payloadlen = DIAG_GET_PAYLEN(header2);
            vdevid = DIAG_GET_VDEVID(header2);
            vdevlevel = DIAG_GET_VDEVLEVEL(header2);
            memset(buf, 0, BUF_SIZ);
            memset(payload_buf, 0, BUF_SIZ);
            debug_printf(" DIAG_TYPE_FW_DEBUG_MSG: "
                   " vdevid %d vdevlevel %d payloadlen = %d id = %d\n",
                                  vdevid, vdevlevel, payloadlen, id);
            if (gdiag_header->file_version != version) {
                snprintf(buf, BUF_SIZ, "**ERROR**"
                " Data.msc Version %d doesn't match"
                " with Firmware version %d id = %d",
                gdiag_header->file_version, version, id);
                diag_printf(buf, 0, 4, optionflag, 0, NULL);
                break;
            }
            entry = diag_find_by_id(id);
            if (entry) {
                if ((payloadlen > 0) && (entry->format && entry->pack)) {
                    debug_printf("entry->format = %s pack = %s\n",
                                    entry->format, entry->pack);
                    if (payloadlen < BUF_SIZ)
                        memcpy(payload_buf, payload, payloadlen);
                    else
                        memcpy(payload_buf, payload, BUF_SIZ);
                    /* Sending with BUF_SIZ to pack_printf
                     * because some times payloadlen received
                     * doesnt match with the pack specifier, in
                     * that case just print the zero
                     */
                    entry->msg_len = BUF_SIZ;
                    entry->msg = payload_buf;
                    start = buf;
                    pack_printf(
                             dbg_write_char,
                             &start,
                             start + sizeof(buf),
                             entry->format,
                             entry->pack,
                             (uint8_t*)entry->msg,
                             entry->msg_len
                              );
                }
                else if (entry->format)
                    strlcpy(buf, entry->format, strlen(entry->format));

                debug_printf("\n buf = %s \n", buf);
                if (optionflag & LOGFILE_FLAG)  {
                    lrecord = *record;
                    lrecord++;
                    if (!((optionflag & SILENT_FLAG) == SILENT_FLAG))
                        printf("%d: %s\n", lrecord, buf);

                    res = diag_printf(
                         buf, vdevid, vdevlevel, optionflag, timestamp, log_out
                              );
                    //fseek(log_out, lrecord * res, SEEK_SET);
                    if (lrecord == max_records) {
                        lrecord = 0;
                        fseek(log_out, lrecord * res, SEEK_SET);
                    }
                    *record = lrecord;
                }
                if (optionflag & (CONSOLE_FLAG | QXDM_FLAG))
                    diag_printf(
                         buf, vdevid, vdevlevel, optionflag, timestamp, NULL
                              );
            }
            else {
                switch (id) {
                case DIAG_WLAN_MODULE_STA_PWRSAVE:
                case DIAG_WLAN_MODULE_WAL:
                case DIAG_NAN_MODULE_ID:
                case DIAG_WLAN_MODULE_IBSS_PWRSAVE:
                    if (!diag_msg_handler(id, payload, vdevid, timestamp)) {
                        snprintf(buf, BUF_SIZ,
                            "****WARNING****, undefined moduleid = %d no t"
                            " found", moduleid);
                        diag_printf(buf, 0, 4, optionflag, timestamp, NULL);
                    }
                break;
                default:
                    snprintf(buf, BUF_SIZ,
                             "****WARNING****, FWMSG ID %d not found", id);
                    diag_printf(buf, 0, 4, optionflag, timestamp, NULL);
                    printf( "NOT found id = %d\n", id);
                }
            }
        }
        break;
        default:
            diag_printf(" ****WARNING**** WRONG DIAG ID", 0,
                      4, optionflag, timestamp, NULL);
        return 0;
        }
        count  += payloadlen + 8;
        index = count >> 2;
        debug_printf("Loope end:id = %d  payloadlen = %d count = %d index = %d\n",
                    id,  payloadlen,  count, index);
    }

    return (0);
}