diff --git a/doc/developer-guides/images/boot_information_parsing_module.png b/doc/developer-guides/images/boot_information_parsing_module.png deleted file mode 100644 index 91588ce76..000000000 Binary files a/doc/developer-guides/images/boot_information_parsing_module.png and /dev/null differ diff --git a/doc/developer-guides/sw_design_guidelines.rst b/doc/developer-guides/sw_design_guidelines.rst index bd3e1e13a..8db1c8838 100644 --- a/doc/developer-guides/sw_design_guidelines.rst +++ b/doc/developer-guides/sw_design_guidelines.rst @@ -590,104 +590,6 @@ The following table shows some use cases of module level configuration design: configuration is dereferenced after it has been instantiated. -Examples -======== - -Take the module for parsing boot information as an example to illustrate the -idea of module level configuration design. - -.. figure:: images/boot_information_parsing_module.png - :align: center - :scale: 70 % - :name: boot_information_parsing_module - - Boot Information Parsing Module - - -As shown in the source code below, 'struct firmware_operations' is an operations -data structure that contains a set of function pointers. -Different firmware may have different implementations: - -- 'firmware_uefi_ops' is for UEFI platform; -- 'firmware_sbl_ops' is for SBL platform. - - -.. code-block:: c - - struct firmware_operations { - void (*init)(void); - uint64_t (*get_ap_trampoline)(void); - void *(*get_rsdp)(void); - void (*init_irq)(void); - int32_t (*init_vm_boot_info)(struct acrn_vm *vm); - }; - - static struct firmware_operations firmware_uefi_ops = { - .init = uefi_init, - .get_ap_trampoline = uefi_get_ap_trampoline, - .get_rsdp = uefi_get_rsdp, - .init_irq = uefi_init_irq, - .init_vm_boot_info = uefi_init_vm_boot_info, - }; - - static struct firmware_operations firmware_sbl_ops = { - .init = sbl_init, - .get_ap_trampoline = sbl_get_ap_trampoline, - .get_rsdp = sbl_get_rsdp, - .init_irq = sbl_init_irq, - .init_vm_boot_info = sbl_init_vm_boot_info, - }; - - -'firmware_ops' is the operations set that is dereferenced and takes effect. - -'init_firmware_operations' is called when the hypervisor is in DETECT mode and -'firmware_ops' is instantiated here to either 'firmware_uefi_ops' or -'firmware_sbl_ops' depending on the platform. - -.. note:: All the other exported interfaces using 'firmware_ops' shall be called - after the instantiation. - - -.. code-block:: c - - static struct firmware_operations *firmware_ops; - - struct firmware_operations* uefi_get_firmware_operations(void) - { - return &firmware_uefi_ops; - } - - struct firmware_operations* sbl_get_firmware_operations(void) - { - return &firmware_sbl_ops; - } - - void init_firmware_operations(void) - { - if (is_firmware_sbl()) { - firmware_ops = sbl_get_firmware_operations(); - } else { - firmware_ops = uefi_get_firmware_operations(); - } - } - - -For example, when the hypervisor needs to initialize the VM boot information, -it calls 'firmware_init_vm_boot_info' and 'firmware_ops->init_vm_boot_info' is -dereferenced here with correct API being called. - -.. code-block:: c - - /** - * @pre firmware_ops->init_vm_boot_info != NULL - */ - int32_t firmware_init_vm_boot_info(struct acrn_vm *vm) - { - return firmware_ops->init_vm_boot_info(vm); - } - - References **********