Ejemplo n.º 1
0
/*-----------------------------------------------------------------------------*
 *  Application entry point
 *-----------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
	void *platform;
	struct rpmsg_device *rpdev;
	int ret;

	LPRINTF("Starting application...\n");

	/* Initialize platform */
	ret = platform_init(argc, argv, &platform);
	if (ret) {
		LPERROR("Failed to initialize platform.\n");
		ret = -1;
	} else {
		rpdev = platform_create_rpmsg_vdev(platform, 0,
						   VIRTIO_DEV_SLAVE,
						   NULL, NULL);
		if (!rpdev) {
			LPERROR("Failed to create rpmsg virtio device.\n");
			ret = -1;
		} else {
			app(rpdev, platform);
			platform_release_rpmsg_vdev(rpdev);
			ret = 0;
		}
	}

	LPRINTF("Stopping application...\n");
	platform_cleanup(platform);

	return ret;
}
/* Handler function for dedicated endpoint threads */
static void *
listener_thread_handler_(void *ptr)
{
	CONTAINER_REQUEST *req;
	LISTENER *me;
	int r;
	
	me = (LISTENER *) ptr;
	DPRINTF("endpoint thread is starting");
	pthread_mutex_lock(&(me->mutex));
	me->state = LS_RUNNING;
	for(;;)
	{
		DPRINTF("waiting for activity");
		r = me->endpoint->api->process(me->endpoint);
		if(r == -1)
		{
			LPRINTF(CWLOG_CRIT, "endpoint returned error: %s", strerror(errno));
			break;
		}
		if(!r)
		{
			LPRINTF(CWLOG_INFO, "endpoint terminated normally");
			break;
		}
		DPRINTF("request is ready to be acquired");
		r = me->endpoint->api->acquire(me->endpoint, &req);
		if(r)
		{
			LPRINTF(CWLOG_CRIT, "failed to acquire a request from endpoint: %s", strerror(errno));
			break;
		}
		DPRINTF("request has been acquired and will now be routed");
		route_request(req, me);
		req->api->release(req);
	}
	me->status = LS_ZOMBIE;
	me->status = r;
	me->thread = 0;
	pthread_mutex_unlock(&(me->mutex));
	DPRINTF("endpoint thread is terminating");
	return me;
}
Ejemplo n.º 3
0
int
pushbytes(struct lpt_softc *sc)
{
	int s, error, spin, tic;

	if (sc->sc_flags & LPT_NOINTR) {
		while (sc->sc_count > 0) {
			spin = 0;
			while ((sc->sc_funcs->lf_notrdy) (sc, 0)) {
				if (++spin < sc->sc_spinmax)
					continue;
				tic = 0;
				/* adapt busy-wait algorithm */
				sc->sc_spinmax++;
				while ((sc->sc_funcs->lf_notrdy) (sc, 1)) {
					/* exponential backoff */
					tic = tic + tic + 1;
					if (tic > TIMEOUT)
						tic = TIMEOUT;
					error = tsleep((void *) sc,
					    LPTPRI | PCATCH, "lptpsh", tic);
					if (error != EWOULDBLOCK)
						return (error);
				}
				break;
			}

			(sc->sc_funcs->lf_wrdata) (sc, *sc->sc_cp++);
			sc->sc_count--;

			/* adapt busy-wait algorithm */
			if (spin * 2 + 16 < sc->sc_spinmax)
				sc->sc_spinmax--;
		}
	} else {
		while (sc->sc_count > 0) {
			/* if the printer is ready for a char, give it one */
			if ((sc->sc_state & LPT_OBUSY) == 0) {
				LPRINTF((sc->sc_dev, "write %d\n",
					sc->sc_count));
				s = spltty();
				(void) lpt_intr(sc);
				splx(s);
			}
			error = tsleep((void *) sc, LPTPRI | PCATCH,
			    "lptwrite2", 0);
			if (error)
				return (error);
		}
	}
	return (0);
}
Ejemplo n.º 4
0
/* Register a new container type. The container instance will
 * be retained for the duration of it being included in the
 * list.
 *
 * Threading: thread-safe
 */
