13
© 2020 Arm Limited (or its affiliates) Edison Ai 2020.5.28 Trusted Firmware-M Hardware Abstraction Layer

TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

© 2020 Arm Limited (or its affiliates)

Edison Ai2020.5.28

Trusted Firmware-M

HardwareAbstraction

Layer

Page 2: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

2 © 2020 Arm Limited (or its affiliates)

Agenda

• Introduction

• Overview Structure

• API Categories• Platform Initialization• Secure Partition Loader• Isolation Interface• Interrupt

• Appendix

Page 3: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

3 © 2020 Arm Limited (or its affiliates)

Introduction

• Higher-level interface, not a device driver API.

• Abstract the hardware• Abstract hardware-oriented operations to support the hardware difference.• Make TF-M easy to use the hardware and make it easy to develop the Core and RoT Services that need

to access the devices.

• Portability• Help user more quick and simple porting to different platform.

• Easy to maintain.

Page 4: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

4 © 2020 Arm Limited (or its affiliates)

Secure Partition

Core / SPM

HAL Arch

Platform Source

Hardware

Arm M Core

UARTPPC

MPC Flash

Fuses RNG

HW CryptoTimer

Library / OS

Kernel

APP

Isolation

Platform

Log dev

Loader

Interrupt Debug

SP Peripherals

SAU

MPU

IDAU

... …

Overview Structure

Page 5: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

5 © 2020 Arm Limited (or its affiliates)

API CategoriesPlatform API tfm_hal_init_platform()

tfm_hal_reset_platform()tfm_hal_get_platform_profile()tfm_hal_version()

Provides the platform initialization, platform-specific profile getting, system reset, etc.

Isolation API tfm_hal_create_isolation_region()tfm_hal_destroy_isolation_region()tfm_hal_switch_isolation_regions()tfm_hal_access_to_region()

Provides the necessary isolation functionalities required by the PSA FF and TBSA-M. And provides functions to SPM to check the validate of memory access.

Loader API tfm_hal_load_partition()tfm_hal_load_service()

Provides the function to load partition and service and provides the necessary data to SPM.

Log dev API tfm_hal_output_core_log()tfm_hal_output_service_log()

Provides the log system functions.

Interrupt API tfm_hal_config_irq()tfm_hal_enable_irq()tfm_hal_disable_irq()tfm_hal_clear_pending_status()

Provides the interrupt functions.

SP Peripherals Next step and investigating.

Debug Enhance in the future.

Dual core Follow the current design.

Page 6: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

6 © 2020 Arm Limited (or its affiliates)

tfm_hal_init_platform()

Platform Initialization

• tfm_hal_init_platform(uint32_t measurements)

• Measurements:• A hint to platform what should to do.• Platform expects to set the related bit after each

operation.• Check the alignment between SPM and platform.

• Cover most of the init functions

Clock configure

Isolation init

Interrupt init

System reset config

Core&Partition log init

NS code configure

Debug init

… …

TF-M

measurements

measurements

Page 7: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

7 © 2020 Arm Limited (or its affiliates)

Secure Partition Loader

• Why needs it?• The platform decide where to put all the partition regions.• The platform allocate memory in the link stage for SP.• SPM is a logic implantation of PSA FF, only focuses on the partition management.

• Platform needs to provide all the necessary memory to SPM.

• tfm_hal_load_partition()

Partition static data

Platform data (Peripherals)

Interrupt data

Runtime data(for SPM) TFM_HAL_PARTITION_RUNTIME_SIZE

Generated by Tools

• tfm_hal_load_service()

Service static data

TFM_HAL_SERVICE_RUNTIME_SIZERuntime data(for SPM)

Page 8: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

8 © 2020 Arm Limited (or its affiliates)

Platform

PlatformSPM

SP1

What change to TF-M by loader API?

SP1 platform data

SP1

SP2

SP1

SP2SP1 runtime data

SP1 static data

SP1 memory data

SP1

SP2

SP1 platform data

Platform data

Interrupt data

Static data

SP1 interrupt data

SP1 static data

SP1 runtime data

SP3

SP3

SP3

Platform data array

Static data array

memory data array

Page 9: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

9 © 2020 Arm Limited (or its affiliates)

Isolation Interface

Isolation region

SP1

Memory

Peripherals

Interrupts

SPM

Isolation region

SP2

Memory

Peripherals

Interruptstfm_hal_switch_isolation_regions()

tfm_hal_access_to_region() tfm_hal_access_to_region()

tfm_hal_create_isolation_region()

Page 10: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

10 © 2020 Arm Limited (or its affiliates)

Log Interface

• Support flexible logging devices

Core log Service Log

Serial PortMemory Serial Port

SPM

Secure Partition

Page 11: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

11 © 2020 Arm Limited (or its affiliates)

Interrupt Interface

• tfm_hal_status_t tfm_hal_config_irq(struct tfm_hal_interrupt_t *intr)

struct tfm_hal_interrupt_t {

size_t count;

struct tfm_hal_irq_data_t irqs[];

};

struct tfm_hal_irq_data_t {

int32_t line;

psa_signal_t signal;

uint32_t priority;

bool secure_state;

struct tfm_hal_partition_t *sp;

tfm_hal_interrupt_isr_t isr;

};

Page 12: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

12 © 2020 Arm Limited (or its affiliates)

Appendix

• Patch link: https://review.trustedfirmware.org/c/trusted-firmware-m/+/4076

Page 13: TF-M Hardware Abstraction Layer Introduction · Loader API tfm_hal_load_partition() tfm_hal_load_service() Provides the function to load partition and service and provides the necessary

© 2020 Arm Limited (or its affiliates)

Thank YouDankeMerci谢谢

ありがとうGracias

Kiitos감사합니다

धन्यवाद

شكًراধন্যবাদתודה