github.com/aykevl/tinygo@v0.5.0/src/runtime/arch_cortexm.go (about)

     1  // +build cortexm
     2  
     3  package runtime
     4  
     5  import (
     6  	"unsafe"
     7  
     8  	"device/arm"
     9  )
    10  
    11  const GOARCH = "arm"
    12  
    13  // The bitness of the CPU (e.g. 8, 32, 64).
    14  const TargetBits = 32
    15  
    16  //go:extern _heap_start
    17  var heapStartSymbol unsafe.Pointer
    18  
    19  //go:extern _heap_end
    20  var heapEndSymbol unsafe.Pointer
    21  
    22  //go:extern _globals_start
    23  var globalsStartSymbol unsafe.Pointer
    24  
    25  //go:extern _globals_end
    26  var globalsEndSymbol unsafe.Pointer
    27  
    28  //go:extern _stack_top
    29  var stackTopSymbol unsafe.Pointer
    30  
    31  var (
    32  	heapStart    = uintptr(unsafe.Pointer(&heapStartSymbol))
    33  	heapEnd      = uintptr(unsafe.Pointer(&heapEndSymbol))
    34  	globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
    35  	globalsEnd   = uintptr(unsafe.Pointer(&globalsEndSymbol))
    36  	stackTop     = uintptr(unsafe.Pointer(&stackTopSymbol))
    37  )
    38  
    39  // Align on word boundary.
    40  func align(ptr uintptr) uintptr {
    41  	return (ptr + 3) &^ 3
    42  }
    43  
    44  func getCurrentStackPointer() uintptr {
    45  	return arm.ReadRegister("sp")
    46  }