int
container_register(const char *name, CONTAINER *container)
{
	size_t c;
	
	struct container_list_entry_struct *p;
	
	container->api->addref(container);
	container_list_wrlock(&containers);
	for(c = 0; c < containers.allocated; c++)
	{
		if(containers.list[c] && !strcmp(containers.list[c]->name, name))
		{
			LPRINTF(CWLOG_ERR, "failed to register container '%s': already registered", name);
			container_list_unlock(&containers);
			container->api->release(container);
			return -1;
		}
	}
	container_list_unlock(&containers);
	p = (struct container_list_entry_struct *) calloc(1, sizeof(struct container_list_entry_struct));
	if(!p)
	{
		container->api->release(container);
		return -1;
	}
	strncpy(p->name, name, sizeof(p->name) - 1);
	p->container = container;
	if(container_list_add(&containers, p) == -1)
	{
		LPRINTF(CWLOG_CRIT, "failed to register container '%s': %s", name, strerror(errno));
		free(p);
		container->api->release(container);
		return -1;
	}
	DPRINTF("registered container '%s'", name);
	return 0;
}
Ejemplo n.º 5
0
USING_PTYPES


/**
 *
 */
void rp_init(hid_device* hid) {
    LPRINTF("Saitek ProPanels Plugin: rp_init\n");
    uint8_t buf[4];

    hid_set_nonblocking(hid, (int)true);
    hid_read(hid, buf, sizeof(buf));
    hid_send_feature_report(hid, rp_blank_panel, sizeof(rp_blank_panel));
    hid_set_nonblocking(hid, (int)false);
}
Ejemplo n.º 6
0
//parses the input file, runs phoneme tests and produces output to be parsed by perl script
void doInputTestPhonemes(SR_Vocabulary *vocab, PFile* fin, FILE* fout)
{
#if 0
  //waste of space with all of these arrays, they are too large, but leave for now
  ESR_ReturnCode rc;
  LCHAR line[2 * MAX_PRONS_LENGTH];
  LCHAR phoneme[MAX_PRONS_LENGTH];
  LCHAR* phrase;
  LCHAR* expectedPhoneme;
    LCHAR** tokenArray;
  size_t len;

  //read through the test file parsing it into the variables
  while(!pfeof(fin))
  {
    pfgets(line, MAX_LINE_LENGTH, fin);

        rc = ESR_ProcessLinearToCommandLineTokens(line, &tokenArray, &len);
        if (rc!=ESR_SUCCESS || len!=2)
        {
          LFPRINTF(fout, "ERROR: INVALID FORMAT for input line\n");
            continue;
        }
        phrase = tokenArray[0];
        expectedPhoneme = tokenArray[1];

      LPRINTF( "expected %s\n", expectedPhoneme);

        len = MAX_PRONS_LENGTH;
        rc = vocab->getPronunciation(vocab, phrase, phoneme, &len);

        if(rc != ESR_SUCCESS)
            LFPRINTF(fout,"ERROR: %s\n", ESR_rc2str(rc));
        else
        {
            LFPRINTF(fout,"%s|%s|%s|", phrase, expectedPhoneme, phoneme);

            if(LSTRCMP(expectedPhoneme, phoneme) == 0)
                LFPRINTF(fout,"PASSED\n");
            else
                LFPRINTF(fout,"FAILED\n");
        }
  }
#endif
}
Ejemplo n.º 7
0
/*
 * Internal routine to lptprobe to do port tests of one byte value.
 */
int
lpt_port_test(bus_space_tag_t iot, bus_space_handle_t ioh, bus_addr_t base,
    bus_size_t off, u_int8_t data, u_int8_t mask)
{
	int timeout;
	u_int8_t temp;

	data &= mask;
	bus_space_write_1(iot, ioh, off, data);
	timeout = 1000;
	do {
		delay(10);
		temp = bus_space_read_1(iot, ioh, off) & mask;
	} while (temp != data && --timeout);
	LPRINTF(("lpt: port=0x%x out=0x%x in=0x%x timeout=%d\n", base + off,
	    data, temp, timeout));
	return (temp == data);
}
Ejemplo n.º 8
0
/*
 * Close the device, and free the local line buffer.
 */
int
lptclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct lpt_softc *sc;

	sc = device_lookup_private(&lpt_cd, LPTUNIT(dev));

	if (sc->sc_count)
		(void) pushbytes(sc);

	if ((sc->sc_flags & LPT_NOINTR) == 0)
		callout_stop(&sc->sc_wakeup_ch);

	(sc->sc_funcs->lf_close) (sc);

	sc->sc_state = 0;
	brelse(sc->sc_inbuf, 0);

	LPRINTF((sc->sc_dev, "%s: closed\n"));
	return (0);
}
Ejemplo n.º 9
0
/*
 * Reset the printer, then wait until it's selected and not busy.
 */
