Example #1
0
/*
**  Name:	void do_init(message *mp)
**  Function:	Checks for hardware presence.
**  		Provides initialization of hardware and data structures
*/
static void do_init(const message * mp)
{
  dpeth_t *dep;
  dp_conf_t *dcp;
  message reply_mess;
  int r, confnr;

  dep = &de_state;

  /* Pick a default configuration for this instance. */
  confnr = MIN(de_instance, DP_CONF_NR-1);

  dcp = &dp_conf[confnr];
  strcpy(dep->de_name, DevName);
  dep->de_name[4] = '0' + de_instance;

  if (dep->de_mode == DEM_DISABLED) {

	update_conf(dep, dcp);	/* First time thru */
	if (dep->de_mode == DEM_ENABLED &&
	    !el1_probe(dep) &&	/* Probe for 3c501  */
	    !wdeth_probe(dep) &&	/* Probe for WD80x3 */
	    !ne_probe(dep) &&	/* Probe for NEx000 */
	    !el2_probe(dep) &&	/* Probe for 3c503  */
	    !el3_probe(dep)) {	/* Probe for 3c509  */
		printf("%s: warning no ethernet card found at 0x%04X\n",
		       dep->de_name, dep->de_base_port);
		dep->de_mode = DEM_DISABLED;
	}
  }

  r = OK;

  /* 'de_mode' may change if probe routines fail, test again */
  switch (dep->de_mode) {

    case DEM_DISABLED:
	/* Device is configured OFF or hardware probe failed */
	r = ENXIO;
	break;

    case DEM_ENABLED:
	/* Device is present and probed */
	if (dep->de_flags == DEF_EMPTY) {
		/* These actions only the first time */
		do_first_init(dep, dcp);
		dep->de_flags |= DEF_ENABLED;
	}
	dep->de_flags &= NOT(DEF_PROMISC | DEF_MULTI | DEF_BROAD);
	if (mp->DL_MODE & DL_PROMISC_REQ)
		dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD;
	if (mp->DL_MODE & DL_MULTI_REQ) dep->de_flags |= DEF_MULTI;
	if (mp->DL_MODE & DL_BROAD_REQ) dep->de_flags |= DEF_BROAD;
	(*dep->de_flagsf) (dep);
	break;

    case DEM_SINK:
	/* Device not present (sink mode) */
	memset(dep->de_address.ea_addr, 0, sizeof(ether_addr_t));
	dp_confaddr(dep);	/* Station address from env. */
	break;

    default:	break;
  }

  reply_mess.m_type = DL_CONF_REPLY;
  reply_mess.DL_STAT = r;
  if (r == OK)
	*(ether_addr_t *) reply_mess.DL_HWADDR = dep->de_address;
  DEBUG(printf("\t reply %d\n", reply_mess.m_type));
  if (send(mp->m_source, &reply_mess) != OK)	/* Can't send */
	panic(SendErrMsg, mp->m_source);

  return;
}
Example #2
0
/*
**  Name:	void do_init(message *mp)
**  Function:	Checks for hardware presence.
**  		Provides initialization of hardware and data structures
*/
static void do_init(message * mp)
{
  int port;
  dpeth_t *dep;
  dp_conf_t *dcp;
  message reply_mess;

  port = mp->DL_PORT;
  if (port >= 0 && port < DE_PORT_NR) {

	dep = &de_table[port];
	dcp = &dp_conf[port];
	strcpy(dep->de_name, DevName);
	dep->de_name[4] = '0' + port;

	if (dep->de_mode == DEM_DISABLED) {

		update_conf(dep, dcp);	/* First time thru */
		if (dep->de_mode == DEM_ENABLED &&
		    !el1_probe(dep) &&	/* Probe for 3c501  */
		    !wdeth_probe(dep) &&	/* Probe for WD80x3 */
		    !ne_probe(dep) &&	/* Probe for NEx000 */
		    !el2_probe(dep) &&	/* Probe for 3c503  */
		    !el3_probe(dep)) {	/* Probe for 3c509  */
			printf("%s: warning no ethernet card found at 0x%04X\n",
			       dep->de_name, dep->de_base_port);
			dep->de_mode = DEM_DISABLED;
		}
	}

	/* 'de_mode' may change if probe routines fail, test again */
	switch (dep->de_mode) {

	    case DEM_DISABLED:
		/* Device is configured OFF or hardware probe failed */
		port = ENXIO;
		break;

	    case DEM_ENABLED:
		/* Device is present and probed */
		if (dep->de_flags == DEF_EMPTY) {
			/* These actions only the first time */
			do_first_init(dep, dcp);
			dep->de_flags |= DEF_ENABLED;
		}
		dep->de_flags &= NOT(DEF_PROMISC | DEF_MULTI | DEF_BROAD);
		if (mp->DL_MODE & DL_PROMISC_REQ)
			dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD;
		if (mp->DL_MODE & DL_MULTI_REQ) dep->de_flags |= DEF_MULTI;
		if (mp->DL_MODE & DL_BROAD_REQ) dep->de_flags |= DEF_BROAD;
		(*dep->de_flagsf) (dep);
		dep->de_client = mp->m_source;
		break;

	    case DEM_SINK:
		/* Device not present (sink mode) */
		memset(dep->de_address.ea_addr, 0, sizeof(ether_addr_t));
		dp_confaddr(dep);	/* Station address from env. */
		break;

	    default:	break;
	}
	*(ether_addr_t *) reply_mess.m3_ca1 = dep->de_address;

  } else			/* Port number is out of range */
	port = ENXIO;

  reply_mess.m_type = DL_INIT_REPLY;
  reply_mess.m3_i1 = port;
  reply_mess.m3_i2 = DE_PORT_NR;
  DEBUG(printf("\t reply %d\n", reply_mess.m_type));
  if (send(mp->m_source, &reply_mess) != OK)	/* Can't send */
	panic(dep->de_name, SendErrMsg, mp->m_source);

  return;
}