コード例 #1
0
ファイル: md_share3.CPP プロジェクト: abcweizhuo/Test3
void MRngChkMngr::Dump()
  {
  POSITION Pos=m_List.GetHeadPosition();
  while (Pos)
    {
    MRngChkCntxt &C=*m_List.GetNext(Pos);
    //dbgpln("MRngChkMngr::Dump %4i %08x %i  %s", m_Iter, this, C.m_Iter, C.RngChkTag());
    if (C.m_Iter==m_Iter)
      {
      //dbgpln("RngChk %s:%s", C.RngChkTag());
      POSITION PosI=C.m_List.GetHeadPosition();
      while (PosI)
        {
        MRngChkItem &I=*C.m_List.GetNext(PosI);
        dbgp("  %-20s %08x", I.m_Key.m_sCntxt, &I);
        if (I.m_GTMax)
          dbgp("  %-20s %.4f > %.4f", I.m_Key.m_sName, I.m_Value, I.m_MaxValue);
        if (I.m_LTMin)
          dbgp("  %-20s %.4f < %.4f", I.m_Key.m_sName, I.m_Value, I.m_MinValue);
        dbgpln("");
        
        }
      }
    }
  };
コード例 #2
0
ファイル: platform_linux.c プロジェクト: mrtos/gk6105s-id
int platform_request_firmware(struct firmware *fw, const char *name)
{
    dbgp("'%s' firmware requested\n", name);
    char filename[1024];

    int fd;

    snprintf(filename, 1024, "%s/%s", CONFIG_FIRMWARE_PATH, name);

    fd = open(filename, O_RDONLY);

    fw->buffer = NULL;
    fw->length = 0;

    if (fd < 0) {
        dbgp("could not open '%s'\n", filename);
        return DIB_RETURN_ERROR;
    }

    fw->buffer = malloc(300000);
    fw->length = read(fd, fw->buffer, 300000);
    close(fd);

    return DIB_RETURN_SUCCESS;
}
コード例 #3
0
static int host_i2c_xfer(struct dibDataBusClient *client, struct dibDataBusAccess *msg)
{
    struct i2c_state *st = NULL;
    
    //DBG("TSTV:DIBCOM8076: client is %p\n", client);
    st = client->host->priv;
    msg->address = data_bus_access_device_id(client, msg);
#ifdef DEBUG_DATA
    dbgp("i2c_%s: (addr: %02x): ",msg->rx == NULL ? "wr" : "rd",data_bus_access_device_id(client, msg) >> 1);
    dbg_bufdump(msg->tx,msg->txlen);
    if (msg->rx != NULL && msg->rxlen != 0) {
        dbgp(" - ");
        dbg_bufdump(msg->rx,msg->rxlen);
    }
    dbgp("\n");
#endif

    if (msg->rx == NULL || msg->rxlen == 0) {
        // implement here the write function and return DIB_RETURN_SUCCESS in case of success
        // return DIB_RETURN_SUCCESS
        return I2C_backend_Write(st, msg->address, msg->tx, msg->txlen);
        //return DIB_RETURN_ERROR;
    }
    else {
        // implement here the read function and return DIB_RETURN_SUCCESS in case of success
        // return DIB_RETURN_SUCCESS

        //return DIB_RETURN_ERROR;
        return I2C_backend_WriteRead(st, msg->address, msg->tx, msg->txlen, msg->rx, msg->rxlen);
    }
}
コード例 #4
0
ファイル: FLWNTDSP.CPP プロジェクト: abcweizhuo/Test3
void CSubNetBlk::ShowSubNetsJ(CJoinRec * p, int dbgShowConns)
  {
  dbgp("%s%s ", p->VFlowAllowed(m_bFullFlow) ? "V":" ", p->LFlowAllowed(m_bFullFlow) ? "L":" ");
  dbgp("%02i ", p->m_pSubNet->m_SubNetNo);
  dbgp(" %s", JoinTypeStr(p->Typ));
//  dbgp("%s", p->fIsImpNd ? "I":" ");
//  dbgp("%s", p->fIsAccLnk? "A":" ");
  dbgp(" %s",SgnStr(p->Dirn));
  dbgp(" %s%s%s%s %s",
    (p->fLonely ? "L" : p->fUnDefined ? "U" : " "),
    (p->fIsolatedNet ? (p->fIsoNetRef ? "I" : " ") : p->fIsolatedNode ? "i" : " "),
    (p->fIsFixedXfer ? "X" : (p->fInFixedNet ? "F" : " ")),
    (p->fIsFixedExtern ? "x" : " "), (p->fHasXBstHere? "B" : " "), (p->fUDFShut ? "S" : " "));
  switch(p->Typ)
    {
    case JTyp_Tie:
    case JTyp_ImpNd:
    case JTyp_AccLnk:
      dbgp(" P ");
      if (p->nProdFracs>=2)
        {
        dbgp(" pf[%i]",p->nProdFracs);
        for (int pf=0; pf<p->nProdFracs; pf++)
          dbgp(" [%s:%g]",p->Nd_Rmt(p->ProdFracs[pf].iConnNo)->FullObjTag(),p->ProdFracs[pf].dProdFrac);
        }
      break;
    default :
      dbgp(" ?              ");
      break;
    }
  dbgpln(" %s%s(%i)", SgnStr(p->Dirn), p->Nd()->FullObjTag(),p->iJoinArrayInx);
  }
