Esempio n. 1
0
int kchar_init(void)
{
    sysarg_t present;
    int rc = sysinfo_get_value("fb", &present);
    if (rc != EOK)
        present = false;

    if (!present)
        return ENOENT;

    sysarg_t kind;
    rc = sysinfo_get_value("fb.kind", &kind);
    if (rc != EOK)
        kind = (sysarg_t) -1;

    if (kind != 3)
        return EINVAL;

    sysarg_t paddr;
    rc = sysinfo_get_value("fb.address.physical", &paddr);
    if (rc != EOK)
        return rc;

    rc = physmem_map((void *) paddr,
                     ALIGN_UP(1, PAGE_SIZE) >> PAGE_WIDTH,
                     AS_AREA_READ | AS_AREA_WRITE, (void *) &kchar.addr);
    if (rc != EOK)
        return rc;

    return serial_init(kchar_putchar, kchar_control_puts);
}
Esempio n. 2
0
static int cuda_init(void)
{
	if (sysinfo_get_value("cuda.address.physical", &(instance->cuda_physical)) != EOK)
		return -1;
	
	void *vaddr;
	if (pio_enable((void *) instance->cuda_physical, sizeof(cuda_t), &vaddr) != 0)
		return -1;
	
	dev = vaddr;

	instance->cuda = dev;
	instance->xstate = cx_listen;
	instance->bidx = 0;
	instance->snd_bytes = 0;

	fibril_mutex_initialize(&instance->dev_lock);

	/* Disable all interrupts from CUDA. */
	pio_write_8(&dev->ier, IER_CLR | ALL_INT);

	cuda_irq_code.ranges[0].base = (uintptr_t) instance->cuda_physical;
	cuda_irq_code.cmds[0].addr = (void *) &((cuda_t *) instance->cuda_physical)->ifr;
	async_set_interrupt_received(cuda_irq_handler);
	irq_register(10, device_assign_devno(), 0, &cuda_irq_code);

	/* Enable SR interrupt. */
	pio_write_8(&dev->ier, TIP | TREQ);
	pio_write_8(&dev->ier, IER_SET | SR_INT);

	/* Enable ADB autopolling. */
	cuda_autopoll_set(true);

	return 0;
}
QString QmSystemInformationPrivate::valueForKey(const QString &key) const
{
    QString value("");
    uint8_t *data = 0;
    #if HAVE_SYSINFO
    unsigned long size = 0;

    if (!systemConfig) {
        goto EXIT;
    }

    if (sysinfo_get_value(systemConfig, key.toStdString().c_str(), &data, &size) != 0) {
        /* Failed to read the key from the system configuration */
        goto EXIT;
    }

    for (unsigned long k=0; k < size; k++) {
        /* Values can contain non-ascii data -> escape those */
        int c = data[k];
        if (c < 32 || c > 126)
            continue;
        value += (char)c;
    }
    #endif /* HAVE_SYSINFO */
    EXIT:
    /* Free allocation done by sysinfo_get_value() */
    if (data) {
        free(data), data = 0;
    }
    return value;
}
/* Returns the product version string */
inline const QString& product()
{
    static QString result;
#ifdef MEEGO
    return result;
#else
    if (result.isNull()) {
        struct system_config *sc = 0;
        if( sysinfo_init(&sc) == 0 ) {
            uint8_t *data = 0;
            unsigned long size = 0;
            if( sysinfo_get_value(sc, "/component/product", &data, &size) == 0 ) {
                result = QString::fromLatin1 ((const char*)data, size);
                free(data);
            }
        }
        sysinfo_finish(sc);

        // this prevents that this block runs twice:
        if (result.isNull()) result = "";

        qDebug ("Product is \"%s\"", qPrintable(result));
    }
    return result;
#endif
}
Esempio n. 5
0
/** Get system uptime
 *
 * @return System uptime (in seconds).
 *
 */
sysarg_t stats_get_uptime(void)
{
	sysarg_t uptime;
	if (sysinfo_get_value("system.uptime", &uptime) != EOK)
		uptime = 0;
	
	return uptime;
}
Esempio n. 6
0
/**
 * Connect to IRC service. This function should be called only from
 * the add_device handler, thus no locking is required.
 *
 * @param nic_data
 *
 * @return EOK		If connection was successful.
 * @return EINVAL	If the IRC service cannot be determined.
 * @return EREFUSED	If IRC service cannot be connected.
 */
