Skip to content

Commit 7b3dc19

Browse files
authored
UEFI target groundwork: runtime: split baremetal memory setup (#5360)
* runtime: split baremetal memory setup * add missing unsafe import
1 parent 8e36d27 commit 7b3dc19

2 files changed

Lines changed: 35 additions & 30 deletions

File tree

src/runtime/baremetal.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,6 @@ import (
77
"unsafe"
88
)
99

10-
//go:extern _heap_start
11-
var heapStartSymbol [0]byte
12-
13-
//go:extern _heap_end
14-
var heapEndSymbol [0]byte
15-
16-
//go:extern _globals_start
17-
var globalsStartSymbol [0]byte
18-
19-
//go:extern _globals_end
20-
var globalsEndSymbol [0]byte
21-
22-
//go:extern _stack_top
23-
var stackTopSymbol [0]byte
24-
25-
var (
26-
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
27-
heapEnd = uintptr(unsafe.Pointer(&heapEndSymbol))
28-
globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
29-
globalsEnd = uintptr(unsafe.Pointer(&globalsEndSymbol))
30-
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
31-
)
32-
33-
// growHeap tries to grow the heap size. It returns true if it succeeds, false
34-
// otherwise.
35-
func growHeap() bool {
36-
// On baremetal, there is no way the heap can be grown.
37-
return false
38-
}
39-
4010
//export malloc
4111
func libc_malloc(size uintptr) unsafe.Pointer {
4212
// Note: this zeroes the returned buffer which is not necessary.

src/runtime/baremetal_memory.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//go:build baremetal
2+
3+
package runtime
4+
5+
import "unsafe"
6+
7+
//go:extern _heap_start
8+
var heapStartSymbol [0]byte
9+
10+
//go:extern _heap_end
11+
var heapEndSymbol [0]byte
12+
13+
//go:extern _globals_start
14+
var globalsStartSymbol [0]byte
15+
16+
//go:extern _globals_end
17+
var globalsEndSymbol [0]byte
18+
19+
//go:extern _stack_top
20+
var stackTopSymbol [0]byte
21+
22+
var (
23+
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
24+
heapEnd = uintptr(unsafe.Pointer(&heapEndSymbol))
25+
globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
26+
globalsEnd = uintptr(unsafe.Pointer(&globalsEndSymbol))
27+
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
28+
)
29+
30+
// growHeap tries to grow the heap size. It returns true if it succeeds, false
31+
// otherwise.
32+
func growHeap() bool {
33+
// On baremetal, there is no way the heap can be grown.
34+
return false
35+
}

0 commit comments

Comments
 (0)