int
lptopen(dev_t dev, int flag, int mode, struct lwp *l)
{
	u_char flags = LPTFLAGS(dev);
	struct lpt_softc *sc;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	u_char control;
	int error;
	int spin;

	sc = device_lookup_private(&lpt_cd, LPTUNIT(dev));
	if (!sc || !sc->sc_dev_ok)
		return ENXIO;

#if 0	/* XXX what to do? */
	if (sc->sc_irq == IRQUNK && (flags & LPT_NOINTR) == 0)
		return ENXIO;
#endif

#ifdef DIAGNOSTIC
	if (sc->sc_state)
		aprint_verbose_dev(sc->sc_dev, "stat=0x%x not zero\n",
		    sc->sc_state);
#endif

	if (sc->sc_state)
		return EBUSY;

	sc->sc_state = LPT_INIT;
	sc->sc_flags = flags;
	LPRINTF(("%s: open: flags=0x%x\n", device_xname(sc->sc_dev),
	    (unsigned)flags));
	iot = sc->sc_iot;
	ioh = sc->sc_ioh;

	if ((flags & LPT_NOPRIME) == 0) {
		/* assert INIT for 100 usec to start up printer */
		bus_space_write_1(iot, ioh, lpt_control, LPC_SELECT);
		delay(100);
	}

	control = LPC_SELECT | LPC_NINIT;
	bus_space_write_1(iot, ioh, lpt_control, control);

	/* wait till ready (printer running diagnostics) */
	for (spin = 0; NOT_READY_ERR(); spin += STEP) {
		if (spin >= TIMEOUT) {
			sc->sc_state = 0;
			return EBUSY;
		}

		/* wait 1/4 second, give up if we get a signal */
		error = tsleep((void *)sc, LPTPRI | PCATCH, "lptopen", STEP);
		if (error != EWOULDBLOCK) {
			sc->sc_state = 0;
			return error;
		}
	}

	if ((flags & LPT_NOINTR) == 0)
		control |= LPC_IENABLE;
	if (flags & LPT_AUTOLF)
		control |= LPC_AUTOLF;
	sc->sc_control = control;
	bus_space_write_1(iot, ioh, lpt_control, control);

	sc->sc_inbuf = malloc(LPT_BSIZE, M_DEVBUF, M_WAITOK);
	sc->sc_count = 0;
	sc->sc_state = LPT_OPEN;

	if ((sc->sc_flags & LPT_NOINTR) == 0)
		lptwakeup(sc);

	LPRINTF(("%s: opened\n", device_xname(sc->sc_dev)));
	return 0;
}
Ejemplo n.º 10
0
/*
 * Reset the printer, then wait until it's selected and not busy.
 */
int
lptopen(dev_t dev, int flag, int mode, struct proc *p)
{
	int unit = LPTUNIT(dev);
	u_int8_t flags = LPTFLAGS(dev);
	struct lpt_softc *sc;
	u_int8_t control;
	int error;
	int spin;

	if (unit >= lpt_cd.cd_ndevs)
		return ENXIO;
	sc = lpt_cd.cd_devs[unit];
	if (!sc)
		return ENXIO;

	sc->sc_flags = (sc->sc_flags & LPT_POLLED) | flags;
	if ((sc->sc_flags & (LPT_POLLED|LPT_NOINTR)) == LPT_POLLED)
		return ENXIO;

#ifdef DIAGNOSTIC
	if (sc->sc_state)
		printf("%s: stat=0x%x not zero\n", sc->sc_dev.dv_xname,
		    sc->sc_state);
#endif

	if (sc->sc_state)
		return EBUSY;

	sc->sc_state = LPT_INIT;
	LPRINTF(("%s: open: flags=0x%x\n", sc->sc_dev.dv_xname, flags));

	if ((flags & LPT_NOPRIME) == 0) {
		/* assert INIT for 100 usec to start up printer */
		bus_space_write_1(sc->sc_iot, sc->sc_ioh, lpt_control, LPC_SELECT);
		delay(100);
	}

	control = LPC_SELECT | LPC_NINIT;
	bus_space_write_1(sc->sc_iot, sc->sc_ioh, lpt_control, control);

	/* wait till ready (printer running diagnostics) */
	for (spin = 0; NOT_READY_ERR(); spin += STEP) {
		if (spin >= TIMEOUT) {
			sc->sc_state = 0;
			return EBUSY;
		}

		/* wait 1/4 second, give up if we get a signal */
		error = tsleep((caddr_t)sc, LPTPRI | PCATCH, "lptopen", STEP);
		if (sc->sc_state == 0)
			return (EIO);
		if (error != EWOULDBLOCK) {
			sc->sc_state = 0;
			return error;
		}
	}

	if ((flags & LPT_NOINTR) == 0)
		control |= LPC_IENABLE;
	if (flags & LPT_AUTOLF)
		control |= LPC_AUTOLF;
	sc->sc_control = control;
	bus_space_write_1(sc->sc_iot, sc->sc_ioh, lpt_control, control);

	sc->sc_inbuf = geteblk(LPT_BSIZE);
	sc->sc_count = 0;
	sc->sc_state = LPT_OPEN;

	if ((sc->sc_flags & LPT_NOINTR) == 0)
		lptwakeup(sc);

	LPRINTF(("%s: opened\n", sc->sc_dev.dv_xname));
	return 0;
}
Ejemplo n.º 11
0
static int no_modem_voice_mode_on(void)
     {
     LPRINTF(L_WARN, "%s: voice_mode_on called", POS);
     return(FAIL);
     }