コード例 #5
0
ファイル: FLWNTDSP.CPP プロジェクト: abcweizhuo/Test3
void CSubNetBlk::ShowSubNetsL(CGrpFlwBlk * g, int dbgShowConns)
  {
  dbgp("%s%s ", g->m_iFlwPh_Act&FPh_Gasses ? "V":" ", g->m_iFlwPh_Act&FPh_Liquid? "L":" ");
  dbgp("%02i ", g->m_pSubNet->m_SubNetNo);
  dbgp(" %s", JoinTypeStr(g->m_LnkInx.Typ));

  int Fxd=g->m_Src.m_pFBJn->GetFixed();
  dbgp(" %s[%s]%s", (Fxd?"{":" "), g->m_Src.m_pNd->FullObjTag(),(Fxd?"}":" "));
  JoinIter L(g->m_Lnks);
  for (CJoinRec * p = L.First(); p; p = L.Next())
    {
    switch(p->Typ)
      {
      case JTyp_Link:
      case JTyp_Edge:
      case JTyp_FxdLnk:
      case JTyp_Lone:
        {
        dbgp("->");
        Fxd=0;
        for (int c=0; c<p->NConns(); c++)
          if (p->IOFB(c,0)->GetFixed())
            Fxd=1;
        dbgp("%s%s%s(%i)%s",(Fxd?"{":" "), SgnStr(p->Dirn), p->Nd()->FullObjTag(),p->iJoinArrayInx,(Fxd?"}":" "));
        dbgp("%02i ", p->m_pSubNet->m_SubNetNo);
        }
        break;
      default:
        dbgpln(" %s%s(%i)", SgnStr(p->Dirn), p->Nd()->FullObjTag(),p->iJoinArrayInx);
      }
    }
  Fxd=g->m_Dst.m_pFBJn->GetFixed();
  dbgp("->%s[%s]%s", (Fxd?"{":" "), g->m_Dst.m_pNd->FullObjTag(),(Fxd?"}":" "));
  dbgpln("");
  }
コード例 #6
0
ファイル: DDE_EXEC.CPP プロジェクト: ChrisMoreton/Test3
flag CDdeExec::EO_WriteSubsData(CXMsgLst &XM, flag FirstBlock, flag LastBlock)
  {
//dbgp("SubsData:Wrt ");
  while (XM.MsgAvail())
    {
    CXM_ObjectData *pX = XM.ObjectData();
    CPkDataItem * pPItem = pX->FirstItem();
    int iIndex = pX->Index;
    Dde.Lock();
    if (iIndex<SubsData.GetSize())
      {
      CDdeAdviseBlk *p = SubsData[iIndex];
//dbgp(" %i", iIndex);
      //if (p->pItem && pPItem->Value() && IsData(pPItem->Value()->Type()))
      if (p->pItem && pPItem->Contains(PDI_Value) && IsData(pPItem->Value()->Type()))
        {
//dbgp(" %s", (LPCTSTR)p->pItem->m_strName);
        // Fetch On First Pass
        //if (pPItem->Contains(PDI_CnvInfo) && p->sCnvTxt.Length() > 0)
        CCnvIndex iCnv = p->pItem->iCnvIndex;
        if (p->sCnvTxt.Length()>0 && (iCnv)==0)
          p->sValue.Set("#Conversion not expected");
        else
          {
          if (p->sCnvTxt() && Cnvs[iCnv]->Find(p->sCnvTxt())==NULL)
            p->sValue.Set("#Unknown conversion '%s's", p->sCnvTxt());
          else
            p->sValue = pPItem->Value()->GetString("%i", "%g", iCnv, p->sCnvTxt());
          }
        StatsCnt[0]++;

        PostThreadMessage(dwThreadId, wm_SyscadDdeCommand, MAKEWPARAM(DDE_POSTADVISE, (WORD)iIndex), (LPARAM)p);
        }
      else
        {
        dbgp("Skipping DDE Data subscription change");
        if (p->pItem)
          dbgp(" %s", (LPCTSTR)p->pItem->m_strName);
        dbgpln("");
        }
      }
    Dde.Release();
    }
//dbgpln("");
  CScdDDEManager::pTheMngr->UpdateStatusWnd((WPARAM)SUB_UPDATE_EOWRITE);
  return True;
  }
コード例 #7
0
ファイル: FLWNTDSP.CPP プロジェクト: abcweizhuo/Test3
void CSubNetBlk::ShowSubNet(int dbgShowConns)
  {
  dbgpln("--------------------------------");
  //dbgp("%i.%i - %s - ",pNet->NetNo, SubNetNo, SolnString(SolutionType()));
  dbgp("%i.%i - ",pNet->NetNo, m_SubNetNo);
  if (m_fLonely) dbgp("Lonely ");
  if (m_fUnDefined) dbgp("Undefined ");
  if (m_fIsolatedNet) dbgp("IsolatedNet ");
  if (m_fIsolatedNode) dbgp("IsolatedNode ");
  if (m_fFixed) dbgp("Fixed ");
  if (m_fNetWrk) dbgp("NetWrk ");
  dbgpln("");

  GrpFlwIter G(m_Grps);
  for (CGrpFlwBlk * g=G.First(); g; g=G.Next())
    ShowSubNetsL(g, dbgShowConns);

  dbgpln("...");
  JoinIter T(m_Ties);
  for (CJoinRec * p = T.First(); (p); p = T.Next())
    ShowSubNetsT(p, dbgShowConns);

//  dbgpln("...");
//  JoinIter J(Joins);
//  for (CJoinRec * j = J.First(); (j); j = J.Next())
//    ShowSubNetsJ(j, dbgShowConns);

  if (dbgShowConns) 
    {
    }
  }
コード例 #8
0
ファイル: md_share3.CPP プロジェクト: abcweizhuo/Test3
void MDebug::Print(LPCSTR pFmt, ...)
  {
  char Buff[2048];
  va_list argptr;
  va_start(argptr, pFmt);
  vsprintf(Buff, pFmt, argptr);
  va_end(argptr);
  dbgp("%s", Buff);
  };
