github.com/transparency-dev/armored-witness-os@v0.1.3-0.20240514084412-27eef7325168/trusted_os/mem_bee.go (about)

     1  // Copyright 2022 The Armored Witness OS authors. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  //go:build bee
    16  // +build bee
    17  
    18  package main
    19  
    20  import (
    21  	_ "unsafe"
    22  )
    23  
    24  // The following memory regions are within an alias of external DDR, required
    25  // when memory encryption is enforced by the i.MX6UL Bus Encryption Engine
    26  // (BEE).
    27  const (
    28  	// The Secure Monitor RAM cannot be used as reserved area for
    29  	// arm.Init() as the L1/L2 page tables cannot be placed in BEE aliased
    30  	// memory due to its caching requirements, we therefore override
    31  	// vecTableStart with the alias physical pointer.
    32  	physicalStart = 0x80000000 // imx6ul.MMDC_BASE
    33  
    34  	// Secure Monitor DMA
    35  	//
    36  	// BEE aliased regions must be accessed either through cache or 16 byte
    37  	// accesses, this makes it impractical for peripheral driver DMA use
    38  	// and we must therefore keep DMA on a non-aliased region.
    39  	secureDMAStart = 0x8e000000
    40  	secureDMASize  = 0x02000000 // 32MB
    41  
    42  	// Secure Monitor
    43  	secureStart = 0x10000000 // bee.AliasRegion0
    44  	secureSize  = 0x0e000000 // 224MB
    45  
    46  	// Secure Monitor Applet
    47  	appletStart = 0x20000000
    48  	appletSize  = 0x10000000 // 256MB
    49  )
    50  
    51  //go:linkname ramStart runtime.ramStart
    52  var ramStart uint32 = secureStart
    53  
    54  //go:linkname ramSize runtime.ramSize
    55  var ramSize uint32 = secureSize
    56  
    57  //go:linkname vecTableStart github.com/usbarmory/tamago/arm.vecTableStart
    58  var vecTableStart uint32 = physicalStart