Beispiel #1
0
/*
 * Initialization of device initial setting information
 */
LOCAL ER initIDev( void )
{
	T_CMBF	cmbf;
	INT	val[2];
	ER	ercd;

	/* Get system information */
	ercd = _tk_get_cfn(SCTAG_TDEVTMBFSZ, val, 2);
	if ( ercd < 2 ) {
		val[0] = -1;
	}

	if ( val[0] >= 0 ) {
		/* Generate message buffer for event notification */
		SetOBJNAME(cmbf.exinf, OBJNAME_DMMBF);
		cmbf.mbfatr = TA_TFIFO;
		cmbf.bufsz  = val[0];
		cmbf.maxmsz = val[1];
		ercd = tk_cre_mbf(&cmbf);
		if ( ercd < E_OK ) {
			DefaultIDev.evtmbfid = 0;
			goto err_ret;
		}
		DefaultIDev.evtmbfid = ercd;
	} else {
		/* Do not use message buffer for event notification */
		DefaultIDev.evtmbfid = 0;
	}

	return E_OK;

err_ret:
	DEBUG_PRINT(("initIDev ercd = %d\n", ercd));
	return ercd;
}
Beispiel #2
0
/*
 * syslog initialization
 */
EXPORT ER initialize_syslog( void )
{
#if USE_SYSLOG_CONSIO
	T_CMBF	cmbf;
	T_CTSK	ctsk;
	ID	tskid;
	ER	ercd;

	/* Generate message buffer */
	SetOBJNAME(cmbf.exinf, OBJNAME_SYSLOG);
	cmbf.mbfatr = TA_TFIFO | TA_NODISWAI;
	cmbf.bufsz  = MBF_LOG_BUFSZ;
	cmbf.maxmsz = MBF_LOG_MAXMSZ;
	ercd = tk_cre_mbf(&cmbf);
	if ( ercd < E_OK ) {
		goto err_ret1;
	}
	log_mbfid = ercd;

	/* Temporarily lower the local task priority 
	   so that the system log task executes initialization sequence. */
	tk_chg_pri(TSK_SELF, 10);

	/* Start log task */
	SetOBJNAME(ctsk.exinf, OBJNAME_SYSLOG);
	ctsk.tskatr  = TA_HLNG | TA_RNG0;
	ctsk.task    = log_task;
	ctsk.itskpri = 6;
	ctsk.stksz   = 512;
	ercd = tk_cre_tsk(&ctsk);
	if ( ercd < E_OK ) {
		goto err_ret1;
	}
	tskid = ercd;
	ercd = tk_sta_tsk(tskid, CONSOLE_PORT);
	if ( ercd < E_OK ) {
		goto err_ret2;
	}

	/* Return local task priority */
	tk_chg_pri(TSK_SELF, TPRI_INI);

	return E_OK;

err_ret2:
	tk_del_tsk(tskid);
err_ret1:
	DEBUG_PRINT(("initialize_syslog ercd = %d\n", ercd));
	return ercd;
#else
	return E_OK;
#endif
}
Beispiel #3
0
/*
        initial setting at driver start up time
*/
LOCAL	ER	kpStartUp(void)
{
	W	w[L_DEVCONF_VAL];
	W	dd, n;
	ER	er;
	RawEvt	evt;
	T_CMBF	cmbf;
	T_CFLG	cflg;
	ID	datatsk;
	void*	name;
	union {
		FlgInStat	stat;
		UW		uw;
	} u;

        /* extract ID of the mailbox for event notification to KB/PD driver */
	dd = er = tk_opn_dev(devkbpd, TD_READ);
	if (er >= E_OK) {
		er = tk_srea_dev(dd, DN_KPINPUT, (VB*)&EvtMbx,
						sizeof(EvtMbx), &n);
		tk_cls_dev(dd, 0);
	}
	if (er < E_OK) goto EEXIT1;

        /* KBID is extracted from DEVCONF parameter */
	KbdId = (GetDevConf("KBTYPE", w) == 1) ? w[0] : KID_IBM_JP;

        /* input message buffer creation */
	SetOBJNAME(cmbf.exinf, "lkbM");
	cmbf.mbfatr = TA_TFIFO;
	cmbf.bufsz  = sizeof(InMsg) * MAX_INMSG;
	cmbf.maxmsz = sizeof(InMsg);
	if ((er = tk_cre_mbf(&cmbf)) < E_OK) goto EEXIT1;
	InpMbf = er;

        /* creating the event flag for command */
	SetOBJNAME(cflg.exinf, "lkbC");
	cflg.flgatr  = TA_WMUL;
	cflg.iflgptn = 0;
	if ((er = tk_cre_flg(&cflg)) < E_OK) goto EEXIT2;
	CmdFlg = (ID)er;

        /* create and start data processing task */
	SetOBJNAME(name, "lkbD");
	er = kpCreTask((W)name, kpDataTask);
	if (er < E_OK) goto EEXIT3;
	datatsk = (ID)er;

        /* create and start command processing task */
	SetOBJNAME(name, "lkbC");
	er = kpCreTask((W)name, kpCmdTask);
	if (er < E_OK) goto EEXIT4;
	CmdTsk = (ID)er;

        /* registering event flag for commands */
	u.uw = 0;
	evt.f.stat = u.stat;
	evt.f.stat.cmd = INP_FLG;
	evt.f.stat.kb = 1;
	evt.f.stat.kbid = KbdId;
	evt.f.stat.reg = 1;
	evt.f.flgid = CmdFlg;
	if ((er = kpSendMsg(&evt)) < E_OK) goto EEXIT5;

        /* device initialization processing */
	er = hwInit(DC_OPEN);
	if (er < E_OK) goto EEXIT5;

	return E_OK;

EEXIT5:
	tk_ter_tsk(CmdTsk);
	tk_del_tsk(CmdTsk);
EEXIT4:
	tk_ter_tsk(datatsk);
	tk_del_tsk(datatsk);
EEXIT3:
	tk_del_flg(CmdFlg);
EEXIT2:
	tk_del_mbf(InpMbf);
EEXIT1:
	DP(("kpStartUp: err=%#x\n", er));
	return er;
}