Enable call function for MS2130

This commit is contained in:
Bertold Van den Bergh 2023-11-03 23:48:07 +01:00
parent 162cc22d62
commit bc6f0b327d
3 changed files with 17 additions and 1 deletions

Binary file not shown.

View file

@ -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
}

View file

@ -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
}