Esempio n. 1
0
bool
int1a_TCG_HashAll (struct TCG_HashAll_input_param_blk *input, void *digest,
		   int digest_len, u32 *return_code)
{
	struct tcgbios_args args;

	copy_input_buffer (input, input->IPBLength);
	args.in_ebx = TCPA;
	args.in_ecx = 0;
	args.in_edx = 0;
	args.in_esi = OUTPUT_PARAM_BLK_ADDR & 0xF;
	args.in_ds = OUTPUT_PARAM_BLK_ADDR >> 4;
	args.in_edi = INPUT_PARAM_BLK_ADDR & 0xF;
	args.in_es = INPUT_PARAM_BLK_ADDR >> 4;
	callrealmode_tcgbios (FUNC_TCG_HashAll, &args);
	*return_code = args.out_eax;
	if (args.out_eax)
		return false;
	copy_output_buffer (digest, digest_len);
	return true;
}
Esempio n. 2
0
long
spu_aac_decode (void **destbuf, void *destend, void **srcbuf, void *srcend,
		struct spu_aac_decode_fmt *format, void *dataout,
		void *datain, int datalen)
{
	long status;
	int need_input, need_output;
	int inbuf_added;
	int endflag;
	int state_decode;
	int state_decode_end, state_decode_really_end;
	int incopy, outcopy;
	unsigned long nblk;
	long err = RSACPDS_RTN_GOOD;
	void *_dataout;
	int _dataoutlen;

once_again:
	need_input = 0;
	need_output = 0;
	inbuf_added = 0;
	if (state.init == 0) {
		if (init2 () < 0)
			return -1;
		state.init = 1;
	}
	pthread_mutex_lock (&transfer_lock);
	while (output_remain <= 0 && outlendata.head != NULL) {
		int *outlen;
		struct spu_aac_decode_fmt *outfmt;
		void *p;
		int tmp;

		datalist_sub (&outlendata, &p, &tmp, 1);
		outlen = p;
		datalist_sub (&outfmtdata, &p, &tmp, 1);
		outfmt = p;
		output_remain += *outlen;
		format_next = *outfmt;
		free (outlen);
		free (outfmt);
	}
	endflag = outbuf_end;
	state_decode_end = state.decode_end;
	state_decode_really_end = state.decode_really_end;
	transfer_flag = 1;
	pthread_mutex_unlock (&transfer_lock);

	outcopy = copy_output_buffer (destbuf, destend, &need_output,
				      &_dataout, &_dataoutlen);
	incopy = copy_input_buffer (srcbuf, srcend, &need_input, &inbuf_added,
				    datain, datalen);
	if (_dataoutlen != 0) {
		if (_dataoutlen > datalen)
			_dataoutlen = datalen;
		memcpy (dataout, _dataout, _dataoutlen);
		free (_dataout);
	}
	*format = format_current;

	if (state.open == 0) {
		state_decode = 0;
		state.decode_end = 0;
		state.decode_really_end = 0;
		state_decode_end = 0;
		state_decode_really_end = 0;
		callbk_err = 0;
		inbuf_end = 0;
		pthread_mutex_lock (&transfer_lock);
		outbuf_end = 0;
		pthread_mutex_unlock (&transfer_lock);
		if (inbuf_added == 0)
			goto unlock_ret;
		if ((err = middleware_open ()) < 0)
			goto ret;
		if ((err = RSACPDS_SetDecOpt(paac, 0)) < RSACPDS_RTN_GOOD) {
			ERR ("RSACPDS_SetDecOpt error");
			goto close_and_ret;
		}
		err = RSACPDS_RTN_GOOD;
		state.first_block = 1;
		state.open = 1;
		need_input = 1;
		need_output = 0;
		output_remain = 0;
	} else {
		state_decode = 1;
		if (state_decode_really_end != 0)
			state_decode = 0;
	}
	status = 0;
	if (state_decode_end != 0) {
		if (state.first_block != 0) {
			state.first_block = 0;
			need_output = 1;
		}
		if (output_remain <= 0) {
			state_decode = 0;
			state.decode_end = 0;
			err = RSACPDS_DecodeStatus (paac, &status);
			if (err < RSACPDS_RTN_GOOD) {
				ERR ("RSACPDS_DecodeStatus error");
				goto close_and_ret;
			}
		}
	}
	if (need_input != 0)
		stream_input_end_cb (0);
	if (need_output != 0)
		pcm_output_end_cb (0, 0);
	if (state_decode == 0 && state_decode_really_end == 0) {
		err = get_header_and_pce (status);
		if (err < 0)
			goto close_and_ret;
		nblk = 0;
		if (format_type == SPU_AAC_DECODE_SETFMT_TYPE_RAW_AAC ||
		    format_type == SPU_AAC_DECODE_SETFMT_TYPE_RAW_AACPLUS)
			nblk = 1;
		if (state.first_block != 0)
			nblk = 1;
		if (RSACPDS_Decode (paac, nblk) < RSACPDS_RTN_GOOD) {
			err = RSACPDS_GetStatusCode (paac);
			ERR ("RSACPDS_Decode error");
			goto close_and_ret;
		}
		state_decode = 1;
	}
	if (inbuf_end == 2 && endflag != 0 && outbuf_copying == NULL &&
	    buflist_poll (&outbuf_used) == NULL) {
		if (decode_end_status != RSACPDS_ERR_DATA_EMPTY)
			ERR ("strange statusCode; ignored");
		err = decoder_close (0);
		state.open = 0;
		goto ret;
	}
	if (callbk_err != 0) {
		err = -1;
		goto close_and_ret;
	}
	if ((inbuf_end != 0 || incopy == 0) && outcopy == 0) {
		pthread_mutex_lock (&transfer_done);
		goto once_again;
	}
	goto unlock_ret;
close_and_ret:
	if (state.decode_end != 0 || state.decode_really_end != 0)
		state_decode = 0;
	decoder_close (state_decode);
	state.open = 0;
ret:
	if (inbuf_copying != NULL) {
		buflist_add (&inbuf_free, inbuf_copying);
		inbuf_copying = NULL;
	}
	if (outbuf_current != NULL) {
		buflist_add (&outbuf_free, outbuf_current);
		outbuf_current = NULL;
	}
	do {
		if (inbuf_current != NULL)
			buflist_add (&inbuf_free, inbuf_current);
		inbuf_current = buflist_pop (&inbuf_used);
	} while (inbuf_current != NULL);
	do {
		if (outbuf_copying != NULL)
			buflist_add (&outbuf_free, outbuf_copying);
		outbuf_copying = buflist_pop (&outbuf_used);
	} while (outbuf_copying != NULL);
	while (indata.head != NULL)
		datalist_sub (&indata, NULL, NULL, indata.head->len);
	while (outdata.head != NULL)
		datalist_sub (&outdata, NULL, NULL, outdata.head->len);
	while (delaydata.head != NULL)
		datalist_sub (&delaydata, NULL, NULL, delaydata.head->len);
unlock_ret:
	pthread_mutex_lock (&transfer_lock);
	if (transfer_flag == 0) {
		pthread_mutex_unlock (&transfer_lock);
		pthread_mutex_lock (&transfer_done);
	} else {
		transfer_flag = 0;
		pthread_mutex_unlock (&transfer_lock);
	}
	return err;
}