-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Cannon codebase to support both 32-bit and 64-bit MIPS emulation while reusing code as much as possible.
- Loading branch information
Showing
56 changed files
with
1,091 additions
and
595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//go:build !cannon64 | ||
// +build !cannon64 | ||
|
||
package arch | ||
|
||
import "encoding/binary" | ||
|
||
type ( | ||
// Word differs from the tradditional meaning in MIPS. The type represents the *maximum* architecture specific access length and value sizes. | ||
Word = uint32 | ||
// SignedInteger specifies the maximum signed integer type used for arithmetic. | ||
SignedInteger = int32 | ||
) | ||
|
||
const ( | ||
IsMips32 = true | ||
WordSize = 32 | ||
WordSizeBytes = WordSize >> 3 | ||
PageAddrSize = 12 | ||
PageKeySize = WordSize - PageAddrSize | ||
|
||
MemProofLeafCount = 28 | ||
MemProofSize = MemProofLeafCount * 32 | ||
|
||
AddressMask = 0xFFffFFfc | ||
ExtMask = 0x3 | ||
|
||
HeapStart = 0x05_00_00_00 | ||
HeapEnd = 0x60_00_00_00 | ||
ProgramBreak = 0x40_00_00_00 | ||
HighMemoryStart = 0x7f_ff_d0_00 | ||
) | ||
|
||
var ByteOrderWord = byteOrder32{} | ||
|
||
type byteOrder32 struct{} | ||
|
||
func (bo byteOrder32) Word(b []byte) Word { | ||
return binary.BigEndian.Uint32(b) | ||
} | ||
|
||
func (bo byteOrder32) AppendWord(b []byte, v uint32) []byte { | ||
return binary.BigEndian.AppendUint32(b, v) | ||
} | ||
|
||
func (bo byteOrder32) PutWord(b []byte, v uint32) { | ||
binary.BigEndian.PutUint32(b, v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//go:build cannon64 | ||
// +build cannon64 | ||
|
||
package arch | ||
|
||
import "encoding/binary" | ||
|
||
type ( | ||
// Word differs from the tradditional meaning in MIPS. The type represents the *maximum* architecture specific access length and value sizes | ||
Word = uint64 | ||
// SignedInteger specifies the maximum signed integer type used for arithmetic. | ||
SignedInteger = int64 | ||
) | ||
|
||
const ( | ||
IsMips32 = false | ||
WordSize = 64 | ||
WordSizeBytes = WordSize >> 3 | ||
PageAddrSize = 12 | ||
PageKeySize = WordSize - PageAddrSize | ||
|
||
MemProofLeafCount = 60 | ||
MemProofSize = MemProofLeafCount * 32 | ||
|
||
AddressMask = 0xFFFFFFFFFFFFFFF8 | ||
ExtMask = 0x7 | ||
|
||
HeapStart = 0x10_00_00_00_00_00_00_00 | ||
HeapEnd = 0x60_00_00_00_00_00_00_00 | ||
ProgramBreak = 0x40_00_00_00_00_00_00_00 | ||
HighMemoryStart = 0x7F_FF_FF_FF_D0_00_00_00 | ||
) | ||
|
||
var ByteOrderWord = byteOrder64{} | ||
|
||
type byteOrder64 struct{} | ||
|
||
func (bo byteOrder64) Word(b []byte) Word { | ||
return binary.BigEndian.Uint64(b) | ||
} | ||
|
||
func (bo byteOrder64) AppendWord(b []byte, v uint64) []byte { | ||
return binary.BigEndian.AppendUint64(b, v) | ||
} | ||
|
||
func (bo byteOrder64) PutWord(b []byte, v uint64) { | ||
binary.BigEndian.PutUint64(b, v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package arch | ||
|
||
type ByteOrder interface { | ||
Word([]byte) Word | ||
AppendWord([]byte, Word) []byte | ||
PutWord([]byte, Word) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.