static void channel_out_run(struct fs_dma_ctrl *ctrl, int c)

{

	uint32_t len;

	uint32_t saved_data_buf;

	unsigned char buf[2 * 1024];



	if (ctrl->channels[c].eol == 1)

		return;



	saved_data_buf = channel_reg(ctrl, c, RW_SAVED_DATA_BUF);



	D(fprintf(logfile, "ch=%d buf=%x after=%x saved_data_buf=%x\n",

		 c,

		 (uint32_t)ctrl->channels[c].current_d.buf,

		 (uint32_t)ctrl->channels[c].current_d.after,

		 saved_data_buf));



	len = (uint32_t)(unsigned long) ctrl->channels[c].current_d.after;

	len -= saved_data_buf;



	if (len > sizeof buf)

		len = sizeof buf;

	cpu_physical_memory_read (saved_data_buf, buf, len);



	D(printf("channel %d pushes %x %u bytes\n", c, 

		 saved_data_buf, len));



	if (ctrl->channels[c].client->client.push)

		ctrl->channels[c].client->client.push(

			ctrl->channels[c].client->client.opaque, buf, len);

	else

		printf("WARNING: DMA ch%d dataloss, no attached client.\n", c);



	saved_data_buf += len;



	if (saved_data_buf ==

	    (uint32_t)(unsigned long)ctrl->channels[c].current_d.after) {

		/* Done. Step to next.  */

		if (ctrl->channels[c].current_d.out_eop) {

			/* TODO: signal eop to the client.  */

			D(printf("signal eop\n"));

		}

		if (ctrl->channels[c].current_d.intr) {

			/* TODO: signal eop to the client.  */

			/* data intr.  */

			D(printf("signal intr\n"));

			ctrl->channels[c].regs[R_INTR] |= (1 << 2);

			channel_update_irq(ctrl, c);

		}

		if (ctrl->channels[c].current_d.eol) {

			D(printf("channel %d EOL\n", c));

			ctrl->channels[c].eol = 1;



			/* Mark the context as disabled.  */

			ctrl->channels[c].current_c.dis = 1;

			channel_store_c(ctrl, c);



			channel_stop(ctrl, c);

		} else {

			ctrl->channels[c].regs[RW_SAVED_DATA] =

				(uint32_t)(unsigned long) ctrl->channels[c].current_d.next;

			/* Load new descriptor.  */

			channel_load_d(ctrl, c);

			saved_data_buf = (uint32_t)(unsigned long)

				ctrl->channels[c].current_d.buf;

		}



		channel_store_d(ctrl, c);

		ctrl->channels[c].regs[RW_SAVED_DATA_BUF] = saved_data_buf;

		D(dump_d(c, &ctrl->channels[c].current_d));

	}

	ctrl->channels[c].regs[RW_SAVED_DATA_BUF] = saved_data_buf;

}

static void channel_out_run(struct fs_dma_ctrl *ctrl, int c)