コード例 #9
0
/*#F:Outputs the vector contents (format acording to options) to the debug file.*/
void CIArray::dbgDump( pchar Desc,  //Optional text description, default = ''
                       flag Horizontal) //Optional, default = True
{
    dbgp("%s:[%d]", Desc, GetSize());
    if (Horizontal)
    {
        for (long i=0; i<Min(50,GetSize()); i++)
            dbgp("%11.3g ", m_pData[i]);
        if (GetSize()>5)
            dbgp("...");
        dbgpln("");
    }
    else
    {
        dbgpln("");
        for (long i=0; i<GetSize(); i++)
            dbgpln("%4d: %11.3g", i, m_pData[i]);
    }
}
コード例 #10
0
ファイル: SR_CTRL.CPP プロジェクト: abcweizhuo/Test3
double CEC_FracExt::ExtentActual(double ProdMoles)
  {
  double EA=0;
  if (m_iXSpcId>=0)
    {
    if (RB.Version()==3)
      {
      double MolesUsed=0;
      if (m_iXReactTerm>=0)
        MolesUsed=Eq.m_dMlXfer*Eq.Reactant[m_iXReactTerm].NoOfMoles;
      else if (m_iXProdTerm>=0)
        MolesUsed=Eq.m_dMlXfer*Eq.Product[m_iXProdTerm].NoOfMoles;
      else
        {
        ASSERT_ALWAYS(0, "FracExt not setup", __FILE__, __LINE__);
        }
      if (RB.Moles_BS[m_iXSpcId]>=ZeroLimit)
        EA=MolesUsed/RB.Moles_BS[m_iXSpcId];
      else
        EA=ExtentReqd();
      }
    }
  if (0)
    {
    dbgp("Extent   :Actual: Prod:%14.8g Act:%14.8f Rqd:%14.8f|", ProdMoles, EA, ExtentReqd());
    //for (int i=0; i<SVSpcCount();i++)
    //  if (RB.Moles[i]>0.0 || NewMoles[i]>0)
    //    dbgp(" %10.6f", RB.Moles[i]);
    dbgpln("");
    //dbgp("                  %14s %14s %14s|", "", "", "", "", "", "", "", "");
    //for (int i=0; i<SVSpcCount();i++)
    //  if (RB.Moles[i]>0.0 || NewMoles[i]>0)
    //    dbgp(" %10.6f", NewMoles[i]);
    //dbgpln("");
    }
  if (0)
    {
    dbgp("FracExt:Actual:  %10.4f  %10.4f  %10.4f  ",
          ProdMoles, EA, ExtentReqd());
    dbgpln("");
    }
  return EA;
  };
コード例 #11
0
void CSlotConnect::Dump(LPCSTR Hd)
  {
  dbgp("%sConn %s %s %s %10s %4i %10s ",//%4i Cd:%4i %08x %08x %s", 
    Hd, m_bValid?"OK":"  ", m_bIsGet?"Get":"   ", m_bIsSet?"Set":"   ", SrcDstString(m_eSrc), m_lSrcIndex, SrcDstString(m_eDst));

  if (m_eDst==eCSD_CdBlk)
    dbgpln("Cd:%4i %08x %08x %s", m_lCdBlk, m_pCdBlk, m_pCdBlkVar, m_sTag);
  else
    dbgpln("%4i%22s%s", m_lDstIndex, "", m_sTag);

  for (int i=0; i<m_Delay.m_OnRise.GetCount(); i++)
    dbgpln("       Rise Delay  %8.2f @ %5i msecs", m_Delay.m_OnRise[i].m_Value.dblVal, m_Delay.m_OnRise[i].m_dwTime);
  for (int i=0; i<m_Delay.m_OnFall.GetCount(); i++)
    dbgpln("       Fall Delay  %8.2f @ %5i msecs", m_Delay.m_OnFall[i].m_Value.dblVal, m_Delay.m_OnFall[i].m_dwTime);
  }
コード例 #12
0
ファイル: netcfg.c プロジェクト: Corbachu/KallistiOS
void netcfg_vmuify(const char *filename_in, const char *filename_out) {
    int fd, pkg_size;
    uint8   *buf;
    uint8   *pkg_out;
    vmu_pkg_t pkg;

    dbgp("Opening source file\n");
    fd = fs_open(filename_in, O_RDONLY);
    buf = (uint8 *) malloc(fs_total(fd));
    fs_read(fd, buf, fs_total(fd));
    dbgp("Read %i bytes\n", fs_total(fd));

    strcpy(pkg.desc_short, "KallistiOS 1.3");
    strcpy(pkg.desc_long, "KOS Network Settings");
    strcpy(pkg.app_id, "KOS");
    pkg.icon_cnt = 1;
    pkg.icon_anim_speed = 1;
    memcpy(&pkg.icon_pal[0], netcfg_icon, 32);
    pkg.icon_data = netcfg_icon + 32;
    pkg.eyecatch_type = VMUPKG_EC_NONE;
    pkg.data_len = fs_total(fd);
    pkg.data = buf;
    dbgp("Building package\n");
    vmu_pkg_build(&pkg, &pkg_out, &pkg_size);
    fs_close(fd);
    dbgp("Closing source file\n");

    dbgp("Opening output file\n");
    fd = fs_open(filename_out, O_WRONLY);
    dbgp("Writing..\n");
    fs_write(fd, pkg_out, pkg_size);
    dbgp("Closing output file\n");
    fs_close(fd);
    free(buf);
    dbgp("VMUification complete\n");
}
コード例 #13
0
ファイル: SR_CTRL.CPP プロジェクト: abcweizhuo/Test3
double CEC_FinalConc::ExtentActual(double ProdMoles)
  {
  SpMArray NewMoles;
  NewMoles=RB.Moles;
  CR_EqnControl::ApplyChanges(ProdMoles, NewMoles);
  RB.AdjustForSrcSnks(NewMoles);

  double M=NewMoles[m_Spc.m_SpcId];
  double MW=SDB[m_Spc.m_SpcId].MoleWt();
  double V=RB.VolWithLockup(som_Liq, NewMoles, Valid(m_dRqdTemp)?m_dRqdTemp:RB.EstFinalT(), RB.m_Press);
  double C;
  if (m_Spc.m_ReactTerm>=0)
    {
    C=(M*MW)/GTZ(V);
    }
  else if (m_Spc.m_ProdTerm>=0)
    {
    C=(M*MW)/GTZ(V);
    }
  else
    C=0.0;

  if (0)
    {
    if (1)
      dbgp("FinalConc:Actual: Prod:%14.8g Act:%14.8f Rqd:%14.8f %10.4f %10.4f|",
          ProdMoles, C, ExtentReqd(), M, V);
    else
      dbgp("FinalConc:Actual: %14.8f %14.8f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f|",
          ProdMoles, C, ExtentReqd(), M, MW, V, Valid(m_dRqdTemp)?m_dRqdTemp:RB.EstFinalT(), RB.m_Press);
    for (int i=0; i<SVSpcCount();i++)
      if (RB.Moles[i]>0.0 || NewMoles[i]>0)
        dbgp(" %10.6f", RB.Moles[i]);
    dbgpln("");
    if (1)
      dbgp("                  %14s %14s %14s %10s %10s|", "", "", "", "", "", "", "", "");
    else
      dbgp("                  %14s %14s %10s %10s %10s %10s %10s %10s|", "", "", "", "", "", "", "", "");
    for (int i=0; i<SVSpcCount();i++)
      if (RB.Moles[i]>0.0 || NewMoles[i]>0)
        dbgp(" %10.6f", NewMoles[i]);
    dbgpln("");
    }
  return C;
  };
