80bd109cd3
- move system calls for use by services from libminlib into libsys; - move srv_fork(2) and srv_kill(2) from RS and into libsys; - replace getprocnr(2) with sef_self(3); - rename previous getnprocnr(2) to getprocnr(2); - clean up getepinfo(2); - change all libsys calls that used _syscall to use _taskcall, so as to avoid going through errno to pass errors; this is already how most calls work anyway, and many of the calls previously using _syscall were already assumed to return the actual error; - initialize request messages to zero, for future compatibility (note that this does not include PCI calls, which are in need of a much bigger overhaul, nor kernel calls); - clean up more of dead DS code as a side effect. Change-Id: I8788f54c68598fcf58e23486e270c2d749780ebb
82 lines
2 KiB
C
82 lines
2 KiB
C
/* This file contains device independent network device driver interface.
|
|
*
|
|
* Changes:
|
|
* Apr 01, 2010 Created (Cristiano Giuffrida)
|
|
*
|
|
* The file contains the following entry points:
|
|
*
|
|
* netdriver_announce: called by a network driver to announce it is up
|
|
* netdriver_receive: receive() interface for network drivers
|
|
*/
|
|
|
|
#include <minix/drivers.h>
|
|
#include <minix/endpoint.h>
|
|
#include <minix/netdriver.h>
|
|
#include <minix/ds.h>
|
|
|
|
static int conf_expected = TRUE;
|
|
|
|
/*===========================================================================*
|
|
* netdriver_announce *
|
|
*===========================================================================*/
|
|
void netdriver_announce()
|
|
{
|
|
/* Announce we are up after a fresh start or restart. */
|
|
int r;
|
|
char key[DS_MAX_KEYLEN];
|
|
char label[DS_MAX_KEYLEN];
|
|
char *driver_prefix = "drv.net.";
|
|
|
|
/* Publish a driver up event. */
|
|
r = ds_retrieve_label_name(label, sef_self());
|
|
if (r != OK) {
|
|
panic("driver_announce: unable to get own label: %d\n", r);
|
|
}
|
|
snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
|
|
r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE);
|
|
if (r != OK) {
|
|
panic("driver_announce: unable to publish driver up event: %d\n", r);
|
|
}
|
|
|
|
conf_expected = TRUE;
|
|
}
|
|
|
|
/*===========================================================================*
|
|
* netdriver_receive *
|
|
*===========================================================================*/
|
|
int netdriver_receive(src, m_ptr, status_ptr)
|
|
endpoint_t src;
|
|
message *m_ptr;
|
|
int *status_ptr;
|
|
{
|
|
/* receive() interface for drivers. */
|
|
int r;
|
|
|
|
while (TRUE) {
|
|
/* Wait for a request. */
|
|
r = sef_receive_status(src, m_ptr, status_ptr);
|
|
if (r != OK) {
|
|
return r;
|
|
}
|
|
|
|
/* Let non-datalink requests through regardless. */
|
|
if (!IS_DL_RQ(m_ptr->m_type)) {
|
|
return r;
|
|
}
|
|
|
|
/* See if only DL_CONF is to be expected. */
|
|
if(conf_expected) {
|
|
if(m_ptr->m_type == DL_CONF) {
|
|
conf_expected = FALSE;
|
|
}
|
|
else {
|
|
continue;
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
return OK;
|
|
}
|
|
|