Browse Source

Merge branch 'development'

master
Andrej Rosano 2 weeks ago
parent
commit
23dd03e653
  1. 16
      dma/alloc.go
  2. 2
      dma/dma.go
  3. 2
      go.mod

16
dma/alloc.go

@ -11,27 +11,23 @@ package dma
import (
"container/list"
"reflect"
"unsafe"
)
func (b *block) read(off int, buf []byte) {
var mem []byte
var ptr unsafe.Pointer
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&mem))
hdr.Data = uintptr(unsafe.Pointer(uintptr(b.addr + uint32(off))))
hdr.Len = len(buf)
hdr.Cap = hdr.Len
ptr = unsafe.Add(ptr, int(b.addr) + off)
mem := unsafe.Slice((*byte)(ptr), len(buf))
copy(buf, mem)
}
func (b *block) write(off int, buf []byte) {
var mem []byte
var ptr unsafe.Pointer
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&mem))
hdr.Data = uintptr(unsafe.Pointer(uintptr(b.addr + uint32(off))))
hdr.Len = len(buf)
ptr = unsafe.Add(ptr, int(b.addr) + off)
mem := unsafe.Slice((*byte)(ptr), len(buf))
copy(mem, buf)
}

2
dma/dma.go

@ -33,7 +33,7 @@ type block struct {
res bool
}
// Region represents a memory region allocated form DMA purposes.
// Region represents a memory region allocated for DMA purposes.
type Region struct {
sync.Mutex

2
go.mod

@ -1,3 +1,3 @@
module github.com/f-secure-foundry/tamago
go 1.16
go 1.17

Loading…
Cancel
Save