target
int64 0
1
| idx
int64 0
27.3k
| func
stringlengths 23
97k
|
---|---|---|
1 | 619 | static void do_dcbz(CPUPPCState *env, target_ulong addr, int dcache_line_size, uintptr_t raddr) { int i; addr &= ~(dcache_line_size - 1); for (i = 0; i < dcache_line_size; i += 4) { cpu_stl_data_ra(env, addr + i, 0, raddr); } if (env->reserve_addr == addr) { env->reserve_addr = (target_ulong)-1ULL; } } |
1 | 620 | static int32_t ide_nop_int32(IDEDMA *dma, int x) { return 0; } |
1 | 621 | static int read_password(char *buf, int buf_size) { int c, i; printf("Password: "); fflush(stdout); i = 0; for(;;) { c = getchar(); if (c == '\n') break; if (i < (buf_size - 1)) buf[i++] = c; } buf[i] = '\0'; return 0; } |
1 | 622 | long do_rt_sigreturn(CPUARMState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr = env->xregs[31]; if (frame_addr & 15) { goto badframe; } if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } if (target_restore_sigframe(env, frame)) { goto badframe; } if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); return env->xregs[0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; } |
1 | 623 | tcp_sockclosed(struct tcpcb *tp) { DEBUG_CALL("tcp_sockclosed"); DEBUG_ARG("tp = %p", tp); switch (tp->t_state) { case TCPS_CLOSED: case TCPS_LISTEN: case TCPS_SYN_SENT: tp->t_state = TCPS_CLOSED; tp = tcp_close(tp); break; case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: tp->t_state = TCPS_FIN_WAIT_1; break; case TCPS_CLOSE_WAIT: tp->t_state = TCPS_LAST_ACK; break; } if (tp) tcp_output(tp); } |
1 | 624 | static void icp_pit_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { icp_pit_state *s = (icp_pit_state *)opaque; int n; n = offset >> 8; if (n > 3) { hw_error("sp804_write: Bad timer %d\n", n); } arm_timer_write(s->timer[n], offset & 0xff, value); } |
1 | 625 | static int exynos4210_combiner_init(SysBusDevice *sbd) { DeviceState *dev = DEVICE(sbd); Exynos4210CombinerState *s = EXYNOS4210_COMBINER(dev); unsigned int i; /* Allocate general purpose input signals and connect a handler to each of * them */ qdev_init_gpio_in(dev, exynos4210_combiner_handler, IIC_NIRQ); /* Connect SysBusDev irqs to device specific irqs */ for (i = 0; i < IIC_NIRQ; i++) { sysbus_init_irq(sbd, &s->output_irq[i]); } memory_region_init_io(&s->iomem, OBJECT(s), &exynos4210_combiner_ops, s, "exynos4210-combiner", IIC_REGION_SIZE); sysbus_init_mmio(sbd, &s->iomem); return 0; } |
0 | 626 | static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder, uint32_t *sums, int n, int pred_order) { int i; int k, cnt, part; uint32_t all_bits; part = (1 << porder); all_bits = 0; cnt = (n >> porder) - pred_order; for(i=0; i<part; i++) { if(i == 1) cnt = (n >> porder); k = find_optimal_param(sums[i], cnt); rc->params[i] = k; all_bits += rice_encode_count(sums[i], cnt, k); } all_bits += (4 * part); rc->porder = porder; return all_bits; } |
0 | 627 | static void raw_decode(uint8_t *dst, const int8_t *src, int src_size) { while (src_size--) *dst++ = *src++ + 128; } |
0 | 628 | static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { int h, w; uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V; int ret; if (src_size < avctx->width * avctx->height * 9LL / 8) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV410P; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; Y1 = pic->data[0]; Y2 = pic->data[0] + pic->linesize[0]; Y3 = pic->data[0] + pic->linesize[0] * 2; Y4 = pic->data[0] + pic->linesize[0] * 3; U = pic->data[1]; V = pic->data[2]; for (h = 0; h < avctx->height; h += 4) { for (w = 0; w < avctx->width; w += 4) { AV_COPY32U(Y1 + w, src); AV_COPY32U(Y2 + w, src + 4); AV_COPY32U(Y3 + w, src + 8); AV_COPY32U(Y4 + w, src + 12); U[w >> 2] = src[16] + 0x80; V[w >> 2] = src[17] + 0x80; src += 18; } Y1 += pic->linesize[0] << 2; Y2 += pic->linesize[0] << 2; Y3 += pic->linesize[0] << 2; Y4 += pic->linesize[0] << 2; U += pic->linesize[1]; V += pic->linesize[2]; } return 0; } |
1 | 629 | static int ff_filter_frame_framed(AVFilterLink *link, AVFilterBufferRef *frame) { int (*filter_frame)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *src = link->srcpad; AVFilterPad *dst = link->dstpad; AVFilterBufferRef *out; int perms, ret; AVFilterCommand *cmd= link->dst->command_queue; int64_t pts; if (link->closed) { avfilter_unref_buffer(frame); return AVERROR_EOF; } if (!(filter_frame = dst->filter_frame)) filter_frame = default_filter_frame; av_assert1((frame->perms & src->min_perms) == src->min_perms); frame->perms &= ~ src->rej_perms; perms = frame->perms; if (frame->linesize[0] < 0) perms |= AV_PERM_NEG_LINESIZES; /* prepare to copy the frame if the buffer has insufficient permissions */ if ((dst->min_perms & perms) != dst->min_perms || dst->rej_perms & perms) { av_log(link->dst, AV_LOG_DEBUG, "Copying data in avfilter (have perms %x, need %x, reject %x)\n", perms, link->dstpad->min_perms, link->dstpad->rej_perms); /* Maybe use ff_copy_buffer_ref instead? */ switch (link->type) { case AVMEDIA_TYPE_VIDEO: out = ff_get_video_buffer(link, dst->min_perms, link->w, link->h); break; case AVMEDIA_TYPE_AUDIO: out = ff_get_audio_buffer(link, dst->min_perms, frame->audio->nb_samples); break; default: return AVERROR(EINVAL); } if (!out) { avfilter_unref_buffer(frame); return AVERROR(ENOMEM); } avfilter_copy_buffer_ref_props(out, frame); switch (link->type) { case AVMEDIA_TYPE_VIDEO: av_image_copy(out->data, out->linesize, frame->data, frame->linesize, frame->format, frame->video->w, frame->video->h); break; case AVMEDIA_TYPE_AUDIO: av_samples_copy(out->extended_data, frame->extended_data, 0, 0, frame->audio->nb_samples, av_get_channel_layout_nb_channels(frame->audio->channel_layout), frame->format); break; default: return AVERROR(EINVAL); } avfilter_unref_buffer(frame); } else out = frame; while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){ av_log(link->dst, AV_LOG_DEBUG, "Processing command time:%f command:%s arg:%s\n", cmd->time, cmd->command, cmd->arg); avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags); ff_command_queue_pop(link->dst); cmd= link->dst->command_queue; } pts = out->pts; ret = filter_frame(link, out); ff_update_link_current_pts(link, pts); return ret; } |
1 | 630 | void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size) { if (!bs->backing_hd) { pstrcpy(filename, filename_size, ""); } else { pstrcpy(filename, filename_size, bs->backing_file); } } |
1 | 631 | static uint32_t e1000e_macreg_read(e1000e_device *d, uint32_t reg) { return qpci_io_readl(d->pci_dev, d->mac_regs + reg); } |
1 | 632 | static inline void direct_ref_list_init(H264Context * const h){ MpegEncContext * const s = &h->s; Picture * const ref1 = &h->ref_list[1][0]; Picture * const cur = s->current_picture_ptr; int list, i, j; if(cur->pict_type == I_TYPE) cur->ref_count[0] = 0; if(cur->pict_type != B_TYPE) cur->ref_count[1] = 0; for(list=0; list<2; list++){ cur->ref_count[list] = h->ref_count[list]; for(j=0; j<h->ref_count[list]; j++) cur->ref_poc[list][j] = h->ref_list[list][j].poc; } if(cur->pict_type != B_TYPE || h->direct_spatial_mv_pred) return; for(list=0; list<2; list++){ for(i=0; i<ref1->ref_count[list]; i++){ const int poc = ref1->ref_poc[list][i]; h->map_col_to_list0[list][i] = PART_NOT_AVAILABLE; for(j=0; j<h->ref_count[list]; j++) if(h->ref_list[list][j].poc == poc){ h->map_col_to_list0[list][i] = j; break; } } } } |
1 | 633 | static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) { DPXContext *s = avctx->priv_data; const uint8_t *src = pic->data[0]; int x, y; for (y = 0; y < avctx->height; y++) { for (x = 0; x < avctx->width; x++) { int value; if (s->big_endian) { value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4) | ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6) | ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16); } else { value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4) | ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6) | ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16); } write32(dst, value); dst += 4; } src += pic->linesize[0]; } } |
1 | 634 | static int tgv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TgvContext *s = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int chunk_type; if (buf_end - buf < EA_PREAMBLE_SIZE) return AVERROR_INVALIDDATA; chunk_type = AV_RL32(&buf[0]); buf += EA_PREAMBLE_SIZE; if (chunk_type==kVGT_TAG) { int pal_count, i; if(buf_end - buf < 12) { av_log(avctx, AV_LOG_WARNING, "truncated header\n"); return -1; } s->width = AV_RL16(&buf[0]); s->height = AV_RL16(&buf[2]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) { avcodec_set_dimensions(s->avctx, s->width, s->height); cond_release_buffer(&s->frame); cond_release_buffer(&s->last_frame); } pal_count = AV_RL16(&buf[6]); buf += 12; for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) { s->palette[i] = 0xFF << 24 | AV_RB24(buf); buf += 3; } } if (av_image_check_size(s->width, s->height, 0, avctx)) return -1; /* shuffle */ FFSWAP(AVFrame, s->frame, s->last_frame); if (!s->frame.data[0]) { s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.linesize[0] = s->width; /* allocate additional 12 bytes to accommodate av_memcpy_backptr() OUTBUF_PADDED optimisation */ s->frame.data[0] = av_malloc(s->width*s->height + 12); if (!s->frame.data[0]) return AVERROR(ENOMEM); s->frame.data[1] = av_malloc(AVPALETTE_SIZE); if (!s->frame.data[1]) { av_freep(&s->frame.data[0]); return AVERROR(ENOMEM); } } memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); if(chunk_type==kVGT_TAG) { s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) { av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n"); return -1; } }else{ if (!s->last_frame.data[0]) { av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n"); return buf_size; } s->frame.key_frame = 0; s->frame.pict_type = AV_PICTURE_TYPE_P; if (tgv_decode_inter(s, buf, buf_end)<0) { av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n"); return -1; } } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; } |
1 | 635 | static void adjust_frame_information(ChannelElement *cpe, int chans) { int i, w, w2, g, ch; int start, maxsfb, cmaxsfb; for (ch = 0; ch < chans; ch++) { IndividualChannelStream *ics = &cpe->ch[ch].ics; start = 0; maxsfb = 0; cpe->ch[ch].pulse.num_pulse = 0; for (w = 0; w < ics->num_windows*16; w += 16) { for (g = 0; g < ics->num_swb; g++) { //apply M/S if (cpe->common_window && !ch && cpe->ms_mask[w + g]) { for (i = 0; i < ics->swb_sizes[g]; i++) { cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0; cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]; } } start += ics->swb_sizes[g]; } for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--) ; maxsfb = FFMAX(maxsfb, cmaxsfb); } ics->max_sfb = maxsfb; //adjust zero bands for window groups for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { for (g = 0; g < ics->max_sfb; g++) { i = 1; for (w2 = w; w2 < w + ics->group_len[w]; w2++) { if (!cpe->ch[ch].zeroes[w2*16 + g]) { i = 0; break; } } cpe->ch[ch].zeroes[w*16 + g] = i; } } } if (chans > 1 && cpe->common_window) { IndividualChannelStream *ics0 = &cpe->ch[0].ics; IndividualChannelStream *ics1 = &cpe->ch[1].ics; int msc = 0; ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); ics1->max_sfb = ics0->max_sfb; for (w = 0; w < ics0->num_windows*16; w += 16) for (i = 0; i < ics0->max_sfb; i++) if (cpe->ms_mask[w+i]) msc++; if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0; else cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2; } } |
1 | 636 | int ff_img_read_header(AVFormatContext *s1) { VideoDemuxData *s = s1->priv_data; int first_index, last_index; AVStream *st; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; s1->ctx_flags |= AVFMTCTX_NOHEADER; st = avformat_new_stream(s1, NULL); if (!st) { return AVERROR(ENOMEM); } if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } av_strlcpy(s->path, s1->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; /* find format */ if (s1->iformat->flags & AVFMT_NOFILE) s->is_pipe = 0; else { s->is_pipe = 1; st->need_parsing = AVSTREAM_PARSE_FULL; } if (s->ts_from_file == 2) { #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n"); return AVERROR(ENOSYS); #endif avpriv_set_pts_info(st, 64, 1, 1000000000); } else if (s->ts_from_file) avpriv_set_pts_info(st, 64, 1, 1); else avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); if (s->width && s->height) { st->codec->width = s->width; st->codec->height = s->height; } if (!s->is_pipe) { if (s->pattern_type == PT_GLOB_SEQUENCE) { s->use_glob = is_glob(s->path); if (s->use_glob) { #if HAVE_GLOB char *p = s->path, *q, *dup; int gerr; #endif av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: " "use pattern_type 'glob' instead\n"); #if HAVE_GLOB dup = q = av_strdup(p); while (*q) { /* Do we have room for the next char and a \ insertion? */ if ((p - s->path) >= (sizeof(s->path) - 2)) break; if (*q == '%' && strspn(q + 1, "%*?[]{}")) ++q; else if (strspn(q, "\\*?[]{}")) *p++ = '\\'; *p++ = *q++; } *p = 0; av_free(dup); gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; #endif } } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(&first_index, &last_index, s->path, s->start_number, s->start_number_range) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); return AVERROR(ENOENT); } } else if (s->pattern_type == PT_GLOB) { #if HAVE_GLOB int gerr; gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; s->use_glob = 1; #else av_log(s1, AV_LOG_ERROR, "Pattern type 'glob' was selected but globbing " "is not supported by this libavformat build\n"); return AVERROR(ENOSYS); #endif } else if (s->pattern_type != PT_GLOB_SEQUENCE) { av_log(s1, AV_LOG_ERROR, "Unknown value '%d' for pattern_type option\n", s->pattern_type); return AVERROR(EINVAL); } s->img_first = first_index; s->img_last = last_index; s->img_number = first_index; /* compute duration */ if (!s->ts_from_file) { st->start_time = 0; st->duration = last_index - first_index + 1; } } if (s1->video_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->video_codec_id; } else if (s1->audio_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = s1->audio_codec_id; } else if (s1->iformat->raw_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->iformat->raw_codec_id; } else { const char *str = strrchr(s->path, '.'); s->split_planes = str && !av_strcasecmp(str + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (s1->pb) { int probe_buffer_size = 2048; uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE); AVInputFormat *fmt = NULL; AVProbeData pd = { 0 }; if (!probe_buffer) return AVERROR(ENOMEM); probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size); if (probe_buffer_size < 0) { av_free(probe_buffer); return probe_buffer_size; } memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE); pd.buf = probe_buffer; pd.buf_size = probe_buffer_size; pd.filename = s1->filename; while ((fmt = av_iformat_next(fmt))) { if (fmt->read_header != ff_img_read_header || !fmt->read_probe || (fmt->flags & AVFMT_NOFILE) || !fmt->raw_codec_id) continue; if (fmt->read_probe(&pd) > 0) { st->codec->codec_id = fmt->raw_codec_id; break; } } ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size); } if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_guess_image2_codec(s->path); if (st->codec->codec_id == AV_CODEC_ID_LJPEG) st->codec->codec_id = AV_CODEC_ID_MJPEG; if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distingiush this from BRENDER_PIX st->codec->codec_id = AV_CODEC_ID_NONE; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != AV_PIX_FMT_NONE) st->codec->pix_fmt = pix_fmt; return 0; } |
1 | 637 | static void hpet_ram_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_read(opaque, addr, 4); new_val = value; /*address range of all TN regs*/ if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x\n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: // Interrupt capabilities DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: // comparator register DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP\n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { /* * FIXME: Clamp period to reasonable min value? * Clamp period to reasonable max value */ new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: // comparator register high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { /* * FIXME: Clamp period to reasonable min value? * Clamp period to reasonable max value */ new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Enable main counter and interrupt generation. */ s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Halt main counter and disable interrupt generation. */ s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } /* i8254 and RTC output pins are disabled * when HPET is in legacy mode */ if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_set_irq(s->pit_enabled, 0); qemu_irq_lower(s->irqs[0]); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_irq_lower(s->irqs[0]); qemu_set_irq(s->pit_enabled, 1); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write\n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } } |
1 | 638 | static abi_ulong copy_elf_strings(int argc,char ** argv, void **page, abi_ulong p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; if (!p) { return 0; /* bullet-proofing */ } while (argc-- > 0) { tmp = argv[argc]; if (!tmp) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } tmp1 = tmp; while (*tmp++); len = tmp - tmp1; if (p < len) { /* this shouldn't happen - 128kB */ return 0; } while (len) { --p; --tmp; --len; if (--offset < 0) { offset = p % TARGET_PAGE_SIZE; pag = (char *)page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)malloc(TARGET_PAGE_SIZE); memset(pag, 0, TARGET_PAGE_SIZE); page[p/TARGET_PAGE_SIZE] = pag; if (!pag) return 0; } } if (len == 0 || offset == 0) { *(pag + offset) = *tmp; } else { int bytes_to_copy = (len > offset) ? offset : len; tmp -= bytes_to_copy; p -= bytes_to_copy; offset -= bytes_to_copy; len -= bytes_to_copy; memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); } } } return p; } |
1 | 639 | static int mov_text_decode_close(AVCodecContext *avctx) { MovTextContext *m = avctx->priv_data; mov_text_cleanup_ftab(m); return 0; } |
1 | 640 | static void xhci_intr_raise(XHCIState *xhci, int v) { PCIDevice *pci_dev = PCI_DEVICE(xhci); xhci->intr[v].erdp_low |= ERDP_EHB; xhci->intr[v].iman |= IMAN_IP; xhci->usbsts |= USBSTS_EINT; if (!(xhci->intr[v].iman & IMAN_IE)) { if (!(xhci->usbcmd & USBCMD_INTE)) { if (msix_enabled(pci_dev)) { trace_usb_xhci_irq_msix(v); msix_notify(pci_dev, v); if (msi_enabled(pci_dev)) { trace_usb_xhci_irq_msi(v); msi_notify(pci_dev, v); if (v == 0) { trace_usb_xhci_irq_intx(1); pci_irq_assert(pci_dev); |
1 | 641 | int qemu_chr_fe_get_msgfd(CharDriverState *s) { int fd; return (qemu_chr_fe_get_msgfds(s, &fd, 1) >= 0) ? fd : -1; } |
1 | 642 | void qemu_set_dfilter_ranges(const char *filter_spec) { gchar **ranges = g_strsplit(filter_spec, ",", 0); if (ranges) { gchar **next = ranges; gchar *r = *next++; debug_regions = g_array_sized_new(FALSE, FALSE, sizeof(Range), g_strv_length(ranges)); while (r) { char *range_op = strstr(r, "-"); char *r2 = range_op ? range_op + 1 : NULL; if (!range_op) { range_op = strstr(r, "+"); r2 = range_op ? range_op + 1 : NULL; if (!range_op) { range_op = strstr(r, ".."); r2 = range_op ? range_op + 2 : NULL; if (range_op) { const char *e = NULL; uint64_t r1val, r2val; if ((qemu_strtoull(r, &e, 0, &r1val) == 0) && (qemu_strtoull(r2, NULL, 0, &r2val) == 0) && r2val > 0) { struct Range range; g_assert(e == range_op); switch (*range_op) { case '+': { range.begin = r1val; range.end = r1val + (r2val - 1); break; case '-': { range.end = r1val; range.begin = r1val - (r2val - 1); break; case '.': range.begin = r1val; range.end = r2val; break; default: g_assert_not_reached(); g_array_append_val(debug_regions, range); } else { g_error("Failed to parse range in: %s", r); } else { g_error("Bad range specifier in: %s", r); r = *next++; g_strfreev(ranges); |
1 | 643 | static void flush(AVCodecContext *avctx) { WmallDecodeCtx *s = avctx->priv_data; s->packet_loss = 1; s->packet_done = 0; s->num_saved_bits = 0; s->frame_offset = 0; s->next_packet_start = 0; s->cdlms[0][0].order = 0; s->frame.nb_samples = 0; init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); } |
1 | 644 | avs_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; int buf_size = avpkt->size; AvsContext *const avs = avctx->priv_data; AVFrame *picture = data; AVFrame *const p = &avs->picture; const uint8_t *table, *vect; uint8_t *out; int i, j, x, y, stride, vect_w = 3, vect_h = 3; AvsVideoSubType sub_type; AvsBlockType type; GetBitContext change_map; if (avctx->reget_buffer(avctx, p)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } p->reference = 3; p->pict_type = AV_PICTURE_TYPE_P; p->key_frame = 0; out = avs->picture.data[0]; stride = avs->picture.linesize[0]; if (buf_end - buf < 4) return AVERROR_INVALIDDATA; sub_type = buf[0]; type = buf[1]; buf += 4; if (type == AVS_PALETTE) { int first, last; uint32_t *pal = (uint32_t *) avs->picture.data[1]; first = AV_RL16(buf); last = first + AV_RL16(buf + 2); if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first)) return AVERROR_INVALIDDATA; buf += 4; for (i=first; i<last; i++, buf+=3) { pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2); pal[i] |= 0xFF << 24 | (pal[i] >> 6) & 0x30303; } sub_type = buf[0]; type = buf[1]; buf += 4; } if (type != AVS_VIDEO) return -1; switch (sub_type) { case AVS_I_FRAME: p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; case AVS_P_FRAME_3X3: vect_w = 3; vect_h = 3; break; case AVS_P_FRAME_2X2: vect_w = 2; vect_h = 2; break; case AVS_P_FRAME_2X3: vect_w = 2; vect_h = 3; break; default: return -1; } if (buf_end - buf < 256 * vect_w * vect_h) return AVERROR_INVALIDDATA; table = buf + (256 * vect_w * vect_h); if (sub_type != AVS_I_FRAME) { int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h); if (buf_end - table < map_size) return AVERROR_INVALIDDATA; init_get_bits(&change_map, table, map_size * 8); table += map_size; } for (y=0; y<198; y+=vect_h) { for (x=0; x<318; x+=vect_w) { if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) { if (buf_end - table < 1) return AVERROR_INVALIDDATA; vect = &buf[*table++ * (vect_w * vect_h)]; for (j=0; j<vect_w; j++) { out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j]; out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j]; if (vect_h == 3) out[(y + 2) * stride + x + j] = vect[(2 * vect_w) + j]; } } } if (sub_type != AVS_I_FRAME) align_get_bits(&change_map); } *picture = avs->picture; *data_size = sizeof(AVPicture); return buf_size; } |
1 | 645 | static void uc32_cpu_realizefn(DeviceState *dev, Error **errp) { UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(dev); ucc->parent_realize(dev, errp); } |
1 | 647 | void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp) { char *postfix; double sizef; sizef = strtod(value, &postfix); if (sizef < 0 || sizef > UINT64_MAX) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a non-negative number below 2^64"); return; } switch (*postfix) { case 'T': sizef *= 1024; /* fall through */ case 'G': sizef *= 1024; /* fall through */ case 'M': sizef *= 1024; /* fall through */ case 'K': case 'k': sizef *= 1024; /* fall through */ case 'b': case '\0': *ret = (uint64_t) sizef; break; default: error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_append_hint(errp, "You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); return; } } |
1 | 648 | static void gen_ove_cy(DisasContext *dc, TCGv cy) { if (dc->tb_flags & SR_OVE) { gen_helper_ove(cpu_env, cy); } } |
1 | 649 | static void limits_nesting(void) { enum { max_nesting = 1024 }; /* see qobject/json-streamer.c */ char buf[2 * (max_nesting + 1) + 1]; QObject *obj; obj = qobject_from_json(make_nest(buf, max_nesting), NULL); g_assert(obj != NULL); qobject_decref(obj); obj = qobject_from_json(make_nest(buf, max_nesting + 1), NULL); g_assert(obj == NULL); } |
1 | 650 | static int decode_end(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; free_tables(h); //FIXME cleanup init stuff perhaps MPV_common_end(s); // memset(h, 0, sizeof(H264Context)); return 0; } |
0 | 651 | static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) { int i, j; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " "encoder will guess the layout, but it " "might be incorrect.\n"); } if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) { av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); return -1; } /* frequency */ for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate) goto found; } return -1; found: s->sample_rate = avctx->sample_rate; s->bit_alloc.sr_shift = i; s->bit_alloc.sr_code = j; s->bitstream_id = 8 + s->bit_alloc.sr_shift; s->bitstream_mode = 0; /* complete main audio service */ /* bitrate & frame size */ for (i = 0; i < 19; i++) { if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate) break; } if (i == 19) return -1; s->bit_rate = avctx->bit_rate; s->frame_size_code = i << 1; return 0; } |
0 | 652 | static NvencSurface *get_free_frame(NvencContext *ctx) { int i; for (i = 0; i < ctx->nb_surfaces; i++) { if (!ctx->surfaces[i].lockCount) { ctx->surfaces[i].lockCount = 1; return &ctx->surfaces[i]; } } return NULL; } |
0 | 654 | int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize, uint8_t *dst, int height, int stride, enum TiffCompr compr, int opts) { int j; GetBitContext gb; int *runs, *ref, *runend; int ret; int runsize= avctx->width + 2; runs = av_malloc(runsize * sizeof(runs[0])); ref = av_malloc(runsize * sizeof(ref[0])); ref[0] = avctx->width; ref[1] = 0; ref[2] = 0; init_get_bits(&gb, src, srcsize*8); for(j = 0; j < height; j++){ runend = runs + runsize; if(compr == TIFF_G4){ ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(ret < 0){ av_free(runs); av_free(ref); return -1; } }else{ int g3d1 = (compr == TIFF_G3) && !(opts & 1); if(compr!=TIFF_CCITT_RLE && find_group3_syncmarker(&gb, srcsize*8) < 0) break; if(compr==TIFF_CCITT_RLE || g3d1 || get_bits1(&gb)) ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs, runend); else ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(compr==TIFF_CCITT_RLE) align_get_bits(&gb); } if(ret < 0){ put_line(dst, stride, avctx->width, ref); }else{ put_line(dst, stride, avctx->width, runs); FFSWAP(int*, runs, ref); } dst += stride; } av_free(runs); av_free(ref); return 0; } |
0 | 655 | static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le, int depth, AVDictionary **metadata) { int ret, cur_pos; unsigned id, count; enum TiffTypes type; if (depth > 2) { return 0; } ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos); if (!bytestream2_tell(gbytes)) { bytestream2_seek(gbytes, cur_pos, SEEK_SET); return 0; } // read count values and add it metadata // store metadata or proceed with next IFD ret = ff_tis_ifd(id); if (ret) { ret = avpriv_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata); } else { const char *name = exif_get_tag_name(id); char *use_name = (char*) name; if (!use_name) { use_name = av_malloc(7); if (!use_name) { return AVERROR(ENOMEM); } snprintf(use_name, 7, "0x%04X", id); } ret = exif_add_metadata(logctx, count, type, use_name, NULL, gbytes, le, metadata); if (!name) { av_freep(&use_name); } } bytestream2_seek(gbytes, cur_pos, SEEK_SET); return ret; } |
1 | 656 | static int pci_bridge_dev_initfn(PCIDevice *dev) { PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br); int err; pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn); err = pci_bridge_initfn(dev); if (err) { goto bridge_error; } memory_region_init(&bridge_dev->bar, "shpc-bar", shpc_bar_size(dev)); err = shpc_init(dev, &br->sec_bus, &bridge_dev->bar, 0); if (err) { goto shpc_error; } err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0); if (err) { goto slotid_error; } if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) && msi_supported) { err = msi_init(dev, 0, 1, true, true); if (err < 0) { goto msi_error; } } /* TODO: spec recommends using 64 bit prefetcheable BAR. * Check whether that works well. */ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &bridge_dev->bar); dev->config[PCI_INTERRUPT_PIN] = 0x1; return 0; msi_error: slotid_cap_cleanup(dev); slotid_error: shpc_cleanup(dev, &bridge_dev->bar); shpc_error: memory_region_destroy(&bridge_dev->bar); bridge_error: return err; } |
0 | 658 | static const AVClass *urlcontext_child_class_next(const AVClass *prev) { URLProtocol *p = NULL; /* find the protocol that corresponds to prev */ while (prev && (p = ffurl_protocol_next(p))) if (p->priv_data_class == prev) break; /* find next protocol with priv options */ while (p = ffurl_protocol_next(p)) if (p->priv_data_class) return p->priv_data_class; return NULL; } |
1 | 659 | static void do_change_vnc(const char *target) { if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) { char password[9]; monitor_readline("Password: ", 1, password, sizeof(password)-1); password[sizeof(password)-1] = '\0'; if (vnc_display_password(NULL, password) < 0) term_printf("could not set VNC server password\n"); } else { if (vnc_display_open(NULL, target) < 0) term_printf("could not start VNC server on %s\n", target); } } |
1 | 660 | int ff_get_cpu_flags_x86(void) { int rval = 0; int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps=0, ext_caps=0; int family=0, model=0; union { int i[3]; char c[12]; } vendor; #if ARCH_X86_32 x86_reg a, c; __asm__ volatile ( /* See if CPUID instruction is supported ... */ /* ... Get copies of EFLAGS into eax and ecx */ "pushfl\n\t" "pop %0\n\t" "mov %0, %1\n\t" /* ... Toggle the ID bit in one copy and store */ /* to the EFLAGS reg */ "xor $0x200000, %0\n\t" "push %0\n\t" "popfl\n\t" /* ... Get the (hopefully modified) EFLAGS */ "pushfl\n\t" "pop %0\n\t" : "=a" (a), "=c" (c) : : "cc" ); if (a == c) return 0; /* CPUID not supported */ #endif cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if(max_std_level >= 1){ cpuid(1, eax, ebx, ecx, std_caps); family = ((eax>>8)&0xf) + ((eax>>20)&0xff); model = ((eax>>4)&0xf) + ((eax>>12)&0xf0); if (std_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1<<25)) rval |= AV_CPU_FLAG_MMX2 #if HAVE_SSE | AV_CPU_FLAG_SSE; if (std_caps & (1<<26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX /* Check OXSAVE and AVX bits */ if ((ecx & 0x18000000) == 0x18000000) { /* Check for OS support */ xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) rval |= AV_CPU_FLAG_AVX; } #endif #endif ; } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if(max_ext_level >= 0x80000001){ cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1<<31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1<<30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1<<22)) rval |= AV_CPU_FLAG_MMX2; /* Allow for selectively disabling SSE2 functions on AMD processors with SSE2 support but not SSE4a. This includes Athlon64, some Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster than SSE2 often enough to utilize this special-case flag. AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case so that SSE2 is used unless explicitly disabled by checking AV_CPU_FLAG_SSE2SLOW. */ if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah") * theoretically support sse2, but it's usually slower than mmx, * so let's just pretend they don't. AV_CPU_FLAG_SSE2 is disabled and * AV_CPU_FLAG_SSE2SLOW is enabled so that SSE2 is not used unless * explicitly enabled by checking AV_CPU_FLAG_SSE2SLOW. The same * situation applies for AV_CPU_FLAG_SSE3 and AV_CPU_FLAG_SSE3SLOW. */ if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3; } /* The Atom processor has SSSE3 support, which is useful in many cases, * but sometimes the SSSE3 version is slower than the SSE2 equivalent * on the Atom, but is generally faster on other processors supporting * SSSE3. This flag allows for selectively disabling certain SSSE3 * functions on the Atom. */ if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } return rval; } |
1 | 661 | static inline void cvtyuvtoRGB (SwsContext *c, vector signed short Y, vector signed short U, vector signed short V, vector signed short *R, vector signed short *G, vector signed short *B) { vector signed short vx,ux,uvx; Y = vec_mradds (Y, c->CY, c->OY); U = vec_sub (U,(vector signed short) vec_splat((vector signed short)AVV(128),0)); V = vec_sub (V,(vector signed short) vec_splat((vector signed short)AVV(128),0)); // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15; ux = vec_sl (U, c->CSHIFT); *B = vec_mradds (ux, c->CBU, Y); // vx = (CRV*(v<<c->CSHIFT)+0x4000)>>15; vx = vec_sl (V, c->CSHIFT); *R = vec_mradds (vx, c->CRV, Y); // uvx = ((CGU*u) + (CGV*v))>>15; uvx = vec_mradds (U, c->CGU, Y); *G = vec_mradds (V, c->CGV, uvx); } |
1 | 662 | void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p) { if (p->len < 0) { s->setup_state = SETUP_STATE_IDLE; } switch (s->setup_state) { case SETUP_STATE_SETUP: if (p->len < s->setup_len) { s->setup_len = p->len; } s->setup_state = SETUP_STATE_DATA; p->len = 8; break; case SETUP_STATE_ACK: s->setup_state = SETUP_STATE_IDLE; p->len = 0; break; default: break; } usb_packet_complete(s, p); } |
1 | 663 | static int encode_audio_frame(AVFormatContext *s, OutputStream *ost, const uint8_t *buf, int buf_size) { AVCodecContext *enc = ost->st->codec; AVFrame *frame = NULL; AVPacket pkt; int ret, got_packet; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (buf && buf_size) { if (!ost->output_frame) { ost->output_frame = avcodec_alloc_frame(); if (!ost->output_frame) { av_log(NULL, AV_LOG_FATAL, "out-of-memory in encode_audio_frame()\n"); exit_program(1); } } frame = ost->output_frame; if (frame->extended_data != frame->data) av_freep(&frame->extended_data); avcodec_get_frame_defaults(frame); frame->nb_samples = buf_size / (enc->channels * av_get_bytes_per_sample(enc->sample_fmt)); if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt, buf, buf_size, 1)) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_fill_audio_frame)\n"); exit_program(1); } frame->pts = ost->sync_opts; ost->sync_opts += frame->nb_samples; } got_packet = 0; update_benchmark(NULL); if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n"); exit_program(1); } update_benchmark("encode_audio %d.%d", ost->file_index, ost->index); ret = pkt.size; if (got_packet) { if (pkt.pts != AV_NOPTS_VALUE) pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base); if (pkt.dts != AV_NOPTS_VALUE) { int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base); if (ost->st->cur_dts && ost->st->cur_dts != AV_NOPTS_VALUE && max > pkt.dts) { av_log(s, max - pkt.dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt.dts, max); pkt.pts = pkt.dts = max; } } if (pkt.duration > 0) pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base); write_frame(s, &pkt, ost); audio_size += pkt.size; av_free_packet(&pkt); } if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:audio " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); } return ret; } |
1 | 664 | static void rng_egd_opened(RngBackend *b, Error **errp) { RngEgd *s = RNG_EGD(b); if (s->chr_name == NULL) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "chardev", "a valid character device"); s->chr = qemu_chr_find(s->chr_name); if (s->chr == NULL) { error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name); /* FIXME we should resubmit pending requests when the CDS reconnects. */ qemu_chr_add_handlers(s->chr, rng_egd_chr_can_read, rng_egd_chr_read, NULL, s); |
0 | 665 | static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) { MpegTSContext *ts = s->priv_data; int64_t pos, timestamp; uint8_t buf[TS_PACKET_SIZE]; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; while(pos < pos_limit) { avio_seek(s->pb, pos, SEEK_SET); if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && parse_pcr(×tamp, &pcr_l, buf) == 0) { *ppos = pos; return timestamp; } pos += ts->raw_packet_size; } return AV_NOPTS_VALUE; } |
0 | 667 | static enum AVPixelFormat get_pixel_format(H264Context *h) { #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ CONFIG_H264_D3D11VA_HWACCEL + \ CONFIG_H264_VAAPI_HWACCEL + \ (CONFIG_H264_VDA_HWACCEL * 2) + \ CONFIG_H264_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; const enum AVPixelFormat *choices = pix_fmts; switch (h->sps.bit_depth_luma) { case 9: if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP9; } else *fmt++ = AV_PIX_FMT_YUV444P9; } else if (CHROMA422(h)) *fmt++ = AV_PIX_FMT_YUV422P9; else *fmt++ = AV_PIX_FMT_YUV420P9; break; case 10: if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP10; } else *fmt++ = AV_PIX_FMT_YUV444P10; } else if (CHROMA422(h)) *fmt++ = AV_PIX_FMT_YUV422P10; else *fmt++ = AV_PIX_FMT_YUV420P10; break; case 8: #if CONFIG_H264_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) *fmt++ = AV_PIX_FMT_GBRP; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ444P; else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(h)) { if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ422P; else *fmt++ = AV_PIX_FMT_YUV422P; } else { #if CONFIG_H264_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif #if CONFIG_H264_D3D11VA_HWACCEL *fmt++ = AV_PIX_FMT_D3D11VA_VLD; #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif #if CONFIG_H264_VDA_HWACCEL *fmt++ = AV_PIX_FMT_VDA_VLD; *fmt++ = AV_PIX_FMT_VDA; #endif if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ420P; else *fmt++ = AV_PIX_FMT_YUV420P; } break; default: av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", h->sps.bit_depth_luma); return AVERROR_INVALIDDATA; } *fmt = AV_PIX_FMT_NONE; return ff_get_format(h->avctx, choices); } |
1 | 671 | static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) { mv88w8618_eth_state *s; int iomemtype; qemu_check_nic_model(nd, "mv88w8618"); s = qemu_mallocz(sizeof(mv88w8618_eth_state)); s->irq = irq; s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, s); iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype); } |
1 | 672 | static int vnc_update_client_sync(VncState *vs, int has_dirty) { int ret = vnc_update_client(vs, has_dirty); vnc_jobs_join(vs); return ret; } |
1 | 673 | static struct omap_tipb_bridge_s *omap_tipb_bridge_init( MemoryRegion *memory, hwaddr base, qemu_irq abort_irq, omap_clk clk) { struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) g_malloc0(sizeof(struct omap_tipb_bridge_s)); s->abort = abort_irq; omap_tipb_bridge_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_tipb_bridge_ops, s, "omap-tipb-bridge", 0x100); memory_region_add_subregion(memory, base, &s->iomem); return s; } |
1 | 675 | static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size) { GetBitContext gb; int flags, i, j, x, y, op; unsigned char c[3]; unsigned char *dst; uint32_t *palette; flags = *data++; if (flags & 1) { palette = (uint32_t *)seq->frame.data[1]; for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++, data++) c[j] = (*data << 2) | (*data >> 4); palette[i] = AV_RB24(c); } seq->frame.palette_has_changed = 1; } if (flags & 2) { init_get_bits(&gb, data, 128 * 8); data += 128; for (y = 0; y < 128; y += 8) for (x = 0; x < 256; x += 8) { dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x]; op = get_bits(&gb, 2); switch (op) { case 1: data = seq_decode_op1(seq, data, dst); break; case 2: data = seq_decode_op2(seq, data, dst); break; case 3: data = seq_decode_op3(seq, data, dst); break; } } } } |
1 | 676 | static int get_video_buffer(AVFrame *frame, int align) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); int ret, i; if (!desc) return AVERROR(EINVAL); if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0) return ret; if (!frame->linesize[0]) { ret = av_image_fill_linesizes(frame->linesize, frame->format, frame->width); if (ret < 0) return ret; for (i = 0; i < 4 && frame->linesize[i]; i++) frame->linesize[i] = FFALIGN(frame->linesize[i], align); } for (i = 0; i < 4 && frame->linesize[i]; i++) { int h = frame->height; if (i == 1 || i == 2) h = -((-h) >> desc->log2_chroma_h); frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h); if (!frame->buf[i]) goto fail; frame->data[i] = frame->buf[i]->data; } if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL) { av_buffer_unref(&frame->buf[1]); frame->buf[1] = av_buffer_alloc(1024); if (!frame->buf[1]) goto fail; frame->data[1] = frame->buf[1]->data; } frame->extended_data = frame->data; return 0; fail: av_frame_unref(frame); return AVERROR(ENOMEM); } |
0 | 678 | static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, VLCcode *codes, int flags) { int table_size, table_index, index, code_prefix, symbol, subtable_bits; int i, j, k, n, nb, inc; uint32_t code; VLC_TYPE (*table)[2]; table_size = 1 << table_nb_bits; if (table_nb_bits > 30) return -1; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); if (table_index < 0) return table_index; table = &vlc->table[table_index]; for (i = 0; i < table_size; i++) { table[i][1] = 0; //bits table[i][0] = -1; //codes } /* first pass: map codes and compute auxiliary table sizes */ for (i = 0; i < nb_codes; i++) { n = codes[i].bits; code = codes[i].code; symbol = codes[i].symbol; av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code); if (n <= table_nb_bits) { /* no need to add another table */ j = code >> (32 - table_nb_bits); nb = 1 << (table_nb_bits - n); inc = 1; if (flags & INIT_VLC_LE) { j = bitswap_32(code); inc = 1 << n; } for (k = 0; k < nb; k++) { av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); if (table[j][1] /*bits*/ != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } table[j][1] = n; //bits table[j][0] = symbol; j += inc; } } else { /* fill auxiliary table recursively */ n -= table_nb_bits; code_prefix = code >> (32 - table_nb_bits); subtable_bits = n; codes[i].bits = n; codes[i].code = code << table_nb_bits; for (k = i+1; k < nb_codes; k++) { n = codes[k].bits - table_nb_bits; if (n <= 0) break; code = codes[k].code; if (code >> (32 - table_nb_bits) != code_prefix) break; codes[k].bits = n; codes[k].code = code << table_nb_bits; subtable_bits = FFMAX(subtable_bits, n); } subtable_bits = FFMIN(subtable_bits, table_nb_bits); j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; table[j][1] = -subtable_bits; av_dlog(NULL, "%4x: n=%d (subtable)\n", j, codes[i].bits + table_nb_bits); index = build_table(vlc, subtable_bits, k-i, codes+i, flags); if (index < 0) return index; /* note: realloc has been done, so reload tables */ table = &vlc->table[table_index]; table[j][0] = index; //code av_assert0(table[j][0] == index); i = k-1; } } return table_index; } |
0 | 679 | static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta); } |
0 | 680 | static inline void do_imdct(AC3DecodeContext *s, int channels) { int ch; for (ch=1; ch<=channels; ch++) { if (s->block_switch[ch]) { int i; float *x = s->tmp_output+128; for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i]; ff_imdct_half(&s->imdct_256, s->tmp_output, x); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128); for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i+1]; ff_imdct_half(&s->imdct_256, s->delay[ch-1], x); } else { ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128); memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); } } } |
1 | 681 | static void parse_header_digest(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *digest = NULL; list = qemu_find_opts("iscsi"); if (!list) { return; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } digest = qemu_opt_get(opts, "header-digest"); if (!digest) { return; } if (!strcmp(digest, "CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(digest, "NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE); } else if (!strcmp(digest, "CRC32C-NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE); } else if (!strcmp(digest, "NONE-CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); } else { error_report("Invalid header-digest setting : %s", digest); } } |
1 | 684 | void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp) { if (!error_is_set(errp)) { v->type_str(v, obj, name, errp); } } |
1 | 685 | static int http_send_data(HTTPContext *c) { int len, ret; while (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret == 0) { break; } else { /* state change requested */ return 0; } } if (c->buffer_end > c->buffer_ptr) { len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ return -1; } } else { c->buffer_ptr += len; c->data_count += len; } } return 0; } |
1 | 687 | static void m68060_cpu_initfn(Object *obj) { M68kCPU *cpu = M68K_CPU(obj); CPUM68KState *env = &cpu->env; m68k_set_feature(env, M68K_FEATURE_M68000); m68k_set_feature(env, M68K_FEATURE_USP); m68k_set_feature(env, M68K_FEATURE_WORD_INDEX); m68k_set_feature(env, M68K_FEATURE_BRAL); m68k_set_feature(env, M68K_FEATURE_BCCL); m68k_set_feature(env, M68K_FEATURE_BITFIELD); m68k_set_feature(env, M68K_FEATURE_EXT_FULL); m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX); m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV); m68k_set_feature(env, M68K_FEATURE_FPU); m68k_set_feature(env, M68K_FEATURE_CAS); m68k_set_feature(env, M68K_FEATURE_BKPT); m68k_set_feature(env, M68K_FEATURE_RTD); } |
1 | 688 | void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { char buf[1024]; unsigned long bios_offset; int bios_size; CPUState *env; RTCState *rtc_state; int i; qemu_irq *i8259; int index; BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; /* init CPUs */ if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "R4000"; #else cpu_model = "24Kf"; #endif env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); qemu_register_reset(main_cpu_reset, env); /* allocate RAM */ cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); if (!mips_qemu_iomemtype) { mips_qemu_iomemtype = cpu_register_io_memory(0, mips_qemu_read, mips_qemu_write, NULL); cpu_register_physical_memory(0x1fbf0000, 0x10000, mips_qemu_iomemtype); /* Try to load a BIOS image. If this fails, we continue regardless, but initialize the hardware ourselves. When a kernel gets preloaded we also initialize the hardware, since the BIOS wasn't run. */ bios_offset = ram_size + vga_ram_size; if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); bios_size = load_image(buf, phys_ram_base + bios_offset); if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) { cpu_register_physical_memory(0x1fc00000, BIOS_SIZE, bios_offset | IO_MEM_ROM); } else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) { uint32_t mips_rom = 0x00400000; cpu_register_physical_memory(0x1fc00000, mips_rom, qemu_ram_alloc(mips_rom) | IO_MEM_ROM); if (!pflash_cfi01_register(0x1fc00000, qemu_ram_alloc(mips_rom), drives_table[index].bdrv, sector_len, mips_rom / sector_len, 4, 0, 0, 0, 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); else { /* not fatal */ fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n", buf); if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; load_kernel (env); /* Init CPU internal devices */ cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); /* The PIC is attached to the MIPS CPU INT0 pin */ i8259 = i8259_init(env->irq[2]); rtc_state = rtc_init(0x70, i8259[8]); /* Register 64 KB of ISA IO space at 0x14000000 */ isa_mmio_init(0x14000000, 0x00010000); isa_mem_base = 0x10000000; pit = pit_init(0x40, i8259[0]); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_init(serial_io[i], i8259[serial_irq[i]], 115200, serial_hds[i]); isa_vga_init(phys_ram_base + ram_size, ram_size, vga_ram_size); if (nd_table[0].vlan) isa_ne2000_init(0x300, i8259[9], &nd_table[0]); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); if (index != -1) hd[i] = drives_table[index].bdrv; else hd[i] = NULL; for(i = 0; i < MAX_IDE_BUS; i++) isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); i8042_init(i8259[1], i8259[12], 0x60); |
1 | 689 | static void windowing_and_mdct_ltp(AACContext *ac, float *out, float *in, IndividualChannelStream *ics) { const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { ac->dsp.vector_fmul(in, in, lwindow_prev, 1024); } else { memset(in, 0, 448 * sizeof(float)); ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); memcpy(in + 576, in + 576, 448 * sizeof(float)); } if (ics->window_sequence[0] != LONG_START_SEQUENCE) { ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); } else { memcpy(in + 1024, in + 1024, 448 * sizeof(float)); ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); memset(in + 1024 + 576, 0, 448 * sizeof(float)); } ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); } |
0 | 690 | static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = c->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; c->trak_index = -1; /* sanity checks */ if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))) { av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); return 0; } fix_timescale(c, sc); avpriv_set_pts_info(st, 64, 1, sc->time_scale); mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (mov_open_dref(c, &sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } else { sc->pb = c->fc->pb; sc->pb_is_copied = 1; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height && sc->height && sc->width && (st->codec->width != sc->width || st->codec->height != sc->height)) { st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) / ((double)st->codec->width * sc->height), INT_MAX); } #if FF_API_R_FRAME_RATE if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, sc->time_scale, sc->stts_data[0].duration, INT_MAX); #endif } // done for ai5q, ai52, ai55, ai1q, ai12 and ai15. if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 && TAG_IS_AVCI(st->codec->codec_tag)) { ret = ff_generate_avci_extradata(st); if (ret < 0) return ret; } switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case AV_CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case AV_CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case AV_CODEC_ID_MPEG4: #endif st->codec->width = 0; /* let decoder init width/height */ st->codec->height= 0; break; } // If the duration of the mp3 packets is not constant, then they could need a parser if (st->codec->codec_id == AV_CODEC_ID_MP3 && sc->stts_count > 3 && sc->stts_count*10 > st->nb_frames && sc->time_scale == st->codec->sample_rate) { st->need_parsing = AVSTREAM_PARSE_FULL; } /* Do not need those anymore. */ av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); return 0; } |
1 | 692 | static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; unsigned int size; uint8_t *startmarker_ptr, *end, *search_end, marker; MXGContext *mxg = s->priv_data; while (!avio_feof(s->pb) && !s->pb->error){ if (mxg->cache_size <= OVERREAD_SIZE) { /* update internal buffer */ ret = mxg_update_cache(s, DEFAULT_PACKET_SIZE + OVERREAD_SIZE); if (ret < 0) return ret; } end = mxg->buffer_ptr + mxg->cache_size; /* find start marker - 0xff */ if (mxg->cache_size > OVERREAD_SIZE) { search_end = end - OVERREAD_SIZE; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); } else { search_end = end; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); if (startmarker_ptr >= search_end - 1 || *(startmarker_ptr + 1) != EOI) break; } if (startmarker_ptr != search_end) { /* start marker found */ marker = *(startmarker_ptr + 1); mxg->buffer_ptr = startmarker_ptr + 2; mxg->cache_size = end - mxg->buffer_ptr; if (marker == SOI) { mxg->soi_ptr = startmarker_ptr; } else if (marker == EOI) { if (!mxg->soi_ptr) { av_log(s, AV_LOG_WARNING, "Found EOI before SOI, skipping\n"); continue; } pkt->pts = pkt->dts = mxg->dts; pkt->stream_index = 0; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->buf = NULL; pkt->size = mxg->buffer_ptr - mxg->soi_ptr; pkt->data = mxg->soi_ptr; if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } mxg->soi_ptr = 0; return pkt->size; } else if ( (SOF0 <= marker && marker <= SOF15) || (SOS <= marker && marker <= COM) ) { /* all other markers that start marker segment also contain length value (see specification for JPEG Annex B.1) */ size = AV_RB16(mxg->buffer_ptr); if (size < 2) return AVERROR(EINVAL); if (mxg->cache_size < size) { ret = mxg_update_cache(s, size); if (ret < 0) return ret; startmarker_ptr = mxg->buffer_ptr - 2; mxg->cache_size = 0; } else { mxg->cache_size -= size; } mxg->buffer_ptr += size; if (marker == APP13 && size >= 16) { /* audio data */ /* time (GMT) of first sample in usec since 1970, little-endian */ pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8); pkt->stream_index = 1; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->buf = NULL; pkt->size = size - 14; pkt->data = startmarker_ptr + 16; if (startmarker_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } return pkt->size; } else if (marker == COM && size >= 18 && !strncmp(startmarker_ptr + 4, "MXF", 3)) { /* time (GMT) of video frame in usec since 1970, little-endian */ mxg->dts = AV_RL64(startmarker_ptr + 12); } } } else { /* start marker not found */ mxg->buffer_ptr = search_end; mxg->cache_size = OVERREAD_SIZE; } } return AVERROR_EOF; } |
1 | 693 | static uint32_t pci_unin_config_readl (void *opaque, target_phys_addr_t addr) { UNINState *s = opaque; return s->config_reg; } |
1 | 694 | static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; FLVContext *flv = s->priv_data; AVIOContext *ioc; AMFDataType amf_type; char str_val[256]; double num_val; num_val = 0; ioc = s->pb; amf_type = avio_r8(ioc); switch (amf_type) { case AMF_DATA_TYPE_NUMBER: num_val = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && ioc->seekable && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, max_pos) < 0) av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n"); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; // if we couldn't skip, bomb out. if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; // these take up no additional space case AMF_DATA_TYPE_MIXEDARRAY: avio_skip(ioc, 4); // skip 32-bit max array index while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) // this is the only case in which we would want a nested // parse to not skip over the object if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = avio_rb32(ioc); for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) if (amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; // if we couldn't skip, bomb out. } break; case AMF_DATA_TYPE_DATE: avio_skip(ioc, 8 + 2); // timestamp (double) and UTC offset (int16) break; default: // unsupported type, we couldn't skip return -1; } if (key) { // stream info doesn't live any deeper than the first object if (depth == 1) { acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; if (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) { if (!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) vcodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) acodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "datastream")) { AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA); if (!st) return AVERROR(ENOMEM); st->codec->codec_id = AV_CODEC_ID_TEXT; } else if (flv->trust_metadata) { if (!strcmp(key, "videocodecid") && vcodec) { flv_set_video_codec(s, vstream, num_val, 0); } else if (!strcmp(key, "audiocodecid") && acodec) { int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET; flv_set_audio_codec(s, astream, acodec, id); } else if (!strcmp(key, "audiosamplerate") && acodec) { acodec->sample_rate = num_val; } else if (!strcmp(key, "audiosamplesize") && acodec) { acodec->bits_per_coded_sample = num_val; } else if (!strcmp(key, "stereo") && acodec) { acodec->channels = num_val + 1; acodec->channel_layout = acodec->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } else if (!strcmp(key, "width") && vcodec) { vcodec->width = num_val; } else if (!strcmp(key, "height") && vcodec) { vcodec->height = num_val; } } } } if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))) s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object if (!strcmp(key, "duration") || !strcmp(key, "filesize") || !strcmp(key, "width") || !strcmp(key, "height") || !strcmp(key, "videodatarate") || !strcmp(key, "framerate") || !strcmp(key, "videocodecid") || !strcmp(key, "audiodatarate") || !strcmp(key, "audiosamplerate") || !strcmp(key, "audiosamplesize") || !strcmp(key, "stereo") || !strcmp(key, "audiocodecid") || !strcmp(key, "datastream")) return 0; s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; if (amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&s->metadata, key, str_val, 0); } return 0; } |
1 | 695 | static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv b) { TCGv_i64 tmp64 = tcg_temp_new_i64(); tcg_gen_extu_i32_i64(tmp64, b); dead_tmp(b); tcg_gen_shli_i64(tmp64, tmp64, 32); tcg_gen_sub_i64(a, tmp64, a); tcg_temp_free_i64(tmp64); return a; } |
1 | 697 | static void decode_component(DiracContext *s, int comp) { AVCodecContext *avctx = s->avctx; SubBand *bands[3*MAX_DWT_LEVELS+1]; enum dirac_subband orientation; int level, num_bands = 0; /* Unpack all subbands at all levels. */ for (level = 0; level < s->wavelet_depth; level++) { for (orientation = !!level; orientation < 4; orientation++) { SubBand *b = &s->plane[comp].band[level][orientation]; bands[num_bands++] = b; align_get_bits(&s->gb); /* [DIRAC_STD] 13.4.2 subband() */ b->length = svq3_get_ue_golomb(&s->gb); if (b->length) { b->quant = svq3_get_ue_golomb(&s->gb); align_get_bits(&s->gb); b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8; b->length = FFMIN(b->length, get_bits_left(&s->gb)/8); skip_bits_long(&s->gb, b->length*8); } } /* arithmetic coding has inter-level dependencies, so we can only execute one level at a time */ if (s->is_arith) avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level], NULL, 4-!!level, sizeof(SubBand)); } /* golomb coding has no inter-level dependencies, so we can execute all subbands in parallel */ if (!s->is_arith) avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*)); } |
1 | 698 | static void ppc_heathrow_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; const char *boot_device = machine->boot_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; char *filename; qemu_irq *pic, **heathrow_irqs; int linux_boot, i; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); MemoryRegion *isa = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base, cmdline_base = 0; int32_t kernel_size, initrd_size; PCIBus *pci_bus; PCIDevice *macio; MACIOIDEState *macio_ide; DeviceState *dev; BusState *adb_bus; int bios_size; MemoryRegion *pic_mem; MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1); uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; uint64_t tbfreq; linux_boot = (kernel_filename != NULL); /* init CPUs */ if (cpu_model == NULL) cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; /* Set time-base frequency to 16.6 Mhz */ cpu_ppc_tb_init(env, TBFREQ); qemu_register_reset(ppc_heathrow_reset, cpu); } /* allocate RAM */ if (ram_size > (2047 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", ram_size); memory_region_add_subregion(sysmem, 0, ram); /* allocate and load BIOS */ memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE); vmstate_register_ram_global(bios); if (bios_name == NULL) bios_name = PROM_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); memory_region_set_readonly(bios, true); memory_region_add_subregion(sysmem, PROM_ADDR, bios); /* Load OpenBIOS (ELF) */ if (filename) { bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, 1, ELF_MACHINE, 0); g_free(filename); } else { bios_size = -1; } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); exit(1); } if (linux_boot) { uint64_t lowaddr = 0; int bswap_needed; #ifdef BSWAP_NEEDED bswap_needed = 1; #else bswap_needed = 0; #endif kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, kernel_base, ram_size - kernel_base, bswap_needed, TARGET_PAGE_SIZE); if (kernel_size < 0) kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { hw_error("qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* load initrd */ if (initrd_filename) { initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP); initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } cmdline_base = round_page(initrd_base + initrd_size); } else { initrd_base = 0; initrd_size = 0; cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP); } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (i = 0; boot_device[i] != '\0'; i++) { /* TOFIX: for now, the second IDE channel is not properly * used by OHW. The Mac floppy disk are not emulated. * For now, OHW cannot boot from the network. */ #if 0 if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } #else if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { ppc_boot_device = boot_device[i]; break; } #endif } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for G3 Beige machine\n"); exit(1); } } /* Register 2 MB of ISA IO space */ memory_region_init_alias(isa, NULL, "isa_mmio", get_system_io(), 0, 0x00200000); memory_region_add_subregion(sysmem, 0xfe000000, isa); /* XXX: we register only 1 output pin for heathrow PIC */ heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); heathrow_irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * 1); /* Connect the heathrow PIC outputs to the 6xx bus */ for (i = 0; i < smp_cpus; i++) { switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); heathrow_irqs[i][0] = ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; break; default: hw_error("Bus model not supported on OldWorld Mac machine\n"); } } /* Timebase Frequency */ if (kvm_enabled()) { tbfreq = kvmppc_get_tbfreq(); } else { tbfreq = TBFREQ; } /* init basic PC hardware */ if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on heathrow machine\n"); } pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic, get_system_memory(), get_system_io()); pci_vga_init(pci_bus); escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); memory_region_init_alias(escc_bar, NULL, "escc-bar", escc_mem, 0, memory_region_size(escc_mem)); for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO); dev = DEVICE(macio); qdev_connect_gpio_out(dev, 0, pic[0x12]); /* CUDA */ qdev_connect_gpio_out(dev, 1, pic[0x0D]); /* IDE-0 */ qdev_connect_gpio_out(dev, 2, pic[0x02]); /* IDE-0 DMA */ qdev_connect_gpio_out(dev, 3, pic[0x0E]); /* IDE-1 */ qdev_connect_gpio_out(dev, 4, pic[0x03]); /* IDE-1 DMA */ macio_init(macio, pic_mem, escc_bar); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[0]")); macio_ide_init_drives(macio_ide, hd); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[1]")); macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); adb_bus = qdev_get_child_bus(dev, "adb.0"); dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD); qdev_init_nofail(dev); dev = qdev_create(adb_bus, TYPE_ADB_MOUSE); qdev_init_nofail(dev); if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) graphic_depth = 15; /* No PCI init: the BIOS will do it */ fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); if (kvm_enabled()) { #ifdef CONFIG_KVM uint8_t *hypercall; hypercall = g_malloc(16); kvmppc_get_hypercall(env, hypercall, 16); fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); #endif } fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq); /* Mac OS X requires a "known good" clock-frequency value; pass it one. */ fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } |
1 | 699 | static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb) { int i; int dc_y_table; int dc_c_table; int ac_y_table; int ac_c_table; int residual_eob_run = 0; VLC *y_tables[64]; VLC *c_tables[64]; s->dct_tokens[0][0] = s->dct_tokens_base; if (get_bits_left(gb) < 16) /* fetch the DC table indexes */ dc_y_table = get_bits(gb, 4); dc_c_table = get_bits(gb, 4); /* unpack the Y plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0, 0, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; /* reverse prediction of the Y-plane DC coefficients */ reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]); /* unpack the C plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 1, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 2, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; /* reverse prediction of the C-plane DC coefficients */ if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { reverse_dc_prediction(s, s->fragment_start[1], s->fragment_width[1], s->fragment_height[1]); reverse_dc_prediction(s, s->fragment_start[2], s->fragment_width[1], s->fragment_height[1]); } /* fetch the AC table indexes */ ac_y_table = get_bits(gb, 4); ac_c_table = get_bits(gb, 4); /* build tables of AC VLC tables */ for (i = 1; i <= 5; i++) { y_tables[i] = &s->ac_vlc_1[ac_y_table]; c_tables[i] = &s->ac_vlc_1[ac_c_table]; } for (i = 6; i <= 14; i++) { y_tables[i] = &s->ac_vlc_2[ac_y_table]; c_tables[i] = &s->ac_vlc_2[ac_c_table]; } for (i = 15; i <= 27; i++) { y_tables[i] = &s->ac_vlc_3[ac_y_table]; c_tables[i] = &s->ac_vlc_3[ac_c_table]; } for (i = 28; i <= 63; i++) { y_tables[i] = &s->ac_vlc_4[ac_y_table]; c_tables[i] = &s->ac_vlc_4[ac_c_table]; } /* decode all AC coefficients */ for (i = 1; i <= 63; i++) { residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, 0, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 1, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 2, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; } return 0; } |
1 | 700 | static void free_device_list(AVOpenCLDeviceList *device_list) { int i, j; if (!device_list) return; for (i = 0; i < device_list->platform_num; i++) { if (!device_list->platform_node[i]) continue; for (j = 0; j < device_list->platform_node[i]->device_num; j++) { av_freep(&(device_list->platform_node[i]->device_node[j]->device_name)); av_freep(&(device_list->platform_node[i]->device_node[j])); } av_freep(&device_list->platform_node[i]->device_node); av_freep(&(device_list->platform_node[i]->platform_name)); av_freep(&device_list->platform_node[i]); } av_freep(&device_list->platform_node); device_list->platform_num = 0; } |
1 | 701 | void qemu_cond_init(QemuCond *cond) { memset(cond, 0, sizeof(*cond)); cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL); if (!cond->sema) { error_exit(GetLastError(), __func__); } cond->continue_event = CreateEvent(NULL, /* security */ FALSE, /* auto-reset */ FALSE, /* not signaled */ NULL); /* name */ if (!cond->continue_event) { error_exit(GetLastError(), __func__); } } |
1 | 702 | void helper_rfdi(CPUPPCState *env) { do_rfi(env, env->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1, ~((target_ulong)0x3FFF0000), 0); } |
1 | 703 | static void choose_sample_rate(AVStream *st, AVCodec *codec) { if(codec && codec->supported_samplerates){ const int *p= codec->supported_samplerates; int best; int best_dist=INT_MAX; for(; *p; p++){ int dist= abs(st->codec->sample_rate - *p); if(dist < best_dist){ best_dist= dist; best= *p; } } if(best_dist){ av_log(st->codec, AV_LOG_WARNING, "Requested sampling rate unsupported using closest supported (%d)\n", best); } st->codec->sample_rate= best; } } |
1 | 704 | unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, const struct iovec *iov, unsigned int iov_cnt, size_t offset, size_t bytes) { size_t len; unsigned int i, j; for (i = 0, j = 0; i < iov_cnt && j < dst_iov_cnt && bytes; i++) { if (offset >= iov[i].iov_len) { offset -= iov[i].iov_len; continue; } len = MIN(bytes, iov[i].iov_len - offset); dst_iov[j].iov_base = iov[i].iov_base + offset; dst_iov[j].iov_len = len; j++; bytes -= len; offset = 0; } assert(offset == 0); return j; } |
1 | 706 | static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg) FDCharDriver *s = chr->opaque; switch(cmd) { case CHR_IOCTL_SERIAL_SET_PARAMS: QEMUSerialSetParams *ssp = arg; tty_serial_init(s->fd_in, ssp->speed, ssp->parity, ssp->data_bits, ssp->stop_bits); case CHR_IOCTL_SERIAL_SET_BREAK: int enable = *(int *)arg; if (enable) tcsendbreak(s->fd_in, 1); default: return -ENOTSUP; return 0; |
1 | 708 | static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt) { MachineState *machine = MACHINE(spapr); int ret, i, offset; uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE; uint32_t prop_lmb_size[] = {0, cpu_to_be32(lmb_size)}; uint32_t nr_lmbs = (machine->maxram_size - machine->ram_size)/lmb_size; uint32_t *int_buf, *cur_index, buf_len; int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1; /* Allocate enough buffer size to fit in ibm,dynamic-memory */ buf_len = nr_lmbs * SPAPR_DR_LMB_LIST_ENTRY_SIZE * sizeof(uint32_t) + sizeof(uint32_t); cur_index = int_buf = g_malloc0(buf_len); offset = fdt_add_subnode(fdt, 0, "ibm,dynamic-reconfiguration-memory"); ret = fdt_setprop(fdt, offset, "ibm,lmb-size", prop_lmb_size, sizeof(prop_lmb_size)); if (ret < 0) { goto out; } ret = fdt_setprop_cell(fdt, offset, "ibm,memory-flags-mask", 0xff); if (ret < 0) { goto out; } ret = fdt_setprop_cell(fdt, offset, "ibm,memory-preservation-time", 0x0); if (ret < 0) { goto out; } /* ibm,dynamic-memory */ int_buf[0] = cpu_to_be32(nr_lmbs); cur_index++; for (i = 0; i < nr_lmbs; i++) { sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; uint64_t addr = i * lmb_size + spapr->hotplug_memory.base;; uint32_t *dynamic_memory = cur_index; drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB, addr/lmb_size); g_assert(drc); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); dynamic_memory[0] = cpu_to_be32(addr >> 32); dynamic_memory[1] = cpu_to_be32(addr & 0xffffffff); dynamic_memory[2] = cpu_to_be32(drck->get_index(drc)); dynamic_memory[3] = cpu_to_be32(0); /* reserved */ dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL)); if (addr < machine->ram_size || memory_region_present(get_system_memory(), addr)) { dynamic_memory[5] = cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED); } else { dynamic_memory[5] = cpu_to_be32(0); } cur_index += SPAPR_DR_LMB_LIST_ENTRY_SIZE; } ret = fdt_setprop(fdt, offset, "ibm,dynamic-memory", int_buf, buf_len); if (ret < 0) { goto out; } /* ibm,associativity-lookup-arrays */ cur_index = int_buf; int_buf[0] = cpu_to_be32(nr_nodes); int_buf[1] = cpu_to_be32(4); /* Number of entries per associativity list */ cur_index += 2; for (i = 0; i < nr_nodes; i++) { uint32_t associativity[] = { cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(i) }; memcpy(cur_index, associativity, sizeof(associativity)); cur_index += 4; } ret = fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", int_buf, (cur_index - int_buf) * sizeof(uint32_t)); out: g_free(int_buf); return ret; } |
1 | 709 | static int http_server(struct sockaddr_in my_addr) { int server_fd, tmp, ret; struct sockaddr_in from_addr; struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 1], *poll_entry; HTTPContext *c, **cp; long cur_time; server_fd = socket(AF_INET,SOCK_STREAM,0); if (server_fd < 0) { perror ("socket"); return -1; } tmp = 1; setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp)); if (bind (server_fd, (struct sockaddr *) &my_addr, sizeof (my_addr)) < 0) { perror ("bind"); close(server_fd); return -1; } if (listen (server_fd, 5) < 0) { perror ("listen"); close(server_fd); return -1; } http_log("ffserver started.\n"); start_children(first_feed); fcntl(server_fd, F_SETFL, O_NONBLOCK); first_http_ctx = NULL; nb_connections = 0; first_http_ctx = NULL; for(;;) { poll_entry = poll_table; poll_entry->fd = server_fd; poll_entry->events = POLLIN; poll_entry++; /* wait for events on each HTTP handle */ c = first_http_ctx; while (c != NULL) { int fd; fd = c->fd; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_SEND_HEADER: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_TRAILER: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLOUT; poll_entry++; break; case HTTPSTATE_RECEIVE_DATA: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_WAIT_FEED: /* need to catch errors */ c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN;/* Maybe this will work */ poll_entry++; break; default: c->poll_entry = NULL; break; } c = c->next; } /* wait for an event on one connection. We poll at least every second to handle timeouts */ do { ret = poll(poll_table, poll_entry - poll_table, 1000); } while (ret == -1); cur_time = gettime_ms(); /* now handle the events */ cp = &first_http_ctx; while ((*cp) != NULL) { c = *cp; if (handle_http (c, cur_time) < 0) { /* close and free the connection */ log_connection(c); close(c->fd); if (c->fmt_in) av_close_input_file(c->fmt_in); *cp = c->next; nb_bandwidth -= c->bandwidth; av_free(c->buffer); av_free(c->pbuffer); av_free(c); nb_connections--; } else { cp = &c->next; } } /* new connection request ? */ poll_entry = poll_table; if (poll_entry->revents & POLLIN) { int fd, len; len = sizeof(from_addr); fd = accept(server_fd, (struct sockaddr *)&from_addr, &len); if (fd >= 0) { fcntl(fd, F_SETFL, O_NONBLOCK); /* XXX: should output a warning page when coming close to the connection limit */ if (nb_connections >= nb_max_connections) { c = NULL; } else { /* add a new connection */ c = av_mallocz(sizeof(HTTPContext)); if (c) { c->next = first_http_ctx; first_http_ctx = c; c->fd = fd; c->poll_entry = NULL; c->from_addr = from_addr; c->state = HTTPSTATE_WAIT_REQUEST; c->buffer = av_malloc(c->buffer_size = IOBUFFER_INIT_SIZE); c->pbuffer = av_malloc(c->pbuffer_size = PBUFFER_INIT_SIZE); if (!c->buffer || !c->pbuffer) { av_free(c->buffer); av_free(c->pbuffer); av_freep(&c); } else { c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + c->buffer_size; c->timeout = cur_time + REQUEST_TIMEOUT; c->start_time = cur_time; nb_connections++; } } } if (!c) { close(fd); } } } poll_entry++; } } |
1 | 711 | int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { uint8_t t[sizeof(diag_501)]; if (cpu_memory_rw_debug(cs, bp->pc, t, sizeof(diag_501), 0)) { return -EINVAL; } else if (memcmp(t, diag_501, sizeof(diag_501))) { return -EINVAL; } else if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, sizeof(diag_501), 1)) { return -EINVAL; } return 0; } |
1 | 714 | static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) { unsigned int i, j; unsigned long page_number, addr, addr1, c; unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; /* * bitmap-traveling is faster than memory-traveling (for addr...) * especially when most of the memory is not dirty. */ for (i = 0; i < len; i++) { if (bitmap[i] != 0) { c = leul_to_cpu(bitmap[i]); do { j = ffsl(c) - 1; c &= ~(1ul << j); page_number = i * HOST_LONG_BITS + j; addr1 = page_number * TARGET_PAGE_SIZE; addr = section->offset_within_region + addr1; memory_region_set_dirty(section->mr, addr); } while (c != 0); } } return 0; } |
1 | 715 | static int ppc_hash64_pte_prot(PowerPCCPU *cpu, ppc_slb_t *slb, ppc_hash_pte64_t pte) { CPUPPCState *env = &cpu->env; unsigned pp, key; /* Some pp bit combinations have undefined behaviour, so default * to no access in those cases */ int prot = 0; key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP) : (slb->vsid & SLB_VSID_KS)); pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61); if (key == 0) { switch (pp) { case 0x0: case 0x1: case 0x2: prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; case 0x3: case 0x6: prot = PAGE_READ | PAGE_EXEC; break; } } else { switch (pp) { case 0x0: case 0x6: break; case 0x1: case 0x3: prot = PAGE_READ | PAGE_EXEC; break; case 0x2: prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; } } /* No execute if either noexec or guarded bits set */ if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G) || (slb->vsid & SLB_VSID_N)) { prot |= PAGE_EXEC; } return prot; } |
1 | 716 | static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size) { int num_strips, strip, h, i, y, size, temp_size, best_size; AVPicture last_pict, pict, scratch_pict; int64_t best_score = 0, score, score_temp; //TODO: support encoding zero strips (meaning skip the whole frame) for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) { score = 0; size = 0; h = s->h / num_strips; //make h into next multiple of 4 h += 4 - (h & 3); for(strip = 0; strip < num_strips; strip++) { y = strip*h; get_sub_picture(s, 0, y, (AVPicture*)frame, &pict); get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame, &last_pict); get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict); if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0) return temp_size; score += score_temp; size += temp_size; } if(best_score == 0 || score < best_score) { best_score = score; best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size); av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size); FFSWAP(AVFrame, s->best_frame, s->scratch_frame); } } memcpy(buf, s->frame_buf, best_size); return best_size; } |
1 | 717 | void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) { int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size); if (s->HEVClc->tu.cu_qp_delta != 0) { int off = s->sps->qp_bd_offset; s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off; } else s->HEVClc->qp_y = qp_y; } |
1 | 718 | static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->vmsd = &sdhci_vmstate; dc->props = sdhci_sysbus_properties; dc->realize = sdhci_sysbus_realize; dc->reset = sdhci_poweron_reset; } |
1 | 719 | grlib_gptimer_writel(void *opaque, target_phys_addr_t addr, uint32_t value) { GPTimerUnit *unit = opaque; target_phys_addr_t timer_addr; int id; addr &= 0xff; /* Unit registers */ switch (addr) { case SCALER_OFFSET: value &= 0xFFFF; /* clean up the value */ unit->scaler = value; trace_grlib_gptimer_writel(-1, "scaler:", unit->scaler); return; case SCALER_RELOAD_OFFSET: value &= 0xFFFF; /* clean up the value */ unit->reload = value; trace_grlib_gptimer_writel(-1, "reload:", unit->reload); grlib_gptimer_set_scaler(unit, value); return; case CONFIG_OFFSET: /* Read Only (disable timer freeze not supported) */ trace_grlib_gptimer_writel(-1, "config (Read Only):", 0); return; default: break; } timer_addr = (addr % TIMER_BASE); id = (addr - TIMER_BASE) / TIMER_BASE; if (id >= 0 && id < unit->nr_timers) { /* GPTimer registers */ switch (timer_addr) { case COUNTER_OFFSET: trace_grlib_gptimer_writel(id, "counter:", value); unit->timers[id].counter = value; grlib_gptimer_enable(&unit->timers[id]); return; case COUNTER_RELOAD_OFFSET: trace_grlib_gptimer_writel(id, "reload:", value); unit->timers[id].reload = value; return; case CONFIG_OFFSET: trace_grlib_gptimer_writel(id, "config:", value); if (value & GPTIMER_INT_PENDING) { /* clear pending bit */ value &= ~GPTIMER_INT_PENDING; } else { /* keep pending bit */ value |= unit->timers[id].config & GPTIMER_INT_PENDING; } unit->timers[id].config = value; /* gptimer_restart calls gptimer_enable, so if "enable" and "load" bits are present, we just have to call restart. */ if (value & GPTIMER_LOAD) { grlib_gptimer_restart(&unit->timers[id]); } else if (value & GPTIMER_ENABLE) { grlib_gptimer_enable(&unit->timers[id]); } /* These fields must always be read as 0 */ value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); unit->timers[id].config = value; return; default: break; } } trace_grlib_gptimer_unknown_register("write", addr); } |
1 | 720 | static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) { CPUState *cpu = current_cpu; CPUClass *cc = CPU_GET_CLASS(cpu); CPUArchState *env = cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; uint32_t cpu_flags; if (cpu->watchpoint_hit) { /* We re-entered the check after replacing the TB. Now raise * the debug interrupt so that is will trigger after the * current instruction. */ cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; vaddr = cc->adjust_watchpoint_address(cpu, vaddr, len); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) && (wp->flags & flags)) { if (flags == BP_MEM_READ) { wp->flags |= BP_WATCHPOINT_HIT_READ; } else { wp->flags |= BP_WATCHPOINT_HIT_WRITE; } wp->hitaddr = vaddr; wp->hitattrs = attrs; if (!cpu->watchpoint_hit) { if (wp->flags & BP_CPU && !cc->debug_check_watchpoint(cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT; continue; } cpu->watchpoint_hit = wp; /* The tb_lock will be reset when cpu_loop_exit or * cpu_loop_exit_noexc longjmp back into the cpu_exec * main loop. */ tb_lock(); tb_check_watchpoint(cpu); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); tb_gen_code(cpu, pc, cs_base, cpu_flags, 1); cpu_loop_exit_noexc(cpu); } } } else { wp->flags &= ~BP_WATCHPOINT_HIT; } } } |
1 | 721 | DISAS_INSN(shift_im) { TCGv reg; int tmp; TCGv shift; set_cc_op(s, CC_OP_FLAGS); reg = DREG(insn, 0); tmp = (insn >> 9) & 7; if (tmp == 0) tmp = 8; shift = tcg_const_i32(tmp); /* No need to flush flags becuse we know we will set C flag. */ if (insn & 0x100) { gen_helper_shl_cc(reg, cpu_env, reg, shift); } else { if (insn & 8) { gen_helper_shr_cc(reg, cpu_env, reg, shift); } else { gen_helper_sar_cc(reg, cpu_env, reg, shift); } } } |
1 | 722 | static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUPPCState *env = &cpu->env; target_ulong flags = args[0]; target_ulong pte_index = args[1]; target_ulong avpn = args[2]; uint64_t token; target_ulong v, r, rb; if (!valid_pte_index(env, pte_index)) { return H_PARAMETER; } token = ppc_hash64_start_access(cpu, pte_index); v = ppc_hash64_load_hpte0(cpu, token, 0); r = ppc_hash64_load_hpte1(cpu, token, 0); ppc_hash64_stop_access(token); if ((v & HPTE64_V_VALID) == 0 || ((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) { return H_NOT_FOUND; } r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_HI | HPTE64_R_KEY_LO); r |= (flags << 55) & HPTE64_R_PP0; r |= (flags << 48) & HPTE64_R_KEY_HI; r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO); rb = compute_tlbie_rb(v, r, pte_index); ppc_hash64_store_hpte(cpu, pte_index, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY, 0); ppc_tlb_invalidate_one(env, rb); /* Don't need a memory barrier, due to qemu's global lock */ ppc_hash64_store_hpte(cpu, pte_index, v | HPTE64_V_HPTE_DIRTY, r); return H_SUCCESS; } |
1 | 723 | static int kvm_get_msrs(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_msr_entry *msrs = cpu->kvm_msr_buf->entries; int ret, i; uint64_t mtrr_top_bits; kvm_msr_buf_reset(cpu); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_CS, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_ESP, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_EIP, 0); kvm_msr_entry_add(cpu, MSR_PAT, 0); if (has_msr_star) { kvm_msr_entry_add(cpu, MSR_STAR, 0); } if (has_msr_hsave_pa) { kvm_msr_entry_add(cpu, MSR_VM_HSAVE_PA, 0); } if (has_msr_tsc_aux) { kvm_msr_entry_add(cpu, MSR_TSC_AUX, 0); } if (has_msr_tsc_adjust) { kvm_msr_entry_add(cpu, MSR_TSC_ADJUST, 0); } if (has_msr_tsc_deadline) { kvm_msr_entry_add(cpu, MSR_IA32_TSCDEADLINE, 0); } if (has_msr_misc_enable) { kvm_msr_entry_add(cpu, MSR_IA32_MISC_ENABLE, 0); } if (has_msr_smbase) { kvm_msr_entry_add(cpu, MSR_IA32_SMBASE, 0); } if (has_msr_feature_control) { kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL, 0); } if (has_msr_bndcfgs) { kvm_msr_entry_add(cpu, MSR_IA32_BNDCFGS, 0); } if (has_msr_xss) { kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0); } if (!env->tsc_valid) { kvm_msr_entry_add(cpu, MSR_IA32_TSC, 0); env->tsc_valid = !runstate_is_running(); } #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_add(cpu, MSR_CSTAR, 0); kvm_msr_entry_add(cpu, MSR_KERNELGSBASE, 0); kvm_msr_entry_add(cpu, MSR_FMASK, 0); kvm_msr_entry_add(cpu, MSR_LSTAR, 0); } #endif kvm_msr_entry_add(cpu, MSR_KVM_SYSTEM_TIME, 0); kvm_msr_entry_add(cpu, MSR_KVM_WALL_CLOCK, 0); if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) { kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) { kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, 0); } if (has_msr_architectural_pmu) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); for (i = 0; i < MAX_FIXED_COUNTERS; i++) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i, 0); } for (i = 0; i < num_architectural_pmu_counters; i++) { kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i, 0); kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i, 0); } } if (env->mcg_cap) { kvm_msr_entry_add(cpu, MSR_MCG_STATUS, 0); kvm_msr_entry_add(cpu, MSR_MCG_CTL, 0); if (has_msr_mcg_ext_ctl) { kvm_msr_entry_add(cpu, MSR_MCG_EXT_CTL, 0); } for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) { kvm_msr_entry_add(cpu, MSR_MC0_CTL + i, 0); } } if (has_msr_hv_hypercall) { kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID, 0); } if (cpu->hyperv_vapic) { kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE, 0); } if (cpu->hyperv_time) { kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, 0); } if (has_msr_hv_crash) { int j; for (j = 0; j < HV_CRASH_PARAMS; j++) { kvm_msr_entry_add(cpu, HV_X64_MSR_CRASH_P0 + j, 0); } } if (has_msr_hv_runtime) { kvm_msr_entry_add(cpu, HV_X64_MSR_VP_RUNTIME, 0); } if (cpu->hyperv_synic) { uint32_t msr; kvm_msr_entry_add(cpu, HV_X64_MSR_SCONTROL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIEFP, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIMP, 0); for (msr = HV_X64_MSR_SINT0; msr <= HV_X64_MSR_SINT15; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (has_msr_hv_stimer) { uint32_t msr; for (msr = HV_X64_MSR_STIMER0_CONFIG; msr <= HV_X64_MSR_STIMER3_COUNT; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (env->features[FEAT_1_EDX] & CPUID_MTRR) { kvm_msr_entry_add(cpu, MSR_MTRRdefType, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix64K_00000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_80000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_A0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F8000, 0); for (i = 0; i < MSR_MTRRcap_VCNT; i++) { kvm_msr_entry_add(cpu, MSR_MTRRphysBase(i), 0); kvm_msr_entry_add(cpu, MSR_MTRRphysMask(i), 0); } } ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, cpu->kvm_msr_buf); if (ret < 0) { return ret; } if (ret < cpu->kvm_msr_buf->nmsrs) { struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret]; error_report("error: failed to get MSR 0x%" PRIx32, (uint32_t)e->index); } assert(ret == cpu->kvm_msr_buf->nmsrs); /* * MTRR masks: Each mask consists of 5 parts * a 10..0: must be zero * b 11 : valid bit * c n-1.12: actual mask bits * d 51..n: reserved must be zero * e 63.52: reserved must be zero * * 'n' is the number of physical bits supported by the CPU and is * apparently always <= 52. We know our 'n' but don't know what * the destinations 'n' is; it might be smaller, in which case * it masks (c) on loading. It might be larger, in which case * we fill 'd' so that d..c is consistent irrespetive of the 'n' * we're migrating to. */ if (cpu->fill_mtrr_mask) { QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 52); assert(cpu->phys_bits <= TARGET_PHYS_ADDR_SPACE_BITS); mtrr_top_bits = MAKE_64BIT_MASK(cpu->phys_bits, 52 - cpu->phys_bits); } else { mtrr_top_bits = 0; } for (i = 0; i < ret; i++) { uint32_t index = msrs[i].index; switch (index) { case MSR_IA32_SYSENTER_CS: env->sysenter_cs = msrs[i].data; break; case MSR_IA32_SYSENTER_ESP: env->sysenter_esp = msrs[i].data; break; case MSR_IA32_SYSENTER_EIP: env->sysenter_eip = msrs[i].data; break; case MSR_PAT: env->pat = msrs[i].data; break; case MSR_STAR: env->star = msrs[i].data; break; #ifdef TARGET_X86_64 case MSR_CSTAR: env->cstar = msrs[i].data; break; case MSR_KERNELGSBASE: env->kernelgsbase = msrs[i].data; break; case MSR_FMASK: env->fmask = msrs[i].data; break; case MSR_LSTAR: env->lstar = msrs[i].data; break; #endif case MSR_IA32_TSC: env->tsc = msrs[i].data; break; case MSR_TSC_AUX: env->tsc_aux = msrs[i].data; break; case MSR_TSC_ADJUST: env->tsc_adjust = msrs[i].data; break; case MSR_IA32_TSCDEADLINE: env->tsc_deadline = msrs[i].data; break; case MSR_VM_HSAVE_PA: env->vm_hsave = msrs[i].data; break; case MSR_KVM_SYSTEM_TIME: env->system_time_msr = msrs[i].data; break; case MSR_KVM_WALL_CLOCK: env->wall_clock_msr = msrs[i].data; break; case MSR_MCG_STATUS: env->mcg_status = msrs[i].data; break; case MSR_MCG_CTL: env->mcg_ctl = msrs[i].data; break; case MSR_MCG_EXT_CTL: env->mcg_ext_ctl = msrs[i].data; break; case MSR_IA32_MISC_ENABLE: env->msr_ia32_misc_enable = msrs[i].data; break; case MSR_IA32_SMBASE: env->smbase = msrs[i].data; break; case MSR_IA32_FEATURE_CONTROL: env->msr_ia32_feature_control = msrs[i].data; break; case MSR_IA32_BNDCFGS: env->msr_bndcfgs = msrs[i].data; break; case MSR_IA32_XSS: env->xss = msrs[i].data; break; default: if (msrs[i].index >= MSR_MC0_CTL && msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { env->mce_banks[msrs[i].index - MSR_MC0_CTL] = msrs[i].data; } break; case MSR_KVM_ASYNC_PF_EN: env->async_pf_en_msr = msrs[i].data; break; case MSR_KVM_PV_EOI_EN: env->pv_eoi_en_msr = msrs[i].data; break; case MSR_KVM_STEAL_TIME: env->steal_time_msr = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR_CTRL: env->msr_fixed_ctr_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_CTRL: env->msr_global_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_STATUS: env->msr_global_status = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_OVF_CTRL: env->msr_global_ovf_ctrl = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR0 ... MSR_CORE_PERF_FIXED_CTR0 + MAX_FIXED_COUNTERS - 1: env->msr_fixed_counters[index - MSR_CORE_PERF_FIXED_CTR0] = msrs[i].data; break; case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR0 + MAX_GP_COUNTERS - 1: env->msr_gp_counters[index - MSR_P6_PERFCTR0] = msrs[i].data; break; case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1: env->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = msrs[i].data; break; case HV_X64_MSR_HYPERCALL: env->msr_hv_hypercall = msrs[i].data; break; case HV_X64_MSR_GUEST_OS_ID: env->msr_hv_guest_os_id = msrs[i].data; break; case HV_X64_MSR_APIC_ASSIST_PAGE: env->msr_hv_vapic = msrs[i].data; break; case HV_X64_MSR_REFERENCE_TSC: env->msr_hv_tsc = msrs[i].data; break; case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4: env->msr_hv_crash_params[index - HV_X64_MSR_CRASH_P0] = msrs[i].data; break; case HV_X64_MSR_VP_RUNTIME: env->msr_hv_runtime = msrs[i].data; break; case HV_X64_MSR_SCONTROL: env->msr_hv_synic_control = msrs[i].data; break; case HV_X64_MSR_SIEFP: env->msr_hv_synic_evt_page = msrs[i].data; break; case HV_X64_MSR_SIMP: env->msr_hv_synic_msg_page = msrs[i].data; break; case HV_X64_MSR_SINT0 ... HV_X64_MSR_SINT15: env->msr_hv_synic_sint[index - HV_X64_MSR_SINT0] = msrs[i].data; break; case HV_X64_MSR_STIMER0_CONFIG: case HV_X64_MSR_STIMER1_CONFIG: case HV_X64_MSR_STIMER2_CONFIG: case HV_X64_MSR_STIMER3_CONFIG: env->msr_hv_stimer_config[(index - HV_X64_MSR_STIMER0_CONFIG)/2] = msrs[i].data; break; case HV_X64_MSR_STIMER0_COUNT: case HV_X64_MSR_STIMER1_COUNT: case HV_X64_MSR_STIMER2_COUNT: case HV_X64_MSR_STIMER3_COUNT: env->msr_hv_stimer_count[(index - HV_X64_MSR_STIMER0_COUNT)/2] = msrs[i].data; break; case MSR_MTRRdefType: env->mtrr_deftype = msrs[i].data; break; case MSR_MTRRfix64K_00000: env->mtrr_fixed[0] = msrs[i].data; break; case MSR_MTRRfix16K_80000: env->mtrr_fixed[1] = msrs[i].data; break; case MSR_MTRRfix16K_A0000: env->mtrr_fixed[2] = msrs[i].data; break; case MSR_MTRRfix4K_C0000: env->mtrr_fixed[3] = msrs[i].data; break; case MSR_MTRRfix4K_C8000: env->mtrr_fixed[4] = msrs[i].data; break; case MSR_MTRRfix4K_D0000: env->mtrr_fixed[5] = msrs[i].data; break; case MSR_MTRRfix4K_D8000: env->mtrr_fixed[6] = msrs[i].data; break; case MSR_MTRRfix4K_E0000: env->mtrr_fixed[7] = msrs[i].data; break; case MSR_MTRRfix4K_E8000: env->mtrr_fixed[8] = msrs[i].data; break; case MSR_MTRRfix4K_F0000: env->mtrr_fixed[9] = msrs[i].data; break; case MSR_MTRRfix4K_F8000: env->mtrr_fixed[10] = msrs[i].data; break; case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1): if (index & 1) { env->mtrr_var[MSR_MTRRphysIndex(index)].mask = msrs[i].data | mtrr_top_bits; } else { env->mtrr_var[MSR_MTRRphysIndex(index)].base = msrs[i].data; } break; } } return 0; } |
1 | 724 | static void blk_mig_unlock(void) { qemu_mutex_unlock(&block_mig_state.lock); } |
1 | 725 | static void do_tb_flush(CPUState *cpu, void *data) { unsigned tb_flush_req = (unsigned) (uintptr_t) data; tb_lock(); /* If it's already been done on request of another CPU, * just retry. */ if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_req) { goto done; } #if defined(DEBUG_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer), tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ? ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) / tcg_ctx.tb_ctx.nb_tbs : 0); #endif if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) > tcg_ctx.code_gen_buffer_size) { cpu_abort(cpu, "Internal error: code buffer overflow\n"); } CPU_FOREACH(cpu) { int i; for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) { atomic_set(&cpu->tb_jmp_cache[i], NULL); } } tcg_ctx.tb_ctx.nb_tbs = 0; qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer; /* XXX: flush processor icache at this point if cache flush is expensive */ atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count, tcg_ctx.tb_ctx.tb_flush_count + 1); done: tb_unlock(); } |
1 | 726 | static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns) { uint16_t insns[5]; int ld_adr, ld_dst, ld_mop; int op_dst, op_src, op_opc; int mv_src, mt_dst, st_src, st_mop; TCGv op_arg; uint32_t pc = ctx->pc; uint32_t pc_end = ctx->tb->cs_base; int backup = sextract32(ctx->tbflags, GUSA_SHIFT, 8); int max_insns = (pc_end - pc) / 2; int i; if (pc != pc_end + backup || max_insns < 2) { /* This is a malformed gUSA region. Don't do anything special, since the interpreter is likely to get confused. */ ctx->envflags &= ~GUSA_MASK; return 0; } if (ctx->tbflags & GUSA_EXCLUSIVE) { /* Regardless of single-stepping or the end of the page, we must complete execution of the gUSA region while holding the exclusive lock. */ *pmax_insns = max_insns; return 0; } /* The state machine below will consume only a few insns. If there are more than that in a region, fail now. */ if (max_insns > ARRAY_SIZE(insns)) { goto fail; } /* Read all of the insns for the region. */ for (i = 0; i < max_insns; ++i) { insns[i] = cpu_lduw_code(env, pc + i * 2); } ld_adr = ld_dst = ld_mop = -1; mv_src = -1; op_dst = op_src = op_opc = -1; mt_dst = -1; st_src = st_mop = -1; TCGV_UNUSED(op_arg); i = 0; #define NEXT_INSN \ do { if (i >= max_insns) goto fail; ctx->opcode = insns[i++]; } while (0) /* * Expect a load to begin the region. */ NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x6000: /* mov.b @Rm,Rn */ ld_mop = MO_SB; break; case 0x6001: /* mov.w @Rm,Rn */ ld_mop = MO_TESW; break; case 0x6002: /* mov.l @Rm,Rn */ ld_mop = MO_TESL; break; default: goto fail; } ld_adr = B7_4; ld_dst = B11_8; if (ld_adr == ld_dst) { goto fail; } /* Unless we see a mov, any two-operand operation must use ld_dst. */ op_dst = ld_dst; /* * Expect an optional register move. */ NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x6003: /* mov Rm,Rn */ /* Here we want to recognize ld_dst being saved for later consumtion, or for another input register being copied so that ld_dst need not be clobbered during the operation. */ op_dst = B11_8; mv_src = B7_4; if (op_dst == ld_dst) { /* Overwriting the load output. */ goto fail; } if (mv_src != ld_dst) { /* Copying a new input; constrain op_src to match the load. */ op_src = ld_dst; } break; default: /* Put back and re-examine as operation. */ --i; } /* * Expect the operation. */ NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x300c: /* add Rm,Rn */ op_opc = INDEX_op_add_i32; goto do_reg_op; case 0x2009: /* and Rm,Rn */ op_opc = INDEX_op_and_i32; goto do_reg_op; case 0x200a: /* xor Rm,Rn */ op_opc = INDEX_op_xor_i32; goto do_reg_op; case 0x200b: /* or Rm,Rn */ op_opc = INDEX_op_or_i32; do_reg_op: /* The operation register should be as expected, and the other input cannot depend on the load. */ if (op_dst != B11_8) { goto fail; } if (op_src < 0) { /* Unconstrainted input. */ op_src = B7_4; } else if (op_src == B7_4) { /* Constrained input matched load. All operations are commutative; "swap" them by "moving" the load output to the (implicit) first argument and the move source to the (explicit) second argument. */ op_src = mv_src; } else { goto fail; } op_arg = REG(op_src); break; case 0x6007: /* not Rm,Rn */ if (ld_dst != B7_4 || mv_src >= 0) { goto fail; } op_dst = B11_8; op_opc = INDEX_op_xor_i32; op_arg = tcg_const_i32(-1); break; case 0x7000 ... 0x700f: /* add #imm,Rn */ if (op_dst != B11_8 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_add_i32; op_arg = tcg_const_i32(B7_0s); break; case 0x3000: /* cmp/eq Rm,Rn */ /* Looking for the middle of a compare-and-swap sequence, beginning with the compare. Operands can be either order, but with only one overlapping the load. */ if ((ld_dst == B11_8) + (ld_dst == B7_4) != 1 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_setcond_i32; /* placeholder */ op_src = (ld_dst == B11_8 ? B7_4 : B11_8); op_arg = REG(op_src); NEXT_INSN; switch (ctx->opcode & 0xff00) { case 0x8b00: /* bf label */ case 0x8f00: /* bf/s label */ if (pc + (i + 1 + B7_0s) * 2 != pc_end) { goto fail; } if ((ctx->opcode & 0xff00) == 0x8b00) { /* bf label */ break; } /* We're looking to unconditionally modify Rn with the result of the comparison, within the delay slot of the branch. This is used by older gcc. */ NEXT_INSN; if ((ctx->opcode & 0xf0ff) == 0x0029) { /* movt Rn */ mt_dst = B11_8; } else { goto fail; } break; default: goto fail; } break; case 0x2008: /* tst Rm,Rn */ /* Looking for a compare-and-swap against zero. */ if (ld_dst != B11_8 || ld_dst != B7_4 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_setcond_i32; op_arg = tcg_const_i32(0); NEXT_INSN; if ((ctx->opcode & 0xff00) != 0x8900 /* bt label */ || pc + (i + 1 + B7_0s) * 2 != pc_end) { goto fail; } break; default: /* Put back and re-examine as store. */ --i; } /* * Expect the store. */ /* The store must be the last insn. */ if (i != max_insns - 1) { goto fail; } NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x2000: /* mov.b Rm,@Rn */ st_mop = MO_UB; break; case 0x2001: /* mov.w Rm,@Rn */ st_mop = MO_UW; break; case 0x2002: /* mov.l Rm,@Rn */ st_mop = MO_UL; break; default: goto fail; } /* The store must match the load. */ if (ld_adr != B11_8 || st_mop != (ld_mop & MO_SIZE)) { goto fail; } st_src = B7_4; #undef NEXT_INSN /* * Emit the operation. */ tcg_gen_insn_start(pc, ctx->envflags); switch (op_opc) { case -1: /* No operation found. Look for exchange pattern. */ if (st_src == ld_dst || mv_src >= 0) { goto fail; } tcg_gen_atomic_xchg_i32(REG(ld_dst), REG(ld_adr), REG(st_src), ctx->memidx, ld_mop); break; case INDEX_op_add_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst && st_mop == MO_UL) { tcg_gen_atomic_add_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_add_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); if (op_dst != ld_dst) { /* Note that mop sizes < 4 cannot use add_fetch because it won't carry into the higher bits. */ tcg_gen_add_i32(REG(op_dst), REG(ld_dst), op_arg); } } break; case INDEX_op_and_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_and_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_and_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_and_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_or_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_or_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_or_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_or_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_xor_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_xor_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_xor_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_xor_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_setcond_i32: if (st_src == ld_dst) { goto fail; } tcg_gen_atomic_cmpxchg_i32(REG(ld_dst), REG(ld_adr), op_arg, REG(st_src), ctx->memidx, ld_mop); tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(ld_dst), op_arg); if (mt_dst >= 0) { tcg_gen_mov_i32(REG(mt_dst), cpu_sr_t); } break; default: g_assert_not_reached(); } /* If op_src is not a valid register, then op_arg was a constant. */ if (op_src < 0) { tcg_temp_free_i32(op_arg); } /* The entire region has been translated. */ ctx->envflags &= ~GUSA_MASK; ctx->pc = pc_end; return max_insns; fail: qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n", pc, pc_end); /* Restart with the EXCLUSIVE bit set, within a TB run via cpu_exec_step_atomic holding the exclusive lock. */ tcg_gen_insn_start(pc, ctx->envflags); ctx->envflags |= GUSA_EXCLUSIVE; gen_save_cpu_state(ctx, false); gen_helper_exclusive(cpu_env); ctx->bstate = BS_EXCP; /* We're not executing an instruction, but we must report one for the purposes of accounting within the TB. We might as well report the entire region consumed via ctx->pc so that it's immediately available in the disassembly dump. */ ctx->pc = pc_end; return 1; } |
1 | 727 | static int yop_read_header(AVFormatContext *s) { YopDecContext *yop = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *audio_dec, *video_dec; AVStream *audio_stream, *video_stream; int frame_rate, ret; audio_stream = avformat_new_stream(s, NULL); video_stream = avformat_new_stream(s, NULL); // Extra data that will be passed to the decoder video_stream->codec->extradata_size = 8; video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!video_stream->codec->extradata) // Audio audio_dec = audio_stream->codec; audio_dec->codec_type = AVMEDIA_TYPE_AUDIO; audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC; audio_dec->channels = 1; audio_dec->sample_rate = 22050; // Video video_dec = video_stream->codec; video_dec->codec_type = AVMEDIA_TYPE_VIDEO; video_dec->codec_id = AV_CODEC_ID_YOP; avio_skip(pb, 6); frame_rate = avio_r8(pb); yop->frame_size = avio_r8(pb) * 2048; video_dec->width = avio_rl16(pb); video_dec->height = avio_rl16(pb); video_stream->sample_aspect_ratio = (AVRational){1, 2}; ret = avio_read(pb, video_dec->extradata, 8); if (ret < 8) return ret < 0 ? ret : AVERROR_EOF; yop->palette_size = video_dec->extradata[0] * 3 + 4; yop->audio_block_length = AV_RL16(video_dec->extradata + 6); // 1840 samples per frame, 1 nibble per sample; hence 1840/2 = 920 if (yop->audio_block_length < 920 || yop->audio_block_length + yop->palette_size >= yop->frame_size) { av_log(s, AV_LOG_ERROR, "YOP has invalid header\n"); return AVERROR_INVALIDDATA; } avio_seek(pb, 2048, SEEK_SET); avpriv_set_pts_info(video_stream, 32, 1, frame_rate); return 0; } |
1 | 728 | int64_t bdrv_get_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .base = base, .file = file, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_get_block_status_above_co_entry(&data); } else { AioContext *aio_context = bdrv_get_aio_context(bs); co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { aio_poll(aio_context, true); } } return data.ret; } |
1 | 730 | static int add_string_metadata(int count, const char *name, TiffContext *s) { char *value; if (bytestream2_get_bytes_left(&s->gb) < count || count < 0) return AVERROR_INVALIDDATA; value = av_malloc(count + 1); if (!value) return AVERROR(ENOMEM); bytestream2_get_bufferu(&s->gb, value, count); value[count] = 0; av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, value, AV_DICT_DONT_STRDUP_VAL); return 0; } |
1 | 731 | static void pc_q35_init_1_6(QEMUMachineInitArgs *args) { has_pci_info = false; pc_q35_init(args); } |
0 | 732 | static void dvbsub_parse_clut_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int i, clut_id; DVBSubCLUT *clut; int entry_id, depth , full_range; int y, cr, cb, alpha; int r, g, b, r_add, g_add, b_add; av_dlog(avctx, "DVB clut packet:\n"); for (i=0; i < buf_size; i++) { av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) av_dlog(avctx, "\n"); } if (i % 16) av_dlog(avctx, "\n"); clut_id = *buf++; buf += 1; clut = get_clut(ctx, clut_id); if (!clut) { clut = av_malloc(sizeof(DVBSubCLUT)); memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); clut->id = clut_id; clut->next = ctx->clut_list; ctx->clut_list = clut; } while (buf + 4 < buf_end) { entry_id = *buf++; depth = (*buf) & 0xe0; if (depth == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); return; } full_range = (*buf++) & 1; if (full_range) { y = *buf++; cr = *buf++; cb = *buf++; alpha = *buf++; } else { y = buf[0] & 0xfc; cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; cb = (buf[1] << 2) & 0xf0; alpha = (buf[1] << 6) & 0xc0; buf += 2; } if (y == 0) alpha = 0xff; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); if (depth & 0x80) clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); if (depth & 0x40) clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); if (depth & 0x20) clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); } } |
0 | 733 | static void intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, int32_t stride) { uint8_t lp_cnt; uint32_t src0, src1, src2 = 0; uint32_t out0, out1, out2; v16u8 src_top; v8u16 add; v4u32 sum; src_top = LD_UB(src - stride); add = __msa_hadd_u_h(src_top, src_top); sum = __msa_hadd_u_w(add, add); src0 = __msa_copy_u_w((v4i32) sum, 0); src1 = __msa_copy_u_w((v4i32) sum, 1); for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { src2 += src[lp_cnt * stride - 1]; } src2 = (src0 + src2 + 4) >> 3; src0 = (src0 + 2) >> 2; src1 = (src1 + 2) >> 2; out0 = src0 * 0x01010101; out1 = src1 * 0x01010101; out2 = src2 * 0x01010101; for (lp_cnt = 4; lp_cnt--;) { SW(out2, src); SW(out1, src + 4); SW(out0, src + stride * 4); SW(out1, src + stride * 4 + 4); src += stride; } } |
0 | 735 | static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i){ NUTContext *nut = avctx->priv_data; AVCodecContext *codec = st->codec; unsigned codec_tag = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id); ff_put_v(bc, i); switch(codec->codec_type){ case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break; case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break; case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break; default : ff_put_v(bc, 3); break; } ff_put_v(bc, 4); if (!codec_tag) codec_tag = codec->codec_tag; if (codec_tag) { avio_wl32(bc, codec_tag); } else { av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i); return AVERROR(EINVAL); } ff_put_v(bc, nut->stream[i].time_base - nut->time_base); ff_put_v(bc, nut->stream[i].msb_pts_shift); ff_put_v(bc, nut->stream[i].max_pts_distance); ff_put_v(bc, codec->has_b_frames); avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */ ff_put_v(bc, codec->extradata_size); avio_write(bc, codec->extradata, codec->extradata_size); switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, codec->sample_rate); ff_put_v(bc, 1); ff_put_v(bc, codec->channels); break; case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, codec->width); ff_put_v(bc, codec->height); if(st->sample_aspect_ratio.num<=0 || st->sample_aspect_ratio.den<=0){ ff_put_v(bc, 0); ff_put_v(bc, 0); }else{ ff_put_v(bc, st->sample_aspect_ratio.num); ff_put_v(bc, st->sample_aspect_ratio.den); } ff_put_v(bc, 0); /* csp type -- unknown */ break; default: break; } return 0; } |
0 | 736 | SYNTH_FILTER_FUNC(sse2) SYNTH_FILTER_FUNC(avx) SYNTH_FILTER_FUNC(fma3) #endif /* HAVE_YASM */ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s) { #if HAVE_YASM int cpu_flags = av_get_cpu_flags(); #if ARCH_X86_32 if (EXTERNAL_SSE(cpu_flags)) { s->synth_filter_float = synth_filter_sse; } #endif if (EXTERNAL_SSE2(cpu_flags)) { s->synth_filter_float = synth_filter_sse2; } if (EXTERNAL_AVX(cpu_flags)) { s->synth_filter_float = synth_filter_avx; } if (EXTERNAL_FMA3(cpu_flags)) { s->synth_filter_float = synth_filter_fma3; } #endif /* HAVE_YASM */ } |
1 | 737 | static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; struct iscsi_data data; IscsiAIOCB *acb; assert(req == SG_IO); acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; } acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; data.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { data.data = acb->ioh->dxferp; data.size = acb->ioh->dxfer_len; } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else struct iovec *iov = (struct iovec *)acb->ioh->dxferp; acb->buf = g_malloc(acb->ioh->dxfer_len); data.data = acb->buf; data.size = iov_to_buf(iov, acb->ioh->iovec_count, 0, acb->buf, acb->ioh->dxfer_len); #endif } } if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (data.size > 0) ? &data : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); qemu_aio_release(acb); return NULL; } /* tell libiscsi to read straight into the buffer we got from ioctl */ if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else int i; for (i = 0; i < acb->ioh->iovec_count; i++) { struct iovec *iov = (struct iovec *)acb->ioh->dxferp; scsi_task_add_data_in_buffer(acb->task, iov[i].iov_len, iov[i].iov_base); } #endif } } iscsi_set_events(iscsilun); return &acb->common; } |
1 | 738 | static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, DMADirection dir) { dma_addr_t addr; DMADirection expected_dir; if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) { expected_dir = DMA_DIRECTION_FROM_DEVICE; } else { expected_dir = DMA_DIRECTION_TO_DEVICE; } if (dir != expected_dir) { trace_esp_pci_error_invalid_dma_direction(); return; } if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) { qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n"); } addr = pci->dma_regs[DMA_SPA]; if (pci->dma_regs[DMA_WBC] < len) { len = pci->dma_regs[DMA_WBC]; } pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir); /* update status registers */ pci->dma_regs[DMA_WBC] -= len; pci->dma_regs[DMA_WAC] += len; } |
1 | 739 | void qemu_fflush(QEMUFile *f) { ssize_t ret = 0; if (!qemu_file_is_writable(f)) { return; } if (f->ops->writev_buffer) { if (f->iovcnt > 0) { ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos); } } else { if (f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->pos, f->buf_index); } } if (ret >= 0) { f->pos += ret; } f->buf_index = 0; f->iovcnt = 0; if (ret < 0) { qemu_file_set_error(f, ret); } } |