github.com/icexin/eggos@v0.4.2-0.20220216025428-78b167e4f349/kernel/mm/sys.go (about) 1 package mm 2 3 import "syscall" 4 5 const ( 6 // sync with kernel 7 _SYS_FIXED_MMAP = 502 8 ) 9 10 // SysMmap like Mmap but can run in user mode 11 // wraper of syscall.Mmap 12 func SysMmap(vaddr, size uintptr) uintptr { 13 mem, _, err := syscall.Syscall6(syscall.SYS_MMAP, uintptr(vaddr), size, syscall.PROT_READ|syscall.PROT_WRITE, 0, 0, 0) 14 if err != 0 { 15 panic(err.Error()) 16 } 17 return mem 18 } 19 20 // SysFixedMmap map the same physical address to the virtual address 21 // run in user mode 22 func SysFixedMmap(vaddr, paddr, size uintptr) { 23 _, _, err := syscall.Syscall(_SYS_FIXED_MMAP, vaddr, paddr, size) 24 if err != 0 { 25 panic(err.Error()) 26 } 27 }