| Andrew Walbran | 32731a6 | 2019-11-13 18:04:31 +0000 | [diff] [blame] | 1 | # Code structure | 
|  | 2 |  | 
|  | 3 | The Hafnium repository contains Hafnium itself, along with unit tests and | 
|  | 4 | integration tests, a small client library for VMs, a Linux kernel module for the | 
|  | 5 | primary VM, prebuilt binaries of tools needed for building it and running tests. | 
|  | 6 | Everything is built with [GN](https://gn.googlesource.com/gn/). | 
|  | 7 |  | 
|  | 8 | Hafnium can be built for an **architecture**, currently including: | 
|  | 9 |  | 
|  | 10 | *   `aarch64`: 64-bit Armv8 | 
|  | 11 | *   `fake`: A dummy architecture used for running unit tests on the host system. | 
|  | 12 |  | 
|  | 13 | And for a **platform**, such as: | 
|  | 14 |  | 
|  | 15 | *   `aem_v8a_fvp`: The Arm [Fixed Virtual Platform](FVP.md) emulator. | 
|  | 16 | *   `qemu_aarch64`: QEMU emulating an AArch64 device. | 
|  | 17 | *   `rpi4`: A Raspberry Pi 4 board. | 
|  | 18 |  | 
|  | 19 | Each platform has a single associated architecture. | 
|  | 20 |  | 
|  | 21 | The source tree is organised as follows: | 
|  | 22 |  | 
|  | 23 | *   [`build`](../build): Common GN configuration, build scripts, and linker | 
|  | 24 | script. | 
|  | 25 | *   [`docs`](.): Documentation | 
|  | 26 | *   [`driver/linux`](../driver/linux): Linux kernel driver for Hafnium, for use | 
|  | 27 | in the primary VM. | 
|  | 28 | *   [`inc`](../inc): Header files... | 
|  | 29 | *   [`hf`](../inc/hf): ... internal to Hafnium | 
|  | 30 | *   [`arch`](../inc/hf/arch): Architecture-dependent modules, which have | 
|  | 31 | a common interface but separate implementations per architecture. | 
|  | 32 | This includes details of CPU initialisation, exception handling, | 
|  | 33 | timers, page table management, and other system registers. | 
|  | 34 | *   [`plat`](../inc/hf/plat): Platform-dependent modules, which have a | 
|  | 35 | common interface but separate implementations per platform. This | 
|  | 36 | includes details of the boot flow, and a UART driver for the debug | 
|  | 37 | log console. | 
|  | 38 | *   [`system`](../inc/system): ... which are included by the `stdatomic.h` | 
|  | 39 | which we use from Android Clang but not really needed, so we use dummy | 
|  | 40 | empty versions. | 
|  | 41 | *   [`vmapi/hf`](../inc/vmapi/hf): ... for the interface exposed to VMs. | 
|  | 42 | *   [`kokoro`](../kokoro): Scripts and configuration for continuous integration | 
|  | 43 | and presubmit checks. | 
|  | 44 | *   [`prebuilts`](../prebuilts): Prebuilt binaries needed for building Hafnium | 
|  | 45 | or running tests. | 
|  | 46 | *   [`project`](../project): Configuration and extra code for each **project**. | 
|  | 47 | A project is a set of one or more _platforms_ (see above) that are built | 
|  | 48 | together. Hafnium comes with the [`reference`](../project/reference) project | 
|  | 49 | for running it on some common emulators and development boards. To port | 
|  | 50 | Hafnium to a new board, you can create a new project under this directory | 
|  | 51 | with the platform or platforms you want to add, without affecting the core | 
|  | 52 | Hafnium code. | 
|  | 53 | *   [`src`](../src): Source code for Hafnium itself in C and assembly, and | 
|  | 54 | [unit tests](Testing.md) in C++. | 
|  | 55 | *   [`arch`](../src/arch): Implementation of architecture-dependent modules. | 
|  | 56 | *   [`test`](../test): [Integration tests](Testing.md) | 
|  | 57 | *   [`arch`](../test/arch): Tests for components of Hafnium that need to be | 
|  | 58 | run on a real architecture. | 
|  | 59 | *   [`hftest`](../test/hftest): A simple test framework that supports | 
|  | 60 | running tests standalone on bare metal, in VMs under Hafnium, or as | 
|  | 61 | user-space binaries under Linux under Hafnium. | 
|  | 62 | *   [`linux`](../test/linux): Tests which are run in a Linux VM under | 
|  | 63 | Hafnium. | 
|  | 64 | *   [`vmapi`](../test/vmapi): Tests which are run in minimal test VMs under | 
|  | 65 | Hafnium. | 
|  | 66 | *   [`arch`](../test/vmapi/arch): Tests which are rely on specific | 
|  | 67 | architectural details such as the GIC version. | 
|  | 68 | *   [`primary_only`](../test/vmapi/primary_only): Tests which run only a | 
|  | 69 | single (primary) VM. | 
|  | 70 | *   [`primary_with_secondaries`](../test/vmapi/primary_with_secondaries): | 
|  | 71 | Test which run with a primary VM and one or more secondary VMs to | 
|  | 72 | test how they interact. | 
|  | 73 | *   [`third_party`](../third_party): Third party code needed for building | 
|  | 74 | Hafnium. | 
|  | 75 | *   [`vmlib`](../vmlib): A small client library for VMs running under Hafnium. |