Example #1
0
entity_ptr entity::build(variant node)
{
	if(node["is_human"].as_bool()) {
		return entity_ptr(new playable_custom_object(node));
	} else {
		return entity_ptr(new custom_object(node));
	}
}
Example #2
0
DDS_ReturnCode_t DDS_DataWriter_get_matched_subscription_data (
				DDS_DataWriter                   wp,
				DDS_SubscriptionBuiltinTopicData *data,
				DDS_InstanceHandle_t             handle)
{
	Entity_t		*ep;
	DDS_ReturnCode_t	ret;

	ctrc_begind (DCPS_ID, DCPS_DW_G_SUBS_D, &wp, sizeof (wp));
	ctrc_contd (&data, sizeof (data));
	ctrc_contd (&handle, sizeof (handle));
	ctrc_endd ();

	if (!data || !handle)
		return (DDS_RETCODE_BAD_PARAMETER);

	if (!writer_ptr (wp, 1, &ret))
		return (ret);

	ep = entity_ptr (handle);
	if (!ep ||
	     ep->type != ET_READER ||
	     entity_ignored (ep->flags)) {
		ret = DDS_RETCODE_BAD_PARAMETER;
		goto done;
	}
	if (entity_discovered (ep->flags))
		ret = dcps_get_builtin_subscription_data (data, (DiscoveredReader_t *) ep);
	else
		ret = dcps_get_local_subscription_data (data, (Reader_t *) ep);

    done:
	lock_release (wp->w_lock);
	return (ret);
}
Example #3
0
DDS_ReturnCode_t DDS_DomainParticipant_ignore_publication (DDS_DomainParticipant dp,
						           DDS_InstanceHandle_t handle)
{
	Entity_t		*ep;
	DDS_ReturnCode_t	ret;

	ctrc_begind (DCPS_ID, DCPS_DP_IGN_PUB, &dp, sizeof (dp));
	ctrc_contd (&handle, sizeof (handle));
	ctrc_endd ();

	if (!domain_ptr (dp, 1, &ret))
		return (ret);

	if ((dp->participant.p_flags & EF_ENABLED) == 0) {
		lock_release (dp->lock);
		return (DDS_RETCODE_NOT_ENABLED);
	}
	ep = entity_ptr (handle);
	if (!ep ||
	    ep->type != ET_WRITER ||
	    !entity_discovered (ep->flags)) {
		ret = DDS_RETCODE_ALREADY_DELETED;
		goto done;
	}
	ret = disc_ignore_writer ((DiscoveredWriter_t *) ep);

    done:
	lock_release (dp->lock);
	return (ret);
}
Example #4
0
void gun::add_new_bullets(const int count) {
    for (int i = 0; i < count; ++i) {
        auto bullet = m_bullets.insert(m_bullets.end(), entity_ptr(new entity("bullet")));
        (*bullet)->set_position(m_start_x, m_start_y);
        (*bullet)->set_move_to(m_aim_x, m_aim_y);
        m_parent->addChild((*bullet)->get_sprite());
    }
}
Example #5
0
int DDS_DomainParticipant_contains_entity (DDS_DomainParticipant dp,
					   DDS_InstanceHandle_t handle)
{
	Entity_t	*ep;
	int		contained = 0;

	ctrc_begind (DCPS_ID, DCPS_DP_CONT, &dp, sizeof (dp));
	ctrc_contd (&handle, sizeof (handle));
	ctrc_endd ();

	if (!domain_ptr (dp, 1, NULL))
		return (0);

	ep = entity_ptr (handle);
	if (!ep)
		goto done;

	if ((ep->flags & EF_LOCAL) == 0)
		goto done;

	switch (ep->type) {
		case ET_TOPIC:
			contained = (((Topic_t *) ep)->domain == dp);
			break;

		case ET_PUBLISHER:
			contained = (((Publisher_t *) ep)->domain == dp);
			break;

		case ET_SUBSCRIBER:
			contained = (((Subscriber_t *) ep)->domain == dp);
			break;

		case ET_WRITER:
			contained = (((Writer_t *) ep)->w_publisher->domain == dp);
			break;

		case ET_READER:
			contained = (((Reader_t *) ep)->r_subscriber->domain == dp);
			break;

		case ET_PARTICIPANT:
		default:
			break;
	}

done:
	lock_release (dp->lock);
	return (contained);
}
Example #6
0
void sec_crypto_dump (unsigned handle)
{
	Entity_t	*p = entity_ptr (handle);
	Participant_t	*pp;
	LocalEndpoint_t	*ep;
	CryptoData_t	*dp;
	unsigned	ch;

	if (!p) {
		dbg_printf ("Entity not found!\r\n");
		return;
	}
	switch (entity_type (p)) {
		case ET_PARTICIPANT:
			pp = (Participant_t *) p;
			ch = pp->p_crypto;
			break;
		case ET_WRITER:
		case ET_READER:
			if ((p->flags & EF_LOCAL) != 0) {
				ep = (LocalEndpoint_t *) p;
				ch = ep->crypto;
			}
			else if (entity_type (p) == ET_WRITER)
				ch = rtps_peer_writer_crypto_get (NULL, 
							(DiscoveredWriter_t *) p);
			else
				ch = rtps_peer_reader_crypto_get (NULL, 
							(DiscoveredReader_t *) p);
			break;
		default:
			dbg_printf ("Invalid entity type!\r\n");
			return;
	}
	if (!ch) {
		dbg_printf ("No associated crypto context.\r\n");
		return;
	}
	dp = crypto_lookup (ch);
	if (!dp) {
		dbg_printf ("Crypto context deleted.\r\n");
		return;
	}
	dp->plugin->dump (dp->plugin, dp, p);
}
Example #7
0
DDS_ReturnCode_t DDS_DomainParticipant_get_discovered_topic_data (
					DDS_DomainParticipant     dp,
					DDS_TopicBuiltinTopicData *data,
					DDS_InstanceHandle_t      handle)
{
	Entity_t		*ep;
	DDS_ReturnCode_t	ret;

	ctrc_begind (DCPS_ID, DCPS_DP_G_DISC_T, &dp, sizeof (dp));
	ctrc_contd (&data, sizeof (data));
	ctrc_contd (&handle, sizeof (handle));
	ctrc_endd ();

	if (!data || !handle)
		return (DDS_RETCODE_BAD_PARAMETER);

	if (!domain_ptr (dp, 1, &ret))
		return (ret);

	if ((dp->participant.p_flags & EF_ENABLED) == 0) {
		lock_release (dp->lock);
		return (DDS_RETCODE_NOT_ENABLED);
	}
	ep = entity_ptr (handle);
	if (!ep ||
	     ep->type != ET_TOPIC ||
	     !entity_discovered (ep->flags) ||
	     entity_ignored (ep->flags)) {
		ret = DDS_RETCODE_BAD_PARAMETER;
		goto done;
	}
	if (dcps_get_builtin_topic_data (data, (Topic_t *) ep, 0)) {
		ret = DDS_RETCODE_OUT_OF_RESOURCES;
		goto done;
	}

    done:
	lock_release (dp->lock);
	return (ret);
}
Example #8
0
static void *read_builtin_topic_data (Change_t *cp)
{
	Entity_t			*ep;
	DDS_TopicBuiltinTopicData	*dp;

	ep = entity_ptr (cp->c_writer);
	if (!ep)
		return (NULL);
	if (ep->type != ET_TOPIC ||
	    (ep->flags & EF_REMOTE) == 0)
		return (NULL);

	dp = xmalloc (sizeof (DDS_TopicBuiltinTopicData));
	if (!dp)
		return (NULL);

	if (dcps_get_builtin_topic_data (dp, (Topic_t *) ep, 1)) {
		xfree (dp);
		return (NULL);
	}
	return (dp);
}
Example #9
0
static void *read_builtin_participant_data (Change_t *cp)
{
	Entity_t			*ep;
	DDS_ParticipantBuiltinTopicData	*dp;

	ep = entity_ptr (cp->c_writer);
	if (!ep)
		return (NULL);
	if (ep->type != ET_PARTICIPANT ||
	    (ep->flags & EF_REMOTE) == 0)
		return (NULL);

	dp = xmalloc (sizeof (DDS_ParticipantBuiltinTopicData));
	if (!dp)
		return (NULL);

	if (dcps_get_builtin_participant_data (dp, (Participant_t *) ep)) {
		xfree (dp);
		return (NULL);
	}
	return (dp);
}
Example #10
0
static void *read_builtin_subscription_data (Change_t *cp)
{
	Entity_t			 *ep;
	DDS_SubscriptionBuiltinTopicData *dp;

	ep = entity_ptr (cp->c_writer);
	if (!ep)
		return (NULL);
	if (ep->type != ET_READER ||
	    (ep->flags & EF_REMOTE) == 0)
		return (NULL);

	dp = xmalloc (sizeof (DDS_SubscriptionBuiltinTopicData));
	if (!dp)
		return (NULL);

	if (dcps_get_builtin_subscription_data (dp, (DiscoveredReader_t *) ep)) {
		xfree (dp);
		return (NULL);
	}
	return (dp);
}
Example #11
0
/*------------------------------------------------------------------*/
static byte isdn_rc(ADAPTER *a,
		    byte Rc,
		    byte Id,
		    byte Ch,
		    word Ref,
		    dword extended_info_type,
		    dword extended_info)
{
	ENTITY *this;
	byte e_no;
	word i;
	int cancel_rc;
#ifdef USE_EXTENDED_DEBUGS
	{
		DBG_TRC(("<A%d Id=0x%x Rc=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, Id, Rc))
			}
#else
	dbug(dprintf("isdn_rc(Rc=%x,Id=%x,Ch=%x)", Rc, Id, Ch));
#endif
	/* check for ready interrupt                                */
	if (Rc == READY_INT) {
		xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 0, 0);
		if (a->ReadyInt) {
			a->ReadyInt--;
			return 0;
		}
		return 2;
	}
	/* if we know this Id ...                                   */
	e_no = a->IdTable[Id];
	if (e_no) {
		this = entity_ptr(a, e_no);
		xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 0, a->IdTypeTable[this->No]);
		this->RcCh = Ch;
		/* if it is a return code to a REMOVE request, remove the   */
		/* Id from our table                                        */
		if ((a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_REMOVE_PENDING) &&
		    (Rc == OK)) {
			if (a->IdTypeTable[e_no] == NL_ID) {
				if (a->RcExtensionSupported &&
				    (extended_info_type != DIVA_RC_TYPE_REMOVE_COMPLETE)) {
					dtrc(dprintf("XDI: N-REMOVE, A(%02x) Id:%02x, ignore RC=OK",
						     XDI_A_NR(a), Id));
					return (0);
				}
				if (extended_info_type == DIVA_RC_TYPE_REMOVE_COMPLETE)
					a->RcExtensionSupported = true;
			}
			a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_REMOVE_PENDING;
			a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_NO_RC_CANCELLING;
			free_entity(a, e_no);
			for (i = 0; i < 256; i++)
			{
				if (a->FlowControlIdTable[i] == Id)
					a->FlowControlIdTable[i] = 0;
			}
			a->IdTable[Id] = 0;
			this->Id = 0;
			/* ---------------------------------------------------------------
			   If we send N_DISC or N_DISK_ACK after we have received OK_FC
			   then the card will respond with OK_FC and later with RC==OK.
			   If we send N_REMOVE in this state we will receive only RC==OK
			   This will create the state in that the XDI is waiting for the
			   additional RC and does not delivery the RC to the client. This
			   code corrects the counter of outstanding RC's in this case.
			   --------------------------------------------------------------- */
			if ((this->More & XMOREC) > 1) {
				this->More &= ~XMOREC;
				this->More |= 1;
				dtrc(dprintf("XDI: correct MORE on REMOVE A(%02x) Id:%02x",
					     XDI_A_NR(a), Id));
			}
		}
		if (Rc == OK_FC) {
			a->FlowControlIdTable[Ch] = Id;
			a->FlowControlSkipTable[Ch] = false;
			this->Rc = Rc;
			this->More &= ~(XBUSY | XMOREC);
			this->complete = 0xff;
			xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);
			CALLBACK(a, this);
			return 0;
		}
		/*
		  New protocol code sends return codes that comes from release
		  of flow control condition marked with DIVA_RC_TYPE_OK_FC extended
		  information element type.
		  If like return code arrives then application is able to process
		  all return codes self and XDI should not cances return codes.
		  This return code does not decrement XMOREC partial return code
		  counter due to fact that it was no request for this return code,
		  also XMOREC was not incremented.
		*/
		if (extended_info_type == DIVA_RC_TYPE_OK_FC) {
			a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_NO_RC_CANCELLING;
			this->Rc = Rc;
			this->complete = 0xff;
			xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);
			DBG_TRC(("XDI OK_FC A(%02x) Id:%02x Ch:%02x Rc:%02x",
				 XDI_A_NR(a), Id, Ch, Rc))
				CALLBACK(a, this);
			return 0;
		}
		cancel_rc = !(a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_NO_RC_CANCELLING);
		if (cancel_rc && (a->FlowControlIdTable[Ch] == Id))
		{
			a->FlowControlIdTable[Ch] = 0;
			if ((Rc != OK) || !a->FlowControlSkipTable[Ch])
			{
				this->Rc = Rc;
				if (Ch == this->ReqCh)
				{
					this->More &= ~(XBUSY | XMOREC);
					this->complete = 0xff;
				}
				xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);
				CALLBACK(a, this);
			}
			return 0;
		}
		if (this->More & XMOREC)
			this->More--;
		/* call the application callback function                   */
		if (((!cancel_rc) || (this->More & XMOREF)) && !(this->More & XMOREC)) {
			this->Rc = Rc;
			this->More &= ~XBUSY;
			this->complete = 0xff;
			xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]);
			CALLBACK(a, this);
		}
		return 0;
	}
	/* if it's an ASSIGN return code check if it's a return     */
	/* code to an ASSIGN request from us                        */
	if ((Rc & 0xf0) == ASSIGN_RC) {
		e_no = get_assign(a, Ref);
		if (e_no) {
			this = entity_ptr(a, e_no);
			this->Id = Id;
			xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 2, a->IdTypeTable[this->No]);
			/* call the application callback function                   */
			this->Rc = Rc;
			this->More &= ~XBUSY;
			this->complete = 0xff;
#if defined(DIVA_ISTREAM) /* { */
			if ((Rc == ASSIGN_OK) && a->ram_offset &&
			    (a->IdTypeTable[this->No] == NL_ID) &&
			    ((extended_info_type == DIVA_RC_TYPE_RX_DMA) ||
			     (extended_info_type == DIVA_RC_TYPE_CMA_PTR)) &&
			    extended_info) {
				dword offset = (*(a->ram_offset)) (a);
				dword tmp[2];
				extended_info -= offset;
#ifdef PLATFORM_GT_32BIT
				a->ram_in_dw(a, (void *)ULongToPtr(extended_info), (dword *)&tmp[0], 2);
#else
				a->ram_in_dw(a, (void *)extended_info, (dword *)&tmp[0], 2);
#endif
				a->tx_stream[Id]  = tmp[0];
				a->rx_stream[Id]  = tmp[1];
				if (extended_info_type == DIVA_RC_TYPE_RX_DMA) {
					DBG_TRC(("Id=0x%x RxDMA=%08x:%08x",
						 Id, a->tx_stream[Id], a->rx_stream[Id]))
						a->misc_flags_table[this->No] |= DIVA_MISC_FLAGS_RX_DMA;
				} else {
					DBG_TRC(("Id=0x%x CMA=%08x:%08x",
						 Id, a->tx_stream[Id], a->rx_stream[Id]))
						a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA;
					a->rx_pos[Id]     = 0;
					a->rx_stream[Id] -= offset;
				}
				a->tx_pos[Id]     = 0;
				a->tx_stream[Id] -= offset;
			} else {
				a->tx_stream[Id] = 0;
				a->rx_stream[Id] = 0;
				a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA;
			}
#endif /* } */
			CALLBACK(a, this);
			if (Rc == ASSIGN_OK) {
				a->IdTable[Id] = e_no;
			}
			else
			{
				free_entity(a, e_no);
				for (i = 0; i < 256; i++)
				{
					if (a->FlowControlIdTable[i] == Id)
						a->FlowControlIdTable[i] = 0;
				}
				a->IdTable[Id] = 0;
				this->Id = 0;
			}
			return 1;
		}
	}
	return 2;
}
Example #12
0
	virtual entity_ptr save_condition() const { return entity_ptr(); }
