From: Michael Gernoth Date: Mon, 23 Aug 2010 15:16:57 +0000 (+0200) Subject: implement powercycle via IPMI X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/ae50f4d4b8167088d5bac42cdc07407ab96c4bb4?hp=ed12045ff73c6ac30effca87367a9bd82f689dea implement powercycle via IPMI --- diff --git a/bmc/chassis.c b/bmc/chassis.c index 852e726..2259d86 100644 --- a/bmc/chassis.c +++ b/bmc/chassis.c @@ -2,6 +2,7 @@ #include #include +#include "config.h" #include "chassis.h" #ifdef __AVR_ATmega16__ @@ -23,6 +24,7 @@ static volatile int power_cnt = 0; static volatile int reset_cnt = 0; +static volatile int power_cycle = 0; static void chassis_set_pins(uint8_t pins, uint8_t state); @@ -78,23 +80,31 @@ static void chassis_reset(int msec) void chassis_control(unsigned char action) { + uint8_t old_SREG = SREG; + #ifdef DEBUG printf("Chassis control 0x%02x\n", action); #endif switch(action) { case CHASSIS_ACTION_POWER_DOWN: - chassis_power(5000); + chassis_power(POWERDOWN_TIME_MS); break; case CHASSIS_ACTION_POWER_UP: - chassis_power(200); + chassis_power(POWERUP_TIME_MS); break; case CHASSIS_ACTION_HARD_RESET: - chassis_reset(200); + chassis_reset(RESET_TIME_MS); break; + case CHASSIS_ACTION_POWER_CYCLE: + cli(); + power_cycle = POWER_CYCLE_PAUSE_MS; + SREG = old_SREG; + chassis_power(POWERDOWN_TIME_MS); + default: #ifdef DEBUG printf("Unimplemented chassis action 0x%02x\n", action); @@ -110,6 +120,13 @@ ISR(TIMER0_COMP_vect) if (!power_cnt) chassis_set_pins((1<