Basic paging stuff

master
kolaente 4 years ago
parent 81e8dd1cd9
commit 06a53bf6f4
Signed by: kolaente
GPG Key ID: F40E70337AB24C9B
  1. 1
      hal/module.go
  2. 30
      hal/paging.go
  3. 14
      hal/paging_test.go

@ -16,6 +16,7 @@ type Module struct {
programStorage Program
register []float64
IO map[int64]IO
pageTable *PageTable
isStopped bool
debugEnabled bool

@ -0,0 +1,30 @@
package hal
type Page struct {
Referenced bool
PageNumber uint16
}
type PageTable []*Page
type Address uint16
func (address Address) PageNumber() uint16 {
return uint16(address) >> 10
}
func (address Address) Offset() uint16 {
return uint16(address) & 0x03FF
}
func (table *PageTable) Find(address Address) {
// 10 bit for one register in a page
// 6 bit to address the page
// 000010 | 0000000011
// -> Page 2, offset 3
// Find the page with that number
// Check if it is already loaded
// Load it if not
}

@ -0,0 +1,14 @@
package hal
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestAddress(t *testing.T) {
// 000010 | 0000000011
address := Address(0b0000100000000011)
assert.Equal(t, uint16(0b10), address.PageNumber())
assert.Equal(t, uint16(0b11), address.Offset())
}
Loading…
Cancel
Save