Ejemplo n.º 1
0
psim_command(device *root,
             char **argv)
{
    int argp = 0;
    if (argv[argp] == NULL) {
        return;
    }
    else if (strcmp(argv[argp], "trace") == 0) {
        const char *opt = find_arg("Missing <trace> option", &argp, argv);
        if (opt[0] == '!')
            trace_option(opt + 1, 0);
        else
            trace_option(opt, 1);
    }
    else if (strcmp(*argv, "change-media") == 0) {
        char *device = find_arg("Missing device name", &argp, argv);
        char *media = argv[++argp];
        device_ioctl(tree_find_device(root, device), NULL, 0,
                     device_ioctl_change_media, media);
    }
    else {
        printf_filtered("Unknown PSIM command %s, try\n", argv[argp]);
        printf_filtered("    trace <trace-option>\n");
        printf_filtered("    change-media <device> [ <new-image> ]\n");
    }
}
Ejemplo n.º 2
0
static int
pow_get_policy(struct msg *msg)
{
    int policy;

    device_ioctl(pmdev, PMIOC_GET_POLICY, &policy);
    msg->data[0] = policy;
    return 0;
}
Ejemplo n.º 3
0
static int
pow_get_dimtmr(struct msg *msg)
{
    int timeout;

    device_ioctl(pmdev, PMIOC_GET_DIMTMR, &timeout);
    msg->data[0] = timeout;
    return 0;
}
Ejemplo n.º 4
0
static int
pow_set_dimtmr(struct msg *msg)
{
    int timeout;

    timeout = msg->data[0];
    device_ioctl(pmdev, PMIOC_SET_DIMTMR, &timeout);
    return 0;
}
Ejemplo n.º 5
0
static int
devfs_ioctl(struct vnode *vp, struct file *fp, u_long cmd, void *arg)
{
	int error;

	error = device_ioctl(vp->v_data, cmd, arg);
	DPRINTF(("devfs_ioctl: cmd=%x\n", cmd));
	return error;
}
Ejemplo n.º 6
0
static int
pow_set_policy(struct msg *msg)
{
    int policy;

    policy = msg->data[0];
    device_ioctl(pmdev, PMIOC_SET_POLICY, &policy);
    return 0;
}
Ejemplo n.º 7
0
void init_mouse_handler(void)
{
    device_id_t uartDevice = api_device_build_id(DEVICE_TYPE_UART, 3);
    mouse_input_handler = device_open(global_device_manager, uartDevice);
    device_ioctl(global_device_manager,mouse_input_handler,UART_DRIVER_INIT,(uint32_t)&uart_protocol_rs232);

    global_mouse_position.x = SCREEN_WIDTH / 2;
    global_mouse_position.y = SCREEN_HEIGHT / 2;

    mouse_click_fetched = FALSE;
}
Ejemplo n.º 8
0
static int device_release(struct inode *inode, struct file *file)
{
	if (tdfe) {
		/* reset the tuner on close */
		if (pol != SEC_VOLTAGE_OFF)
			device_ioctl(NULL, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF);
		filp_close(tdfe, NULL);
	}
	tdfe = NULL;
	usecount--;
	return 0;
}
Ejemplo n.º 9
0
static void
cmd_shutdown(int argc, char **argv)
{
	device_t pm_dev;
	int error, state = PWR_OFF;

	if ((error = device_open("pm", 0, &pm_dev)) == 0) {
		error = device_ioctl(pm_dev, PMIOC_SET_POWER, &state);
		device_close(pm_dev);
	}
	if (error)
		printf("Error %d\n", error);
}
Ejemplo n.º 10
0
int
reboot(int howto)
{
    device_t pm_dev;
    int err, mode;

    mode = (howto & RB_POWERDOWN) ? POWER_OFF : POWER_REBOOT;

    if ((err = device_open("pm", 0, &pm_dev)) == 0) {
        err = device_ioctl(pm_dev, PMIOC_SET_POWER, &mode);
        device_close(pm_dev);
    }
    return err;
}
Ejemplo n.º 11
0
Archivo: reset.c Proyecto: AndrewD/prex
int
main(int argc, char *argv[])
{
	device_t pm_dev;
	int state;

	timer_sleep(2000, 0);

	if (device_open("pm", 0, &pm_dev) != 0)
		exit(1);
	state = POWER_REBOOT;
	device_ioctl(pm_dev, PMIOC_SET_POWER, &state);
	device_close(pm_dev);
	exit(1);
}
Ejemplo n.º 12
0
/*
 * Send TTY signal.
 */
