mirror of
https://github.com/libretro/Mu.git
synced 2026-09-22 14:45:57 +00:00
ARM calling is working
This commit is contained in:
@@ -6,57 +6,6 @@
|
||||
#include "testSuite.h"
|
||||
|
||||
|
||||
uint8_t armRead8(uint32_t address){
|
||||
/*//LDR R0, [PC, 4] //LDRB R0, [R0] //MOV PC, LR //DATA*/
|
||||
static ALIGN(4) uint32_t getValue[] = {0x04009FE5, 0x0000D0E5, 0x0EF0A0E1, 0x00000000};
|
||||
|
||||
getValue[3] = EndianSwap32(address);
|
||||
return PceNativeCall(getValue, NULL) & 0xFF;
|
||||
}
|
||||
|
||||
uint16_t armRead16(uint32_t address){
|
||||
/*//LDR R0, [PC, 4] //LDRH R0, [R0] //MOV PC, LR //DATA*/
|
||||
static ALIGN(4) uint32_t getValue[] = {0x04009FE5, 0xB000D0E1, 0x0EF0A0E1, 0x00000000};
|
||||
|
||||
getValue[3] = EndianSwap32(address);
|
||||
return PceNativeCall(getValue, NULL) & 0xFFFF;
|
||||
}
|
||||
|
||||
uint32_t armRead32(uint32_t address){
|
||||
/*//LDR R0, [PC, 4] //LDR R0, [R0] //MOV PC, LR //DATA*/
|
||||
static ALIGN(4) uint32_t getValue[] = {0x04009FE5, 0x000090E5, 0x0EF0A0E1, 0x00000000};
|
||||
|
||||
getValue[3] = EndianSwap32(address);
|
||||
return PceNativeCall(getValue, NULL);
|
||||
}
|
||||
|
||||
void armWrite8(uint32_t address, uint8_t value){
|
||||
/*//PUSH {R1} //LDR R0, [PC, 12] //LDR R1, [PC, 12] //STRB R1, [R0] //POP{R1} //MOV PC, LR //DATA //DATA*/
|
||||
static ALIGN(4) uint32_t setValue[] = {0x04102DE5, 0x0C009FE5, 0x0C109FE5, 0x0010C0E5, 0x04109DE4, 0x0EF0A0E1, 0x00000000, 0x00000000};
|
||||
|
||||
setValue[6] = EndianSwap32(address);
|
||||
setValue[7] = EndianSwap32(value);
|
||||
PceNativeCall(setValue, NULL);
|
||||
}
|
||||
|
||||
void armWrite16(uint32_t address, uint16_t value){
|
||||
/*//PUSH {R1} //LDR R0, [PC, 12] //LDR R1, [PC, 12] //STRH R1, [R0] //POP{R1} //MOV PC, LR //DATA //DATA*/
|
||||
static ALIGN(4) uint32_t setValue[] = {0x04102DE5, 0x0C009FE5, 0x0C109FE5, 0xB010C0E1, 0x04109DE4, 0x0EF0A0E1, 0x00000000, 0x00000000};
|
||||
|
||||
setValue[6] = EndianSwap32(address);
|
||||
setValue[7] = EndianSwap32(value);
|
||||
PceNativeCall(setValue, NULL);
|
||||
}
|
||||
|
||||
void armWrite32(uint32_t address, uint32_t value){
|
||||
/*//PUSH {R1} //LDR R0, [PC, 12] //LDR R1, [PC, 12] //STR R1, [R0] //POP{R1} //MOV PC, LR //DATA //DATA*/
|
||||
static ALIGN(4) uint32_t setValue[] = {0x04102DE5, 0x0C009FE5, 0x0C109FE5, 0x001080E5, 0x04109DE4, 0x0EF0A0E1, 0x00000000, 0x00000000};
|
||||
|
||||
setValue[6] = EndianSwap32(address);
|
||||
setValue[7] = EndianSwap32(value);
|
||||
PceNativeCall(setValue, NULL);
|
||||
}
|
||||
|
||||
void callArmTests(uint32_t* args, uint8_t argCount){
|
||||
MemHandle armHandle;
|
||||
MemPtr armPointer;
|
||||
|
||||
@@ -3,12 +3,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t armRead8(uint32_t address);
|
||||
uint16_t armRead16(uint32_t address);
|
||||
uint32_t armRead32(uint32_t address);
|
||||
void armWrite8(uint32_t address, uint8_t value);
|
||||
void armWrite16(uint32_t address, uint16_t value);
|
||||
void armWrite32(uint32_t address, uint32_t value);
|
||||
void callArmTests(uint32_t* args, uint8_t argCount);/*must call with 32 bit aligned data*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,10 @@ USED unsigned long runTest(const void* emulStateP, void* userData68KP, /*Call68K
|
||||
oldInts = disableInts();
|
||||
|
||||
switch(test){
|
||||
case ARM_TEST_DATA_EXCHANGE:
|
||||
returnArgCount = testArmDataExchange(args);
|
||||
break;
|
||||
|
||||
case ARM_TEST_TSC2101_READ_ADC_VALUES:
|
||||
returnArgCount = readAllTsc2101AdcValues(args);
|
||||
break;
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#define ARM_SIDE_CODE_H
|
||||
|
||||
enum{
|
||||
ARM_TEST_TSC2101_READ_ADC_VALUES = 0,
|
||||
ARM_TEST_DATA_EXCHANGE = 0,
|
||||
ARM_TEST_TSC2101_READ_ADC_VALUES,
|
||||
TOTAL_ARM_TESTS
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
#include "tsc2101Driver.h"
|
||||
|
||||
|
||||
uint32_t testArmDataExchange(uint32_t* args){
|
||||
args[1] = args[0];
|
||||
args[0] = 0x12345678;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
uint32_t readAllTsc2101AdcValues(uint32_t* args){
|
||||
//uint16_t tsc2101OldStatus = tsc2101Read(TOUCH_CONTROL_TSC_ADC);
|
||||
|
||||
@@ -22,5 +29,5 @@ uint32_t readAllTsc2101AdcValues(uint32_t* args){
|
||||
|
||||
//tsc2101Write(TOUCH_CONTROL_TSC_ADC, tsc2101OldStatus);
|
||||
|
||||
return 0x0B;
|
||||
return 11;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t testArmDataExchange(uint32_t* args);
|
||||
uint32_t readAllTsc2101AdcValues(uint32_t* args);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -972,30 +972,82 @@ var callSysUnimplemented(void){
|
||||
return makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
}
|
||||
|
||||
var testArmAccess(void){
|
||||
uint32_t value;
|
||||
var testArmDataExchange(void){
|
||||
ALIGN(4) uint32_t* args[3];
|
||||
static Boolean firstRun = true;
|
||||
uint16_t y = 0;
|
||||
|
||||
/*should return 0x12345678*/
|
||||
armWrite8((uint32_t)sharedDataBuffer, 0x12);
|
||||
value = (uint32_t)armRead8((uint32_t)sharedDataBuffer) << 8 | 0x34;
|
||||
armWrite16((uint32_t)sharedDataBuffer, value);
|
||||
value = (uint32_t)armRead16((uint32_t)sharedDataBuffer) << 8 | 0x56;
|
||||
armWrite32((uint32_t)sharedDataBuffer, value);
|
||||
value = (uint32_t)armRead32((uint32_t)sharedDataBuffer) << 8 | 0x78;
|
||||
if(firstRun){
|
||||
firstRun = false;
|
||||
debugSafeScreenClear(C_WHITE);
|
||||
|
||||
}
|
||||
|
||||
setSubprogramArgs(makeVar(LENGTH_32, TYPE_UINT, (uint64_t)value));
|
||||
execSubprogram(valueViewer);
|
||||
if(getButtonPressed(buttonBack)){
|
||||
firstRun = true;
|
||||
exitSubprogram();
|
||||
}
|
||||
|
||||
args[0] = ARM_TEST_DATA_EXCHANGE;
|
||||
args[1] = 0x13245768;
|
||||
callArmTests(args, 1);
|
||||
|
||||
StrPrintF(sharedDataBuffer, "0x12345678:0x%08lX", args[1]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "0x13245768:0x%08lX", args[2]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
|
||||
return makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
}
|
||||
|
||||
var tsc2101ReadAllAnalogValues(void){
|
||||
ALIGN(4) uint32_t args[0x0C];
|
||||
ALIGN(4) uint32_t args[12];
|
||||
static Boolean firstRun = true;
|
||||
uint16_t y = 0;
|
||||
|
||||
if(firstRun){
|
||||
firstRun = false;
|
||||
debugSafeScreenClear(C_WHITE);
|
||||
|
||||
}
|
||||
|
||||
if(getButtonPressed(buttonBack)){
|
||||
firstRun = true;
|
||||
exitSubprogram();
|
||||
}
|
||||
|
||||
args[0] = ARM_TEST_TSC2101_READ_ADC_VALUES;
|
||||
callArmTests(args, 0);
|
||||
|
||||
/*TODO: use output*/
|
||||
StrPrintF(sharedDataBuffer, "X:0x%04X", args[1]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "Y:0x%04X", args[2]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "Z1:0x%04X", args[3]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "Z2:0x%04X", args[4]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "BAT:0x%04X", args[6]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "AUX1:0x%04X", args[8]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "AUX2:0x%04X", args[9]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "TEMP1:0x%04X", args[10]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "TEMP2:0x%04X", args[11]);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
|
||||
return makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ var playConstantTone(void);
|
||||
var unaligned32bitAccess(void);
|
||||
var isIrq2AttachedToSdCardChipSelect(void);
|
||||
var callSysUnimplemented(void);
|
||||
var testArmAccess(void);
|
||||
var testArmDataExchange(void);
|
||||
var tsc2101ReadAllAnalogValues(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#ifndef __UGUI_CONFIG_H
|
||||
#define __UGUI_CONFIG_H
|
||||
|
||||
#include <stdint.h>
|
||||
#define __UGUI_CONFIG_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "testSuiteConfig.h"
|
||||
#include "testSuite.h"
|
||||
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
/* -- CONFIG SECTION -- */
|
||||
@@ -14,15 +15,15 @@
|
||||
//#define USE_COLOR_RGB888 // RGB = 0xFF,0xFF,0xFF
|
||||
#define USE_COLOR_RGB565 // RGB = 0bRRRRRGGGGGGBBBBB
|
||||
|
||||
/* Enable needed fonts here */
|
||||
#if FONT_WIDTH == 4 && FONT_HEIGHT == 6
|
||||
#define USE_FONT_4X6
|
||||
/* Enable needed fonts here */
|
||||
#if FONT_WIDTH == 4 && FONT_HEIGHT == 6
|
||||
#define USE_FONT_4X6
|
||||
#elif FONT_WIDTH == 5 && FONT_HEIGHT == 8
|
||||
#define USE_FONT_5X8
|
||||
#elif FONT_WIDTH == 6 && FONT_HEIGHT == 8
|
||||
#define USE_FONT_6X8
|
||||
#endif
|
||||
//#define USE_FONT_4X6
|
||||
#define USE_FONT_5X8
|
||||
#elif FONT_WIDTH == 6 && FONT_HEIGHT == 8
|
||||
#define USE_FONT_6X8
|
||||
#endif
|
||||
//#define USE_FONT_4X6
|
||||
//#define USE_FONT_5X8
|
||||
//#define USE_FONT_5X12
|
||||
//#define USE_FONT_6X8
|
||||
@@ -43,7 +44,7 @@
|
||||
|
||||
/* Specify platform-dependent integer types here */
|
||||
|
||||
#define __UG_FONT_DATA const
|
||||
#define __UG_FONT_DATA const CODE_SECTION("ugui")
|
||||
typedef uint8_t UG_U8;
|
||||
typedef int8_t UG_S8;
|
||||
typedef uint16_t UG_U16;
|
||||
@@ -51,16 +52,6 @@ typedef int16_t UG_S16;
|
||||
typedef uint32_t UG_U32;
|
||||
typedef int32_t UG_S32;
|
||||
|
||||
|
||||
/* Example for dsPIC33
|
||||
typedef unsigned char UG_U8;
|
||||
typedef signed char UG_S8;
|
||||
typedef unsigned int UG_U16;
|
||||
typedef signed int UG_S16;
|
||||
typedef unsigned long int UG_U32;
|
||||
typedef signed long int UG_S32;
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@@ -394,8 +394,8 @@ void resetFunctionViewer(void){
|
||||
}
|
||||
|
||||
if(cpuType & CPU_ARM){
|
||||
StrNCopy(hwTests[totalHwTests].name, "Test ARM Mode Access", TEST_NAME_LENGTH);
|
||||
hwTests[totalHwTests].testFunction = testArmAccess;
|
||||
StrNCopy(hwTests[totalHwTests].name, "Test ARM Exchange", TEST_NAME_LENGTH);
|
||||
hwTests[totalHwTests].testFunction = testArmDataExchange;
|
||||
totalHwTests++;
|
||||
|
||||
if(isT3){
|
||||
|
||||
Reference in New Issue
Block a user