160 lines
7.3 KiB
Plaintext
160 lines
7.3 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: Bao-Attach script template for ZYNQ-Ultrascale
|
|
; @Description:
|
|
; Generic script template for Bao debugging setup in TRACE32 in SMP mode.
|
|
; In this example, the script will create two Baremetal guests, each one with two cores.
|
|
; Prerequisites:
|
|
; * Bao is already booted
|
|
; * Bao is compiled with debug symbols
|
|
; @Keywords: Bao, Virtualization, Awareness
|
|
; @Author: Joao Peixoto (joaopeixotooficial@gmail.com)
|
|
; Diogo Silvino (diogo.roseira.sil@gmail.com)
|
|
; --------------------------------------------------------------------------------
|
|
|
|
PRINT "TRACE32 for Bao hypervisor on zcu102"
|
|
|
|
; ======= Open a new window and delete the Bao menu (if it exists) ========
|
|
|
|
AREA.CLEAR
|
|
AREA.view
|
|
|
|
IF MENU.EXIST("EXT.BAOHYPERVISOR")
|
|
MENU.Delete.NAME EXT.BAOHYPERVISOR
|
|
|
|
|
|
; ======== Reset debugger ========
|
|
|
|
PRINT "Resetting debugger..."
|
|
RESet
|
|
SYStem.RESet
|
|
EXTension.RESet
|
|
TASK.RESet
|
|
TRANSlation.RESet
|
|
Break.Delete
|
|
|
|
; ======== Setup debugger ========
|
|
|
|
PRINT "Setting up debugger..."
|
|
; To ensured that the JTAG port is reset in normal operation
|
|
; Pull down the TRST line (Reset the TAP address controller)
|
|
SYStem.Option TRST OFF
|
|
; Halt the core (enter into debug mode by a JTAG sequence)
|
|
SYStem.Option ResBreak OFF
|
|
;SYStem.Option DACR ON ; Give Debugger global write permissions
|
|
SYStem.Option WaitReset 500ms ; Wait 0,5s
|
|
SYStem.JtagClock CTCK 10MHz ; JTAG clock frequency
|
|
SYStem.CPU ZYNQ-ULTRASCALE+-APU ; Target CPU (Application Processing Unit composed by 4 Cortex a53 cores)
|
|
CORE.ASSIGN 1. 2. 3. 4. ; Assign all cores (the four Cortex a53 ones)
|
|
|
|
; ======== Enable space IDs, zone distinction and machine IDs ========
|
|
|
|
; As TRACE32 assumes a single linear address space for all CPU modes of RISC processors by default, the system must be configured to
|
|
; recognize multiple overlapping address spaces. This is necessary to allow TRACE32 to load symbol and debug information per address space
|
|
; and to maintain separate MMU translation tables for each address space.
|
|
; TRACE32 supports three types of address spaces:
|
|
; - Zone Spaces (used to keep symbols and MMU/TRANSlation setups separate from each CPU operation mode)
|
|
; - MMU Spaces (MMU-mapped memory space)
|
|
; - Machine Spaces (if a hypervisor is used to manage virtual machines)
|
|
|
|
PRINT "Enabling space IDs, zone distinction and machine IDs"
|
|
SYStem.Option.MACHINESPACES ON ; Defines the host machine and each guest machine as individual zones (Debugging virtualized systems)
|
|
SYStem.Option IMASKASM ON ; Interrupt mask bits of the CPU will be set during assembler single-step operation
|
|
SYStem.Option.MMUSPACES ON ; Enable multiple equivalent page tables within the same zone (This is necessary, if one of the guests or the hypervisor itself uses MMU spaces (processes))
|
|
SYStem.Option.ZONESPACES ON ; Defines each CPU operation mode with an individual address space as an individual zone (Secure/NonSecure & EL)
|
|
|
|
; Note: TRACE32 addresses are extended as following:
|
|
; <access class> : <machine_id> ::: <space_id> : <offset>
|
|
; Where:
|
|
; <access class> => P (Program), D (Data), H (Hypervisor mode), M (Monitor mode), DC (Data cache), L2 (L2 cache), IC (Instruction Cache)
|
|
; => S (Privileged access), U (User memory), Z (Secure - TrustZone), N (Non-secure - TrustZone), E (Run-time memory access)
|
|
; => A (Physical Address, bypassing MMU), I (Intermediate Physical Address), D (Guest Logical Address, or VA)
|
|
; <machine_id> => 0 (Host machine / Hypervisor) , >=1 (VMs)
|
|
; <space_id> => 16-bit number
|
|
|
|
|
|
; ======== Connect to target ========
|
|
|
|
PRINT "Attaching to target..."
|
|
SYStem.Mode Attach
|
|
IF STATE.RUN()
|
|
Break
|
|
|
|
|
|
; ======== Configure Hypervisor awareness support ========
|
|
|
|
; Load the Bao symbols into the Hypervisor zone, Host machine and with a space ID of zero
|
|
PRINT "Loading Bao symbols..."
|
|
Data.LOAD.ELF /home/joaopeixoto13/bao-demos/wrkdir/srcs/bao-hypervisor-v1.0.0/bin/zcu102/baremetal/bao.elf H:0x0:::0x0 /NoCODE
|
|
|
|
; Verify the maximum address
|
|
PRIVATE &nAddressMax &nAddressKernelCheck &nIsSMP
|
|
&nAddressMax = 0xffffffff ; 32-bit processor
|
|
&nAddressKernelCheck = 0x80000000 ; 2G/2G split
|
|
&nIsSMP = "0x1" ; 1 if SMP, 0 if AMP
|
|
|
|
; If the CPU is 64-bit, update the maximum address
|
|
IF CPUIS64BIT()
|
|
(
|
|
&nAddressMax = 0xffffffffffffffff ; 64-bit processor
|
|
&nAddressKernelCheck = 0xf000000000000000 ; Whole upper memory
|
|
PRINT "CPU is 64-bit"
|
|
)
|
|
ELSE
|
|
PRINT "CPU is 32-bit"
|
|
|
|
; Enable extension debug
|
|
EXTension.DEBUG 1 bao
|
|
|
|
; Load the Bao Hypervisor Menu
|
|
MENU.ReProgram ~~/demo/arm/kernel/bao/bao-smp.men
|
|
|
|
; Define the default MMU table structure
|
|
; Note: MMU command lets you access and view the real hardware MMU.
|
|
; However, TRANSlation command configures and controls the TRACE32 internal debugger address translation. This feature is used to "mimic"
|
|
; the translations within the real hardware MMU so that the debugger can acess code and data of any OS process at any time.
|
|
|
|
; Defines the default logical-to-physical address translation. Also, gives the information needed for the page table walks, which are performed
|
|
; by TRACE32 for debugger address translation, page table dumps, or page table scans.
|
|
MMU.FORMAT STD /MACHINE 0.
|
|
|
|
; Defines one mapping of logical address range that is shared by the kernel
|
|
; Note: Common address ranges are ranges of logical addresses belonging to the kernel. The common address ranges contain code or data which
|
|
; is shared by various processes. When the address of a memory access falls into a common address range, TRACE32 uses the kernel
|
|
; address translation, with the space ID of 0x0 to find the translation of a common address.
|
|
TRANSlation.COMMON H:0x0:::0x0--&(nAddressMax) /MACHINE 0.
|
|
|
|
; Configures the debugger to perform an MMU page table walk.
|
|
; Note: In this scenario, the debugger will first lookup the static address translation table (TRANSlation.List) and if the address lookup
|
|
; fails, the debugger will walk through the OS MMU tables to find a valid logical-to-physical translation.
|
|
TRANSlation.TableWalk ON
|
|
|
|
; Activates the TRACE32 internal debugger address translation based on translations already created (TRANSlation.COMMON)
|
|
; Can be consulted with TRANSlation.List command
|
|
TRANSlation.ON
|
|
|
|
; Load the Bao hypervisor awareness extension into Hypervisor zone, Host machine and with a space ID
|
|
PRINT "Loading Bao awareness..."
|
|
EXTension.LOAD ~~/demo/arm/kernel/bao/bao-smp.t32 /ACCESS H:0x0:::0x0 /MACHINE 0. /NAME "BAO"
|
|
|
|
; ======== Load here your Guests ========
|
|
|
|
; --- BAREMETAL + BAREMETAL DEMO ---
|
|
; Add a new Baremetal Guest on VM #1
|
|
DO ~~/demo/arm/kernel/bao/guests/attach-baremetal "0x1" "/PATH/TO/YOUR/baremetal.elf" "&nAddressMax" "&nIsSMP"
|
|
; Add a new Baremetal Guest on VM #2
|
|
DO ~~/demo/arm/kernel/bao/guests/attach-baremetal "0x2" "/PATH/TO/YOUR/baremetal.elf" "&nAddressMax" "&nIsSMP"
|
|
|
|
; --- BAREMETAL + FreeRTOS DEMO ---
|
|
; Add a new Baremetal Guest on VM #1
|
|
;DO ~~/demo/arm/kernel/bao/guests/attach-baremetal "0x1" "/PATH/TO/YOUR/baremetal.elf" "&nAddressMax" "&nIsSMP"
|
|
; Add a new FreeRTOS Guest on VM #2
|
|
;DO ~~/demo/arm/kernel/bao/guests/attach-freertos "0x2" "/PATH/TO/YOUR/freertos.elf" "~~/demo/arm/kernel/freertos/freertos.t32" "~~/demo/arm/kernel/freertos/freertos.men" "&nAddressMax" "&nIsSMP"
|
|
|
|
IF !STATE.RUN()
|
|
Go
|
|
|
|
; ======== Done ========
|
|
|
|
PRINT "Done!"
|
|
ENDDO
|