mirror of
https://github.com/taigrr/gopher-os
synced 2026-04-01 08:18:42 -07:00
Use pwd as a workspace; move sources to src/gopheros and rewrite imports
By setting up pwd as a Go workspace, we can trim import paths from something like "github.com/achilleasa/gopher-os/kernel" to just "kernel". These changes make forking easier and also allows us to move the code to a different git hosting provider without having to rewrite the imports.
This commit is contained in:
19
src/gopheros/kernel/mem/vmm/page.go
Normal file
19
src/gopheros/kernel/mem/vmm/page.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package vmm
|
||||
|
||||
import "gopheros/kernel/mem"
|
||||
|
||||
// Page describes a virtual memory page index.
|
||||
type Page uintptr
|
||||
|
||||
// Address returns a pointer to the virtual memory address pointed to by this Page.
|
||||
func (f Page) Address() uintptr {
|
||||
return uintptr(f << mem.PageShift)
|
||||
}
|
||||
|
||||
// PageFromAddress returns a Page that corresponds to the given virtual
|
||||
// address. This function can handle both page-aligned and not aligned virtual
|
||||
// addresses. in the latter case, the input address will be rounded down to the
|
||||
// page that contains it.
|
||||
func PageFromAddress(virtAddr uintptr) Page {
|
||||
return Page((virtAddr & ^(uintptr(mem.PageSize - 1))) >> mem.PageShift)
|
||||
}
|
||||
Reference in New Issue
Block a user