static int __ui_cre_mbx(struct pt_regs *regs) { ID mbxid = __xn_reg_arg1(regs); T_CMBX pk_cmbx; if (__xn_safe_copy_from_user(&pk_cmbx, (void __user *)__xn_reg_arg2(regs), sizeof(pk_cmbx))) return -EFAULT; return cre_mbx(mbxid, &pk_cmbx); }
void task1( unsigned int arg ) { ER ercd; int tests = 0; CYG_TEST_INFO( "Task 1 running" ); ercd = dis_dsp(); CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); ercd = sta_tsk( 2, 22222 ); CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" ); ercd = chg_pri( 2, 5 ); CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" ); ercd = ena_dsp(); CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" ); ercd = dly_tsk( 10 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_sem( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" ); ercd = del_sem( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" ); ercd = cre_sem( -6, &t_csem ); CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" ); ercd = cre_sem( 99, &t_csem ); CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object ercd = cre_sem( 3, &t_csem ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_sem bad ercd !E_OBJ" ); // delete it so we can play ercd = del_sem( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" ); // check it is deleted ercd = sig_sem( 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); ercd = preq_sem( 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "preq_sem bad ercd !E_NOEXS" ); ercd = twai_sem( 3, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "twai_sem bad ercd !E_NOEXS" ); ercd = wai_sem( 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "wai_sem bad ercd !E_NOEXS" ); ercd = ref_sem( &t_rsem, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_sem bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_sem( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" ); #endif ercd = cre_sem( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" ); t_csem.sematr = 0xfff; ercd = cre_sem( 3, &t_csem ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_sem bad ercd !E_RSATR" ); t_csem.sematr = 0; #endif // we can test bad param error returns ercd = cre_sem( 3, &t_csem ); CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); // and check we can use it ercd = sig_sem( 3 ); CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" ); ercd = wai_sem( 3 ); CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" ); ercd = preq_sem( 3 ); CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" ); ercd = twai_sem( 3, 2 ); CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" ); ercd = ref_sem( &t_rsem, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_sem( 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_sem( 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" ); // check they are deleted ercd = sig_sem( 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); ercd = sig_sem( 2 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); // re-create and do it again ercd = cre_sem( 1, &t_csem ); CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); ercd = cre_sem( 2, &t_csem ); CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); // now wait while task 2 deletes the wait objects again ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_sem( 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_sem( 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" ); // check they are deleted ercd = sig_sem( 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); ercd = sig_sem( 2 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete semaphores"); #endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_flg( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" ); ercd = del_flg( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" ); ercd = cre_flg( -6, &t_cflg ); CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" ); ercd = cre_flg( 99, &t_cflg ); CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_flg bad ercd !E_OBJ" ); // delete it so we can play ercd = del_flg( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" ); // check it is deleted ercd = set_flg( 3, 0x6789 ); CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" ); ercd = clr_flg( 3, 0x9876 ); CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" ); ercd = pol_flg( &scratch, 3, 0xdddd, TWF_ANDW ); CYG_TEST_CHECK( E_NOEXS == ercd, "pol_flg bad ercd !E_NOEXS" ); ercd = twai_flg( &scratch, 3, 0x4444, TWF_ORW, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "twai_flg bad ercd !E_NOEXS" ); ercd = wai_flg( &scratch, 3, 0xbbbb, TWF_ANDW | TWF_CLR ); CYG_TEST_CHECK( E_NOEXS == ercd, "wai_flg bad ercd !E_NOEXS" ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_flg bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_flg( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" ); #endif ercd = cre_flg( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" ); t_cflg.flgatr = 0xfff; ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_flg bad ercd !E_RSATR" ); #endif // we can test bad param error returns // now create it well t_cflg.flgatr = 0; t_cflg.iflgptn = 0; ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); // and check we can use it ercd = clr_flg( 3, 0x7256 ); CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" ); ercd = set_flg( 3, 0xff ); CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" ); ercd = wai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR ); CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" ); ercd = pol_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR ); CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" ); ercd = twai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR, 2 ); CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" ); CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" ); // now create it again with a preset pattern and check that we can // detect that pattern: ercd = del_flg( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" ); t_cflg.flgatr = 0; t_cflg.iflgptn = 0x1234; ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); // and check we can use it ercd = wai_flg( &scratch, 3, 0x1200, TWF_ANDW ); CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" ); ercd = pol_flg( &scratch, 3, 0x0034, TWF_ANDW ); CYG_TEST_CHECK( E_OK == ercd, "pol_flg bad ercd" ); ercd = twai_flg( &scratch, 3, 0x1004, TWF_ANDW, 10 ); CYG_TEST_CHECK( E_OK == ercd, "twai_flg bad ercd" ); ercd = pol_flg( &scratch, 3, 0xffedcb, TWF_ORW ); CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" ); CYG_TEST_CHECK( 0x1234 == t_rflg.flgptn, "ref_flg bad ercd" ); ercd = clr_flg( 3, 0 ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" ); CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_flg( &scratch, 1, 0xaa, TWF_ANDW ); CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_flg( &scratch, 2, 0x55, TWF_ANDW, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" ); // check they are deleted ercd = set_flg( 1, 0x22 ); CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" ); ercd = clr_flg( 2, 0xdd ); CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" ); // re-create and do it again t_cflg.iflgptn = 0x5555; ercd = cre_flg( 1, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); t_cflg.iflgptn = 0; ercd = cre_flg( 2, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); // now wait while task 2 deletes the wait objects again ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_flg( &scratch, 1, 0xaaaa, TWF_ORW | TWF_CLR ); CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_flg( &scratch, 2, 0xffff, TWF_ORW, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" ); // check they are deleted ercd = clr_flg( 1, 0xd00d ); CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" ); ercd = set_flg( 2, 0xfff00 ); CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete flags"); #endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_mbx( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" ); ercd = del_mbx( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" ); ercd = cre_mbx( -6, &t_cmbx ); CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" ); ercd = cre_mbx( 99, &t_cmbx ); CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object ercd = cre_mbx( 3, &t_cmbx ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_mbx bad ercd !E_OBJ" ); // delete it so we can play ercd = del_mbx( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" ); // check it is deleted ercd = snd_msg( 3, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); ercd = rcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "rcv_msg bad ercd !E_NOEXS" ); ercd = trcv_msg( &msg, 3, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "trcv_msg bad ercd !E_NOEXS" ); ercd = prcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "prcv_msg bad ercd !E_NOEXS" ); ercd = ref_mbx( &t_rmbx, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mbx bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_mbx( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" ); #endif ercd = cre_mbx( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" ); t_cmbx.mbxatr = 0xfff; ercd = cre_mbx( 3, &t_cmbx ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_mbx bad ercd !E_RSATR" ); t_cmbx.mbxatr = 0; #endif // we can test bad param error returns ercd = cre_mbx( 3, &t_cmbx ); CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" ); // and check we can use it ercd = snd_msg( 3, t_msg ); CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" ); ercd = rcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" ); ercd = trcv_msg( &msg, 3, 2 ); CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" ); ercd = prcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" ); ercd = ref_mbx( &t_rmbx, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = rcv_msg( &msg, 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = trcv_msg( &msg, 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" ); // check they are deleted ercd = snd_msg( 1, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); ercd = snd_msg( 2, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); // re-create and do it again ercd = cre_mbx( 1, &t_cmbx ); CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" ); ercd = cre_mbx( 2, &t_cmbx ); CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" ); // now wait while task 2 deletes the wait objects again ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = rcv_msg( &msg, 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = trcv_msg( &msg, 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" ); // check they are deleted ercd = snd_msg( 1, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); ercd = snd_msg( 2, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete mboxes"); #endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE ercd = ter_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); ercd = dly_tsk( 5 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); // all done if ( 0 == tests ) { CYG_TEST_NA( "No objects have create/delete enabled" ); } else { CYG_TEST_EXIT( "All done" ); } ext_tsk(); }