Esempio n. 1
0
static int
hdmi_init(void)
{
	int r;

	/* Turn on HDMI module (slave 0x70) */
	r = enable_hdmi_module();
	if (r != OK) {
		log_warn(&log, "HDMI Module Init Failed\n");
		return -1;
	}

	/* Read chip version to ensure compatibility */
	r = check_revision();
	if (r != OK) {
		log_warn(&log, "Couldn't find expected TDA19988 revision\n");
		return -1;
	}

	/* Turn on DDC interface between TDA19988 and display */
	r = hdmi_ddc_enable();
	if (r != OK) {
		log_warn(&log, "Failed to enable DDC\n");
		return -1;
	}

	return OK;
}
Esempio n. 2
0
static int
sef_cb_init(int type, sef_init_info_t * UNUSED(info))
{
	int r;

	if (type == SEF_INIT_LU) {
		/* Restore the state. */
		lu_state_restore();
	}

	/* look-up the endpoint for the bus driver */
	bus_endpoint = i2cdriver_bus_endpoint(bus);
	if (bus_endpoint == 0) {
		log_warn(&log, "Couldn't find bus driver.\n");
		return EXIT_FAILURE;
	}

	/* claim the device */
	r = i2cdriver_reserve_device(bus_endpoint, address);
	if (r != OK) {
		log_warn(&log, "Couldn't reserve device 0x%x (r=%d)\n",
		    address, r);
		return EXIT_FAILURE;
	}

	/* check that the chip / rev is reasonable */
	r = check_revision();
	if (r != OK) {
		/* prevent user from using the driver with a different chip */
		log_warn(&log, "Bad CHIPID\n");
		return EXIT_FAILURE;
	}

	/* enable interrupts */
	r = intr_enable();
	if (r != OK) {
		log_warn(&log, "Failed to enable interrupts.\n");
		return EXIT_FAILURE;
	}

	/* enable power-off pin so the kernel can cut power to the SoC */
	enable_pwr_off();

	if (type != SEF_INIT_LU) {

		/* sign up for updates about the i2c bus going down/up */
		r = i2cdriver_subscribe_bus_updates(bus);
		if (r != OK) {
			log_warn(&log, "Couldn't subscribe to bus updates\n");
			return EXIT_FAILURE;
		}

		i2cdriver_announce(bus);
		log_debug(&log, "announced\n");
	}

	return OK;
}
Esempio n. 3
0
static int
sef_cb_init(int type, sef_init_info_t * UNUSED(info))
{
	int r, i;

	if (type == SEF_INIT_LU) {
		/* Restore the state. */
		lu_state_restore();
	}

	/* look-up the endpoint for the bus driver */
	bus_endpoint = i2cdriver_bus_endpoint(bus);
	if (bus_endpoint == 0) {
		log_warn(&log, "Couldn't find bus driver.\n");
		return EXIT_FAILURE;
	}

	for (i = 0; i < NADDRESSES; i++) {

		/* claim the device */
		r = i2cdriver_reserve_device(bus_endpoint, addresses[i]);
		if (r != OK) {
			log_warn(&log, "Couldn't reserve device 0x%x (r=%d)\n",
			    addresses[i], r);
			return EXIT_FAILURE;
		}
	}

	/* check that the chip / rev is reasonable */
	r = check_revision();
	if (r != OK) {
		/* prevent user from using the driver with a different chip */
		log_warn(&log, "Bad IDCODE\n");
		return EXIT_FAILURE;
	}

	r = rtc_init();
	if (r != OK) {
		log_warn(&log, "RTC Start-up Failed\n");
		return EXIT_FAILURE;
	}

	if (type != SEF_INIT_LU) {

		/* sign up for updates about the i2c bus going down/up */
		r = i2cdriver_subscribe_bus_updates(bus);
		if (r != OK) {
			log_warn(&log, "Couldn't subscribe to bus updates\n");
			return EXIT_FAILURE;
		}

		i2cdriver_announce(bus);
		log_debug(&log, "announced\n");
	}

	return OK;
}
int main(int argc, char ** argv)
{
	if(argc != 2)
	{
		std::cout << argv[0] << " <path to D2 binaries with terminating slash/backslash>" << std::endl;
		return 1;
	}

	std::string directory(argv[1]);

	std::cout << "Running check_revision tests:" << std::endl << std::endl;

	for(std::size_t i = 0; i < nil::countof(mpq_strings); i++)
	{
		ulong sum = 0;
		check_revision_result_type result = check_revision(formulas[i], mpq_strings[i], directory, sum);
		std::cout << "Key " << (i + 1) << " result: " << result_to_string(result) << ", checksum: " << std::hex << sum << std::endl;
	}

	std::cout << std::endl << "Running hash_d2key tests:" << std::endl << std::endl;

	for(std::size_t i = 0; i < nil::countof(keys); i++)
	{
		std::string hash, public_value;
		bool result = hash_d2key(keys[i], client_token, server_token, hash, public_value);
		std::cout << "Key " << (i + 1);
		if(result)
		{
			std::cout << ":" << std::endl;
			std::cout << "Hash: ";
			print_data(hash);
			std::cout << "Public value: ";
			print_data(public_value);
		}
		else
			std::cout << " is invalid" << std::endl;
	}

	std::cout << std::endl << "Running double_hash tests:" << std::endl << std::endl;

	for(std::size_t i = 0; i < nil::countof(passwords); i++)
	{
		std::string hash = double_hash(client_token, server_token, passwords[i]);
		std::cout << "Password " << (i + 1) << ": ";
		print_data(hash);
	}

#ifdef NIL_WINDOWS
	//haha
	std::cin.get();
#endif

	return 0;
}
Esempio n. 5
0
void dbmanager::update_page(QString pageid)
{
    // update a single page as requested by user .
    int revid ;
    QSqlQuery query("SELECT page_revision FROM Pages WHERE page_ID = '" + pageid + "'");
    while(query.next()){
        revid = query.value(0).toInt();
    }
    check_revision(pageid,revid);


}
Esempio n. 6
0
void
spcs_s_copyout(spcs_s_info_t *kstatus_a, spcs_s_info_t ustatus)
{
#ifdef UNISTAT_TRACE
	cmn_err(CE_WARN, "!spcs_s_copyout entry");
#endif
	if (check_revision(ustatus) == B_TRUE)
		scopyout((spcs_s_pinfo_t *)*kstatus_a,
		    (spcs_s_pinfo_t *)ustatus);
#ifdef UNISTAT_TRACE
	cmn_err(CE_WARN, "!spcs_s_copyout exit");
#endif
}
Esempio n. 7
0
void dbmanager::update()
{

    // universal update function . called when users wants to  update all pages

    QDir dir(data_path);
    dir.cd("WTL_appdata");

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");//not dbConnection
    db.setDatabaseName(dir.absoluteFilePath("WTL.db"));
    if(!db.open())
    {
        qDebug() <<"error in opening DB";
    }
    else
    {
        qDebug() <<"connected to DB" ;
    }


    bool change = false ;


    QVector<QString> id ;
    QVector<int> revid;


    QSqlQuery query("SELECT page_ID , page_revision FROM Pages");
    while (query.next()) {
        QString i = query.value(0).toString();
        id.push_back(i);
        int r = query.value(1).toInt();
        revid.push_back(r);

    }
    for(int i = 0 ; i < id.size() ; i++){
        change  = check_revision(id[i] , revid[i]);
        qDebug() << id[i];
        qDebug() << revid[i];
        if(change == true)
        {
            qDebug() << " same";
        }
        else
        {
            qDebug() << "need update";

        }
    }

}
Esempio n. 8
0
spcs_s_status_t
spcs_s_ocopyoutf(spcs_s_info_t *kstatus_a,
		spcs_s_info_t ustatus, spcs_s_status_t stcode, ...)
{
	spcs_s_udata_t ret;
	va_list ap;
	spcs_s_udata_t c;
	spcs_s_pinfo_t *p;
	char *sp;

#ifdef UNISTAT_TRACE
	cmn_err(CE_WARN, "!spcs_s_ocopyoutf entry");
#endif
	p = *(spcs_s_pinfo_t **)kstatus_a;
	c.s = stcode;

	if (check_revision(ustatus) == B_FALSE) {
		ret.s = EINVAL;
	} else {
		if (stcode) {
			if (add_code(p, stcode) == B_FALSE) {
				va_start(ap, stcode);

				while (c.f.sup_count--) {
					sp = va_arg(ap, caddr_t);
					if (sp != (char *)NULL)
						add_item(p, sp);
				}

				va_end(ap);
			}
		}

		ret.s = p->icount ? p->idata[last_code_idx(p)].s: SPCS_S_OK;
		scopyout(p, (spcs_s_pinfo_t *)ustatus);
	}
	spcs_s_kfree((spcs_s_info_t)p);
	*kstatus_a = NULL;
#ifdef UNISTAT_TRACE
	cmn_err(CE_WARN, "!spcs_s_ocopyoutf exit");
#endif
	return (ret.s);
}