From b50ed1e21a857ef03e81a0f8aea0811ef9bdfd26 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Sun, 7 Oct 2018 12:18:47 -0700 Subject: [PATCH] Update changelog --- changelog.txt | 12 ++++ readme.md | 1 + specifications/emuFeatureRegistersSpec.h | 1 + src/hardwareRegisters.c | 6 ++ src/m68328.c | 1 + tools/palm/hwTestSuite/testSuite.h | 30 +++++----- tools/palm/muExpansionDriver/appIcon.svg | 1 + tools/palm/muExpansionDriver/emuFunctions.c | 58 ++++++++++++++++++- ...raryMemoryAccess.h => palmGlobalDefines.h} | 11 +++- 9 files changed, 101 insertions(+), 20 deletions(-) create mode 100644 tools/palm/muExpansionDriver/appIcon.svg rename tools/palm/muExpansionDriver/{arbitraryMemoryAccess.h => palmGlobalDefines.h} (60%) diff --git a/changelog.txt b/changelog.txt index 4e623ff..5f0cae0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ +------------------------------------------ +v0.9 to v0.9.5(Sept 22 2018 - *** ** 2018) + +Qt GUI: +*added Mac OS icon +*added Windows icon +*now runs on Windows + +Core: +*bus error and address error are now handled properly + +---------------------------------------- v0.7 to v0.9(Jul 30 2018 - Sept 22 2018) Qt GUI: diff --git a/readme.md b/readme.md index d1a371d..d956ecf 100644 --- a/readme.md +++ b/readme.md @@ -51,6 +51,7 @@ Musashi v3.4(last version that builds outside of mame) (68k core) http://www.iconarchive.com/show/crystal-clear-icons-by-everaldo/App-palm-icon.html (Desktop Icon) http://tango.freedesktop.org/Tango_Icon_Library (Palm Action Buttons, All UI buttons) https://www.iconfinder.com/icons/2317746/chip_computer_cpu_device_frequency_microchip_processor_icon (hwTestSuite Icon) +https://www.flaticon.com/free-icon/cow_235371#term=cow&page=1&position=13 (muExpDriver Icon) Some main board photos by Reddit /u/KHRoN ## Building diff --git a/specifications/emuFeatureRegistersSpec.h b/specifications/emuFeatureRegistersSpec.h index 97a40c3..eeaf9c8 100644 --- a/specifications/emuFeatureRegistersSpec.h +++ b/specifications/emuFeatureRegistersSpec.h @@ -46,6 +46,7 @@ These registers will do nothing it there corresponding feature bit is not set on #define CMD_STRNCPY 0x0004 #define CMD_STRCMP 0x0005 #define CMD_STRNCMP 0x0006 +#define CMD_PRINTF 0x0007 /*new HLE API cmds go here*/ /*new system cmds go here*/ diff --git a/src/hardwareRegisters.c b/src/hardwareRegisters.c index 8b5840d..d904a2f 100644 --- a/src/hardwareRegisters.c +++ b/src/hardwareRegisters.c @@ -379,6 +379,12 @@ void setEmuRegister(uint32_t address, uint32_t value){ sandboxReturn(); break; + case CMD_PRINTF: + if(palmSpecialFeatures & FEATURE_DEBUG){ + + } + break; + default: debugLog("Invalid emu command 0x%04X.\n", value); break; diff --git a/src/m68328.c b/src/m68328.c index 6ebdfd2..48ba4dd 100755 --- a/src/m68328.c +++ b/src/m68328.c @@ -173,5 +173,6 @@ void m68328LoadState(uint8_t* data){ } void m68328BusError(uint32_t address, bool isWrite){ + //never call outsize of a 68k opcode, behavior is undefined due to longjmp m68ki_trigger_bus_error(address, isWrite ? MODE_WRITE : MODE_READ, FLAG_S | m68ki_get_address_space()); } diff --git a/tools/palm/hwTestSuite/testSuite.h b/tools/palm/hwTestSuite/testSuite.h index b4d15d3..94880c2 100644 --- a/tools/palm/hwTestSuite/testSuite.h +++ b/tools/palm/hwTestSuite/testSuite.h @@ -22,21 +22,21 @@ #define buttonBack keyBitHard3 #define buttonSelect keyBitHard4 -#define TYPE_NULL 0x00 -#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 -#define LENGTH_16 0x30 -#define LENGTH_32 0x40 -#define LENGTH_64 0x50 -#define LENGTH_PTR 0x60/*first half of 64bit value is length, second is pointer*/ -#define LENGTH_ANY 0x70/*for pointers with a user defined end or no end*/ -#define LENGTH_STR 0xF0/*for pointers to string*/ +#define TYPE_NULL 0x00 +#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 +#define LENGTH_16 0x30 +#define LENGTH_32 0x40 +#define LENGTH_64 0x50 +#define LENGTH_PTR 0x60/*first half of 64bit value is length, second is pointer*/ +#define LENGTH_ANY 0x70/*for pointers with a user defined end or no end*/ +#define LENGTH_STR 0xF0/*for pointers to string*/ /*types*/ typedef struct{ diff --git a/tools/palm/muExpansionDriver/appIcon.svg b/tools/palm/muExpansionDriver/appIcon.svg new file mode 100644 index 0000000..24763e8 --- /dev/null +++ b/tools/palm/muExpansionDriver/appIcon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tools/palm/muExpansionDriver/emuFunctions.c b/tools/palm/muExpansionDriver/emuFunctions.c index 9a071ee..02d72f8 100644 --- a/tools/palm/muExpansionDriver/emuFunctions.c +++ b/tools/palm/muExpansionDriver/emuFunctions.c @@ -1,12 +1,64 @@ #include #include -#include "testSuite.h" +#include "palmGlobalDefines.h" +#include "specs/hardwareRegisterNames.h" #include "specs/emuFeatureRegistersSpec.h" + +enum{ + EMU_STATE_UNTESTED = 0, + EMU_STATE_FALSE, + EMU_STATE_TRUE +}; + + +/*this handler may not work if the opcode size that triggered the bus error isnt 4 bytes, I am currently depending on the compiler generating a 4 byte opcode for that access*/ +static const uint16_t skipBusError[5] = { + 0x5C8F,/*addq.l #6,sp ; remove error info from stack*/ + 0x548F,/*addq.l #2,sp ; remove error info from stack*/ + 0x54AF,/*addq.l #2,2(sp) ; skip over the invalid access, what ever was in the variable before the read should still be there*/ + 0x0002,/* ; displacement for above*/ + 0x4E73/*rte ; return*/ +}; + Boolean isEmulator(){ - /*return (readArbitraryMemory32(EMU_REG_ADDR(EMU_INFO)) & FEATURE_EMU_HONEST) != 0;*/ - return false; + static uint8_t emuStatus = EMU_STATE_UNTESTED; + uint32_t osVer; + + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &osVer); + if(osVer >= PalmOS50){ + /*writing to interrupt handlers wont work on OS5+*/ + emuStatus = EMU_STATE_FALSE; + } + else{ + /*test if first call, else return cached value since testing is intensive*/ + if(emuStatus == EMU_STATE_UNTESTED){ + uint32_t oldBusErrorHandler = readArbitraryMemory32(2 * sizeof(uint32_t));/*EXCEPTION_BUS_ERROR vector*/ + uint8_t oldScr = readArbitraryMemory8(HW_REG_ADDR(SCR)); + volatile uint32_t palmSpecialFeatures;/*must be declared volatile since its modifyed by bus error behavior*/ + + writeArbitraryMemory8(HW_REG_ADDR(SCR), 0xF0);/*enable bus error timeout, clear current invalid accesses*/ + writeArbitraryMemory32(2 * sizeof(uint32_t), (uint32_t)skipBusError);/*set EXCEPTION_BUS_ERROR vector*/ + + /*set fallback value, will be the returned value if bus error timeout occurs*/ + palmSpecialFeatures = FEATURE_INVALID; + + /*everything is setup, now try to read invalid memory, success == its an emu*/ + palmSpecialFeatures = readArbitraryMemory32(EMU_REG_ADDR(EMU_INFO)); + + if(palmSpecialFeatures == FEATURE_INVALID) + emuStatus = EMU_STATE_FALSE; + else + emuStatus = EMU_STATE_TRUE; + + /*restore original state*/ + writeArbitraryMemory8(HW_REG_ADDR(SCR), 0xE0 | oldScr); + writeArbitraryMemory32(2 * sizeof(uint32_t), oldBusErrorHandler); + } + } + + return emuStatus == EMU_STATE_TRUE; } Boolean isEmulatorFeatureEnabled(uint32_t feature){ diff --git a/tools/palm/muExpansionDriver/arbitraryMemoryAccess.h b/tools/palm/muExpansionDriver/palmGlobalDefines.h similarity index 60% rename from tools/palm/muExpansionDriver/arbitraryMemoryAccess.h rename to tools/palm/muExpansionDriver/palmGlobalDefines.h index 8cdcf9c..bfbe3d2 100644 --- a/tools/palm/muExpansionDriver/arbitraryMemoryAccess.h +++ b/tools/palm/muExpansionDriver/palmGlobalDefines.h @@ -1,8 +1,15 @@ -#ifndef ARBITRARY_MEMORY_ACCESS_HEADER -#define ARBITRARY_MEMORY_ACCESS_HEADER +#ifndef PALM_GLOBAL_DEFINES_HEADER +#define PALM_GLOBAL_DEFINES_HEADER +#include #include +#define CODE_SECTION(codeSection) __attribute__((section(codeSection))) +#define ALIGN(size) __attribute__((aligned(size))) + +#define PalmOS35 sysMakeROMVersion(3, 5, 0, sysROMStageRelease, 0) +#define PalmOS50 sysMakeROMVersion(5, 0, 0, sysROMStageRelease, 0) + #define readArbitraryMemory8(address) (*((volatile uint8_t*)(address))) #define readArbitraryMemory16(address) (*((volatile uint16_t*)(address))) #define readArbitraryMemory32(address) (*((volatile uint32_t*)(address)))