コード例 #14
0
ファイル: sample_tune.c プロジェクト: mrtos/gk6105s-id
static void dump_dvb_channel_params(struct dibChannel *cd)
{
    int i;
    if (cd->type == STANDARD_DVBT) {
        dbgp("DVB-T at %d kHz: ",cd->RF_kHz);
        switch (cd->u.dvbt.nfft) {
            case FFT_8K: dbgp("8K "); break;
            case FFT_4K: dbgp("4K "); break;
            case FFT_2K: dbgp("2K "); break;
            default: dbgp("FFT_UNK "); break;
        }

        dbgp("1/%i  ", 32 / (1 << cd->u.dvbt.guard));
        switch (cd->u.dvbt.constellation) {
            case QAM_QPSK: dbgp("QPSK "); break;
            case QAM_16QAM: dbgp("16QAM "); break;
            case QAM_64QAM: dbgp("64QAM "); break;
            default: dbgp("QAM_UNK "); break;
        }

        dbgp("%s ", cd->u.dvbt.intlv_native ? "NATIVE_INTLV" : "EXTENDED_INTLV");
        dbgp("ALPHA %i ", cd->u.dvbt.alpha);
        dbgp("Code Rate HP %i/%i ", cd->u.dvbt.code_rate_hp, cd->u.dvbt.code_rate_hp + 1);
        dbgp("Code Rate LP %i/%i ", cd->u.dvbt.code_rate_lp, cd->u.dvbt.code_rate_lp + 1);
        dbgp("HRCH %i\n", cd->u.dvbt.hrch);
    }
    else if (cd->type == STANDARD_ISDBT) {
        dbgp("ISDBT at %d kHz: ",cd->RF_kHz);
        switch (cd->u.isdbt.nfft) {
            case FFT_8K: dbgp("8K "); break;
            case FFT_4K: dbgp("4K "); break;
            case FFT_2K: dbgp("2K "); break;
            default: dbgp("FFT_UNK "); break;
        }

        dbgp("1/%i  ", 32 / (1 << cd->u.isdbt.guard));

        dbgp("%s ", cd->u.isdbt.partial_reception ? "PARTIAL_RCPT" : "NATIVE_RCPT");
        dbgp("%s ", cd->u.isdbt.sb_mode ? "SB_mode":"");
        for (i = 0; i < 3; i ++) {
            dbgp("| L%c: nb_seg: %d ", 'a' + i, cd->u.isdbt.layer[i].nb_segments);
            switch (cd->u.isdbt.layer[i].constellation) {
                case QAM_QPSK: dbgp("QPSK "); break;
                case QAM_16QAM: dbgp("16QAM "); break;
                case QAM_64QAM: dbgp("64QAM "); break;
                case QAM_DQPSK: dbgp("DQPSK"); break;
                default: dbgp("QAM_UNK "); break;
            }
            dbgp("%d/%d ",cd->u.isdbt.layer[i].code_rate, cd->u.isdbt.layer[i].code_rate+1);
            dbgp("%d ", cd->u.isdbt.layer[i].time_intlv);
        }
        dbgp("\n");
    }
}
コード例 #15
0
ファイル: dibcom7070X_app.c プロジェクト: mrtos/gk6105s-id
static void dump_dvb_channel_params(struct dibChannel *cd)
{
//    int i;
    if (cd->type == STANDARD_DVBT) {
        dbgp("DVB-T at %d kHz: ",cd->RF_kHz);
        switch (cd->u.dvbt.nfft) {
        case FFT_8K:
            dbgp("8K ");
            break;
        case FFT_4K:
            dbgp("4K ");
            break;
        case FFT_2K:
            dbgp("2K ");
            break;
        default:
            dbgp("FFT_UNK ");
            break;
        }

        dbgp("1/%i  ", 32 / (1 << cd->u.dvbt.guard));
        switch (cd->u.dvbt.constellation) {
        case QAM_QPSK:
            dbgp("QPSK ");
            break;
        case QAM_16QAM:
            dbgp("16QAM ");
            break;
        case QAM_64QAM:
            dbgp("64QAM ");
            break;
        default:
            dbgp("QAM_UNK ");
            break;
        }

        dbgp("%s ", cd->u.dvbt.intlv_native ? "NATIVE_INTLV" : "EXTENDED_INTLV");
        dbgp("ALPHA %i ", cd->u.dvbt.alpha);
        dbgp("Code Rate HP %i/%i ", cd->u.dvbt.code_rate_hp, cd->u.dvbt.code_rate_hp + 1);
        dbgp("Code Rate LP %i/%i ", cd->u.dvbt.code_rate_lp, cd->u.dvbt.code_rate_lp + 1);
        dbgp("HRCH %i\n", cd->u.dvbt.hrch);
    }

}
コード例 #16
0
ファイル: platform_linux.c プロジェクト: alkap007/ali3606
int platform_request_firmware(const char *name,
                              int options,
                              int size,
                              int * off,
                              int (*platform_firmware_indication)(void * ctx, uint8_t * buf, uint32_t len, uint32_t off, uint32_t done),
                              void *ctx)
{
    dbgp("'%s' firmware requested\n", name);
    char filename[1024];

    int fd;

    uint8_t * buffer;
    int32_t len;
    uint32_t async = options & (1 << 29);
    uint32_t uncompress = options & (1 << 31);
    uint32_t done = 0;

    /* if max length is forwarded keeping the options, clean it */
    size &= ~REQUEST_FIRMWARE_OPTION_MASK;

    snprintf(filename, 1024, "%s/%s", CONFIG_FIRMWARE_PATH, name);

    if(platform_firmware_indication == 0)
    {
      return DIB_RETURN_ERROR;
    }

    if(uncompress)
    {
        dbgp("uncompress not supported on HOST\n");
        return DIB_RETURN_ERROR;
    }

    fd = open(filename, O_RDONLY);

    if (fd < 0) {
        dbgp("could not open '%s'\n", filename);
        return DIB_RETURN_ERROR;
    }

    lseek(fd, *off, SEEK_SET);

    buffer = malloc(size);
    if(buffer == 0)
    {
        close(fd);
        return DIB_RETURN_ERROR;
    }

    while(!done)
    {
        len = read(fd, buffer, size);
        if(len < 0) {
           return DIB_RETURN_ERROR;
        }
        else {
           done = (len < size) ? 1 : 0 ;
           platform_firmware_indication(ctx, buffer, len, *off, done);
           *off += len;
           if(async)
              break;
        }
    }

    close(fd);
    free(buffer);

    return DIB_RETURN_SUCCESS;
}
コード例 #17
0
ファイル: glfs.c プロジェクト: rootfs/tcmu-runner
/*
 * Return scsi status or TCMU_NOT_HANDLED
 */
