Documentation ¶
Index ¶
- Variables
- type Mem
- func (m *Mem) Alloc(addr uint64, size int, permissions Permissions) error
- func (m *Mem) Close() error
- func (m *Mem) Free(address uint64) error
- func (m *Mem) Raw() *MemRW
- func (m *Mem) ReadAt(p []byte, addr int64) (int, error)
- func (m *Mem) Reader() io.ReaderAt
- func (m *Mem) ReaderX() io.ReaderAt
- func (m *Mem) WriteAt(p []byte, addr int64) (int, error)
- func (m *Mem) Writer() io.WriterAt
- type MemRW
- type Permissions
- type SegmentationFaultError
Constants ¶
This section is empty.
Variables ¶
var ( PermRead Permissions = 0b001 PermWrite Permissions = 0b010 PermExecute Permissions = 0b100 PermReadWrite = PermRead | PermWrite PermReadExecute = PermRead | PermExecute PermReadWriteExecute = PermRead | PermWrite | PermExecute )
Functions ¶
This section is empty.
Types ¶
type Mem ¶
type Mem struct {
// contains filtered or unexported fields
}
Mem is a memory management system that acts as a MMU. Mem translates virtual to physical addresses and provide an interface to read and write to that virtual memory space
func NewMemFromMemory ¶
func NewMemFromMemory() *Mem
Creates a new memory management that uses MemoryAllocator
func (*Mem) Alloc ¶
func (m *Mem) Alloc(addr uint64, size int, permissions Permissions) error
Allocates a new memory block and map it to a virtual address This method uses the underlying Allocator to allocated memory blocks
func (*Mem) Free ¶
Free a memory block and from both the underlying Allocator and the memory manager. address must be the address used in the Alloc method.
func (*Mem) ReadAt ¶
Reads from a specific virtual address with read permissions. Returns SegmentationFaultError if trying to access unallocated or memory without permission
type MemRW ¶
type MemRW struct {
// contains filtered or unexported fields
}
MemRW is the gateway to all the memory operations with read/execute permissions it implements ReadAt
type Permissions ¶
type Permissions int
Memory operation permissions Permissions can be joined via | (p := PermRead | PermWrite) Permissions can be checked via & (ok := p & PermWrite)
func (Permissions) Has ¶
func (p Permissions) Has(permissions Permissions) bool
Check if this permissions has permissions
func (Permissions) String ¶
func (p Permissions) String() string
type SegmentationFaultError ¶
type SegmentationFaultError struct { Address int64 AccessPermissions Permissions }
Represents a segmentation fault. Invalid access to a either an unallocated memory or memory segments with wrong permissions
func NewSegmentationFaultError ¶
func NewSegmentationFaultError(address int64, permissions Permissions) *SegmentationFaultError
func (*SegmentationFaultError) Error ¶
func (s *SegmentationFaultError) Error() string