Hardware in the loop

I am a newbie developer and I need some assistance in the following topics please :
Where can I find

  1. Normal flight mode C code for apm 2 ?

  2. Hardware in the loop C code for apm 2 ?

  3. Normal flight mode C code for PIXHAWK 4 ?

  4. Hardware in the loop C code for PIXHAWK 4?