void _debug_assert_fail(const char *expr, const char *file, unsigned line, const char *function) { _debug_printf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr); if (debug_get_bool_option("GALLIUM_ABORT_ON_ASSERT", TRUE)) os_abort(); else _debug_printf("continuing...\n"); }
void _nine_debug_printf( unsigned long flag, const char *func, const char *fmt, ... ) { static boolean first = TRUE; static unsigned long dbg_flags = DBG_ERROR | DBG_WARN; unsigned long tid = 0; if (first) { first = FALSE; dbg_flags |= debug_get_flags_option("NINE_DEBUG", nine_debug_flags, 0); } #if defined(HAVE_PTHREAD) # if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \ (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12)) if (dbg_flags & DBG_TID) tid = pthread_self(); # endif #endif if (dbg_flags & flag) { const char *f = func ? strrchr(func, '_') : NULL; va_list ap; /* inside a class this will print nine:tid:classinlowercase:func: while * outside a class (rarely used) it will just print nine:tid:func * the reason for lower case is simply to match the filenames, as it * will also strip off the "Nine" */ if (f && strncmp(func, "Nine", 4) == 0) { char klass[96]; /* no class name is this long */ char *ptr = klass; for (func += 4; func != f; ++func) { *ptr++ = tolower(*func); } *ptr = '\0'; if (tid) _debug_printf("nine:0x%08lx:%s:%s: ", tid, klass, ++f); else _debug_printf("nine:%s:%s: ", klass, ++f); } else if (func) { if (tid) _debug_printf("nine:0x%08lx:%s ", tid, func); else _debug_printf("nine:%s ", func); } va_start(ap, fmt); _debug_vprintf(fmt, ap); va_end(ap); } }
void _debug_assert_fail(const char *expr, const char *file, unsigned line, const char *function) { _debug_printf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr); #if defined(PIPE_OS_WINDOWS) && !defined(PIPE_SUBSYSTEM_WINDOWS_USER) if (debug_get_bool_option("GALLIUM_ABORT_ON_ASSERT", FALSE)) #else if (debug_get_bool_option("GALLIUM_ABORT_ON_ASSERT", TRUE)) #endif os_abort(); else _debug_printf("continuing...\n"); }
const struct sh_opcode_info *svga_opcode_info( uint op ) { struct sh_opcode_info *info; if (op >= sizeof( opcode_info ) / sizeof( opcode_info[0] )) { /* The opcode is either PHASE, COMMENT, END or out of range. */ assert( 0 ); return NULL; } info = &opcode_info[op]; if (info->svga_opcode == SVGA3DOP_INVALID) { /* No valid information. Please provide number of dst/src registers. */ _debug_printf("Missing information for opcode %u, '%s'\n", op, opcode_info[op].mnemonic); assert( 0 ); return NULL; } /* Sanity check. */ assert( op == info->svga_opcode ); return info; }
static LLVMValueRef emit_tex(struct lp_build_tgsi_aos_context *bld, const struct tgsi_full_instruction *inst, enum lp_build_tex_modifier modifier) { unsigned target; unsigned unit; LLVMValueRef coords; struct lp_derivatives derivs = { {NULL}, {NULL} }; if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); return bld->bld_base.base.undef; } target = inst->Texture.Texture; coords = lp_build_emit_fetch( &bld->bld_base, inst, 0 , LP_CHAN_ALL); if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) { /* probably not going to work */ derivs.ddx[0] = lp_build_emit_fetch( &bld->bld_base, inst, 1 , LP_CHAN_ALL); derivs.ddy[0] = lp_build_emit_fetch( &bld->bld_base, inst, 2 , LP_CHAN_ALL); unit = inst->Src[3].Register.Index; } else { unit = inst->Src[1].Register.Index; } return bld->sampler->emit_fetch_texel(bld->sampler, &bld->bld_base.base, target, unit, coords, derivs, modifier); }
void radio_end_listen(void) { /* Stop the radio task */ radio_shutdown(0); _debug_printf("XCVR should shutdown%s", ""); }
static int nouveau_codegen(int chipset, int type, struct tgsi_token tokens[], unsigned *size, unsigned **code) { struct nv50_ir_prog_info info = {0}; int ret; info.type = type; info.target = chipset; info.bin.sourceRep = NV50_PROGRAM_IR_TGSI; info.bin.source = tokens; info.io.ucpCBSlot = 15; info.io.ucpBase = NV50_CB_AUX_UCP_OFFSET; info.io.resInfoCBSlot = 15; info.io.suInfoBase = NV50_CB_AUX_TEX_MS_OFFSET; info.io.msInfoCBSlot = 15; info.io.msInfoBase = NV50_CB_AUX_MS_OFFSET; info.assignSlots = dummy_assign_slots; info.optLevel = debug_get_num_option("NV50_PROG_OPTIMIZE", 3); info.dbgFlags = debug_get_num_option("NV50_PROG_DEBUG", 0); ret = nv50_ir_generate_code(&info); if (ret) { _debug_printf("Error compiling program: %d\n", ret); return ret; } *size = info.bin.codeSize; *code = info.bin.code; return 0; }
static LLVMValueRef emit_sample(struct lp_build_tgsi_aos_context *bld, const struct tgsi_full_instruction *inst, enum lp_build_tex_modifier modifier) { unsigned target; unsigned unit; LLVMValueRef coords; struct lp_derivatives derivs = { {NULL}, {NULL} }; if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); return bld->bld_base.base.undef; } coords = lp_build_emit_fetch( &bld->bld_base, inst, 0 , LP_CHAN_ALL); /* ignore modifiers, can't handle different sampler / sampler view, etc... */ unit = inst->Src[1].Register.Index; assert(inst->Src[2].Register.Index == unit); target = bld->sv[unit].Resource; return bld->sampler->emit_fetch_texel(bld->sampler, &bld->bld_base.base, target, unit, coords, derivs, modifier); }
void _debug_assert_fail(const char *expr, const char *file, unsigned line, const char *function) { _debug_printf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr); os_abort(); }
static void blitter_unset_running_flag(struct blitter_context_priv *ctx) { if (!ctx->base.running) { _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n", __LINE__); } ctx->base.running = FALSE; }
static void format_reg(const char *name, const struct sh_reg reg, const struct sh_srcreg *indreg) { if (reg.relative) { assert(indreg); if (sh_srcreg_type(*indreg) == SVGA3DREG_LOOP) { _debug_printf("%s[aL+%u]", name, reg.number); } else { _debug_printf("%s[a%u.x+%u]", name, indreg->number, reg.number); } } else { _debug_printf("%s%u", name, reg.number); } }
void _nine_stub( const char *file, const char *func, unsigned line ) { const char *r = strrchr(file, '/'); if (r == NULL) { r = strrchr(file, '\\'); } _debug_printf("nine:%s:%d: %s STUB!\n", r ? ++r : file, line, func); }
static void dump_indent(int indent) { int i; for (i = 0; i < indent; ++i) { _debug_printf(" "); } }
uint64_t debug_get_flags_option(const char *name, const struct debug_named_value *flags, uint64_t dfault) { uint64_t result; const char *str; const struct debug_named_value *orig = flags; unsigned namealign = 0; str = os_get_option(name); if (!str) result = dfault; else if (!util_strcmp(str, "help")) { result = dfault; _debug_printf("%s: help for %s:\n", __FUNCTION__, name); for (; flags->name; ++flags) namealign = MAX2(namealign, strlen(flags->name)); for (flags = orig; flags->name; ++flags) _debug_printf("| %*s [0x%0*"PRIx64"]%s%s\n", namealign, flags->name, (int)sizeof(uint64_t)*CHAR_BIT/4, flags->value, flags->desc ? " " : "", flags->desc ? flags->desc : ""); } else { result = 0; while (flags->name) { if (str_has_option(str, flags->name)) result |= flags->value; ++flags; } } if (debug_get_option_should_print()) { if (str) { debug_printf("%s: %s = 0x%"PRIx64" (%s)\n", __FUNCTION__, name, result, str); } else { debug_printf("%s: %s = 0x%"PRIx64"\n", __FUNCTION__, name, result); } } return result; }
static void dump_sampleinfo(struct sh_sampleinfo sampleinfo) { assert( sampleinfo.is_reg == 1 ); switch (sampleinfo.texture_type) { case SVGA3DSAMP_2D: _debug_printf( "_2d" ); break; case SVGA3DSAMP_CUBE: _debug_printf( "_cube" ); break; case SVGA3DSAMP_VOLUME: _debug_printf( "_volume" ); break; default: assert( 0 ); } }
static int nv30_codegen(int chipset, int type, struct tgsi_token tokens[], unsigned *size, unsigned **code) { switch (type) { case PIPE_SHADER_FRAGMENT: return nv30_fp(chipset, tokens, size, code); case PIPE_SHADER_VERTEX: return nv30_vp(chipset, tokens, size, code); } _debug_printf("Unexpected shader type: %d\n", type); return 1; }
void raw_debug_ostream::write_impl(const char *Ptr, size_t Size) { if (Size > 0) { char *lastPtr = (char *)&Ptr[Size]; char last = *lastPtr; *lastPtr = 0; _debug_printf("%*s", Size, Ptr); *lastPtr = last; pos += Size; } }
LLVMValueRef lp_build_intrinsic(LLVMBuilderRef builder, const char *name, LLVMTypeRef ret_type, LLVMValueRef *args, unsigned num_args, unsigned attr_mask) { LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); LLVMValueRef function, call; bool set_callsite_attrs = HAVE_LLVM >= 0x0400 && !(attr_mask & LP_FUNC_ATTR_LEGACY); function = LLVMGetNamedFunction(module, name); if(!function) { LLVMTypeRef arg_types[LP_MAX_FUNC_ARGS]; unsigned i; assert(num_args <= LP_MAX_FUNC_ARGS); for(i = 0; i < num_args; ++i) { assert(args[i]); arg_types[i] = LLVMTypeOf(args[i]); } function = lp_declare_intrinsic(module, name, ret_type, arg_types, num_args); /* * If llvm removes an intrinsic we use, we'll hit this abort (rather * than a call to address zero in the jited code). */ if (LLVMGetIntrinsicID(function) == 0) { _debug_printf("llvm (version 0x%x) found no intrinsic for %s, going to crash...\n", HAVE_LLVM, name); abort(); } if (!set_callsite_attrs) lp_add_func_attributes(function, attr_mask); if (gallivm_debug & GALLIVM_DEBUG_IR) { lp_debug_dump_value(function); } } call = LLVMBuildCall(builder, function, args, num_args, ""); if (set_callsite_attrs) lp_add_func_attributes(call, attr_mask); return call; }
static LLVMAttribute lp_attr_to_llvm_attr(enum lp_func_attr attr) { switch (attr) { case LP_FUNC_ATTR_ALWAYSINLINE: return LLVMAlwaysInlineAttribute; case LP_FUNC_ATTR_INREG: return LLVMInRegAttribute; case LP_FUNC_ATTR_NOALIAS: return LLVMNoAliasAttribute; case LP_FUNC_ATTR_NOUNWIND: return LLVMNoUnwindAttribute; case LP_FUNC_ATTR_READNONE: return LLVMReadNoneAttribute; case LP_FUNC_ATTR_READONLY: return LLVMReadOnlyAttribute; default: _debug_printf("Unhandled function attribute: %x\n", attr); return 0; } }
static void dump_inst(struct dump_info *di, const unsigned **assem, struct sh_op op, const struct sh_opcode_info *info) { struct dump_op dop; boolean not_first_arg = FALSE; uint i; assert(info->num_dst <= 1); di->indent -= info->pre_dedent; dump_indent(di->indent); di->indent += info->post_indent; dump_op(op, info->mnemonic); parse_op(di, assem, &dop, info->num_dst, info->num_src); if (info->num_dst > 0) { dump_dstreg(dop.dst, &dop.dstind, di); not_first_arg = TRUE; } for (i = 0; i < info->num_src; i++) { if (not_first_arg) { _debug_printf(", "); } else { _debug_printf(" "); } dump_srcreg(dop.src[i], &dop.srcind[i], di); not_first_arg = TRUE; } _debug_printf("\n"); }
static const char *attr_to_str(enum lp_func_attr attr) { switch (attr) { case LP_FUNC_ATTR_ALWAYSINLINE: return "alwaysinline"; case LP_FUNC_ATTR_INREG: return "inreg"; case LP_FUNC_ATTR_NOALIAS: return "noalias"; case LP_FUNC_ATTR_NOUNWIND: return "nounwind"; case LP_FUNC_ATTR_READNONE: return "readnone"; case LP_FUNC_ATTR_READONLY: return "readonly"; case LP_FUNC_ATTR_WRITEONLY: return "writeonly"; case LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY: return "inaccessiblememonly"; case LP_FUNC_ATTR_CONVERGENT: return "convergent"; default: _debug_printf("Unhandled function attribute: %x\n", attr); return 0; } }
static LLVMValueRef emit_tex(struct lp_build_tgsi_aos_context *bld, const struct tgsi_full_instruction *inst, enum lp_build_tex_modifier modifier) { unsigned target; unsigned unit; LLVMValueRef coords; LLVMValueRef ddx; LLVMValueRef ddy; if (!bld->sampler) { _debug_printf("warning: found texture instruction but no sampler generator supplied\n"); return bld->base.undef; } target = inst->Texture.Texture; coords = emit_fetch( bld, inst, 0 ); if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) { ddx = emit_fetch( bld, inst, 1 ); ddy = emit_fetch( bld, inst, 2 ); unit = inst->Src[3].Register.Index; } else { #if 0 ddx = lp_build_ddx( &bld->base, coords ); ddy = lp_build_ddy( &bld->base, coords ); #else /* TODO */ ddx = bld->base.one; ddy = bld->base.one; #endif unit = inst->Src[1].Register.Index; } return bld->sampler->emit_fetch_texel(bld->sampler, &bld->base, target, unit, coords, ddx, ddy, modifier); }
/** * Convert the TGSI assembly to a runnable shader. * * We need not care about geometry shaders. All we have is screen quads. */ void * pp_tgsi_to_state(struct pipe_context *pipe, const char *text, bool isvs, const char *name) { struct pipe_shader_state state; struct tgsi_token *tokens = NULL; void *ret_state = NULL; /* * Allocate temporary token storage. State creation will duplicate * tokens so we must free them on exit. */ tokens = tgsi_alloc_tokens(PP_MAX_TOKENS); if (!tokens) { pp_debug("Failed to allocate temporary token storage.\n"); return NULL; } if (tgsi_text_translate(text, tokens, PP_MAX_TOKENS) == FALSE) { _debug_printf("pp: Failed to translate a shader for %s\n", name); return NULL; } state.tokens = tokens; memset(&state.stream_output, 0, sizeof(state.stream_output)); if (isvs) { ret_state = pipe->create_vs_state(pipe, &state); FREE(tokens); } else { ret_state = pipe->create_fs_state(pipe, &state); FREE(tokens); } return ret_state; }
uint16_t radio_middle_listen(volatile radio_packet_t * data, uint16_t us_listen_duration) { if (!data || !us_listen_duration) { return 0; } /* Clear packet RX'd */ RadioPtr->EVENTS_END = 0U; /* clr END (packet received) flag */ /* Break listen time into LISTEN_QUANTA quanta */ uint32_t wait_time = us_listen_duration / LISTEN_QUANTA; /* Start Listening */ RadioPtr->TASKS_START = 1U; while (wait_time-- && (RadioPtr->EVENTS_END == 0U)) { nrf_delay_us(LISTEN_QUANTA); } /* If no packet was received the whole duration */ if (RadioPtr->EVENTS_END == 0U) { _debug_printf("No packet received.%s", ""); return 0; } /* * By here, we know we got a packet */ data->pipe = RadioPtr->RXMATCH; data->rssi = RadioPtr->RSSISAMPLE * -1; /* Return the amount of time left to listen */ return wait_time * LISTEN_QUANTA; }
/** * Allocate gallivm LLVM objects. * \return TRUE for success, FALSE for failure */ static boolean init_gallivm_state(struct gallivm_state *gallivm) { assert(!gallivm->context); assert(!gallivm->module); assert(!gallivm->provider); lp_build_init(); gallivm->context = LLVMContextCreate(); if (!gallivm->context) goto fail; gallivm->module = LLVMModuleCreateWithNameInContext("gallivm", gallivm->context); if (!gallivm->module) goto fail; gallivm->provider = LLVMCreateModuleProviderForExistingModule(gallivm->module); if (!gallivm->provider) goto fail; if (!GlobalEngine) { /* We can only create one LLVMExecutionEngine (w/ LLVM 2.6 anyway) */ enum LLVM_CodeGenOpt_Level optlevel; char *error = NULL; if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) { optlevel = None; } else { optlevel = Default; } if (LLVMCreateJITCompiler(&GlobalEngine, gallivm->provider, (unsigned) optlevel, &error)) { _debug_printf("%s\n", error); LLVMDisposeMessage(error); goto fail; } #if defined(DEBUG) || defined(PROFILE) lp_register_oprofile_jit_event_listener(GlobalEngine); #endif } gallivm->engine = GlobalEngine; LLVMAddModuleProvider(gallivm->engine, gallivm->provider);//new gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine); if (!gallivm->target) goto fail; if (!create_pass_manager(gallivm)) goto fail; gallivm->builder = LLVMCreateBuilderInContext(gallivm->context); if (!gallivm->builder) goto fail; return TRUE; fail: free_gallivm_state(gallivm); return FALSE; }
void lp_build_tgsi_aos(struct gallivm_state *gallivm, const struct tgsi_token *tokens, struct lp_type type, const unsigned char swizzles[4], LLVMValueRef consts_ptr, const LLVMValueRef *inputs, LLVMValueRef *outputs, struct lp_build_sampler_aos *sampler, const struct tgsi_shader_info *info) { struct lp_build_tgsi_aos_context bld; struct tgsi_parse_context parse; uint num_immediates = 0; unsigned chan; int pc = 0; /* Setup build context */ memset(&bld, 0, sizeof bld); lp_build_context_init(&bld.bld_base.base, gallivm, type); lp_build_context_init(&bld.bld_base.uint_bld, gallivm, lp_uint_type(type)); lp_build_context_init(&bld.bld_base.int_bld, gallivm, lp_int_type(type)); lp_build_context_init(&bld.int_bld, gallivm, lp_int_type(type)); for (chan = 0; chan < 4; ++chan) { bld.swizzles[chan] = swizzles[chan]; bld.inv_swizzles[swizzles[chan]] = chan; } bld.inputs = inputs; bld.outputs = outputs; bld.consts_ptr = consts_ptr; bld.sampler = sampler; bld.indirect_files = info->indirect_files; bld.bld_base.emit_swizzle = swizzle_aos; bld.bld_base.info = info; bld.bld_base.emit_fetch_funcs[TGSI_FILE_CONSTANT] = emit_fetch_constant; bld.bld_base.emit_fetch_funcs[TGSI_FILE_IMMEDIATE] = emit_fetch_immediate; bld.bld_base.emit_fetch_funcs[TGSI_FILE_INPUT] = emit_fetch_input; bld.bld_base.emit_fetch_funcs[TGSI_FILE_TEMPORARY] = emit_fetch_temporary; /* Set opcode actions */ lp_set_default_actions_cpu(&bld.bld_base); if (!lp_bld_tgsi_list_init(&bld.bld_base)) { return; } tgsi_parse_init(&parse, tokens); while (!tgsi_parse_end_of_tokens(&parse)) { tgsi_parse_token(&parse); switch(parse.FullToken.Token.Type) { case TGSI_TOKEN_TYPE_DECLARATION: /* Inputs already interpolated */ lp_emit_declaration_aos(&bld, &parse.FullToken.FullDeclaration); break; case TGSI_TOKEN_TYPE_INSTRUCTION: /* save expanded instruction */ lp_bld_tgsi_add_instruction(&bld.bld_base, &parse.FullToken.FullInstruction); break; case TGSI_TOKEN_TYPE_IMMEDIATE: /* simply copy the immediate values into the next immediates[] slot */ { const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1; float imm[4]; assert(size <= 4); assert(num_immediates < LP_MAX_TGSI_IMMEDIATES); for (chan = 0; chan < 4; ++chan) { imm[chan] = 0.0f; } for (chan = 0; chan < size; ++chan) { unsigned swizzle = bld.swizzles[chan]; imm[swizzle] = parse.FullToken.FullImmediate.u[chan].Float; } bld.immediates[num_immediates] = lp_build_const_aos(gallivm, type, imm[0], imm[1], imm[2], imm[3], NULL); num_immediates++; } break; case TGSI_TOKEN_TYPE_PROPERTY: break; default: assert(0); } } while (pc != -1) { struct tgsi_full_instruction *instr = bld.bld_base.instructions + pc; const struct tgsi_opcode_info *opcode_info = tgsi_get_opcode_info(instr->Instruction.Opcode); if (!lp_emit_instruction_aos(&bld, instr, opcode_info, &pc)) _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n", opcode_info->mnemonic); } if (0) { LLVMBasicBlockRef block = LLVMGetInsertBlock(gallivm->builder); LLVMValueRef function = LLVMGetBasicBlockParent(block); debug_printf("11111111111111111111111111111 \n"); tgsi_dump(tokens, 0); lp_debug_dump_value(function); debug_printf("2222222222222222222222222222 \n"); } tgsi_parse_free(&parse); FREE(bld.bld_base.instructions); if (0) { LLVMModuleRef module = LLVMGetGlobalParent( LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder))); LLVMDumpModule(module); } }
void radio_start_listen(volatile radio_packet_t * data, uint8_t is_manufacturing_mode) { if (!data) { _debug_printf("NULL data pointer%s", ""); return; } /* Set up the radio */ radio_init(); /* Set the pipe to some value that could never happen */ data->pipe = RADIO_PIPE_NONE; /* Turn off the RADIO Task */ radio_shutdown(0); /* Set the packet source pointer */ RadioPtr->PACKETPTR = (uint32_t)data->payload; /* Set up the RADIO parameters */ RadioPtr->PCNF1 = /* Disable data whitening agent */ (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | /* Set endianness to BIG */ (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | /* Set 'base' address length */ ((ADDRESS_LENGTH - 1) << RADIO_PCNF1_BALEN_Pos) | /* Set expected packet length */ (data->payloadLength << RADIO_PCNF1_STATLEN_Pos) | /* Set the maximum length to the actual max packet size */ (MAX_PACKET_SIZE << RADIO_PCNF1_MAXLEN_Pos); /* Set the listen addresses */ if (is_manufacturing_mode) { RadioPtr->PREFIX0 = radio_convert_byte('S') << 24 | /* 4. Manufacture secrets */ radio_convert_byte('M') << 16; /* 3. Manufacture uuid? */ RadioPtr->RXADDRESSES = 0x0C; } else { RadioPtr->PREFIX0 = radio_convert_byte('R') << 8 | radio_convert_byte('K'); RadioPtr->RXADDRESSES = 0x03; } /* Set address bases */ RadioPtr->BASE0 = radio_convert_bytes("KIWI"); /* Beacon pipe */ RadioPtr->BASE1 = radio_convert_bytes("RNKI"); /* Random pipe */ /* Clear the event ready task flag */ RadioPtr->EVENTS_READY = 0U; /* Tell the radio that the task is now receiving */ RadioPtr->TASKS_RXEN = 1U; /* Wait for radio to ramp up */ wait_for_val_ne(&RadioPtr->EVENTS_READY); _debug_printf("XCVR Turned on in RX mode%s", ""); }
/* * Transmit a packet * * to the specified address * * the specified number of times * * and wait a certain amount of microseconds between each packet. */ void radio_send_packet(volatile radio_packet_t * data, char * address, uint8_t count, uint8_t us_wait_after) { if (!count || !data || !address) { return; } /* Turn off the RADIO Task */ RadioPtr->TASKS_DISABLE = 1U; /* Block until the radio is off */ wait_for_val_ne(&RadioPtr->EVENTS_DISABLED); /* Set the packet source pointer */ RadioPtr->PACKETPTR = (uint32_t)data->payload; /* Set up the RADIO parameters */ RadioPtr->PCNF1 = /* Disable data whitening agent */ (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | /* Set endianness to BIG */ (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | /* Set 'base' address length */ ((ADDRESS_LENGTH - 1) << RADIO_PCNF1_BALEN_Pos) | /* Set packet length */ ((data->payloadLength) << RADIO_PCNF1_STATLEN_Pos) | /* Set the maximum length to zero (ignore) */ (MAX_PACKET_SIZE << RADIO_PCNF1_MAXLEN_Pos); /* Clear the SHORTS register */ RadioPtr->SHORTS = 0b00000000; /* Calculate the proper addresses */ RadioPtr->PREFIX0 = (uint32_t)radio_convert_byte(address[0]); RadioPtr->BASE0 = radio_convert_bytes(address); _debug_printf("Sending packet to address %s 0x%02x%08x", address, RadioPtr->PREFIX0, RadioPtr->BASE0); /* Tell the RADIO to use the above address */ RadioPtr->TXADDRESS = 0; /* Clear event ready */ RadioPtr->EVENTS_READY = 0U; /* Enable the TX Task */ RadioPtr->TASKS_TXEN = 1U; /* Block until Radio is powered up */ wait_for_val_ne(&RadioPtr->EVENTS_READY); while (count--) { /* Clear event flag */ RadioPtr->EVENTS_END = 0U; /* Start the task */ RadioPtr->TASKS_START = 1U; /* Reset the hold-down timer */ uint8_t hold_down_timer = 255; /* Block until sent */ while (!RadioPtr->EVENTS_END && hold_down_timer--); /* Wait the packet spacing */ nrf_delay_us(us_wait_after); } /* Stop Radio Task */ radio_shutdown(0); }
/** * Similar to sp_get_cached_tile() but for textures. * Tiles are read-only and indexed with more params. */ const struct softpipe_tex_cached_tile * sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, union tex_tile_address addr ) { struct softpipe_tex_cached_tile *tile; tile = tc->entries + tex_cache_pos( addr ); if (addr.value != tile->addr.value) { /* cache miss. Most misses are because we've invaldiated the * texture cache previously -- most commonly on binding a new * texture. Currently we effectively flush the cache on texture * bind. */ #if 0 _debug_printf("miss at %u: x=%d y=%d z=%d face=%d level=%d\n" " tile %u: x=%d y=%d z=%d face=%d level=%d\n", pos, x/TILE_SIZE, y/TILE_SIZE, z, face, level, pos, tile->addr.bits.x, tile->addr.bits.y, tile->z, tile->face, tile->level); #endif /* check if we need to get a new transfer */ if (!tc->tex_trans || tc->tex_face != addr.bits.face || tc->tex_level != addr.bits.level || tc->tex_z != addr.bits.z) { /* get new transfer (view into texture) */ if (tc->tex_trans) { if (tc->tex_trans_map) { tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans); tc->tex_trans_map = NULL; } tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans); tc->tex_trans = NULL; } tc->tex_trans = pipe_get_transfer(tc->pipe, tc->texture, addr.bits.level, addr.bits.face + addr.bits.z, PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED, 0, 0, u_minify(tc->texture->width0, addr.bits.level), u_minify(tc->texture->height0, addr.bits.level)); tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans); tc->tex_face = addr.bits.face; tc->tex_level = addr.bits.level; tc->tex_z = addr.bits.z; } /* get tile from the transfer (view into texture) */ pipe_get_tile_swizzle(tc->pipe, tc->tex_trans, addr.bits.x * TILE_SIZE, addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->swizzle_r, tc->swizzle_g, tc->swizzle_b, tc->swizzle_a, tc->format, (float *) tile->data.color); tile->addr = addr; } tc->last_tile = tile; return tile; }
static boolean init_gallivm_engine(struct gallivm_state *gallivm) { if (1) { /* We can only create one LLVMExecutionEngine (w/ LLVM 2.6 anyway) */ enum LLVM_CodeGenOpt_Level optlevel; char *error = NULL; int ret; if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) { optlevel = None; } else { optlevel = Default; } #if USE_MCJIT ret = lp_build_create_mcjit_compiler_for_module(&gallivm->engine, gallivm->module, (unsigned) optlevel, &error); #else ret = LLVMCreateJITCompiler(&gallivm->engine, gallivm->provider, (unsigned) optlevel, &error); #endif if (ret) { _debug_printf("%s\n", error); LLVMDisposeMessage(error); goto fail; } #if defined(DEBUG) || defined(PROFILE) lp_register_oprofile_jit_event_listener(gallivm->engine); #endif } LLVMAddModuleProvider(gallivm->engine, gallivm->provider);//new #if !USE_MCJIT gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine); if (!gallivm->target) goto fail; #else if (0) { /* * Dump the data layout strings. */ LLVMTargetDataRef target = LLVMGetExecutionEngineTargetData(gallivm->engine); char *data_layout; char *engine_data_layout; data_layout = LLVMCopyStringRepOfTargetData(gallivm->target); engine_data_layout = LLVMCopyStringRepOfTargetData(target); if (1) { debug_printf("module target data = %s\n", data_layout); debug_printf("engine target data = %s\n", engine_data_layout); } free(data_layout); free(engine_data_layout); } #endif return TRUE; fail: return FALSE; }