static void
tty_signal(int sig)
{
	pid_t pgid;

	/*
	 * Get the process group that was active when
	 * the TTY signal was invoked.
	 */
	if (device_ioctl(ttydev, TIOCGPGRP, &pgid) != 0)
		return;

	DPRINTF(("proc: tty_signal pgid=%d sig=%d\n", pgid, sig));
	kill_pg(pgid, sig);
}
Ejemplo n.º 13
0
static void
set_power_state(int state)
{

    if (pmdev != NODEV) {
        DPRINTF(("set_power_state: state=%d\n", state));

        sync();
        if (state == PWR_OFF || state == PWR_REBOOT) {
            kill(-1, SIGTERM);
            shutdown_server("!exec");
            shutdown_server("!fs");
            shutdown_server("!proc");
        }
        device_ioctl(pmdev, PMIOC_SET_POWER, &state);
    }
}
Ejemplo n.º 14
0
static void
power_thread(void)
{
    int sig, event, state;

    DPRINTF(("power_thread: start\n"));

    for (;;) {
        /*
         * Wait signals from PM driver.
         */
        exception_wait(&sig);
        DPRINTF(("power_thread: sig=%d\n", sig));

        if (sig == SIGPWR) {
            /*
             * Query PM events.
             */
            device_ioctl(pmdev, PMIOC_QUERY_EVENT, &event);
            DPRINTF(("power_thread: event=%d\n", event));

            /*
             * Do action for current power settings.
             */
            state = PWR_ON;
            switch (event) {
            case PME_PWRBTN_PRESS:
                state = pmact.pwrbtn;
                break;
            case PME_LOW_BATTERY:
                state = pmact.lowbatt;
                break;
            case PME_SLPBTN_PRESS:
                state = pmact.slpbtn;
                break;
            case PME_LCD_CLOSE:
                state = pmact.lcdclose;
                break;
            }
            if (state != PWR_ON)
                set_power_state(state);

        }
    }
}
Ejemplo n.º 15
0
psim_stack(psim *system,
           char **argv,
           char **envp)
{
    /* pass the stack device the argv/envp and let it work out what to
       do with it */
    device *stack_device = tree_find_device(system->devices,
                                            "/openprom/init/stack");
    if (stack_device != (device*)0) {
        unsigned_word stack_pointer;
        ASSERT (psim_read_register(system, 0, &stack_pointer, "sp",
                                   cooked_transfer) > 0);
        device_ioctl(stack_device,
                     NULL, /*cpu*/
                     0, /*cia*/
                     device_ioctl_create_stack,
                     stack_pointer,
                     argv,
                     envp);
    }
}
Ejemplo n.º 16
0
Archivo: tty.c Proyecto: AndrewD/prex
/*
 * Initialize TTY.
 *
 * Since we manage the process group only in the process
 * server, the TTY driver can not know anything about the
 * process group.  However, POSIX specification requires TTY
 * driver to send a signal to the specific process group.
 * So, we will catch all TTY related signals by this server
 * and forward them to the actual process or process group.
 */
void
tty_init(void)
{
	task_t self;

	/*
	 * Setup exception to receive signals from tty.
	 */
	exception_setup(exception_handler);

	if (device_open("tty", 0, &ttydev) != 0)
		ttydev = DEVICE_NULL;
	else {
		/*
		 * Notify the TTY driver to send all tty related
		 * signals in system to this task.
		 */
		self = task_self();
		device_ioctl(ttydev, TIOCSETSIGT, &self);
	}
}
Ejemplo n.º 17
0
/*
 * Initialize TTY.
 *
 * Since we manage the process group only in the process
 * server, the TTY driver can not know anything about the
 * process group.  However, POSIX specification requires TTY
 * driver to send a signal to the specific process group.
 * So, we will catch all TTY related signals by this server
 * and forward them to the actual process or process group.
 */
