-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: draft porting guide #81
base: main
Are you sure you want to change the base?
Conversation
The Bao Hypervisor only contains architecture-specific drivers (e.g., interrupt controllers or | ||
IOMMUS). Therefore porting the hypervisor essentially resumes to two simple operation: creating a | ||
platform description folder containing a platform definition source and header files which | ||
indicates, among others, the number of CPUs or the memory available. The exception is an UART driver | ||
used fore logging, so if a driver is not available for a UART on the target platform this might |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, the first sentence doesn't contribute significantly. It looks like a bit disconnected from the remaining text.
The Bao Hypervisor only contains architecture-specific drivers (e.g., interrupt controllers or | |
IOMMUS). Therefore porting the hypervisor essentially resumes to two simple operation: creating a | |
platform description folder containing a platform definition source and header files which | |
indicates, among others, the number of CPUs or the memory available. The exception is an UART driver | |
used fore logging, so if a driver is not available for a UART on the target platform this might | |
Porting the hypervisor involves two basic steps: (i) creating a platform description folder with | |
source and header files that specify platform details, such as the number of CPUs or available | |
memory, and (ii) integrating a UART driver used for logging, so if a driver is not available for a | |
UART on the target platform this might require writing a custom driver. |
require writing such a driver. Finally, given for some platforms provide a custom mechanism to | ||
define DMA device Master IDs required for configuring IOMMUs, one might require to configure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, it would be interesting to refer to some examples to contextualize the firmware changes
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | ||
*src/platform*. For example, for port to a *foo* platform, create the directory *src/platform/foo*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | |
*src/platform*. For example, for port to a *foo* platform, create the directory *src/platform/foo*. | |
Creating a new platform description for the Bao Hypervisor begins by establishing a new directory | |
under src/platform. For instance, when porting to a foo platform, generate the directory | |
src/platform/foo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | |
*src/platform*. For example, for port to a *foo* platform, create the directory *src/platform/foo*. | |
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | |
``src/platform``. For example, for port to a *foo* platform, create the directory ``src/platform/foo``. |
- **base** [mandatory] - Is the base physical address of that memory region. Must be aligned to the minimum architecture's page size; | ||
- **size** [mandatory] - The size of the memory region. Must be aligned to the minimum architecture's page size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **base** [mandatory] - Is the base physical address of that memory region. Must be aligned to the minimum architecture's page size; | |
- **size** [mandatory] - The size of the memory region. Must be aligned to the minimum architecture's page size; | |
- **base** [mandatory] - Is the base physical address of that memory region. | |
- **size** [mandatory] - The size of the memory region. | |
.. warning:: | |
Ensure that the memory ``base`` and ``size`` are aligned to the minimum architecture's page size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the format to inline code.
Note that, by convention, we do not add on-chip/scratcpad SRAMs as a platform memory region as the hypervisor as an uniform view of memory. | ||
This regions should be assigned to guests in the form of devices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that, by convention, we do not add on-chip/scratcpad SRAMs as a platform memory region as the hypervisor as an uniform view of memory. | |
This regions should be assigned to guests in the form of devices. | |
.. note:: | |
By convention, we do not add on-chip/scratcpad SRAMs as a platform memory region as the hypervisor as an uniform view of memory. This regions should be assigned to guests in the form of devices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any major suggestions to add on the structure of the document. I considerer it already touches all the necessary topics.
Few points:
- inline code format must be used be used for file paths, file names, shell commands, programming language directives/keywords/identifiers, syntax characters as required in the Documentation Guidelines;
- when using tabs, the contents of each tab must one step indented from the ..tab: directive;
- an image from the folder structure of a platform definition would be helpful
1) Create a platform directory containing a platform description [mandatory]; | ||
2) Writing an UART driver [if the driver for the target UART is not available]; | ||
3) Setting up firmware to define DMA device Master IDs used by the platform IOMMU [platform dependent]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Diogo21Costa suggested to add here reference links to each section on the document detailing each process. I deleted the comment by mistake. I would also change the []
for ()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
1) A source file (e.g., *src/platform/foo/foo_desc.c*) containing the platform description structure, `struct platform platform` | ||
defininition; | ||
2) A *plat.h* header file under *src/platform/foo/inc/plat/* with platform-specific includes and definitions; | ||
3) A *platform.mk* makefile containing definitions required by the build system (e.g., the target architecture); | ||
4) A *objects.mk* containing the platform's target object files. In principle this should only contain the | ||
object for the source description file, but you may add others if you have any other platform specific sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1) A source file (e.g., *src/platform/foo/foo_desc.c*) containing the platform description structure, `struct platform platform` | |
defininition; | |
2) A *plat.h* header file under *src/platform/foo/inc/plat/* with platform-specific includes and definitions; | |
3) A *platform.mk* makefile containing definitions required by the build system (e.g., the target architecture); | |
4) A *objects.mk* containing the platform's target object files. In principle this should only contain the | |
object for the source description file, but you may add others if you have any other platform specific sources. | |
1) A source file (e.g., ``src/platform/foo/foo_desc.c``) containing the platform description structure, `struct platform platform` | |
definition; | |
2) A ``plat.h`` header file under ``src/platform/foo/inc/plat/`` with platform-specific includes and definitions; | |
3) A ``platform.mk`` makefile containing definitions required by the build system (e.g., the target architecture); | |
4) A ``objects.mk`` containing the platform's target object files. In principle this should only contain the | |
object for the source description file, but you may add others if you have any other platform specific sources. |
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | ||
*src/platform*. For example, for port to a *foo* platform, create the directory *src/platform/foo*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | |
*src/platform*. For example, for port to a *foo* platform, create the directory *src/platform/foo*. | |
Creating a new platform description for the Bao Hypervisor starts by creating a new directory under | |
``src/platform``. For example, for port to a *foo* platform, create the directory ``src/platform/foo``. |
Platform Description Structure | ||
****************************** | ||
|
||
A global structure of type `struct platform` named `platform` must be defined when porting Bao to a new platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A global structure of type `struct platform` named `platform` must be defined when porting Bao to a new platform. | |
A global structure of type ``struct platform`` named ``platform`` must be defined when porting Bao to a new platform. |
Porting | ||
======= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Porting | |
======= | |
Porting Guide | |
============= |
Architcture-Specific Platform Description | ||
######################################### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Architcture-Specific Platform Description | |
######################################### | |
Architecture-Specific Platform Description | |
########################################## |
|
||
.. code-block:: c | ||
|
||
struct arch_platform { | ||
struct gic_dscrp { | ||
paddr_t gicc_addr; | ||
paddr_t gich_addr; | ||
paddr_t gicv_addr; | ||
paddr_t gicd_addr; | ||
paddr_t gicr_addr; | ||
|
||
irqid_t maintenance_id; | ||
} gic; | ||
|
||
struct smmu_dscrp { | ||
paddr_t base; | ||
streamid_t global_mask; | ||
} smmu; | ||
|
||
struct clusters { | ||
size_t num; | ||
size_t* core_num; | ||
} clusters; | ||
}; | ||
|
||
Where, for the GIC interrupt controller `struct gic_dscrp` description: | ||
|
||
- **gic.gicc_addr** [mandatory for GICv2 platforms] - base address for the GIC's CPU Interface; | ||
- **gic.gich_addr** [mandatory for GICv2 platforms] - base address for the GIC's Virtual Interface Control Registers; | ||
- **gic.gicv_addr** [mandatory for GICv2 platforms] - base address for the GIC's Virtual CPU Interface; | ||
- **gic.gicd_addr** [mandatory] - base address for the GIC's Distributor; | ||
- **gic.gicr_addr** [mandatory for GICv3/4 platforms] - base address for the GIC's Redistributor; | ||
- **gic.maintenance_id** [mandatory] - The interrupt ID for the GIC's maintenance interrupt; | ||
|
||
For the SMMU `struct smmu_dscrp`: | ||
|
||
- **smmu.base** [mandatory] - is the base address for the SMMU; | ||
- **smmu.global_mask** [optional; only valid for SMMUv2] - a mask to be applied to all SMMUv2's Stream Match Registers; | ||
|
||
|
||
Finally, when CPUs are organized in clusters, in the Arm architecture their IDs are assigned using an hierarchical schema. | ||
To be able to calculate the linearized ID for each core, we require the port to provide the number of CPUs of cluster in | ||
ascending order of AFF1. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs an extra indentation to be grouped on each tab. Same for the RISC-V information.
|
||
For the SMMU `struct smmu_dscrp`: | ||
|
||
- **smmu.base** [mandatory] - is the base address for the SMMU; | ||
- **smmu.global_mask** [optional; only valid for SMMUv2] - a mask to be applied to all SMMUv2's Stream Match Registers; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inline code format for all code related text.
- **gic.gicd_addr** [mandatory] - base address for the GIC's Distributor; | ||
- **gic.gicr_addr** [mandatory for GICv3/4 platforms] - base address for the GIC's Redistributor; | ||
- **gic.maintenance_id** [mandatory] - The interrupt ID for the GIC's maintenance interrupt; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split this for each GIC version to be more explicit.
For all platforms:
- **gic.maintenance_id**
- **gic.gicd_addr**
For GICv2 platforms:
- **gic.gicc_addr**
- **gic.gich_addr**
- **gic.gicv_addr**
For GICv3/4 platforms:
- **gic.gicr_addr**
Platform Make Defintions | ||
************************ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Platform Make Defintions | |
************************ | |
Platform Make Definitions | |
************************* |
Signed-off-by: Jose Martins <[email protected]>
1f61406
to
74ce71e
Compare
1654e31
to
d42b0fa
Compare
.. tabs:: | ||
.. tab:: Arm | ||
|
||
- `GIC_VERSION` [mandatory] - indicates the GIC's version present on the platform. Option: `GICV2`, or `GICV3`. | ||
|
||
.. tab:: RISC-V | ||
|
||
- `IRQC` [mandatory] - indicates the interrupt controller available on the platform. Options: `PLIC`, `APLIC`, or `AIA`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently not working
1) Create a platform directory containing a platform description [mandatory]; | ||
2) Writing an UART driver [if the driver for the target UART is not available]; | ||
3) Setting up firmware to define DMA device Master IDs used by the platform IOMMU [platform dependent]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
1) A source file (e.g., *src/platform/foo/foo_desc.c*) containing the platform description structure, `struct platform platform` | ||
defininition; | ||
2) A *plat.h* header file under *src/platform/foo/inc/plat/* with platform-specific includes and definitions; | ||
3) A *platform.mk* makefile containing definitions required by the build system (e.g., the target architecture); | ||
4) A *objects.mk* containing the platform's target object files. In principle this should only contain the | ||
object for the source description file, but you may add others if you have any other platform specific sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List is not working
|
||
The architecture-specific field of the platform description includes fields that describe interrupt controllers or others. | ||
|
||
.. tabs:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs not working
This PR details the steps for porting the Bao Hypervisor to a new platform. Still WIP, but any feedback is welcome.