Example #13
0
	virtual entity_ptr driver() { return entity_ptr(); }
Example #14
0
	virtual entity_ptr clone() const { return entity_ptr(); }
entity_ptr playable_custom_object::clone() const
{
	return entity_ptr(new playable_custom_object(*this));
}
	entity_ptr get_entity() const { return entity_.empty() ? entity_ptr() : entity_.front(); }
Example #17
0
void DivasOut(ADAPTER * a)
{
  byte e_no;
  ENTITY  * this = NULL;
  BUFFERS  *X;
  word length;
  word i;
  word clength;
  REQ * ReqOut;
  byte more;
  byte ReadyCount;
  byte ReqCount;
  byte Id;

        /* while a request is pending ...                           */
  e_no = look_req(a);
  if(!e_no)
  {
    return;
  }

  ReadyCount = pr_ready(a);
  if(!ReadyCount)
  {
    DPRINTF(("IDI: card not ready for next request"));
    return;
  }

  ReqCount = 0;
  while(e_no && ReadyCount) {

    next_req(a);

    this = entity_ptr(a, e_no);

#ifdef	USE_EXTENDED_DEBUGS
	if ( !this )
	{
		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
		DBG_FTL(("!A%d ==> NULL entity ptr - try to ignore", (int)io->ANum))
		e_no = look_req(a) ;
		ReadyCount-- ;
		continue ;
	}
	{
		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
		DPRINTF(("IDI: >A%d Id=0x%x Req=0x%x", io->ANum, this->Id, this->Req))
	}
#else
    DPRINTF(("IDI: >REQ=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh));
#endif

        /* get address of next available request buffer             */
    ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)];

        /* now copy the data from the current data buffer into the  */
        /* adapters request buffer                                  */
    length = 0;
    i = this->XCurrent;
    X = PTR_X(a,this);
    while(i<this->XNum && length<270) {
      clength = (word)(270-length);
      if (clength > X[i].PLength-this->XOffset)
	      clength = X[i].PLength-this->XOffset;
      a->ram_out_buffer(a,
                        &ReqOut->XBuffer.P[length],
                        PTR_P(a,this,&X[i].P[this->XOffset]),
                        clength);

      length +=clength;
      this->XOffset +=clength;
      if(this->XOffset==X[i].PLength) {
        this->XCurrent = (byte)++i;
        this->XOffset = 0;
      }
    }

    a->ram_outw(a, &ReqOut->XBuffer.length, length);
    a->ram_out(a, &ReqOut->ReqId, this->Id);
    a->ram_out(a, &ReqOut->ReqCh, this->ReqCh);

        /* if its a specific request (no ASSIGN) ...                */

    if(this->Id &0x1f) {

        /* if buffers are left in the list of data buffers do       */
        /* do chaining (LL_MDATA, N_MDATA)                          */

      this->More++;
      if(i<this->XNum && this->MInd) {
        a->ram_out(a, &ReqOut->Req, this->MInd);
        more = TRUE;
      }
      else {
        this->More |=XMOREF;
        a->ram_out(a, &ReqOut->Req, this->Req);
        more = FALSE;
      }

        /* if we did chaining, this entity is put back into the     */
        /* request queue                                            */

      if(more) {
        req_queue(a,this->No);
      }
    }

        /* else it's a ASSIGN                                       */

    else {

        /* save the request code used for buffer chaining           */

      this->MInd = 0;
      if (this->Id==BLLC_ID) this->MInd = LL_MDATA;
      if (this->Id==NL_ID   ||
          this->Id==TASK_ID ||
          this->Id==MAN_ID
        ) this->MInd = N_MDATA;

        /* send the ASSIGN                                          */

      this->More |=XMOREF;
      a->ram_out(a, &ReqOut->Req, this->Req);

        /* save the reference of the ASSIGN                         */

      assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference));
    }
    a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next));
    ReadyCount--;
    ReqCount++;

    e_no = look_req(a);
  }

        /* send the filled request buffers to the ISDN adapter      */

  a->ram_out(a, &PR_RAM->ReqInput,
             (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount));

        /* if it is a 'unreturncoded' UREMOVE request, remove the  */
        /* Id from our table after sending the request             */
  if(this->Req==UREMOVE && this->Id) {
    Id = this->Id;
    e_no = a->IdTable[Id];
    free_entity(a, e_no);
    a->IdTable[Id] = 0;
    this->Id = 0;
  }

}
Example #18
0
static
byte isdn_rc(ADAPTER * a,
             byte Rc,
             byte Id,
             byte Ch,
             word Ref)
{
  ENTITY  * this;
  byte e_no;

#ifdef	USE_EXTENDED_DEBUGS
	{
		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
		DPRINTF(("IDI: <A%d Id=0x%x Rc=0x%x", io->ANum, Id, Rc))
	}
#else
  DPRINTF(("IDI: <RC(Rc=%x,Id=%x,Ch=%x)",Rc,Id,Ch));
#endif

        /* check for ready interrupt                                */
  if(Rc==READY_INT) {
    if(a->ReadyInt) {
      a->ReadyInt--;
      return 0;
    }
    return 2;
  }

        /* if we know this Id ...                                   */
  e_no = a->IdTable[Id];
  if(e_no) {

    this = entity_ptr(a,e_no);

    this->RcCh = Ch;

        /* if it is a return code to a REMOVE request, remove the   */
        /* Id from our table                                        */
    if(this->Req==REMOVE && Rc==OK) {
      free_entity(a, e_no);
      a->IdTable[Id] = 0;
      this->Id = 0;
/**************************************************************/
      if ((this->More & XMOREC) > 1) {
        this->More &= ~XMOREC;
	this->More |= 1;
	DPRINTF(("isdn_rc, Id=%x, correct More on REMOVE", Id));
      }
    }

    if (Rc==OK_FC) {
      this->Rc = Rc;
      this->More = (this->More & (~XBUSY | XMOREC)) | 1;
      this->complete = 0xFF;
      CALLBACK(a, this);
      return 0;
    }
    if(this->More &XMOREC)
      this->More--;

        /* call the application callback function                   */
    if(this->More &XMOREF && !(this->More &XMOREC)) {
      this->Rc = Rc;
      this->More &=~XBUSY;
      this->complete=0xff;
      CALLBACK(a, this);
    }
    return 0;
  }

        /* if it's an ASSIGN return code check if it's a return     */
        /* code to an ASSIGN request from us                        */
  if((Rc &0xf0)==ASSIGN_RC) {

    e_no = get_assign(a, Ref);

    if(e_no) {

      this = entity_ptr(a,e_no);

      this->Id = Id;

        /* call the application callback function                   */
      this->Rc = Rc;
      this->More &=~XBUSY;
      this->complete=0xff;
      CALLBACK(a, this);

      if(Rc==ASSIGN_OK) {
        a->IdTable[Id] = e_no;
      }
      else
      {
        free_entity(a, e_no);
        a->IdTable[Id] = 0;
        this->Id = 0;
      }
      return 1;
    }
  }
  return 2;
}
Example #19
0
/*------------------------------------------------------------------*/
static byte isdn_ind(ADAPTER *a,
		     byte Ind,
		     byte Id,
		     byte Ch,
		     PBUFFER *RBuffer,
		     byte MInd,
		     word MLength)
{
	ENTITY *this;
	word clength;
	word offset;
	BUFFERS *R;
	byte *cma = NULL;
#ifdef USE_EXTENDED_DEBUGS
	{
		DBG_TRC(("<A%d Id=0x%x Ind=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, Id, Ind))
			}
#else
	dbug(dprintf("isdn_ind(Ind=%x,Id=%x,Ch=%x)", Ind, Id, Ch));
#endif
	if (a->IdTable[Id]) {
		this = entity_ptr(a, a->IdTable[Id]);
		this->IndCh = Ch;
		xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind,
			     0/* rnr_valid */, 0 /* rnr */, a->IdTypeTable[this->No]);
		/* if the Receive More flag is not yet set, this is the     */
		/* first buffer of the packet                               */
		if (this->RCurrent == 0xff) {
			/* check for receive buffer chaining                        */
			if (Ind == this->MInd) {
				this->complete = 0;
				this->Ind = MInd;
			}
			else {
				this->complete = 1;
				this->Ind = Ind;
			}
			/* call the application callback function for the receive   */
			/* look ahead                                               */
			this->RLength = MLength;
#if defined(DIVA_ISTREAM)
			if ((a->rx_stream[this->Id] ||
			     (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA)) &&
			    ((Ind == N_DATA) ||
			     (a->protocol_capabilities & PROTCAP_CMA_ALLPR))) {
				PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io;
				if (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA) {
#if defined(DIVA_IDI_RX_DMA)
					dword d;
					diva_get_dma_map_entry(\
						(struct _diva_dma_map_entry *)IoAdapter->dma_map,
						(int)a->rx_stream[this->Id], (void **)&cma, &d);
#else
					cma = &a->stream_buffer[0];
					cma[0] = cma[1] = cma[2] = cma[3] = 0;
#endif
					this->RLength = MLength = (word)*(dword *)cma;
					cma += 4;
				} else {
					int final = 0;
					cma = &a->stream_buffer[0];
					this->RLength = MLength = (word)diva_istream_read(a,
											  Id,
											  cma,
											  sizeof(a->stream_buffer),
											  &final, NULL, NULL);
				}
				IoAdapter->RBuffer.length = min(MLength, (word)270);
				if (IoAdapter->RBuffer.length != MLength) {
					this->complete = 0;
				} else {
					this->complete = 1;
				}
				memcpy(IoAdapter->RBuffer.P, cma, IoAdapter->RBuffer.length);
				this->RBuffer = (DBUFFER *)&IoAdapter->RBuffer;
			}
#endif
			if (!cma) {
				a->ram_look_ahead(a, RBuffer, this);
			}
			this->RNum = 0;
			CALLBACK(a, this);
			/* map entity ptr, selector could be re-mapped by call to   */
			/* IDI from within callback                                 */
			this = entity_ptr(a, a->IdTable[Id]);
			xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind,
				     1/* rnr_valid */, this->RNR/* rnr */, a->IdTypeTable[this->No]);
			/* check for RNR                                            */
			if (this->RNR == 1) {
				this->RNR = 0;
				return 1;
			}
			/* if no buffers are provided by the application, the       */
			/* application want to copy the data itself including       */
			/* N_MDATA/LL_MDATA chaining                                */
			if (!this->RNR && !this->RNum) {
				xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind,
					     2/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]);
				return 0;
			}
			/* if there is no RNR, set the More flag                    */
			this->RCurrent = 0;
			this->ROffset = 0;
		}
