-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
56 additions
and
10 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,29 @@ | ||
package mm | ||
|
||
import ( | ||
"syscall" | ||
) | ||
|
||
const ( | ||
// sync with kernel | ||
_SYS_FIXED_MMAP = 502 | ||
) | ||
|
||
// SysMmap like Mmap but can run in user mode | ||
// wraper of syscall.Mmap | ||
func SysMmap(vaddr, size uintptr) uintptr { | ||
mem, _, err := syscall.Syscall6(syscall.SYS_MMAP2, uintptr(vaddr), size, syscall.PROT_READ|syscall.PROT_WRITE, 0, 0, 0) | ||
if err != 0 { | ||
panic(err.Error()) | ||
} | ||
return mem | ||
} | ||
|
||
// SysFixedMmap map the same physical address to the virtual address | ||
// run in user mode | ||
func SysFixedMmap(addr, size uintptr) { | ||
_, _, err := syscall.Syscall(_SYS_FIXED_MMAP, addr, size, 0) | ||
if err != 0 { | ||
panic(err.Error()) | ||
} | ||
} |
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