Ejemplo n.º 1
0
void gaelco_serial_device::device_stop()
{
	shmem_lock(m_shmem);
	buf_reset(m_out_ptr);
	buf_reset(m_in_ptr);
	shmem_unlock(m_shmem);

	osd_sharedmem_free(m_os_shmem);
}
Ejemplo n.º 2
0
static TIMER_CALLBACK( link_cb )
{
	gaelco_serial_state *state = (gaelco_serial_state *) ptr;

	shmem_lock(state->m_shmem);
	state->m_out_ptr->cnt++;
	sync_link(state);
	shmem_unlock(state->m_shmem);
}
Ejemplo n.º 3
0
static DEVICE_STOP( gaelco_serial )
{
	gaelco_serial_state *state = get_token(device);

	shmem_lock(state->m_shmem);
	buf_reset(state->m_out_ptr);
	buf_reset(state->m_in_ptr);
	shmem_unlock(state->m_shmem);

	osd_sharedmem_free(state->m_os_shmem);
}
Ejemplo n.º 4
0
void gaelco_serial_device::device_reset()
{
	m_status = GAELCOSER_STATUS_READY    |GAELCOSER_STATUS_IRQ_ENABLE ;

	m_last_in_msg_cnt = -1;
	m_slack_cnt = LINK_SLACK_B;

	shmem_lock(m_shmem);
	buf_reset(m_out_ptr);
	buf_reset(m_in_ptr);
	shmem_unlock(m_shmem);
}
Ejemplo n.º 5
0
static DEVICE_RESET( gaelco_serial )
{
	gaelco_serial_state *state = get_token(device);

	state->m_status = GAELCOSER_STATUS_READY	|GAELCOSER_STATUS_IRQ_ENABLE ;

	state->m_last_in_msg_cnt = -1;
	state->m_slack_cnt = LINK_SLACK_B;

	shmem_lock(state->m_shmem);
	buf_reset(state->m_out_ptr);
	buf_reset(state->m_in_ptr);
	shmem_unlock(state->m_shmem);
}
Ejemplo n.º 6
0
static void sync_link(gaelco_serial_state *state)
{
	volatile buf_t *buf = state->m_in_ptr;
	int breakme = 1;
	do
	{
		shmem_lock(state->m_shmem);
		process_in(state);
		/* HACK: put some timing noise on the line */
		if (buf->cnt + state->m_slack_cnt > state->m_out_ptr->cnt)
			breakme = 0;
		/* stop if not connected .. */
		if ((state->m_out_ptr->stat & GAELCOSER_STATUS_RESET) != 0)
			breakme = 0;
		shmem_unlock(state->m_shmem);
	} while (breakme);

	state->m_slack_cnt++;
	state->m_slack_cnt = (state->m_slack_cnt % LINK_SLACK) + LINK_SLACK_B;

	shmem_lock(state->m_shmem);
	state->m_out_ptr->stat &= ~GAELCOSER_STATUS_RESET;
	shmem_unlock(state->m_shmem);
}
Ejemplo n.º 7
0
/*
 * shm_destroy - free the struct shmid_kernel
 *
 * @ns: namespace
 * @shp: struct to free
 *
 * It has to be called with shp and shm_ids.rwsem (writer) locked,
 * but returns with shp unlocked and freed.
 */
static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
{
	struct file *shm_file;

	shm_file = shp->shm_file;
	shp->shm_file = NULL;
	ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
	shm_rmid(ns, shp);
	shm_unlock(shp);
	if (!is_file_hugepages(shm_file))
		shmem_lock(shm_file, 0, shp->mlock_user);
	else if (shp->mlock_user)
		user_shm_unlock(file_inode(shm_file)->i_size, shp->mlock_user);
	fput(shm_file);
	ipc_rcu_putref(shp, shm_rcu_free);
}