Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
db6b9185
Commit
db6b9185
authored
Oct 07, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make MIPS exit properly
parent
60cd86a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
MIPS.sol
contracts/MIPS.sol
+9
-4
No files found.
contracts/MIPS.sol
View file @
db6b9185
...
@@ -73,9 +73,10 @@ contract MIPS {
...
@@ -73,9 +73,10 @@ contract MIPS {
return uint32(dat&mask | (isSigned ? signed : 0));
return uint32(dat&mask | (isSigned ? signed : 0));
}
}
function handleSyscall(bytes32 stateHash) internal returns (bytes32) {
function handleSyscall(bytes32 stateHash) internal returns (bytes32
, bool
) {
uint32 syscall_no = ReadMemory(stateHash, REG_OFFSET+2*4);
uint32 syscall_no = ReadMemory(stateHash, REG_OFFSET+2*4);
uint32 v0 = 0;
uint32 v0 = 0;
bool exit = false;
if (syscall_no == 4090) {
if (syscall_no == 4090) {
// mmap
// mmap
...
@@ -96,12 +97,12 @@ contract MIPS {
...
@@ -96,12 +97,12 @@ contract MIPS {
v0 = 1;
v0 = 1;
} else if (syscall_no == 4246) {
} else if (syscall_no == 4246) {
// exit group
// exit group
stateHash = WriteMemory(stateHash, REG_PC, 0x5ead0000)
;
exit = true
;
}
}
stateHash = WriteMemory(stateHash, REG_OFFSET+2*4, v0);
stateHash = WriteMemory(stateHash, REG_OFFSET+2*4, v0);
stateHash = WriteMemory(stateHash, REG_OFFSET+7*4, 0);
stateHash = WriteMemory(stateHash, REG_OFFSET+7*4, 0);
return
stateHash
;
return
(stateHash, exit)
;
}
}
function branchDelay(bytes32 stateHash, uint32 pc, uint32 nextPC, bool link) internal returns (bytes32) {
function branchDelay(bytes32 stateHash, uint32 pc, uint32 nextPC, bool link) internal returns (bytes32) {
...
@@ -232,7 +233,11 @@ contract MIPS {
...
@@ -232,7 +233,11 @@ contract MIPS {
// syscall (can read and write)
// syscall (can read and write)
if (func == 0xC) {
if (func == 0xC) {
//revert("unhandled syscall");
//revert("unhandled syscall");
stateHash = handleSyscall(stateHash);
bool exit;
(stateHash, exit) = handleSyscall(stateHash);
if (exit) {
nextPC = 0x5ead0000;
}
}
}
// lo and hi registers
// lo and hi registers
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment