UEFI target groundwork: runtime: split baremetal memory setup (#5360)

* runtime: split baremetal memory setup
* add missing unsafe import
This commit is contained in:
Matthew Hiles
2026-06-06 10:11:20 -04:00
committed by GitHub
parent 8e36d2758b
commit 7b3dc19445
2 changed files with 35 additions and 30 deletions
-30
View File
@@ -7,36 +7,6 @@ import (
"unsafe"
)
//go:extern _heap_start
var heapStartSymbol [0]byte
//go:extern _heap_end
var heapEndSymbol [0]byte
//go:extern _globals_start
var globalsStartSymbol [0]byte
//go:extern _globals_end
var globalsEndSymbol [0]byte
//go:extern _stack_top
var stackTopSymbol [0]byte
var (
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = uintptr(unsafe.Pointer(&heapEndSymbol))
globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
globalsEnd = uintptr(unsafe.Pointer(&globalsEndSymbol))
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
)
// growHeap tries to grow the heap size. It returns true if it succeeds, false
// otherwise.
func growHeap() bool {
// On baremetal, there is no way the heap can be grown.
return false
}
//export malloc
func libc_malloc(size uintptr) unsafe.Pointer {
// Note: this zeroes the returned buffer which is not necessary.
+35
View File
@@ -0,0 +1,35 @@
//go:build baremetal
package runtime
import "unsafe"
//go:extern _heap_start
var heapStartSymbol [0]byte
//go:extern _heap_end
var heapEndSymbol [0]byte
//go:extern _globals_start
var globalsStartSymbol [0]byte
//go:extern _globals_end
var globalsEndSymbol [0]byte
//go:extern _stack_top
var stackTopSymbol [0]byte
var (
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = uintptr(unsafe.Pointer(&heapEndSymbol))
globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
globalsEnd = uintptr(unsafe.Pointer(&globalsEndSymbol))
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
)
// growHeap tries to grow the heap size. It returns true if it succeeds, false
// otherwise.
func growHeap() bool {
// On baremetal, there is no way the heap can be grown.
return false
}