int tcmu_glfs_handle_cmd(
	struct tcmu_device *dev,
	struct tcmulib_cmd *tcmulib_cmd)
{
	uint8_t *cdb = tcmulib_cmd->cdb;
	struct iovec *iovec = tcmulib_cmd->iovec;
	size_t iov_cnt = tcmulib_cmd->iov_cnt;
	uint8_t *sense = tcmulib_cmd->sense_buf;
	struct glfs_state *state = tcmu_get_dev_private(dev);
	uint8_t cmd;

	glfs_fd_t *gfd = state->gfd;
	int ret;
	uint32_t length;
	int result = SAM_STAT_GOOD;
	char *tmpbuf;
	uint64_t offset = state->block_size * tcmu_get_lba(cdb);
	uint32_t tl     = state->block_size * tcmu_get_xfer_length(cdb);
	int do_verify = 0;
	uint32_t cmp_offset;
	ret = length = 0;

	cmd = cdb[0];

	switch (cmd) {
	case INQUIRY:
		return tcmu_emulate_inquiry(dev, cdb, iovec, iov_cnt, sense);
		break;
	case TEST_UNIT_READY:
		return tcmu_emulate_test_unit_ready(cdb, iovec, iov_cnt, sense);
		break;
	case SERVICE_ACTION_IN_16:
		if (cdb[1] == READ_CAPACITY_16) {
			long long size;
			unsigned long long num_lbas;

			size = tcmu_get_device_size(dev);
			if (size == -1) {
				errp("Could not get device size\n");
				return TCMU_NOT_HANDLED;
			}

			num_lbas = size / state->block_size;

			return tcmu_emulate_read_capacity_16(num_lbas, state->block_size,
							     cdb, iovec, iov_cnt, sense);
		} else {
			return TCMU_NOT_HANDLED;
		}
		break;
	case MODE_SENSE:
	case MODE_SENSE_10:
		return tcmu_emulate_mode_sense(cdb, iovec, iov_cnt, sense);
		break;
	case MODE_SELECT:
	case MODE_SELECT_10:
		return tcmu_emulate_mode_select(cdb, iovec, iov_cnt, sense);
		break;
	case COMPARE_AND_WRITE:
		/* Blocks are transferred twice, first the set that
		 * we compare to the existing data, and second the set
		 * to write if the compare was successful.
		 */
		length = tl / 2;

		tmpbuf = malloc(length);
		if (!tmpbuf) {
			result = tcmu_set_sense_data(sense, HARDWARE_ERROR,
						     ASC_INTERNAL_TARGET_FAILURE, NULL);
			break;
		}

		ret = glfs_pread(gfd, tmpbuf, length, offset, SEEK_SET);

		if (ret != length) {
			result = set_medium_error(sense);
			free(tmpbuf);
			break;
		}

		cmp_offset = tcmu_compare_with_iovec(tmpbuf, iovec, length);
		if (cmp_offset != -1) {
			result = tcmu_set_sense_data(sense, MISCOMPARE,
						     ASC_MISCOMPARE_DURING_VERIFY_OPERATION,
						     &cmp_offset);
			free(tmpbuf);
			break;
		}

		free(tmpbuf);

		tcmu_seek_in_iovec(iovec, length);
		goto write;
	case SYNCHRONIZE_CACHE:
	case SYNCHRONIZE_CACHE_16:
		if (cdb[1] & 0x2)
			result = tcmu_set_sense_data(sense, ILLEGAL_REQUEST,
						     ASC_INVALID_FIELD_IN_CDB, NULL);
		else
			glfs_fdatasync(gfd);
		break;
	case WRITE_VERIFY:
	case WRITE_VERIFY_12:
	case WRITE_VERIFY_16:
		do_verify = 1;
	case WRITE_6:
	case WRITE_10:
	case WRITE_12:
	case WRITE_16:
		length = tl;
write:
		ret = glfs_pwritev(gfd, iovec, iov_cnt, offset, ALLOWED_BSOFLAGS);

		if (ret == length) {
			/* Sync if FUA */
			if ((cmd != WRITE_6) && (cdb[1] & 0x8))
				glfs_fdatasync(gfd);
		} else {
			errp("Error on write %x %x\n", ret, length);
			result = set_medium_error(sense);
			break;
		}

		if (!do_verify)
			break;

		tmpbuf = malloc(length);
		if (!tmpbuf) {
			result = tcmu_set_sense_data(sense, HARDWARE_ERROR,
						     ASC_INTERNAL_TARGET_FAILURE, NULL);
			break;
		}

		ret = glfs_pread(gfd, tmpbuf, length, offset, ALLOWED_BSOFLAGS);

		if (ret != length) {
			result = set_medium_error(sense);
			free(tmpbuf);
			break;
		}

		cmp_offset = tcmu_compare_with_iovec(tmpbuf, iovec, length);
		if (cmp_offset != -1)
			result = tcmu_set_sense_data(sense, MISCOMPARE,
					    ASC_MISCOMPARE_DURING_VERIFY_OPERATION,
					    &cmp_offset);
		free(tmpbuf);
		break;

	case WRITE_SAME:
	case WRITE_SAME_16:
		errp("WRITE_SAME called, but has vpd b2 been implemented?\n");
		result = tcmu_set_sense_data(sense, ILLEGAL_REQUEST,
					     ASC_INVALID_FIELD_IN_CDB, NULL);
		break;

#if 0
		/* WRITE_SAME used to punch hole in file */
		if (cdb[1] & 0x08) {
			ret = glfs_discard(gfd, offset, tl);
			if (ret != 0) {
				result = tcmu_set_sense_data(sense, HARDWARE_ERROR,
						    ASC_INTERNAL_TARGET_FAILURE, NULL);
			}
			break;
		}
		while (tl > 0) {
			size_t blocksize = state->block_size;
			uint32_t val32;
			uint64_t val64;

			assert(iovec->iov_len >= 8);

			switch (cdb[1] & 0x06) {
			case 0x02: /* PBDATA==0 LBDATA==1 */
				val32 = htobe32(offset);
				memcpy(iovec->iov_base, &val32, 4);
				break;
			case 0x04: /* PBDATA==1 LBDATA==0 */
				/* physical sector format */
				/* hey this is wrong val! But how to fix? */
				val64 = htobe64(offset);
				memcpy(iovec->iov_base, &val64, 8);
				break;
			default:
				/* FIXME */
				errp("PBDATA and LBDATA set!!!\n");
			}

			ret = glfs_pwritev(gfd, iovec, blocksize,
					offset, ALLOWED_BSOFLAGS);

			if (ret != blocksize)
				result = set_medium_error(sense);

			offset += blocksize;
			tl     -= blocksize;
		}
		break;
#endif
	case READ_6:
	case READ_10:
	case READ_12:
	case READ_16:
		length = tcmu_iovec_length(iovec, iov_cnt);
		ret = glfs_preadv(gfd, iovec, iov_cnt, offset, SEEK_SET);

		if (ret != length) {
			errp("Error on read %x %x\n", ret, length);
			result = set_medium_error(sense);
		}
		break;
	case UNMAP:
		/* TODO: implement UNMAP */
		result = tcmu_set_sense_data(sense, ILLEGAL_REQUEST,
					     ASC_INVALID_FIELD_IN_CDB, NULL);
		break;
	default:
		result = TCMU_NOT_HANDLED;
		break;
	}

