Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrique Silva committed Apr 24, 2019
2 parents 118a349 + 69dbf19 commit 73c73e5
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 93 deletions.
18 changes: 9 additions & 9 deletions modules/fru.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, 0x00, &common_header[0], 8, 0 );
}

printf("[FRU] Asserting FRU information integrity\n");
printf("[FRU][%s] Asserting FRU information integrity\n", id == FRU_AMC ? "AMC" : "RTM");
total_len += 8;
if ( !((calculate_chksum( &common_header[0], 8 ) == 0) && common_header[0] == 1) ) {
/* Wrong checksum */
printf("[FRU] Error in COMMON HEADER checksum\n");
printf("[FRU][%s] Error in COMMON HEADER checksum\n", id == FRU_AMC ? "AMC" : "RTM");
return 0;
}

Expand All @@ -108,7 +108,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
multirec_off = 8*common_header[5];

if (chassis_off > 0) {
printf("[FRU] Checking CHASSIS AREA record...");
printf("[FRU][%s] Checking CHASSIS AREA record...", id == FRU_AMC ? "AMC" : "RTM");
if (fru[id].runtime) {
rec_len = fru[id].buffer[chassis_off+1];
} else {
Expand All @@ -133,7 +133,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
}

if (board_off > 0) {
printf("[FRU] Checking BOARD AREA record...");
printf("[FRU][%s] Checking BOARD AREA record...", id == FRU_AMC ? "AMC" : "RTM");
if (fru[id].runtime) {
rec_len = fru[id].buffer[board_off+1];
} else {
Expand All @@ -159,7 +159,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
}

if (product_off > 0) {
printf("[FRU] Checking PRODUCT AREA record...");
printf("[FRU][%s] Checking PRODUCT AREA record...", id == FRU_AMC ? "AMC" : "RTM");
if (fru[id].runtime) {
rec_len = fru[id].buffer[product_off+1];
} else {
Expand Down Expand Up @@ -188,7 +188,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
uint8_t eol = 0;
uint8_t rec_chksum;
rec_len = 0;
printf("[FRU] Checking MULTIRECORD AREA records...\n");
printf("[FRU][%s] Checking MULTIRECORD AREA records...\n", id == FRU_AMC ? "AMC" : "RTM");
do {
if (fru[id].runtime) {
memcpy( &rec_buff[0], &fru[id].buffer[multirec_off], 5);
Expand All @@ -198,7 +198,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
/* Calculate Multirecord header checksum */
if ( !(calculate_chksum( &rec_buff[0], 5 ) == 0) ) {
/* Wrong checksum */
printf("[FRU] Error in MULTIRECORD AREA HEADER integrity check!\n");
printf("[FRU][%s] Error in MULTIRECORD AREA HEADER integrity check!\n", id == FRU_AMC ? "AMC" : "RTM");
return 0;
}
multirec_off += 5;
Expand All @@ -215,7 +215,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
}
if ( !((calculate_chksum( &rec_buff[0], rec_len ) == rec_chksum)) ) {
/* Wrong checksum */
printf("[FRU] Error in MULTIRECORD AREA integrity check!\n");
printf("[FRU][%s] Error in MULTIRECORD AREA integrity check!\n", id == FRU_AMC ? "AMC" : "RTM");
return 0;
} else {
total_len += rec_len;
Expand All @@ -229,7 +229,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
*fru_size = total_len;
}

printf("[FRU] FRU info is healthy!\n");
printf("[FRU][%s] FRU info is healthy!\n", id == FRU_AMC ? "AMC" : "RTM");

vPortFree(rec_buff);
return 1;
Expand Down
8 changes: 4 additions & 4 deletions modules/ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,16 @@ IPMI_HANDLER(ipmi_picmg_cmd_fru_control, NETFN_GRPEXT, IPMI_PICMG_CMD_FRU_CONTRO

switch (fru_ctl) {
case FRU_CTLCODE_COLD_RST:
payload_send_message( fru_id, PAYLOAD_MESSAGE_COLD_RST);
payload_send_message(fru_id, PAYLOAD_MESSAGE_COLD_RST);
break;
case FRU_CTLCODE_WARM_RST:
payload_send_message( fru_id, PAYLOAD_MESSAGE_WARM_RST);
payload_send_message(fru_id, PAYLOAD_MESSAGE_WARM_RST);
break;
case FRU_CTLCODE_REBOOT:
payload_send_message( fru_id, PAYLOAD_MESSAGE_REBOOT);
payload_send_message(fru_id, PAYLOAD_MESSAGE_REBOOT);
break;
case FRU_CTLCODE_QUIESCE:
payload_send_message( fru_id, PAYLOAD_MESSAGE_QUIESCED);
payload_send_message(fru_id, PAYLOAD_MESSAGE_QUIESCE);
break;
default:
rsp->completion_code = IPMI_CC_INV_DATA_FIELD_IN_REQ;
Expand Down
96 changes: 56 additions & 40 deletions modules/rtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,40 @@
#include "hotswap.h"
#include "payload.h"
#include "uart_debug.h"
#include "led.h"

volatile bool rtm_present = false;
volatile uint8_t rtm_power_level = 0;
extern EventGroupHandle_t rtm_payload_evt;

void RTM_Manage( void * Parameters )
{
uint8_t ps_old_state = 0xFF;
uint8_t ps_new_state;
bool rtm_compatible;
bool rtm_compatible = false;
extern sensor_t * hotswap_rtm_sensor;

EventBits_t current_evt;
uint8_t rtm_hs_state;

/* A local copy of rtm_power_level to check if it's changed status */
uint8_t rtm_pwr_lvl_change = rtm_power_level;
/* Defaults to not present */
rtm_present = false;

/* Start with RTM payload disabled */
rtm_disable_payload_power();

#ifdef BENCH_TEST
rtm_power_level = 0x01;
rtm_pwr_lvl_change = 0x00;
#endif

for ( ;; ) {
vTaskDelay(100);
vTaskDelay(500);

rtm_check_presence( &ps_new_state );

if ( ps_new_state ^ ps_old_state ) {
if ( ps_new_state == HOTSWAP_STATE_URTM_PRSENT ) {

printf("RTM Board detected!\n");
printf("[RTM] Rear Board detected!\n");

rtm_present = true;

/* Initialize basic hardware to enable communication */
rtm_hardware_init();

/* Create/Read the RTM FRU info before sending the hotswap event */
fru_init(FRU_RTM);

Expand All @@ -83,14 +80,25 @@ void RTM_Manage( void * Parameters )
/* Check the Zone3 compatibility records */
rtm_compatible = rtm_compatibility_check();
if ( rtm_compatible ) {
printf("RTM Board is compatible! Initializing...\n");
printf("[RTM] Rear Board is compatible! Initializing...\n");
/* Send RTM Compatible message */
hotswap_send_event( hotswap_rtm_sensor, HOTSWAP_STATE_URTM_COMPATIBLE );
hotswap_set_mask_bit( HOTSWAP_RTM, HOTSWAP_URTM_COMPATIBLE_MASK );

rtm_hardware_init();
/* Perform hotswap first read */
while (!rtm_get_hotswap_handle_status( &rtm_hs_state ));

/* Override RTM state so that if the handle is closed when the MMC is starting,
* the LED and payload power remains in the correct state */
if ( rtm_hs_state == 0 ) {
LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_OFF, 0, 0 );
payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE);
} else {
LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_ON, 0, 0 );
payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE);
}
} else {
printf("RTM Board is not compatible.\n");
printf("[RTM] Rear Board is not compatible.\n");
/* Send RTM Incompatible message */
hotswap_send_event( hotswap_rtm_sensor, HOTSWAP_STATE_URTM_INCOMPATIBLE );
hotswap_clear_mask_bit( HOTSWAP_RTM, HOTSWAP_URTM_COMPATIBLE_MASK );
Expand All @@ -102,7 +110,7 @@ void RTM_Manage( void * Parameters )
} else if ( ps_new_state == HOTSWAP_STATE_URTM_ABSENT ) {
//sdr_disable_sensors(); /* Not implemented yet */

printf("RTM Board disconnected!\n");
printf("[RTM] Rear Board disconnected!\n");

rtm_present = false;

Expand All @@ -113,39 +121,36 @@ void RTM_Manage( void * Parameters )
ps_old_state = ps_new_state;
}

if ( rtm_pwr_lvl_change ^ rtm_power_level ) {
rtm_pwr_lvl_change = rtm_power_level;

if ( rtm_power_level == 0x01 ) {
hotswap_clear_mask_bit( HOTSWAP_RTM, HOTSWAP_QUIESCED_MASK );

printf("Enabling RTM Payload power...\n");
rtm_enable_payload_power();
} else {
printf("Disabling RTM Payload power...\n");
rtm_disable_payload_power();
}
}

/* Check enable/disable events */
current_evt = xEventGroupGetBits( rtm_payload_evt );

if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) {
if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) {
if ( rtm_quiesce() ) {
/* Quiesced event */
printf("RTM Quiesced successfuly!\n");
printf("[RTM] Quiesced RTM successfuly!\n");
hotswap_set_mask_bit( HOTSWAP_RTM, HOTSWAP_QUIESCED_MASK );
hotswap_send_event( hotswap_rtm_sensor, HOTSWAP_STATE_QUIESCED );
xEventGroupClearBits( rtm_payload_evt, PAYLOAD_MESSAGE_QUIESCED );
} else {
printf("[RTM] RTM failed to quiesce!\n");
}
xEventGroupClearBits( rtm_payload_evt, PAYLOAD_MESSAGE_QUIESCE );

} else if ( current_evt & PAYLOAD_MESSAGE_RTM_ENABLE ) {
if (rtm_compatible) {
hotswap_clear_mask_bit( HOTSWAP_RTM, HOTSWAP_QUIESCED_MASK );
printf("[RTM] Enabling RTM Payload power...\n");
rtm_enable_payload_power();
} else {
printf("[RTM] Impossible to enable payload power to an incompatible RTM board!\n");
}
xEventGroupClearBits( rtm_payload_evt, PAYLOAD_MESSAGE_RTM_ENABLE );
}
}
}

void rtm_manage_init( void )
{
rtm_power_level = 0;

xTaskCreate( RTM_Manage, "RTM Manage", 100, (void *) NULL, tskRTM_MANAGE_PRIORITY, (TaskHandle_t *) NULL );
xTaskCreate( RTM_Manage, "RTM Manage", 150, (void *) NULL, tskRTM_MANAGE_PRIORITY, (TaskHandle_t *) NULL );
}

/* Set Power Level Request handler */
Expand All @@ -154,9 +159,20 @@ IPMI_HANDLER(ipmi_picmg_set_power_level, NETFN_GRPEXT, IPMI_PICMG_CMD_SET_POWER_
{
int len = rsp->data_len = 0;
uint8_t fru_id = req->data[1];

if ( fru_id == FRU_RTM ) {
rtm_power_level = req->data[2];
uint8_t power_level = req->data[2];

/*
* Power Level:
* 00h = Power off
* 01h - 14h = Select power level, if available
* 0xFF = Do not change power level
*/
if ( fru_id == FRU_RTM && power_level != 0xFF ) {
if (power_level == 0x00) {
payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE);
} else {
payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE);
}
}

rsp->completion_code = IPMI_CC_OK;
Expand Down
2 changes: 2 additions & 0 deletions modules/rtm.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include "rtm_user.h"

volatile bool rtm_present;

/**
* @brief Initialize RTM Manage task
*
Expand Down
24 changes: 11 additions & 13 deletions modules/sensors/hotswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "utils.h"
#include "uart_debug.h"

#ifdef MODULE_RTM
#include "rtm.h"
#endif

TaskHandle_t vTaskHotSwap_Handle;

static bool hotswap_get_handle_status( uint8_t *state )
Expand Down Expand Up @@ -106,7 +110,6 @@ void vTaskHotSwap( void *Parameters )
static uint8_t new_state_amc = 0x01, old_state_amc = 0xFF;
#ifdef MODULE_RTM
static uint8_t new_state_rtm = 0x01, old_state_rtm = 0xFF;
extern bool rtm_present;
#endif

TickType_t xLastWakeTime;
Expand All @@ -122,17 +125,6 @@ void vTaskHotSwap( void *Parameters )
LEDUpdate( FRU_AMC, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_ON, 0, 0 );
}

#ifdef MODULE_RTM
/* Perform hotswap first read */
while (!rtm_get_hotswap_handle_status( &new_state_rtm ));

/* Override RTM Blue LED state so that if the handle is closed when the MMC is starting, the LED remains in the correct state */
if ( new_state_rtm == 0 ) {
LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_OFF, 0, 0 );
} else {
LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_ON, 0, 0 );
}
#endif
/* Initialise the xLastWakeTime variable with the current time. */
xLastWakeTime = xTaskGetTickCount();

Expand Down Expand Up @@ -173,8 +165,14 @@ void vTaskHotSwap( void *Parameters )
if ( new_state_rtm ^ old_state_rtm ) {
if ( new_state_rtm == 0 ) {
printf("RTM Hotswap handle pressed!\n");
#ifdef BENCH_TEST
payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE);
#endif
} else {
printf("RTM Hotswap handle released!\n");
printf("RTM Hotswap handle released!\n");
#ifdef BENCH_TEST
payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE);
#endif
}
if ( hotswap_send_event( hotswap_rtm_sensor, new_state_rtm ) == ipmb_error_success ) {
hotswap_set_mask_bit( HOTSWAP_RTM, 1 << new_state_rtm );
Expand Down
4 changes: 2 additions & 2 deletions port/board/afc-bpm/v3_0/payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ void vTaskPayload( void *pvParameters )
DCDC_good = 0;
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_DCDC_PGOODn );
}
if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) {
if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) {
QUIESCED_req = 1;
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCED );
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCE );
}
if ( current_evt & PAYLOAD_MESSAGE_COLD_RST ) {
state = PAYLOAD_SWITCHING_OFF;
Expand Down
2 changes: 1 addition & 1 deletion port/board/afc-bpm/v3_0/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum {
#define PAYLOAD_MESSAGE_COLD_RST (1 << 4)
#define PAYLOAD_MESSAGE_WARM_RST (1 << 5)
#define PAYLOAD_MESSAGE_REBOOT (1 << 6)
#define PAYLOAD_MESSAGE_QUIESCED (1 << 7)
#define PAYLOAD_MESSAGE_QUIESCE (1 << 7)
/**
* @}
*/
Expand Down
4 changes: 2 additions & 2 deletions port/board/afc-bpm/v3_1/payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ void vTaskPayload( void *pvParameters )

current_evt = xEventGroupGetBits( amc_payload_evt );

if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) {
if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) {
QUIESCED_req = 1;
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCED );
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCE );
}