Ejemplo n.º 12
0
static int no_modem_stop_dialing(void)
     {
     LPRINTF(L_WARN, "%s: stop_dialing called", POS);
     return(FAIL);
     }
Ejemplo n.º 13
0
static int no_modem_wait(int wait_timeout)
     {
     LPRINTF(L_WARN, "%s: wait called", POS);
     return(FAIL);
     }
Ejemplo n.º 14
0
static int no_modem_beep(int frequency, int length)
     {
     LPRINTF(L_WARN, "%s: beep called", POS);
     return(FAIL);
     }
Ejemplo n.º 15
0
static int no_modem_set_device(int device)
     {
     LPRINTF(L_WARN, "%s: set_device called", POS);
     return(FAIL);
     }
Ejemplo n.º 16
0
/*
 * Reset the printer, then wait until it's selected and not busy.
 */
int
lptopen(dev_t dev, int flag, int mode, struct lwp *l)
{
	u_char flags;
	struct lpt_softc *sc;
	int error;
	int spin;

	flags = LPTFLAGS(dev);

	sc = device_lookup_private(&lpt_cd, LPTUNIT(dev));
	if (!sc)
		return (ENXIO);

#ifdef DIAGNOSTIC
	if (sc->sc_state)
		aprint_verbose_dev(sc->sc_dev, "stat=0x%x not zero\n",
		    sc->sc_state);
#endif

	if (sc->sc_state)
		return (EBUSY);

	sc->sc_state = LPT_INIT;
	sc->sc_flags = flags;
	LPRINTF((sc->sc_dev, "open: flags=0x%x\n", flags));

	if ((flags & LPT_NOPRIME) == 0) {
		/* assert Input Prime for 100 usec to start up printer */
		(sc->sc_funcs->lf_iprime) (sc);
	}

	/* select fast or slow strobe depending on minor device number */
	if (flags & LPT_FAST_STROBE)
		(sc->sc_funcs->lf_speed) (sc, LPT_STROBE_FAST);
	else
		(sc->sc_funcs->lf_speed) (sc, LPT_STROBE_SLOW);

	/* wait till ready (printer running diagnostics) */
	for (spin = 0; (sc->sc_funcs->lf_notrdy) (sc, 1); spin += STEP) {
		if (spin >= TIMEOUT) {
			sc->sc_state = 0;
			return (EBUSY);
		}
		/* wait 1/4 second, give up if we get a signal */
		error = tsleep((void *) sc, LPTPRI | PCATCH, "lptopen", STEP);
		if (error != EWOULDBLOCK) {
			sc->sc_state = 0;
			return (error);
		}
	}

	sc->sc_inbuf = geteblk(LPT_BSIZE);
	sc->sc_count = 0;
	sc->sc_state = LPT_OPEN;

	if ((sc->sc_flags & LPT_NOINTR) == 0)
		lpt_wakeup(sc);

	(sc->sc_funcs->lf_open) (sc, sc->sc_flags & LPT_NOINTR);

	LPRINTF((sc->sc_dev, "opened\n"));
	return (0);
}
Ejemplo n.º 17
0
/**
 * @brief measure_shmem_throughputd() - measure shmem throughpput with libmetal
 *        - Download throughput measurement:
 *          Start TTC RPU counter, wait for IPI kick, check if data is
 *          available, if yes, read as much data as possible from shared
 *          memory. It will iterates untill 1000 packages have been received,
 *          stop TTC RPU counter and kick IPI to notify the remote. Repeat
 *          for different package size.
 *        - Upload throughput measurement:
 *          Start TTC RPU counter, write data to shared memory and kick IPI
 *          to notify remote. It will iterate for 1000 times, stop TTC RPU
 *          counter.Wait for APU IPI kick to know APU has received all the
 *          packages. Kick IPI to notify it TTC RPU conter value is ready to
 *          read. Repeat for different package size.
 *
 * @param[in] ch - channel information
 * @return - 0 on success, error code if failure.
 */