	dbgp("io done %p %x %d %u\n", cdb, cmd, result, length);

	if (result == TCMU_NOT_HANDLED)
		dbgp("io not handled %p %x %x %d %d %llu\n",
		     cdb, result, cmd, ret, length, (unsigned long long)offset);
	else if (result != SAM_STAT_GOOD) {
		errp("io error %p %x %x %d %d %llu\n",
		     cdb, result, cmd, ret, length, (unsigned long long)offset);
	}

	return result;
}
コード例 #18
0
ファイル: sample_nim9090md.c プロジェクト: mrtos/gk6105s-id
/* both demods are on the same I2C-bus by default accessible through address 18 */
int main (void)
{
    // default I2C implementation is based on parallel port but user can connect its
    // own I2C driver using host_i2c_interface_attach();
    // implementation is done in sample/interface/host.c
    //struct dibDataBusHost *i2c = host_i2c_interface_attach(NULL), *b;
    struct dibDataBusHost *i2c = open_spp_i2c(), *b;
    struct dibFrontend frontend[2];

    struct dibChannel ch;
    struct dibDemodMonitor mon[2];
    struct dibPMU *pmu;

    if (i2c == NULL)
        return 1;
    DibZeroMemory(&mon, sizeof(mon));

    frontend_init(&frontend[0]); /* initializing the frontend-structure */
    frontend_init(&frontend[1]); /* initializing the frontend-structure */
    frontend_set_id(&frontend[0], 0); /* assign an absolute ID to the frontend */
    frontend_set_id(&frontend[1], 1); /* assign an absolute ID to the frontend */

    if (dib9090_firmware_sip_register(&frontend[0], 0x80, i2c, &nim9090md_config[0]) == NULL) { /* using a frontend on I2C address 0x80 */
        dbgp(" DiB9090: attaching demod and tuners failed.\n");
        return DIB_RETURN_ERROR;
    }
    i2c = dib7000m_get_i2c_master(&frontend[0], DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
    if (dib9090_firmware_sip_register(&frontend[1], 0x82, i2c, &nim9090md_config[1]) == NULL) { /* using a frontend on I2C address 0x82 */
        dbgp(" DiB9090: attaching demod and tuners failed.\n");
        return DIB_RETURN_ERROR;
    }

    /* do the i2c-enumeration for 2 demod and use 0x80 as the I2C address for first device */
    i2c = data_bus_client_get_data_bus(demod_get_data_bus_client(&frontend[0]));
    dib7000m_i2c_enumeration(i2c, 1, 0x20, 0x80); /* non-standard i2c-enumeration, because of INT_SELECT-fixation */
    i2c = data_bus_client_get_data_bus(demod_get_data_bus_client(&frontend[1]));
    dib7000m_i2c_enumeration(i2c, 1, DEFAULT_DIB9000_I2C_ADDRESS, 0x82);

    b = dib7000m_get_i2c_master(&frontend[0], DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
    if ((pmu = osiris_create(b, &nim9090md_osiris_config)) == NULL)
        return DIB_RETURN_ERROR;
    dib9090_set_pmu(&frontend[0], pmu); /* workaround because we cannot access the PMU from the host after downloading the firmware - for now */

    frontend_reset(&frontend[0]);
    frontend_reset(&frontend[1]);

    INIT_CHANNEL(&ch, STANDARD_DVBT);
    ch.RF_kHz = 474000;
    ch.bandwidth_kHz = 8000;

/* just to set them in a known state - not important */
    tune_diversity(frontend, 2, &ch);

    DibDbgPrint("-I-  Tuning done <enter>\n");
    getchar();

    while (1) {
        /* after enumerating on the same i2c-bus, the i2c-addresses of the bus will be 0x80 for the diversity master and 0x82 for the slave */
        demod_get_monitoring(&frontend[0], &mon[0]);
        demod_get_monitoring(&frontend[1], &mon[1]);
        dib7000_print_monitor(mon, NULL, 0 ,2);
        usleep(100000);
    }

    DibDbgPrint("-I-  Cleaning up\n");

    frontend_unregister_components(&frontend[1]);
    frontend_unregister_components(&frontend[0]);
    pmu_release(pmu);

    //host_i2c_release(i2c);
    close_spp_i2c();

    return 0;
}
コード例 #19
0
ファイル: M_XFER.CPP プロジェクト: abcweizhuo/Test3
void MN_Xfer::EvalIntegral(CNodeEvalIndex & NEI)
  {
  //dbgpln("EvalIntegral - %s %s %s %s", InlineIntegral()?"Inline":"      ", IntegralDone()?"IntDone":"       ", GetActiveHold()?"Hold":"    ", Tag());
  if (m_NetworkIsolator)
    {

    //flag VLEOn=0 && VLE.Enabled();
    dword IOMsk=First64IOIds;
    //StkSpConduit QPF("QPF", chLINEID(), this);

    m_Accumulator->ZeroDeriv();
#if dbgMSurge
    if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk)
      {
      dbgp("           %*s",151-24,"");
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.12s", SVImg(s).Tag());
      dbgpln(" %s.Contents", FullObjTag());
      dbgp("InI:---  : T:%+13.6f = %13.6f P:%+13.6f = %13.6f M:%+13.6f = %13.6f L:%+13.6f = %13.6f",
        m_CnStart.DTemp(Contents), m_Accumulator->Temp(),
        m_CnStart.DPress(Contents), m_Accumulator->Press(),
        m_CnStart.DMass(Contents), m_Accumulator->Mass(),
        m_CnStart.DLevel(Contents)*100, m_Accumulator->Level()*100, FullObjTag());
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.5g", m_Accumulator->MArray()[s]);
      dbgpln(" %s.Contents", FullObjTag());
      }
#endif
    for (int i = 0; i < NoProcessIOs(); i++)
      {
      SpConduit * Cd;
      //if (VLEOn && IO_In(i))
      //  {
      //  QPF->QSetF(*IOConduit(i), som_ALL, 1.0);
      //  VLE.PFlash(QPF(), m_Accumulator->Press(), 0.0, VLEF_Null);
      //  Cd=&QPF();
      //  }
      //else
      Cd=IOConduit(i);
      //double FracAbove=(IOAbsFracHgt_Term(i, Contents)-m_Accumulator->Level())/GTZ(IOAperture(i));
      //FracAbove=Range(0.0, FracAbove, 1.0);
      double EntR=1.0;//FracAbove*IOEntrainRateSL(i)*Cd->QMass(som_SL)+
      //(1.0-FracAbove)*IOEntrainRateG(i)*Cd->QMass(som_Gas);
      m_Accumulator->AddDeriv(*Cd, IOSign(i), EntR);
#if dbgMSurge
      if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk)
        {
        dbgp("dM :IO   > Sgn:%2i EntR:%10.4f CdQm:%10.4f %*s",IOSign(i),EntR,Cd->QMass(),151-39-24,"");
        if (dbgODEOperateSpc())
          for (int s=0; s<SVValueCount(); s++)
            dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pFd->m_M[s]*ICGetTimeInc());
        dbgpln(" %s", Nd_Rmt(i)->FullObjTag());
        dbgp("         < %*s",151-24,"");
        if (dbgODEOperateSpc())
          for (int s=0; s<SVValueCount(); s++)
            dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pPr->m_M[s]*ICGetTimeInc());
        dbgpln(" %s %s", IOQmEst_In(i)?"IN":"", IOQmEst_Out(i)?"Out":"");
        }
#endif
      }

    //dbgpln("EvalIntegral - AddInflow");
    //m_Accumulator->AddInFlowDeriv();

    //if (m_Accumulator->SpillExists())
    //  {
    //  //if (m_Accumulator->Spill.Cd.QMass()>0)
    //  //  dbgpln("EvalIntegral - AddDeriv Overflow: %14.3f %s", m_Accumulator->Spill.Cd.QMass(), FullObjTag());
    //  m_Accumulator->AddDeriv(m_Accumulator->Spill.Cd, -1.0);
    //  }
    //if (m_Accumulator->VentExists())
    //  {
    //  //if (m_Accumulator->Vent.Cd.QMass()>0)
    //  //  dbgpln("EvalIntegral - AddDeriv Vent    : %14.3f %s", m_Accumulator->Vent.Cd.QMass(), FullObjTag());
    //  m_Accumulator->AddDeriv(m_Accumulator->Vent.Cd, -1.0);
    //  }
