Callisto4Bootloader: ARK/platform_startup.c File Reference

Callisto4Bootloader

Data Structures | Macros | Functions | Variables
platform_startup.c File Reference
`#include <string.h>`
`#include <stdio.h>`
`#include "platform-api.h"`
`#include "platform-memory-map.h"`

Go to the source code of this file.

## Data Structures

struct | stPluginLocs_t

## Macros

#define | DO_CALL(FNPTR) (pstMainPlatform->FNPTR)
#define | assert(CONDITION) PLATFORM_ASSERT(CONDITION)
#define | PLUGINCALL_ISVALID(PLUGININDEX, FNPTR)
#define | DO_CALLPLUGIN(PLUGININDEX, FNPTR) (*apstPluginHeader[PLUGININDEX]->stPluginCallBlock.pstPluginCalls->FNPTR)

## Functions

static ePLUGIN_Status_t | sLaunchPlugin (uint32_t uiPluginSlotIndex, uint32_t uiDeviceIndex)
| Launch a given plugin. More...
static uint32_t | checksum_calculate (const void *pvBase, uint32_t uiLength)
| Calculate a 32-bit additive checksum. More...
static bool | CheckThatPluginIsValid (uint32_t uiPluginSlotIndex, stPluginHeader_t **ppstPluginHeader)
| Check that the plugin loaded in a given plugin slot is valid. More...
static bool | sTestCallback (uint32_t uiTargetPluginIndex, const stPlatformCallBlock_t *pstMockAPI, stPluginCallBlock_t **ppstTargetPluginCallBlock)
ePLATFORM_HasMask_t | PLATFORM_STARTUP_PluginsRelocate (uint16_t u16DeviceNumber)
| Relocate the plugins (but don't actually start executing them) More...
bool | PLATFORM_STARTUP_PluginsLateLink (const stPlatformCalls_t *pstPlatformCalls, uint16_t u16DeviceNumber)
| Late-link the plugins. More...
uint32_t | PLATFORM_STARTUP_PluginsLaunch (uint16_t u16DeviceNumber)
| Launch all valid plugins. More...

## Variables

const stPluginLocs_t | astPluginLocs [PLUGINS_MAX]
const stPlatformCalls_t * | pstMainPlatform = NULL
static stPluginHeader_t * | apstPluginHeader [PLUGINS_MAX]
static const stPlatformCallBlock_t * | apstMockHeader [PLUGINS_MAX]
static stPluginCallBlock_t ** | appstTestPluginTargetPluginCallBlock [PLUGINS_MAX]

## Macro Definition Documentation

## ◆ assert

#define assert | ( |  | CONDITION | ) | PLATFORM_ASSERT(CONDITION)

Definition at line 68 of file platform_startup.c.

## ◆ DO_CALL

#define DO_CALL | ( |  | FNPTR | ) | (pstMainPlatform->FNPTR)

Definition at line 65 of file platform_startup.c.

## ◆ DO_CALLPLUGIN

#define DO_CALLPLUGIN | ( |  | PLUGININDEX,
|  |  | FNPTR
| ) |  | (*apstPluginHeader[PLUGININDEX]->stPluginCallBlock.pstPluginCalls->FNPTR)

Definition at line 377 of file platform_startup.c.

## ◆ PLUGINCALL_ISVALID

#define PLUGINCALL_ISVALID | ( |  | PLUGININDEX,
|  |  | FNPTR
| ) |  |

Value:
( FIELD_OFFSET(stPluginCalls_t,FNPTR) < \
apstPluginHeader[PLUGININDEX]->stPluginCallBlock.uiPluginCallsSize_Bytes )

Definition at line 373 of file platform_startup.c.

## Function Documentation

## ◆ checksum_calculate()

static uint32_t checksum_calculate | ( | const void * | pvBase,
|  | uint32_t | uiLength
| ) |  |

static

Calculate a 32-bit additive checksum.

