/*------------------------------------------------------------------------------------------------*/
/* UNICENS V2.1.0-3491 */
/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
/* */
/* This program is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see . */
/* */
/* You may also obtain this software under a propriety license from Microchip. */
/* Please contact Microchip for further information. */
/*------------------------------------------------------------------------------------------------*/
/*!
* \file
* \brief Implementation of the Programming Service.
*
* \cond UCS_INTERNAL_DOC
* \addtogroup G_PROG_MODE
* @{
*/
/*------------------------------------------------------------------------------------------------*/
/* Includes */
/*------------------------------------------------------------------------------------------------*/
#include "ucs_inic_pb.h"
#include "ucs_prog.h"
#include "ucs_misc.h"
/*------------------------------------------------------------------------------------------------*/
/* Internal constants */
/*------------------------------------------------------------------------------------------------*/
#define PRG_NUM_STATES 6U /*!< \brief Number of state machine states */
#define PRG_NUM_EVENTS 13U /*!< \brief Number of state machine events */
#define PRG_TIMEOUT_COMMAND 100U /*!< \brief supervise EXC commands */
#define PRG_SIGNATURE_VERSION 1U /*!< \brief signature version used for Node Discovery */
#define PRG_ADMIN_BASE_ADDR 0x0F00U /*!< \brief bas admin address */
/* Error values */
#define PRG_HW_RESET_REQ 0x200110U /* HW reset required */
#define PRG_SESSION_ACTIVE 0x200111U /* Session already active */
#define PRG_CFG_STRING_ERROR 0x200220U /* A configuration string erase error has occurred. */
#define PRG_MEM_ERASE_ERROR 0x200221U /* An error memory erase error has occurred.*/
#define PRG_CFG_WRITE_ERROR 0x200225U /* Configuration memory write error. */
#define PRG_CFG_FULL_ERROR 0x200226U /* Configuration memory is full. */
#define PRG_HDL_MATCH_ERROR 0x200330U /* The SessionHandle does not match the current memory session. */
#define PRG_MEMID_ERROR 0x200331U /* The memory session does not support the requested MemID. */
#define PRG_ADDR_EVEN_ERROR 0x200332U /* The Address is not even when writing the configuration memory. */
#define PRG_LEN_EVEN_ERROR 0x200333U /* The UnitLen is not even when writing the configuration memory. */
/*------------------------------------------------------------------------------------------------*/
/* Service parameters */
/*------------------------------------------------------------------------------------------------*/
/*! Priority of the Programming service used by scheduler */
static const uint8_t PRG_SRV_PRIO = 248U; /* parasoft-suppress MISRA2004-8_7 "Value shall be part of the module, not part of a function." */
/*! Main event for the Programming service */
static const Srv_Event_t PRG_EVENT_SERVICE = 1U;
/*------------------------------------------------------------------------------------------------*/
/* Internal enumerators */
/*------------------------------------------------------------------------------------------------*/
/*! \brief Possible events of the system diagnosis state machine */
typedef enum Prg_Events_
{
PRG_E_NIL = 0U, /*!< \brief NIL Event */
PRG_E_START = 1U, /*!< \brief API start command was called. */
PRG_E_STOP = 2U, /*!< \brief Stop request occurred. */
PRG_E_WELCOME_SUCCESS = 3U, /*!< \brief Welcome command was successful. */
PRG_E_WELCOME_NOSUCCESS = 4U, /*!< \brief Welcome command was not successful. */
PRG_E_MEM_WRITE_CMD = 5U, /*!< \brief MemorySessionOpen command was succcessful */
PRG_E_MEM_WRITE_FINISH = 6U, /*!< \
# short-description: Custom EFI disk image with systemd-boot
# long-description: Creates a partitioned EFI disk image that the user
# can directly dd to boot media. The selected bootloader is systemd-boot
# and we do not have swap. We assume a Joule system and provide an
# appropriate kernel command line.
part /boot --source bootimg-efi --sourceparams="loader=systemd-boot,initrd=microcode.cpio" --ondisk sda --label msdos --active --align 1024
part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
# Modify the append line here as needed to suit the environment
bootloader --ptable gpt --timeout=5 --append="rootwait rootfstype=ext4 console=ttyS2,115200n8 console=tty0 video=efifb maxcpus=4 noxsave reboot=efi kmemleak=off"