/* _redirect() redirect a pin's memory dynamic pin pointer. if address is not valid, then we continue processing, thus give the configurator a chance to correct it later. Note, the `mdp field is set to zero in IBLk_from_stream, and it can only be set to a non-zero value in here, so we can safely assume that the memory pointer is not bound if the `mdp' is zero. */ static __inline __bool _redirect( struct kernel_t * kernel, struct blk_pin_t *p, struct mem_addr_t * addr ) { f8_u8 * reg; struct blk_pin_t * peer; PTRIPLE_LIST_ENTRY lk; if(PIN_B_CONST == p->binding){ p->mdp = 0; return __true; } if(p->mdp){ /* already bound */ return __true; } if(p->_class == PIN_CLASS_DI){ /* an input pin reuses the peer's address the addr parameter is ignored */ if(!RtkIsTripleListEmpty(&p->u1.link)){ peer = IBlk_peer(p); assert(peer); /* the pin will have the value on the peer's memory register. */ if(!peer->mdp){ if(!_redirect(kernel, peer, &peer->u2.mem_addr)){ return __false; } } p->mdp = peer->mdp; p->u2.mem_addr = peer->u2.mem_addr; return __true; }else{ if(!is_address_valid(kernel, p, addr)){ return __false; } } }else{ if(!is_address_valid(kernel, p, addr)){ lk = p->u1.link.Flink; while(lk != &p->u1.link){ peer = RTK_CONTAINING_RECORD(lk, struct blk_pin_t, u1.link); peer->mdp = 0; peer->u2.mem_addr = *addr; lk = lk->Flink; } return __false; } }
int CLIClient::readline() { int rpos; if (!dev->available()) { return -1; } int readch = dev->read(); while (readch > 0) { switch (readch) { case '\r': // Ignore CR case '\n': // Return on NL rpos = pos; pos = 0; // Reset position index ready for next time if (willEcho) dev->println(); if (_redirect != NULL) { _redirect(this, input, rpos); return -1; } return rpos; case 8: case 127: if (pos > 0) { pos--; input[pos] = 0; if (willEcho) dev->print("\b \b"); } break; default: if (pos < CLI_BUFFER-2) { if (willEcho) dev->write(readch); input[pos++] = readch; input[pos] = 0; } } readch = dev->read(); } // No end of line has been found, so return -1. return -1; }