Parameters

  [in] | pvBase | Base of the area of memory
  [in] | uiLength | Length of the area of memory

Returns
  32-bit additive checksum of the area

Calculate the 32-bit additive checksum of an area of memory

Definition at line 96 of file platform_startup.c.

References i.

Referenced by CheckThatPluginIsValid().

## ◆ CheckThatPluginIsValid()

static bool CheckThatPluginIsValid | ( | uint32_t | uiPluginSlotIndex,
|  | stPluginHeader_t ** | ppstPluginHeader
| ) |  |

static

Check that the plugin loaded in a given plugin slot is valid.

Parameters

  [in] | uiPluginSlotIndex | Index of the plugin slot to check
  [out] | ppstPluginHeader | Place to put plugin header pointer if plugin is valid

Return values

  false | Plugin was not valid
  true | Plugin was valid

Check that the plugin programmed into a given plugin slot is valid

Definition at line 120 of file platform_startup.c.

References assert, astPluginLocs, checksum_calculate(), NULL, and stPluginLocs_t::pvRamLoc.

Referenced by PLATFORM_STARTUP_PluginsRelocate().

## ◆ PLATFORM_STARTUP_PluginsLateLink()

bool PLATFORM_STARTUP_PluginsLateLink | ( | const stPlatformCalls_t * | pstPlatformCalls,
|  | uint16_t | u16DeviceNumber
| ) |  |

Late-link the plugins.

Parameters

  [in] | pstPlatformCalls | Platform vector table to start plugins with
  [in] | u16DeviceNumber | Device number to pass down to plugins

Returns
  false if problem encountered, else true

Late-link all valid plugins to the platform (or to a mock platform)

Definition at line 280 of file platform_startup.c.

References appstTestPluginTargetPluginCallBlock, apstMockHeader, apstPluginHeader, i, NULL, and pstMainPlatform.

## ◆ PLATFORM_STARTUP_PluginsLaunch()

uint32_t PLATFORM_STARTUP_PluginsLaunch | ( | uint16_t | u16DeviceNumber | ) |

Launch all valid plugins.

Parameters

  [in] | u16DeviceNumber | Device number to pass down to plugins

Returns
  false if problem encountered, else true

Launch all valid plugins

Definition at line 335 of file platform_startup.c.

References apstPluginHeader, NULL, and sLaunchPlugin().

## ◆ PLATFORM_STARTUP_PluginsRelocate()

ePLATFORM_HasMask_t PLATFORM_STARTUP_PluginsRelocate | ( | uint16_t | u16DeviceNumber | ) |