Example #20
0
static
byte isdn_ind(ADAPTER * a,
              byte Ind,
              byte Id,
              byte Ch,
              PBUFFER * RBuffer,
              byte MInd,
              word MLength)
{
  ENTITY  * this;
  word clength;
  word offset;
  BUFFERS  *R;

#ifdef	USE_EXTENDED_DEBUGS
	{
		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
		DPRINTF(("IDI: <A%d Id=0x%x Ind=0x%x", io->ANum, Id, Ind))
	}
#else
  DPRINTF(("IDI: <IND(Ind=%x,Id=%x,Ch=%x)",Ind,Id,Ch));
#endif

  if(a->IdTable[Id]) {

    this = entity_ptr(a,a->IdTable[Id]);

    this->IndCh = Ch;

        /* if the Receive More flag is not yet set, this is the     */
        /* first buffer of the packet                               */
    if(this->RCurrent==0xff) {

        /* check for receive buffer chaining                        */
      if(Ind==this->MInd) {
        this->complete = 0;
        this->Ind = MInd;
      }
      else {
        this->complete = 1;
        this->Ind = Ind;
      }

        /* call the application callback function for the receive   */
        /* look ahead                                               */
      this->RLength = MLength;

      a->ram_look_ahead(a, RBuffer, this);

      this->RNum = 0;
      CALLBACK(a, this);

        /* map entity ptr, selector could be re-mapped by call to   */
        /* IDI from within callback                                 */
      this = entity_ptr(a,a->IdTable[Id]);

        /* check for RNR                                            */
      if(this->RNR==1) {
        this->RNR = 0;
        return 1;
      }

        /* if no buffers are provided by the application, the       */
        /* application want to copy the data itself including       */
        /* N_MDATA/LL_MDATA chaining                                */
      if(!this->RNR && !this->RNum) {
        return 0;
      }

        /* if there is no RNR, set the More flag                    */
      this->RCurrent = 0;
      this->ROffset = 0;
    }

    if(this->RNR==2) {
      if(Ind!=this->MInd) {
        this->RCurrent = 0xff;
        this->RNR = 0;
      }
      return 0;
    }
        /* if we have received buffers from the application, copy   */
        /* the data into these buffers                              */
    offset = 0;
    R = PTR_R(a,this);
    do {
      if(this->ROffset==R[this->RCurrent].PLength) {
        this->ROffset = 0;
        this->RCurrent++;
      }
      clength = a->ram_inw(a, &RBuffer->length)-offset;
      if (clength > R[this->RCurrent].PLength-this->ROffset)
	      clength = R[this->RCurrent].PLength-this->ROffset;
      if(R[this->RCurrent].P) {
        a->ram_in_buffer(a,
                         &RBuffer->P[offset],
                         PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]),
                         clength);
      }
      offset +=clength;
      this->ROffset +=clength;
    } while(offset<(a->ram_inw(a, &RBuffer->length)));

        /* if it's the last buffer of the packet, call the          */
        /* application callback function for the receive complete   */
        /* call                                                     */
    if(Ind!=this->MInd) {
      R[this->RCurrent].PLength = this->ROffset;
      if(this->ROffset) this->RCurrent++;
      this->RNum = this->RCurrent;
      this->RCurrent = 0xff;
      this->Ind = Ind;
      this->complete = 2;
      CALLBACK(a, this);
    }
    return 0;
  }
  return 2;
}
Example #21
0
/*------------------------------------------------------------------*/
void pr_out(ADAPTER *a)
{
	byte e_no;
	ENTITY *this = NULL;
	BUFFERS *X;
	word length;
	word i;
	word clength;
	REQ *ReqOut;
	byte more;
	byte ReadyCount;
	byte ReqCount;
	byte Id;
	dtrc(dprintf("pr_out"));
	/* while a request is pending ...                           */
	e_no = look_req(a);
	if (!e_no)
	{
		dtrc(dprintf("no_req"));
		return;
	}
	ReadyCount = pr_ready(a);
	if (!ReadyCount)
	{
		dtrc(dprintf("not_ready"));
		return;
	}
	ReqCount = 0;
	while (e_no && ReadyCount) {
		next_req(a);
		this = entity_ptr(a, e_no);
#ifdef USE_EXTENDED_DEBUGS
		if (!this)
		{
			DBG_FTL(("XDI: [%02x] !A%d ==> NULL entity ptr - try to ignore",
				 xdi_xlog_sec++, (int)((ISDN_ADAPTER *)a->io)->ANum))
				e_no = look_req(a);
			ReadyCount--;
			continue;
		}
		{
			DBG_TRC((">A%d Id=0x%x Req=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, this->Id, this->Req))
				}
#else
		dbug(dprintf("out:Req=%x,Id=%x,Ch=%x", this->Req, this->Id, this->ReqCh));
#endif
		/* get address of next available request buffer             */
		ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)];
#if defined(DIVA_ISTREAM)
		if (!(a->tx_stream[this->Id]   &&
		      this->Req == N_DATA)) {
#endif
			/* now copy the data from the current data buffer into the  */
			/* adapters request buffer                                  */
			length = 0;
			i = this->XCurrent;
			X = PTR_X(a, this);
			while (i < this->XNum && length < 270) {
				clength = min((word)(270 - length), (word)(X[i].PLength-this->XOffset));
				a->ram_out_buffer(a,
						  &ReqOut->XBuffer.P[length],
						  PTR_P(a, this, &X[i].P[this->XOffset]),
						  clength);
				length += clength;
				this->XOffset += clength;
				if (this->XOffset == X[i].PLength) {
					this->XCurrent = (byte)++i;
					this->XOffset = 0;
				}
			}
#if defined(DIVA_ISTREAM)
		} else { /* Use CMA extension in order to transfer data to the card */
			i = this->XCurrent;
			X = PTR_X(a, this);
			while (i < this->XNum) {
				diva_istream_write(a,
						   this->Id,
						   PTR_P(a, this, &X[i].P[0]),
						   X[i].PLength,
						   ((i + 1) == this->XNum),
						   0, 0);
				this->XCurrent = (byte)++i;
			}
			length = 0;
		}
#endif
		a->ram_outw(a, &ReqOut->XBuffer.length, length);
		a->ram_out(a, &ReqOut->ReqId, this->Id);
		a->ram_out(a, &ReqOut->ReqCh, this->ReqCh);
		/* if it's a specific request (no ASSIGN) ...                */
		if (this->Id & 0x1f) {
			/* if buffers are left in the list of data buffers do       */
			/* do chaining (LL_MDATA, N_MDATA)                          */
			this->More++;
			if (i < this->XNum && this->MInd) {
				xdi_xlog_request(XDI_A_NR(a), this->Id, this->ReqCh, this->MInd,
						 a->IdTypeTable[this->No]);
				a->ram_out(a, &ReqOut->Req, this->MInd);
				more = true;
			}
			else {
				xdi_xlog_request(XDI_A_NR(a), this->Id, this->ReqCh, this->Req,
						 a->IdTypeTable[this->No]);
				this->More |= XMOREF;
				a->ram_out(a, &ReqOut->Req, this->Req);
				more = false;
				if (a->FlowControlIdTable[this->ReqCh] == this->Id)
					a->FlowControlSkipTable[this->ReqCh] = true;
				/*
				  Note that remove request was sent to the card
				*/
				if (this->Req == REMOVE) {
					a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_REMOVE_PENDING;
				}
			}
			/* if we did chaining, this entity is put back into the     */
			/* request queue                                            */
			if (more) {
				req_queue(a, this->No);
			}
		}
		/* else it's a ASSIGN                                       */
		else {
			/* save the request code used for buffer chaining           */
			this->MInd = 0;
			if (this->Id == BLLC_ID) this->MInd = LL_MDATA;
			if (this->Id == NL_ID ||
			    this->Id == TASK_ID ||
			    this->Id == MAN_ID
				) this->MInd = N_MDATA;
			/* send the ASSIGN                                          */
			a->IdTypeTable[this->No] = this->Id;
			xdi_xlog_request(XDI_A_NR(a), this->Id, this->ReqCh, this->Req, this->Id);
			this->More |= XMOREF;
			a->ram_out(a, &ReqOut->Req, this->Req);
			/* save the reference of the ASSIGN                         */
			assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference));
		}
		a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next));
		ReadyCount--;
		ReqCount++;
		e_no = look_req(a);
	}
	/* send the filled request buffers to the ISDN adapter      */
	a->ram_out(a, &PR_RAM->ReqInput,
		   (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount));
	/* if it is a 'unreturncoded' UREMOVE request, remove the  */
	/* Id from our table after sending the request             */
	if (this && (this->Req == UREMOVE) && this->Id) {
		Id = this->Id;
		e_no = a->IdTable[Id];
		free_entity(a, e_no);
		for (i = 0; i < 256; i++)
		{
			if (a->FlowControlIdTable[i] == Id)
				a->FlowControlIdTable[i] = 0;
		}
		a->IdTable[Id] = 0;
		this->Id = 0;
	}
}
Example #22
0
DDS_ReturnCode_t DDS_DataWriter_get_reply_subscriptions(
				DDS_DataWriter        wp,
				DDS_InstanceHandle_t  publication_handle,
				DDS_InstanceHandleSeq *handles)
{
	Endpoint_t	*rwp;
	Participant_t	*pp;
	Entity_t	*p;
	Topic_t		*tp;
	Endpoint_t	*ep;
	FilteredTopic_t	*ftp;
	DDS_ReturnCode_t ret;

	ctrc_begind (DCPS_ID, DCPS_DW_G_REPLY_S, &wp, sizeof (wp));
	ctrc_contd (&handles, sizeof (handles));
	ctrc_endd ();

	p = entity_ptr (publication_handle);
	if (!p || p->type != ET_WRITER || !handles)
		return (DDS_RETCODE_BAD_PARAMETER);

	rwp = (Endpoint_t *) p;
	if ((rwp->entity.flags & EF_LOCAL) != 0)
		pp = &rwp->u.publisher->domain->participant;
	else
		pp = rwp->u.participant;

	DDS_SEQ_INIT (*handles);
	if (!writer_ptr (wp, 0, &ret))
		return (ret);

	tp = wp->w_topic;
	if (lock_take (tp->lock))
		return (DDS_RETCODE_ALREADY_DELETED);

#ifndef RW_TOPIC_LOCK
	if (lock_take (wp->w_lock)) {
		lock_release (tp->lock);
		return (DDS_RETCODE_ALREADY_DELETED);
	}
#endif
	for (ep = tp->writers; ep && ep != &wp->w_ep; ep = ep->next)
		;
	if (!ep) {
		ret = DDS_RETCODE_ALREADY_DELETED;
		goto done;
	}
	for (ep = tp->readers; ep; ep = ep->next)
		if (check_matched_subscription (wp, ep, handles, pp)) {
			ret = DDS_RETCODE_OUT_OF_RESOURCES;
			goto done;
		}

	for (ftp = tp->filters; ftp; ftp = ftp->next)
		for (ep = ftp->topic.readers; ep; ep = ep->next)
			if (check_matched_subscription (wp, ep, handles, pp)) {
				ret = DDS_RETCODE_OUT_OF_RESOURCES;
				goto done;
			}

    done:
#ifndef RW_TOPIC_LOCK
	lock_release (wp->w_lock);
#endif
	lock_release (tp->lock);
	return (ret);
}