void adc_inst(ARMProc *proc, UWord instruction) { #ifdef DEBUG printf("Ejecutaste un adc\n"); #endif //Instrucciones de DP ARMAddr *modes = addr_modes_dp(); ARMAddr *mode; Word S; Word Rn; Word Rd; Word carry; Word last_rd; ARMAddrDPReturn result; if(!cond(proc, instruction)) return; S = get_bits(instruction,20,1); Rn = get_bits(instruction,16,4); Rd = get_bits(instruction,12,4); //---Parte indispensable para obtener el result mode = fetch_addr(modes, instruction); if(mode != NULL) mode->execute(proc, instruction, &result); //--- last_rd = *proc->r[Rd]; *proc->r[Rd] = AddCarryFrom(*proc->r[Rn],result.shifter_operand + get_bits(*proc->cpsr,29,1),&carry); if(S && Rd == 15) { if(proc->cpsr != NULL) { *proc->cpsr = *proc->spsr; } } else if(S == 1) { set_status(proc, status_n, get_bits(*proc->r[Rd], 31, 1)); set_status(proc, status_z, *proc->r[Rd] == 0); set_status(proc, status_c, carry); set_status(proc, status_v, OverflowFrom(last_rd,*proc->r[Rd])); } }
/* * Curl_fetch_addr() fetches a 'Curl_dns_entry' already in the DNS cache. * * Curl_resolv() checks initially and multi_runsingle() checks each time * it discovers the handle in the state WAITRESOLVE whether the hostname * has already been resolved and the address has already been stored in * the DNS cache. This short circuits waiting for a lot of pending * lookups for the same hostname requested by different handles. * * Returns the Curl_dns_entry entry pointer or NULL if not in the cache. * * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after * use, or we'll leak memory! */ struct Curl_dns_entry * Curl_fetch_addr(struct connectdata *conn, const char *hostname, int port) { struct SessionHandle *data = conn->data; struct Curl_dns_entry *dns = NULL; if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); dns = fetch_addr(conn, hostname, port); if(dns) dns->inuse++; /* we use it! */ if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); return dns; }
void ldrex_inst(ARMProc *proc, UWord instruction) { #ifdef DEBUG printf("Ejecutaste un ldrex\n"); #endif //Instrucciones de LS ARMAddr *modes = addr_modes_ls(); ARMAddr *mode; ARMAddrLSReturn result; Word Rd, Rn; if( !cond(proc, instruction) ) return; mode = fetch_addr(modes, instruction); Rd = get_bits(instruction, 12, 4); Rn = get_bits(instruction, 16, 4); if(mode != NULL) mode->execute(proc, instruction, &result); *proc->r[Rd] = proc->readWord(proc, *proc->r[Rn]); exit(1); }
void rsc_inst(ARMProc *proc, UWord instruction) { #ifdef DEBUG printf("Ejecutaste un rsc\n"); #endif //Instrucciones de DP ARMAddr *modes = addr_modes_dp(); ARMAddr *mode; ARMAddrDPReturn result; Word S; Word Rn; Word Rd; Word borrow; Word last_rd; Word Cflag = get_bits(*proc->cpsr,29,1); mode = fetch_addr(modes, instruction); if(mode != NULL) mode->execute(proc, instruction, &result); if(!cond(proc,instruction)) return; Rn = get_bits(instruction,16,4); Rd = get_bits(instruction,12,4); last_rd = *proc->r[Rd]; *proc->r[Rd] = SubWithBorrow(result.shifter_operand,*proc->r[Rn]+!Cflag,&borrow); if(S && Rd==15){ if(proc->cpsr != NULL){ *proc->cpsr = *proc->spsr; } } else if(S == 1){ set_status(proc,status_n,get_bits(*proc->r[Rd],31,1)); set_status(proc,status_z,*proc->r[Rd] == 0); set_status(proc,status_c,borrow == 0); set_status(proc,status_v,OverflowFrom(last_rd,*proc->r[Rd])); } }
void ldm1_inst(ARMProc *proc, UWord instruction) { #ifdef DEBUG printf("Ejecutaste un ldm(1)\n"); #endif //Instrucciones de LSM ARMAddr *modes = addr_modes_lsm(); ARMAddr *mode; ARMAddrLSMReturn result; Word address, register_list, value; int i; if( !cond(proc, instruction) ) return; mode = fetch_addr(modes, instruction); register_list = get_bits(instruction, 0, 16); if(mode != NULL) mode->execute(proc, instruction, &result); address = result.start_address; for( i = 0; i < 15; i++) if( get_bits(register_list, i, 1) ){ *proc->r[i] = proc->readWord(proc, address); address += 4; } if( get_bits(register_list, 15, 1) ){ value = proc->readWord(proc, address); *proc->r[15] = value & 0xFFFFFFFE; set_bits( proc->cpsr, 5, 1, get_bits(value, 0, 1) ); address += 4; } if( result.end_address != address - 4 ) exit(1); }
int Curl_resolv(struct connectdata *conn, const char *hostname, int port, struct Curl_dns_entry **entry) { struct Curl_dns_entry *dns = NULL; struct SessionHandle *data = conn->data; CURLcode result; int rc = CURLRESOLV_ERROR; /* default to failure */ *entry = NULL; if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); dns = fetch_addr(conn, hostname, port); if(dns) { infof(data, "Hostname %s was found in DNS cache\n", hostname); dns->inuse++; /* we use it! */ rc = CURLRESOLV_RESOLVED; } if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); if(!dns) { /* The entry was not in the cache. Resolve it to IP address */ Curl_addrinfo *addr; int respwait; /* Check what IP specifics the app has requested and if we can provide it. * If not, bail out. */ if(!Curl_ipvalid(conn)) return CURLRESOLV_ERROR; /* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a non-zero value indicating that we need to wait for the response to the resolve call */ addr = Curl_getaddrinfo(conn, #ifdef DEBUGBUILD (data->set.str[STRING_DEVICE] && !strcmp(data->set.str[STRING_DEVICE], "LocalHost"))?"localhost": #endif hostname, port, &respwait); if(!addr) { if(respwait) { /* the response to our resolve call will come asynchronously at a later time, good or bad */ /* First, check that we haven't received the info by now */ result = Curl_resolver_is_resolved(conn, &dns); if(result) /* error detected */ return CURLRESOLV_ERROR; if(dns) rc = CURLRESOLV_RESOLVED; /* pointer provided */ else rc = CURLRESOLV_PENDING; /* no info yet */ } } else { if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); /* we got a response, store it in the cache */ dns = Curl_cache_addr(data, addr, hostname, port); if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); if(!dns) /* returned failure, bail out nicely */ Curl_freeaddrinfo(addr); else rc = CURLRESOLV_RESOLVED; } } *entry = dns; return rc; }