#if dbgMSurge
    if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk)
      {
      dbgp("dM :Ovr  > %*s",151-24,"");
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pFd->m_M[s]*ICGetTimeInc());
      dbgpln(" %s.Contents", FullObjTag());
      dbgp("         < %*s",151-24,"");
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pPr->m_M[s]*ICGetTimeInc());
      dbgpln("");
      }
#endif

    m_Accumulator->pModel->m_DC.Finalise(m_Accumulator->pModel, ICGetTimeInc());
    //m_Accumulator->m_DC.Finalise(this, ICGetTimeInc());

#if dbgMSurge
    if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk)
      {
      dbgp("dM :Final> %*s",151-24,"");
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pFd->m_M[s]*ICGetTimeInc());
      dbgpln(" %s.Contents", FullObjTag());
      dbgp("         < %*s",151-24,"");
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pPr->m_M[s]*ICGetTimeInc());
      dbgpln("");
      dbgp("         = %*s",151-24,"");
      if (dbgODEOperateSpc())
        for (int s=0; s<SVValueCount(); s++)
          dbgp(" %12.5g", (m_Accumulator->pModel->m_DC.m_pFd->m_M[s]-m_Accumulator->pModel->m_DC.m_pPr->m_M[s])*ICGetTimeInc());
      dbgpln("");
      }
