		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
Guest with Xvisor running on QEMU Realview PB-A8 Host:

  [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/arm32/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/arm32/elf2cpatch.py -f build/arm_irq.o .text | <xvisor_source_directory>/build/tools/cpatch/cpatch32 build/arm_irq.o 0
  # <xvisor_source_directory>/arch/arm/cpu/arm32/elf2cpatch.py -f build/atomport-asm.o .text | <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 all atomthreads testcases) 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 build/kern2.bin@0x70920000 build/kern3.bin@0x70940000 build/kern4.bin@0x70960000 build/mutex1.bin@0x70980000 build/mutex2.bin@0x709A0000 build/mutex3.bin@0x709C0000 build/mutex4.bin@0x709E0000 build/mutex5.bin@0x70A00000 build/mutex6.bin@0x70A20000 build/mutex7.bin@0x70A40000 build/mutex8.bin@0x70A60000 build/mutex9.bin@0x70A80000 build/queue1.bin@0x70AA0000 build/queue2.bin@0x70AC0000 build/queue3.bin@0x70AE0000 build/queue4.bin@0x70B00000 build/queue5.bin@0x70B20000 build/queue6.bin@0x70B40000 build/queue7.bin@0x70B60000 build/queue8.bin@0x70B80000 build/queue9.bin@0x70BA0000 build/queue10.bin@0x70BC0000 build/sem1.bin@0x70BE0000 build/sem2.bin@0x70C00000 build/sem3.bin@0x70C20000 build/sem4.bin@0x70C40000 build/sem5.bin@0x70C60000 build/sem6.bin@0x70C80000 build/sem7.bin@0x70CA0000 build/sem8.bin@0x70CC0000 build/sem9.bin@0x70CE0000 build/timer1.bin@0x70D00000 build/timer2.bin@0x70D20000 build/timer3.bin@0x70D40000 build/timer4.bin@0x70D60000 build/timer5.bin@0x70D80000 build/timer6.bin@0x70DA0000 build/timer7.bin@0x70DC0000

  [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 0

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

  [14. Copy kern1.bin atomthreads test 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: the above steps assumes Xvisor running on Realview-PB-A8 host emulated
   by QEMU 0.14.xx or higher. For other types of ARM host some of the above 
   steps will need to be adapted for that specfic ARM host. For more info on 
   your desired ARM host refer docs/arm/)
  (Note: step 14 copies kern1.bin test case to 0x100000 instead of this you 
   can use kern2.bin, ..., mutex1.bin, ..., etc. testcases. All testcases are
   loaded to NOR flash location 0x40100000 at 0x20000 offset. All testcases are
   compiled for 0x100000 location so you have to copy them to same location and
   you can test only one test case at a time. To try another test after running
   a particular test we have to reset the guest from Xvisor prompt using guest
   command after step 16 and do step 14 to step 16 for another testcase.)
  (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.)

