/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { message m_out; int r, ipc_status; size_t size; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); for (;;) { /* Wait for request. */ if(driver_receive(ANY, &m_in, &ipc_status) != OK) { panic("driver_receive failed"); } #if DEBUG2 printf("Filter: got request %d from %d\n", m_in.m_type, m_in.m_source); #endif if(m_in.m_source == DS_PROC_NR && is_ipc_notify(ipc_status)) { ds_event(); continue; } who_e = m_in.m_source; req_id = m_in.BDEV_ID; grant_id = m_in.BDEV_GRANT; size = 0; /* Forword the request message to the drivers. */ switch(m_in.m_type) { case BDEV_OPEN: /* open/close is a noop for filter. */ case BDEV_CLOSE: r = OK; break; case BDEV_READ: r = do_rdwt(FLT_READ); break; case BDEV_WRITE: r = do_rdwt(FLT_WRITE); break; case BDEV_GATHER: r = do_vrdwt(FLT_READ); break; case BDEV_SCATTER: r = do_vrdwt(FLT_WRITE); break; case BDEV_IOCTL: r = do_ioctl(&m_in); break; default: printf("Filter: ignoring unknown request %d from %d\n", m_in.m_type, m_in.m_source); continue; } #if DEBUG2 printf("Filter: replying with code %d\n", r); #endif /* Send back reply message. */ m_out.m_type = BDEV_REPLY; m_out.BDEV_ID = req_id; m_out.BDEV_STATUS = r; send(who_e, &m_out); } return 0; }
/* ** Name: int dpeth_task(void) ** Function: Main entry for dp task */ PUBLIC int main(int argc, char **argv) { message m; int ipc_status; int rc; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); while (TRUE) { if ((rc = netdriver_receive(ANY, &m, &ipc_status)) != OK){ panic(RecvErrMsg, rc); } DEBUG(printf("eth: got message %d, ", m.m_type)); if (is_ipc_notify(ipc_status)) { 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 */ panic(TypeErrMsg, m.m_type); break; } /* message processed, get another one */ continue; } switch (m.m_type) { case DL_WRITEV_S: /* Write message to device */ do_vwrite_s(&m); break; case DL_READV_S: /* Read message from device */ do_vread_s(&m); break; case DL_CONF: /* Initialize device */ do_init(&m); break; case DL_GETSTAT_S: /* Get device statistics */ do_getstat_s(&m); break; default: /* Invalid message type */ panic(TypeErrMsg, m.m_type); break; } } return OK; /* Never reached, but keeps compiler happy */ }
int main(int argc, char **argv) { env_setargs(argc, argv); sef_local_startup(); return 0; }
int main(int argc, char *argv[]) { env_setargs(argc, argv); sef_local_startup(); virtio_net_main_loop(); }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { env_setargs(argc, argv); netdriver_task(&rl_table); return 0; }
int main(int argc, char **argv) { /* Set and apply the environment */ env_setargs(argc, argv); sef_local_startup(); blockdriver_task(&mmc_driver); return EXIT_SUCCESS; }
/* * The e1000 driver. */ int main(int argc, char * argv[]) { env_setargs(argc, argv); /* Let the netdriver library take control. */ netdriver_task(&e1000_table); return 0; }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char **argv) { /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* Call the generic receive loop. */ blockdriver_task(&fbd_dtab); return OK; }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { int r; int ipc_status; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); while (TRUE) { if ((r = netdriver_receive(ANY, &m, &ipc_status)) != OK) panic("netdriver_receive failed: %d", r); if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(m.m_source)) { case CLOCK: /* * Under MINIX, synchronous alarms are used * instead of watchdog functions. * The approach is very different: MINIX VMD * timeouts are handled within the kernel * (the watchdog is executed by CLOCK), and * notify() the driver in some cases. MINIX * timeouts result in a SYN_ALARM message to * the driver and thus are handled where they * should be handled. Locally, watchdog * functions are used again. */ rl_watchdog_f(NULL); break; case HARDWARE: do_hard_int(); if (int_event_check) { check_int_events(); } break ; default: panic("illegal notify from: %d", m.m_type); } /* done, get nwe message */ continue; } switch (m.m_type) { case DL_WRITEV_S: rl_writev_s(&m, FALSE); break; case DL_READV_S: rl_readv_s(&m, FALSE); break; case DL_CONF: rl_init(&m); break; case DL_GETSTAT_S: rl_getstat_s(&m); break; default: panic("illegal message: %d", m.m_type); } } }
/*===========================================================================* * main * *===========================================================================*/ PUBLIC int main(int argc, char *argv[]) { /* This is the main routine of this service. The main loop consists of * three major activities: getting new work, processing the work, and * sending the reply. The loop never terminates, unless a panic occurs. */ int error, ind; unsigned short test_endian = 1; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); le_CPU = (*(unsigned char *) &test_endian == 0 ? 0 : 1); /* Server isn't tested on big endian CPU */ ASSERT(le_CPU == 1); while(!unmountdone || !exitsignaled) { endpoint_t src; /* Wait for request message. */ get_work(&fs_m_in); src = fs_m_in.m_source; error = OK; caller_uid = INVAL_UID; /* To trap errors */ caller_gid = INVAL_GID; req_nr = fs_m_in.m_type; if (req_nr < VFS_BASE) { fs_m_in.m_type += VFS_BASE; req_nr = fs_m_in.m_type; } ind = req_nr - VFS_BASE; if (ind < 0 || ind >= NREQS) { printf("mfs: bad request %d\n", req_nr); printf("ind = %d\n", ind); error = EINVAL; } else { error = (*fs_call_vec[ind])(); /*cch_check();*/ } fs_m_out.m_type = error; reply(src, &fs_m_out); if (error == OK) read_ahead(); /* do block read ahead */ } }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { dpeth_t *dep; message m; int ipc_status; int r; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); while (TRUE) { if ((r= netdriver_receive(ANY, &m, &ipc_status)) != OK) panic("netdriver_receive failed: %d", r); if(is_ipc_notify(ipc_status)) { switch(_ENDPOINT_P(m.m_source)) { case CLOCK: do_watchdog(&m); break; case HARDWARE: dep = &de_state; if (dep->de_mode == DEM_ENABLED) { do_interrupt(dep); if (dep->de_flags & (DEF_ACK_SEND | DEF_ACK_RECV)) do_reply(dep); sys_irqenable(&dep->de_hook); } break; default: printf("ignoring notify from %d\n", m.m_source); break; } continue; } switch (m.m_type) { case DL_WRITEV_S: do_vwrite_s(&m, FALSE); break; case DL_READV_S: do_vread_s(&m, FALSE); break; case DL_CONF: do_conf(&m); break; case DL_GETSTAT_S: do_get_stat_s(&m); break; default: printf("message 0x%x; %d from %d\n", m.m_type, m.m_type-DL_RQ_BASE, m.m_source); panic("illegal message: %d", m.m_type); } } }
/* * Driver task. */ int main(int argc, char **argv) { /* Initialize the driver. */ env_setargs(argc, argv); vnd_startup(); /* Process requests until shutdown. */ blockdriver_task(&vnd_dtab); return 0; }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { /* This is the main routine of this service. */ /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* The fsdriver library does the actual work here. */ fsdriver_task(&mfs_table); return(0); }
/*============================================================================* * main * *============================================================================*/ int main(int argc, char *argv[]) { struct machine machine; env_setargs(argc, argv); sys_getmachine(&machine); if (BOARD_IS_BB(machine.board_id)) netdriver_task(&lan8710a_table); return EXIT_SUCCESS; }
int main(int argc, char **argv) { env_setargs(argc, argv); sef_local_startup(); blockdriver_mt_task(&virtio_blk_dtab); dprintf(("Terminating")); virtio_blk_cleanup(); return OK; }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char **argv) { /* Driver task. */ message m; int ipc_status; int r; /* Initialize SEF. */ env_setargs(argc, argv); sef_local_startup(); while (TRUE) { if ((r = netdriver_receive(ANY, &m, &ipc_status)) != OK) panic("netdriver_receive failed: %d", r); if (is_ipc_notify(ipc_status)) { switch (m.m_source) { case HARDWARE: /* interrupt */ atl2_intr(&m); break; case TTY_PROC_NR: /* function key */ atl2_dump(); break; default: printf("ATL2: illegal notify from %d\n", m.m_source); } continue; } /* Process requests from Inet. */ switch (m.m_type) { case DL_CONF: atl2_conf(&m); break; case DL_GETSTAT_S: atl2_getstat(&m); break; case DL_WRITEV_S: atl2_writev(&m, FALSE); break; case DL_READV_S: atl2_readv(&m, FALSE); break; default: printf("ATL2: illegal message %d from %d\n", m.m_type, m.m_source); } } }
int __wrap_main(int argc, char *argv[]) { int i; int new_argc = 0; static char* new_argv[PUFFS_MAX_ARGS]; char *name; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); global_kcred.pkcr_type = PUFFCRED_TYPE_INTERNAL; if (argc < 3) { panic("Unexpected arguments, use:\ mount -t fs /dev/ /dir [-o option1,option2]\n"); }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { message m; int ipc_status; int r; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* * Enter the main driver loop. */ while (TRUE) { if ((r= netdriver_receive(ANY, &m, &ipc_status)) != OK) { panic("netdriver_receive failed: %d", r); } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(m.m_source)) { case HARDWARE: e1000_interrupt(&m); break; case CLOCK: break; } continue; } switch (m.m_type) { case DL_WRITEV_S: e1000_writev_s(&m, FALSE); break; case DL_READV_S: e1000_readv_s(&m, FALSE); break; case DL_CONF: e1000_init(&m); break; case DL_GETSTAT_S: e1000_getstat_s(&m); break; default: panic("illegal message: %d", m.m_type); } } }
/*===========================================================================* * dpeth_task * *===========================================================================*/ int main(int argc, char *argv[]) { message m; int ipc_status; int r; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); while (TRUE) { if ((r= netdriver_receive(ANY, &m, &ipc_status)) != OK) panic("dp8390: netdriver_receive failed: %d", r); if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(m.m_source)) { case HARDWARE: handle_hw_intr(); break; case CLOCK: printf("dp8390: notify from CLOCK\n"); break; default: panic("dp8390: illegal notify from: %d", m.m_source); } /* done, get a new message */ continue; } switch (m.m_type) { case DL_WRITEV_S: do_vwrite_s(&m, FALSE); break; case DL_READV_S: do_vread_s(&m); break; case DL_CONF: do_init(&m); break; case DL_GETSTAT_S: do_getstat_s(&m); break; default: panic("dp8390: illegal message: %d", m.m_type); } } }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char *argv[]) { int r; message m; int ipc_status; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); for (;;) { r= driver_receive(ANY, &m, &ipc_status); if (r != OK) panic("driver_receive failed: %d", r); printf("ti1225: got message %u from %d\n", m.m_type, m.m_source); } return 0; }
int main(int argc, char **argv) { message m; int r; env_setargs(argc, argv); sef_local_startup(); for (;;) { if ((r = sef_receive(ANY, &m)) != OK) panic("sef_receive failed (%d)\n", r); m.m_type = do_request(&m); send(m.m_source, &m); } return 0; }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char **argv) { /* This is the main routine of this service. The main loop consists of * three major activities: getting new work, processing the work, and * sending the reply. The loop never terminates, unless a panic occurs. */ int result; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* Main loop - get work and do it, forever. */ while (TRUE) { /* Wait for incoming message, sets 'callnr' and 'who'. */ get_work(); if (is_notify(callnr)) { switch (_ENDPOINT_P(who_e)) { case TTY_PROC_NR: result = do_fkey_pressed(&m_in); break; default: /* FIXME: error message. */ result = EDONTREPLY; break; } } else { printf("IS: warning, got illegal request %d from %d\n", callnr, m_in.m_source); result = EDONTREPLY; } /* Finally send reply message, unless disabled. */ if (result != EDONTREPLY) { reply(who_e, result); } } return(OK); /* shouldn't come here */ }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char **argv) { endpoint_t ep_self, ep_requestor, ep_child; cp_grant_id_t gid; int i, r, pid; char *buf; int status; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* Prepare work. */ buf = (char*) CLICK_CEIL(buf_buf); fid_send = open(FIFO_GRANTOR, O_WRONLY); fid_get = open(FIFO_REQUESTOR, O_RDONLY); if(fid_get < 0 || fid_send < 0) { printf("GRANTOR: can't open fifo files.\n"); return 1; } /* Get the requestor's endpoint. */ read(fid_get, &ep_requestor, sizeof(ep_requestor)); dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor); /* Grant. */ gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE, CPF_READ | CPF_WRITE | CPF_MAP); ep_self = getprocnr(); dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid); write(fid_send, &ep_self, sizeof(ep_self)); write(fid_send, &gid, sizeof(gid)); /* Test safemap. */ buf[0] = 0; FIFO_NOTIFY(fid_send); FIFO_WAIT(fid_get); return 0; }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char **argv) { /* The main message loop. */ message m; int r, ipc_status; env_setargs(argc, argv); sef_local_startup(); while (TRUE) { if ((r = driver_receive(ANY, &m, &ipc_status)) != OK) panic("driver_receive failed: %d", r); if (is_ipc_notify(ipc_status)) { switch (m.m_source) { case HARDWARE: vbox_intr(); break; case CLOCK: vbox_update_time(); break; default: printf("VBOX: received notify from %d\n", m.m_source); } continue; } hgcm_message(&m, ipc_status); } return 0; }
int main(int argc, char *argv[]) { int r; env_setargs(argc, argv); r = tda19988_env_parse(); if (r < 0) { log_warn(&log, "Expecting -args 'cec_bus=X cec_address=0xAA hdmi_bus=Y hdmi_address=0xBB'\n"); log_warn(&log, "Example -args 'cec_bus=1 cec_address=0x34 hdmi_bus=1 hdmi_address=0x70'\n"); return EXIT_FAILURE; } sef_local_startup(); log_debug(&log, "Startup Complete\n"); blockdriver_task(&tda19988_tab); log_debug(&log, "Shutting down\n"); return OK; }
PUBLIC int main(int argc, char *argv[]) { message m; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); while (TRUE) { int r; int i; if ((r = sef_receive(ANY, &m)) != OK) printf("sef_receive failed %d.\n", r); who_e = m.m_source; call_type = m.m_type; if(verbose) printf("IPC: get %d from %d\n", call_type, who_e); if (call_type & NOTIFY_MESSAGE) { switch (who_e) { case PM_PROC_NR: /* PM sends a notify() on shutdown, * checkout if there are still IPC keys, * give warning messages. */ if (!is_sem_nil() || !is_shm_nil()) printf("IPC: exit with un-clean states.\n"); break; case VM_PROC_NR: /* currently, only semaphore needs such information. */ sem_process_vm_notify(); break; default: printf("IPC: ignoring notify() from %d\n", who_e); break; } continue; } /* dispatch messages */ for (i = 0; i < SIZE(ipc_calls); i++) { if (ipc_calls[i].type == call_type) { int result; result = ipc_calls[i].func(&m); if (ipc_calls[i].reply) break; m.m_type = result; if(verbose && result != OK) printf("IPC: error for %d: %d\n", call_type, result); if ((r = sendnb(who_e, &m)) != OK) printf("IPC send error %d.\n", r); break; } } if (i == SIZE(ipc_calls)) { /* warn and then ignore */ printf("IPC unknown call type: %d from %d.\n", call_type, who_e); } update_refcount_and_destroy(); } /* no way to get here */ return -1; }
/*===========================================================================* * main * *===========================================================================*/ PUBLIC int main(int argc, char **argv) { /* This is the main routine of this service. The main loop consists of * three major activities: getting new work, processing the work, and * sending the reply. The loop never terminates, unless a panic occurs. */ message m; int result; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* Main loop - get work and do it, forever. */ while (TRUE) { /* Wait for incoming message, sets 'callnr' and 'who'. */ get_work(&m); if (is_notify(callnr)) { printf("DS: warning, got illegal notify from: %d\n", m.m_source); result = EINVAL; goto send_reply; } switch (callnr) { case DS_PUBLISH: result = do_publish(&m); break; case DS_RETRIEVE: result = do_retrieve(&m); break; case DS_RETRIEVE_LABEL: result = do_retrieve_label(&m); break; case DS_DELETE: result = do_delete(&m); break; case DS_SUBSCRIBE: result = do_subscribe(&m); break; case DS_CHECK: result = do_check(&m); break; case DS_SNAPSHOT: result = do_snapshot(&m); break; case GETSYSINFO: result = do_getsysinfo(&m); break; default: printf("DS: warning, got illegal request from %d\n", m.m_source); result = EINVAL; } send_reply: /* Finally send reply message, unless disabled. */ if (result != EDONTREPLY) { m.m_type = result; /* build reply message */ reply(who_e, &m); /* send it away */ } } return(OK); /* shouldn't come here */ }
/*===========================================================================* * main * *===========================================================================*/ int main(int argc, char **argv) { endpoint_t ep_self, ep_child; size_t size = BUF_SIZE; int i, r, pid; int status; u64_t start, end, diff; double micros; char nr_pages_str[10], is_map_str[2], is_write_str[2]; int nr_pages, is_map, is_write; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); /* Parse the command line. */ r = env_get_param("pages", nr_pages_str, sizeof(nr_pages_str)); errno = 0; nr_pages = atoi(nr_pages_str); if (r != OK || errno || nr_pages <=0) { exit_usage(); } if(nr_pages > TEST_PAGE_NUM) { printf("REQUESTOR: too many pages. Max allowed: %d\n", TEST_PAGE_NUM); exit_usage(); } r = env_get_param("map", is_map_str, sizeof(is_map_str)); errno = 0; is_map = atoi(is_map_str); if (r != OK || errno || (is_map!=0 && is_map!=1)) { exit_usage(); } r = env_get_param("write", is_write_str, sizeof(is_write_str)); errno = 0; is_write = atoi(is_write_str); if (r != OK || errno || (is_write!=0 && is_write!=1)) { exit_usage(); } printf("REQUESTOR: Running tests with pages=%d map=%d write=%d...\n", nr_pages, is_map, is_write); /* Prepare work. */ buf = (char*) CLICK_CEIL(buf_buf); fid_get = open(FIFO_GRANTOR, O_RDONLY); fid_send = open(FIFO_REQUESTOR, O_WRONLY); if(fid_get < 0 || fid_send < 0) { printf("REQUESTOR: can't open fifo files.\n"); return 1; } /* Send the endpoint to the granter, in order to let him to * create the grant. */ ep_self = getprocnr(); write(fid_send, &ep_self, sizeof(ep_self)); dprint("REQUESTOR: sending my endpoint: %d\n", ep_self); /* Get the granter's endpoint and gid. */ read(fid_get, &ep_granter, sizeof(ep_granter)); read(fid_get, &gid, sizeof(gid)); dprint("REQUESTOR: getting granter's endpoint %d and gid %d\n", ep_granter, gid); FIFO_WAIT(fid_get); diff = make64(0, 0); if(is_map) { /* Test safemap. */ for(i=0;i<NR_TEST_ITERATIONS;i++) { read_tsc_64(&start); r = sys_safemap(ep_granter, gid, 0, (long)buf, nr_pages*CLICK_SIZE, D, 1); if(r != OK) { printf("REQUESTOR: safemap error: %d\n", r); return 1; } read_write_buff(buf, nr_pages*CLICK_SIZE, is_write); read_tsc_64(&end); diff = add64(diff, (sub64(end, start))); r = sys_safeunmap(D, (long)buf); if(r != OK) { printf("REQUESTOR: safeunmap error: %d\n", r); return 1; } } micros = ((double)tsc_64_to_micros(diff)) / (NR_TEST_ITERATIONS*nr_pages); REPORT_TEST("REQUESTOR", "SAFEMAP", micros); } else { /* Test safecopy. */ for(i=0;i<NR_TEST_ITERATIONS;i++) { read_tsc_64(&start); r = sys_safecopyfrom(ep_granter, gid, 0, (long)buf, nr_pages*CLICK_SIZE, D); if(r != OK) { printf("REQUESTOR: safecopy error: %d\n", r); return 1; } read_write_buff(buf, nr_pages*CLICK_SIZE, is_write); read_tsc_64(&end); diff = add64(diff, (sub64(end, start))); } micros = ((double)tsc_64_to_micros(diff)) / (NR_TEST_ITERATIONS*nr_pages); REPORT_TEST("REQUESTOR", "SAFECOPY", micros); } FIFO_NOTIFY(fid_send); return 0; }
int main(int argc, char *argv[]) { int r, i; struct tm t; endpoint_t user, caller; message m; int ipc_status, reply_status; env_setargs(argc, argv); r = i2cdriver_env_parse(&bus, &addresses[0], valid_addrs); if (r < 0) { log_warn(&log, "Expecting -args 'bus=X address=0xYY'\n"); log_warn(&log, "Example -args 'bus=1 address=0x48'\n"); return EXIT_FAILURE; } else if (r > 0) { log_warn(&log, "Invalid slave address for device, expecting 0x48\n"); return EXIT_FAILURE; } sef_local_startup(); while (TRUE) { /* Receive Message */ r = sef_receive_status(ANY, &m, &ipc_status); if (r != OK) { log_warn(&log, "sef_receive_status() failed\n"); continue; } if (is_ipc_notify(ipc_status)) { if (m.m_source == DS_PROC_NR) { for (i = 0; i < NADDRESSES; i++) { /* changed state, update endpoint */ i2cdriver_handle_bus_update (&bus_endpoint, bus, addresses[i]); } } /* Do not reply to notifications. */ continue; } caller = m.m_source; log_debug(&log, "Got message 0x%x from 0x%x\n", m.m_type, caller); switch (m.m_type) { case RTCDEV_GET_TIME_G: /* Any user can read the time */ reply_status = rtc_get_time(&t, m.RTCDEV_FLAGS); if (reply_status != OK) { break; } /* write results back to calling process */ reply_status = store_t(caller, (cp_grant_id_t) m.RTCDEV_GRANT, &t); break; case RTCDEV_SET_TIME_G: /* Only super user is allowed to set the time */ if (getnuid(caller) == SUPER_USER) { /* read time from calling process */ reply_status = fetch_t(caller, (cp_grant_id_t) m.RTCDEV_GRANT, &t); if (reply_status != OK) { break; } reply_status = rtc_set_time(&t, m.RTCDEV_FLAGS); } else { reply_status = EPERM; } break; case RTCDEV_PWR_OFF: reply_status = ENOSYS; break; default: /* Unrecognized call */ reply_status = EINVAL; break; } /* Send Reply */ m.m_type = RTCDEV_REPLY; m.RTCDEV_STATUS = reply_status; log_debug(&log, "Sending Reply"); r = sendnb(caller, &m); if (r != OK) { log_warn(&log, "sendnb() failed\n"); continue; } } rtc_exit(); return 0; }
/*===========================================================================* * main * *===========================================================================*/ PUBLIC int main(int argc, char *argv[]) { /* This is the main routine of this service. The main loop consists of * three major activities: getting new work, processing the work, and * sending the reply. The loop never terminates, unless a panic occurs. */ int error = OK, ind, transid; unsigned short test_endian = 1; /* SEF local startup. */ env_setargs(argc, argv); sef_local_startup(); le_CPU = (*(unsigned char *) &test_endian == 0 ? 0 : 1); /* Server isn't tested on big endian CPU */ ASSERT(le_CPU == 1); while(!unmountdone || !exitsignaled) { endpoint_t src; /* Wait for request message. */ get_work(&fs_m_in); transid = TRNS_GET_ID(fs_m_in.m_type); fs_m_in.m_type = TRNS_DEL_ID(fs_m_in.m_type); if (fs_m_in.m_type == 0) { assert(!IS_VFS_FS_TRANSID(transid)); fs_m_in.m_type = transid; /* Backwards compat. */ transid = 0; } else assert(IS_VFS_FS_TRANSID(transid)); src = fs_m_in.m_source; caller_uid = INVAL_UID; /* To trap errors */ caller_gid = INVAL_GID; req_nr = fs_m_in.m_type; if (req_nr < VFS_BASE) { fs_m_in.m_type += VFS_BASE; req_nr = fs_m_in.m_type; } ind = req_nr - VFS_BASE; if (ind < 0 || ind >= NREQS) { printf("mfs: bad request %d\n", req_nr); printf("ind = %d\n", ind); error = EINVAL; } else { error = (*fs_call_vec[ind])(); } fs_m_out.m_type = error; if (IS_VFS_FS_TRANSID(transid)) { /* If a transaction ID was set, reset it */ fs_m_out.m_type = TRNS_ADD_ID(fs_m_out.m_type, transid); } reply(src, &fs_m_out); if (error == OK) read_ahead(); /* do block read ahead */ } return 0; }