Relocate the plugins (but don't actually start executing them)

Parameters

  [in] | u16DeviceNumber | Device number to pass down to plugins

Returns
  Merged bitmask of all the extra hardware that needs initialising

Relocate the plugins and determine what hardware they need initialising Note: we don't actually launch the plugins until a later step!

Definition at line 239 of file platform_startup.c.

References apstMockHeader, apstPluginHeader, CheckThatPluginIsValid(), NULL, and sTestCallback().

## ◆ sLaunchPlugin()

static ePLUGIN_Status_t sLaunchPlugin | ( | uint32_t | uiPluginSlotIndex,
|  | uint32_t | uiDeviceIndex
| ) |  |

static

Launch a given plugin.

Parameters

  [in] | uiPluginSlotIndex | Index of plugin slot
  [in] | uiDeviceIndex | Device module code (e.g. 12369)

Returns
  Status of plugin launch

Launch a given plugin

Definition at line 388 of file platform_startup.c.

References apstPluginHeader, DO_CALLPLUGIN, and PLUGINCALL_ISVALID.

Referenced by PLATFORM_STARTUP_PluginsLaunch().

## ◆ sTestCallback()

static bool sTestCallback | ( | uint32_t | uiTargetPluginIndex,
|  | const stPlatformCallBlock_t * | pstMockAPI,
|  | stPluginCallBlock_t ** | ppstTargetPluginCallBlock
| ) |  |

static

Callback called by test plugins when they want to mock a target plugin's platform API

Parameters

  [in] | uiTargetPluginIndex | - index of the target plugin
  [in] | pstMockAPI | - mock API that the test plugin wants the target plugin to use
  [in] | ppstTargetPluginCallBlock | - where to (eventually) write the target plugin's call block

Return values

  false | Problem encountered with request
  true | Request registered (but not necessarily acted upon, that happens later)

Definition at line 194 of file platform_startup.c.

References appstTestPluginTargetPluginCallBlock, apstMockHeader, apstPluginHeader, and NULL.

Referenced by PLATFORM_STARTUP_PluginsRelocate().

## Variable Documentation

## ◆ appstTestPluginTargetPluginCallBlock

stPluginCallBlock_t* * appstTestPluginTargetPluginCallBlock[PLUGINS_MAX]

static

Definition at line 77 of file platform_startup.c.

Referenced by PLATFORM_STARTUP_PluginsLateLink(), and sTestCallback().

## ◆ apstMockHeader

const stPlatformCallBlock_t* apstMockHeader[PLUGINS_MAX]

static

Definition at line 74 of file platform_startup.c.

Referenced by PLATFORM_STARTUP_PluginsLateLink(), PLATFORM_STARTUP_PluginsRelocate(), and sTestCallback().

## ◆ apstPluginHeader

stPluginHeader_t* apstPluginHeader[PLUGINS_MAX]

static

Definition at line 71 of file platform_startup.c.

Referenced by PLATFORM_STARTUP_PluginsLateLink(), PLATFORM_STARTUP_PluginsLaunch(), PLATFORM_STARTUP_PluginsRelocate(), sLaunchPlugin(), and sTestCallback().

## ◆ astPluginLocs

const stPluginLocs_t astPluginLocs[PLUGINS_MAX]

Initial value:
=
{
{
(void *)QSPI_PLUGIN1x_BINARY, QSPI_PLUGIN_BINARY_SIZE,
(void *)QSPI_PLUGIN1x_CONFIG, QSPI_PLUGIN_CONFIG_SIZE,
(void *)RAM_PLUGIN1, RAM_PLUGIN_SIZE
},
{
(void *)QSPI_PLUGIN2x_BINARY, QSPI_PLUGIN_BINARY_SIZE,
(void *)QSPI_PLUGIN2x_CONFIG, QSPI_PLUGIN_CONFIG_SIZE,
(void *)RAM_PLUGIN2, RAM_PLUGIN_SIZE
},
{
(void *)QSPI_PLUGIN3x_BINARY, QSPI_PLUGIN_BINARY_SIZE,
(void *)QSPI_PLUGIN3x_CONFIG, QSPI_PLUGIN_CONFIG_SIZE,
(void *)RAM_PLUGIN3, RAM_PLUGIN_SIZE
},
{
(void *)QSPI_PLUGIN4x_BINARY, QSPI_PLUGIN_BINARY_SIZE,
(void *)QSPI_PLUGIN4x_CONFIG, QSPI_PLUGIN_CONFIG_SIZE,
(void *)RAM_PLUGIN4, RAM_PLUGIN_SIZE
},
{
(void *)QSPI_PLUGIN5x_BINARY, QSPI_PLUGIN_BINARY_SIZE,
(void *)QSPI_PLUGIN5x_CONFIG, QSPI_PLUGIN_CONFIG_SIZE,
(void *)RAM_PLUGIN5, RAM_PLUGIN_SIZE
}
}

Definition at line 29 of file platform_startup.c.

Referenced by CheckThatPluginIsValid().

## ◆ pstMainPlatform

const stPlatformCalls_t* pstMainPlatform = NULL

Definition at line 62 of file platform_startup.c.

Referenced by PLATFORM_STARTUP_PluginsLateLink().