Beispiel #1
0
/*
 * main()
 *	Startup of the "nvram" server
 */
int
main(void)
{
	/*
	 * Initialize syslog
	 */
	openlog("nvram", LOG_PID, LOG_DAEMON);

	/*
	 * Allocate handle->file hash table.  16 is just a guess
	 * as to what we'll have to handle.
	 */
	filehash = hash_alloc(16);
	if (filehash == 0) {
		syslog(LOG_ERR, "unable to allocate file hash");
		exit(1);
	}

	/*
	 * Enable I/O for the NVRAM index and data ports
	 */
	if (enable_io(RTCSEL, RTCDATA) < 0) {
		syslog(LOG_ERR, "unable to get I/O permissions");
		exit(1);
	}

	/*
	 * Initialise the server parameters for the NVRAM - basically find out
	 * how many bytes of data we can support
	 */
	nvram_init();

	/*
	 * Get a port for the NVRAM server
	 */
	nvram_port = msg_port((port_name)0, &nvram_name);

	/*
	 * Register the device name with the namer
	 */
	if (namer_register("srv/nvram", nvram_name) < 0) {
		syslog(LOG_ERR, "can't register name");
		exit(1);
	}

	/*
	 * Start serving requests for the filesystem
	 */
	nvram_main();
	return(0);
}
Beispiel #2
0
int
main(int argc, char *argv[])
{
	port_name n;
	int status;

	/*
	 * Initialize syslog
	 */
	openlog("parallel", LOG_PID, LOG_DAEMON);

	if (argc != 3) {
		usage();
	}

	if (!strcmp(argv[1], "par0") || (argv[1][0] == '0')) {
		status = par_init(&printer, 0);
	} else if (!strcmp(argv[1], "par1") || (argv[1][0] == '1')) {
		status = par_init(&printer, 1);
	} else if (!strcmp(argv[1], "par2") || (argv[1][0] == '2')) {
		status = par_init(&printer, 2);
	} else {
		usage();
	}
	if (status) {
		syslog(LOG_ERR, "can't get I/O permissions");
		exit(1);
	}
	par_reset(&printer);

	/*
	 * Allocate handle->file hash table.  16 is just a guess
	 * as to what we'll have to handle.
	 */
	filehash = hash_alloc(16);
	if (filehash == 0) {
		syslog(LOG_ERR, "file hash not allocated");
		exit(1);
	}

	lp_port = msg_port((port_name)0, &n);
	if (namer_register(argv[2], n) < 0) {
		syslog(LOG_ERR, "unable to register name '%s'", argv[2]);
		exit(1);
	}

	par_main();
}
Beispiel #3
0
int console_main(void)
{
    int err,i;    
	area_create(0x2000, 0, &screen, AREA_PHYSMAP);
    
    console_port = port_create(0,"console_listen_port");
    send_port = port_create(0,"console_send_port");
	port_option(send_port, PORT_OPT_NOWAIT, 1);
	
    err = namer_register(console_port,"console");

	init_virtscreen(&statbar, 1, 80);
    statbar.back = statbar.data;
	statbar.data = (unsigned short *) (((uint32) screen) + 80*24*2);    
    statbar.lock = sem_create(1,"statbar_lock");
    
    for(i=0;i<10;i++){
        init_virtscreen(&con[i], 24, 80);
        con[i].back = con[i].data;
        con[i].lock = sem_create(1,"vscr_lock");
        vputs(&con[i],CLEAR);
    }
    load(&con[0]);
	
    status(0);
    if(err) vprintf(active,"console: the namer hates us\n");
    else
#ifdef CONSOLE_DEBUG
	    vprintf(active,"console: " FG_GREEN "online." FG_WHITE "\n");
#else
        ;
#endif
    
	thr_create(keyboard_irq_thread, NULL, "console:kbd");
    ready = 1;
    console_thread();
    
    return 0;
}
Beispiel #4
0
/*
 * main()
 *	Startup of a tmpfs filesystem
 *
 * A TMPFS instance expects to start with a command line:
 *	$ tmpfs <filesystem name>
 */
int
main(int argc, char *argv[])
{
	port_name fsname;
	char *namer_name;
	int x;

	/*
	 * Initialize syslog
	 */
	openlog("tmpfs", LOG_PID, LOG_DAEMON);

	/*
	 * Check arguments
	 */
	if (argc != 2) {
		usage();
	}

	/*
	 * Name we'll offer service as
	 */
	namer_name = argv[1];

	/*
	 * Zero memory
	 */
	zeroes = malloc(BLOCKSIZE);
	if (zeroes == 0) {
		syslog(LOG_ERR, "unable to allocte zeroes");
		exit(1);
	}
	bzero(zeroes, BLOCKSIZE);

	/*
	 * Allocate data structures we'll need
	 */
        filehash = hash_alloc(NCACHE/4);
	if (filehash == 0) {
		syslog(LOG_ERR, "file hash not allocated");
		exit(1);
        }
	ll_init(&files);

	/*
	 * Last check is that we can register with the given name.
	 */
	rootport = msg_port((port_name)0, &fsname);
	x = namer_register(namer_name, fsname);
	if (x < 0) {
		syslog(LOG_ERR, "can't register name '%s'", fsname);
		exit(1);
	}

	/*
	 * Start serving requests for the filesystem
	 */
	syslog(LOG_INFO, "filesystem established");
	tmpfs_main();
	return(0);
}