static int measure_shmem_throughputd(struct channel_s *ch)
{
	void *lbuf = NULL;
	int ret = 0;
	size_t s;
	uint32_t rx_count, rx_avail, tx_count, iterations;
	unsigned long tx_avail_offset, rx_avail_offset;
	unsigned long tx_addr_offset, rx_addr_offset;
	unsigned long tx_data_offset, rx_data_offset;
	uint32_t buf_phy_addr_32;

	/* allocate memory for receiving data */
	lbuf = metal_allocate_memory(BUF_SIZE_MAX);
	if (!lbuf) {
		LPERROR("Failed to allocate memory.\r\n");
		return -1;
	}
	memset(lbuf, 0xA, BUF_SIZE_MAX);

	/* Clear shared memory */
	metal_io_block_set(ch->shm_io, 0, 0, metal_io_region_size(ch->shm_io));

	LPRINTF("Starting shared mem throughput demo\n");

	/* for each data size, measure block receive throughput */
	for (s = PKG_SIZE_MIN; s <= PKG_SIZE_MAX; s <<= 1) {
		rx_count = 0;
		iterations = TOTAL_DATA_SIZE / s;
		/* Set rx buffer address offset */
		rx_avail_offset = SHM_DESC_OFFSET_RX + SHM_DESC_AVAIL_OFFSET;
		rx_addr_offset = SHM_DESC_OFFSET_RX +
				SHM_DESC_ADDR_ARRAY_OFFSET;
		rx_data_offset = SHM_DESC_OFFSET_RX + SHM_BUFF_OFFSET_RX;
		wait_for_notified(&ch->remote_nkicked);
		/* Data has arrived, seasure start. Reset RPU TTC counter */
		reset_timer(ch->ttc_io, TTC_CNT_RPU_TO_APU);
		while (1) {
			rx_avail = metal_io_read32(ch->shm_io, rx_avail_offset);

			while(rx_count != rx_avail) {
				/* Get the buffer location from the shared
				 * memory rx address array.
			         */
				buf_phy_addr_32 = metal_io_read32(ch->shm_io,
							rx_addr_offset);
				rx_data_offset = metal_io_phys_to_offset(
					ch->shm_io,
					(metal_phys_addr_t)buf_phy_addr_32);
				if (rx_data_offset == METAL_BAD_OFFSET) {
					LPERROR(
					"[%u]failed to get rx offset: 0x%x, 0x%lx.\n",
					rx_count, buf_phy_addr_32,
					metal_io_phys(ch->shm_io,
						rx_addr_offset));
					ret = -EINVAL;
					goto out;
				}
				rx_addr_offset += sizeof(buf_phy_addr_32);
				/* Read data from shared memory */
				metal_io_block_read(ch->shm_io, rx_data_offset,
						lbuf, s);
				rx_count++;
			}
			if (rx_count < iterations)
				/* Need to wait for more data */
				wait_for_notified(&ch->remote_nkicked);
			else
				break;
		}
		/* Stop RPU TTC counter */
		stop_timer(ch->ttc_io, TTC_CNT_RPU_TO_APU);
		/* Clear remote kicked flag -- 0 is kicked */
		atomic_init(&ch->remote_nkicked, 1);
		/* Kick IPI to notify RPU TTC counter value is ready */
		metal_io_write32(ch->ipi_io, IPI_TRIG_OFFSET, ch->ipi_mask);
	}

	/* for each data size, measure send throughput */
	for (s = PKG_SIZE_MIN; s <= PKG_SIZE_MAX; s <<= 1) {
		tx_count = 0;
		iterations = TOTAL_DATA_SIZE / s;

		/* Set tx buffer address offset */
		tx_avail_offset = SHM_DESC_OFFSET_TX + SHM_DESC_AVAIL_OFFSET;
		tx_addr_offset = SHM_DESC_OFFSET_TX +
				SHM_DESC_ADDR_ARRAY_OFFSET;
		tx_data_offset = SHM_DESC_OFFSET_TX + SHM_BUFF_OFFSET_TX;
		/* Wait for APU to signal it is ready for the measurement */
		wait_for_notified(&ch->remote_nkicked);
		/* Data has arrived, seasure start. Reset RPU TTC counter */
		reset_timer(ch->ttc_io, TTC_CNT_RPU_TO_APU);
		while (tx_count < iterations) {
			/* Write data to the shared memory*/
			metal_io_block_write(ch->shm_io, tx_data_offset,
					lbuf, s);

			/* Write to the address array to tell the other end
			 * the buffer address.
			 */
			buf_phy_addr_32 = (uint32_t)metal_io_phys(ch->shm_io,
						tx_data_offset);
			metal_io_write32(ch->shm_io, tx_addr_offset,
					buf_phy_addr_32);
			tx_data_offset += s;
			tx_addr_offset += sizeof(buf_phy_addr_32);

			/* Increase number of available buffers */
			tx_count++;
			metal_io_write32(ch->shm_io, tx_avail_offset, tx_count);
			/* Kick IPI to notify remote data is ready in the
			 * shared memory */
			metal_io_write32(ch->ipi_io, IPI_TRIG_OFFSET,
					ch->ipi_mask);
		}
		/* Stop RPU TTC counter */
		stop_timer(ch->ttc_io, TTC_CNT_RPU_TO_APU);
		/* Wait for IPI kick to know when the remote is ready
		 * to read the TTC counter value */
		wait_for_notified(&ch->remote_nkicked);
		/* Kick IPI to notify RPU TTC counter value is ready */
		metal_io_write32(ch->ipi_io, IPI_TRIG_OFFSET, ch->ipi_mask);
	}

out:
	if (lbuf)
		metal_free_memory(lbuf);
	return ret;
}
Ejemplo n.º 18
0
static int no_modem_message_light_on(void)
     {
     LPRINTF(L_WARN, "%s: message_light_on called", POS);
     return(FAIL);
     }
