예제 #1
0
파일: main.c 프로젝트: Sciumo/minix
/*===========================================================================*
 *			       do_async_dev_result			     *
 *===========================================================================*/
static void *do_async_dev_result(void *arg)
{
  endpoint_t endpt;
  struct job my_job;

  my_job = *((struct job *) arg);
  fp = my_job.j_fp;

  /* An asynchronous character driver has results for us */
  if (job_call_nr == DEV_REVIVE) {
	endpt = job_m_in.REP_ENDPT;
	if (endpt == VFS_PROC_NR)
		endpt = find_suspended_ep(job_m_in.m_source,
					  job_m_in.REP_IO_GRANT);

	if (endpt == NONE) {
		printf("VFS: proc with grant %d from %d not found\n",
			job_m_in.REP_IO_GRANT, job_m_in.m_source);
	} else if (job_m_in.REP_STATUS == SUSPEND) {
		printf("VFS: got SUSPEND on DEV_REVIVE: not reviving proc\n");
	} else
		revive(endpt, job_m_in.REP_STATUS);
  }
  else if (job_call_nr == DEV_OPEN_REPL) open_reply();
  else if (job_call_nr == DEV_REOPEN_REPL) reopen_reply();
  else if (job_call_nr == DEV_CLOSE_REPL) close_reply();
  else if (job_call_nr == DEV_SEL_REPL1)
	select_reply1(job_m_in.m_source, job_m_in.DEV_MINOR,
		      job_m_in.DEV_SEL_OPS);
  else if (job_call_nr == DEV_SEL_REPL2)
	select_reply2(job_m_in.m_source, job_m_in.DEV_MINOR,
		      job_m_in.DEV_SEL_OPS);

  if (deadlock_resolving) {
	if (fp != NULL && fp->fp_wtid == dl_worker.w_tid)
		deadlock_resolving = 0;
  }

  if (fp != NULL && (fp->fp_flags & FP_SYS_PROC)) {
	struct vmnt *vmp;

	if ((vmp = find_vmnt(fp->fp_endpoint)) != NULL)
		vmp->m_flags &= ~VMNT_CALLBACK;
  }

  thread_cleanup(NULL);
  return(NULL);
}
예제 #2
0
/*===========================================================================*
 *			       do_async_dev_result			     *
 *===========================================================================*/
static void *do_async_dev_result(void *arg)
{
  endpoint_t endpt;
  struct job my_job;

  my_job = *((struct job *) arg);
  fp = my_job.j_fp;

  /* An asynchronous character driver has results for us */
  if (job_call_nr == DEV_REVIVE) {
	endpt = job_m_in.REP_ENDPT;
	if (endpt == VFS_PROC_NR)
		endpt = find_suspended_ep(job_m_in.m_source,
					  job_m_in.REP_IO_GRANT);

	if (endpt == NONE) {
		printf("VFS: proc with grant %d from %d not found\n",
			job_m_in.REP_IO_GRANT, job_m_in.m_source);
	} else if (job_m_in.REP_STATUS == SUSPEND) {
		printf("VFS: got SUSPEND on DEV_REVIVE: not reviving proc\n");
	} else
		revive(endpt, job_m_in.REP_STATUS);
  }
  else if (job_call_nr == DEV_OPEN_REPL) open_reply();
  else if (job_call_nr == DEV_REOPEN_REPL) reopen_reply();
  else if (job_call_nr == DEV_CLOSE_REPL) close_reply();
  else if (job_call_nr == DEV_SEL_REPL1)
	select_reply1(job_m_in.m_source, job_m_in.DEV_MINOR,
		      job_m_in.DEV_SEL_OPS);
  else if (job_call_nr == DEV_SEL_REPL2)
	select_reply2(job_m_in.m_source, job_m_in.DEV_MINOR,
		      job_m_in.DEV_SEL_OPS);

  thread_cleanup(fp);
  return(NULL);
}
예제 #3
0
파일: device.c 프로젝트: jkiiski/minix
/*===========================================================================*
 *				dev_status				     *
 *===========================================================================*/
void dev_status(endpoint_t drv_e)
{
/* A device sent us a notification it has something for us. Retrieve it. */

  message st;
  int major, get_more = 1;
  endpoint_t endpt;

  for (major = 0; major < NR_DEVICES; major++)
	if (dmap_driver_match(drv_e, major))
		break; /* 'major' is the device that sent the message */

  if (major >= NR_DEVICES)	/* Device endpoint not found; nothing to do */
	return;

  if (dev_style_asyn(dmap[major].dmap_style)) {
	printf("VFS: not doing dev_status for async driver %d\n", drv_e);
	return;
  }

  /* Continuously send DEV_STATUS messages until the device has nothing to
   * say to us anymore. */
  do {
	int r;
	st.m_type = DEV_STATUS;
	r = drv_sendrec(drv_e, &st);
	if (r == OK && st.REP_STATUS == ERESTART) r = EDEADEPT;
	if (r != OK) {
		printf("VFS: DEV_STATUS failed to %d: %d\n", drv_e, r);
		if (r == EDEADSRCDST || r == EDEADEPT) return;
		panic("VFS: couldn't sendrec for DEV_STATUS: %d", r);
	}

	switch(st.m_type) {
	  case DEV_REVIVE:
		/* We've got results for a read/write/ioctl call to a
		 * synchronous character driver */
		endpt = st.REP_ENDPT;
		if (endpt == VFS_PROC_NR) {
			endpt = find_suspended_ep(drv_e, st.REP_IO_GRANT);
			if (endpt == NONE) {
			  printf("VFS: proc with grant %d from %d not found\n",
				 st.REP_IO_GRANT, st.m_source);
			  continue;
			}
		}
		revive(endpt, st.REP_STATUS);
		break;
	  case DEV_IO_READY:
		/* Reply to a select request: driver is ready for I/O */
		select_reply2(st.m_source, st.DEV_MINOR, st.DEV_SEL_OPS);
		break;
	  default:
		printf("VFS: unrecognized reply %d to DEV_STATUS\n",st.m_type);
		/* Fall through. */
	  case DEV_NO_STATUS:
		get_more = 0;
		break;
	}
  } while(get_more);
}