#endif

    if (!GetActiveHold())
      {
      m_Accumulator->ApplyDerivs(ICGetTimeInc(), true);

      //VLE.VFlash(Contents, 0.0, VLEF_Null);
      }

    //#if dbgMSurge
    //if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk)
    //  {
    //  dbgp("InI:End  : T:%+13.6f = %13.6f P:%+13.6f = %13.6f M:%+13.6f = %13.6f L:%+13.6f = %13.6f",
    //    m_CnStart.DTemp(Contents), m_Accumulator->Temp(),
    //    m_CnStart.DPress(Contents), m_Accumulator->Press(),
    //    m_CnStart.DMass(Contents), m_Accumulator->Mass(),
    //    m_CnStart.DLevel(Contents)*100, m_Accumulator->Level()*100);
    //  if (dbgODEOperateSpc())
    //    for (int s=0; s<SVValueCount(); s++)
    //      dbgp(" %12.5g", m_Accumulator->MArray()[s]);
    //  dbgpln(" %s.Contents", FullObjTag());
    //  }
    //#endif
    }
  SetIntegralDone(true);
  }
コード例 #20
0
ファイル: netcfg.c プロジェクト: Corbachu/KallistiOS
int netcfg_save_to(const char * fn, const netcfg_t * cfg) {
    FILE * f;
    char buf[64];

    assert(cfg);

    dbgp("Saving: %s\n", fn);

    // Open the output file
    if(fn[0] == '/' && fn[1] == 'v' && fn[2] == 'm' && fn[3] == 'u') {
        dbgp("Saving to VMU\n");
        f = fopen("/ram/netcfg.tmp", "wb");
    }
    else {
        f = fopen(fn, "wb");
    }

    if(!f)
        return -1;

    // Write out each line...
    sprintf(buf, "# KOS Network Config written by netcfg_save_to\n");

    if(fwrite(buf, strlen(buf), 1, f) != 1)
        goto error;

#define WRITESTR(fmt, data) \
    sprintf(buf, fmt, data); \
    if (fwrite(buf, strlen(buf), 1, f) != 1) \
        goto error;

    WRITESTR("driver=%s\n", cfg->driver);
    WRITESTR("ip=%08lx\n", cfg->ip);
    WRITESTR("gateway=%08lx\n", cfg->gateway);
    WRITESTR("netmask=%08lx\n", cfg->netmask);
    WRITESTR("broadcast=%08lx\n", cfg->broadcast);
    WRITESTR("dns1=%08lx\n", cfg->dns[0]);
    WRITESTR("dns2=%08lx\n", cfg->dns[1]);
    WRITESTR("hostname=%s\n", cfg->hostname);
    WRITESTR("email=%s\n", cfg->email);
    WRITESTR("smtp=%s\n", cfg->smtp);
    WRITESTR("pop3=%s\n", cfg->pop3);
    WRITESTR("pop3_login=%s\n", cfg->pop3_login);
    WRITESTR("pop3_passwd=%s\n", cfg->pop3_passwd);
    WRITESTR("proxy_host=%s\n", cfg->proxy_host);
    WRITESTR("proxy_port=%d\n", cfg->proxy_port);
    WRITESTR("ppp_login=%s\n", cfg->ppp_login);
    WRITESTR("ppp_passwd=%s\n", cfg->ppp_passwd);

    switch(cfg->method) {
        case 0:
            WRITESTR("method=%s\n", "dhcp");
            break;
        case 1:
            WRITESTR("method=%s\n", "static");
            break;
        case 4:
            WRITESTR("method=%s\n", "pppoe");
            break;
    }

#undef WRITESTR

    fclose(f);

    //If we're saving to a VMU, tack on the header and send it out
    if(fn[0] == '/' && fn[1] == 'v' && fn[2] == 'm' && fn[3] == 'u') {
        netcfg_vmuify("/ram/netcfg.tmp", fn);
        unlink("/ram/netcfg.tmp");
    }

    return 0;

error:
    fclose(f);
    return -1;
}