示例#1
0
static void TestDbCommit(void)
{
	int			rowcount;	/* Number of rows returned */
	char*		sql;		/* Constructed query */
	int			status;		/* Status return */
	int			where = 0;	/* WHERE clause count */

    status = DbBeginTransaction();
	CU_ASSERT_EQUAL(status, 0);

	sql = DisInit("TEST_BASIC");
	DisAppendInt(&sql, 600);
	DisAppendString(&sql, "JKL");
	DisAppendString(&sql, NULL);
	DisEnd(&sql);
	status = DbExecuteSqlNoResult(DbHandle(), sql);
	CU_ASSERT_EQUAL(status, 0);
	DisFree(sql);

    status = DbCommit();
	CU_ASSERT_EQUAL(status, 0);

	/* Check that our row got into the table */

	sql = DqsCountInit("TEST_BASIC");
	DqsConditionInt(&sql, "IVALUE", DQS_COMPARE_EQ, 600, where++);
	DqsEnd(&sql);
	status = DbIntQuery(DbHandle(), &rowcount, sql);
	CU_ASSERT_EQUAL(status, 0);
	DqsFree(sql);

	CU_ASSERT_EQUAL(rowcount, 1);

	return;
}
示例#2
0
mad_status DisasmInit()
{
    if( DisInit( DISCPU_x86, &DH, FALSE ) != DR_OK ) {
        return( MS_ERR | MS_FAIL );
    }
    return( MS_OK );
}
示例#3
0
mad_status DisasmInit()
{
    bool        swap_bytes;

#ifdef __BIG_ENDIAN__
    swap_bytes = true;
#else
    swap_bytes = false;
#endif
    if( DisInit( DISCPU_mips, &DH, swap_bytes ) != DR_OK ) {
        return( MS_ERR | MS_FAIL );
    }
    return( MS_OK );
}
示例#4
0
static void TestDbLastRowId(void)
{
	DB_ID	first_id = 0;	/* ID of first insertion */
	DB_ID	second_id = 0;	/* ID of second insertion */
	char*	sql = NULL;		/* SQL statement */
	int		status;			/* Status return */

	/* Construct the insertion statement */

	sql = DisInit("TEST_BASIC");
	CU_ASSERT_PTR_NOT_NULL(sql);

	DisAppendInt(&sql, 500);
	DisAppendString(&sql, "XYZZY");
	DisAppendString(&sql, "20090101");
	DisEnd(&sql);

	/* Insert and store row IDs */

	status = DbExecuteSqlNoResult(DbHandle(), sql);
	CU_ASSERT_EQUAL(status, 0);

	status = DbLastRowId(DbHandle(), &first_id);
	CU_ASSERT_EQUAL(status, 0);
	CU_ASSERT_NOT_EQUAL(first_id, 0);

	status = DbExecuteSqlNoResult(DbHandle(), sql);
	CU_ASSERT_EQUAL(status, 0);

	status = DbLastRowId(DbHandle(), &second_id);
	CU_ASSERT_EQUAL(status, 0);
	CU_ASSERT_EQUAL(second_id, (first_id + 1));

	/* ... and tidy up */

	DisFree(sql);

	return;

}
示例#5
0
static void dumpCodeBuff( void (*output)( char ),
                          code_buff *buff )
{
    dis_handle          handle;
    dis_dec_ins         ins;
    char                name[ MAX_INS_NAME ];
    char                ops[ MAX_OBJ_NAME + 24 ];

    DisInit( buff->cpu, &handle );
    while( buff->offset < buff->length ){
        DisDecodeInit( &handle, &ins );
        if( buff->cpu == DISCPU_x86 ) {
            ins.flags |= DIF_X86_USE32_FLAGS;
        }
        DisDecode( &handle, buff, &ins );
        DisFormat( &handle, buff, &ins, DFF_AXP_SYMBOLIC_REG|DFF_PSEUDO, &name, &ops );
        myPrintf( output, "\t%4.4x:", buff->offset );
        dumpOpcodes( output, buff->start+buff->offset, ins.size );
        myPrintf( output, "\t%s\t%s\n", name, ops );
        buff->offset += ins.size;
    }
    DisFini( &handle );
}
示例#6
0
static return_val initORL( void )
{
    orl_file_flags      flags;
    orl_machine_type    machine_type;
    orl_return          o_error = ORL_OKAY;
    orl_file_format     type;
    bool                byte_swap;
    ORLSetFuncs( orl_cli_funcs, objRead, objSeek, MemAlloc, MemFree );

    ORLHnd = ORLInit( &orl_cli_funcs );
    if( ORLHnd != ORL_NULL_HANDLE ) {
        type = ORLFileIdentify( ORLHnd, NULL );
        if( type == ORL_UNRECOGNIZED_FORMAT ) {
            PrintErrorMsg( RC_OKAY, WHERE_NOT_COFF_ELF );
            return( RC_ERROR );
        }
        ObjFileHnd = ORLFileInit( ORLHnd, NULL, type );
        if( ObjFileHnd != ORL_NULL_HANDLE ) {
            // check byte order
            flags = ORLFileGetFlags( ObjFileHnd );
            byte_swap = false;
#ifdef __BIG_ENDIAN__
            if( flags & ORL_FILE_FLAG_LITTLE_ENDIAN ) {
                byte_swap = true;
            }
#else
            if( flags & ORL_FILE_FLAG_BIG_ENDIAN ) {
                byte_swap = true;
            }
#endif

            // check intended machine type
            machine_type = GetMachineType();
            switch( machine_type ) {
            // If there's no machine specific code, the CPU we choose shouldn't
            // matter; there are some object files like this.
            case ORL_MACHINE_TYPE_NONE:
            case ORL_MACHINE_TYPE_ALPHA:
                if( DisInit( DISCPU_axp, &DHnd, byte_swap ) != DR_OK ) {
                    ORLFini( ORLHnd );
                    PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                    return( RC_ERROR );
                }
                break;
            case ORL_MACHINE_TYPE_PPC601:
                if( DisInit( DISCPU_ppc, &DHnd, byte_swap ) != DR_OK ) {
                    ORLFini( ORLHnd );
                    PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                    return( RC_ERROR );
                }
                // PAS assembler expects "", not \" for quotes.
                if( (Options & METAWARE_COMPATIBLE) == 0 ) {
                    QuoteChar = '\"';
                }
                break;
            case ORL_MACHINE_TYPE_R3000:
            case ORL_MACHINE_TYPE_R4000:
                if( DisInit( DISCPU_mips, &DHnd, byte_swap ) != DR_OK ) {
                    ORLFini( ORLHnd );
                    PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                    return( RC_ERROR );
                }
                break;
            case ORL_MACHINE_TYPE_I386:
            case ORL_MACHINE_TYPE_I8086:
                if( DisInit( DISCPU_x86, &DHnd, byte_swap ) != DR_OK ) {
                    ORLFini( ORLHnd );
                    PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                    return( RC_ERROR );
                }
                break;
            case ORL_MACHINE_TYPE_AMD64:
                if( DisInit( DISCPU_x64, &DHnd, byte_swap ) != DR_OK ) {
                    ORLFini( ORLHnd );
                    PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                    return( RC_ERROR );
                }
                break;
            case ORL_MACHINE_TYPE_SPARC:
            case ORL_MACHINE_TYPE_SPARCPLUS:
                if( DisInit( DISCPU_sparc, &DHnd, byte_swap ) != DR_OK ) {
                    ORLFini( ORLHnd );
                    PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                    return( RC_ERROR );
                }
                break;
            default:
                ORLFini( ORLHnd );
                PrintErrorMsg( RC_OKAY, WHERE_UNSUPPORTED_PROC );
                return( RC_ERROR );
            }
            return( RC_OKAY );
        } else {
            o_error = ORLGetError( ORLHnd );
            ORLFini( ORLHnd );
            // An "out of memory" error is not necessarily what it seems.
            // The ORL returns this error when encountering a bad or
            // unrecognized object file record.
            if( o_error == ORL_OUT_OF_MEMORY ) {
                PrintErrorMsg( RC_OUT_OF_MEMORY, WHERE_OPENING_ORL );
                return( RC_OUT_OF_MEMORY );
            } else {
                PrintErrorMsg( RC_ERROR, WHERE_OPENING_ORL );
                return( RC_ERROR );
            }
        }
    } else {
        return( RC_OUT_OF_MEMORY );
    }
}
示例#7
0
void initController()
{

	pauseSeq = 1;								//In case of the Timing Engine is in "Firing" on powering up, this setting can prevent it from actually firing

	KPLED_All_Bright();							//Turn on all keypad LEDs (Bright)

	DisInit();									//Initialize Display
	DisCurPos(1,1);
	DisWrStr("Initializing...");				//Show message "Initializing..."

	UartInit();									//Initialize Nios UART


	remoteEn = 1;								//Disable Remote Control (make sure Nios core has the right of the UART)
	DisClear();
	DisCurPos(1,1);
	DisWrStr("Remote Mode!");
	KPLED_All_Off();
	while(remoteEn){
    }
	DisClear();
	DisCurPos(1,1);
	DisWrStr("Initializing...");
	Stop();										//Send a Stop instruction to the Timing Engine. Make sure it's not firing on initial state.


	clrTimer = 1; 								//Reset Password&Heater Timer
	clrTimer = 0;

	clrPreionFault = 1;							//Clear Preion Fault Handler
	clrPreionFault = 0;

	clrInterlock=1;								//Clear Interlock Handler
	clrInterlock=0;

	//InterlockIn=1;
	//InterlockIn=0;

	//InterockSplitted=1;
	//InterockSplitted=0;

	loadData();									//Load Data From EEPROM to Main RAM
	delay(5000);								//There is no signal that indicates if the loading is done so use delay() to wait.

	KPLED_All_Dim();							//Turn on all keypad LEDs (Dim)
	delay(5000);

	reloadRegisters();							//Reload all Timing Engine registers with current data in Main RAM. (Load data from EEPROM does not refresh those registers)


	refreshErrFlags();							//Data Error Check

	CounterInit();								//Load Counters data to FPGA Counter module (from FRAM)

	PowerFailure_Init();						//Power Failure Handler Initialization (enable interrupt and register ISR)

	pauseSeq = 0;								//Clear Pause

	KPLED_All_Off();							//Turn off all keypad LEDs

	printf("Done!\n");							//Send massage through JTAG, for debugging.
}