Ejemplo n.º 19
0
static int no_modem_reset_play_file(void)
     {
     LPRINTF(L_WARN, "%s: next_play_file called", POS);
     return(FAIL);
     }
Ejemplo n.º 20
0
static int no_modem_init(void)
     {
     LPRINTF(L_WARN, "%s: init called", POS);
     return(FAIL);
     }
Ejemplo n.º 21
0
static int no_modem_handle_dle(char data)
     {
     LPRINTF(L_WARN, "%s: handle_dle called", POS);
     return(FAIL);
     }
Ejemplo n.º 22
0
static int no_modem_dial(char *number)
     {
     LPRINTF(L_WARN, "%s: dial called", POS);
     return(FAIL);
     }
Ejemplo n.º 23
0
static void rpmsg_rpc_shutdown(struct rpmsg_rpc_data *rpc)
{
	(void)rpc;
	LPRINTF("RPMSG RPC is shutting down.\n");
}
Ejemplo n.º 24
0
static int no_modem_switch_to_data_fax(char *mode)
     {
     LPRINTF(L_WARN, "%s: switch_to_data_fax called", POS);
     return(FAIL);
     }
Ejemplo n.º 25
0
/*-----------------------------------------------------------------------------*
 *  Application specific
 *-----------------------------------------------------------------------------*/