{

	uint32_t len;

	uint32_t saved_data_buf;

	unsigned char buf[2 * 1024];



	if (ctrl->channels[c].eol == 1)

		return;



	saved_data_buf = channel_reg(ctrl, c, RW_SAVED_DATA_BUF);



	D(fprintf(logfile, "ch=%d buf=%x after=%x saved_data_buf=%x\n",

		 c,

		 (uint32_t)ctrl->channels[c].current_d.buf,

		 (uint32_t)ctrl->channels[c].current_d.after,

		 saved_data_buf));



	len = (uint32_t)(unsigned long) ctrl->channels[c].current_d.after;

	len -= saved_data_buf;



	if (len > sizeof buf)

		len = sizeof buf;

	cpu_physical_memory_read (saved_data_buf, buf, len);



	D(printf("channel %d pushes %x %u bytes\n", c, 

		 saved_data_buf, len));



	if (ctrl->channels[c].client->client.push)

		ctrl->channels[c].client->client.push(

			ctrl->channels[c].client->client.opaque, buf, len);

	else

		printf("WARNING: DMA ch%d dataloss, no attached client.\n", c);



	saved_data_buf += len;



	if (saved_data_buf ==

	    (uint32_t)(unsigned long)ctrl->channels[c].current_d.after) {

		

		if (ctrl->channels[c].current_d.out_eop) {

			

			D(printf("signal eop\n"));

		}

		if (ctrl->channels[c].current_d.intr) {

			

			

			D(printf("signal intr\n"));

			ctrl->channels[c].regs[R_INTR] |= (1 << 2);

			channel_update_irq(ctrl, c);

		}

		if (ctrl->channels[c].current_d.eol) {

			D(printf("channel %d EOL\n", c));

			ctrl->channels[c].eol = 1;



			

			ctrl->channels[c].current_c.dis = 1;

			channel_store_c(ctrl, c);



			channel_stop(ctrl, c);

		} else {

			ctrl->channels[c].regs[RW_SAVED_DATA] =

				(uint32_t)(unsigned long) ctrl->channels[c].current_d.next;

			

			channel_load_d(ctrl, c);

			saved_data_buf = (uint32_t)(unsigned long)

				ctrl->channels[c].current_d.buf;

		}



		channel_store_d(ctrl, c);

		ctrl->channels[c].regs[RW_SAVED_DATA_BUF] = saved_data_buf;

		D(dump_d(c, &ctrl->channels[c].current_d));

	}

	ctrl->channels[c].regs[RW_SAVED_DATA_BUF] = saved_data_buf;

}

	D(fprintf(logfile, "ch=%d buf=%x after=%x saved_data_buf=%x\n",
static void FUNC_0(struct fs_dma_ctrl *VAR_0, int VAR_1)

{

	uint32_t len;

	uint32_t saved_data_buf;

	unsigned char VAR_2[2 * 1024];



	if (VAR_0->channels[VAR_1].eol == 1)

		return;



	saved_data_buf = channel_reg(VAR_0, VAR_1, RW_SAVED_DATA_BUF);



	D(fprintf(logfile, "ch=%d VAR_2=%x after=%x saved_data_buf=%x\n",

		 VAR_1,

		 (uint32_t)VAR_0->channels[VAR_1].current_d.VAR_2,

		 (uint32_t)VAR_0->channels[VAR_1].current_d.after,

		 saved_data_buf));



	len = (uint32_t)(unsigned long) VAR_0->channels[VAR_1].current_d.after;

	len -= saved_data_buf;



	if (len > sizeof VAR_2)

		len = sizeof VAR_2;

	cpu_physical_memory_read (saved_data_buf, VAR_2, len);



	D(printf("channel %d pushes %x %u bytes\n", VAR_1, 

		 saved_data_buf, len));



	if (VAR_0->channels[VAR_1].client->client.push)

		VAR_0->channels[VAR_1].client->client.push(

			VAR_0->channels[VAR_1].client->client.opaque, VAR_2, len);

	else

		printf("WARNING: DMA ch%d dataloss, no attached client.\n", VAR_1);



	saved_data_buf += len;



	if (saved_data_buf ==

	    (uint32_t)(unsigned long)VAR_0->channels[VAR_1].current_d.after) {

		

		if (VAR_0->channels[VAR_1].current_d.out_eop) {

			

			D(printf("signal eop\n"));

		}

		if (VAR_0->channels[VAR_1].current_d.intr) {

			

			

			D(printf("signal intr\n"));

			VAR_0->channels[VAR_1].regs[R_INTR] |= (1 << 2);

			channel_update_irq(VAR_0, VAR_1);

		}

		if (VAR_0->channels[VAR_1].current_d.eol) {

			D(printf("channel %d EOL\n", VAR_1));

			VAR_0->channels[VAR_1].eol = 1;



			

			VAR_0->channels[VAR_1].current_c.dis = 1;

			channel_store_c(VAR_0, VAR_1);



			channel_stop(VAR_0, VAR_1);

		} else {

			VAR_0->channels[VAR_1].regs[RW_SAVED_DATA] =

				(uint32_t)(unsigned long) VAR_0->channels[VAR_1].current_d.next;

			

			channel_load_d(VAR_0, VAR_1);

			saved_data_buf = (uint32_t)(unsigned long)

				VAR_0->channels[VAR_1].current_d.VAR_2;

		}



		channel_store_d(VAR_0, VAR_1);

		VAR_0->channels[VAR_1].regs[RW_SAVED_DATA_BUF] = saved_data_buf;

		D(dump_d(VAR_1, &VAR_0->channels[VAR_1].current_d));

	}

	VAR_0->channels[VAR_1].regs[RW_SAVED_DATA_BUF] = saved_data_buf;

}

static void FUNC_0(struct fs_dma_ctrl *VAR_0, int VAR_1)
{ uint32_t len; uint32_t saved_data_buf; unsigned char VAR_2[2 * 1024]; if (VAR_0->channels[VAR_1].eol == 1)
return; saved_data_buf = channel_reg(VAR_0, VAR_1, RW_SAVED_DATA_BUF); D(fprintf(logfile, "ch=%d VAR_2=%x after=%x saved_data_buf=%x\n",
VAR_1,
(uint32_t)VAR_0->channels[VAR_1].current_d.VAR_2,
(uint32_t)VAR_0->channels[VAR_1].current_d.after,
saved_data_buf)); len = (uint32_t)(unsigned long) VAR_0->channels[VAR_1].current_d.after; len -= saved_data_buf; if (len > sizeof VAR_2)
len = sizeof VAR_2; cpu_physical_memory_read (saved_data_buf, VAR_2, len); D(printf("channel %d pushes %x %u bytes\n", VAR_1,
saved_data_buf, len)); if (VAR_0->channels[VAR_1].client->client.push)
VAR_0->channels[VAR_1].client->client.push(
VAR_0->channels[VAR_1].client->client.opaque, VAR_2, len); else
printf("WARNING: DMA ch%d dataloss, no attached client.\n", VAR_1); saved_data_buf += len; if (saved_data_buf ==
(uint32_t)(unsigned long)VAR_0->channels[VAR_1].current_d.after) { if (VAR_0->channels[VAR_1].current_d.out_eop) { D(printf("signal eop\n")); } if (VAR_0->channels[VAR_1].current_d.intr) { D(printf("signal intr\n")); VAR_0->channels[VAR_1].regs[R_INTR] |= (1 << 2); channel_update_irq(VAR_0, VAR_1); } if (VAR_0->channels[VAR_1].current_d.eol) { D(printf("channel %d EOL\n", VAR_1)); VAR_0->channels[VAR_1].eol = 1; VAR_0->channels[VAR_1].current_c.dis = 1; channel_store_c(VAR_0, VAR_1); channel_stop(VAR_0, VAR_1); } else { VAR_0->channels[VAR_1].regs[RW_SAVED_DATA] =
(uint32_t)(unsigned long) VAR_0->channels[VAR_1].current_d.next; channel_load_d(VAR_0, VAR_1); saved_data_buf = (uint32_t)(unsigned long)
VAR_0->channels[VAR_1].current_d.VAR_2; } channel_store_d(VAR_0, VAR_1); VAR_0->channels[VAR_1].regs[RW_SAVED_DATA_BUF] = saved_data_buf; D(dump_d(VAR_1, &VAR_0->channels[VAR_1].current_d)); } VAR_0->channels[VAR_1].regs[RW_SAVED_DATA_BUF] = saved_data_buf; }