Callisto4Bootloader: drivers/bootloader_common.h File Reference

Callisto4Bootloader

Data Structures | Macros | Typedefs | Enumerations | Functions
bootloader_common.h File Reference
`#include <stdio.h>`
`#include <stdarg.h>`
`#include <stdint.h>`
`#include <stdbool.h>`
`#include "fsl_common.h"`
`#include "bootloader_config.h"`
`#include "target_config.h"`

Go to the source code of this file.

## Data Structures

union | StandardVersion
| Structure of version property. More...

## Macros

#define | NULL 0
#define | USE_ONLY_UART(instance) (defined(BL_FEATURE_UART_OPTIMIZE) && (BL_UART_USED_INSTANCE == instance))
#define | USE_ONLY_SPI(instance) (defined(BL_FEATURE_SPI_OPTIMIZE) && (BL_SPI_USED_INSTANCE == instance))
#define | USE_ONLY_I2C(instance) (defined(BL_FEATURE_I2C_OPTIMIZE) && (BL_I2C_USED_INSTANCE == instance))
#define | ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
| Computes the number of elements in an array. More...
#define | FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))
| Build a 32-bit code from four character values. More...
#define | debug_printf(x, ...)
Min/max macros
#define | MIN(a, b) ((a) < (b) ? (a) : (b))
#define | MAX(a, b) ((a) > (b) ? (a) : (b))
Byte swap macros
#define | BSWAP_16(x) (uint16_t)((((x)&0xFF00) >> 0x8) | (((x)&0xFF) << 0x8))
#define | BSWAP_32(val) (uint32_t)((BSWAP_16((uint32_t)(val) & (uint32_t)0xFFFF) << 0x10) | (BSWAP_16((uint32_t)((val) >> 0x10))))
Alignment macros
#define | ALIGN_DOWN(x, a) ((x) & -(a))
#define | ALIGN_UP(x, a) (-(-(x) & -(a)))

## Typedefs

typedef void(* | pin_irq_callback_t) (uint32_t instance)
| Callback function invoked for a pin change interrupt. More...
typedef union StandardVersion | standard_version_t
| Structure of version property. More...
typedef enum _bootloader_clock_option | bootloader_clock_option_t
| Bootloader clock option. More...
typedef enum _bootdevice_option | bootdevice_option_t
| Boot device Option. More...
typedef enum _bootmode_option | boot_mode_option_t
| Boot Mode Option. More...
typedef enum _habstatus_option | habstatus_option_t
| Hab status option. More...

## Enumerations

enum

_bl_status_groups {
kStatusGroup_Bootloader = 100, kStatusGroup_SBLoader = 101, kStatusGroup_MemoryInterface = 102, kStatusGroup_PropertyStore = 103,
kStatusGroup_AppCrcCheck = 104, kStatusGroup_Packetizer = 105, kStatusGroup_ReliableUpdate = 106, kStatusGroup_SerialNorEeprom = 107,
kStatusGroup_FlexSPINAND = 200, kStatusGroup_FLEXSPINOR = 201, kStatusGroup_OCOTP = 202, kStatusGroup_SemcNOR = 211,
kStatusGroup_SemcNAND = 212
}

| Bootloader status group numbers. More...
enum | _bl_driver_status_groups { kStatusGroup_QuadSPIDriver = 4, kStatusGroup_OTFADDriver = 5 }
| Driver status group numbers. More...
enum | _bootloader_clock_option { kClockOption_EnterBootloader = 0, kClockOption_ExitBootloader = 1 }
| Bootloader clock option. More...
enum | _bootdevice_option { kBootDevice_FlexSpiNOR = 0x01, kBootDevice_FlexSpiNAND = 0x02, kBootDevice_SPIEEPROM = 0x04, kBootDevice_MMC_SD = 0x08, kBootDevice_SemcNOR = 0x10, kBootDevice_SemcNAND = 0x20 }
| Boot device Option. More...
enum | _bootmode_option { kBootMode_BootFromFuse, kBootMode_SerialDownloader, kBootMode_InternalBoot }
| Boot Mode Option. More...
enum | _habstatus_option { kHabStatus_Open, kHabStatus_Close }
| Hab status option. More...

## Functions

