PRIVATE int sef_cb_init(int type, sef_init_info_t *UNUSED(info)) { /* Initialize the counter driver. */ int do_announce_driver = TRUE; open_counter = (-1) ; switch(type) { case SEF_INIT_FRESH: printf("%s", COUNTER_MESSAGE); break; case SEF_INIT_LU: /* Restore the state. */ lu_state_restore(); do_announce_driver = FALSE; printf("%sHey, I'm a new version!\n", COUNTER_MESSAGE); break; case SEF_INIT_RESTART: printf("%sHey, I've just been restarted!\n", COUNTER_MESSAGE); break; } /* Announce we are up when necessary. */ if (do_announce_driver) { chardriver_announce(); } /* Initialization completed successfully. */ return OK; }
static int sef_cb_init(int type, sef_init_info_t *UNUSED(info)) { /* Initialize the fb driver. */ int do_announce_driver = TRUE; open_counter[0] = 0; switch(type) { case SEF_INIT_FRESH: printf("framebuffer fresh: pid %d\n", getpid()); break; case SEF_INIT_LU: /* Restore the state. */ lu_state_restore(); do_announce_driver = FALSE; printf("framebuffer: I'm a new version!\n"); break; case SEF_INIT_RESTART: printf("framebuffer restarted: pid %d\n", getpid()); has_restarted = 1; break; } /* Announce we are up when necessary. */ if (do_announce_driver) { chardriver_announce(); } /* Initialization completed successfully. */ return OK; }
/*===========================================================================* * sef_cb_init_fresh * *===========================================================================*/ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) { /* Initialize the printer driver. */ /* If no printer is present, do not start. */ if (!do_probe()) return ENODEV; /* arbitrary error code */ /* Announce we are up! */ chardriver_announce(); return OK; }
/*===========================================================================* * sef_cb_init_fresh * *===========================================================================*/ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) { /* Initialize the log driver. */ int i; /* Initialize log devices. */ for(i = 0; i < NR_DEVS; i++) { logdevices[i].log_size = logdevices[i].log_read = logdevices[i].log_write = logdevices[i].log_selected = 0; logdevices[i].log_source = NONE; } /* Register for diagnostics notifications. */ sys_diagctl_register(); /* Announce we are up! */ chardriver_announce(); return(OK); }
static int sef_cb_init_fresh(__unused int type, __unused sef_init_info_t *info) { int err; unsigned int hz; nic_init_all(); inet_read_conf(); /* init lwip library */ stats_init(); sys_init(); mem_init(); memp_init(); pbuf_init(); hz = sys_hz(); arp_ticks = ARP_TMR_INTERVAL / (1000 / hz); tcp_fticks = TCP_FAST_INTERVAL / (1000 / hz); tcp_sticks = TCP_SLOW_INTERVAL / (1000 / hz); etharp_init(); set_timer(&arp_tmr, arp_ticks, arp_watchdog, 0); set_timer(&tcp_ftmr, tcp_fticks, tcp_fwatchdog, 0); set_timer(&tcp_stmr, tcp_sticks, tcp_swatchdog, 0); netif_init(); netif_lo = netif_find(__UNCONST("lo0")); /* Read configuration. */ #if 0 nw_conf(); /* Get a random number */ timerand= 1; fd = open(RANDOM_DEV_NAME, O_RDONLY | O_NONBLOCK); if (fd != -1) { err= read(fd, randbits, sizeof(randbits)); if (err == sizeof(randbits)) timerand= 0; else { printf("inet: unable to read random data from %s: %s\n", RANDOM_DEV_NAME, err == -1 ? strerror(errno) : err == 0 ? "EOF" : "not enough data"); } close(fd); } else { printf("inet: unable to open random device %s: %s\n", RANDOM_DEV_NAME, strerror(errno)); } if (timerand) { printf("inet: using current time for random-number seed\n"); err= gettimeofday(&tv, NULL); if (err == -1) { printf("sysutime failed: %s\n", strerror(errno)); exit(1); } memcpy(randbits, &tv, sizeof(tv)); } init_rand256(randbits); #endif /* Subscribe to driver events for network drivers. */ if ((err = ds_subscribe("drv\\.net\\..*", DSF_INITIAL | DSF_OVERWRITE)) != OK) panic(("inet: can't subscribe to driver events")); /* Announce we are up. LWIP announces its presence to VFS just like * any other character driver. */ chardriver_announce(); return(OK); }
/*===========================================================================* * sef_cb_init_fresh * *===========================================================================*/ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info) { /* Initialize the inet server. */ int r; int timerand, fd; u8_t randbits[32]; struct timeval tv; struct passwd *pw; #if DEBUG printf("Starting inet...\n"); printf("%s\n", version); #endif #if HZ_DYNAMIC system_hz = sys_hz(); #endif /* Read configuration. */ nw_conf(); /* Get a random number */ timerand= 1; fd= open(RANDOM_DEV_NAME, O_RDONLY | O_NONBLOCK); if (fd != -1) { r= read(fd, randbits, sizeof(randbits)); if (r == sizeof(randbits)) timerand= 0; else { printf("inet: unable to read random data from %s: %s\n", RANDOM_DEV_NAME, r == -1 ? strerror(errno) : r == 0 ? "EOF" : "not enough data"); } close(fd); } else { printf("inet: unable to open random device %s: %s\n", RANDOM_DEV_NAME, strerror(errno)); } if (timerand) { printf("inet: using current time for random-number seed\n"); r= gettimeofday(&tv, NULL); if (r == -1) { printf("sysutime failed: %s\n", strerror(errno)); exit(1); } memcpy(randbits, &tv, sizeof(tv)); } init_rand256(randbits); /* Our new identity as a server. */ this_proc= info->endpoint; #ifdef BUF_CONSISTENCY_CHECK inet_buf_debug= (getenv("inetbufdebug") && (strcmp(getenv("inetbufdebug"), "on") == 0)); inet_buf_debug= 100; if (inet_buf_debug) { ip_warning(( "buffer consistency check enabled" )); } #endif if (getenv("killerinet")) { ip_warning(( "killer inet active" )); killer_inet= 1; } nw_init(); /* Subscribe to driver events for network drivers. */ r = ds_subscribe("drv\\.net\\..*", DSF_INITIAL | DSF_OVERWRITE); if(r != OK) { ip_panic(("inet: can't subscribe to driver events")); } /* Drop root privileges */ if ((pw = getpwnam(SERVICE_LOGIN)) == NULL) { printf("inet: unable to retrieve uid of SERVICE_LOGIN, " "still running as root"); } else if (setuid(pw->pw_uid) != 0) { ip_panic(("inet: unable to drop privileges")); } /* Announce we are up. INET announces its presence to VFS just like * any other character driver. */ chardriver_announce(); return(OK); }