		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 realview-pb-a8-defconfig 

  [4. Build Xvisor]
  # make

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

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

  [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 | <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 | <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 | <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/arm32/realview-pb-a8/basic/arm_test.bin.patched@0x71000000 build/kern1.bin@0x71100000 build/kern2.bin@0x71120000 build/kern3.bin@0x71140000 build/kern4.bin@0x71160000 build/mutex1.bin@0x71180000 build/mutex2.bin@0x711A0000 build/mutex3.bin@0x711C0000 build/mutex4.bin@0x711E0000 build/mutex5.bin@0x71200000 build/mutex6.bin@0x71220000 build/mutex7.bin@0x71240000 build/mutex8.bin@0x71260000 build/mutex9.bin@0x71280000 build/queue1.bin@0x712A0000 build/queue2.bin@0x712C0000 build/queue3.bin@0x712E0000 build/queue4.bin@0x71300000 build/queue5.bin@0x71320000 build/queue6.bin@0x71340000 build/queue7.bin@0x71360000 build/queue8.bin@0x71380000 build/queue9.bin@0x713A0000 build/queue10.bin@0x713C0000 build/sem1.bin@0x713E0000 build/sem2.bin@0x71400000 build/sem3.bin@0x71420000 build/sem4.bin@0x71440000 build/sem5.bin@0x71460000 build/sem6.bin@0x71480000 build/sem7.bin@0x714A0000 build/sem8.bin@0x714C0000 build/sem9.bin@0x714E0000 build/timer1.bin@0x71500000 build/timer2.bin@0x71520000 build/timer3.bin@0x71540000 build/timer4.bin@0x71560000 build/timer5.bin@0x71580000 build/timer6.bin@0x715A0000 build/timer7.bin@0x715C0000

  [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.)

