mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 02:35:32 +00:00
Merge pull request #221 from lunixbochs/cpu_model
add Go support for cpu_model api update
This commit is contained in:
commit
573736d1b9
|
@ -7,6 +7,7 @@ import (
|
||||||
/*
|
/*
|
||||||
#cgo LDFLAGS: -lunicorn
|
#cgo LDFLAGS: -lunicorn
|
||||||
#include <unicorn/unicorn.h>
|
#include <unicorn/unicorn.h>
|
||||||
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ type Unicorn interface {
|
||||||
RegRead(reg int) (uint64, error)
|
RegRead(reg int) (uint64, error)
|
||||||
RegWrite(reg int, value uint64) error
|
RegWrite(reg int, value uint64) error
|
||||||
Start(begin, until uint64) error
|
Start(begin, until uint64) error
|
||||||
StartWithOptions(begin, until uint64, options *UcOptions) error
|
StartWithOptions(begin, until uint64, options *StartOptions) error
|
||||||
Stop() error
|
Stop() error
|
||||||
HookAdd(htype int, cb interface{}, extra ...uint64) (Hook, error)
|
HookAdd(htype int, cb interface{}, extra ...uint64) (Hook, error)
|
||||||
HookDel(hook Hook) error
|
HookDel(hook Hook) error
|
||||||
|
@ -43,31 +44,37 @@ type uc struct {
|
||||||
handle *C.uc_engine
|
handle *C.uc_engine
|
||||||
}
|
}
|
||||||
|
|
||||||
type UcOptions struct {
|
func NewUnicornModel(arch, mode int, model string) (Unicorn, error) {
|
||||||
Timeout, Count uint64
|
mstr := C.CString(model)
|
||||||
}
|
defer C.free(unsafe.Pointer(mstr))
|
||||||
|
|
||||||
func NewUnicorn(arch, mode int) (Unicorn, error) {
|
|
||||||
var major, minor C.uint
|
var major, minor C.uint
|
||||||
C.uc_version(&major, &minor)
|
C.uc_version(&major, &minor)
|
||||||
if major != C.UC_API_MAJOR || minor != C.UC_API_MINOR {
|
if major != C.UC_API_MAJOR || minor != C.UC_API_MINOR {
|
||||||
return nil, UcError(ERR_VERSION)
|
return nil, UcError(ERR_VERSION)
|
||||||
}
|
}
|
||||||
var handle *C.uc_engine
|
var handle *C.uc_engine
|
||||||
if ucerr := C.uc_open(C.uc_arch(arch), C.uc_mode(mode), &handle); ucerr != ERR_OK {
|
if ucerr := C.uc_open(C.uc_arch(arch), C.uc_mode(mode), mstr, &handle); ucerr != ERR_OK {
|
||||||
return nil, UcError(ucerr)
|
return nil, UcError(ucerr)
|
||||||
}
|
}
|
||||||
uc := &uc{handle}
|
uc := &uc{handle}
|
||||||
return uc, nil
|
return uc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *uc) StartWithOptions(begin, until uint64, options *UcOptions) error {
|
func NewUnicorn(arch, mode int) (Unicorn, error) {
|
||||||
|
return NewUnicornModel(arch, mode, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
type StartOptions struct {
|
||||||
|
Timeout, Count uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *uc) StartWithOptions(begin, until uint64, options *StartOptions) error {
|
||||||
ucerr := C.uc_emu_start(u.handle, C.uint64_t(begin), C.uint64_t(until), C.uint64_t(options.Timeout), C.size_t(options.Count))
|
ucerr := C.uc_emu_start(u.handle, C.uint64_t(begin), C.uint64_t(until), C.uint64_t(options.Timeout), C.size_t(options.Count))
|
||||||
return errReturn(ucerr)
|
return errReturn(ucerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *uc) Start(begin, until uint64) error {
|
func (u *uc) Start(begin, until uint64) error {
|
||||||
return u.StartWithOptions(begin, until, &UcOptions{})
|
return u.StartWithOptions(begin, until, &StartOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *uc) Stop() error {
|
func (u *uc) Stop() error {
|
||||||
|
|
Loading…
Reference in a new issue