static int sef_cb_lu_state_save(int UNUSED(state)) { ds_publish_u32("bus", bus, DSF_OVERWRITE); ds_publish_u32("address", address, DSF_OVERWRITE); return OK; }
/*===========================================================================* * test_u32 * *===========================================================================*/ void test_u32(void) { int r; unsigned long value; /* Publish and retrieve. */ r = ds_publish_u32(key_u32, 1234, 0); assert(r == OK); r = ds_retrieve_u32(key_u32, &value); assert(r == OK && value == 1234); /* If dstest deletes 'test_u32' immediately after publishing it, * subs will catch the event, but it can't check it immediately. * So dstest will sleep 2 seconds to wait for subs to complete. */ sleep(2); /* Publish again without DSF_OVERWRITE. */ r = ds_publish_u32(key_u32, 4321, 0); assert(r == EEXIST); /* Publish again with DSF_OVERWRITE to overwrite it. */ r = ds_publish_u32(key_u32, 4321, DSF_OVERWRITE); assert(r == OK); r = ds_retrieve_u32(key_u32, &value); assert(r == OK && value == 4321); /* Delete. */ r = ds_delete_u32(key_u32); assert(r == OK); r = ds_retrieve_u32(key_u32, &value); assert(r == ESRCH); printf("DSTEST: U32 test successful!\n"); }
static int sef_cb_lu_state_save(int UNUSED(state)) { ds_publish_u32("cec_bus", cec_bus, DSF_OVERWRITE); ds_publish_u32("hdmi_bus", hdmi_bus, DSF_OVERWRITE); ds_publish_u32("cec_address", cec_address, DSF_OVERWRITE); ds_publish_u32("hdmi_address", hdmi_address, DSF_OVERWRITE); return OK; }
/*===========================================================================* * blockdriver_announce * *===========================================================================*/ void blockdriver_announce(int type) { /* Announce we are up after a fresh start or a restart. */ int r; char key[DS_MAX_KEYLEN]; char label[DS_MAX_KEYLEN]; char *driver_prefix = "drv.blk."; /* Callers are allowed to use ipc_sendrec to communicate with drivers. * For this reason, there may blocked callers when a driver restarts. * Ask the kernel to unblock them (if any). Note that most block drivers * will not restart statefully, and thus will skip this code. */ if (type == SEF_INIT_RESTART) { if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK) panic("blockdriver_init: sys_statectl failed: %d", r); } /* Publish a driver up event. */ if ((r = ds_retrieve_label_name(label, sef_self())) != OK) panic("blockdriver_init: unable to get own label: %d", r); snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label); if ((r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE)) != OK) panic("blockdriver_init: unable to publish driver up event: %d", r); /* Expect an open for any device before serving regular driver requests. */ clear_open_devs(); /* Initialize or reset the message queue. */ mq_init(); }
static int sef_cb_lu_state_save(int UNUSED(state)) { /* The addresses are fixed/non-configurable so bus is the only state */ ds_publish_u32("bus", bus, DSF_OVERWRITE); return OK; }
/*===========================================================================* * chardriver_announce * *===========================================================================*/ void chardriver_announce(void) { /* 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.chr."; /* Callers are allowed to use sendrec to communicate with drivers. * For this reason, there may blocked callers when a driver restarts. * Ask the kernel to unblock them (if any). */ #if USE_STATECTL if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK) panic("chardriver_init: sys_statectl failed: %d", r); #endif /* Publish a driver up event. */ if ((r = ds_retrieve_label_name(label, getprocnr())) != OK) panic("chardriver_init: unable to get own label: %d", r); snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label); if ((r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE)) != OK) panic("chardriver_init: unable to publish driver up event: %d", r); /* Expect a DEV_OPEN for any device before serving regular driver requests. */ clear_open_devs(); }
static int sef_cb_lu_state_save(int UNUSED(state)) { /* Save the state. */ ds_publish_u32("open_counter", open_counter[0], DSF_OVERWRITE); return OK; }
/*===========================================================================* * netdriver_announce * *===========================================================================*/ PUBLIC 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, getprocnr()); 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; }