; --------------------------------------------------------------------------------
; @Title: Load an example APU for USR: accesses implemented on the host
; @Description:
;   This script loads the APU library, which first has to be compiled by the
;   user, for example by using the provided Makefiles.
;
;   See the comments in example_usraccess.c for further information.
;
;   Example:
;   CD ~~/demo/apu/example_usraccess
;   OS.Area make
;   DO example_usraccess.cmm
;
; @Author: MPL
; @Copyright: (C) 1989-2016 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id$

PRIVATE &ppd &name &architecture &extension

&ppd=OS.PPD()
&name="example_usraccess"

IF OS.NAME()=="Linux"
(
  &extension="so"
)
ELSE IF OS.NAME()=="Windows"
(
  &extension="dll"
)
ELSE
(
  PRINT %ERROR "Unsupported OS"
  ENDDO FALSE()
)

&architecture=""
IF SOFTWARE.64BIT()
(
  &architecture="64"
)

APU.LOAD &ppd/&name&architecture.&extension

IF !SYStem.Up()
(
  IF SIMULATOR()
  (
    SYStem.Up
  )
  ELSE
  (
    ERROR "Please connect to your target first or use this script in simulator mode"
  )
)

; open some windows; the USR: window should always show the one's complement of
; the normal D: address space.
Data.dump   D:0x00000000 /Long /LE
Data.dump USR:0x00000000 /Long /LE

PRINT "USRACCESS example loaded."

ENDDO TRUE()