void | init_hardware (void)
| Initialize the hardware such as pinmux. More...
void | deinit_hardware (void)
| DeInitialize the hardware such as disabling port clock gate. More...
void | update_available_peripherals (void)
| Update available peripherals based on specific chips. More...
void | check_available_dFlash (void)
| Update DFlash based on specific chips. More...
void | configure_clocks (bootloader_clock_option_t option)
| Returns the logic level of the board specific GPIO pin used for autobaud. More...
uint32_t | get_available_lirc_clock (void)
| Returns the available lirc clock frequency in Hertz. More...
uint32_t | get_bus_clock (void)
| Returns the current bus clock frequency in Hertz. More...
uint32_t | get_flexcomm_clock (uint32_t instance)
| Returns the current flexcomm clock frequency in Hertz. More...
uint32_t | get_system_core_clock (void)
| Returns the current core clock frequency in Hertz. More...
bool | usb_clock_init (void)
| Configure usb clock. More...
uint32_t | get_uart_clock (uint32_t instance)
| Returns the value in MHz of the UART clock based on the instance. More...
bool | is_boot_pin_asserted (void)
| Returns true if reset BOOTROM mode is selected. More...
void | enable_autobaud_pin_irq (uint32_t instance, pin_irq_callback_t func)
| Enables the autobaud pin IRQ for the specific instance passed. More...
void | disable_autobaud_pin_irq (uint32_t instance)
| Disables the autobaud pin IRQ for the instance passed. More...
void | Reset_Handler (void)
| Declaration for the reset handler, which is defined in assembler. More...
void | bootloader_watchdog_init (void)
| Initialize watchdog. More...
void | bootloader_watchdog_service (void)
| Service watchdog. More...
void | bootloader_watchdog_deinit (void)
| De-initialize watchdog. More...
bool | qspi_need_configure (void)
| Determine if QSPI module to be configured. More...
status_t | otfad_init_as_needed (void)
| Initialize QSPI and OTFAD module. More...
status_t | otfad_bypass_as_needed (void)
| Bypass OTFAD module as needed. More...
status_t | oftfad_resume_as_needed (void)
| Resume OTFAD module as needed. More...
bool | is_qspi_present (void)
| Determine if QSPI memory is present or not. More...
bool | is_otfad_present (void)
| Determine if OTFAD module is present or not. More...
bool | is_ltc_present (void)
| Determine if LTC module is present or not. More...
status_t | get_qspi_otfad_init_status (void)
| Return status for intializing qspi and otfad modules. More...
void | update_qspi_otfad_init_status (status_t initStatus)
| Update status for intializing qspi and otfad modules. More...
bool | is_flexspi_nor_present (void)
| Determine if FlexSPI NOR module is present or not. More...
bool | is_semc_nor_present (void)
| Determine if SEMC NOR module is present or not. More...
bool | is_secondary_i2c_slave_address_enabled (void)
| Determine is the Secondary I2C slave address is enabled. More...
bool | is_in_execute_only_region (uint32_t start, uint32_t lengthInBytes)
| Check if data to be accessed is in execute-only region. More...
bool | is_second_core_present (void)
| Check if second core is present. More...
void | update_memory_map_lpc_sram (void)
| Update LPC SRAM memory map based on Device ID0. More...
uint32_t | get_primary_boot_device (void)
| Return Primary boot device type. More...
habstatus_option_t | get_hab_status ()
| Get the hab status. More...

## Detailed Description

Copyright (c) 2013-2015 Freescale Semiconductor, Inc. Copyright 2016-2018 NXP All rights reserved.

SPDX-License-Identifier: BSD-3-Clause

Definition in file bootloader_common.h.

## Macro Definition Documentation

## ◆ ALIGN_DOWN

#define ALIGN_DOWN | ( |  | x,
|  |  | a
| ) |  | ((x) & -(a))

Definition at line 61 of file bootloader_common.h.

## ◆ ALIGN_UP

#define ALIGN_UP | ( |  | x,
|  |  | a
| ) |  | (-(-(x) & -(a)))

Definition at line 64 of file bootloader_common.h.

## ◆ ARRAY_SIZE

#define ARRAY_SIZE | ( |  | x | ) | (sizeof(x) / sizeof((x)[0]))

Computes the number of elements in an array.

Definition at line 49 of file bootloader_common.h.

## ◆ BSWAP_16

#define BSWAP_16 | ( |  | x | ) | (uint16_t)((((x)&0xFF00) >> 0x8) | (((x)&0xFF) << 0x8))

Definition at line 53 of file bootloader_common.h.

## ◆ BSWAP_32

#define BSWAP_32 | ( |  | val | ) | (uint32_t)((BSWAP_16((uint32_t)(val) & (uint32_t)0xFFFF) << 0x10) | (BSWAP_16((uint32_t)((val) >> 0x10))))

Definition at line 54 of file bootloader_common.h.

## ◆ debug_printf

#define debug_printf | ( |  | x,
|  |  | ...
| ) |  |

Value:
do \
{ \
} while (false)

Definition at line 97 of file bootloader_common.h.

## ◆ FOUR_CHAR_CODE

#define FOUR_CHAR_CODE | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d
| ) |  | (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))