if ( current_evt & PAYLOAD_MESSAGE_COLD_RST ) {
Expand Down
2 changes: 1 addition & 1 deletion port/board/afc-bpm/v3_1/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum {
#define PAYLOAD_MESSAGE_COLD_RST (1 << 0)
#define PAYLOAD_MESSAGE_WARM_RST (1 << 1)
#define PAYLOAD_MESSAGE_REBOOT (1 << 2)
#define PAYLOAD_MESSAGE_QUIESCED (1 << 3)
#define PAYLOAD_MESSAGE_QUIESCE (1 << 3)
/**
* @}
*/
Expand Down
4 changes: 2 additions & 2 deletions port/board/afc-timing/payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ void vTaskPayload( void *pvParameters )

current_evt = xEventGroupGetBits( amc_payload_evt );

if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) {
if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) {
QUIESCED_req = 1;
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCED );
xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCE );
}

if ( current_evt & PAYLOAD_MESSAGE_COLD_RST ) {
Expand Down
3 changes: 2 additions & 1 deletion port/board/afc-timing/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ enum {
#define PAYLOAD_MESSAGE_COLD_RST (1 << 0)
#define PAYLOAD_MESSAGE_WARM_RST (1 << 1)
#define PAYLOAD_MESSAGE_REBOOT (1 << 2)
#define PAYLOAD_MESSAGE_QUIESCED (1 << 3)
#define PAYLOAD_MESSAGE_QUIESCE (1 << 3)
#define PAYLOAD_MESSAGE_RTM_ENABLE (1 << 4)
/**
* @}
*/
Expand Down
Loading

0 comments on commit 73c73e5

Please sign in to comment.