diff --git a/ms213x_patch/ms213x_patch b/ms213x_patch/ms213x_patch deleted file mode 100755 index 55f0ce8..0000000 Binary files a/ms213x_patch/ms213x_patch and /dev/null differ diff --git a/mshal/hal.go b/mshal/hal.go index 68abba1..3dc809b 100644 --- a/mshal/hal.go +++ b/mshal/hal.go @@ -1,6 +1,8 @@ package mshal import ( + "bytes" + "github.com/BertoldVdb/ms-tools/gohid" ) @@ -16,6 +18,7 @@ type HAL struct { patchCallAddrs []int patchInstalled bool + patchCanCall bool config HALConfig ms2130spiEnabled int @@ -114,6 +117,19 @@ func New(dev gohid.HIDDevice, config HALConfig) (*HAL, error) { h.config.LogFunc(1, "Assumed EEPROM Size: %d", h.eepromSize) + /* MS2130 can be running code from flash that is pre-patched. This is a hack to allow + * using that even withtout offset discovery */ + if h.deviceType == 2130 { + var id [4]byte + if _, err := xdata.Access(false, 0x7b00, id[:]); err != nil { + return nil, err + } + if bytes.Equal(id[:], []byte("BVDB")) { + h.patchCanCall = true + h.config.LogFunc(1, "MS213x firmware supports calling functions") + } + } + return h, nil } diff --git a/mshal/hal_patch_call.go b/mshal/hal_patch_call.go index 86d6d88..6874021 100644 --- a/mshal/hal_patch_call.go +++ b/mshal/hal_patch_call.go @@ -60,7 +60,7 @@ type PatchExecFuncRequest struct { func (h *HAL) PatchExecFunc(inIRQ bool, addr int, req PatchExecFuncRequest) (PatchExecFuncResponse, error) { var response PatchExecFuncResponse - if !h.patchInstalled { + if !h.patchInstalled && !h.patchCanCall { return response, ErrorMissingFunction }