		Atomthreads on Realview PB-A8 Guest

Atomthreads is a free, lightweight, portable, real-time scheduler for 
embedded systems. Please visit: http://atomthreads.com/ for more details.

The Realview PB-A8 port of atomthreads is still not released officially, but
you can obtain the sources from: https://github.com/avpatel/atomthreads-arm

Atomthreads uses all the CPU & Hardware features except Memory managment unit
(MMU) and Floating point unit (FPU).

Please follow the steps below to build & run Atomthreads on Realview PB-A8:

  [1. Build environment for Xvisor]
  # CROSS_COMPILE=arm-none-linux-gnueabi-

  [2. GoTo Xvisor source directory]
  # cd <xvisor_source_directory>

  [3. Configure Xvisor with Realview PB-A8 default settings]
  # make ARCH=arm pb-a8-defconfig 

  [4. Build Xvisor]
  # make

  [5. Build Basic Test Code]
  # make -C tests/armv7a/pb-a8/basic

  [6. GoTo Atomthreads source directory]
  # cd <atomthreads_source_directory>/ports/armv7a

  [7. Build Atomthreads]
  # make

  [8. Patch Atomthreads objects to replace sensitive non-priviledged instructions]
  # <xvisor_source_directory>/arch/arm/cpu/armv7a/elf2cpatch.py -f build/arm_entry.o .expvect | <xvisor_source_directory>/build/tools/cpatch/cpatch32 build/arm_entry.o 0
  # <xvisor_source_directory>/arch/arm/cpu/armv7a/elf2cpatch.py -f build/arm_irq.o .expvect | <xvisor_source_directory>/build/tools/cpatch/cpatch32 build/arm_irq.o 0
  # <xvisor_source_directory>/arch/arm/cpu/armv7a/elf2cpatch.py -f build/atomport-asm.o .expvect | <xvisor_source_directory>/build/tools/cpatch/cpatch32 build/atomport-asm.o 0

  [9. Rebuild Atomthreads to reflect changed object files]
  # make

  [10. Create qemu.img (from vmm.bin, arm_test.bin.patched and kern1.bin) for running it on QEMU]
  # <xvisor_source_directory>/tools/scripts/memimg.py -a 0x70010000 -o build/qemu.img <xvisor_source_directory>/build/vmm.bin@0x70010000 <xvisor_source_directory>/build/tests/armv7a/pb-a8/basic/arm_test.bin.patched@0x70800000 build/kern1.bin@0x70900000

  [11. Launch QEMU]
  # qemu-system-arm -M realview-pb-a8 -display none -serial stdio -kernel build/qemu.img

  [12. Kick Guest for starting Basic Test]
  XVisor# guest kick -1

  [13. Bind to virtual UART]
  XVisor# vserial bind guest0/uart0

  [14. Copy atomthreads binary from NOR flash to DDR]
  [guest0/uart0] arm-test# copy 0x100000 0x40100000 0x20000

  [15. Start atomthreads]
  [guest0/uart0] arm-test# go 0x100000

  [16. Enter character seqence 'ESCAPE+x+q" return to Xvisor prompt]
  [guest0/uart0] 

  (Note: replace all <> brackets based on your workspace)
  (Note: step 10. uses build/kern1.bin test case instead of this you can use 
   build/kern2.bin, ..., build/mutex1.bin, ..., etc. test cases)
  (Note: step 14. & step 15. assume that text base address for atomthreads
   binary is 0x100000. You can change this in atomthreads source and modify
   the above steps accordingly.)

