diff --git a/hwTestSuite/make.sh b/hwTestSuite/make.sh index 14419f2..c45d00b 100755 --- a/hwTestSuite/make.sh +++ b/hwTestSuite/make.sh @@ -11,7 +11,7 @@ CREATORID="guiC" RESFILE=$APPNAME.rcp PRC=$APPNAME.prc -SRCS="testSuite.c viewer.c tools.c cpu.c emuFunctions.c debug.c ugui.c" +SRCS="testSuite.c viewer.c tools.c tests.c cpu.c emuFunctions.c debug.c ugui.c" DEFINES="-DHW_TEST -DDEBUG" CFLAGS="-O2 -g $DEFINES" diff --git a/hwTestSuite/readme.md b/hwTestSuite/readme.md index 830e19d..4981274 100644 --- a/hwTestSuite/readme.md +++ b/hwTestSuite/readme.md @@ -16,3 +16,4 @@ If you enable unsafe mode you will have to reboot to exit, this is because it wi In the hex viewer registers that are not safe to read will say "UNSAFE" instead of a hex value, the main unsafe reads are the uart registers. There is almost no memory, 4KB stack on some devices. +For some reason the official FileClose(FileHandle) crashes with "Fatal Exeption" on Clie Peg-SL10 and "illegal instruction 19F0 at 00000002" on Tungsten E and black screen reboot on Palm T|X, I think that it corrupts the stack triggering a jump to 0x00000000. diff --git a/hwTestSuite/testSuite.c b/hwTestSuite/testSuite.c index 30e8050..f375b8f 100644 --- a/hwTestSuite/testSuite.c +++ b/hwTestSuite/testSuite.c @@ -234,7 +234,7 @@ static Boolean testerInit(){ framebuffer = BmpGetBits(offscreenBitmap); UG_Init(&uguiStruct, uguiDrawPixel, SCREEN_WIDTH, SCREEN_HEIGHT); - UG_FontSelect(&FONT_4X6); + UG_FontSelect(&FONT_8X8); UG_SetBackcolor(C_WHITE); UG_SetForecolor(C_BLACK); UG_ConsoleSetBackcolor(C_WHITE); diff --git a/hwTestSuite/testSuite.h b/hwTestSuite/testSuite.h index 2ba905b..0102ce0 100644 --- a/hwTestSuite/testSuite.h +++ b/hwTestSuite/testSuite.h @@ -7,7 +7,6 @@ /*defines*/ - #define PalmOS35 sysMakeROMVersion(3,5,0,sysROMStageRelease,0) #define PalmOS50 sysMakeROMVersion(5,0,0,sysROMStageRelease,0) @@ -19,11 +18,11 @@ #define buttonSelect keyBitHard4 #define TYPE_NULL 0x00 -#define TYPE_BOOL 0x01/*bool can share with uint*/ -#define TYPE_UINT 0x01 -#define TYPE_INT 0x02 -#define TYPE_FLOAT 0x03 -#define TYPE_PTR 0x04 +#define TYPE_BOOL 0x01 +#define TYPE_UINT 0x02 +#define TYPE_INT 0x03 +#define TYPE_FLOAT 0x04 +#define TYPE_PTR 0x05 #define LENGTH_0 0x00/*for null*/ #define LENGTH_1 0x10 #define LENGTH_8 0x20 diff --git a/hwTestSuite/tests.c b/hwTestSuite/tests.c new file mode 100644 index 0000000..e20368a --- /dev/null +++ b/hwTestSuite/tests.c @@ -0,0 +1,10 @@ +#include "testSuite.h" +#include "tools.h" + + +var testFileAccessWorks(){ + uint32_t testTook = UINT32_C(0xFFFFFE00); + makeFile((uint8_t*)&testTook, 4, "FILEOUT.BIN"); + exitSubprogram(); + return makeVar(LENGTH_0, TYPE_NULL, 0); +} diff --git a/hwTestSuite/tests.h b/hwTestSuite/tests.h new file mode 100644 index 0000000..558a284 --- /dev/null +++ b/hwTestSuite/tests.h @@ -0,0 +1,7 @@ +#ifndef TESTS_HEADER +#define TESTS_HEADER + +#include "testSuite.h" + +var testFileAccessWorks(); +#endif diff --git a/hwTestSuite/tools.c b/hwTestSuite/tools.c index a81c435..eafeb5e 100644 --- a/hwTestSuite/tools.c +++ b/hwTestSuite/tools.c @@ -1,17 +1,18 @@ +#include #include "testSuite.h" #include "viewer.h" #include "debug.h" #include "ugui.h" -uint32_t makeFile(uint8_t* data, uint32_t size, char* fileName){ +Err makeFile(uint8_t* data, uint32_t size, char* fileName){ FileHand file; Err error; uint8_t dataBuffer[100];//used to anonymize data source uint32_t count; - file = FileOpen(0 /*cardNo*/, fileName, 'DATA', 'GuiC', fileModeReadWrite | fileModeAnyTypeCreator, &error); - if(!file || error) + file = FileOpen(0 /*cardNo*/, fileName, (uint32_t)'DATA', (uint32_t)'GuiC', fileModeReadWrite | fileModeAnyTypeCreator, &error); + if(file == fileNullHandle || error) return error; count = size; @@ -28,11 +29,10 @@ uint32_t makeFile(uint8_t* data, uint32_t size, char* fileName){ count -= chunkSize; } - error = FileClose(file); - if(error) - return error; + UG_PutString(0, 0, "File close next"); - return 0;//success + error = FileClose(file);//I have no idea why, but this function causes a fatal execption but i still get valid data in the file after reboot + return error; } var hexRamBrowser(){ @@ -86,15 +86,7 @@ var hexRamBrowser(){ } var dumpBootloaderToFile(){ - makeFile((uint8_t*)UINT32_C(0xFFFFFE00), 0x200, "BOOTLOAD.BIN"); + makeFile((uint8_t*)UINT32_C(0xFFFFFE00), 0x200, "BOOTLOADER.BIN"); exitSubprogram(); return makeVar(LENGTH_0, TYPE_NULL, 0); } - -var testFileAccessWorks(){ - uint32_t testTook = UINT32_C(0xFFFFFE00); - makeFile((uint8_t*)&testTook, 4, "FILEOUT.BIN"); - exitSubprogram(); - return makeVar(LENGTH_0, TYPE_NULL, 0); -} - diff --git a/hwTestSuite/tools.h b/hwTestSuite/tools.h index f2ec528..8841d18 100644 --- a/hwTestSuite/tools.h +++ b/hwTestSuite/tools.h @@ -1,10 +1,10 @@ #ifndef TOOLS_HEADER #define TOOLS_HEADER +#include #include "testSuite.h" -uint32_t makeFile(uint8_t* data, uint32_t size, char* fileName); +Err makeFile(uint8_t* data, uint32_t size, char* fileName); var hexRamBrowser(); var dumpBootloaderToFile(); -var testFileAccessWorks(); #endif diff --git a/hwTestSuite/ugui_config.h b/hwTestSuite/ugui_config.h index 8057461..9159925 100755 --- a/hwTestSuite/ugui_config.h +++ b/hwTestSuite/ugui_config.h @@ -14,13 +14,13 @@ #define USE_COLOR_RGB565 // RGB = 0bRRRRRGGGGGGBBBBB /* Enable needed fonts here */ -#define USE_FONT_4X6 +//#define USE_FONT_4X6 //#define USE_FONT_5X8 //#define USE_FONT_5X12 //#define USE_FONT_6X8 //#define USE_FONT_6X10 //#define USE_FONT_7X12 -//#define USE_FONT_8X8 +#define USE_FONT_8X8 //#define USE_FONT_8X12_CYRILLIC //#define USE_FONT_8X12 //#define USE_FONT_8X12 diff --git a/hwTestSuite/viewer.c b/hwTestSuite/viewer.c index 7842766..2b0c26d 100644 --- a/hwTestSuite/viewer.c +++ b/hwTestSuite/viewer.c @@ -1,14 +1,15 @@ #include "testSuiteConfig.h" #include "testSuite.h" #include "tools.h" +#include "tests.h" #include "debug.h" #include "ugui.h" #define MAX_OBJECTS 50 -#define FONT_WIDTH 4 -#define FONT_HEIGHT 6 +#define FONT_WIDTH 8 +#define FONT_HEIGHT 8 #define FONT_SPACING 0 #define RESERVED_PIXELS_Y (SCREEN_HEIGHT / 4)/*save pixels at the bottom of the screen for other information on the current item*/ @@ -81,7 +82,7 @@ static void hexHandler(uint32_t command){ uint32_t displayAddress = hexViewOffset - bufferAddress; if(displayAddress + i < listLength){ /*Palm OS sprintf only supports 16 bit ints*/ - StrPrintF(itemStrings[i], "0x%04X%04X:0x%02X", (uint16_t)(displayAddress >> 16), (uint16_t)displayAddress , readArbitraryMemory8(hexViewOffset)); + StrPrintF(itemStrings[i], "0x%04X%04X:0x%02X", (uint16_t)(displayAddress >> 16), (uint16_t)displayAddress, readArbitraryMemory8(hexViewOffset)); hexViewOffset++; } else{ @@ -187,6 +188,36 @@ static var listModeFrame(){ return makeVar(LENGTH_0, TYPE_NULL, 0); } +var valueViewer(){ + static Boolean clearNeeded = true; + var value = getSubprogramArgs(); + uint64_t varData = getVarValue(value); + + if(getButtonPressed(buttonBack)){ + /*go back*/ + clearNeeded = true; + exitSubprogram(); + } + + if(clearNeeded){ + char printBuffer[100]; + debugSafeScreenClear(C_WHITE); + + switch(getVarType(value)){ + case TYPE_INT: + StrPrintF(printBuffer, "uint32_t:0x%04X%04X", (uint16_t)(varData >> 16), (uint16_t)varData); + UG_PutString(0, 0, printBuffer); + break; + + default: + UG_PutString(0, 0, "Unknown Var Type"); + break; + } + + clearNeeded = false; + } +} + var hexViewer(){ var where = getSubprogramArgs(); @@ -204,7 +235,7 @@ var hexViewer(){ listLength = UINT64_C(0x100000000); } listHandler = hexHandler; - callSubprogram(listModeFrame); + execSubprogram(listModeFrame); setDebugTag("Hex Viewer Starting"); @@ -215,7 +246,7 @@ var functionPicker(){ resetListHandler(); listLength = totalHwTests; listHandler = testPickerHandler; - callSubprogram(listModeFrame); + execSubprogram(listModeFrame); setDebugTag("Test Picker Starting"); @@ -227,15 +258,21 @@ void initViewer(){ totalHwTests = 0; - StrNCopy(hwTests[0].name, "Ram Browser", TEST_NAME_LENGTH); - hwTests[0].testFunction = hexRamBrowser; + StrNCopy(hwTests[totalHwTests].name, "Ram Browser", TEST_NAME_LENGTH); + hwTests[totalHwTests].testFunction = hexRamBrowser; totalHwTests++; - StrNCopy(hwTests[1].name, "Dump Bootloader", TEST_NAME_LENGTH); - hwTests[1].testFunction = dumpBootloaderToFile; + /* + StrNCopy(hwTests[totalHwTests].name, "Get Trap Address", TEST_NAME_LENGTH); + hwTests[totalHwTests].testFunction = testFileAccessWorks; + totalHwTests++; + */ + + StrNCopy(hwTests[totalHwTests].name, "Dump Bootloader", TEST_NAME_LENGTH); + hwTests[totalHwTests].testFunction = dumpBootloaderToFile; totalHwTests++; - StrNCopy(hwTests[2].name, "File Access Test", TEST_NAME_LENGTH); - hwTests[2].testFunction = testFileAccessWorks; + StrNCopy(hwTests[totalHwTests].name, "File Access Test", TEST_NAME_LENGTH); + hwTests[totalHwTests].testFunction = testFileAccessWorks; totalHwTests++; } diff --git a/hwTestSuite/viewer.h b/hwTestSuite/viewer.h index 264c1aa..011cbc6 100644 --- a/hwTestSuite/viewer.h +++ b/hwTestSuite/viewer.h @@ -3,6 +3,7 @@ #include "testSuite.h" +var valueViewer(); var hexViewer(); var functionPicker(); void initViewer();