int nic_connect_to_services(nic_t *nic_data)
{
	/* IRC service */
	sysarg_t apic;
	sysarg_t i8259;
	services_t irc_service = -1;
	if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) ||
	    ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)))
		irc_service = SERVICE_IRC;
	else
		return EINVAL;
	
	nic_data->irc_session = service_connect_blocking(EXCHANGE_SERIALIZE,
		irc_service, 0, 0);
	if (nic_data->irc_session == NULL)
		return errno;
	
	return EOK;
}
Esempio n. 7
0
/** Get time of day
 *
 * The time variables are memory mapped (read-only) from kernel which
 * updates them periodically.
 *
 * As it is impossible to read 2 values atomically, we use a trick:
 * First we read the seconds, then we read the microseconds, then we
 * read the seconds again. If a second elapsed in the meantime, set
 * the microseconds to zero.
 *
 * This assures that the values returned by two subsequent calls
 * to gettimeofday() are monotonous.
 *
 */
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
	if (ktime == NULL) {
		uintptr_t faddr;
		int rc = sysinfo_get_value("clock.faddr", &faddr);
		if (rc != EOK) {
			errno = rc;
			return -1;
		}
		
		void *addr;
		rc = physmem_map((void *) faddr, 1,
		    AS_AREA_READ | AS_AREA_CACHEABLE, &addr);
		if (rc != EOK) {
			as_area_destroy(addr);
			errno = rc;
			return -1;
		}
		
		ktime = addr;
	}
	
	if (tz) {
		tz->tz_minuteswest = 0;
		tz->tz_dsttime = DST_NONE;
	}
	
	sysarg_t s2 = ktime->seconds2;
	
	read_barrier();
	tv->tv_usec = ktime->useconds;
	
	read_barrier();
	sysarg_t s1 = ktime->seconds1;
	
	if (s1 != s2) {
		tv->tv_sec = max(s1, s2);
		tv->tv_usec = 0;
	} else
		tv->tv_sec = s1;
	
	return 0;
}
Esempio n. 8
0
/** Initialize the APIC driver.
 *
 */
static bool apic_init(void)
{
	sysarg_t apic;
	
	if ((sysinfo_get_value("apic", &apic) != EOK) || (!apic)) {
		printf("%s: No APIC found\n", NAME);
		return false;
	}

	int rc = pio_enable((void *) IO_APIC_BASE, IO_APIC_SIZE,
		(void **) &io_apic);
	if (rc != EOK) {
		printf("%s: Failed to enable PIO for APIC: %d\n", NAME, rc);
		return false;	
	}
	
	async_set_fallback_port_handler(apic_connection, NULL);
	service_register(SERVICE_IRC);
	
	return true;
}
Esempio n. 9
0
int ega_init(void)
{
	sysarg_t present;
	int rc = sysinfo_get_value("fb", &present);
	if (rc != EOK)
		present = false;
	
	if (!present)
		return ENOENT;
	
	sysarg_t kind;
	rc = sysinfo_get_value("fb.kind", &kind);
	if (rc != EOK)
		kind = (sysarg_t) -1;
	
	if (kind != 2)
		return EINVAL;
	
	sysarg_t paddr;
	rc = sysinfo_get_value("fb.address.physical", &paddr);
	if (rc != EOK)
		return rc;
	
	rc = sysinfo_get_value("fb.width", &ega.cols);
	if (rc != EOK)
		return rc;
	
	rc = sysinfo_get_value("fb.height", &ega.rows);
	if (rc != EOK)
		return rc;
	
	rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL);
	if (rc != EOK)
		return rc;
	
	ega.size = (ega.cols * ega.rows) << 1;
	
	rc = physmem_map((void *) paddr,
	    ALIGN_UP(ega.size, PAGE_SIZE) >> PAGE_WIDTH,
	    AS_AREA_READ | AS_AREA_WRITE, (void *) &ega.addr);
	if (rc != EOK)
		return rc;
	
	sysarg_t blinking;
	rc = sysinfo_get_value("fb.blinking", &blinking);
	if (rc != EOK)
		blinking = false;
	
	ega.style_normal = 0xf0;
	ega.style_inverted = 0x0f;
	
	if (blinking) {
		ega.style_normal &= 0x77;
		ega.style_inverted &= 0x77;
	}
	
	outdev_t *dev = outdev_register(&ega_ops, (void *) &ega);
	if (dev == NULL) {
		as_area_destroy(ega.addr);
		return EINVAL;
	}
	
	return EOK;
}