2005-06-29 12:16:46 +02:00
|
|
|
/*
|
2007-10-17 12:53:47 +02:00
|
|
|
** File: dp.c Version 1.01, Oct. 17, 2007
|
|
|
|
** Original: eth.c Version 1.00, Jan. 14, 1997
|
2005-06-29 12:16:46 +02:00
|
|
|
**
|
|
|
|
** Author: Giovanni Falzoni <gfalzoni@inwind.it>
|
|
|
|
**
|
|
|
|
** This file contains the ethernet device driver main task.
|
|
|
|
** It has to be integrated with the board specific drivers.
|
|
|
|
** It is a rewriting of Minix 2.0.0 ethernet driver (dp8390.c)
|
|
|
|
** to remove bord specific code. It should operate (I hope)
|
|
|
|
** with any board driver.
|
|
|
|
*/
|
|
|
|
|
2010-03-22 22:25:22 +01:00
|
|
|
#include <minix/drivers.h>
|
2010-04-08 15:41:35 +02:00
|
|
|
#include <minix/netdriver.h>
|
2009-09-29 20:47:56 +02:00
|
|
|
#include <minix/endpoint.h>
|
2010-04-08 15:41:35 +02:00
|
|
|
#include <minix/ds.h>
|
2005-06-29 12:16:46 +02:00
|
|
|
#include <net/gen/ether.h>
|
|
|
|
#include <net/gen/eth_io.h>
|
|
|
|
|
|
|
|
#include "dp.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Local data
|
|
|
|
*/
|
2010-05-18 00:22:53 +02:00
|
|
|
static dpeth_t de_state;
|
|
|
|
static int de_instance;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
typedef struct dp_conf { /* Configuration description structure */
|
|
|
|
port_t dpc_port;
|
|
|
|
int dpc_irq;
|
|
|
|
phys_bytes dpc_mem;
|
|
|
|
} dp_conf_t;
|
|
|
|
|
|
|
|
/* Device default configuration */
|
2010-05-18 00:22:53 +02:00
|
|
|
#define DP_CONF_NR 3
|
|
|
|
static dp_conf_t dp_conf[DP_CONF_NR] = {
|
|
|
|
/* I/O port, IRQ, Buff addr, Env. var */
|
|
|
|
{ 0x300, 5, 0xC8000, },
|
|
|
|
{ 0x280, 10, 0xCC000, },
|
|
|
|
{ 0x000, 0, 0x00000, },
|
2005-06-29 12:16:46 +02:00
|
|
|
};
|
|
|
|
|
2006-07-10 14:43:38 +02:00
|
|
|
static char CopyErrMsg[] = "unable to read/write user data";
|
2010-04-08 15:41:35 +02:00
|
|
|
static char RecvErrMsg[] = "netdriver_receive failed";
|
2006-07-10 14:43:38 +02:00
|
|
|
static char SendErrMsg[] = "send failed";
|
|
|
|
static char SizeErrMsg[] = "illegal packet size";
|
|
|
|
static char TypeErrMsg[] = "illegal message type";
|
|
|
|
static char DevName[] = "eth#?";
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
/*
|
2007-10-17 12:53:47 +02:00
|
|
|
** Name: void reply(dpeth_t *dep, int err, int m_type)
|
|
|
|
** Function: Fills a reply message and sends it.
|
2005-06-29 12:16:46 +02:00
|
|
|
*/
|
2010-05-18 00:22:53 +02:00
|
|
|
static void reply(dpeth_t * dep)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
message reply;
|
2010-05-18 00:22:53 +02:00
|
|
|
int r, flags;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
flags = DL_NOFLAGS;
|
|
|
|
if (dep->de_flags & DEF_ACK_SEND) flags |= DL_PACK_SEND;
|
|
|
|
if (dep->de_flags & DEF_ACK_RECV) flags |= DL_PACK_RECV;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
reply.m_type = DL_TASK_REPLY;
|
|
|
|
reply.DL_FLAGS = flags;
|
2005-06-29 12:16:46 +02:00
|
|
|
reply.DL_COUNT = dep->de_read_s;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
DEBUG(printf("\t reply %d (%lx)\n", reply.m_type, reply.DL_FLAGS));
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
if ((r = send(dep->de_client, &reply)) != OK)
|
|
|
|
panic(SendErrMsg, r);
|
2005-09-04 20:52:16 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep->de_read_s = 0;
|
|
|
|
dep->de_flags &= NOT(DEF_ACK_SEND | DEF_ACK_RECV);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void dp_confaddr(dpeth_t *dep)
|
2005-09-04 20:52:16 +02:00
|
|
|
** Function: Checks environment for a User defined ethernet address.
|
2005-06-29 12:16:46 +02:00
|
|
|
*/
|
|
|
|
static void dp_confaddr(dpeth_t * dep)
|
|
|
|
{
|
|
|
|
static char ea_fmt[] = "x:x:x:x:x:x";
|
|
|
|
char ea_key[16];
|
|
|
|
int ix;
|
|
|
|
long val;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
strcpy(ea_key, "DPETH0_EA");
|
|
|
|
ea_key[5] += de_instance;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
for (ix = 0; ix < SA_ADDR_LEN; ix++) {
|
|
|
|
val = dep->de_address.ea_addr[ix];
|
|
|
|
if (env_parse(ea_key, ea_fmt, ix, &val, 0x00L, 0xFFL) != EP_SET)
|
|
|
|
break;
|
|
|
|
dep->de_address.ea_addr[ix] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ix != 0 && ix != SA_ADDR_LEN)
|
|
|
|
/* It's all or nothing, force a panic */
|
|
|
|
env_parse(ea_key, "?", 0, &val, 0L, 0L);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void update_conf(dpeth_t *dep, dp_conf_t *dcp)
|
|
|
|
** Function: Gets the default settings from 'dp_conf' table and
|
|
|
|
** modifies them from the environment.
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void update_conf(dpeth_t * dep, const dp_conf_t * dcp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
static char dpc_fmt[] = "x:d:x";
|
2010-05-18 00:22:53 +02:00
|
|
|
char ec_key[16];
|
2005-06-29 12:16:46 +02:00
|
|
|
long val;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
strcpy(ec_key, "DPETH0");
|
|
|
|
ec_key[5] += de_instance;
|
|
|
|
|
2005-06-29 12:16:46 +02:00
|
|
|
dep->de_mode = DEM_SINK;
|
|
|
|
val = dcp->dpc_port; /* Get I/O port address */
|
2010-05-18 00:22:53 +02:00
|
|
|
switch (env_parse(ec_key, dpc_fmt, 0, &val, 0x000L, 0x3FFL)) {
|
2005-06-29 12:16:46 +02:00
|
|
|
case EP_OFF: dep->de_mode = DEM_DISABLED; break;
|
|
|
|
case EP_ON:
|
|
|
|
case EP_SET: dep->de_mode = DEM_ENABLED; break;
|
|
|
|
}
|
|
|
|
dep->de_base_port = val;
|
|
|
|
|
|
|
|
val = dcp->dpc_irq | DEI_DEFAULT; /* Get Interrupt line (IRQ) */
|
2010-05-18 00:22:53 +02:00
|
|
|
env_parse(ec_key, dpc_fmt, 1, &val, 0L, (long) NR_IRQ_VECTORS - 1);
|
2005-06-29 12:16:46 +02:00
|
|
|
dep->de_irq = val;
|
|
|
|
|
|
|
|
val = dcp->dpc_mem; /* Get shared memory address */
|
2010-05-18 00:22:53 +02:00
|
|
|
env_parse(ec_key, dpc_fmt, 2, &val, 0L, LONG_MAX);
|
2005-06-29 12:16:46 +02:00
|
|
|
dep->de_linmem = val;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void do_dump(message *mp)
|
|
|
|
** Function: Displays statistics on screen (SFx key from console)
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_dump(const message *mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
dpeth_t *dep;
|
2010-05-18 00:22:53 +02:00
|
|
|
|
|
|
|
dep = &de_state;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
if (dep->de_mode == DEM_DISABLED) return;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
printf("%s statistics:\t\t", dep->de_name);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Network interface status */
|
|
|
|
printf("Status: 0x%04x (%d)\n\n", dep->de_flags, dep->de_int_pending);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
(*dep->de_dumpstatsf) (dep);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Transmitted/received bytes */
|
|
|
|
printf("Tx bytes:%10ld\t", dep->bytes_Tx);
|
|
|
|
printf("Rx bytes:%10ld\n", dep->bytes_Rx);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Transmitted/received packets */
|
|
|
|
printf("Tx OK: %8ld\t", dep->de_stat.ets_packetT);
|
|
|
|
printf("Rx OK: %8ld\n", dep->de_stat.ets_packetR);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Transmit/receive errors */
|
|
|
|
printf("Tx Err: %8ld\t", dep->de_stat.ets_sendErr);
|
|
|
|
printf("Rx Err: %8ld\n", dep->de_stat.ets_recvErr);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Transmit unnerruns/receive overrruns */
|
|
|
|
printf("Tx Und: %8ld\t", dep->de_stat.ets_fifoUnder);
|
|
|
|
printf("Rx Ovr: %8ld\n", dep->de_stat.ets_fifoOver);
|
|
|
|
|
|
|
|
/* Transmit collisions/receive CRC errors */
|
|
|
|
printf("Tx Coll: %8ld\t", dep->de_stat.ets_collision);
|
|
|
|
printf("Rx CRC: %8ld\n", dep->de_stat.ets_CRCerr);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-07-10 14:43:38 +02:00
|
|
|
** Name: void get_userdata_s(int user_proc, vir_bytes user_addr, int count, void *loc_addr)
|
2005-06-29 12:16:46 +02:00
|
|
|
** Function: Copies data from user area.
|
|
|
|
*/
|
2006-07-10 14:43:38 +02:00
|
|
|
static void get_userdata_s(int user_proc, cp_grant_id_t grant,
|
|
|
|
vir_bytes offset, int count, void *loc_addr)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
vir_bytes len;
|
|
|
|
|
|
|
|
len = (count > IOVEC_NR ? IOVEC_NR : count) * sizeof(iovec_t);
|
2006-07-10 14:43:38 +02:00
|
|
|
if ((rc = sys_safecopyfrom(user_proc, grant, 0, (vir_bytes)loc_addr, len, D)) != OK)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(CopyErrMsg, rc);
|
2005-06-29 12:16:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void do_first_init(dpeth_t *dep, dp_conf_t *dcp);
|
|
|
|
** Function: Init action to setup task
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_first_init(dpeth_t *dep, const dp_conf_t *dcp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
|
2012-05-09 18:34:40 +02:00
|
|
|
dep->de_linmem = 0xFFFF0000;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
/* Make sure statisics are cleared */
|
|
|
|
memset((void *) &(dep->de_stat), 0, sizeof(eth_stat_t));
|
|
|
|
|
|
|
|
/* Device specific initialization */
|
|
|
|
(*dep->de_initf) (dep);
|
|
|
|
|
2005-09-04 20:52:16 +02:00
|
|
|
/* Set the interrupt handler policy. Request interrupts not to be reenabled
|
2005-07-29 14:44:42 +02:00
|
|
|
* automatically. Return the IRQ line number when an interrupt occurs.
|
|
|
|
*/
|
|
|
|
dep->de_hook = dep->de_irq;
|
2005-09-04 20:52:16 +02:00
|
|
|
sys_irqsetpolicy(dep->de_irq, 0 /*IRQ_REENABLE*/, &dep->de_hook);
|
|
|
|
dep->de_int_pending = FALSE;
|
2005-06-29 12:16:46 +02:00
|
|
|
sys_irqenable(&dep->de_hook);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void do_init(message *mp)
|
|
|
|
** Function: Checks for hardware presence.
|
|
|
|
** Provides initialization of hardware and data structures
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_init(const message * mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
dpeth_t *dep;
|
|
|
|
dp_conf_t *dcp;
|
|
|
|
message reply_mess;
|
2010-05-18 00:22:53 +02:00
|
|
|
int r, confnr;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep = &de_state;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Pick a default configuration for this instance. */
|
|
|
|
confnr = MIN(de_instance, DP_CONF_NR-1);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dcp = &dp_conf[confnr];
|
|
|
|
strcpy(dep->de_name, DevName);
|
|
|
|
dep->de_name[4] = '0' + de_instance;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
if (dep->de_mode == DEM_DISABLED) {
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
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;
|
2005-06-29 12:16:46 +02:00
|
|
|
}
|
2010-05-18 00:22:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
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;
|
2010-01-26 11:59:01 +01:00
|
|
|
}
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2006-07-10 14:43:38 +02:00
|
|
|
reply_mess.m_type = DL_CONF_REPLY;
|
2010-05-18 00:22:53 +02:00
|
|
|
reply_mess.DL_STAT = r;
|
|
|
|
if (r == OK)
|
|
|
|
*(ether_addr_t *) reply_mess.DL_HWADDR = dep->de_address;
|
2005-06-29 12:16:46 +02:00
|
|
|
DEBUG(printf("\t reply %d\n", reply_mess.m_type));
|
|
|
|
if (send(mp->m_source, &reply_mess) != OK) /* Can't send */
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(SendErrMsg, mp->m_source);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void dp_next_iovec(iovec_dat_t *iovp)
|
|
|
|
** Function: Retrieves data from next iovec element.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void dp_next_iovec(iovec_dat_s_t * iovp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
iovp->iod_iovec_s -= IOVEC_NR;
|
2006-07-10 14:43:38 +02:00
|
|
|
iovp->iod_iovec_offset += IOVEC_NR * sizeof(iovec_t);
|
|
|
|
get_userdata_s(iovp->iod_proc_nr, iovp->iod_grant, iovp->iod_iovec_offset,
|
2005-06-29 12:16:46 +02:00
|
|
|
iovp->iod_iovec_s, iovp->iod_iovec);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: int calc_iovec_size(iovec_dat_t *iovp)
|
|
|
|
** Function: Compute the size of a request.
|
|
|
|
*/
|
2006-07-10 14:43:38 +02:00
|
|
|
static int calc_iovec_size(iovec_dat_s_t * iovp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
int size, ix;
|
|
|
|
|
|
|
|
size = ix = 0;
|
|
|
|
do {
|
|
|
|
size += iovp->iod_iovec[ix].iov_size;
|
|
|
|
if (++ix >= IOVEC_NR) {
|
|
|
|
dp_next_iovec(iovp);
|
|
|
|
ix = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Till all vectors added */
|
|
|
|
} while (ix < iovp->iod_iovec_s);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-01-20 18:59:48 +01:00
|
|
|
** Name: void do_vwrite_s(message *mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
** Function:
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_vwrite_s(const message * mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
int size;
|
2005-06-29 12:16:46 +02:00
|
|
|
dpeth_t *dep;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep = &de_state;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep->de_client = mp->m_source;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
if (dep->de_mode == DEM_ENABLED) {
|
|
|
|
|
|
|
|
if (dep->de_flags & DEF_SENDING) /* Is sending in progress? */
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("send already in progress ");
|
2005-06-29 12:16:46 +02:00
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
dep->de_write_iovec.iod_proc_nr = mp->m_source;
|
|
|
|
get_userdata_s(mp->m_source, mp->DL_GRANT, 0,
|
2006-07-10 14:43:38 +02:00
|
|
|
mp->DL_COUNT, dep->de_write_iovec.iod_iovec);
|
|
|
|
dep->de_write_iovec.iod_iovec_s = mp->DL_COUNT;
|
2010-03-04 17:15:26 +01:00
|
|
|
dep->de_write_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
|
2006-07-10 14:43:38 +02:00
|
|
|
dep->de_write_iovec.iod_iovec_offset = 0;
|
|
|
|
size = calc_iovec_size(&dep->de_write_iovec);
|
2005-06-29 12:16:46 +02:00
|
|
|
if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(SizeErrMsg, size);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
dep->de_flags |= DEF_SENDING;
|
|
|
|
(*dep->de_sendf) (dep, FALSE, size);
|
|
|
|
|
|
|
|
} else if (dep->de_mode == DEM_SINK)
|
|
|
|
dep->de_flags |= DEF_ACK_SEND;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
reply(dep);
|
2005-06-29 12:16:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-07-10 14:43:38 +02:00
|
|
|
** Name: void do_vread_s(message *mp, int vectored)
|
2005-06-29 12:16:46 +02:00
|
|
|
** Function:
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_vread_s(const message * mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
int size;
|
2005-06-29 12:16:46 +02:00
|
|
|
dpeth_t *dep;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep = &de_state;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep->de_client = mp->m_source;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
if (dep->de_mode == DEM_ENABLED) {
|
|
|
|
|
|
|
|
if (dep->de_flags & DEF_READING) /* Reading in progress */
|
2010-03-05 16:05:11 +01:00
|
|
|
panic("read already in progress");
|
2005-06-29 12:16:46 +02:00
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
dep->de_read_iovec.iod_proc_nr = mp->m_source;
|
|
|
|
get_userdata_s(mp->m_source, (cp_grant_id_t) mp->DL_GRANT, 0,
|
2006-07-10 14:43:38 +02:00
|
|
|
mp->DL_COUNT, dep->de_read_iovec.iod_iovec);
|
|
|
|
dep->de_read_iovec.iod_iovec_s = mp->DL_COUNT;
|
2010-03-04 17:15:26 +01:00
|
|
|
dep->de_read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
|
2006-07-10 14:43:38 +02:00
|
|
|
dep->de_read_iovec.iod_iovec_offset = 0;
|
|
|
|
size = calc_iovec_size(&dep->de_read_iovec);
|
2010-03-05 16:05:11 +01:00
|
|
|
if (size < ETH_MAX_PACK_SIZE) panic(SizeErrMsg, size);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
dep->de_flags |= DEF_READING;
|
|
|
|
(*dep->de_recvf) (dep, FALSE, size);
|
|
|
|
#if 0
|
|
|
|
if ((dep->de_flags & (DEF_READING | DEF_STOPPED)) == (DEF_READING | DEF_STOPPED))
|
|
|
|
/* The chip is stopped, and all arrived packets delivered */
|
|
|
|
(*dep->de_resetf) (dep);
|
|
|
|
dep->de_flags &= NOT(DEF_STOPPED);
|
|
|
|
#endif
|
|
|
|
}
|
2010-05-18 00:22:53 +02:00
|
|
|
reply(dep);
|
2005-06-29 12:16:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-07-10 14:43:38 +02:00
|
|
|
** Name: void do_getstat_s(message *mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
** Function: Reports device statistics.
|
|
|
|
*/
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_getstat_s(const message * mp)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
int rc;
|
2005-06-29 12:16:46 +02:00
|
|
|
dpeth_t *dep;
|
2010-05-18 00:22:53 +02:00
|
|
|
message reply_mess;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep = &de_state;
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
if (dep->de_mode == DEM_ENABLED) (*dep->de_getstatsf) (dep);
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
if ((rc = sys_safecopyto(mp->m_source, mp->DL_GRANT, 0,
|
2006-07-10 14:43:38 +02:00
|
|
|
(vir_bytes)&dep->de_stat,
|
|
|
|
(vir_bytes) sizeof(dep->de_stat), 0)) != OK)
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(CopyErrMsg, rc);
|
2005-06-29 12:16:46 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
reply_mess.m_type = DL_STAT_REPLY;
|
|
|
|
rc= send(mp->m_source, &reply_mess);
|
|
|
|
if (rc != OK)
|
|
|
|
panic("do_getname: send failed: %d", rc);
|
|
|
|
return;
|
2005-10-21 19:09:08 +02:00
|
|
|
}
|
|
|
|
|
2005-06-29 12:16:46 +02:00
|
|
|
/*
|
2010-05-18 00:22:53 +02:00
|
|
|
** Name: void dp_stop(dpeth_t *dep)
|
2005-06-29 12:16:46 +02:00
|
|
|
** Function: Stops network interface.
|
|
|
|
*/
|
2010-05-18 00:22:53 +02:00
|
|
|
static void dp_stop(dpeth_t * dep)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
if (dep->de_mode == DEM_ENABLED && (dep->de_flags & DEF_ENABLED)) {
|
|
|
|
|
|
|
|
/* Stop device */
|
|
|
|
(dep->de_stopf) (dep);
|
|
|
|
dep->de_flags = DEF_EMPTY;
|
|
|
|
dep->de_mode = DEM_DISABLED;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-07 13:25:51 +02:00
|
|
|
static void do_watchdog(const void *UNUSED(message))
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
DEBUG(printf("\t no reply"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void handle_hw_intr(void)
|
2009-09-29 20:47:56 +02:00
|
|
|
{
|
|
|
|
dpeth_t *dep;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
dep = &de_state;
|
|
|
|
|
|
|
|
/* If device is enabled and interrupt pending */
|
|
|
|
if (dep->de_mode == DEM_ENABLED) {
|
|
|
|
dep->de_int_pending = TRUE;
|
|
|
|
(*dep->de_interruptf) (dep);
|
|
|
|
if (dep->de_flags & (DEF_ACK_SEND | DEF_ACK_RECV))
|
|
|
|
reply(dep);
|
|
|
|
dep->de_int_pending = FALSE;
|
|
|
|
sys_irqenable(&dep->de_hook);
|
2009-09-29 20:47:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* SEF functions and variables. */
|
2012-03-25 20:25:53 +02:00
|
|
|
static void sef_local_startup(void);
|
|
|
|
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
|
|
|
|
static void sef_cb_signal_handler(int signo);
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
|
2005-06-29 12:16:46 +02:00
|
|
|
/*
|
|
|
|
** Name: int dpeth_task(void)
|
|
|
|
** Function: Main entry for dp task
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int main(int argc, char **argv)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
message m;
|
2010-04-08 15:41:35 +02:00
|
|
|
int ipc_status;
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
int rc;
|
2005-10-21 19:09:08 +02:00
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* SEF local startup. */
|
2005-08-05 20:37:15 +02:00
|
|
|
env_setargs(argc, argv);
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
sef_local_startup();
|
2005-10-21 19:09:08 +02:00
|
|
|
|
2005-06-29 12:16:46 +02:00
|
|
|
while (TRUE) {
|
2010-04-08 15:41:35 +02:00
|
|
|
if ((rc = netdriver_receive(ANY, &m, &ipc_status)) != OK){
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(RecvErrMsg, rc);
|
2010-01-20 18:59:48 +01:00
|
|
|
}
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
DEBUG(printf("eth: got message %d, ", m.m_type));
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
if (is_ipc_notify(ipc_status)) {
|
2009-09-29 20:47:56 +02:00
|
|
|
switch(_ENDPOINT_P(m.m_source)) {
|
|
|
|
case CLOCK:
|
|
|
|
/* to be defined */
|
|
|
|
do_watchdog(&m);
|
|
|
|
break;
|
|
|
|
case HARDWARE:
|
|
|
|
/* Interrupt from device */
|
|
|
|
handle_hw_intr();
|
|
|
|
break;
|
|
|
|
case TTY_PROC_NR:
|
|
|
|
/* Function key pressed */
|
|
|
|
do_dump(&m);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Invalid message type */
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(TypeErrMsg, m.m_type);
|
2009-09-29 20:47:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* message processed, get another one */
|
2005-10-21 16:39:21 +02:00
|
|
|
continue;
|
2009-09-29 20:47:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (m.m_type) {
|
2006-07-10 14:43:38 +02:00
|
|
|
case DL_WRITEV_S: /* Write message to device */
|
|
|
|
do_vwrite_s(&m);
|
2005-06-29 12:16:46 +02:00
|
|
|
break;
|
2006-07-10 14:43:38 +02:00
|
|
|
case DL_READV_S: /* Read message from device */
|
|
|
|
do_vread_s(&m);
|
2005-06-29 12:16:46 +02:00
|
|
|
break;
|
2006-07-10 14:43:38 +02:00
|
|
|
case DL_CONF: /* Initialize device */
|
2005-06-29 12:16:46 +02:00
|
|
|
do_init(&m);
|
|
|
|
break;
|
2006-07-10 14:43:38 +02:00
|
|
|
case DL_GETSTAT_S: /* Get device statistics */
|
|
|
|
do_getstat_s(&m);
|
2005-06-29 12:16:46 +02:00
|
|
|
break;
|
|
|
|
default: /* Invalid message type */
|
2010-03-05 16:05:11 +01:00
|
|
|
panic(TypeErrMsg, m.m_type);
|
2005-06-29 12:16:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OK; /* Never reached, but keeps compiler happy */
|
|
|
|
}
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_local_startup *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void sef_local_startup()
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
{
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
/* Register init callbacks. */
|
|
|
|
sef_setcb_init_fresh(sef_cb_init_fresh);
|
2010-04-08 15:41:35 +02:00
|
|
|
sef_setcb_init_lu(sef_cb_init_fresh);
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
sef_setcb_init_restart(sef_cb_init_fresh);
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
/* Register live update callbacks. */
|
|
|
|
sef_setcb_lu_prepare(sef_cb_lu_prepare_always_ready);
|
|
|
|
sef_setcb_lu_state_isvalid(sef_cb_lu_state_isvalid_workfree);
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
/* Register signal callbacks. */
|
|
|
|
sef_setcb_signal_handler(sef_cb_signal_handler);
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* Let SEF perform startup. */
|
|
|
|
sef_startup();
|
|
|
|
}
|
|
|
|
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_cb_init_fresh *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int sef_cb_init_fresh(int type, sef_init_info_t *UNUSED(info))
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
{
|
|
|
|
/* Initialize the dpeth driver. */
|
2010-04-15 20:49:36 +02:00
|
|
|
int fkeys, sfkeys;
|
2010-05-18 00:22:53 +02:00
|
|
|
long v;
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
|
|
|
|
/* Request function key for debug dumps */
|
|
|
|
fkeys = sfkeys = 0; bit_set(sfkeys, 8);
|
|
|
|
if ((fkey_map(&fkeys, &sfkeys)) != OK)
|
|
|
|
printf("%s: couldn't program Shift+F8 key (%d)\n", DevName, errno);
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
v = 0;
|
|
|
|
(void) env_parse("instance", "d", 0, &v, 0, 255);
|
|
|
|
de_instance = (int) v;
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
/* Announce we are up! */
|
|
|
|
netdriver_announce();
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_cb_signal_handler *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void sef_cb_signal_handler(int signo)
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
{
|
|
|
|
/* Only check for termination signal, ignore anything else. */
|
|
|
|
if (signo != SIGTERM) return;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
if (de_state.de_mode == DEM_ENABLED)
|
|
|
|
dp_stop(&de_state);
|
|
|
|
|
|
|
|
exit(0);
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
}
|
|
|
|
|
2005-06-29 12:16:46 +02:00
|
|
|
/** dp.c **/
|