Build a 32-bit code from four character values.

The resulting value is built with a byte order such that the string being readable in expected order when viewed in a hex editor, if the value is treated as a 32-bit little endian value.

Definition at line 73 of file bootloader_common.h.

## ◆ MAX

#define MAX | ( |  | a,
|  |  | b
| ) |  | ((a) > (b) ? (a) : (b))

Definition at line 44 of file bootloader_common.h.

## ◆ MIN

#define MIN | ( |  | a,
|  |  | b
| ) |  | ((a) < (b) ? (a) : (b))

Definition at line 40 of file bootloader_common.h.

## ◆ NULL

#define NULL 0

Definition at line 26 of file bootloader_common.h.

## ◆ USE_ONLY_I2C

#define USE_ONLY_I2C | ( |  | instance | ) | (defined(BL_FEATURE_I2C_OPTIMIZE) && (BL_I2C_USED_INSTANCE == instance))

Definition at line 35 of file bootloader_common.h.

## ◆ USE_ONLY_SPI

#define USE_ONLY_SPI | ( |  | instance | ) | (defined(BL_FEATURE_SPI_OPTIMIZE) && (BL_SPI_USED_INSTANCE == instance))

Definition at line 34 of file bootloader_common.h.

## ◆ USE_ONLY_UART

#define USE_ONLY_UART | ( |  | instance | ) | (defined(BL_FEATURE_UART_OPTIMIZE) && (BL_UART_USED_INSTANCE == instance))

Definition at line 33 of file bootloader_common.h.

## Typedef Documentation

## ◆ boot_mode_option_t

typedef enum _bootmode_option boot_mode_option_t

Boot Mode Option.

## ◆ bootdevice_option_t

typedef enum _bootdevice_option bootdevice_option_t

Boot device Option.

## ◆ bootloader_clock_option_t

typedef enum _bootloader_clock_option bootloader_clock_option_t

Bootloader clock option.

## ◆ habstatus_option_t

typedef enum _habstatus_option habstatus_option_t

Hab status option.

## ◆ standard_version_t

typedef union StandardVersion standard_version_t

Structure of version property.

## Enumeration Type Documentation

## ◆ _bl_driver_status_groups

enum _bl_driver_status_groups

Driver status group numbers.

Enumerator
kStatusGroup_QuadSPIDriver | QSPI driver status group number.
kStatusGroup_OTFADDriver | OTFAD driver status group number.

Definition at line 132 of file bootloader_common.h.

## ◆ _bl_status_groups

enum _bl_status_groups

Bootloader status group numbers.

Enumerator
kStatusGroup_Bootloader | Bootloader status group number (100).
kStatusGroup_SBLoader | SB loader status group number (101).
kStatusGroup_MemoryInterface | Memory interface status group number (102).
kStatusGroup_PropertyStore | Property store status group number (103).
kStatusGroup_AppCrcCheck | Application crc check status group number (104).
kStatusGroup_Packetizer | Packetizer status group number (105).
kStatusGroup_ReliableUpdate | Reliable Update status groupt number (106).
kStatusGroup_SerialNorEeprom | Serial NOR/EEPROM status group number.
kStatusGroup_FlexSPINAND | FlexSPINAND status group number.
kStatusGroup_FLEXSPINOR | FlexSPINOR status group number.
kStatusGroup_OCOTP | OCOTP status group number.
kStatusGroup_SemcNOR | SEMC NOR status group number.
kStatusGroup_SemcNAND | SEMC NAND status group number.

Definition at line 111 of file bootloader_common.h.

## ◆ _bootdevice_option

enum _bootdevice_option

Boot device Option.

Enumerator
kBootDevice_FlexSpiNOR |
kBootDevice_FlexSpiNAND |
kBootDevice_SPIEEPROM |
kBootDevice_MMC_SD |
kBootDevice_SemcNOR |
kBootDevice_SemcNAND |

Definition at line 178 of file bootloader_common.h.

## ◆ _bootloader_clock_option

enum _bootloader_clock_option

Bootloader clock option.

Enumerator
kClockOption_EnterBootloader | Clock option for entering bootloader.
kClockOption_ExitBootloader | Clock option for exiting bootloader.

Definition at line 171 of file bootloader_common.h.

## ◆ _bootmode_option

enum _bootmode_option

Boot Mode Option.

Enumerator
kBootMode_BootFromFuse |
kBootMode_SerialDownloader |
kBootMode_InternalBoot |

Definition at line 189 of file bootloader_common.h.

## ◆ _habstatus_option

enum _habstatus_option

Hab status option.

Enumerator
kHabStatus_Open |
kHabStatus_Close |

Definition at line 197 of file bootloader_common.h.