void
tty_init(void)
{
	task_t self;

	/*
	 * Setup exception to receive signals from tty.
	 */
	exception_setup(exception_handler);

	if (device_open("tty", 0, &ttydev) != 0) {
		DPRINTF(("proc: no tty found\n"));
		ttydev = NODEV;
	} else {
		/*
		 * Notify the TTY driver to send all tty related
		 * signals in system to this task.
		 */
		self = task_self();
		device_ioctl(ttydev, TIOCSETSIGT, &self);
	}
}
Ejemplo n.º 18
0
static void
do_break(os_emul_data *emul,
	 unsigned call,
	 const int arg0,
	 cpu *processor,
	 unsigned_word cia)
{
  /* just pass this onto the `vm' device */
  unsigned_word new_break = cpu_registers(processor)->gpr[arg0];
  int status;

  if (WITH_TRACE && ppc_trace[trace_os_emul])
    printf_filtered ("0x%lx", (long)cpu_registers(processor)->gpr[arg0]);

  SYS(break);
  status = device_ioctl(emul->vm,
			processor,
			cia,
			device_ioctl_break,
			new_break); /*ioctl-data*/
  emul_write_status(processor, 0, status);
}
Ejemplo n.º 19
0
int
main(int argc, char *argv[])
{
	struct winsize ws;
	int rows, cols, i;
	device_t cons;

	/* Get screen size */
	device_open("tty", 0, &cons);
	if (device_ioctl(cons, TIOCGWINSZ, &ws) == 0) {
		rows = (int)ws.ws_row;
		cols = (int)ws.ws_col;
	} else {
		/* Use default screen setting */
		rows = 25;
		cols = 80;
	}
	device_close(cons);

	max_x = (cols - 1) * 10;
	max_y = (rows - 2) * 10;

	/* Clear screen */
	printf("\33[2J");

	/* Create threads and run them. */
	for (i = 0; i < NBALLS; i++) {
		if (thread_run(move_ball, stack[i]+STACKLEN) == 0)
			panic("failed to create thread");
	}

	/* Don't return */
	for (;;)
		thread_yield();

	/* NOTREACHED */
	return 0;
}
Ejemplo n.º 20
0
static void
pow_init(void)
{
    task_t self;

    /*
     * Set default power actions
     */
    pmact.pwrbtn = PWR_OFF;
    pmact.slpbtn = PWR_SUSPEND;
    pmact.lcdclose = PWR_SUSPEND;
    pmact.lowbatt = PWR_OFF;

    /*
     * Connect to the pm driver to get all power events.
     */
    if (device_open("pm", 0, &pmdev) != 0) {
        /*
         * Bad config...
         */
        sys_panic("pow: no pm driver");
    }
    self = task_self();
    device_ioctl(pmdev, PMIOC_CONNECT, &self);

    /*
     * Setup exception to receive signals from pm driver.
     */
    exception_setup(exception_handler);

    /*
     * Start power thread.
     */
    if (run_thread(power_thread))
        sys_panic("pow_init");
}
Ejemplo n.º 21
0
Archivo: led.c Proyecto: AndrewD/prex
int
led_count(device_t dev, u_int *count)
{

	return device_ioctl(dev, LEDIOC_COUNT, count);
}
Ejemplo n.º 22
0
int
main(int argc, char *argv[])
{
	device_t dev;
	int last_mhz = 0;
	int i, j;
	static char bar[21];

	/* Boost current prioriy */
	thread_setpri(thread_self(), 50);

	if (device_open("cpufreq", 0, &dev))
		panic("open error: cpufreq");

	/* Clear screen */
	printf("\33[2J");

	printf("CPU voltage monitor\n");
	device_ioctl(dev, CFIOC_GET_INFO, &cf_info);
	if (cf_info.freq == 0 || cf_info.volts == 0)
		panic("Invalid cpu power/speed");

	/*
	 * Setup periodic timer for 10msec period
	 */
	timer_periodic(thread_self(), 100, 10);
	for (;;) {
		/*
		 * Wait next period
		 */
		timer_waitperiod();
		device_ioctl(dev, CFIOC_GET_INFO, &cf_info);
		if (cf_info.freq != last_mhz) {
			printf("\33[s"); /* save cursor */

			/*
			 * Display speed
			 */
			printf("\nSpeed: %4dMHz  0|", cf_info.freq);
			j = cf_info.freq * 100 / cf_info.maxfreq;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf("%s|100", bar);

			/*
			 * Display power
			 */
			printf("\nPower: %4dmV   0|", cf_info.volts);
			j = cf_info.volts * 100 / cf_info.maxvolts;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf("%s|100", bar);

			printf("\33[u"); /* restore cursor */
			last_mhz = cf_info.freq;
		}
	}
	return 0;
}
Ejemplo n.º 23
0
int
main(int argc, char *argv[])
{
	device_t cpu_dev;
	int last_mhz = 0;
	int i, j;
	static char bar[21];

	/* Boost current prioriy */
	thread_setprio(thread_self(), 50);

	if (device_open("cpu", 0, &cpu_dev))
		panic("open error: cpu");

	/* Clear screen */
	printf("\33[2J");

	printf("CPU voltage monitor\n");
	device_ioctl(cpu_dev, CPUIOC_GET_INFO, &cpu_info);
	if (cpu_info.clock_ctrl == 0)
		panic("DVS not supported by cpu");
	if (cpu_info.speed == 0 || cpu_info.power == 0)
		panic("Invalid cpu power/speed");

	/*
	 * Setup periodic timer for 10msec period
	 */
	timer_periodic(thread_self(), 100, 10);
	for (;;) {
		/*
		 * Wait next period
		 */
		timer_waitperiod();
		device_ioctl(cpu_dev, CPUIOC_GET_STAT, &cpu_stat);
		if (cpu_stat.speed != last_mhz) {
			printf("\33[s"); /* save cursor */

			/*
			 * Display speed
			 */
			printf("\nSpeed: %4dMHz  0|", cpu_stat.speed);
			j = cpu_stat.speed * 100 / cpu_info.speed;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf(bar);
			printf("|100");

			/*
			 * Display power
			 */
			printf("\nPower: %4dmV   0|", cpu_stat.power);
			j = cpu_stat.power * 100 / cpu_info.power;
			for (i = 0; i < 20; i++)
				bar[i] = (i <= j / 5) ? '*' : '-';
			bar[i] = '\0';
			printf(bar);
			printf("|100");

			printf("\33[u"); /* restore cursor */
			last_mhz = cpu_stat.speed;
		}
	}
	return 0;
}
Ejemplo n.º 24
0
Archivo: led.c Proyecto: AndrewD/prex
int
led_on(device_t dev, u_int mask)
{

	return device_ioctl(dev, LEDIOC_ON, &mask);
}
Ejemplo n.º 25
0
Archivo: led.c Proyecto: AndrewD/prex
int
led_off(device_t dev, u_int mask)
{

	return device_ioctl(dev, LEDIOC_OFF, &mask);
}
Ejemplo n.º 26
0
Archivo: led.c Proyecto: AndrewD/prex
int
led_status(device_t dev, u_int *status)
{

	return device_ioctl(dev, LEDIOC_STATUS, status);
}
Ejemplo n.º 27
0
psim_options(device *root,
             char **argv)
{
    device *current = root;
    int argp;
    if (argv == NULL)
        return NULL;
    argp = 0;
    while (argv[argp] != NULL && argv[argp][0] == '-') {
        char *p = argv[argp] + 1;
        char *param;
        while (*p != '\0') {
            switch (*p) {
            default:
                psim_usage(0);
                error ("");
                break;
            case 'c':
                param = find_arg("Missing <count> option for -c (max-iterations)\n", &argp, argv);
                tree_parse(root, "/openprom/options/max-iterations %s", param);
                break;
            case 'e':
                param = find_arg("Missing <emul> option for -e (os-emul)\n", &argp, argv);
                tree_parse(root, "/openprom/options/os-emul %s", param);
                break;
            case 'E':
                /* endian spec, ignored for now */
                param = find_arg("Missing <endian> option for -E (target-endian)\n", &argp, argv);
                if (strcmp (param, "big") == 0)
                    tree_parse (root, "/options/little-endian? false");
                else if (strcmp (param, "little") == 0)
                    tree_parse (root, "/options/little-endian? true");
                else
                {
                    printf_filtered ("Invalid <endian> option for -E (target-endian)\n");
                    psim_usage (0);
                }
                break;
            case 'f':
                param = find_arg("Missing <file> option for -f\n", &argp, argv);
                psim_merge_device_file(root, param);
                break;
            case 'h':
            case '?':
                psim_usage(1);
                break;
            case 'H':
                psim_usage(2);
                break;
            case 'i':
                if (isdigit(p[1])) {
                    tree_parse(root, "/openprom/trace/print-info %c", p[1]);
                    p++;
                }
                else {
                    tree_parse(root, "/openprom/trace/print-info 1");
                }
                break;
            case 'I':
                tree_parse(root, "/openprom/trace/print-info 2");
                tree_parse(root, "/openprom/options/model-issue %d",
                           MODEL_ISSUE_PROCESS);
                break;
            case 'm':
                param = find_arg("Missing <model> option for -m (model)\n", &argp, argv);
                tree_parse(root, "/openprom/options/model \"%s", param);
                break;
            case 'n':
                param = find_arg("Missing <nr-smp> option for -n (smp)\n", &argp, argv);
                tree_parse(root, "/openprom/options/smp %s", param);
                break;
            case 'o':
                param = find_arg("Missing <dev-spec> option for -o\n", &argp, argv);
                if (memcmp(param, "mpc860c0", 8) == 0)
                {
                    if (param[8] == '\0')
                        tree_parse(root, "/options/mpc860c0 5");
                    else if (param[8] == '=' && is_num(param+9, 1, 10, 0))
                    {
                        tree_parse(root, "/options/mpc860c0 %s", param+9);
                    }
                    else error("Invalid mpc860c0 option for -o\n");
                }
                else
                    current = tree_parse(current, "%s", param);
                break;
            case 'r':
                param = find_arg("Missing <ram-size> option for -r (oea-memory-size)\n", &argp, argv);
                tree_parse(root, "/openprom/options/oea-memory-size %s",
                           param);
                break;
            case 't':
                param = find_arg("Missing <trace> option for -t (trace/*)\n", &argp, argv);
                if (param[0] == '!')
                    tree_parse(root, "/openprom/trace/%s 0", param+1);
                else
                    tree_parse(root, "/openprom/trace/%s 1", param);
                break;
            case '-':
                /* it's a long option of the form --optionname=optionvalue.
                   Such options can be passed through if we are invoked by
                   gdb.  */
                if (strstr(argv[argp], "architecture") != NULL) {
                    /* we must consume the argument here, so that we get out
                       of the loop.  */
                    p = argv[argp] + strlen(argv[argp]) - 1;
                    printf_filtered("Warning - architecture parameter ignored\n");
                }
                else
                    error("Unrecognized option");
                break;
            }
            p += 1;
        }
        argp += 1;
    }
    /* force the trace node to process its options now *before* the tree
       initialization occures */
    device_ioctl(tree_find_device(root, "/openprom/trace"),
                 NULL, 0,
                 device_ioctl_set_trace);

    {
        void semantic_init(device* root);
        semantic_init(root);
    }

    /* return where the options end */
    return argv + argp;
}