github.com/usbarmory/tamago@v0.0.0-20240508072735-8612bbe1e454/riscv/riscv.go (about)

     1  // RISC-V processor support
     2  // https://github.com/usbarmory/tamago
     3  //
     4  // Copyright (c) WithSecure Corporation
     5  // https://foundry.withsecure.com
     6  //
     7  // Use of this source code is governed by the license
     8  // that can be found in the LICENSE file.
     9  
    10  // Package riscv provides support for RISC-V architecture specific operations.
    11  //
    12  // The following architectures/cores are supported/tested:
    13  //   - RV64 (single-core)
    14  //
    15  // This package is only meant to be used with `GOOS=tamago GOARCH=riscv64` as
    16  // supported by the TamaGo framework for bare metal Go on ARM SoCs, see
    17  // https://github.com/usbarmory/tamago.
    18  package riscv
    19  
    20  import "runtime"
    21  
    22  // This package supports 64-bit cores.
    23  const XLEN = 64
    24  
    25  // CPU instance
    26  type CPU struct{}
    27  
    28  // defined in riscv.s
    29  func halt()
    30  
    31  // Init performs initialization of an RV64 core instance in machine mode.
    32  func (cpu *CPU) Init() {
    33  	runtime.Exit = halt
    34  
    35  	cpu.SetExceptionHandler(DefaultExceptionHandler)
    36  }
    37  
    38  // InitSupervisor performs initialization of an RV64 core instance in
    39  // supervisor mode.
    40  func (cpu *CPU) InitSupervisor() {
    41  	cpu.SetSupervisorExceptionHandler(DefaultSupervisorExceptionHandler)
    42  }