int app(struct rpmsg_device *rdev, void *priv)
{
	struct rpmsg_rpc_data rpc;
	struct rpmsg_rpc_syscall rpccall;
	int fd, bytes_written, bytes_read;
	char fname[] = "remote.file";
	char wbuff[50];
	char rbuff[1024];
	char ubuff[50];
	float fdata;
	int idata;
	int ret;

	/* redirect I/Os */
	LPRINTF("Initializating I/Os redirection...\n");
	ret = rpmsg_rpc_init(&rpc, rdev, RPMSG_SERVICE_NAME,
			     RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
			     priv, platform_poll, rpmsg_rpc_shutdown);
	rpmsg_set_default_rpc(&rpc);
	if (ret) {
		LPRINTF("Failed to intialize rpmsg rpc\n");
		return -1;
	}

	printf("\r\nRemote>Baremetal Remote Procedure Call (RPC) Demonstration\r\n");
	printf("\r\nRemote>***************************************************\r\n");

	printf("\r\nRemote>Rpmsg based retargetting to proxy initialized..\r\n");

	/* Remote performing file IO on Master */
	printf("\r\nRemote>FileIO demo ..\r\n");

	printf("\r\nRemote>Creating a file on master and writing to it..\r\n");
	fd = open(fname, REDEF_O_CREAT | REDEF_O_WRONLY | REDEF_O_APPEND,
		  S_IRUSR | S_IWUSR);
	printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);

	sprintf(wbuff, "This is a test string being written to file..");
	bytes_written = write(fd, wbuff, strlen(wbuff));
	printf("\r\nRemote>Wrote to fd = %d, size = %d, content = %s\r\n", fd,
	       bytes_written, wbuff);
	close(fd);
	printf("\r\nRemote>Closed fd = %d\r\n", fd);

	/* Remote performing file IO on Master */
	printf("\r\nRemote>Reading a file on master and displaying its contents..\r\n");
	fd = open(fname, REDEF_O_RDONLY, S_IRUSR | S_IWUSR);
	printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
	bytes_read = read(fd, rbuff, 1024);
	*(char *)(&rbuff[0] + bytes_read + 1) = 0;
	printf("\r\nRemote>Read from fd = %d, size = %d, printing contents below .. %s\r\n",
		fd, bytes_read, rbuff);
	close(fd);
	printf("\r\nRemote>Closed fd = %d\r\n", fd);

	while (1) {
		/* Remote performing STDIO on Master */
		printf("\r\nRemote>Remote firmware using scanf and printf ..\r\n");
		printf("\r\nRemote>Scanning user input from master..\r\n");
		printf("\r\nRemote>Enter name\r\n");
		ret = scanf("%s", ubuff);
		if (ret) {
			printf("\r\nRemote>Enter age\r\n");
			ret = scanf("%d", &idata);
			if (ret) {
				printf("\r\nRemote>Enter value for pi\r\n");
				ret = scanf("%f", &fdata);
				if (ret) {
					printf("\r\nRemote>User name = '%s'\r\n", ubuff);
					printf("\r\nRemote>User age = '%d'\r\n", idata);
					printf("\r\nRemote>User entered value of pi = '%f'\r\n", fdata);
				}
			}
		}
		if (!ret) {
			scanf("%s", ubuff);
			printf("Remote> Invalid value. Starting again....");
		} else {
			printf("\r\nRemote>Repeat demo ? (enter yes or no) \r\n");
			scanf("%s", ubuff);
			if ((strcmp(ubuff, "no")) && (strcmp(ubuff, "yes"))) {
				printf("\r\nRemote>Invalid option. Starting again....\r\n");
			} else if ((!strcmp(ubuff, "no"))) {
				printf("\r\nRemote>RPC retargetting quitting ...\r\n");
				break;
			}
		}
	}

	printf("\r\nRemote> Firmware's rpmsg-rpc-channel going down! \r\n");
	rpccall.id = TERM_SYSCALL_ID;
	(void)rpmsg_rpc_send(&rpc, &rpccall, sizeof(rpccall), NULL, 0);

	LPRINTF("Release remoteproc procedure call\n");
	rpmsg_rpc_release(&rpc);
	return 0;
}
Ejemplo n.º 26
0
static int no_modem_play_dtmf(char* number)
     {
     LPRINTF(L_WARN, "%s: play_dtmf called", POS);
     return(FAIL);
     }
Ejemplo n.º 27
0
static int no_modem_record_file(FILE *fd, int bps)
     {
     LPRINTF(L_WARN, "%s: record_file called", POS);
     return(FAIL);
     }
Ejemplo n.º 28
0
static int no_modem_set_compression(int *compression, int *speed, int *bits)
     {
     LPRINTF(L_WARN, "%s: set_compression called", POS);
     return(FAIL);
     }
Ejemplo n.º 29
0
static int no_modem_stop_play_file(void)
     {
     LPRINTF(L_WARN, "%s: stop_play_file called", POS);
     return(FAIL);
     }
Ejemplo n.º 30
0
static int no_modem_answer_phone(void)
     {
     LPRINTF(L_WARN, "%s: answer_phone called", POS);
     return(FAIL);
     }