Esempio n. 1
0
bool CSerializePrxToMap::StartPrx(const char* szFilename, const PspModule *mod, u32 iSMask)
{
	u32 i;
	u32 addr;

	PrintComment(m_fpOut, "Generated by prxtool");
	PrintComment(m_fpOut, "Make sure to \"Load From Address 0xA0\" to skip the ELF header");
	PrintComment(m_fpOut, "Make sure to load the module as plain binary, not as ELF");
	fprintf(m_fpOut, "# File: %s\n", szFilename);

	addr = mod->addr;

	PrintOffset(m_fpOut, addr);
	fprintf(m_fpOut, ".word\t_module_flags\n");
	fprintf(m_fpOut, ".byte\t_module_name\n");
	for(i=0; i < (sizeof(mod->name)-2); i++)
		fprintf(m_fpOut, ".byte\n");	
	fprintf(m_fpOut, ".word\t_module_gp\n");
	fprintf(m_fpOut, ".word\t_module_exports\n");
	fprintf(m_fpOut, ".word\t_module_exp_end\n");
	fprintf(m_fpOut, ".word\t_module_imports\n");
	fprintf(m_fpOut, ".word\t_module_imp_end\n");

	return true;
}
Esempio n. 2
0
static void
PrintCppFile(FILE *f, ParserState *parse)
{
    /* things we always need */
    if (gl_header) {
        fprintf(f, "%s", gl_header);
    }
    if (parse->topcomment) {
        PrintComment(f, parse->topcomment);
    }
    if (parse->needsStdlib) {
        fprintf(f, "#include <stdlib.h>\n");
    }
    fprintf(f, "#include <propeller.h>\n");
    fprintf(f, "#include \"%s.h\"\n", parse->basename);
    fprintf(f, "\n");
    PrintMacros(f, parse);

    /* declare static functions and variables */
    if (gl_ccode && !gl_nospin) {
        int n;

        n = PrintPrivateFunctionDecls(f, parse);
        if (n > 0)
            fprintf(f, "\n");
    }
    /* print data block, if applicable */
    if (parse->datblock) {
        if (gl_gas_dat) {
            fprintf(f, "extern ");
            PrintDatArray(f, parse, ";\n", false);
            PrintDataBlockForGas(f, parse, 1);
        } else {
            if (gl_ccode) {
                fprintf(f, "static ");
                PrintDatArray(f, parse, " = {\n", false);
            } else {
                PrintDatArray(f, parse, " = {\n", true);
            }
            PrintDataBlock(f, parse, TEXT_OUTPUT);
            fprintf(f, "};\n");
        }
    }
    /* functions */
    PrintFunctionBodies(f, parse);

    /* any closing comments */
    if (parse->botcomment) {
        PrintComment(f, parse->botcomment);
    }

}
Esempio n. 3
0
void PrintRawData(FILE *f, const PTEID_Raw *rawData)
{
	PrintTitle(f,"RawData");
    PrintBytesLenght(f,"ADDRESS", rawData->addrData, rawData->addrLength);
    PrintBytesLenght(f,"ADDR SIG", rawData->addrSigData, rawData->addrSigLength);
    PrintBytesLenght(f,"CARD DATA", rawData->cardData, rawData->cardDataLength);
    PrintBytesLenght(f,"CERT RN", rawData->certRN, rawData->certRNLength);
    PrintBytesLenght(f,"ID DATA", rawData->idData, rawData->idLength);
    PrintBytesLenght(f,"ID SIG", rawData->idSigData, rawData->idSigLength);
    PrintBytesLenght(f,"PICTURE", rawData->pictureData, rawData->pictureLength);
    PrintBytesLenght(f,"TOKEN INFO", rawData->tokenInfo, rawData->tokenInfoLength);
	PrintComment(f,"CHALLENGE COULD NOT BE COMPARED");
    //PrintBytesLenght(f,"CHALLENGE", rawData->challenge, rawData->challengeLength);
	PrintComment(f,"RESPONSE COULD NOT BE COMPARED");
    //PrintBytesLenght(f,"RESPONSE", rawData->response, rawData->responseLength);
}
Esempio n. 4
0
static void
PrintAllConstants(FILE *f, ParserState *parse)
{
    AST *ast, *upper;

    /* print the constant declarations */
    for (upper = parse->conblock; upper; upper = upper->right) {
        ast = upper->left;
        if (ast->kind == AST_COMMENTEDNODE) {
            PrintComment(f, ast->right);
            ast = ast->left;
        }
        switch (ast->kind) {
        case AST_ENUMSKIP:
            PrintConstantDecl(f, ast->left);
            break;
        case AST_IDENTIFIER:
            PrintConstantDecl(f, ast);
            break;
        case AST_ASSIGN:
            PrintConstantDecl(f, ast->left);
            break;
        default:
            /* do nothing */
            break;
        }
    }
}
Esempio n. 5
0
static int
PrintAllVarListsOfType(FILE *f, ParserState *parse, AST *type, int flags)
{
    AST *ast;
    AST *upper;
    AST *comment;
    enum astkind kind;
    int n = 0;

    if (type == ast_type_byte)
        kind = AST_BYTELIST;
    else if (type == ast_type_word)
        kind = AST_WORDLIST;
    else
        kind = AST_LONGLIST;
    
    for (upper = parse->varblock; upper; upper = upper->right) {
        if (upper->kind != AST_LISTHOLDER) {
            ERROR(upper, "internal error: expected listholder");
            return n;
        }
        ast = upper->left;
        comment = NULL;
        if (ast->kind == AST_COMMENTEDNODE) {
            comment = ast->right;
            ast = ast->left;
        }
        if (ast->kind == kind) {
            if (comment)
                PrintComment(f, comment);
            n += PrintVarList(f, type, ast->left, flags);
        }
    }
    return n;
}
Esempio n. 6
0
int
main (int argc, char *argv[])
{
    DisplayModeRec  *Mode;
    int  HDisplay = 0, VDisplay = 0;
    float  VRefresh = 0.0;
    Bool  Reduced = FALSE, Verbose = FALSE, IsCVT;
    Bool  Interlaced = FALSE;
    int  n;

    if ((argc < 3) || (argc > 7)) {
        PrintUsage(argv[0]);
        return 1;
    }

    /* This doesn't filter out bad flags properly. Bad flags get passed down
     * to atoi/atof, which then return 0, so that these variables can get
     * filled next time round. So this is just a cosmetic problem.
     */
    for (n = 1; n < argc; n++) {
        if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced"))
            Reduced = TRUE;
        else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced"))
            Interlaced = TRUE;
        else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose"))
            Verbose = TRUE;
        else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
            PrintUsage(argv[0]);
            return 0;
        } else if (!HDisplay) {
            HDisplay = atoi(argv[n]);
	    if (!HDisplay) {
		PrintUsage(argv[0]);
		return 1;
	    }
	}
        else if (!VDisplay) {
            VDisplay = atoi(argv[n]);
	    if (!VDisplay) {
		PrintUsage(argv[0]);
		return 1;
	    }
	}
        else if (!VRefresh) {
            VRefresh = atof(argv[n]);
	    if (!VRefresh) {
		PrintUsage(argv[0]);
		return 1;
	    }
	}
        else {
            PrintUsage(argv[0]);
            return 1;
        }
    }

    if (!HDisplay || !VDisplay) {
        PrintUsage(argv[0]);
        return 0;
    }

    /* Default to 60.0Hz */
    if (!VRefresh)
        VRefresh = 60.0;

    /* Horizontal timing is always a multiple of 8: round up. */
    if (HDisplay & 0x07) {
        HDisplay &= ~0x07;
        HDisplay += 8;
    }

    if (Reduced) {
	if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
	    fprintf(stderr,
		    "\nERROR: Multiple of 60Hz refresh rate required for "
		    " reduced blanking.\n");
	    PrintUsage(argv[0]);
	    return 0;
	}
    }

    IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);

    Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced);

    PrintComment(Mode, IsCVT, Reduced);
    PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
    
    return 0;
}
Esempio n. 7
0
void PrintTestOther(FILE *f, int Ocsp, int Crl)
{
    PTEID_Status tStatus = {0};
    PTEID_Bytes Application = {0};
    PTEID_Bytes APDU = {0};
    PTEID_Bytes Response = {0};
    PTEID_Bytes FileID = {0};
    PTEID_Bytes Data = {0};
	PTEID_Pins Pins = {0};
	PTEID_Pin Pin = {0};

	PrintTestFunction(f,"PTEID_GetPINs");
	tStatus = PTEID_GetPINs(&Pins);
	PrintStatus(f,"PTEID_GetPINs",&tStatus);

	Pin.pinType   = Pins.pins[0].pinType;
	Pin.id		  = Pins.pins[0].id;
	Pin.usageCode = Pins.pins[0].usageCode;
	Pin.shortUsage = NULL;
	Pin.longUsage  = NULL;

	//PTEID_ReadFile

	Response.length = PTEID_MAX_PICTURE_LEN;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	Application.length = 12;
 	Application.data = (unsigned char *)"\xA0\x00\x00\x01\x77\x50\x4B\x43\x53\x2D\x31\x35";
	FileID.length = 2;
    FileID.data = (unsigned char *)"\x50\x38";

 	PrintTestFunction(f,"PTEID_SelectApplication");
    tStatus = PTEID_SelectApplication(&Application);
	PrintStatus(f,"PTEID_SelectApplication",&tStatus);

 	PrintTestFunction(f,"PTEID_ReadFile");
    tStatus = PTEID_ReadFile(&FileID, &Response, &Pin);
	PrintStatus(f,"PTEID_ReadFile",&tStatus);

	PrintBytes(f,"FILE",&Response);

/* DOES NOT WORK WITH MW 2.6
	Response.length = PTEID_MAX_PICTURE_LEN;
	memset(Response.data,0,Response.length);

	Application.length = 12;
	Application.data = (unsigned char *)"\xA0\x00\x00\x01\x77\x49\x64\x46\x69\x6C\x65\x73";
	FileID.length = 2;
    FileID.data = (unsigned char *)"\x40\x35";

 	PrintTestFunction(f,"PTEID_SelectApplication");
    tStatus = PTEID_SelectApplication(&Application);
	PrintStatus(f,"PTEID_SelectApplication",&tStatus);

 	PrintTestFunction(f,"PTEID_ReadFile");
    tStatus = PTEID_ReadFile(&FileID, &Response, &Pin);
	PrintStatus(f,"PTEID_ReadFile",&tStatus);

	PrintBytes(f,"FILE",&Response);
*/

/* DOES NOT WORK WITH MW 2.6
	Response.length = PTEID_MAX_PICTURE_LEN;
	memset(Response.data,0,Response.length);

	FileID.length = 6;
	FileID.data = (unsigned char *)"\x3F\x00\xDF\x01\x40\x35";

 	PrintTestFunction(f,"PTEID_ReadFile");
    tStatus = PTEID_ReadFile(&FileID, &Response, &Pin);
	PrintStatus(f,"PTEID_ReadFile",&tStatus);

	PrintBytes(f,"FILE",&Response);

	Response.length = PTEID_MAX_PICTURE_LEN;
	memset(Response.data,0,Response.length);
*/

/* DOES NOT WORK WITH MW 2.6
	FileID.length = 6;
	FileID.data = (unsigned char *)"\x3F\x00\xDF\x00\x50\x38";

 	PrintTestFunction(f,"PTEID_ReadFile");
    tStatus = PTEID_ReadFile(&FileID, &Response, &Pin);
	PrintStatus(f,"PTEID_ReadFile",&tStatus);

	PrintBytes(f,"FILE",&Response);
*/

	free(Response.data);

	//PTEID_WriteFile
	PrintTestFunction(f,"PTEID_WriteFile");
	PrintComment(f,"THIS FUNCTION DOES NOT WORK PROPERLY WITH MW 2.6");

/* DOES NOT WORK WITH MW 2.6

	FileID.length = 6;
	FileID.data = (unsigned char *)"\x3F\x00\xDF\x01\x40\x31";
	Data.length =6;
	Data.data = "\x5b\x54\x65\x73\x74\x5d";

	PrintTestFunction(f,"PTEID_WriteFile");
	PrintComment(f,"Trying to write into ID file");
	tStatus = PTEID_WriteFile(&FileID,&Data,&Pin);
	PrintStatus(f,"PTEID_WriteFile",&tStatus);

	FileID.length = 6;
	FileID.data = (unsigned char *)"\x3F\x00\xDF\x01\x40\x39";
	Data.length =6;
	Data.data = "\x5b\x54\x65\x73\x74\x5d";

	Response.length = 150;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_ReadFile");
	PrintComment(f,"Read the Preference file");
	tStatus = PTEID_ReadFile(&FileID,&Response,&Pin);
	PrintStatus(f,"PTEID_ReadFile",&tStatus);

	PrintBytes(f,"FILE",&Response);

	FileID.length = 6;
	FileID.data = (unsigned char *)"\x3F\x00\xDF\x01\x40\x39";
	Data.length =6;
	Data.data = "\x5b\x54\x65\x73\x74\x5d";

	PrintTestFunction(f,"PTEID_WriteFile");
	PrintComment(f,"Write into the Preference file");
	tStatus = PTEID_WriteFile(&FileID,&Data,&Pin);
	PrintStatus(f,"PTEID_WriteFile",&tStatus);

	Response.length = 150;
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_ReadFile");
	PrintComment(f,"Read the preference file to check the data written");
    tStatus = PTEID_ReadFile(&FileID, &Response, &Pin);
	PrintStatus(f,"PTEID_ReadFile",&tStatus);

	PrintBytes(f,"FILE",&Response);

	PrintTestFunction(f,"PTEID_WriteFile");
	PrintComment(f,"Rewrite into the Preference file with initial content");
	tStatus = PTEID_WriteFile(&FileID,&Response,&Pin);
	PrintStatus(f,"PTEID_WriteFile",&tStatus);

	free(Response.data);
*/

	//PTEID_ReadBinary
	PrintTestFunction(f,"PTEID_ReadBinary");
	PrintComment(f,"THIS FUNCTION DOES NOT WORK PROPERLY WITH MW 2.6");

/* DOES NOT WORK WITH MW 2.6
	FileID.length = 6;
	FileID.data = (unsigned char *)"\x3F\x00\xDF\x01\x40\x31";

	Response.length = 128;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_ReadBinary");
	tStatus = PTEID_ReadBinary(&FileID,64,512,&Response);
	PrintStatus(f,"PTEID_ReadBinary",&tStatus);

	PrintBytes(f,"FILE",&Response);

	free(Response.data);


	Response.length = 512;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_ReadBinary");
	tStatus = PTEID_ReadBinary(&FileID,64,512,&Response);
	PrintStatus(f,"PTEID_ReadBinary",&tStatus);

	PrintBytes(f,"FILE",&Response);

	free(Response.data);

	Response.length = 64;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_ReadBinary");
	tStatus = PTEID_ReadBinary(&FileID,64,64,&Response);
	PrintStatus(f,"PTEID_ReadBinary",&tStatus);

	PrintBytes(f,"FILE",&Response);

	free(Response.data);
*/

	//PTEID_BeginTransaction
	PrintTestFunction(f,"PTEID_BeginTransaction");
	tStatus = PTEID_BeginTransaction();
	PrintStatus(f,"PTEID_BeginTransaction",&tStatus);

	PrintTestFunction(f,"PTEID_BeginTransaction");
	tStatus = PTEID_BeginTransaction();
	PrintStatus(f,"PTEID_BeginTransaction",&tStatus);


	//PTEID_SendAPDU
	//Get serial number with to short buffer
	APDU.length = 5;
	APDU.data = (unsigned char *)"\x80\xE4\x00\x00\x0A";

	Response.length = APDU.data[4]+2;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_SendAPDU");
	tStatus = PTEID_SendAPDU(&APDU,NULL,&Response);
	PrintStatus(f,"PTEID_SendAPDU",&tStatus);

	PrintBytes(f,"RESPONSE",&Response);

	PrintTestFunction(f,"PTEID_SendAPDU");
	tStatus = PTEID_SendAPDU(&APDU,&Pin,&Response);
	PrintStatus(f,"PTEID_SendAPDU",&tStatus);

	PrintBytes(f,"RESPONSE",&Response);

	free(Response.data);

	//Get serial number
	APDU.length = 5;
	APDU.data = (unsigned char *)"\x80\xE4\x00\x00\x1C";

	Response.length = APDU.data[4]+2;
	Response.data = (BYTE *)malloc(Response.length*sizeof(BYTE));
	memset(Response.data,0,Response.length);

	PrintTestFunction(f,"PTEID_SendAPDU");
	tStatus = PTEID_SendAPDU(&APDU,&Pin,&Response);
	PrintStatus(f,"PTEID_SendAPDU",&tStatus);

	PrintBytes(f,"RESPONSE",&Response);

	free(Response.data);

	//PTEID_EndTransaction
	PrintTestFunction(f,"PTEID_EndTransaction");
	tStatus = PTEID_EndTransaction();
	PrintStatus(f,"PTEID_EndTransaction",&tStatus);

	PrintTestFunction(f,"PTEID_EndTransaction");
	tStatus = PTEID_EndTransaction();
	PrintStatus(f,"PTEID_EndTransaction",&tStatus);

	//PTEID_FlushCache
	PrintTestFunction(f,"PTEID_FlushCache");
	tStatus = PTEID_FlushCache();
	PrintStatus(f,"PTEID_FlushCache",&tStatus);
}