diff options
275 files changed, 25629 insertions, 5241 deletions
@@ -26,13 +26,13 @@ BMC SoC layer and board specific layer are grouped together based on the vendor/ * Step 1 - Clone Yocto repository. ``` -$ git clone -b daisy https://git.yoctoproject.org/git/poky +$ git clone -b fido https://git.yoctoproject.org/git/poky ``` * Step 2 - Clone Openembedded and OpenBMC repositories, in the new created `poky` directory, ``` $ cd poky -$ git clone -b daisy https://github.com/openembedded/meta-openembedded.git +$ git clone -b fido https://github.com/openembedded/meta-openembedded.git $ git clone git@github.com:facebook/openbmc.git meta-openbmc ``` diff --git a/common/recipes-connectivity/openssh/openssh_6.5%.bbappend b/common/recipes-connectivity/openssh/openssh_%.bbappend index 60b164b..60b164b 100644 --- a/common/recipes-connectivity/openssh/openssh_6.5%.bbappend +++ b/common/recipes-connectivity/openssh/openssh_%.bbappend diff --git a/common/recipes-core/consoled/files/consoled.c b/common/recipes-core/consoled/files/consoled.c index 9f17e31..b15011e 100644 --- a/common/recipes-core/consoled/files/consoled.c +++ b/common/recipes-core/consoled/files/consoled.c @@ -49,7 +49,7 @@ write_data(int file, char *buf, int len, char *fname) { len -= wlen; tbuf = tbuf + wlen; } else { - syslog(LOG_ALERT, "write_data: write() failed to file %s | errno: %d", + syslog(LOG_WARNING, "write_data: write() failed to file %s | errno: %d", fname, errno); return; } @@ -124,7 +124,7 @@ run_console(char* fru_name, int term) { (O_RDONLY | O_NOCTTY | O_NONBLOCK); if ((tty = open(devtty, flags)) < 0) { - syslog(LOG_ALERT, "Cannot open the file %s", devtty); + syslog(LOG_WARNING, "Cannot open the file %s", devtty); exit(-1); } fcntl(tty, F_SETFL, O_RDWR); @@ -144,7 +144,7 @@ run_console(char* fru_name, int term) { sprintf(old_bfname, "/tmp/consoled_%s_log-old", fru_name); sprintf(bfname, "/tmp/consoled_%s_log", fru_name); if ((buf_fd = open(bfname, O_RDWR | O_APPEND | O_CREAT, 0666)) < 0) { - syslog(LOG_ALERT, "Cannot open the file %s", bfname); + syslog(LOG_WARNING, "Cannot open the file %s", bfname); exit(-1); } @@ -213,7 +213,7 @@ run_console(char* fru_name, int term) { remove(old_bfname); rename(bfname, old_bfname); if ((buf_fd = open(bfname, O_RDWR | O_APPEND | O_CREAT, 0666)) < 0) { - syslog(LOG_ALERT, "Cannot open the file %s", bfname); + syslog(LOG_WARNING, "Cannot open the file %s", bfname); exit(-1); } nline = 0; diff --git a/common/recipes-core/fan-ctrl/fan-ctrl/fand.cpp b/common/recipes-core/fan-ctrl/fan-ctrl/fand.cpp index 49c6f6b..ccfbdb1 100644 --- a/common/recipes-core/fan-ctrl/fan-ctrl/fand.cpp +++ b/common/recipes-core/fan-ctrl/fan-ctrl/fand.cpp @@ -40,11 +40,14 @@ /* Yeah, the file ends in .cpp, but it's a C program. Deal. */ -#if !defined(CONFIG_YOSEMITE) && !defined(CONFIG_WEDGE) +/* XXX: Both CONFIG_WEDGE and CONFIG_WEDGE100 are defined for Wedge100 */ + +#if !defined(CONFIG_YOSEMITE) && !defined(CONFIG_WEDGE) && \ + !defined(CONFIG_WEDGE100) #error "No hardware platform defined!" #endif #if defined(CONFIG_YOSEMITE) && defined(CONFIG_WEDGE) -#error "Both hardware platform defined!" +#error "Two hardware platforms defined!" #endif #include <stdio.h> @@ -54,12 +57,12 @@ #include <errno.h> #include <signal.h> #include <syslog.h> -#ifdef CONFIG_YOSEMITE +#if defined(CONFIG_YOSEMITE) #include <openbmc/ipmi.h> #include <facebook/bic.h> #include <facebook/yosemite_sensor.h> #endif -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) && !defined(CONFIG_WEDGE100) #include <facebook/wedge_eeprom.h> #endif @@ -67,23 +70,15 @@ /* Sensor definitions */ -#ifdef CONFIG_WEDGE -#define INTERNAL_TEMPS(x) ((x) * 1000) // stored a C * 1000 +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) +#define INTERNAL_TEMPS(x) ((x) * 1000) // stored as C * 1000 #define EXTERNAL_TEMPS(x) ((x) / 1000) -#elif CONFIG_YOSEMITE +#elif defined(CONFIG_YOSEMITE) #define INTERNAL_TEMPS(x) (x) #define EXTERNAL_TEMPS(x) (x) #define TOTAL_1S_SERVERS 4 #endif -#define I2C_BUS_3_DIR "/sys/class/i2c-adapter/i2c-3/" -#define I2C_BUS_4_DIR "/sys/class/i2c-adapter/i2c-4/" - -#define INTAKE_TEMP_DEVICE I2C_BUS_3_DIR "3-0048" -#define T2_TEMP_DEVICE I2C_BUS_3_DIR "3-0049" -#define EXHAUST_TEMP_DEVICE I2C_BUS_3_DIR "3-004a" -#define USERVER_TEMP_DEVICE I2C_BUS_4_DIR "4-0040" - /* * The sensor for the uServer CPU is not on the CPU itself, so it reads * a little low. We are special casing this, but we should obviously @@ -91,10 +86,10 @@ * the entire configuration. JSON file? */ -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) #define USERVER_TEMP_FUDGE INTERNAL_TEMPS(10) #else -#define USERVER_TEMP_FUDGE INTERNAL_TEMPS(1) +#define USERVER_TEMP_FUDGE INTERNAL_TEMPS(0) #endif #define BAD_TEMP INTERNAL_TEMPS(-60) @@ -104,25 +99,47 @@ #define FAN_SHUTDOWN_THRESHOLD 20 /* How long fans can be failed before */ /* we just shut down the whole thing. */ +#if defined(CONFIG_WEDGE100) +#define PWM_DIR "/sys/bus/i2c/drivers/fancpld/8-0033/" -#define PWM_DIR "/sys/devices/platform/ast_pwm_tacho.0" +#define PWM_UNIT_MAX 31 -#define PWM_UNIT_MAX 96 +#define LM75_DIR "/sys/bus/i2c/drivers/lm75/" +#define PANTHER_PLUS_DIR "/sys/bus/i2c/drivers/panther_plus/" -#define LARGEST_DEVICE_NAME 120 +#define INTAKE_TEMP_DEVICE LM75_DIR "3-0048" +#define CHIP_TEMP_DEVICE LM75_DIR "3-004b" +#define EXHAUST_TEMP_DEVICE LM75_DIR "3-0048" +#define USERVER_TEMP_DEVICE PANTHER_PLUS_DIR "4-0040" -#define GPIO_USERVER_POWER_DIRECTION "/sys/class/gpio/gpio25/direction" -#define GPIO_USERVER_POWER "/sys/class/gpio/gpio25/value" -#define GPIO_T2_POWER_DIRECTION "/tmp/gpionames/T2_POWER_UP/direction" -#define GPIO_T2_POWER "/tmp/gpionames/T2_POWER_UP/value" +#define FAN_READ_RPM_FORMAT "fan%d_input" + +#define FAN0_LED PWM_DIR "fantray1_led_ctrl" +#define FAN1_LED PWM_DIR "fantray2_led_ctrl" +#define FAN2_LED PWM_DIR "fantray3_led_ctrl" +#define FAN3_LED PWM_DIR "fantray4_led_ctrl" +#define FAN4_LED PWM_DIR "fantray5_led_ctrl" + +#define FAN_LED_BLUE "0x1" +#define FAN_LED_RED "0x2" + +#define MAIN_POWER "/sys/bus/i2c/drivers/syscpld/12-0031/pwr_main_n" +#define USERVER_POWER "/sys/bus/i2c/drivers/syscpld/12-0031/pwr_usrv_en" + +#elif defined(CONFIG_WEDGE) +#define I2C_BUS_3_DIR "/sys/class/i2c-adapter/i2c-3/" +#define I2C_BUS_4_DIR "/sys/class/i2c-adapter/i2c-4/" + +#define INTAKE_TEMP_DEVICE I2C_BUS_3_DIR "3-0048" +#define CHIP_TEMP_DEVICE I2C_BUS_3_DIR "3-0049" +#define EXHAUST_TEMP_DEVICE I2C_BUS_3_DIR "3-004a" +#define USERVER_TEMP_DEVICE I2C_BUS_4_DIR "4-0040" -#define GPIO_FAN0_LED "/sys/class/gpio/gpio53/value" -#define GPIO_FAN1_LED "/sys/class/gpio/gpio54/value" -#define GPIO_FAN2_LED "/sys/class/gpio/gpio55/value" -#define GPIO_FAN3_LED "/sys/class/gpio/gpio72/value" -const char *fan_led[] = {GPIO_FAN0_LED, GPIO_FAN1_LED, - GPIO_FAN2_LED, GPIO_FAN3_LED}; +#define FAN0_LED "/sys/class/gpio/gpio53/value" +#define FAN1_LED "/sys/class/gpio/gpio54/value" +#define FAN2_LED "/sys/class/gpio/gpio55/value" +#define FAN3_LED "/sys/class/gpio/gpio72/value" #define FAN_LED_RED "0" #define FAN_LED_BLUE "1" @@ -142,13 +159,45 @@ const char *fan_led[] = {GPIO_FAN0_LED, GPIO_FAN1_LED, #define REV_ID_NEW_BOARD_ID 3 #define GPIO_BOARD_ID_START_NEW 166 +#elif defined(CONFIG_YOSEMITE) +#define FAN_LED_RED "0" +#define FAN_LED_BLUE "1" +#endif + +#if (defined(CONFIG_YOSEMITE) || defined(CONFIG_WEDGE)) && \ + !defined(CONFIG_WEDGE100) +#define PWM_DIR "/sys/devices/platform/ast_pwm_tacho.0" + +#define PWM_UNIT_MAX 96 +#define FAN_READ_RPM_FORMAT "tacho%d_rpm" + +#define GPIO_USERVER_POWER_DIRECTION "/sys/class/gpio/gpio25/direction" +#define GPIO_USERVER_POWER "/sys/class/gpio/gpio25/value" +#define GPIO_T2_POWER_DIRECTION "/tmp/gpionames/T2_POWER_UP/direction" +#define GPIO_T2_POWER "/tmp/gpionames/T2_POWER_UP/value" +#endif + +#define LARGEST_DEVICE_NAME 120 + +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) +const char *fan_led[] = {FAN0_LED, FAN1_LED, FAN2_LED, FAN3_LED, +#if defined(CONFIG_WEDGE100) + FAN4_LED, +#endif +}; +#endif + #define REPORT_TEMP 720 /* Report temp every so many cycles */ /* Sensor limits and tuning parameters */ #define INTAKE_LIMIT INTERNAL_TEMPS(60) -#define T2_LIMIT INTERNAL_TEMPS(80) +#define SWITCH_LIMIT INTERNAL_TEMPS(80) +#if defined(CONFIG_YOSEMITE) +#define USERVER_LIMIT INTERNAL_TEMPS(110) +#else #define USERVER_LIMIT INTERNAL_TEMPS(90) +#endif #define TEMP_TOP INTERNAL_TEMPS(70) #define TEMP_BOTTOM INTERNAL_TEMPS(40) @@ -165,7 +214,11 @@ const char *fan_led[] = {GPIO_FAN0_LED, GPIO_FAN1_LED, #define WEDGE_FAN_LOW 35 #define WEDGE_FAN_MEDIUM 50 #define WEDGE_FAN_HIGH 70 +#if defined(CONFIG_WEDGE100) +#define WEDGE_FAN_MAX 100 +#else #define WEDGE_FAN_MAX 99 +#endif #define SIXPACK_FAN_LOW 35 #define SIXPACK_FAN_MEDIUM 55 @@ -177,19 +230,28 @@ const char *fan_led[] = {GPIO_FAN0_LED, GPIO_FAN1_LED, * RPM measuring and PWM setting, naturally. Doh. */ -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE100) +int fan_to_rpm_map[] = {1, 3, 5, 7, 9}; +int fan_to_pwm_map[] = {1, 2, 3, 4, 5}; +#define FANS 5 +// Tacho offset between front and rear fans: +#define REAR_FAN_OFFSET 1 +#define BACK_TO_BACK_FANS + +#elif defined(CONFIG_WEDGE) int fan_to_rpm_map[] = {3, 2, 0, 1}; int fan_to_pwm_map[] = {7, 6, 0, 1}; #define FANS 4 // Tacho offset between front and rear fans: #define REAR_FAN_OFFSET 4 #define BACK_TO_BACK_FANS -#else +#elif defined(CONFIG_YOSEMITE) int fan_to_rpm_map[] = {0, 1}; int fan_to_pwm_map[] = {0, 1}; #define FANS 2 // Tacho offset between front and rear fans: #define REAR_FAN_OFFSET 1 + #endif @@ -205,11 +267,49 @@ int fan_to_pwm_map[] = {0, 1}; */ struct rpm_to_pct_map { - ushort pct; - ushort rpm; + uint pct; + uint rpm; }; -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE100) +struct rpm_to_pct_map rpm_front_map[] = {{20, 4200}, + {25, 5550}, + {30, 6180}, + {35, 7440}, + {40, 8100}, + {45, 9300}, + {50, 10410}, + {55, 10920}, + {60, 11910}, + {65, 12360}, + {70, 13260}, + {75, 14010}, + {80, 14340}, + {85, 15090}, + {90, 15420}, + {95, 15960}, + {100, 16200}}; +#define FRONT_MAP_SIZE (sizeof(rpm_front_map) / sizeof(struct rpm_to_pct_map)) + +struct rpm_to_pct_map rpm_rear_map[] = {{20, 2130}, + {25, 3180}, + {30, 3690}, + {35, 4620}, + {40, 5130}, + {45, 6120}, + {50, 7050}, + {55, 7560}, + {60, 8580}, + {65, 9180}, + {70, 10230}, + {75, 11280}, + {80, 11820}, + {85, 12870}, + {90, 13350}, + {95, 14370}, + {100, 14850}}; +#define REAR_MAP_SIZE (sizeof(rpm_rear_map) / sizeof(struct rpm_to_pct_map)) +#elif defined(CONFIG_WEDGE) struct rpm_to_pct_map rpm_front_map[] = {{30, 6150}, {35, 7208}, {40, 8195}, @@ -243,22 +343,21 @@ struct rpm_to_pct_map rpm_rear_map[] = {{30, 3911}, {95, 15516}, {100, 15897}}; #define REAR_MAP_SIZE (sizeof(rpm_rear_map) / sizeof(struct rpm_to_pct_map)) -#else -struct rpm_to_pct_map rpm_map[] = {{30, 3413}, - {35, 3859}, - {40, 4305}, - {45, 4686}, - {50, 5032}, - {55, 5432}, - {60, 5991}, - {65, 6460}, - {70, 6927}, - {75, 7379}, - {80, 7733}, - {85, 8156}, - {90, 8599}, - {95, 9049}, - {100, 9265}}; +#elif defined(CONFIG_YOSEMITE) + +/* XXX: Note that 0% is far from 0 RPM. */ +struct rpm_to_pct_map rpm_map[] = {{0, 989}, + {10, 1654}, + {20, 2650}, + {30, 3434}, + {40, 4318}, + {50, 5202}, + {60, 5969}, + {70, 6869}, + {80, 7604}, + {90, 8525}, + {100, 9325}}; + struct rpm_to_pct_map *rpm_front_map = rpm_map; struct rpm_to_pct_map *rpm_rear_map = rpm_map; #define MAP_SIZE (sizeof(rpm_map) / sizeof(struct rpm_to_pct_map)) @@ -267,6 +366,50 @@ struct rpm_to_pct_map *rpm_rear_map = rpm_map; #endif +/* + * Mappings from temperatures recorded from sensors to fan speeds; + * note that in some cases, we want to be able to look at offsets + * from the CPU temperature margin rather than an absolute temperature, + * so we use ints. + */ + +struct temp_to_pct_map { + int temp; + unsigned speed; +}; + +#if defined(CONFIG_YOSEMITE) +struct temp_to_pct_map intake_map[] = {{25, 15}, + {27, 16}, + {29, 17}, + {31, 18}, + {33, 19}, + {35, 20}, + {37, 21}, + {39, 22}, + {41, 23}, + {43, 24}, + {45, 25}}; +#define INTAKE_MAP_SIZE (sizeof(intake_map) / sizeof(struct temp_to_pct_map)) + +struct temp_to_pct_map cpu_map[] = {{-28, 10}, + {-26, 20}, + {-24, 25}, + {-22, 30}, + {-20, 35}, + {-18, 40}, + {-16, 45}, + {-14, 50}, + {-12, 55}, + {-10, 60}, + {-8, 65}, + {-6, 70}, + {-4, 80}, + {-2, 100}}; +#define CPU_MAP_SIZE (sizeof(cpu_map) / sizeof(struct temp_to_pct_map)) +#endif + + #define FAN_FAILURE_OFFSET 30 int fan_low = WEDGE_FAN_LOW; @@ -355,7 +498,7 @@ int write_device(const char *device, const char *value) { } } -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) int read_temp(const char *device, int *value) { char full_name[LARGEST_DEVICE_NAME + 1]; @@ -365,7 +508,9 @@ int read_temp(const char *device, int *value) { full_name, LARGEST_DEVICE_NAME, "%s/temp1_input", device); return read_device(full_name, value); } +#endif +#if defined(CONFIG_WEDGE) && !defined(CONFIG_WEDGE100) int read_gpio_value(const int id, const char *device, int *value) { char full_name[LARGEST_DEVICE_NAME]; @@ -448,7 +593,7 @@ int read_fan_value(const int fan, const char *device, int *value) { char full_name[LARGEST_DEVICE_NAME]; snprintf(device_name, LARGEST_DEVICE_NAME, device, fan); - snprintf(full_name, LARGEST_DEVICE_NAME, "%s/%s", PWM_DIR, device_name); + snprintf(full_name, LARGEST_DEVICE_NAME, "%s/%s", PWM_DIR,device_name); return read_device(full_name, value); } @@ -512,11 +657,11 @@ int fan_speed_okay(const int fan, const int speed, const int slop) { real_fan = fan_to_rpm_map[fan]; front_fan = 0; - read_fan_value(real_fan, "tacho%d_rpm", &front_fan); + read_fan_value(real_fan, FAN_READ_RPM_FORMAT, &front_fan); front_pct = fan_rpm_to_pct(rpm_front_map, FRONT_MAP_SIZE, front_fan); #ifdef BACK_TO_BACK_FANS rear_fan = 0; - read_fan_value(real_fan + REAR_FAN_OFFSET, "tacho%d_rpm", &rear_fan); + read_fan_value(real_fan + REAR_FAN_OFFSET, FAN_READ_RPM_FORMAT, &rear_fan); rear_pct = fan_rpm_to_pct(rpm_rear_map, REAR_MAP_SIZE, rear_fan); #endif @@ -539,7 +684,7 @@ int fan_speed_okay(const int fan, const int speed, const int slop) { #endif if (!okay || verbose) { - syslog(!okay ? LOG_ALERT : LOG_INFO, + syslog(!okay ? LOG_WARNING : LOG_INFO, #ifdef BACK_TO_BACK_FANS "fan %d rear %d (%d%%), front %d (%d%%), expected %d", #else @@ -570,11 +715,19 @@ int write_fan_speed(const int fan, const int value) { int real_fan = fan_to_pwm_map[fan]; if (value == 0) { +#if defined(CONFIG_WEDGE100) + return write_fan_value(real_fan, "fantray%d_pwm", 0); +#else return write_fan_value(real_fan, "pwm%d_en", 0); +#endif } else { int unit = value * PWM_UNIT_MAX / 100; int status; +#if defined(CONFIG_WEDGE100) + // Note that PWM for Wedge100 is in 32nds of a cycle + return write_fan_value(real_fan, "fantray%d_pwm", unit); +#else if (unit == PWM_UNIT_MAX) unit = 0; @@ -584,14 +737,25 @@ int write_fan_speed(const int fan, const int value) { (status = write_fan_value(real_fan, "pwm%d_en", 1)) != 0) { return status; } +#endif + } +} + +#if defined(CONFIG_YOSEMITE) +int temp_to_fan_speed(int temp, struct temp_to_pct_map *map, int map_size) { + int i = map_size - 1; + + while (i > 0 && temp < map[i].temp) { + --i; } + return map[i].speed; } +#endif /* Set up fan LEDs */ -int write_fan_led(const int fan, const char *color) -{ -#ifdef CONFIG_WEDGE +int write_fan_led(const int fan, const char *color) { +#if defined(CONFIG_WEDGE100) || defined(CONFIG_WEDGE) return write_device(fan_led[fan], color); #else return 0; @@ -605,9 +769,14 @@ int server_shutdown(const char *why) { } syslog(LOG_EMERG, "Shutting down: %s", why); +#if defined(CONFIG_WEDGE100) + write_device(USERVER_POWER, "0"); + sleep(5); + write_device(MAIN_POWER, "0"); +#endif +#if defined(CONFIG_WEDGE) && !defined(CONFIG_WEDGE100) write_device(GPIO_USERVER_POWER_DIRECTION, "out"); write_device(GPIO_USERVER_POWER, "0"); -#ifdef CONFIG_WEDGE /* * Putting T2 in reset generates a non-maskable interrupt to uS, * the kernel running on uS might panic depending on its version. @@ -627,7 +796,6 @@ int server_shutdown(const char *why) { system("rmmod adm1275"); system("i2cset -y 12 0x10 0x01 00"); } - #else // TODO(7088822): try throttling, then shutting down server. syslog(LOG_EMERG, "Need to implement actual shutdown!\n"); @@ -654,7 +822,7 @@ void fand_interrupt(int sig) write_fan_speed(fan + fan_offset, fan_max); } - syslog(LOG_ALERT, "Shutting down fand on signal %s", strsignal(sig)); + syslog(LOG_WARNING, "Shutting down fand on signal %s", strsignal(sig)); if (sig == SIGUSR1) { stop_watchdog(); } @@ -664,10 +832,10 @@ void fand_interrupt(int sig) int main(int argc, char **argv) { /* Sensor values */ -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) int intake_temp; int exhaust_temp; - int t2_temp; + int switch_temp; int userver_temp; #else float intake_temp; @@ -702,7 +870,7 @@ int main(int argc, char **argv) { openlog("fand", LOG_CONS, LOG_DAEMON); -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) && !defined(CONFIG_WEDGE100) if (is_two_fan_board(false)) { /* Alternate, two fan configuration */ total_fans = 2; @@ -779,11 +947,25 @@ int main(int argc, char **argv) { write_fan_led(fan + fan_offset, FAN_LED_BLUE); } -#ifdef CONFIG_YOSEMITE +#if defined(CONFIG_YOSEMITE) /* Ensure that we can read from sensors before proceeding. */ - while (yosemite_sensor_read(1, BIC_SENSOR_SOC_TEMP, &userver_temp)) - syslog(LOG_DEBUG, "Failed reading of SOC_TEMP."); + int found = 0; + userver_temp = 100; + while (!found) { + for (int node = 1; node <= TOTAL_1S_SERVERS && !found; node++) { + if (!yosemite_sensor_read(node, BIC_SENSOR_SOC_THERM_MARGIN, + &userver_temp) && + userver_temp < 0) { + syslog(LOG_DEBUG, "SOC_THERM_MARGIN first valid read of %f.", + userver_temp); + found = 1; + } + sleep(5); + } + // XXX: Will it ever be a problem that we don't exit this until + // we see a valid value? + } #endif /* Start watchdog in manual mode */ @@ -801,10 +983,10 @@ int main(int argc, char **argv) { /* Read sensors */ -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) read_temp(INTAKE_TEMP_DEVICE, &intake_temp); read_temp(EXHAUST_TEMP_DEVICE, &exhaust_temp); - read_temp(T2_TEMP_DEVICE, &t2_temp); + read_temp(CHIP_TEMP_DEVICE, &switch_temp); read_temp(USERVER_TEMP_DEVICE, &userver_temp); /* @@ -813,13 +995,13 @@ int main(int argc, char **argv) { */ if ((intake_temp == BAD_TEMP || exhaust_temp == BAD_TEMP || - t2_temp == BAD_TEMP)) { + switch_temp == BAD_TEMP)) { bad_reads++; } #else - userver_temp = BAD_TEMP; - if (yosemite_sensor_read(1, SP_SENSOR_INLET_TEMP, &intake_temp) || - yosemite_sensor_read(1, SP_SENSOR_OUTLET_TEMP, &exhaust_temp)) + intake_temp = exhaust_temp = userver_temp = BAD_TEMP; + if (yosemite_sensor_read(FRU_SPB, SP_SENSOR_INLET_TEMP, &intake_temp) || + yosemite_sensor_read(FRU_SPB, SP_SENSOR_OUTLET_TEMP, &exhaust_temp)) bad_reads++; /* @@ -829,11 +1011,15 @@ int main(int argc, char **argv) { */ for (int node = 1; node <= TOTAL_1S_SERVERS; node++) { float new_temp; - if (!yosemite_sensor_read(node, BIC_SENSOR_SOC_TEMP, &new_temp)) { + if (!yosemite_sensor_read(node, BIC_SENSOR_SOC_THERM_MARGIN, + &new_temp)) { if (userver_temp < new_temp) { userver_temp = new_temp; } } + + // Since the yosemite_sensor_read() times out after 8secs, keep WDT from expiring + kick_watchdog(); } #endif @@ -843,7 +1029,7 @@ int main(int argc, char **argv) { if (log_count++ % report_temp == 0) { syslog(LOG_DEBUG, -#ifdef CONFIG_WEDGE +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) "Temp intake %d, t2 %d, " " userver %d, exhaust %d, " "fan speed %d, speed changes %d", @@ -852,8 +1038,8 @@ int main(int argc, char **argv) { "fan speed %d, speed changes %d", #endif intake_temp, -#ifdef CONFIG_WEDGE - t2_temp, +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) + switch_temp, #endif userver_temp, exhaust_temp, @@ -867,8 +1053,8 @@ int main(int argc, char **argv) { server_shutdown("Intake temp limit reached"); } -#ifdef CONFIG_WEDGE - if (t2_temp > T2_LIMIT) { +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) + if (switch_temp > SWITCH_LIMIT) { server_shutdown("T2 temp limit reached"); } #endif @@ -885,20 +1071,28 @@ int main(int argc, char **argv) { * as well. */ -#ifdef CONFIG_WEDGE - if (t2_temp > userver_temp + USERVER_TEMP_FUDGE) { - max_temp = t2_temp; +#if defined(CONFIG_YOSEMITE) + /* Use tables to lookup the new fan speed for Yosemite. */ + + int intake_speed = temp_to_fan_speed(intake_temp, intake_map, + INTAKE_MAP_SIZE); + int cpu_speed = temp_to_fan_speed(userver_temp, cpu_map, CPU_MAP_SIZE); + + if (fan_speed == fan_max && fan_failure != 0) { + /* Don't change a thing */ + } else if (intake_speed > cpu_speed) { + fan_speed = intake_speed; } else { - max_temp = userver_temp + USERVER_TEMP_FUDGE; + fan_speed = cpu_speed; } #else - /* Yosemite could have no servers turned on, so ignore that case. */ - if (userver_temp + USERVER_TEMP_FUDGE > exhaust_temp) { - max_temp = userver_temp + USERVER_TEMP_FUDGE; + /* Other systems use a simpler built-in table to determine fan speed. */ + + if (switch_temp > userver_temp + USERVER_TEMP_FUDGE) { + max_temp = switch_temp; } else { - max_temp = exhaust_temp; + max_temp = userver_temp + USERVER_TEMP_FUDGE; } -#endif /* * If recovering from a fan problem, spin down fans gradually in case @@ -924,6 +1118,7 @@ int main(int argc, char **argv) { fan_speed = fan_medium; } } +#endif /* * Update fans only if there are no failed ones. If any fans failed @@ -962,7 +1157,7 @@ int main(int argc, char **argv) { if (fan_speed_okay(fan + fan_offset, fan_speed, FAN_FAILURE_OFFSET)) { if (fan_bad[fan] > FAN_FAILURE_THRESHOLD) { write_fan_led(fan + fan_offset, FAN_LED_BLUE); - syslog(LOG_NOTICE, + syslog(LOG_CRIT, "Fan %d has recovered", fan); } @@ -982,7 +1177,7 @@ int main(int argc, char **argv) { if (fan_failure > 0) { if (prev_fans_bad != fan_failure) { - syslog(LOG_ALERT, "%d fans failed", fan_failure); + syslog(LOG_CRIT, "%d fans failed", fan_failure); } /* @@ -999,6 +1194,15 @@ int main(int argc, char **argv) { write_fan_speed(fan + fan_offset, fan_speed); } +#if defined(CONFIG_WEDGE) || defined(CONFIG_WEDGE100) + /* + * On Wedge, we want to shut down everything if none of the fans + * are visible, since there isn't automatic protection to shut + * off the server or switch chip. On other platforms, the CPUs + * generating the heat will automatically turn off, so this is + * unnecessary. + */ + if (fan_failure == total_fans) { int count = 0; for (fan = 0; fan < total_fans; fan++) { @@ -1009,7 +1213,7 @@ int main(int argc, char **argv) { server_shutdown("all fans are bad for more than 12 cycles"); } } - +#endif /* * Fans can be hot swapped and replaced; in which case the fan daemon diff --git a/common/recipes-core/fan-ctrl/fan-ctrl/watchdog.cpp b/common/recipes-core/fan-ctrl/fan-ctrl/watchdog.cpp index ebb390a..f6e5a45 100644 --- a/common/recipes-core/fan-ctrl/fan-ctrl/watchdog.cpp +++ b/common/recipes-core/fan-ctrl/fan-ctrl/watchdog.cpp @@ -100,7 +100,7 @@ int start_watchdog(const int auto_mode) { while ((status = write(watchdog_dev, WATCHDOG_START_KEY, 1)) == 0 && errno == EINTR); pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_ALERT, "system watchdog already started.\n"); + syslog(LOG_WARNING, "system watchdog already started.\n"); return 0; } @@ -128,7 +128,7 @@ fail: } pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_ALERT, "system watchdog failed to start!\n"); + syslog(LOG_WARNING, "system watchdog failed to start!\n"); return 0; } diff --git a/common/recipes-core/fruid/files/fruid-util.c b/common/recipes-core/fruid/files/fruid-util.c index 3c8d2e1..d0e19b8 100644 --- a/common/recipes-core/fruid/files/fruid-util.c +++ b/common/recipes-core/fruid/files/fruid-util.c @@ -18,11 +18,37 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <fcntl.h> +#include <syslog.h> +#include <string.h> #include <openbmc/fruid.h> #include <openbmc/pal.h> +#define EEPROM_READ 0x1 +#define EEPROM_WRITE 0x2 +#define FRUID_SIZE 256 + +/* To copy the bin files */ +static int +copy_file(int out, int in, int bs) { + + ssize_t bytes_rd, bytes_wr; + uint64_t tmp[FRUID_SIZE]; + + while ((bytes_rd = read(in, tmp, FRUID_SIZE)) > 0) { + bytes_wr = write(out, tmp, bytes_rd); + if (bytes_wr != bytes_rd) { + return errno; + } + } + return 0; +} + /* Print the FRUID in detail */ -void print_fruid_info(fruid_info_t *fruid, const char *name) +static void +print_fruid_info(fruid_info_t *fruid, const char *name) { /* Print format */ printf("%-27s: %s", "\nFRU Information", @@ -78,18 +104,27 @@ void get_fruid_info(uint8_t fru, char *path, char* name) { static int print_usage() { - printf("Usage: fruid-util [ %s ]\n", pal_fru_list); + printf("Usage: fruid-util [ %s ]\n" + "Usage: fruid-util [%s] [--dump | --write ] <file>\n", + pal_fru_list, pal_fru_list); } /* Utility to just print the FRUID */ int main(int argc, char * argv[]) { int ret; + int rw = 0; + int fd_tmpbin; + int fd_newbin; + int fd_eeprom; uint8_t fru; + char *file_path = NULL; char path[64] = {0}; + char eeprom_path[64] = {0}; char name[64] = {0}; + char command[128] = {0}; - if (argc != 2) { + if (argc != 2 && argc != 4) { print_usage(); exit(-1); } @@ -100,8 +135,119 @@ int main(int argc, char * argv[]) { return ret; } - if (fru == 0) { + if (fru == 0 && argc > 2) { + print_usage(); + exit(-1); + } + + if (argc > 2) { + if (!strcmp(argv[2], "--dump")) { + rw = EEPROM_READ; + file_path = argv[3]; + } else if (!strcmp(argv[2], "--write")) { + rw = EEPROM_WRITE; + file_path = argv[3]; + } + } + + // Check if the new eeprom binary file exits. + // TODO: Add file size check before adding to the eeprom + if (rw == EEPROM_WRITE && (access(file_path, F_OK) == -1)) { + print_usage(); + exit(-1); + } + + if (fru != 0) { + ret = pal_get_fruid_path(fru, path); + if (ret < 0) { + return ret; + } + + errno = 0; + + /* FRUID BINARY DUMP */ + if (rw == EEPROM_READ) { + fd_tmpbin = open(path, O_RDONLY); + if (fd_tmpbin == -1) { + syslog(LOG_ERR, "Unable to open the %s file: %s", path, strerror(errno)); + return errno; + } + + fd_newbin = open(file_path, O_WRONLY | O_CREAT, 0644); + if (fd_newbin == -1) { + syslog(LOG_ERR, "Unable to create %s file: %s", file_path, strerror(errno)); + return errno; + } + + ret = copy_file(fd_newbin, fd_tmpbin, FRUID_SIZE); + if (ret < 0) { + syslog(LOG_ERR, "copy: write to %s file failed: %s", + file_path, strerror(errno)); + return ret; + } + + close(fd_newbin); + close(fd_tmpbin); + + } else if (rw == EEPROM_WRITE) { + + /* FRUID BINARY WRITE */ + + fd_tmpbin = open(path, O_WRONLY); + if (fd_tmpbin == -1) { + syslog(LOG_ERR, "Unable to open the %s file: %s", path, strerror(errno)); + return errno; + } + + fd_newbin = open(file_path, O_RDONLY); + if (fd_newbin == -1) { + syslog(LOG_ERR, "Unable to open the %s file: %s", file_path, strerror(errno)); + return errno; + } + + ret = pal_get_fruid_eeprom_path(fru, eeprom_path); + if (ret < 0) { + //Can not handle in common, so call pal libray for update + pal_fruid_write(fru, file_path); + } else { + if (access(eeprom_path, F_OK) == -1) { + syslog(LOG_ERR, "cannot access the eeprom file : %s for fru %d", + eeprom_path, fru); + close(fd_newbin); + close(fd_tmpbin); + return -1; + } + sprintf(command, "dd if=%s of=%s bs=%d count=1", file_path, eeprom_path, FRUID_SIZE); + system(command); + } + + ret = copy_file(fd_tmpbin, fd_newbin, FRUID_SIZE); + if (ret < 0) { + syslog(LOG_ERR, "copy: write to %s file failed: %s", + path, strerror(errno)); + return ret; + } + + close(fd_newbin); + close(fd_tmpbin); + + } else { + /* FRUID PRINT ONE FRU */ + + ret = pal_get_fruid_name(fru, name); + if (ret < 0) { + return ret; + } + + get_fruid_info(fru, path, name); + } + + } else if (fru == 0) { + + /* FRUID PRINT ALL FRUs */ + fru = 1; + while (fru <= MAX_NUM_FRUS) { ret = pal_get_fruid_path(fru, path); if (ret < 0) { @@ -113,32 +259,10 @@ int main(int argc, char * argv[]) { return ret; } - if (fru == FRU_NIC) { - printf("fruid-util does not support nic\n"); - exit(-1); - } - get_fruid_info(fru, path, name); fru++; } - } else { - ret = pal_get_fruid_path(fru, path); - if (ret < 0) { - return ret; - } - - ret = pal_get_fruid_name(fru, name); - if (ret < 0) { - return ret; - } - - if (fru == FRU_NIC) { - printf("fruid-util does not support nic\n"); - exit(-1); - } - - get_fruid_info(fru, path, name); } return 0; diff --git a/common/recipes-core/healthd/files/Makefile b/common/recipes-core/healthd/files/Makefile new file mode 100644 index 0000000..13c0f66 --- /dev/null +++ b/common/recipes-core/healthd/files/Makefile @@ -0,0 +1,26 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +all: healthd + +healthd: healthd.c + $(CC) $(CFLAGS) -pthread -lm -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o healthd diff --git a/common/recipes-core/healthd/files/healthd.c b/common/recipes-core/healthd/files/healthd.c new file mode 100644 index 0000000..f02a363 --- /dev/null +++ b/common/recipes-core/healthd/files/healthd.c @@ -0,0 +1,77 @@ +/* + * healthd + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <syslog.h> +#include <errno.h> +#include <unistd.h> +#include <stdint.h> +#include <string.h> +#include <errno.h> +#include <fcntl.h> +#include <sys/file.h> +#include <openbmc/pal.h> + +static void +initilize_all_kv() { + pal_set_def_key_value(); +} + +static void +check_all_daemon_health() { + while(1) { + + /* + * TODO: Check if all the daemons are running fine + * TODO: Move the HB led control to this daemon + * TODO: Move the watchdog timer to this daemon + */ + sleep(10); + } +} + +int +main(int argc, void **argv) { + int dev, rc, pid_file; + + if (argc > 1) { + exit(1); + } + + pid_file = open("/var/run/healthd.pid", O_CREAT | O_RDWR, 0666); + rc = flock(pid_file, LOCK_EX | LOCK_NB); + if(rc) { + if(EWOULDBLOCK == errno) { + printf("Another healthd instance is running...\n"); + exit(-1); + } + } else { + + daemon(0,1); + openlog("healthd", LOG_CONS, LOG_DAEMON); + syslog(LOG_INFO, "healthd: daemon started"); + } + + initilize_all_kv(); + check_all_daemon_health(); + return 0; +} + diff --git a/common/recipes-core/healthd/files/setup-healthd.sh b/common/recipes-core/healthd/files/setup-healthd.sh new file mode 100644 index 0000000..b64be65 --- /dev/null +++ b/common/recipes-core/healthd/files/setup-healthd.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +### BEGIN INIT INFO +# Provides: setup-healthd +# Required-Start: +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Setup sensor monitoring +### END INIT INFO + +echo -n "Setup healthd for BMC " + +/usr/local/bin/healthd + +echo "done." diff --git a/common/recipes-core/healthd/healthd_0.1.bb b/common/recipes-core/healthd/healthd_0.1.bb new file mode 100644 index 0000000..0c4b2e9 --- /dev/null +++ b/common/recipes-core/healthd/healthd_0.1.bb @@ -0,0 +1,42 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Health Monitoring Daemon" +DESCRIPTION = "Daemon for BMC Health monitoring" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://healthd.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://Makefile \ + file://healthd.c \ + file://setup-healthd.sh \ + " +S = "${WORKDIR}" + +LDFLAGS =+ " -lpal " + +DEPENDS =+ " libpal " + +binfiles = "healthd" + +pkgdir = "healthd" + +do_install() { + dst="${D}/usr/local/fbpackages/${pkgdir}" + bin="${D}/usr/local/bin" + install -d $dst + install -d $bin + install -m 755 healthd ${dst}/healthd + ln -snf ../fbpackages/${pkgdir}/healthd ${bin}/healthd + + install -d ${D}${sysconfdir}/init.d + install -d ${D}${sysconfdir}/rcS.d + install -m 755 setup-healthd.sh ${D}${sysconfdir}/init.d/setup-healthd.sh + update-rc.d -r ${D} setup-healthd.sh start 91 5 . +} + +FBPACKAGEDIR = "${prefix}/local/fbpackages" + +FILES_${PN} = "${FBPACKAGEDIR}/healthd ${prefix}/local/bin ${sysconfdir} " + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" diff --git a/common/recipes-core/i2c-tools/i2c-tools_3.1.1.bb b/common/recipes-core/i2c-tools/i2c-tools_3.1.1.bb deleted file mode 100644 index 6743e3f..0000000 --- a/common/recipes-core/i2c-tools/i2c-tools_3.1.1.bb +++ /dev/null @@ -1,38 +0,0 @@ -DESCRIPTION = "i2c tools" -SECTION = "base" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" - -SRCREV = "6235" -SRC_URI = "svn://lm-sensors.org/svn/i2c-tools/branches/;protocol=http;module=i2c-tools-3.1 \ - " - -S = "${WORKDIR}/i2c-tools-3.1" - -i2ctools = "i2cdetect \ - i2cdump \ - i2cget \ - i2cset \ - " - -eepromtools = "eepromer \ - eeprom \ - eeprog \ - " - -do_compile() { - make -C eepromer - make -} - -do_install() { - mkdir -p ${D}/${bindir} - for f in ${i2ctools}; do - install -m 755 tools/$f ${D}/${bindir}/$f - done - for f in ${eepromtools}; do - install -m 755 eepromer/$f ${D}/${bindir}/$f - done -} - -FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_down b/common/recipes-core/init-ifupdown/files/dhcpv6_down index a44deb4..a44deb4 100644 --- a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_down +++ b/common/recipes-core/init-ifupdown/files/dhcpv6_down diff --git a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_up b/common/recipes-core/init-ifupdown/files/dhcpv6_up index 6469b9f..6469b9f 100644 --- a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_up +++ b/common/recipes-core/init-ifupdown/files/dhcpv6_up diff --git a/common/recipes-core/init-ifupdown/init-ifupdown_%.bbappend b/common/recipes-core/init-ifupdown/init-ifupdown_%.bbappend index 7d74521..e715c27 100644 --- a/common/recipes-core/init-ifupdown/init-ifupdown_%.bbappend +++ b/common/recipes-core/init-ifupdown/init-ifupdown_%.bbappend @@ -1,2 +1,18 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://dhcpv6_up \ + file://dhcpv6_down \ + " + +do_install_append() { + # rules to request dhcpv6 + install -d ${D}/${sysconfdir}/network/if-up.d + install -m 755 ${WORKDIR}/dhcpv6_up ${D}${sysconfdir}/network/if-up.d/dhcpv6_up + install -d ${D}/${sysconfdir}/network/if-down.d + install -m 755 ${WORKDIR}/dhcpv6_down ${D}${sysconfdir}/network/if-down.d/dhcpv6_down +} + +FILES_${PN} += "${sysconfdir}/network/if-up.d/dhcpv6_up \ + ${sysconfdir}/network/if-down.d/dhcpv6_down \ + " diff --git a/common/recipes-core/ipmbd/files/ipmbd.c b/common/recipes-core/ipmbd/files/ipmbd.c index 5ea5af3..ae40ec7 100644 --- a/common/recipes-core/ipmbd/files/ipmbd.c +++ b/common/recipes-core/ipmbd/files/ipmbd.c @@ -73,7 +73,7 @@ #define MQ_IPMB_REQ "/mq_ipmb_req" #define MQ_IPMB_RES "/mq_ipmb_res" #define MQ_MAX_MSG_SIZE MAX_BYTES -#define MQ_MAX_NUM_MSGS 10 +#define MQ_MAX_NUM_MSGS 20 #define SEQ_NUM_MAX 64 @@ -108,6 +108,8 @@ pthread_mutex_t m_seq; pthread_mutex_t m_i2c; +static int g_bus_id = 0; // store the i2c bus ID for debug print + #ifdef CONFIG_YOSEMITE // Returns the payload ID from IPMB bus routing // Slot#1: bus#3, Slot#2: bus#1, Slot#3: bus#7, Slot#4: bus#5 @@ -129,7 +131,7 @@ get_payload_id(uint8_t bus_id) { payload_id = 3; break; default: - syslog(LOG_ALERT, "get_payload_id: Wrong bus ID\n"); + syslog(LOG_WARNING, "get_payload_id: Wrong bus ID\n"); break; } @@ -138,9 +140,9 @@ get_payload_id(uint8_t bus_id) { #endif // Returns an unused seq# from all possible seq# -static uint8_t +static int8_t seq_get_new(void) { - uint8_t ret = -1; + int8_t ret = -1; uint8_t index; pthread_mutex_lock(&m_seq); @@ -183,13 +185,13 @@ i2c_open(uint8_t bus_num) { snprintf(fn, sizeof(fn), "/dev/i2c-%d", bus_num); fd = open(fn, O_RDWR); if (fd == -1) { - syslog(LOG_ALERT, "Failed to open i2c device %s", fn); + syslog(LOG_WARNING, "Failed to open i2c device %s", fn); return -1; } rc = ioctl(fd, I2C_SLAVE, BRIDGE_SLAVE_ADDR); if (rc < 0) { - syslog(LOG_ALERT, "Failed to open slave @ address 0x%x", BRIDGE_SLAVE_ADDR); + syslog(LOG_WARNING, "Failed to open slave @ address 0x%x", BRIDGE_SLAVE_ADDR); close(fd); return -1; } @@ -227,7 +229,7 @@ i2c_write(int fd, uint8_t *buf, uint8_t len) { } if (rc < 0) { - syslog(LOG_ALERT, "Failed to do raw io"); + syslog(LOG_WARNING, "Failed to do raw io"); pthread_mutex_unlock(&m_i2c); return -1; } @@ -249,7 +251,7 @@ i2c_slave_open(uint8_t bus_num) { snprintf(fn, sizeof(fn), "/dev/i2c-%d", bus_num); fd = open(fn, O_RDWR); if (fd == -1) { - syslog(LOG_ALERT, "Failed to open i2c device %s", fn); + syslog(LOG_WARNING, "Failed to open i2c device %s", fn); return -1; } @@ -266,7 +268,7 @@ i2c_slave_open(uint8_t bus_num) { rc = ioctl(fd, I2C_SLAVE_RDWR, &data); if (rc < 0) { - syslog(LOG_ALERT, "Failed to open slave @ address 0x%x", BMC_SLAVE_ADDR); + syslog(LOG_WARNING, "Failed to open slave @ address 0x%x", BMC_SLAVE_ADDR); close(fd); } @@ -341,22 +343,22 @@ ipmb_req_handler(void *bus_num) { // Open the i2c bus for sending response fd = i2c_open(*bnum); if (fd < 0) { - syslog(LOG_ALERT, "i2c_open failure\n"); + syslog(LOG_WARNING, "i2c_open failure\n"); close(mq); return NULL; } // Loop to process incoming requests while (1) { - if ((rlen = mq_receive(mq, rxbuf, MQ_MAX_MSG_SIZE, NULL)) < 0) { + if ((rlen = mq_receive(mq, rxbuf, MQ_MAX_MSG_SIZE, NULL)) <= 0) { sleep(1); continue; } #ifdef DEBUG - syslog(LOG_ALERT, "Received Request of %d bytes\n", rlen); + syslog(LOG_WARNING, "Received Request of %d bytes\n", rlen); for (i = 0; i < rlen; i++) { - syslog(LOG_ALERT, "0x%X", rxbuf[i]); + syslog(LOG_WARNING, "0x%X", rxbuf[i]); } #endif @@ -407,9 +409,9 @@ ipmb_req_handler(void *bus_num) { p_ipmb_res->data[tlen-IPMI_RESP_HDR_SIZE]; #ifdef DEBUG - syslog(LOG_ALERT, "Sending Response of %d bytes\n", tlen+IPMB_HDR_SIZE-1); + syslog(LOG_WARNING, "Sending Response of %d bytes\n", tlen+IPMB_HDR_SIZE-1); for (i = 1; i < tlen+IPMB_HDR_SIZE; i++) { - syslog(LOG_ALERT, "0x%X:", txbuf[i]); + syslog(LOG_WARNING, "0x%X:", txbuf[i]); } #endif @@ -428,45 +430,65 @@ ipmb_res_handler(void *bus_num) { ipmb_res_t *p_res; uint8_t index; char mq_ipmb_res[64] = {0}; + uint8_t hack = 0; sprintf(mq_ipmb_res, "%s_%d", MQ_IPMB_RES, *bnum); // Open the message queue mq = mq_open(mq_ipmb_res, O_RDONLY); if (mq == (mqd_t) -1) { - syslog(LOG_ALERT, "mq_open fails\n"); + syslog(LOG_WARNING, "mq_open fails\n"); return NULL; } // Loop to wait for incomng response messages while (1) { - if ((len = mq_receive(mq, buf, MQ_MAX_MSG_SIZE, NULL)) < 0) { + if ((len = mq_receive(mq, buf, MQ_MAX_MSG_SIZE, NULL)) <= 0) { sleep(1); continue; } p_res = (ipmb_res_t *) buf; + // Check the seq# of response index = p_res->seq_lun >> LUN_OFFSET; + // TODO: observed the IPMB packets with missing slave address at first byte; + // detect and correct them for now, but need fix in i2c driver + hack = 0; + if ((p_res->res_slave_addr != (BRIDGE_SLAVE_ADDR << 1)) || + (p_res->res_slave_addr == p_res->hdr_cksum)) { + index = p_res->res_slave_addr >> LUN_OFFSET; + hack = 1; + } // Check if the response is being waited for pthread_mutex_lock(&m_seq); if (g_seq.seq[index].in_use) { // Copy the response to the requester's buffer - memcpy(g_seq.seq[index].p_buf, buf, len); - g_seq.seq[index].len = len; + if (hack) { + // TODO: hack to correct the packet with missing slave address for now + *(g_seq.seq[index].p_buf) = (BMC_SLAVE_ADDR << 1); + memcpy(g_seq.seq[index].p_buf+1, buf, len); + g_seq.seq[index].len = len+1; + } else { + memcpy(g_seq.seq[index].p_buf, buf, len); + g_seq.seq[index].len = len; + } // Wake up the worker thread to receive the response sem_post(&g_seq.seq[index].s_seq); + } else { + // Either the IPMB packet is corrupted or arrived late after client exits + syslog(LOG_WARNING, "bus: %d, WRONG packet received with seq#%d\n", g_bus_id, index); } pthread_mutex_unlock(&m_seq); #ifdef DEBUG - syslog(LOG_ALERT, "Received Response of %d bytes\n", len); + syslog(LOG_WARNING, "Received Response of %d bytes\n", len); int i; for (i = 0; i < len; i++) { - syslog(LOG_ALERT, "0x%X:", buf[i]); + syslog(LOG_WARNING, "0x%X:", buf[i]); } #endif } @@ -494,7 +516,7 @@ ipmb_rx_handler(void *bus_num) { // Open the i2c bus as a slave fd = i2c_slave_open(*bnum); if (fd < 0) { - syslog(LOG_ALERT, "i2c_slave_open fails\n"); + syslog(LOG_WARNING, "i2c_slave_open fails\n"); goto cleanup; } @@ -504,13 +526,13 @@ ipmb_rx_handler(void *bus_num) { // Open the message queues for post processing mq_req = mq_open(mq_ipmb_req, O_WRONLY); if (mq_req == (mqd_t) -1) { - syslog(LOG_ALERT, "mq_open req fails\n"); + syslog(LOG_WARNING, "mq_open req fails\n"); goto cleanup; } mq_res = mq_open(mq_ipmb_res, O_WRONLY); if (mq_res == (mqd_t) -1) { - syslog(LOG_ALERT, "mq_open res fails\n"); + syslog(LOG_WARNING, "mq_open res fails\n"); goto cleanup; } @@ -532,9 +554,9 @@ ipmb_rx_handler(void *bus_num) { tmq = mq_req; } // Post message to approriate Queue for further processing - if (mq_send(tmq, buf, len, 0)) { - syslog(LOG_ALERT, "mq_send failed\n"); - sleep(1); + if (mq_timedsend(tmq, buf, len, 0, &req)) { + //syslog(LOG_WARNING, "mq_send failed for queue %d\n", tmq); + nanosleep(&req, &rem); continue; } } @@ -563,7 +585,7 @@ ipmb_handle (int fd, unsigned char *request, unsigned char req_len, ipmb_req_t *req = (ipmb_req_t *) request; ipmb_res_t *res = (ipmb_res_t *) response; - uint8_t index; + int8_t index; struct timespec ts; // Allocate right sequence Number @@ -598,12 +620,12 @@ ipmb_handle (int fd, unsigned char *request, unsigned char req_len, // Wait on semaphore for that sequence Number clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += TIMEOUT_IPMI; + ts.tv_sec += TIMEOUT_IPMB; int ret; ret = sem_timedwait(&g_seq.seq[index].s_seq, &ts); if (ret == -1) { - syslog(LOG_ALERT, "No response for sequence number: %d\n", index); + syslog(LOG_DEBUG, "No response for sequence number: %d\n", index); *res_len = 0; } @@ -628,17 +650,26 @@ void unsigned char req_buf[MAX_IPMI_MSG_SIZE]; unsigned char res_buf[MAX_IPMI_MSG_SIZE]; unsigned char res_len = 0; + struct timeval tv; + + // setup timeout for receving on socket + tv.tv_sec = TIMEOUT_IPMB; + tv.tv_usec = 0; + + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval)); n = recv(sock, req_buf, sizeof(req_buf), 0); if (n <= 0) { - syslog(LOG_ALERT, "ipmbd: recv() failed with %d\n", n); + syslog(LOG_WARNING, "ipmbd: recv() failed with %d\n", n); goto conn_cleanup; } ipmb_handle(fd, req_buf, n, res_buf, &res_len); if (send(sock, res_buf, res_len, MSG_NOSIGNAL) < 0) { - syslog(LOG_ALERT, "ipmbd: send() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "ipmbd: send() failed\n"); +#endif } conn_cleanup: @@ -659,11 +690,12 @@ ipmb_lib_handler(void *bus_num) { int fd; uint8_t *bnum = (uint8_t*) bus_num; char sock_path[20] = {0}; + int rc = 0; // Open the i2c bus for sending request fd = i2c_open(*bnum); if (fd < 0) { - syslog(LOG_ALERT, "i2c_open failure\n"); + syslog(LOG_WARNING, "i2c_open failure\n"); return NULL; } @@ -680,7 +712,7 @@ ipmb_lib_handler(void *bus_num) { if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ALERT, "ipmbd: socket() failed\n"); + syslog(LOG_WARNING, "ipmbd: socket() failed\n"); exit (1); } @@ -692,22 +724,25 @@ ipmb_lib_handler(void *bus_num) { len = strlen (local.sun_path) + sizeof (local.sun_family); if (bind (s, (struct sockaddr *) &local, len) == -1) { - syslog(LOG_ALERT, "ipmbd: bind() failed\n"); + syslog(LOG_WARNING, "ipmbd: bind() failed\n"); exit (1); } if (listen (s, 5) == -1) { - syslog(LOG_ALERT, "ipmbd: listen() failed\n"); + syslog(LOG_WARNING, "ipmbd: listen() failed\n"); exit (1); } while(1) { int n; t = sizeof (remote); + // TODO: Seen accept() call failure and need further debug if ((s2 = accept (s, (struct sockaddr *) &remote, &t)) < 0) { - syslog(LOG_ALERT, "ipmbd: accept() failed\n"); - break; + rc = errno; + syslog(LOG_WARNING, "ipmbd: accept() failed with ret: %x, errno: %x\n", s2, rc); + sleep(5); + continue; } // Creating a worker thread to handle the request @@ -718,7 +753,7 @@ ipmb_lib_handler(void *bus_num) { sfd->fd = fd; sfd->sock = s2; if (pthread_create(&tid, NULL, conn_handler, (void*) sfd) < 0) { - syslog(LOG_ALERT, "ipmbd: pthread_create failed\n"); + syslog(LOG_WARNING, "ipmbd: pthread_create failed\n"); close(s2); continue; } @@ -743,17 +778,20 @@ main(int argc, char * const argv[]) { struct mq_attr attr; char mq_ipmb_req[64] = {0}; char mq_ipmb_res[64] = {0}; + int rc = 0; daemon(1, 0); openlog("ipmbd", LOG_CONS, LOG_DAEMON); if (argc != 2) { - syslog(LOG_ALERT, "ipmbd: Usage: ipmbd <bus#>"); + syslog(LOG_WARNING, "ipmbd: Usage: ipmbd <bus#>"); exit(1); } ipmb_bus_num = atoi(argv[1]); -syslog(LOG_ALERT, "ipmbd: bus#:%d\n", ipmb_bus_num); + g_bus_id = ipmb_bus_num; + + syslog(LOG_WARNING, "ipmbd: bus#:%d\n", ipmb_bus_num); pthread_mutex_init(&m_i2c, NULL); @@ -769,44 +807,44 @@ syslog(LOG_ALERT, "ipmbd: bus#:%d\n", ipmb_bus_num); // Remove the MQ if exists mq_unlink(mq_ipmb_req); - errno = 0; mqd_req = mq_open(mq_ipmb_req, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, &attr); if (mqd_req == (mqd_t) -1) { - syslog(LOG_ALERT, "ipmbd: mq_open request failed errno:%d\n", errno); + rc = errno; + syslog(LOG_WARNING, "ipmbd: mq_open request failed errno:%d\n", rc); goto cleanup; } // Remove the MQ if exists mq_unlink(mq_ipmb_res); - errno = 0; mqd_res = mq_open(mq_ipmb_res, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, &attr); if (mqd_res == (mqd_t) -1) { - syslog(LOG_ALERT, "ipmbd: mq_open response failed errno: %d\n", errno); + rc = errno; + syslog(LOG_WARNING, "ipmbd: mq_open response failed errno: %d\n", rc); goto cleanup; } // Create thread to handle IPMB Requests if (pthread_create(&tid_req_handler, NULL, ipmb_req_handler, (void*) &ipmb_bus_num) < 0) { - syslog(LOG_ALERT, "ipmbd: pthread_create failed\n"); + syslog(LOG_WARNING, "ipmbd: pthread_create failed\n"); goto cleanup; } // Create thread to handle IPMB Responses if (pthread_create(&tid_res_handler, NULL, ipmb_res_handler, (void*) &ipmb_bus_num) < 0) { - syslog(LOG_ALERT, "ipmbd: pthread_create failed\n"); + syslog(LOG_WARNING, "ipmbd: pthread_create failed\n"); goto cleanup; } // Create thread to retrieve ipmb traffic from i2c bus as slave if (pthread_create(&tid_ipmb_rx, NULL, ipmb_rx_handler, (void*) &ipmb_bus_num) < 0) { - syslog(LOG_ALERT, "ipmbd: pthread_create failed\n"); + syslog(LOG_WARNING, "ipmbd: pthread_create failed\n"); goto cleanup; } // Create thread to receive ipmb library requests from apps if (pthread_create(&tid_lib_handler, NULL, ipmb_lib_handler, (void*) &ipmb_bus_num) < 0) { - syslog(LOG_ALERT, "ipmbd: pthread_create failed\n"); + syslog(LOG_WARNING, "ipmbd: pthread_create failed\n"); goto cleanup; } diff --git a/common/recipes-core/ipmid/files/ipmid.c b/common/recipes-core/ipmid/files/ipmid.c index c79d3e2..0930cc2 100644 --- a/common/recipes-core/ipmid/files/ipmid.c +++ b/common/recipes-core/ipmid/files/ipmid.c @@ -35,6 +35,11 @@ #include <sys/un.h> #include <openbmc/ipmi.h> +#define SIZE_IANA_ID 3 +#define SIZE_SYS_GUID 16 + +extern void plat_lan_init(lan_config_t *lan); + // TODO: Once data storage is finalized, the following structure needs // to be retrieved/updated from persistant backend storage static lan_config_t g_lan_config = { 0 }; @@ -245,6 +250,27 @@ app_get_device_guid (unsigned char *response, unsigned char *res_len) *res_len = data - &res->data[0]; } +// Get Device System GUID (IPMI/Section 22.14) +static void +app_get_device_sys_guid (unsigned char *request, unsigned char *response, + unsigned char *res_len) +{ + int ret; + + ipmi_mn_req_t *req = (ipmi_mn_req_t *) request; + ipmi_res_t *res = (ipmi_res_t *) response; + + // Get the 16 bytes of System GUID from PAL library + ret = pal_get_sys_guid(req->payload_id, res->data); + if (ret) { + res->cc = CC_UNSPECIFIED_ERROR; + *res_len = 0x00; + } else { + res->cc = CC_SUCCESS; + *res_len = SIZE_SYS_GUID; + } +} + // Get BMC Global Enables (IPMI/Section 22.2) static void app_get_global_enables (unsigned char *response, unsigned char *res_len) @@ -255,7 +281,7 @@ app_get_global_enables (unsigned char *response, unsigned char *res_len) res->cc = CC_SUCCESS; - *data++ = 0x09; // Global Enable + *data++ = 0x0D; // Global Enable *res_len = data - &res->data[0]; } @@ -279,6 +305,7 @@ app_set_sys_info_params (unsigned char *request, unsigned char *response, break; case SYS_INFO_PARAM_SYSFW_VER: memcpy(g_sys_info_params.sysfw_ver, &req->data[1], SIZE_SYSFW_VER); + pal_set_sysfw_ver(req->payload_id, g_sys_info_params.sysfw_ver); break; case SYS_INFO_PARAM_SYS_NAME: memcpy(g_sys_info_params.sys_name, &req->data[1], SIZE_SYS_NAME); @@ -327,6 +354,7 @@ app_get_sys_info_params (unsigned char *request, unsigned char *response, *data++ = g_sys_info_params.set_in_prog; break; case SYS_INFO_PARAM_SYSFW_VER: + pal_get_sysfw_ver(req->payload_id, g_sys_info_params.sysfw_ver); memcpy(data, g_sys_info_params.sysfw_ver, SIZE_SYSFW_VER); data += SIZE_SYSFW_VER; break; @@ -385,12 +413,11 @@ ipmi_handle_app (unsigned char *request, unsigned char req_len, app_get_selftest_results (response, res_len); break; case CMD_APP_GET_DEVICE_GUID: - case CMD_APP_GET_SYSTEM_GUID: - // Get Device GUID and Get System GUID returns same data - // from IPMI stack. FYI, Get System GUID will have to be - // sent with in an IPMI session that includes session info app_get_device_guid (response, res_len); break; + case CMD_APP_GET_SYSTEM_GUID: + app_get_device_sys_guid (request, response, res_len); + break; case CMD_APP_GET_GLOBAL_ENABLES: app_get_global_enables (response, res_len); break; @@ -558,8 +585,10 @@ storage_get_sdr (unsigned char *request, unsigned char *response, } static void -storage_get_sel_info (unsigned char *response, unsigned char *res_len) +storage_get_sel_info (unsigned char *request, unsigned char *response, + unsigned char *res_len) { + ipmi_mn_req_t *req = (ipmi_mn_req_t *) request; ipmi_res_t *res = (ipmi_res_t *) response; unsigned char *data = &res->data[0]; int num_entries; // number of log entries @@ -568,10 +597,10 @@ storage_get_sel_info (unsigned char *response, unsigned char *res_len) time_stamp_t ts_recent_erase; // Recent Erasure Timestamp // Use platform APIs to get SEL information - num_entries = sel_num_entries (); - free_space = sel_free_space (); - sel_ts_recent_add (&ts_recent_add); - sel_ts_recent_erase (&ts_recent_erase); + num_entries = sel_num_entries (req->payload_id); + free_space = sel_free_space (req->payload_id); + sel_ts_recent_add (req->payload_id, &ts_recent_add); + sel_ts_recent_erase (req->payload_id, &ts_recent_erase); res->cc = CC_SUCCESS; @@ -595,14 +624,16 @@ storage_get_sel_info (unsigned char *response, unsigned char *res_len) } static void -storage_rsv_sel (unsigned char *response, unsigned char *res_len) +storage_rsv_sel (unsigned char * request, unsigned char *response, + unsigned char *res_len) { + ipmi_mn_req_t *req = (ipmi_mn_req_t *) request; ipmi_res_t *res = (ipmi_res_t *) response; unsigned char *data = &res->data[0]; int rsv_id; // SEL reservation ID // Use platform APIs to get a SEL reservation ID - rsv_id = sel_rsv_id (); + rsv_id = sel_rsv_id (req->payload_id); if (rsv_id < 0) { res->cc = CC_SEL_ERASE_PROG; @@ -634,7 +665,7 @@ storage_get_sel (unsigned char *request, unsigned char *response, read_rec_id = (req->data[3] >> 8) | req->data[2]; // Use platform API to read the record Id and get next ID - ret = sel_get_entry (read_rec_id, &entry, &next_rec_id); + ret = sel_get_entry (req->payload_id, read_rec_id, &entry, &next_rec_id); if (ret) { res->cc = CC_UNSPECIFIED_ERROR; @@ -670,7 +701,7 @@ storage_add_sel (unsigned char *request, unsigned char *response, memcpy(entry.msg, req->data, SIZE_SEL_REC); // Use platform APIs to add the new SEL entry - ret = sel_add_entry (&entry, &record_id); + ret = sel_add_entry (req->payload_id, &entry, &record_id); if (ret) { res->cc = CC_UNSPECIFIED_ERROR; @@ -711,11 +742,11 @@ storage_clr_sel (unsigned char *request, unsigned char *response, // Use platform APIs to clear or get status if (req->data[5] == IPMI_SEL_INIT_ERASE) { - ret = sel_erase (rsv_id); + ret = sel_erase (req->payload_id, rsv_id); } else if (req->data[5] == IPMI_SEL_ERASE_STAT) { - ret = sel_erase_status (rsv_id, &status); + ret = sel_erase_status (req->payload_id, rsv_id, &status); } else { @@ -739,6 +770,37 @@ storage_clr_sel (unsigned char *request, unsigned char *response, } static void +storage_get_sel_time (unsigned char *response, unsigned char *res_len) +{ + ipmi_res_t *res = (ipmi_res_t *) response; + + res->cc = CC_SUCCESS; + + time_stamp_fill(res->data); + + *res_len = SIZE_TIME_STAMP; + + return; +} + +static void +storage_get_sel_utc (unsigned char *response, unsigned char *res_len) +{ + ipmi_res_t *res = (ipmi_res_t *) response; + unsigned char *data = &res->data[0]; + + res->cc = CC_SUCCESS; + + // TODO: For now, the SEL time stamp is based on UTC time, + // so return 0x0000 as offset. Might need to change once + // supporting zones in SEL time stamps + *data++ = 0x00; + *data++ = 0x00; + + *res_len = data - &res->data[0]; +} + +static void ipmi_handle_storage (unsigned char *request, unsigned char req_len, unsigned char *response, unsigned char *res_len) { @@ -759,10 +821,10 @@ ipmi_handle_storage (unsigned char *request, unsigned char req_len, storage_get_fruid_data (request, response, res_len); break; case CMD_STORAGE_GET_SEL_INFO: - storage_get_sel_info (response, res_len); + storage_get_sel_info (request, response, res_len); break; case CMD_STORAGE_RSV_SEL: - storage_rsv_sel (response, res_len); + storage_rsv_sel (request, response, res_len); break; case CMD_STORAGE_ADD_SEL: storage_add_sel (request, response, res_len); @@ -773,6 +835,12 @@ ipmi_handle_storage (unsigned char *request, unsigned char req_len, case CMD_STORAGE_CLR_SEL: storage_clr_sel (request, response, res_len); break; + case CMD_STORAGE_GET_SEL_TIME: + storage_get_sel_time (response, res_len); + break; + case CMD_STORAGE_GET_SEL_UTC: + storage_get_sel_utc (response, res_len); + break; case CMD_STORAGE_GET_SDR_INFO: storage_get_sdr_info (response, res_len); break; @@ -871,6 +939,9 @@ transport_set_lan_config (unsigned char *request, unsigned char *response, case LAN_PARAM_DEST_ADDR: memcpy(g_lan_config.dest_addr, &req->data[2], SIZE_DEST_ADDR); break; + case LAN_PARAM_IP6_ADDR: + memcpy(g_lan_config.ip6_addr, &req->data[2], SIZE_IP6_ADDR); + break; default: res->cc = CC_INVALID_PARAM; break; @@ -905,6 +976,7 @@ transport_get_lan_config (unsigned char *request, unsigned char *response, data += SIZE_AUTH_ENABLES; break; case LAN_PARAM_IP_ADDR: + plat_lan_init(&g_lan_config); memcpy(data, g_lan_config.ip_addr, SIZE_IP_ADDR); data += SIZE_IP_ADDR; break; @@ -968,6 +1040,11 @@ transport_get_lan_config (unsigned char *request, unsigned char *response, memcpy(data, g_lan_config.dest_addr, SIZE_DEST_ADDR); data += SIZE_DEST_ADDR; break; + case LAN_PARAM_IP6_ADDR: + plat_lan_init(&g_lan_config); + memcpy(data, g_lan_config.ip6_addr, SIZE_IP6_ADDR); + data += SIZE_IP6_ADDR; + break; default: res->cc = CC_INVALID_PARAM; break; @@ -1070,6 +1147,42 @@ oem_set_post_end (unsigned char *request, unsigned char *response, } static void +oem_get_slot_info(unsigned char *request, unsigned char *response, + unsigned char *res_len) +{ + ipmi_mn_req_t *req = (ipmi_mn_req_t *) request; + ipmi_res_t *res = (ipmi_res_t *) response; + + int ret; + uint8_t pres = 0x00; + uint8_t sinfo = 0x00; + + // Slot info: + // Bit[7]: Not Present/Present (from pal) + // Bit[6]: Platform type (TODO from pal) + // Bit[5-0] : Slot# (payload_id indicates) + ret = pal_is_server_prsnt(req->payload_id, &pres); + if (ret) { + res->cc = CC_UNSPECIFIED_ERROR; + *res_len = 0x00; + return; + } + + // Populate the presence bit[7] + if (pres) { + sinfo = 0x80; + } + + // Populate the slot number + sinfo |= req->payload_id; + + // Prepare response buffer + res->cc = CC_SUCCESS; + res->data[0] = sinfo; + *res_len = 0x01; +} + +static void ipmi_handle_oem (unsigned char *request, unsigned char req_len, unsigned char *response, unsigned char *res_len) { @@ -1093,6 +1206,9 @@ ipmi_handle_oem (unsigned char *request, unsigned char req_len, case CMD_OEM_SET_POST_END: oem_set_post_end (request, response, res_len); break; + case CMD_OEM_GET_SLOT_INFO: + oem_get_slot_info (request, response, res_len); + break; default: res->cc = CC_INVALID_CMD; break; @@ -1114,21 +1230,22 @@ oem_1s_handle_ipmb_kcs(unsigned char *request, unsigned char req_len, // Add the payload id from the bridged command req_buf[0] = req->payload_id; - // Remove OEM IPMI Header + 1 byte for BIC interface + // Remove OEM IPMI Header (including 1 byte for interface type, 3 bytes for IANA ID) // The offset moves by one due to the payload ID - memcpy(&req_buf[1], &request[BIC_INTF_HDR_SIZE + 1], req_len - BIC_INTF_HDR_SIZE); + memcpy(&req_buf[1], &request[BIC_INTF_HDR_SIZE], req_len - BIC_INTF_HDR_SIZE + 1); // Send the bridged KCS command along with the payload ID // The offset moves by one due to the payload ID ipmi_handle(req_buf, req_len - BIC_INTF_HDR_SIZE + 1, res_buf, res_len); - // Copy the response back - memcpy(&res->data[1], res_buf, *res_len); + // Copy the response back (1 byte interface type, 3 bytes for IANA ID) + memcpy(&res->data[4], res_buf, *res_len); // Add the OEM command's response res->cc = CC_SUCCESS; - res->data[0] = req->data[0]; // Bridge-IC interface - *res_len += 1; + memcpy(res->data, &req->data, SIZE_IANA_ID); // IANA ID + res->data[3] = req->data[3]; // Bridge-IC interface + *res_len += 4; // Interface type + IANA ID } static void @@ -1139,32 +1256,38 @@ oem_1s_handle_ipmb_req(unsigned char *request, unsigned char req_len, ipmi_res_t *res = (ipmi_res_t *) response; // handle based on Bridge-IC interface - switch(req->data[0]) { + switch(req->data[3]) { case BIC_INTF_ME: // TODO: Need to call ME command handler +#ifdef DEBUG syslog(LOG_INFO, "oem_1s_handle_ipmb_req: Command received from ME for " "payload#%d\n", req->payload_id); - res->data[0] = BIC_INTF_ME; +#endif + memcpy(res->data, req->data, 4); //IANA ID + Interface type res->cc = CC_SUCCESS; - *res_len = 1; + *res_len = 4; break; case BIC_INTF_SOL: // TODO: Need to call Optional SoL message handler +#ifdef DEBUG syslog(LOG_INFO, "oem_1s_handle_ipmb_req: Command received from SOL for " "payload#%d\n", req->payload_id); - res->data[0] = BIC_INTF_SOL; +#endif + memcpy(res->data, req->data, 4); //IANA ID + Interface type res->cc = CC_SUCCESS; - *res_len = 1; + *res_len = 4; break; case BIC_INTF_KCS: + case BIC_INTF_KCS_SMM: oem_1s_handle_ipmb_kcs(request, req_len, response, res_len); break; default: // TODO: Need to add additonal interface handler, if supported - syslog(LOG_ALERT, "oem_1s_handle_ipmb_req: Command received on intf#%d " - "for payload#%d", req->data[0], req->payload_id); + syslog(LOG_WARNING, "oem_1s_handle_ipmb_req: Command received on intf#%d " + "for payload#%d", req->data[3], req->payload_id); + memcpy(res->data, req->data, 4); //IANA ID + Interface type res->cc = CC_INVALID_PARAM; - *res_len = 0; + *res_len = 4; break; } } @@ -1187,62 +1310,70 @@ ipmi_handle_oem_1s(unsigned char *request, unsigned char req_len, break; case CMD_OEM_1S_INTR: syslog(LOG_INFO, "ipmi_handle_oem_1s: 1S server interrupt#%d received " - "for payload#%d\n", req->data[0], req->payload_id); + "for payload#%d\n", req->data[3], req->payload_id); res->cc = CC_SUCCESS; - *res_len = 0; + memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID + *res_len = 3; break; case CMD_OEM_1S_POST_BUF: - for (i = 1; i <= req->data[0]; i++) { + // Skip the first 3 bytes of IANA ID and one byte of length field + for (i = SIZE_IANA_ID+1; i <= req->data[3]; i++) { pal_post_handle(req->payload_id, req->data[i]); } res->cc = CC_SUCCESS; - *res_len = 0; + memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID + *res_len = 3; break; case CMD_OEM_1S_PLAT_DISC: syslog(LOG_INFO, "ipmi_handle_oem_1s: Platform Discovery received for " "payload#%d\n", req->payload_id); res->cc = CC_SUCCESS; - *res_len = 0; + memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID + *res_len = 3; break; case CMD_OEM_1S_BIC_RESET: syslog(LOG_INFO, "ipmi_handle_oem_1s: BIC Reset received " "for payload#%d\n", req->payload_id); - if (req->data[0] == 0x0) { - syslog(LOG_ALERT, "Cold Reset by Firmware Update\n"); + if (req->data[3] == 0x0) { + syslog(LOG_WARNING, "Cold Reset by Firmware Update\n"); res->cc = CC_SUCCESS; - } else if (req->data[1] == 0x01) { - syslog(LOG_ALERT, "WDT Reset\n"); + } else if (req->data[3] == 0x01) { + syslog(LOG_WARNING, "WDT Reset\n"); res->cc = CC_SUCCESS; } else { - syslog(LOG_ALERT, "Error\n"); + syslog(LOG_WARNING, "Error\n"); res->cc = CC_INVALID_PARAM; } - *res_len = 0; + memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID + *res_len = 3; break; case CMD_OEM_1S_BIC_UPDATE_MODE: +#ifdef DEBUG syslog(LOG_INFO, "ipmi_handle_oem_1s: BIC Update Mode received " "for payload#%d\n", req->payload_id); - - if (req->data[0] == 0x0) { +#endif + if (req->data[3] == 0x0) { syslog(LOG_INFO, "Normal Mode\n"); res->cc = CC_SUCCESS; - } else if (req->data[1] == 0x0F) { + } else if (req->data[3] == 0x0F) { syslog(LOG_INFO, "Update Mode\n"); res->cc = CC_SUCCESS; } else { - syslog(LOG_ALERT, "Error\n"); + syslog(LOG_WARNING, "Error\n"); res->cc = CC_INVALID_PARAM; } - *res_len = 0; + memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID + *res_len = 3; break; default: res->cc = CC_INVALID_CMD; - *res_len = 0; + memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID + *res_len = 3; break; } pthread_mutex_unlock(&m_oem_1s); @@ -1306,26 +1437,37 @@ ipmi_handle (unsigned char *request, unsigned char req_len, void *conn_handler(void *socket_desc) { - int sock = *(int*)socket_desc; + int *p_sock = (int*)socket_desc; + int sock = *p_sock; int n; unsigned char req_buf[MAX_IPMI_MSG_SIZE]; unsigned char res_buf[MAX_IPMI_MSG_SIZE]; unsigned char res_len = 0; + struct timeval tv; + int rc = 0; + + // setup timeout for receving on socket + tv.tv_sec = TIMEOUT_IPMI; + tv.tv_usec = 0; + + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval)); n = recv (sock, req_buf, sizeof(req_buf), 0); + rc = errno; if (n <= 0) { - syslog(LOG_ALERT, "ipmid: recv() failed with %d\n", n); + syslog(LOG_WARNING, "ipmid: recv() failed with %d, errno: %d\n", n, rc); goto conn_cleanup; } ipmi_handle(req_buf, n, res_buf, &res_len); if (send (sock, res_buf, res_len, 0) < 0) { - syslog(LOG_ALERT, "ipmid: send() failed\n"); + syslog(LOG_WARNING, "ipmid: send() failed\n"); } conn_cleanup: close(sock); + free(p_sock); pthread_exit(NULL); return 0; @@ -1338,13 +1480,16 @@ main (void) int s, s2, t, len; struct sockaddr_un local, remote; pthread_t tid; + int *p_s2; + int rc = 0; - daemon(1, 0); + daemon(1, 1); openlog("ipmid", LOG_CONS, LOG_DAEMON); plat_fruid_init(); plat_sensor_init(); + plat_lan_init(&g_lan_config); sdr_init(); sel_init(); @@ -1358,7 +1503,7 @@ main (void) if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ALERT, "ipmid: socket() failed\n"); + syslog(LOG_WARNING, "ipmid: socket() failed\n"); exit (1); } @@ -1368,30 +1513,35 @@ main (void) len = strlen (local.sun_path) + sizeof (local.sun_family); if (bind (s, (struct sockaddr *) &local, len) == -1) { - syslog(LOG_ALERT, "ipmid: bind() failed\n"); + syslog(LOG_WARNING, "ipmid: bind() failed\n"); exit (1); } if (listen (s, 5) == -1) { - syslog(LOG_ALERT, "ipmid: listen() failed\n"); + syslog(LOG_WARNING, "ipmid: listen() failed\n"); exit (1); } while(1) { int n; t = sizeof (remote); + // TODO: seen accept() call fails and need further debug if ((s2 = accept (s, (struct sockaddr *) &remote, &t)) < 0) { - syslog(LOG_ALERT, "ipmid: accept() failed\n"); - break; + rc = errno; + syslog(LOG_WARNING, "ipmid: accept() failed with ret: %x, errno: %x\n", s2, rc); + sleep(5); + continue; } // Creating a worker thread to handle the request // TODO: Need to monitor the server performance with higher load and // see if we need to create pre-defined number of workers and schedule // the requests among them. - if (pthread_create(&tid, NULL, conn_handler, (void*) &s2) < 0) { - syslog(LOG_ALERT, "ipmid: pthread_create failed\n"); + p_s2 = malloc(sizeof(int)); + *p_s2 = s2; + if (pthread_create(&tid, NULL, conn_handler, (void*) p_s2) < 0) { + syslog(LOG_WARNING, "ipmid: pthread_create failed\n"); close(s2); continue; } diff --git a/common/recipes-core/ipmid/files/sdr.c b/common/recipes-core/ipmid/files/sdr.c index 91a4df5..78d74c3 100644 --- a/common/recipes-core/ipmid/files/sdr.c +++ b/common/recipes-core/ipmid/files/sdr.c @@ -88,7 +88,7 @@ static int sdr_add_entry(sdr_rec_t *rec, int *rec_id) { // If SDR is full, return error if (sdr_num_entries() == SDR_RECORDS_MAX) { - syslog(LOG_ALERT, "sdr_add_entry: SDR full\n"); + syslog(LOG_WARNING, "sdr_add_entry: SDR full\n"); return -1; } @@ -137,7 +137,7 @@ sdr_add_mgmt_rec(sensor_mgmt_t *p_rec) { // Add this record to SDR repo if (sdr_add_entry(&sdr, &rec_id)) { - syslog(LOG_ALERT, "sdr_add_mgmt_rec: sdr_add_entry failed\n"); + syslog(LOG_WARNING, "sdr_add_mgmt_rec: sdr_add_entry failed\n"); return -1; } @@ -176,7 +176,7 @@ sdr_add_disc_rec(sensor_disc_t *p_rec) { // Add this record to SDR repo if (sdr_add_entry(&sdr, &rec_id)) { - syslog(LOG_ALERT, "sdr_add_disc_rec: sdr_add_entry failed\n"); + syslog(LOG_WARNING, "sdr_add_disc_rec: sdr_add_entry failed\n"); return -1; } @@ -237,7 +237,7 @@ sdr_add_thresh_rec(sensor_thresh_t *p_rec) { // Add this record to SDR repo if (sdr_add_entry(&sdr, &rec_id)) { - syslog(LOG_ALERT, "sdr_add_thresh_rec: sdr_add_entry failed\n"); + syslog(LOG_WARNING, "sdr_add_thresh_rec: sdr_add_entry failed\n"); return -1; } @@ -263,7 +263,7 @@ sdr_add_oem_rec(sensor_oem_t *p_rec) { // Add this record to SDR repo if (sdr_add_entry(&sdr, &rec_id)) { - syslog(LOG_ALERT, "sdr_add_oem_rec: sdr_add_entry failed\n"); + syslog(LOG_WARNING, "sdr_add_oem_rec: sdr_add_entry failed\n"); return -1; } @@ -323,7 +323,7 @@ sdr_get_entry(int rsv_id, int read_rec_id, sdr_rec_t *rec, // Make sure the rsv_id matches if (rsv_id != g_rsv_id) { - syslog(LOG_ALERT, "sdr_get_entry: Reservation ID mismatch\n"); + syslog(LOG_WARNING, "sdr_get_entry: Reservation ID mismatch\n"); return -1; } @@ -338,19 +338,19 @@ sdr_get_entry(int rsv_id, int read_rec_id, sdr_rec_t *rec, // If the SDR repo is empty return error if (sdr_num_entries() == 0) { - syslog(LOG_ALERT, "sdr_get_entry: No entries\n"); + syslog(LOG_WARNING, "sdr_get_entry: No entries\n"); return -1; } // Check for boundary conditions if ((index < SDR_INDEX_MIN) || (index > SDR_INDEX_MAX)) { - syslog(LOG_ALERT, "sdr_get_entry: Invalid Record ID %d\n", read_rec_id); + syslog(LOG_WARNING, "sdr_get_entry: Invalid Record ID %d\n", read_rec_id); return -1; } // Check to make sure the given id is valid if (index < g_sdr_hdr.begin || index >= g_sdr_hdr.end) { - syslog(LOG_ALERT, "sdr_get_entry: Wrong Record ID %d\n", read_rec_id); + syslog(LOG_WARNING, "sdr_get_entry: Wrong Record ID %d\n", read_rec_id); return -1; } diff --git a/common/recipes-core/ipmid/files/sel.c b/common/recipes-core/ipmid/files/sel.c index d598bb1..1b45b42 100644 --- a/common/recipes-core/ipmid/files/sel.c +++ b/common/recipes-core/ipmid/files/sel.c @@ -31,9 +31,19 @@ #include <errno.h> #include <syslog.h> #include <string.h> +#include <stdint.h> +#include <sys/types.h> + + +#if defined(CONFIG_YOSEMITE) +#define MAX_NODES 4 +#else +#define MAX_NODES 1 +#endif // SEL File. -#define SEL_LOG_FILE "/mnt/data/sel.bin" +#define SEL_LOG_FILE "/mnt/data/sel%d.bin" +#define SIZE_PATH_MAX 32 // SEL Header magic number #define SEL_HDR_MAGIC 0xFBFBFBFB @@ -75,24 +85,27 @@ typedef struct { } sel_hdr_t; // Keep track of last Reservation ID -static int g_rsv_id = 0x01; +static int g_rsv_id[MAX_NODES+1]; // Cached version of SEL Header and data -static sel_hdr_t g_sel_hdr; -static sel_msg_t g_sel_data[SEL_ELEMS_MAX]; +static sel_hdr_t g_sel_hdr[MAX_NODES+1]; +static sel_msg_t g_sel_data[MAX_NODES+1][SEL_ELEMS_MAX]; // Local helper functions to interact with file system static int -file_get_sel_hdr(void) { +file_get_sel_hdr(int node) { FILE *fp; + char fpath[SIZE_PATH_MAX] = {0}; + + sprintf(fpath, SEL_LOG_FILE, node); - fp = fopen(SEL_LOG_FILE, "r"); + fp = fopen(fpath, "r"); if (fp == NULL) { return -1; } - if (fread(&g_sel_hdr, sizeof(sel_hdr_t), 1, fp) <= 0) { - syslog(LOG_ALERT, "file_get_sel_hdr: fread\n"); + if (fread(&g_sel_hdr[node], sizeof(sel_hdr_t), 1, fp) <= 0) { + syslog(LOG_WARNING, "file_get_sel_hdr: fread\n"); fclose (fp); return -1; } @@ -102,25 +115,28 @@ file_get_sel_hdr(void) { } static int -file_get_sel_data(void) { +file_get_sel_data(int node) { FILE *fp; int i, j; + char fpath[SIZE_PATH_MAX] = {0}; - fp = fopen(SEL_LOG_FILE, "r"); + sprintf(fpath, SEL_LOG_FILE, node); + + fp = fopen(fpath, "r"); if (fp == NULL) { - syslog(LOG_ALERT, "file_get_sel_data: fopen\n"); + syslog(LOG_WARNING, "file_get_sel_data: fopen\n"); return -1; } if (fseek(fp, SEL_DATA_OFFSET, SEEK_SET)) { - syslog(LOG_ALERT, "file_get_sel_data: fseek\n"); + syslog(LOG_WARNING, "file_get_sel_data: fseek\n"); fclose(fp); return -1; } unsigned char buf[SEL_ELEMS_MAX * 16]; if (fread(buf, 1, SEL_ELEMS_MAX * sizeof(sel_msg_t), fp) <= 0) { - syslog(LOG_ALERT, "file_get_sel_data: fread\n"); + syslog(LOG_WARNING, "file_get_sel_data: fread\n"); fclose(fp); return -1; } @@ -129,7 +145,7 @@ file_get_sel_data(void) { for (i = 0; i < SEL_ELEMS_MAX; i++) { for (j = 0; j < sizeof(sel_msg_t);j++) { - g_sel_data[i].msg[j] = buf[i*16 + j]; + g_sel_data[node][i].msg[j] = buf[i*16 + j]; } } @@ -137,17 +153,20 @@ file_get_sel_data(void) { } static int -file_store_sel_hdr(void) { +file_store_sel_hdr(int node) { FILE *fp; + char fpath[SIZE_PATH_MAX] = {0}; + + sprintf(fpath, SEL_LOG_FILE, node); - fp = fopen(SEL_LOG_FILE, "r+"); + fp = fopen(fpath, "r+"); if (fp == NULL) { - syslog(LOG_ALERT, "file_store_sel_hdr: fopen\n"); + syslog(LOG_WARNING, "file_store_sel_hdr: fopen\n"); return -1; } - if (fwrite(&g_sel_hdr, sizeof(sel_hdr_t), 1, fp) <= 0) { - syslog(LOG_ALERT, "file_store_sel_hdr: fwrite\n"); + if (fwrite(&g_sel_hdr[node], sizeof(sel_hdr_t), 1, fp) <= 0) { + syslog(LOG_WARNING, "file_store_sel_hdr: fwrite\n"); fclose(fp); return -1; } @@ -158,13 +177,16 @@ file_store_sel_hdr(void) { } static int -file_store_sel_data(int recId, sel_msg_t *data) { +file_store_sel_data(int node, int recId, sel_msg_t *data) { FILE *fp; int index; + char fpath[SIZE_PATH_MAX] = {0}; - fp = fopen(SEL_LOG_FILE, "r+"); + sprintf(fpath, SEL_LOG_FILE, node); + + fp = fopen(fpath, "r+"); if (fp == NULL) { - syslog(LOG_ALERT, "file_store_sel_data: fopen\n"); + syslog(LOG_WARNING, "file_store_sel_data: fopen\n"); return -1; } @@ -172,13 +194,13 @@ file_store_sel_data(int recId, sel_msg_t *data) { index = (recId-1) * sizeof(sel_msg_t); if (fseek(fp, SEL_DATA_OFFSET+index, SEEK_SET)) { - syslog(LOG_ALERT, "file_store_sel_data: fseek\n"); + syslog(LOG_WARNING, "file_store_sel_data: fseek\n"); fclose(fp); return -1; } if (fwrite(data->msg, sizeof(sel_msg_t), 1, fp) <= 0) { - syslog(LOG_ALERT, "file_store_sel_data: fwrite\n"); + syslog(LOG_WARNING, "file_store_sel_data: fwrite\n"); fclose(fp); return -1; } @@ -188,37 +210,103 @@ file_store_sel_data(int recId, sel_msg_t *data) { return 0; } +static void +dump_sel_syslog(int fru, sel_msg_t *data) { + int i = 0; + char temp_str[8] = {0}; + char str[128] = {0}; + + for (i = 0; i < 15; i++) { + sprintf(temp_str, "%02X:", data->msg[i]); + strcat(str, temp_str); + } + sprintf(temp_str, "%02X", data->msg[15]); + strcat(str, temp_str); + + syslog(LOG_CRIT, "SEL Entry, FRU: %d, Content: %s\n", fru, str); +} + +static void +parse_sel(uint8_t fru, sel_msg_t *data) { + int i = 0; + uint32_t timestamp; + char *sel = data->msg; + uint8_t sensor_type; + uint8_t sensor_num; + uint8_t event_dir; + uint8_t type_num; + uint8_t event_data[3]; + char sensor_name[32]; + char error_log[64]; + char error_type[64]; + char status[16]; + int ret; + + //memcpy(timestamp, (uint8_t *) &sel[3], 4); + timestamp = 0; + timestamp |= sel[3]; + timestamp |= sel[4] << 8; + timestamp |= sel[5] << 16; + timestamp |= sel[6] << 24; + + sensor_type = (uint8_t) sel[10]; + sensor_num = (uint8_t) sel[11]; + event_dir = ((uint8_t) sel[12] & (1 << 7)) >> 7; /* Bit 7 of sel[12] */ + type_num = (uint8_t) sel[12]; /* Bits 6:0 */ + memcpy(event_data, (uint8_t *) &sel[13], 3); + + sprintf(status, event_dir ? "DEASSERT" : "ASSERT"); + + if (type_num == 0x1) { + sprintf(error_type, "Threshold"); + } else if (type_num >= 0x2 || type_num <= 0xC || type_num == 0x6F) { + sprintf(error_type, "Discrete"); + } else if (type_num >= 0x70 || type_num <= 0x7F) { + sprintf(error_type, "OEM"); + } else { + sprintf(error_type, "Unknown"); + } + + ret = pal_get_event_sensor_name(fru, sensor_num, sensor_name); + ret = pal_parse_sel(fru, sensor_num, event_data, error_log); + ret = pal_sel_handler(fru, sensor_num); + + syslog(LOG_CRIT, "SEL Entry, %s: FRU: %d, Sensor: 0x%X, Name: %s," + " Timestamp: %u, Event Type: %s, Event Data: %s", + status, fru, sensor_num, sensor_name, timestamp, error_type, error_log); +} + // Platform specific SEL API entry points // Retrieve time stamp for recent add operation void -sel_ts_recent_add(time_stamp_t *ts) { - memcpy(ts->ts, g_sel_hdr.ts_add.ts, 0x04); +sel_ts_recent_add(int node, time_stamp_t *ts) { + memcpy(ts->ts, g_sel_hdr[node].ts_add.ts, 0x04); } // Retrieve time stamp for recent erase operation void -sel_ts_recent_erase(time_stamp_t *ts) { - memcpy(ts->ts, g_sel_hdr.ts_erase.ts, 0x04); +sel_ts_recent_erase(int node, time_stamp_t *ts) { + memcpy(ts->ts, g_sel_hdr[node].ts_erase.ts, 0x04); } // Retrieve total number of entries in SEL log int -sel_num_entries(void) { - if (g_sel_hdr.begin <= g_sel_hdr.end) { - return (g_sel_hdr.end - g_sel_hdr.begin); +sel_num_entries(int node) { + if (g_sel_hdr[node].begin <= g_sel_hdr[node].end) { + return (g_sel_hdr[node].end - g_sel_hdr[node].begin); } else { - return (g_sel_hdr.end + (SEL_INDEX_MAX - g_sel_hdr.begin + 1)); + return (g_sel_hdr[node].end + (SEL_INDEX_MAX - g_sel_hdr[node].begin + 1)); } } // Retrieve total free space available in SEL log int -sel_free_space(void) { +sel_free_space(int node) { int total_space; int used_space; total_space = SEL_RECORDS_MAX * sizeof(sel_msg_t); - used_space = sel_num_entries() * sizeof(sel_msg_t); + used_space = sel_num_entries(node) * sizeof(sel_msg_t); return (total_space - used_space); } @@ -226,28 +314,28 @@ sel_free_space(void) { // Reserve an ID that will be used in later operations // IPMI/Section 31.4 int -sel_rsv_id() { +sel_rsv_id(int node) { // Increment the current reservation ID and return - if (g_rsv_id++ == SEL_RSVID_MAX) { - g_rsv_id = SEL_RSVID_MIN; + if (g_rsv_id[node]++ == SEL_RSVID_MAX) { + g_rsv_id[node] = SEL_RSVID_MIN; } - return g_rsv_id; + return g_rsv_id[node]; } // Get the SEL entry for a given record ID // IPMI/Section 31.5 int -sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) { +sel_get_entry(int node, int read_rec_id, sel_msg_t *msg, int *next_rec_id) { int index; // Find the index in to array based on given index if (read_rec_id == SEL_RECID_FIRST) { - index = g_sel_hdr.begin; + index = g_sel_hdr[node].begin; } else if (read_rec_id == SEL_RECID_LAST) { - if (g_sel_hdr.end) { - index = g_sel_hdr.end - 1; + if (g_sel_hdr[node].end) { + index = g_sel_hdr[node].end - 1; } else { index = SEL_INDEX_MAX; } @@ -256,34 +344,34 @@ sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) { } // If the log is empty return error - if (sel_num_entries() == 0) { - syslog(LOG_ALERT, "sel_get_entry: No entries\n"); + if (sel_num_entries(node) == 0) { + syslog(LOG_WARNING, "sel_get_entry: No entries\n"); return -1; } // Check for boundary conditions if ((index < SEL_INDEX_MIN) || (index > SEL_INDEX_MAX)) { - syslog(LOG_ALERT, "sel_get_entry: Invalid Record ID %d\n", read_rec_id); + syslog(LOG_WARNING, "sel_get_entry: Invalid Record ID %d\n", read_rec_id); return -1; } // If begin < end, check to make sure the given id falls between - if (g_sel_hdr.begin < g_sel_hdr.end) { - if (index < g_sel_hdr.begin || index >= g_sel_hdr.end) { - syslog(LOG_ALERT, "sel_get_entry: Wrong Record ID %d\n", read_rec_id); + if (g_sel_hdr[node].begin < g_sel_hdr[node].end) { + if (index < g_sel_hdr[node].begin || index >= g_sel_hdr[node].end) { + syslog(LOG_WARNING, "sel_get_entry: Wrong Record ID %d\n", read_rec_id); return -1; } } // If end < begin, check to make sure the given id is valid - if (g_sel_hdr.begin > g_sel_hdr.end) { - if (index >= g_sel_hdr.end && index < g_sel_hdr.begin) { - syslog(LOG_ALERT, "sel_get_entry: Wrong Record ID2 %d\n", read_rec_id); + if (g_sel_hdr[node].begin > g_sel_hdr[node].end) { + if (index >= g_sel_hdr[node].end && index < g_sel_hdr[node].begin) { + syslog(LOG_WARNING, "sel_get_entry: Wrong Record ID2 %d\n", read_rec_id); return -1; } } - memcpy(msg->msg, g_sel_data[index].msg, sizeof(sel_msg_t)); + memcpy(msg->msg, g_sel_data[node][index].msg, sizeof(sel_msg_t)); // Return the next record ID in the log *next_rec_id = read_rec_id++; @@ -292,7 +380,7 @@ sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) { } // If this is the last entry in the log, return 0xFFFF - if (*next_rec_id == g_sel_hdr.end) { + if (*next_rec_id == g_sel_hdr[node].end) { *next_rec_id = SEL_RECID_LAST; } @@ -302,13 +390,13 @@ sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) { // Add a new entry in to SEL log // IPMI/Section 31.6 int -sel_add_entry(sel_msg_t *msg, int *rec_id) { +sel_add_entry(int node, sel_msg_t *msg, int *rec_id) { // If the SEL if full, roll over. To keep track of empty condition, use // one empty location less than the max records. - if (sel_num_entries() == SEL_RECORDS_MAX) { - syslog(LOG_ALERT, "sel_add_entry: SEL rollover\n"); - if (++g_sel_hdr.begin > SEL_INDEX_MAX) { - g_sel_hdr.begin = SEL_INDEX_MIN; + if (sel_num_entries(node) == SEL_RECORDS_MAX) { + syslog(LOG_WARNING, "sel_add_entry: SEL rollover\n"); + if (++g_sel_hdr[node].begin > SEL_INDEX_MAX) { + g_sel_hdr[node].begin = SEL_INDEX_MIN; } } @@ -316,27 +404,33 @@ sel_add_entry(sel_msg_t *msg, int *rec_id) { time_stamp_fill(&msg->msg[3]); // Add the enry at end - memcpy(g_sel_data[g_sel_hdr.end].msg, msg->msg, sizeof(sel_msg_t)); + memcpy(g_sel_data[node][g_sel_hdr[node].end].msg, msg->msg, sizeof(sel_msg_t)); // Return the newly added record ID - *rec_id = g_sel_hdr.end+1; + *rec_id = g_sel_hdr[node].end+1; - if (file_store_sel_data(*rec_id, msg)) { - syslog(LOG_ALERT, "sel_add_entry: file_store_sel_data\n"); + // Print the data in syslog + dump_sel_syslog(node, msg); + + // Parse the SEL message + parse_sel((uint8_t) node, msg); + + if (file_store_sel_data(node, *rec_id, msg)) { + syslog(LOG_WARNING, "sel_add_entry: file_store_sel_data\n"); return -1; } // Increment the end pointer - if (++g_sel_hdr.end > SEL_INDEX_MAX) { - g_sel_hdr.end = SEL_INDEX_MIN; + if (++g_sel_hdr[node].end > SEL_INDEX_MAX) { + g_sel_hdr[node].end = SEL_INDEX_MIN; } // Update timestamp for add in header - time_stamp_fill(g_sel_hdr.ts_add.ts); + time_stamp_fill(g_sel_hdr[node].ts_add.ts); // Store the structure persistently - if (file_store_sel_hdr()) { - syslog(LOG_ALERT, "sel_add_entry: file_store_sel_hdr\n"); + if (file_store_sel_hdr(node)) { + syslog(LOG_WARNING, "sel_add_entry: file_store_sel_hdr\n"); return -1; } @@ -347,21 +441,21 @@ sel_add_entry(sel_msg_t *msg, int *rec_id) { // IPMI/Section 31.9 // Note: To reduce wear/tear, instead of erasing, manipulating the metadata int -sel_erase(int rsv_id) { - if (rsv_id != g_rsv_id) { +sel_erase(int node, int rsv_id) { + if (rsv_id != g_rsv_id[node]) { return -1; } // Erase SEL Logs - g_sel_hdr.begin = SEL_INDEX_MIN; - g_sel_hdr.end = SEL_INDEX_MIN; + g_sel_hdr[node].begin = SEL_INDEX_MIN; + g_sel_hdr[node].end = SEL_INDEX_MIN; // Update timestamp for erase in header - time_stamp_fill(g_sel_hdr.ts_erase.ts); + time_stamp_fill(g_sel_hdr[node].ts_erase.ts); // Store the structure persistently - if (file_store_sel_hdr()) { - syslog(LOG_ALERT, "sel_erase: file_store_sel_hdr\n"); + if (file_store_sel_hdr(node)) { + syslog(LOG_WARNING, "sel_erase: file_store_sel_hdr\n"); return -1; } @@ -372,8 +466,8 @@ sel_erase(int rsv_id) { // IPMI/Section 31.2 // Note: Since we are not doing offline erasing, need not return in-progress state int -sel_erase_status(int rsv_id, sel_erase_stat_t *status) { - if (rsv_id != g_rsv_id) { +sel_erase_status(int node, int rsv_id, sel_erase_stat_t *status) { + if (rsv_id != g_rsv_id[node]) { return -1; } @@ -384,21 +478,24 @@ sel_erase_status(int rsv_id, sel_erase_stat_t *status) { } // Initialize SEL log file -int -sel_init(void) { +static int +sel_node_init(int node) { FILE *fp; int i; + char fpath[SIZE_PATH_MAX] = {0}; + + sprintf(fpath, SEL_LOG_FILE, node); // Check if the file exists or not - if (access(SEL_LOG_FILE, F_OK) == 0) { + if (access(fpath, F_OK) == 0) { // Since file is present, fetch all the contents to cache - if (file_get_sel_hdr()) { - syslog(LOG_ALERT, "init_sel: file_get_sel_hdr\n"); + if (file_get_sel_hdr(node)) { + syslog(LOG_WARNING, "init_sel: file_get_sel_hdr\n"); return -1; } - if (file_get_sel_data()) { - syslog(LOG_ALERT, "init_sel: file_get_sel_data\n"); + if (file_get_sel_data(node)) { + syslog(LOG_WARNING, "init_sel: file_get_sel_data\n"); return -1; } @@ -406,35 +503,52 @@ sel_init(void) { } // File not present, so create the file - fp = fopen(SEL_LOG_FILE, "w+"); + fp = fopen(fpath, "w+"); if (fp == NULL) { - syslog(LOG_ALERT, "init_sel: fopen\n"); + syslog(LOG_WARNING, "init_sel: fopen\n"); return -1; } fclose (fp); // Populate SEL Header in to the file - g_sel_hdr.magic = SEL_HDR_MAGIC; - g_sel_hdr.version = SEL_HDR_VERSION; - g_sel_hdr.begin = SEL_INDEX_MIN; - g_sel_hdr.end = SEL_INDEX_MIN; - memset(g_sel_hdr.ts_add.ts, 0x0, 4); - memset(g_sel_hdr.ts_erase.ts, 0x0, 4); - - if (file_store_sel_hdr()) { - syslog(LOG_ALERT, "init_sel: file_store_sel_hdr\n"); + g_sel_hdr[node].magic = SEL_HDR_MAGIC; + g_sel_hdr[node].version = SEL_HDR_VERSION; + g_sel_hdr[node].begin = SEL_INDEX_MIN; + g_sel_hdr[node].end = SEL_INDEX_MIN; + memset(g_sel_hdr[node].ts_add.ts, 0x0, 4); + memset(g_sel_hdr[node].ts_erase.ts, 0x0, 4); + + if (file_store_sel_hdr(node)) { + syslog(LOG_WARNING, "init_sel: file_store_sel_hdr\n"); return -1; } // Populate SEL Data in to the file for (i = 1; i <= SEL_RECORDS_MAX; i++) { sel_msg_t msg = {0}; - if (file_store_sel_data(i, &msg)) { - syslog(LOG_ALERT, "init_sel: file_store_sel_data\n"); + if (file_store_sel_data(node, i, &msg)) { + syslog(LOG_WARNING, "init_sel: file_store_sel_data\n"); return -1; } } + g_rsv_id[node] = 0x01; + return 0; } + +int +sel_init(void) { + int ret; + int i; + + for (i = 1; i < MAX_NODES+1; i++) { + ret = sel_node_init(i); + if (ret) { + return ret; + } + } + + return ret; +} diff --git a/common/recipes-core/ipmid/files/sel.h b/common/recipes-core/ipmid/files/sel.h index 3bb9a2f..500b078 100644 --- a/common/recipes-core/ipmid/files/sel.h +++ b/common/recipes-core/ipmid/files/sel.h @@ -37,15 +37,15 @@ typedef struct { unsigned char msg[16]; } sel_msg_t; -void sel_ts_recent_add(time_stamp_t *ts); -void sel_ts_recent_erase(time_stamp_t *ts); -int sel_num_entries(void); -int sel_free_space(void); -int sel_rsv_id(); -int sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id); -int sel_add_entry(sel_msg_t *msg, int *rec_id); -int sel_erase(int rsv_id); -int sel_erase_status(int rsv_id, sel_erase_stat_t *status); +void sel_ts_recent_add(int node, time_stamp_t *ts); +void sel_ts_recent_erase(int node, time_stamp_t *ts); +int sel_num_entries(int node); +int sel_free_space(int node); +int sel_rsv_id(int node); +int sel_get_entry(int node, int read_rec_id, sel_msg_t *msg, int *next_rec_id); +int sel_add_entry(int node, sel_msg_t *msg, int *rec_id); +int sel_erase(int node, int rsv_id); +int sel_erase_status(int node, int rsv_id, sel_erase_stat_t *status); int sel_init(void); #endif /* __SEL_H__ */ diff --git a/common/recipes-core/log-util/files/lib_pal.py b/common/recipes-core/log-util/files/lib_pal.py new file mode 100644 index 0000000..dcae08a --- /dev/null +++ b/common/recipes-core/log-util/files/lib_pal.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +from ctypes import * + +lpal_hndl = CDLL("libpal.so") + +def pal_get_fru_name(fru): + name = create_string_buffer(16) + ret = lpal_hndl.pal_get_fru_name(c_uint8(fru), name) + if ret: + return None + else: + return name.value diff --git a/common/recipes-core/log-util/files/log-util.py b/common/recipes-core/log-util/files/log-util.py new file mode 100644 index 0000000..565e9a1 --- /dev/null +++ b/common/recipes-core/log-util/files/log-util.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +import re +from datetime import datetime +import sys +from ctypes import * +from lib_pal import * + +SYSLOGFILE = '/mnt/data/logfile' +APPNAME = 'log-util' + +def print_usage(): + print 'Usage: %s --show' % (APPNAME) + +def log_main(): + + if len(sys.argv) is not 2: + print_usage() + return -1 + + if sys.argv[1] != '--show': + print_usage() + return -1 + + fd = open(SYSLOGFILE, 'r') + syslog = fd.readlines() + fd.close() + + print '%-4s %-8s %-22s %-16s %s' % ( + "FRU#", + "FRU_NAME", + "TIME_STAMP", + "APP_NAME", + "MESSAGE" + ) + + for log in syslog: + if not (re.search(r' bmc [a-z]*.crit ', log)): + continue + if re.search(r'FRU: [0-9]{1,2}', log, re.IGNORECASE): + fru = ''.join(re.findall(r'FRU: [0-9]{1,2}', log, re.IGNORECASE)) + # fru is in format "FRU: X" + fru = fru[5] + + # Name of the FRU from the PAL library + name = pal_get_fru_name(int(fru)) + else : + fru = '0' + + name = 'all' + + + temp = re.split(r' bmc [a-z]*.crit ', log) + + # Time format Sep 28 22:10:50 + ts = temp[0] + currtime = datetime.now() + ts = '%d %s' % (currtime.year, ts) + time = datetime.strptime(ts, '%Y %b %d %H:%M:%S') + time = time.strftime('%Y-%m-%d %H:%M:%S') + + temp2 = re.split(r': ', temp[1], 1) + app = temp2[0] + message = temp2[1] + + print '%-4s %-8s %-22s %-16s %s' % ( + fru, + name, + time, + app, + message + ) + + +if __name__ == '__main__': + log_main() diff --git a/common/recipes-core/log-util/log-util_0.1.bb b/common/recipes-core/log-util/log-util_0.1.bb new file mode 100644 index 0000000..0782688 --- /dev/null +++ b/common/recipes-core/log-util/log-util_0.1.bb @@ -0,0 +1,57 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +SUMMARY = "Log Utility" +DESCRIPTION = "Utility to parse and display logs." +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://log-util.py;beginline=5;endline=18;md5=0b1ee7d6f844d472fa306b2fee2167e0" + + +SRC_URI = "file://log-util.py \ + file://lib_pal.py \ + " + +S = "${WORKDIR}" + +DEPENDS += "libpal" + +binfiles = "log-util.py lib_pal.py" + +pkgdir = "log-util" + +do_install() { + dst="${D}/usr/local/fbpackages/${pkgdir}" + install -d $dst + localbindir="${D}/usr/local/bin" + install -d ${localbindir} + + install -m 755 log-util.py ${dst}/log-util + ln -s ../fbpackages/${pkgdir}/log-util ${localbindir}/log-util + + install -m 755 lib_pal.py ${dst}/lib_pal.py + ln -s ../fbpackages/${pkgdir}/lib_pal.py ${localbindir}/lib_pal.py +} + +RDEPENDS_${PN} += "libpal" + +FBPACKAGEDIR = "${prefix}/local/fbpackages" + +FILES_${PN} = "${FBPACKAGEDIR}/log-util ${prefix}/local/bin" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" diff --git a/common/recipes-core/power-util/files/power-util.c b/common/recipes-core/power-util/files/power-util.c index 0fda9d6..07e7c23 100644 --- a/common/recipes-core/power-util/files/power-util.c +++ b/common/recipes-core/power-util/files/power-util.c @@ -32,8 +32,8 @@ #define POWER_ON_STR "on" #define POWER_OFF_STR "off" -const char *pwr_option_list = "status, graceful-shutdown, off, on, cycle, 12V-off," - "12V-on, 12V-cycle"; +const char *pwr_option_list = "status, graceful-shutdown, off, on, cycle, " + "12V-off, 12V-on, 12V-cycle"; enum { PWR_STATUS = 1, @@ -47,22 +47,6 @@ enum { PWR_SLED_CYCLE }; -static int -set_last_pwr_state(uint8_t fru, char * state) { - - int ret; - char key[MAX_KEY_LEN] = {0}; - - sprintf(key, "pwr_server%d_last_state", (int) fru); - - ret = pal_set_key_value(key, state); - if (ret < 0) { - syslog(LOG_ALERT, "set_last_pwr_state: pal_set_key_value failed for " - "fru %u", fru); - } - return ret; -} - static void print_usage() { printf("Usage: power-util [ %s ] [ %s ]\nUsage: power-util sled-cycle\n", @@ -107,7 +91,7 @@ power_util(uint8_t fru, uint8_t opt) { case PWR_STATUS: ret = pal_get_server_power(fru, &status); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_get_server_power failed for fru %u\n", fru); + syslog(LOG_WARNING, "power_util: pal_get_server_power failed for fru %u\n", fru); return ret; } printf("Power status for fru %u : %s\n", fru, status?"ON":"OFF"); @@ -119,22 +103,24 @@ power_util(uint8_t fru, uint8_t opt) { ret = pal_set_server_power(fru, SERVER_GRACEFUL_SHUTDOWN); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_server_power failed for" + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" " fru %u", fru); return ret; } else if (ret == 1) { printf("fru %u is already powered OFF...\n", fru); return 0; + } else { + syslog(LOG_CRIT, "SERVER_GRACEFUL_SHUTDOWN successful for FRU: %d", fru); } - ret = set_last_pwr_state(fru, POWER_OFF_STR); + ret = pal_set_last_pwr_state(fru, POWER_OFF_STR); if (ret < 0) { return ret; } ret = pal_set_led(fru, LED_STATE_OFF); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_led failed for fru %u", fru); + syslog(LOG_WARNING, "power_util: pal_set_led failed for fru %u", fru); return ret; } break; @@ -145,22 +131,24 @@ power_util(uint8_t fru, uint8_t opt) { ret = pal_set_server_power(fru, SERVER_POWER_OFF); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_server_power failed for" + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" " fru %u", fru); return ret; } else if (ret == 1) { printf("fru %u is already powered OFF...\n", fru); return 0; + } else { + syslog(LOG_CRIT, "SERVER_POWER_OFF successful for FRU: %d", fru); } - ret = set_last_pwr_state(fru, POWER_OFF_STR); + ret = pal_set_last_pwr_state(fru, POWER_OFF_STR); if (ret < 0) { return ret; } ret = pal_set_led(fru, LED_STATE_OFF); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_led failed for fru %u", fru); + syslog(LOG_WARNING, "power_util: pal_set_led failed for fru %u", fru); return ret; } break; @@ -171,22 +159,24 @@ power_util(uint8_t fru, uint8_t opt) { ret = pal_set_server_power(fru, SERVER_POWER_ON); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_server_power failed for" + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" " fru %u", fru); return ret; } else if (ret == 1) { printf("fru %u is already powered ON...\n", fru); return 0; + } else { + syslog(LOG_CRIT, "SERVER_POWER_ON successful for FRU: %d", fru); } - ret = set_last_pwr_state(fru, POWER_ON_STR); + ret = pal_set_last_pwr_state(fru, POWER_ON_STR); if (ret < 0) { return ret; } ret = pal_set_led(fru, LED_STATE_ON); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_led failed for fru %u", fru); + syslog(LOG_WARNING, "power_util: pal_set_led failed for fru %u", fru); return ret; } break; @@ -197,41 +187,97 @@ power_util(uint8_t fru, uint8_t opt) { ret = pal_set_server_power(fru, SERVER_POWER_CYCLE); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_server_power failed for" + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" " fru %u", fru); return ret; + } else { + syslog(LOG_CRIT, "SERVER_POWER_CYCLE successful for FRU: %d", fru); } - ret = set_last_pwr_state(fru, POWER_ON_STR); + ret = pal_set_last_pwr_state(fru, POWER_ON_STR); if (ret < 0) { return ret; } ret = pal_set_led(fru, LED_STATE_ON); if (ret < 0) { - syslog(LOG_ALERT, "power_util: pal_set_led failed for fru %u", fru); + syslog(LOG_WARNING, "power_util: pal_set_led failed for fru %u", fru); return ret; } break; case PWR_12V_OFF: - ret = 0; // TODO: Need to add the API to support this power state setting + + printf("12V Powering fru %u to OFF state...\n", fru); + + ret = pal_set_server_power(fru, SERVER_12V_OFF); + if (ret < 0) { + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" + " fru %u", fru); + return ret; + } else { + syslog(LOG_CRIT, "SERVER_12V_OFF successful for FRU: %d", fru); + } + + ret = pal_set_last_pwr_state(fru, POWER_OFF_STR); + if (ret < 0) { + return ret; + } + + ret = pal_set_led(fru, LED_STATE_OFF); + if (ret < 0) { + syslog(LOG_WARNING, "power_util: pal_set_led failed for fru %u", fru); + return ret; + } break; case PWR_12V_ON: - ret = 0; // TODO: Need to add the API to support this power state setting + + printf("12V Powering fru %u to ON state...\n", fru); + + ret = pal_set_server_power(fru, SERVER_12V_ON); + if (ret < 0) { + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" + " fru %u", fru); + return ret; + } else { + syslog(LOG_CRIT, "SERVER_12V_ON successful for FRU: %d", fru); + } break; case PWR_12V_CYCLE: - ret = 0; // TODO: Need to add the API to support this power state setting + + printf("12V Power cycling fru %u...\n", fru); + + ret = pal_set_server_power(fru, SERVER_12V_CYCLE); + if (ret < 0) { + syslog(LOG_WARNING, "power_util: pal_set_server_power failed for" + " fru %u", fru); + return ret; + } else { + syslog(LOG_CRIT, "SERVER_12V_CYCLE successful for FRU: %d", fru); + } + + ret = pal_set_last_pwr_state(fru, POWER_OFF_STR); + if (ret < 0) { + return ret; + } + + ret = pal_set_led(fru, LED_STATE_OFF); + if (ret < 0) { + syslog(LOG_WARNING, "power_util: pal_set_led failed for fru %u", fru); + return ret; + } break; case PWR_SLED_CYCLE: + syslog(LOG_CRIT, "SLED_CYCLE successful"); + sleep(1); pal_sled_cycle(); break; default: - syslog(LOG_ALERT, "power_util: wrong option"); + syslog(LOG_WARNING, "power_util: wrong option"); } @@ -292,4 +338,6 @@ main(int argc, char **argv) { print_usage(); return ret; } + + return ret; } diff --git a/common/recipes-core/python/python_2.7.9.bbappend b/common/recipes-core/python/python_2.7.9.bbappend new file mode 100644 index 0000000..c3f1fa1 --- /dev/null +++ b/common/recipes-core/python/python_2.7.9.bbappend @@ -0,0 +1,21 @@ +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +# Patch from here - http://patchwork.openembedded.org/patch/96953/ +# is not available upstream yet . Until then we are adding ourselves to +# satisfy ssl.py that has a dependency on this module. +RDEPENDS_${PN}-io += "${PN}-contextlib" diff --git a/common/recipes-core/sensor-mon/files/sensord.c b/common/recipes-core/sensor-mon/files/sensord.c index 1852af3..0ad00f7 100644 --- a/common/recipes-core/sensor-mon/files/sensord.c +++ b/common/recipes-core/sensor-mon/files/sensord.c @@ -32,73 +32,17 @@ #include <facebook/bic.h> #include <openbmc/ipmi.h> #include <openbmc/sdr.h> -#ifdef CONFIG_YOSEMITE -#include <facebook/yosemite_sensor.h> -#endif /* CONFIG_YOSEMITE */ - -#define MAX_SENSOR_NUM 0xFF -#define NORMAL_STATE 0x00 - -#define SETBIT(x, y) (x | (1 << y)) -#define GETBIT(x, y) ((x & (1 << y)) > y) -#define CLEARBIT(x, y) (x & (~(1 << y))) -#define GETMASK(y) (1 << y) - - - -/* Enum for type of Upper and Lower threshold values */ -enum { - UCR_THRESH = 0x01, - UNC_THRESH, - UNR_THRESH, - LCR_THRESH, - LNC_THRESH, - LNR_THRESH, - POS_HYST, - NEG_HYST, -}; - -/* To hold the sensor info and calculated threshold values from the SDR */ -typedef struct { - uint8_t flag; - float ucr_thresh; - float unc_thresh; - float unr_thresh; - float lcr_thresh; - float lnc_thresh; - float lnr_thresh; - float pos_hyst; - float neg_hyst; - int curr_state; - char name[23]; - char units[64]; - -} thresh_sensor_t; - -/* Function pointer to read sensor current value */ -static int (*read_snr_val)(uint8_t, uint8_t, void *); - -#ifdef CONFIG_YOSEMITE - -// TODO: Change to 6 after adding SPB and NIC -#define MAX_NUM_FRUS 4 -#define YOSEMITE_SDR_PATH "/tmp/sdr_%s.bin" - -static thresh_sensor_t snr_slot1[MAX_SENSOR_NUM] = {0}; -static thresh_sensor_t snr_slot2[MAX_SENSOR_NUM] = {0}; -static thresh_sensor_t snr_slot3[MAX_SENSOR_NUM] = {0}; -static thresh_sensor_t snr_slot4[MAX_SENSOR_NUM] = {0}; -static thresh_sensor_t snr_spb[MAX_SENSOR_NUM] = {0}; -static thresh_sensor_t snr_nic[MAX_SENSOR_NUM] = {0}; - -static sensor_info_t sinfo_slot1[MAX_SENSOR_NUM] = {0}; -static sensor_info_t sinfo_slot2[MAX_SENSOR_NUM] = {0}; -static sensor_info_t sinfo_slot3[MAX_SENSOR_NUM] = {0}; -static sensor_info_t sinfo_slot4[MAX_SENSOR_NUM] = {0}; -static sensor_info_t sinfo_spb[MAX_SENSOR_NUM] = {0}; -static sensor_info_t sinfo_nic[MAX_SENSOR_NUM] = {0}; -#endif /* CONFIG_YOSEMITE */ +#include <openbmc/pal.h> +#define DELAY 2 + +static thresh_sensor_t g_snr[MAX_NUM_FRUS][MAX_SENSOR_NUM] = {0}; + +static void +print_usage() { + printf("Usage: sensord <options>\n"); + printf("Options: [ %s ]\n", pal_fru_list); +} /* * Returns the pointer to the struct holding all sensor info and @@ -109,502 +53,58 @@ get_struct_thresh_sensor(uint8_t fru) { thresh_sensor_t *snr; -#ifdef CONFIG_YOSEMITE - switch (fru) { - case FRU_SLOT1: - snr = snr_slot1; - break; - case FRU_SLOT2: - snr = snr_slot2; - break; - case FRU_SLOT3: - snr = snr_slot3; - break; - case FRU_SLOT4: - snr = snr_slot4; - break; - case FRU_SPB: - snr = snr_spb; - break; - case FRU_NIC: - snr = snr_nic; - break; - default: - syslog(LOG_ALERT, "get_struct_thresh_sensor: Wrong FRU ID %d\n", fru); - return NULL; - } -#endif /* CONFIG_YOSEMITE */ - - return snr; -} - - -/* Returns the all the SDRs for the particular fru# */ -static sensor_info_t * -get_struct_sensor_info(uint8_t fru) { - - sensor_info_t *sinfo; - -#ifdef CONFIG_YOSEMITE - switch (fru) { - case FRU_SLOT1: - sinfo = sinfo_slot1; - break; - case FRU_SLOT2: - sinfo = sinfo_slot2; - break; - case FRU_SLOT3: - sinfo = sinfo_slot3; - break; - case FRU_SLOT4: - sinfo = sinfo_slot4; - break; - case FRU_SPB: - sinfo = sinfo_spb; - break; - case FRU_NIC: - sinfo = sinfo_nic; - break; - default: - syslog(LOG_ALERT, "get_struct_sensor_info: Wrong FRU ID %d\n", fru); - return NULL; - } -#endif /* CONFIG_YOSEMITE */ - - return sinfo; -} - - -/* Returns the SDR for a particular sensor of particular fru# */ -static sdr_full_t * -get_struct_sdr(uint8_t fru, uint8_t snr_num) { - - sdr_full_t *sdr; - sensor_info_t *sinfo; - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "get_struct_sdr: get_struct_sensor_info failed\n"); + if (fru < 1 || fru > MAX_NUM_FRUS) { + syslog(LOG_WARNING, "get_struct_thresh_sensor: Wrong FRU ID %d\n", fru); return NULL; } - sdr = &sinfo[snr_num].sdr; - return sdr; + snr = g_snr[fru-1]; + return snr; } -/* Get the threshold values from the SDRs */ +/* Initialize all thresh_sensor_t structs for all the Yosemite sensors */ static int -get_sdr_thresh_val(uint8_t fru, uint8_t snr_num, uint8_t thresh, void *value) { +init_fru_snr_thresh(uint8_t fru) { + int i; int ret; - uint8_t x; - uint8_t m_lsb, m_msb, m; - uint8_t b_lsb, b_msb, b; - int8_t b_exp, r_exp; - uint8_t thresh_val; - sdr_full_t *sdr; - - sdr = get_struct_sdr(fru, snr_num); - if (sdr == NULL) { - syslog(LOG_ALERT, "get_sdr_thresh_val: get_struct_sdr failed\n"); - return -1; - } - - switch (thresh) { - case UCR_THRESH: - thresh_val = sdr->uc_thresh; - break; - case UNC_THRESH: - thresh_val = sdr->unc_thresh; - break; - case UNR_THRESH: - thresh_val = sdr->unr_thresh; - break; - case LCR_THRESH: - thresh_val = sdr->lc_thresh; - break; - case LNC_THRESH: - thresh_val = sdr->lnc_thresh; - break; - case LNR_THRESH: - thresh_val = sdr->lnr_thresh; - break; - case POS_HYST: - thresh_val = sdr->pos_hyst; - break; - case NEG_HYST: - thresh_val = sdr->neg_hyst; - break; - default: - syslog(LOG_ERR, "get_sdr_thresh_val: reading unknown threshold val"); - return -1; - } - - // y = (mx + b * 10^b_exp) * 10^r_exp - x = thresh_val; - - m_lsb = sdr->m_val; - m_msb = sdr->m_tolerance >> 6; - m = (m_msb << 8) | m_lsb; - - b_lsb = sdr->b_val; - b_msb = sdr->b_accuracy >> 6; - b = (b_msb << 8) | b_lsb; - - // exponents are 2's complement 4-bit number - b_exp = sdr->rb_exp & 0xF; - if (b_exp > 7) { - b_exp = (~b_exp + 1) & 0xF; - b_exp = -b_exp; - } - r_exp = (sdr->rb_exp >> 4) & 0xF; - if (r_exp > 7) { - r_exp = (~r_exp + 1) & 0xF; - r_exp = -r_exp; - } - - * (float *) value = ((m * x) + (b * pow(10, b_exp))) * (pow(10, r_exp)); - - return 0; -} - -/* - * Populate all fields of thresh_sensor_t struct for a particular sensor. - * Incase the threshold value is 0 mask the check for that threshvold - * value in flag field. - */ -int -init_snr_thresh(uint8_t fru, uint8_t snr_num, uint8_t flag) { - - int value; - float fvalue; - uint8_t op, modifier; + uint8_t snr_num; + int sensor_cnt; + uint8_t *sensor_list; thresh_sensor_t *snr; - sdr_full_t *sdr; - - sdr = get_struct_sdr(fru, snr_num); - if (sdr == NULL) { - syslog(LOG_ALERT, "init_snr_name: get_struct_sdr failed\n"); - return -1; - } - snr = get_struct_thresh_sensor(fru); if (snr == NULL) { - syslog(LOG_ALERT, "init_snr_thresh: get_struct_thresh_sensor failed"); - return -1; - } - - snr[snr_num].flag = flag; - snr[snr_num].curr_state = NORMAL_STATE; - - if (sdr_get_sensor_name(sdr, snr[snr_num].name)) { - syslog(LOG_ALERT, "sdr_get_sensor_name: FRU %d: num: 0x%X: reading name" - " from SDR failed.", fru, snr_num); - return -1; - } - - // TODO: Add support for modifier (Mostly modifier is zero) - if (sdr_get_sensor_units(sdr, &op, &modifier, snr[snr_num].units)) { - syslog(LOG_ALERT, "sdr_get_sensor_units: FRU %d: num 0x%X: reading units" - " from SDR failed.", fru, snr_num); +#ifdef DEBUG + syslog(LOG_WARNING, "init_fru_snr_thresh: get_struct_thresh_sensor failed"); +#endif /* DEBUG */ return -1; } - if (get_sdr_thresh_val(fru, snr_num, UCR_THRESH, &fvalue)) { - syslog(LOG_ERR, - "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, UCR_THRESH", - fru, snr_num, snr[snr_num].name); - } else { - snr[snr_num].ucr_thresh = fvalue; - if (!(fvalue)) { - snr[snr_num].flag = CLEARBIT(snr[snr_num].flag, UCR_THRESH); - syslog(LOG_ALERT, - "FRU: %d, num: 0x%X, %-16s, UCR_THRESH check disabled val->%.2f", - fru, snr_num, snr[snr_num].name, fvalue); - } + ret = pal_get_fru_sensor_list(fru, &sensor_list, &sensor_cnt); + if (ret < 0) { + return ret; } - if (get_sdr_thresh_val(fru, snr_num, UNC_THRESH, &fvalue)) { - syslog(LOG_ERR, - "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, UNC_THRESH", - fru, snr_num, snr[snr_num].name); - } else { - snr[snr_num].unc_thresh = fvalue; - if (!(fvalue)) { - snr[snr_num].flag = CLEARBIT(snr[snr_num].flag, UNC_THRESH); - syslog(LOG_ALERT, - "FRU: %d, num: 0x%X, %-16s, UNC_THRESH check disabled val->%.2f", - fru, snr_num, snr[snr_num].name, fvalue); - } - } - - if (get_sdr_thresh_val(fru, snr_num, UNR_THRESH, &fvalue)) { - syslog(LOG_ERR, - "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, UNR_THRESH", - fru, snr_num, snr[snr_num].name); - } else { - snr[snr_num].unr_thresh = fvalue; - if (!(fvalue)) { - snr[snr_num].flag = CLEARBIT(snr[snr_num].flag, UNR_THRESH); - syslog(LOG_ALERT, - "FRU: %d, num: 0x%X, %-16s, UNR_THRESH check disabled val->%.2f", - fru, snr_num, snr[snr_num].name, fvalue); - } - } - - if (get_sdr_thresh_val(fru, snr_num, LCR_THRESH, &fvalue)) { - syslog(LOG_ERR, - "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, LCR_THRESH", - fru, snr_num, snr[snr_num].name); - } else { - snr[snr_num].lcr_thresh = fvalue; - if (!(fvalue)) { - snr[snr_num].flag = CLEARBIT(snr[snr_num].flag, LCR_THRESH); - syslog(LOG_ALERT, - "FRU: %d, num: 0x%X, %-16s, LCR_THRESH check disabled val->%.2f", - fru, snr_num, snr[snr_num].name, fvalue); - } - } - - if (get_sdr_thresh_val(fru, snr_num, LNC_THRESH, &fvalue)) { - syslog(LOG_ERR, - "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, LNC_THRESH", - fru, snr_num, snr[snr_num].name); - } else { - snr[snr_num].lnc_thresh = fvalue; - if (!(fvalue)) { - snr[snr_num].flag = CLEARBIT(snr[snr_num].flag, LNC_THRESH); - syslog(LOG_ALERT, - "FRU: %d, num: 0x%X, %-16s, LNC_THRESH check disabled val->%.2f", - fru, snr_num, snr[snr_num].name, fvalue); + for (i < 0; i < sensor_cnt; i++) { + snr_num = sensor_list[i]; + ret = sdr_get_snr_thresh(fru, snr_num, + GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH), &snr[snr_num]); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "init_fru_snr_thresh: sdr_get_snr_thresh for FRU: %d", fru); +#endif /* DEBUG */ + continue; } } - if (get_sdr_thresh_val(fru, snr_num, LNR_THRESH, &fvalue)) { - syslog(LOG_ERR, - "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, LNR_THRESH", - fru, snr_num, snr[snr_num].name); - } else { - snr[snr_num].lnr_thresh = fvalue; - if (!(fvalue)) { - snr[snr_num].flag = CLEARBIT(snr[snr_num].flag, LNR_THRESH); - syslog(LOG_ALERT, - "FRU: %d, num: 0x%X, %-16s, LNR_THRESH check disabled val->%.2f", - fru, snr_num, snr[snr_num].name, fvalue); - } + // TODO: This is a HACK. Need to add the pal_threshold_verify support + if (fru > 0 && fru < 5) { + snr[BIC_SENSOR_SOC_THERM_MARGIN].flag = SETBIT(snr[BIC_SENSOR_SOC_THERM_MARGIN].flag, UCR_THRESH); } - if (get_sdr_thresh_val(fru, snr_num, POS_HYST, &fvalue)) { - syslog(LOG_ERR, "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, POS_HYST", - fru, snr_num, snr[snr_num].name); - } else - snr[snr_num].pos_hyst = fvalue; - - if (get_sdr_thresh_val(fru, snr_num, NEG_HYST, &fvalue)) { - syslog(LOG_ERR, "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, NEG_HYST", - fru, snr_num, snr[snr_num].name); - } else - snr[snr_num].neg_hyst = fvalue; - return 0; } -#ifdef CONFIG_YOSEMITE -/* Initialize all thresh_sensor_t structs for all the Yosemite sensors */ -static void -init_yosemite_snr_thresh(uint8_t fru) { - - int i; - - switch (fru) { - case FRU_SLOT1: - case FRU_SLOT2: - case FRU_SLOT3: - case FRU_SLOT4: - - for (i < 0; i < bic_sensor_cnt; i++) { - init_snr_thresh(fru, bic_sensor_list[i], GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - } - /* - init_snr_thresh(fru, BIC_SENSOR_MB_OUTLET_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCCIN_VR_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_GBE_VR_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_1V05PCH_VR_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_MB_INLET_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_PCH_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_THERM_MARGIN, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VDDR_VR_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_GBE_VR_CURR, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_1V05_PCH_VR_CURR, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCCIN_VR_POUT, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCCIN_VR_CURR, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCCIN_VR_VOL, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_INA230_POWER, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_PACKAGE_PWR, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_TJMAX, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VDDR_VR_POUT, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VDDR_VR_CURR, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VDDR_VR_VOL, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_SCSUS_VR_CURR, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_SCSUS_VR_VOL, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_SCSUS_VR_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_SCSUS_VR_POUT, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_GBE_VR_POUT, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_VCC_GBE_VR_VOL, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_1V05_PCH_VR_VOL, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_DIMMA0_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_DIMMA1_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_DIMMB0_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_SOC_DIMMB1_TEMP, GETMASK(UCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_P3V3_MB, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_P12V_MB, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_P1V05_PCH, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_P3V3_STBY_MB, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_P5V_STBY_MB, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_PV_BAT, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_PVDDR, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - - init_snr_thresh(fru, BIC_SENSOR_PVCC_GBE, - GETMASK(UCR_THRESH) | GETMASK(LCR_THRESH)); - // TODO: Add Support for Discrete sensors - // init_snr_thresh(fru, BIC_SENSOR_POST_ERR, //Event-only - // init_snr_thresh(fru, BIC_SENSOR_SYSTEM_STATUS, //Discrete - // init_snr_thresh(fru, BIC_SENSOR_SPS_FW_HLTH); //Event-only - // init_snr_thresh(fru, BIC_SENSOR_POWER_THRESH_EVENT, //Event-only - // init_snr_thresh(fru, BIC_SENSOR_MACHINE_CHK_ERR, //Event-only - // init_snr_thresh(fru, BIC_SENSOR_PCIE_ERR); //Event-only - // init_snr_thresh(fru, BIC_SENSOR_OTHER_IIO_ERR); //Event-only - // init_snr_thresh(fru, BIC_SENSOR_PROC_HOT_EXT); //Event-only - // init_snr_thresh(fru, BIC_SENSOR_POWER_ERR); //Event-only - // init_snr_thresh(fru, , ); //Event-only - // init_snr_thresh(fru, BIC_SENSOR_PROC_FAIL); //Discrete - // init_snr_thresh(fru, BIC_SENSOR_SYS_BOOT_STAT ); //Discrete - // init_snr_thresh(fru, BIC_SENSOR_VR_HOT); //Discrete - // init_snr_thresh(fru, BIC_SENSOR_CPU_DIMM_HOT ); //Discrete - // init_snr_thresh(fru, BIC_SENSOR_CAT_ERR, //Event-only - - */ - - break; - - case FRU_SPB: - // TODO: Add support for threshold calculation for SP sensors - /* - init_snr_thresh(fru, SP_SENSOR_INLET_TEMP, "SP_SENSOR_INLET_TEMP"); - init_snr_thresh(fru, SP_SENSOR_OUTLET_TEMP, "SP_SENSOR_OUTLET_TEMP"); - init_snr_thresh(fru, SP_SENSOR_MEZZ_TEMP, "SP_SENSOR_MEZZ_TEMP"); - init_snr_thresh(fru, SP_SENSOR_FAN0_TACH, "SP_SENSOR_FAN0_TACH"); - init_snr_thresh(fru, SP_SENSOR_FAN1_TACH, "SP_SENSOR_FAN1_TACH"); - init_snr_thresh(fru, SP_SENSOR_AIR_FLOW, "SP_SENSOR_AIR_FLOW"); - init_snr_thresh(fru, SP_SENSOR_P5V, "SP_SENSOR_P5V"); - init_snr_thresh(fru, SP_SENSOR_P12V, "SP_SENSOR_P12V"); - init_snr_thresh(fru, SP_SENSOR_P3V3_STBY, "SP_SENSOR_P3V3_STBY"); - init_snr_thresh(fru, SP_SENSOR_P12V_SLOT0, "SP_SENSOR_P12V_SLOT0"); - init_snr_thresh(fru, SP_SENSOR_P12V_SLOT1, "SP_SENSOR_P12V_SLOT1"); - init_snr_thresh(fru, SP_SENSOR_P12V_SLOT2, "SP_SENSOR_P12V_SLOT2"); - init_snr_thresh(fru, SP_SENSOR_P12V_SLOT3, "SP_SENSOR_P12V_SLOT3"); - init_snr_thresh(fru, SP_SENSOR_P3V3, "SP_SENSOR_P3V3"); - init_snr_thresh(fru, SP_SENSOR_HSC_IN_VOLT, "SP_SENSOR_HSC_IN_VOLT"); - init_snr_thresh(fru, SP_SENSOR_HSC_OUT_CURR, "SP_SENSOR_HSC_OUT_CURR"); - init_snr_thresh(fru, SP_SENSOR_HSC_TEMP, "SP_SENSOR_HSC_TEMP"); - init_snr_thresh(fru, SP_SENSOR_HSC_IN_POWER, "SP_SENSOR_HSC_IN_POWER"); - */ - break; - - case FRU_NIC: - // TODO: Add support for NIC sensor threshold, if any. - break; - - default: - syslog(LOG_ALERT, "init_yosemite_snr_thresh: wrong FRU ID"); - exit(-1); - } -} -#endif /* CONFIG_YOSEMITE */ - -/* Wrapper function to initialize all the platform sensors */ -static void -init_all_snr_thresh() { - int fru; - - char path[64] = {0}; - sensor_info_t *sinfo; - - -#ifdef CONFIG_YOSEMITE - for (fru = FRU_SLOT1; fru < (FRU_SLOT1 + MAX_NUM_FRUS); fru++) { - - if (get_fru_sdr_path(fru, path) < 0) { - syslog(LOG_ALERT, "yosemite_sdr_init: get_fru_sdr_path failed\n"); - continue; - } -#endif /* CONFIG_YOSEMITE */ - - sinfo = get_struct_sensor_info(fru); - - if (sdr_init(path, sinfo) < 0) - syslog(LOG_ERR, "init_all_snr_thresh: sdr_init failed for FRU %d", fru); - } - -#ifdef CONFIG_YOSEMITE - for (fru = FRU_SLOT1; fru < (FRU_SLOT1 + MAX_NUM_FRUS); fru++) { - init_yosemite_snr_thresh(fru); - } -#endif /* CONFIG_YOSEMITE */ -} - - - - static float get_snr_thresh_val(uint8_t fru, uint8_t snr_num, uint8_t thresh) { @@ -633,7 +133,7 @@ get_snr_thresh_val(uint8_t fru, uint8_t snr_num, uint8_t thresh) { val = snr[snr_num].lnr_thresh; break; default: - syslog(LOG_ALERT, "get_snr_thresh_val: wrong thresh enum value"); + syslog(LOG_WARNING, "get_snr_thresh_val: wrong thresh enum value"); exit(-1); } @@ -662,7 +162,7 @@ check_thresh_deassert(uint8_t fru, uint8_t snr_num, uint8_t thresh, switch (thresh) { case UNC_THRESH: - if (curr_val <= thresh_val) { + if (curr_val < (thresh_val - snr[snr_num].pos_hyst)) { curr_state = ~(SETBIT(curr_state, UNR_THRESH) | SETBIT(curr_state, UCR_THRESH) | SETBIT(curr_state, UNC_THRESH)); @@ -671,7 +171,7 @@ check_thresh_deassert(uint8_t fru, uint8_t snr_num, uint8_t thresh, break; case UCR_THRESH: - if (curr_val <= thresh_val) { + if (curr_val < (thresh_val - snr[snr_num].pos_hyst)) { curr_state = ~(SETBIT(curr_state, UCR_THRESH) | SETBIT(curr_state, UNR_THRESH)); sprintf(thresh_name, "Upper Critical"); @@ -679,14 +179,14 @@ check_thresh_deassert(uint8_t fru, uint8_t snr_num, uint8_t thresh, break; case UNR_THRESH: - if (curr_val <= thresh_val) { + if (curr_val < (thresh_val - snr[snr_num].pos_hyst)) { curr_state = ~(SETBIT(curr_state, UNR_THRESH)); sprintf(thresh_name, "Upper Non Recoverable"); } break; case LNC_THRESH: - if (curr_val >= thresh_val) { + if (curr_val > (thresh_val + snr[snr_num].neg_hyst)) { curr_state = ~(SETBIT(curr_state, LNR_THRESH) | SETBIT(curr_state, LCR_THRESH) | SETBIT(curr_state, LNC_THRESH)); @@ -695,7 +195,7 @@ check_thresh_deassert(uint8_t fru, uint8_t snr_num, uint8_t thresh, break; case LCR_THRESH: - if (curr_val >= thresh_val) { + if (curr_val > (thresh_val + snr[snr_num].neg_hyst)) { curr_state = ~(SETBIT(curr_state, LCR_THRESH) | SETBIT(curr_state, LNR_THRESH)); sprintf(thresh_name, "Lower Critical"); @@ -703,23 +203,23 @@ check_thresh_deassert(uint8_t fru, uint8_t snr_num, uint8_t thresh, break; case LNR_THRESH: - if (curr_val >= thresh_val) { + if (curr_val > (thresh_val + snr[snr_num].neg_hyst)) { curr_state = ~(SETBIT(curr_state, LNR_THRESH)); sprintf(thresh_name, "Lower Non Recoverable"); } break; default: - syslog(LOG_ALERT, "get_snr_thresh_val: wrong thresh enum value"); + syslog(LOG_WARNING, "get_snr_thresh_val: wrong thresh enum value"); exit(-1); } if (curr_state) { snr[snr_num].curr_state &= curr_state; - syslog(LOG_CRIT, "DEASSERT: %s threshold raised - FRU: %d, num: 0x%X," - " snr: %-16s,",thresh_name, fru, snr_num, snr[snr_num].name); - syslog(LOG_CRIT, "curr_val: %.2f %s, thresh_val: %.2f %s cf: %u", - curr_val, snr[snr_num].units, thresh_val, snr[snr_num].units, snr[snr_num].curr_state); + syslog(LOG_CRIT, "DEASSERT: %s threshold - settled - FRU: %d, num: 0x%X " + "curr_val: %.2f %s, thresh_val: %.2f %s, snr: %-16s",thresh_name, + fru, snr_num,curr_val, snr[snr_num].units, thresh_val, + snr[snr_num].units, snr[snr_num].name); } } @@ -794,17 +294,99 @@ check_thresh_assert(uint8_t fru, uint8_t snr_num, uint8_t thresh, break; default: - syslog(LOG_ALERT, "get_snr_thresh_val: wrong thresh enum value"); + syslog(LOG_WARNING, "get_snr_thresh_val: wrong thresh enum value"); exit(-1); } if (curr_state) { curr_state &= snr[snr_num].flag; snr[snr_num].curr_state |= curr_state; - syslog(LOG_CRIT, "ASSERT: %s threshold raised - FRU: %d, num: 0x%X," - " snr: %-16s,",thresh_name, fru, snr_num, snr[snr_num].name); - syslog(LOG_CRIT, "curr_val: %.2f %s, thresh_val: %.2f %s cf: %u", - curr_val, snr[snr_num].units, thresh_val, snr[snr_num].units, snr[snr_num].curr_state); + syslog(LOG_CRIT, "ASSERT: %s threshold - raised - FRU: %d, num: 0x%X" + " curr_val: %.2f %s, thresh_val: %.2f %s, snr: %-16s", thresh_name, + fru, snr_num, curr_val, snr[snr_num].units, thresh_val, + snr[snr_num].units, snr[snr_num].name); + } +} + + +/* + * Starts monitoring all the sensors on a fru for all discrete sensors. + * Each pthread runs this monitoring for a different fru. + */ +static void * +snr_discrete_monitor(void *arg) { + +#ifdef DEBUG2 + char tmplog[1000]; +#endif /* DEBUG2 */ + uint8_t fru = *(uint8_t *) arg; + int i, ret; + uint8_t discrete_cnt; + uint8_t snr_num; + //uint8_t *discrete_list; + thresh_sensor_t *snr; + float normal_val, curr_val; + + // TODO: Need to resolve the SEGFAULT in the call below and replace HACK here. + /* + ret = pal_get_fru_discrete_list(fru, &discrete_list, &discrete_cnt); + if (ret < 0) { + return; + } + */ + /* HACK */ + uint8_t discrete_list[3]; + if (fru != FRU_SPB && fru != FRU_NIC) { + discrete_list[0] = BIC_SENSOR_SYSTEM_STATUS; + discrete_list[1] = BIC_SENSOR_VR_HOT; + discrete_list[2] = BIC_SENSOR_CPU_DIMM_HOT; + } else { + return -1; + } + + discrete_cnt = 3; + + snr = get_struct_thresh_sensor(fru); + if (snr == NULL) { + syslog(LOG_WARNING, "snr_thresh_monitor: get_struct_thresh_sensor failed"); + exit(-1); + } + + for (i = 0; i < discrete_cnt; i++) { + snr_num = discrete_list[i]; + pal_get_sensor_name(fru, snr_num, snr[snr_num].name); + } + +#if defined(TESTING) || defined(DEBUG) + int cnt = 0; +#endif + while(1) { + for (i = 0; i < discrete_cnt; i++) { + snr_num = discrete_list[i]; + ret = pal_sensor_read(fru, snr_num, &curr_val); + +#ifdef DEBUG2 + sprintf(tmplog, "echo 0x%X %s %d >> /tmp/discretetest%d", snr_num, snr[snr_num].name, (int) curr_val, fru); + system(tmplog); +#endif /* DEBUG2 */ + +#if defined(TESTING) || defined(DEBUG) + if (cnt == 2 && snr_num == BIC_SENSOR_SYSTEM_STATUS) { + curr_val = ((int) curr_val) | 0x1; + } else if (cnt == 6 && snr_num == BIC_SENSOR_SYSTEM_STATUS) { + curr_val = ((int) curr_val) & 0x0; + } +#endif + if ((snr[snr_num].curr_state != (int) curr_val) && !ret) { + pal_sensor_discrete_check(fru, snr_num, snr[snr_num].name, + snr[snr_num].curr_state, (int) curr_val); + snr[snr_num].curr_state = (int) curr_val; + } + } +#if defined(TESTING) || defined(DEBUG) + cnt ++; +#endif + sleep(DELAY); } } @@ -813,24 +395,28 @@ check_thresh_assert(uint8_t fru, uint8_t snr_num, uint8_t thresh, * Each pthread runs this monitoring for a different fru. */ static void * -snr_monitor(void *arg) { +snr_thresh_monitor(void *arg) { uint8_t fru = *(uint8_t *) arg; int f, ret, snr_num; float normal_val, curr_val; thresh_sensor_t *snr; -#ifdef TESTING +#if defined(TESTING) || defined(DEBUG) float temp_thresh; int cnt = 0; #endif /* TESTING */ snr = get_struct_thresh_sensor(fru); if (snr == NULL) { - syslog(LOG_ALERT, "snr_monitor: get_struct_thresh_sensor failed"); + syslog(LOG_WARNING, "snr_thresh_monitor: get_struct_thresh_sensor failed"); exit(-1); } +#ifdef DEBUG2 + char tmplog[1000]; +#endif /* DEBUG2 */ + while(1) { #ifdef TESTING @@ -840,8 +426,11 @@ snr_monitor(void *arg) { for (snr_num = 0; snr_num < MAX_SENSOR_NUM; snr_num++) { curr_val = 0; if (snr[snr_num].flag) { - if (!(ret = read_snr_val(fru, snr_num, &curr_val))) { - + if (!(ret = pal_sensor_read(fru, snr_num, &curr_val))) { +#ifdef DEBUG2 + sprintf(tmplog, "echo 0x%X %s %.2f >> /tmp/analog%d", snr_num, snr[snr_num].name, curr_val, fru); + system(tmplog); +#endif /* DEBUG2 */ #ifdef TESTING /* @@ -871,7 +460,6 @@ snr_monitor(void *arg) { snr[snr_num].units); } #endif /* DEBUG */ - check_thresh_assert(fru, snr_num, UNR_THRESH, curr_val); check_thresh_assert(fru, snr_num, UCR_THRESH, curr_val); check_thresh_assert(fru, snr_num, UNC_THRESH, curr_val); @@ -885,117 +473,149 @@ snr_monitor(void *arg) { check_thresh_deassert(fru, snr_num, LNC_THRESH, curr_val); check_thresh_deassert(fru, snr_num, LCR_THRESH, curr_val); check_thresh_deassert(fru, snr_num, LNR_THRESH, curr_val); - } else { /* - * Incase the read_snr_val failed for a sensor, + * Incase the pal_sensor_read failed for a sensor, * disable all the threshold checks for that sensor * after logging an approciate syslog message. */ + if (ret == ERR_NOT_READY) { + continue; + } + if (ret) { +#ifdef DEBUG syslog(LOG_ERR, "FRU: %d, num: 0x%X, snr:%-16s, read failed", fru, snr_num, snr[snr_num].name); - syslog(LOG_ERR, "FRU: %d, num: 0x%X, snr:%-16s, check disabled", - fru, snr_num, snr[snr_num].name); - snr[snr_num].flag = 0; - //} +#endif + + /* + * Check if the fru is up and running before disabling the sensor. + * If the fru is powered down, DO NOT disable the sensor check. + */ + char state[MAX_VALUE_LEN]; + + pal_get_last_pwr_state(fru, state); + if (!strcmp(state, "on")) { + snr[snr_num].flag = 0; + syslog(LOG_ERR, "FRU: %d, num: 0x%X, snr:%-16s, check disabled", + fru, snr_num, snr[snr_num].name); + } } - } /* read_snr_val return check */ + } /* pal_sensor_read return check */ } /* flag check */ } /* loop for all sensors */ - sleep(5); + sleep(DELAY); } /* while loop*/ } /* function definition */ +#ifdef DEBUG +void print_snr_thread(uint8_t fru, thresh_sensor_t *snr) +{ + int i,j; + float curr_val; + char tmplog[1000]; + char print[1000]; + + for (i = 0; i <= MAX_SENSOR_NUM; i++) { + if (snr[i].flag) { + curr_val = 0; + if(!(pal_sensor_read(fru, i, &curr_val))) { + sprintf(tmplog, "%-30s: %s %.2f %.2f %.2f %.2f\n", + snr[i].name, snr[i].units, + snr[i].ucr_thresh, + snr[i].lcr_thresh, + snr[i].pos_hyst, + snr[i].neg_hyst); + sprintf(print, "echo %s >> /tmp/print%d", tmplog, fru); + system(print); + } + } + } +} +#endif /* DEBUG */ + /* Spawns a pthread for each fru to monitor all the sensors on it */ -static void +static int run_sensord(int argc, char **argv) { - int i, arg; + int ret, arg; + uint8_t fru; + uint8_t fru_flag = 0; pthread_t thread_snr[MAX_NUM_FRUS]; - int fru[MAX_NUM_FRUS] = {0}; - - for (arg = 1; arg < argc; arg ++) { -#ifdef CONFIG_YOSEMITE - if (!(strcmp(argv[arg], "slot1"))) - fru[FRU_SLOT1 - 1] = FRU_SLOT1; - else if (!(strcmp(argv[arg], "slot2"))) - fru[FRU_SLOT2 - 1] = FRU_SLOT2; - else if (!(strcmp(argv[arg], "slot3"))) - fru[FRU_SLOT3 - 1] = FRU_SLOT3; - else if (!(strcmp(argv[arg], "slot4"))) - fru[FRU_SLOT4 - 1] = FRU_SLOT4; - else if (!(strcmp(argv[arg], "spb"))) - fru[FRU_SPB - 1] = FRU_SPB; - else if (!(strcmp(argv[arg], "nic"))) - fru[FRU_NIC - 1] = FRU_NIC; - else { - syslog(LOG_ALERT, "Wrong argument: %s", argv[arg]); - exit(1); - } -#endif /* CONFIG_YOSEMITE */ + pthread_t discrete_snr[MAX_NUM_FRUS]; + + arg = 1; + while(arg < argc) { + ret = pal_get_fru_id(argv[arg], &fru); + if (ret < 0) + return ret; + + fru_flag = SETBIT(fru_flag, fru); + arg++; } - for (i = 0; i < MAX_NUM_FRUS; i++) { - if (fru[i]) { - if (pthread_create(&thread_snr[i], NULL, snr_monitor, - (void*) &fru[i]) < 0) { - syslog(LOG_ALERT, "pthread_create for FRU %d failed\n", fru[i]); + for (fru = 1; fru <= MAX_NUM_FRUS; fru++) { + + if (GETBIT(fru_flag, fru)) { + + if (init_fru_snr_thresh(fru)) + return ret; + + /* Threshold Sensors */ + if (pthread_create(&thread_snr[fru-1], NULL, snr_thresh_monitor, + (void*) &fru) < 0) { + syslog(LOG_WARNING, "pthread_create for FRU %d failed\n", fru); } #ifdef DEBUG else { - syslog(LOG_ALERT, "pthread_create for FRU %d succeed\n", fru[i]); + syslog(LOG_WARNING, "pthread_create for FRU %d succeed\n", fru); } #endif /* DEBUG */ + sleep(1); + + /* Discrete Sensors */ + if (pthread_create(&discrete_snr[fru-1], NULL, snr_discrete_monitor, + (void*) &fru) < 0) { + syslog(LOG_WARNING, "pthread_create for FRU %d failed\n", fru); + } +#ifdef DEBUG + else { + syslog(LOG_WARNING, "pthread_create for discrete FRU %d succeed\n", fru); + } +#endif /* DEBUG */ + sleep(1); } - sleep(1); } - for (i = 0; i < MAX_NUM_FRUS; i++) { - if (fru[i]) - pthread_join(thread_snr[i], NULL); - } -} +#ifdef DEBUG + int i; + for (i = 1; i <= MAX_NUM_FRUS; i++) + print_snr_thread(i, g_snr[i-1]); +#endif /* DEBUG */ + for (fru = 1; fru <= MAX_NUM_FRUS; fru++) { -#ifdef DEBUG -void print_snr_thread(uint8_t fru, thresh_sensor_t *snr) -{ - int i; - float curr_val; + if (GETBIT(fru_flag, fru)) + pthread_join(discrete_snr[fru-1], NULL); + } - for (i = 1; i <= MAX_SENSOR_NUM; i++) { - if (snr[i].flag) { - curr_val = 0; - if(!(read_snr_val(fru, i, &curr_val))) { - printf("%-30s:\t%.2f %s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", - snr[i].name, curr_val,snr[i].units, - snr[i].ucr_thresh, - snr[i].unc_thresh, - snr[i].lcr_thresh, - snr[i].lnr_thresh, - snr[i].pos_hyst, - snr[i].neg_hyst); - } else - printf("Reading failed: %-16s\n", snr[i].name); - } + for (fru = 1; fru <= MAX_NUM_FRUS; fru++) { + + if (GETBIT(fru_flag, fru)) + pthread_join(thread_snr[fru-1], NULL); } } -#endif /* DEBUG */ + int main(int argc, void **argv) { int dev, rc, pid_file; if (argc < 2) { - syslog(LOG_ALERT, "Usage: sensord <options>"); - printf("Usage: sensord <options>\n"); -#ifdef CONFIG_YOSEMITE - syslog(LOG_ALERT, "Options: [slot1 | slot2 | slot3 | slot4 | spb | nic]"); - printf("Options: [slot1 | slot2 | slot3 | slot4 | spb | nic]\n"); -#endif /* CONFIG_YOSEMITE */ + print_usage(); exit(1); } @@ -1008,24 +628,15 @@ main(int argc, void **argv) { } } else { -#ifdef CONFIG_YOSEMITE - read_snr_val = &yosemite_sensor_read; -#endif /* CONFIG_YOSEMITE */ - - init_all_snr_thresh(); - -#ifdef DEBUG - print_snr_thread(1, snr_slot1); - print_snr_thread(2, snr_slot2); - print_snr_thread(3, snr_slot3); - print_snr_thread(4, snr_slot4); -#endif /* DEBUG */ - daemon(0,1); openlog("sensord", LOG_CONS, LOG_DAEMON); syslog(LOG_INFO, "sensord: daemon started"); - run_sensord(argc, (char **) argv); - } + rc = run_sensord(argc, (char **) argv); + if (rc < 0) { + print_usage(); + return -1; + } + } return 0; } diff --git a/common/recipes-core/sensor-mon/sensor-mon_0.1.bb b/common/recipes-core/sensor-mon/sensor-mon_0.1.bb index adbd4cb..2cd2e4d 100644 --- a/common/recipes-core/sensor-mon/sensor-mon_0.1.bb +++ b/common/recipes-core/sensor-mon/sensor-mon_0.1.bb @@ -31,9 +31,9 @@ S = "${WORKDIR}" binfiles = "sensord \ " -CFLAGS += " -lsdr " +CFLAGS += " -lsdr -lpal " -DEPENDS += " libsdr " +DEPENDS += " libpal libsdr " pkgdir = "sensor-mon" diff --git a/common/recipes-core/sensor-util/files/Makefile b/common/recipes-core/sensor-util/files/Makefile index 2d39a04..168e4d7 100644 --- a/common/recipes-core/sensor-util/files/Makefile +++ b/common/recipes-core/sensor-util/files/Makefile @@ -3,7 +3,7 @@ all: sensor-util sensor-util: sensor-util.o - $(CC) $(CFLAGS) -lpal -lrt -lm -std=gnu99 -o $@ $^ $(LDFLAGS) + $(CC) $(CFLAGS) -lsdr -lpal -lrt -lm -std=gnu99 -o $@ $^ $(LDFLAGS) .PHONY: clean diff --git a/common/recipes-core/sensor-util/files/sensor-util.c b/common/recipes-core/sensor-util/files/sensor-util.c index eb38d65..c37fc38 100644 --- a/common/recipes-core/sensor-util/files/sensor-util.c +++ b/common/recipes-core/sensor-util/files/sensor-util.c @@ -26,72 +26,74 @@ #include <stdint.h> #include <string.h> #include <errno.h> +#include <stdbool.h> #include <openbmc/pal.h> +#include <openbmc/sdr.h> static int print_usage() { - printf("Usage: sensor-util [ %s ] <sensor num>\n" - "sensor num is optional.", pal_fru_list); + printf("Usage: sensor-util [ %s ] <--threshold> <sensor num>\n", + pal_fru_list); } static void -print_single_sensor_reading(uint8_t fru, uint8_t *sensor_list, int sensor_cnt, uint8_t num) { - - int i; - float fvalue; - char name[24]; - char units[64]; - int ret = 0; - - for (i = 0; i < sensor_cnt; i++) { - - if (sensor_list[i] == num) { - ret = 1; - pal_get_sensor_name(fru, sensor_list[i], name); - pal_get_sensor_units(fru, sensor_list[i], units); - - if (pal_sensor_read(fru, sensor_list[i], &fvalue) < 0) { - - printf("pal_sensor_read failed: fru: %d num: 0x%X name: %-23s\n", - fru, sensor_list[i], name); - } else { - printf("%-23s: %.2f %s\n", name, fvalue, units); - } - - break; - } +print_sensor_reading(float fvalue, thresh_sensor_t *thresh, bool threshold) { + + if (threshold) { + printf("%-23s: Curr: %.2f %-8s\t" + " UCR: %.2f " + " UNC: %.2f " + " UNR: %.2f " + " LCR: %.2f " + " LNC: %.2f " + " LNR: %.2f \n", + thresh->name, fvalue, thresh->units, + thresh->ucr_thresh, + thresh->unc_thresh, + thresh->unr_thresh, + thresh->lcr_thresh, + thresh->lnc_thresh, + thresh->lnr_thresh); + } else { + printf("%-23s: %.2f %s\n", thresh->name, fvalue, thresh->units); } - if (!ret) { - printf("Wrong sensor number!\n"); - print_usage(); - exit(-1); - } } static void -print_sensor_reading(uint8_t fru, uint8_t *sensor_list, int sensor_cnt) { +calculate_sensor_reading(uint8_t fru, uint8_t *sensor_list, int sensor_cnt, int num, bool threshold) { int i; + uint8_t snr_num; float fvalue; - char name[24]; - char units[64]; + char path[64]; + thresh_sensor_t thresh; for (i = 0; i < sensor_cnt; i++) { - /* Clear the variable */ - sprintf(name, ""); - sprintf(units, ""); + snr_num = sensor_list[i]; - pal_get_sensor_name(fru, sensor_list[i], name); - pal_get_sensor_units(fru, sensor_list[i], units); + /* If calculation is for a single sensor, ignore all others. */ + if (num && snr_num != num) { + continue; + } - if (pal_sensor_read(fru, sensor_list[i], &fvalue) < 0) { + if (threshold) { + if (sdr_get_snr_thresh(fru, snr_num, 0, &thresh)) + syslog(LOG_ERR, "sdr_init_snr_thresh failed for FRU %d num: 0x%X", fru, snr_num); + } else { + sdr_get_sensor_name(fru, sensor_list[i], thresh.name); + sdr_get_sensor_units(fru, sensor_list[i], thresh.units); + } - printf("pal_sensor_read failed: fru: %d num: 0x%X name: %-23s\n", - fru, sensor_list[i], name); + usleep(50); + + if (pal_sensor_read(fru, snr_num, &fvalue) < 0) { + printf("pal_sensor_read failed: FRU: %d num: 0x%X name: %-23s\n", + fru, sensor_list[i], thresh.name, thresh.units); + continue; } else { - printf("%-23s: %.2f %s\n", name, fvalue, units); + print_sensor_reading(fvalue, &thresh, threshold); } } } @@ -99,25 +101,32 @@ print_sensor_reading(uint8_t fru, uint8_t *sensor_list, int sensor_cnt) { int main(int argc, char **argv) { + int i; int ret; int sensor_cnt; uint8_t *sensor_list; uint8_t fru; - uint8_t num; + uint8_t num = 0; + bool threshold = false; - if (argc < 2 || argc > 3) { + if (argc < 2 || argc > 4) { print_usage(); exit(-1); } - if (argc == 3) { - errno = 0; - num = (uint8_t) strtol(argv[2], NULL, 0); - if (errno) { - printf("Sensor number format incorrect.\n"); - print_usage(); - exit(-1); + i = 3; /* Starting at argument 3*/ + while (argc > 2 && i <= argc) { + if (!(strcmp(argv[i-1], "--threshold"))) { + threshold = true; + } else { + errno = 0; + num = (uint8_t) strtol(argv[i-1], NULL, 0); + if (errno) { + print_usage(); + exit(-1); + } } + i++; } @@ -131,42 +140,24 @@ main(int argc, char **argv) { fru = 1; while (fru <= MAX_NUM_FRUS) { - if (fru == FRU_NIC) { - printf("\nsensor-util does not support nic\n"); - exit(-1); - } - ret = pal_get_fru_sensor_list(fru, &sensor_list, &sensor_cnt); if (ret < 0) { return ret; } - if (num) { - print_single_sensor_reading(fru, sensor_list, sensor_cnt, num); - } else { - print_sensor_reading(fru, sensor_list, sensor_cnt); - } + calculate_sensor_reading(fru, sensor_list, sensor_cnt, num, threshold); fru++; printf("\n"); } } else { - if (fru == FRU_NIC) { - printf("\nsensor-util does not support nic\n"); - //exit(-1); - } - ret = pal_get_fru_sensor_list(fru, &sensor_list, &sensor_cnt); if (ret < 0) { return ret; } - if (num) { - print_single_sensor_reading(fru, sensor_list, sensor_cnt, num); - } else { - print_sensor_reading(fru, sensor_list, sensor_cnt); - } + calculate_sensor_reading(fru, sensor_list, sensor_cnt, num, threshold); } return 0; diff --git a/common/recipes-core/sensor-util/sensor-util_0.1.bb b/common/recipes-core/sensor-util/sensor-util_0.1.bb index 227ec53..d802694 100644 --- a/common/recipes-core/sensor-util/sensor-util_0.1.bb +++ b/common/recipes-core/sensor-util/sensor-util_0.1.bb @@ -13,7 +13,7 @@ S = "${WORKDIR}" binfiles = "sensor-util" -DEPENDS =+ " libpal " +DEPENDS =+ " libsdr libpal " pkgdir = "sensor-util" diff --git a/common/recipes-lib/fruid/files/fruid.c b/common/recipes-lib/fruid/files/fruid.c index dc71ac8..e665c27 100644 --- a/common/recipes-lib/fruid/files/fruid.c +++ b/common/recipes-lib/fruid/files/fruid.c @@ -65,7 +65,9 @@ static char * calculate_time(uint8_t * mfg_time) char * mfg_time_str = (char *) malloc(len); if (!mfg_time_str) { - syslog(LOG_ALERT, "fruid: malloc: memory allocation failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "fruid: malloc: memory allocation failed\n"); +#endif return NULL; } @@ -120,13 +122,17 @@ static char * get_chassis_type(uint8_t type_hex) /* If the type is not in the list defined.*/ if (type > FRUID_CHASSIS_TYPECODE_MAX || type < FRUID_CHASSIS_TYPECODE_MIN) { +#ifdef DEBUG syslog(LOG_INFO, "fruid: chassis area: invalid chassis type\n"); +#endif return NULL; } char * type_str = (char *) malloc(strlen(fruid_chassis_type[type])); if (!type_str) { - syslog(LOG_ALERT, "fruid: malloc: memory allocation failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "fruid: malloc: memory allocation failed\n"); +#endif return NULL; } @@ -179,7 +185,9 @@ static char * _fruid_area_field_read(uint8_t *offset) field_len_eff > 0 ? (field = (char *) malloc(field_len_eff + 1)) : (field = (char *) malloc(strlen(FIELD_EMPTY))); if (!field) { - syslog(LOG_ALERT, "fruid: malloc: memory allocation failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "fruid: malloc: memory allocation failed\n"); +#endif return NULL; } @@ -327,7 +335,9 @@ int parse_fruid_area_product(uint8_t * product, /* Check if the format version is as per IPMI FRUID v1.0 format spec */ fruid_product->format_ver = product[index++]; if (fruid_product->format_ver != FRUID_FORMAT_VER) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: product_area: format version not supported"); +#endif return EPROTONOSUPPORT; } @@ -339,7 +349,9 @@ int parse_fruid_area_product(uint8_t * product, fruid_product->area_len, fruid_product->chksum); if (ret) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: product_area: chksum not verified."); +#endif return EBADF; } @@ -401,7 +413,9 @@ int parse_fruid_area_board(uint8_t * board, /* Check if the format version is as per IPMI FRUID v1.0 format spec */ fruid_board->format_ver = board[index++]; if (fruid_board->format_ver != FRUID_FORMAT_VER) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: board_area: format version not supported"); +#endif return EPROTONOSUPPORT; } fruid_board->area_len = board[index++] * FRUID_AREA_LEN_MULTIPLIER; @@ -412,7 +426,9 @@ int parse_fruid_area_board(uint8_t * board, fruid_board->area_len, fruid_board->chksum); if (ret) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: board_area: chksum not verified."); +#endif return EBADF; } @@ -471,7 +487,9 @@ int parse_fruid_area_chassis(uint8_t * chassis, /* Check if the format version is as per IPMI FRUID v1.0 format spec */ fruid_chassis->format_ver = chassis[index++]; if (fruid_chassis->format_ver != FRUID_FORMAT_VER) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: chassis_area: format version not supported"); +#endif return EPROTONOSUPPORT; } @@ -482,7 +500,9 @@ int parse_fruid_area_chassis(uint8_t * chassis, ret = verify_chksum((uint8_t *) chassis, fruid_chassis->area_len, fruid_chassis->chksum); if (ret) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: chassis_area: chksum not verified."); +#endif return EBADF; } @@ -540,7 +560,9 @@ int parse_fruid_header(uint8_t * eeprom, fruid_header_t * header) ret = verify_chksum((uint8_t *) header, sizeof(fruid_header_t), header->chksum); if (ret) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: common_header: chksum not verified."); +#endif return EBADF; } @@ -634,7 +656,9 @@ int fruid_parse(const char * bin, fruid_info_t * fruid) /* Open the FRUID binary file */ fruid_fd = fopen(bin, "rb"); if (!fruid_fd) { +#ifdef DEBUG syslog(LOG_ERR, "fruid: unable to open the file"); +#endif return ENOENT; } @@ -646,7 +670,9 @@ int fruid_parse(const char * bin, fruid_info_t * fruid) eeprom = (uint8_t *) malloc(fruid_len); if (!eeprom) { - syslog(LOG_ALERT, "fruid: malloc: memory allocation failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "fruid: malloc: memory allocation failed\n"); +#endif return ENOMEM; } diff --git a/common/recipes-lib/ipmb/files/ipmb.c b/common/recipes-lib/ipmb/files/ipmb.c index 731eeba..9fe12f5 100644 --- a/common/recipes-lib/ipmb/files/ipmb.c +++ b/common/recipes-lib/ipmb/files/ipmb.c @@ -42,26 +42,39 @@ lib_ipmb_handle(unsigned char bus_id, int s, t, len; struct sockaddr_un remote; char sock_path[64] = {0}; + struct timeval tv; sprintf(sock_path, "%s_%d", SOCK_PATH_IPMB, bus_id); // TODO: Need to update to reuse the socket instead of creating new if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ALERT, "lib_ipmb_handle: socket() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "lib_ipmb_handle: socket() failed\n"); +#endif return; } + // setup timeout for receving on socket + tv.tv_sec = TIMEOUT_IPMB + 1; + tv.tv_usec = 0; + + setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval)); + remote.sun_family = AF_UNIX; strcpy(remote.sun_path, sock_path); len = strlen(remote.sun_path) + sizeof(remote.sun_family); if (connect(s, (struct sockaddr *)&remote, len) == -1) { - syslog(LOG_ALERT, "ipmb_handle: connect() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "ipmb_handle: connect() failed\n"); +#endif goto clean_exit; } if (send(s, request, req_len, 0) == -1) { - syslog(LOG_ALERT, "ipmb_handle: send() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "ipmb_handle: send() failed\n"); +#endif goto clean_exit; } @@ -69,9 +82,13 @@ lib_ipmb_handle(unsigned char bus_id, *res_len = t; } else { if (t < 0) { - syslog(LOG_ALERT, "lib_ipmb_handle: recv() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "lib_ipmb_handle: recv() failed\n"); +#endif } else { - printf("Server closed connection\n"); +#ifdef DEBUG + syslog(LOG_DEBUG, "Server closed connection\n"); +#endif } } diff --git a/common/recipes-lib/ipmb/files/ipmb.h b/common/recipes-lib/ipmb/files/ipmb.h index d9bc16b..070e7ed 100644 --- a/common/recipes-lib/ipmb/files/ipmb.h +++ b/common/recipes-lib/ipmb/files/ipmb.h @@ -40,7 +40,10 @@ extern "C" { // Slot#0 is on I2C Bus1 #define IPMB_BUS_SLOT0 1 -#define TIMEOUT_IPMI 4 +// TODO: Some IPMB responses take about 5-6 seconds +// Need to add a timeout parameter to IPMB request +// For now changing global timeout to 8 seconds +#define TIMEOUT_IPMB 8 #define MAX_IPMB_RES_LEN 255 typedef struct _ipmb_req_t { diff --git a/common/recipes-lib/ipmi/files/ipmi.c b/common/recipes-lib/ipmi/files/ipmi.c index 3579eca..1b0f210 100644 --- a/common/recipes-lib/ipmi/files/ipmi.c +++ b/common/recipes-lib/ipmi/files/ipmi.c @@ -41,24 +41,37 @@ lib_ipmi_handle(unsigned char *request, unsigned char req_len, int s, t, len; struct sockaddr_un remote; + struct timeval tv; // TODO: Need to update to reuse the socket instead of creating new if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ALERT, "lib_ipmi_handle: socket() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "lib_ipmi_handle: socket() failed\n"); +#endif return; } + // setup timeout for receving on socket + tv.tv_sec = TIMEOUT_IPMI + 1; + tv.tv_usec = 0; + + setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval)); + remote.sun_family = AF_UNIX; strcpy(remote.sun_path, SOCK_PATH_IPMI); len = strlen(remote.sun_path) + sizeof(remote.sun_family); if (connect(s, (struct sockaddr *)&remote, len) == -1) { - syslog(LOG_ALERT, "lib_ipmi_handle: connect() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "lib_ipmi_handle: connect() failed\n"); +#endif return; } if (send(s, request, req_len, 0) == -1) { - syslog(LOG_ALERT, "lib_ipmi_handle: send() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "lib_ipmi_handle: send() failed\n"); +#endif return; } @@ -66,7 +79,9 @@ lib_ipmi_handle(unsigned char *request, unsigned char req_len, *res_len = t; } else { if (t < 0) { - syslog(LOG_ALERT, "lib_ipmi_handle: recv() failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "lib_ipmi_handle: recv() failed\n"); +#endif } else { printf("Server closed connection"); } diff --git a/common/recipes-lib/ipmi/files/ipmi.h b/common/recipes-lib/ipmi/files/ipmi.h index 2ae7f1c..7b54dd1 100644 --- a/common/recipes-lib/ipmi/files/ipmi.h +++ b/common/recipes-lib/ipmi/files/ipmi.h @@ -36,6 +36,7 @@ extern "C" { #define SIZE_AUTH_ENABLES 5 #define SIZE_IP_ADDR 4 +#define SIZE_IP6_ADDR 16 #define SIZE_MAC_ADDR 6 #define SIZE_NET_MASK 4 #define SIZE_IP_HDR 3 @@ -58,7 +59,8 @@ extern "C" { #define SIZE_SEL_REC 16 -#define BIC_INTF_HDR_SIZE 3 +// NetFn, Command, Checksum, IANAID(3 bytes), BIC Interface type +#define BIC_INTF_HDR_SIZE 7 #define LUN_OFFSET 2 @@ -76,6 +78,8 @@ extern "C" { #define TYPE_ASCII_6BIT 2 #define TYPE_ASCII_8BIT 3 +#define TIMEOUT_IPMI 5 + // IPMI request Structure (IPMI/Section 9.2) typedef struct { @@ -231,6 +235,7 @@ typedef struct unsigned char no_of_dest; unsigned char dest_type[SIZE_DEST_TYPE]; unsigned char dest_addr[SIZE_DEST_ADDR]; + unsigned char ip6_addr[SIZE_IP6_ADDR]; } lan_config_t; // Structure to store Processor Information @@ -322,6 +327,7 @@ enum { CMD_STORAGE_GET_FRUID_INFO = 0x10, CMD_STORAGE_READ_FRUID_DATA = 0x11, + CMD_STORAGE_WRITE_FRUID_DATA = 0x12, CMD_STORAGE_GET_SDR_INFO = 0x20, CMD_STORAGE_RSV_SDR = 0x22, CMD_STORAGE_GET_SDR = 0x23, @@ -354,17 +360,21 @@ enum CMD_OEM_SET_DIMM_INFO = 0x1C, CMD_OEM_SET_POST_START = 0x73, CMD_OEM_SET_POST_END = 0x74, + CMD_OEM_GET_SLOT_INFO = 0x7E, }; // OEM 1S Command Codes (Quanta/FB defined commands) enum { CMD_OEM_1S_MSG_IN = 0x1, + CMD_OEM_1S_MSG_OUT = 0x2, CMD_OEM_1S_GET_GPIO = 0x3, CMD_OEM_1S_GET_GPIO_CONFIG = 0x5, CMD_OEM_1S_SET_GPIO_CONFIG = 0x6, CMD_OEM_1S_INTR = 0x7, CMD_OEM_1S_POST_BUF = 0x8, + CMD_OEM_1S_UPDATE_FW = 0x9, + CMD_OEM_1S_GET_FW_VER = 0xB, CMD_OEM_1S_GET_CONFIG = 0xE, CMD_OEM_1S_PLAT_DISC = 0xF, CMD_OEM_1S_SET_CONFIG = 0x10, @@ -408,6 +418,7 @@ enum LAN_PARAM_NO_OF_DEST, LAN_PARAM_DEST_TYPE, LAN_PARAM_DEST_ADDR, + LAN_PARAM_IP6_ADDR = 197, /* OEM parameter for IPv6 */ }; // Boot Option Parameters (IPMI/Table 28-14) @@ -441,6 +452,7 @@ enum BIC_INTF_ME = 0x01, BIC_INTF_SOL = 0x02, BIC_INTF_KCS = 0x03, + BIC_INTF_KCS_SMM = 0x04, }; void lib_ipmi_handle(unsigned char *request, unsigned char req_len, diff --git a/common/recipes-lib/sdr/files/Makefile b/common/recipes-lib/sdr/files/Makefile index 11fe3ee..607f914 100644 --- a/common/recipes-lib/sdr/files/Makefile +++ b/common/recipes-lib/sdr/files/Makefile @@ -3,7 +3,7 @@ lib: libsdr.so libsdr.so: sdr.c $(CC) $(CFLAGS) -fPIC -c -o sdr.o sdr.c - $(CC) -lm -shared -o libsdr.so sdr.o -lc + $(CC) -lpal -lm -shared -o libsdr.so sdr.o -lc .PHONY: clean diff --git a/common/recipes-lib/sdr/files/sdr.c b/common/recipes-lib/sdr/files/sdr.c index 208b10f..2b05bf5 100644 --- a/common/recipes-lib/sdr/files/sdr.c +++ b/common/recipes-lib/sdr/files/sdr.c @@ -27,6 +27,7 @@ #include <fcntl.h> #include <errno.h> #include <syslog.h> +#include <string.h> #include "sdr.h" #define FIELD_RATE_UNIT(x) ((x & (0x07 << 3)) >> 3) @@ -34,7 +35,9 @@ #define FIELD_PERCENTAGE(x) (x & 0x01) #define FIELD_TYPE(x) ((x & (0x03 << 6)) >> 6) -#define FIELD_LEN(x) (x & 0xF) +#define FIELD_LEN(x) (x & 0x1F) + +#define MAX_NAME_LEN 16 /* Array for BCD Plus definition. */ const char bcd_plus_array[] = "0123456789 -.XXX"; @@ -48,10 +51,11 @@ const char * ascii_6bit[4] = { }; /* Get the units of the sensor from the SDR */ -int -sdr_get_sensor_units(sdr_full_t *sdr, uint8_t *op, uint8_t *modifier, +static int +_sdr_get_sensor_units(sdr_full_t *sdr, uint8_t *op, uint8_t *modifier, char *units) { + int ret; uint8_t percent; uint8_t rate_idx; uint8_t base_idx; @@ -88,10 +92,46 @@ sdr_get_sensor_units(sdr_full_t *sdr, uint8_t *op, uint8_t *modifier, return 0; } +int +sdr_get_sensor_units(uint8_t fru, uint8_t snr_num, char *units) { + + int ret = 0; + uint8_t op; + uint8_t modifier; + sdr_full_t *sdr; + + sensor_info_t sinfo[MAX_SENSOR_NUM] = {0}; + + if (pal_sensor_sdr_init(fru, sinfo) < 0) { + sdr = NULL; + } else { + sdr = &sinfo[snr_num].sdr; + } + + if (sdr != NULL) { + ret = _sdr_get_sensor_units(sdr, &op, &modifier, units); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "_sdr_get_sensor_units failed for FRU: %d snr_num: %d", + fru, snr_num); +#endif + } + } else { + ret = pal_get_sensor_units(fru, snr_num, units); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "pal_get_sensor_units failed for FRU: %d snr_num: %d", + fru, snr_num); +#endif + } + } + + return ret; +} /* Get the name of the sensor from the SDR */ -int -sdr_get_sensor_name(sdr_full_t *sdr, char *name) { +static int +_sdr_get_sensor_name(sdr_full_t *sdr, char *name) { int field_type, field_len; int idx, idx_eff, val; char *str; @@ -105,9 +145,9 @@ sdr_get_sensor_name(sdr_full_t *sdr, char *name) { /* Case: length is zero */ if (field_len == 1) { - syslog(LOG_ALERT, "get_sensor_name: str length is 0\n"); - // TODO: Fix this hack later - sprintf(name, "%s", str); +#ifdef DEBUG + syslog(LOG_WARNING, "get_sensor_name: str length is 0\n"); +#endif return -1; } @@ -174,37 +214,326 @@ sdr_get_sensor_name(sdr_full_t *sdr, char *name) { return 0; } -/* Populates all sensor_info_t struct using the path to SDR dump */ int -sdr_init(char *path, sensor_info_t *sinfo) { - int fd; - uint8_t buf[MAX_SDR_LEN] = {0}; - uint8_t bytes_rd = 0; - uint8_t snr_num = 0; +sdr_get_sensor_name(uint8_t fru, uint8_t snr_num, char *name) { + + int ret = 0; sdr_full_t *sdr; - while (access(path, F_OK) == -1) { - sleep(5); + sensor_info_t sinfo[MAX_SENSOR_NUM] = {0}; + + if (pal_sensor_sdr_init(fru, sinfo) < 0) { + sdr = NULL; + } else { + sdr = &sinfo[snr_num].sdr; } - fd = open(path, O_RDONLY); - if (fd < 0) { - syslog(LOG_ERR, "sdr_init: open failed for %s\n", path); - return -1; + if (sdr != NULL) { + ret = _sdr_get_sensor_name(sdr, name); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "_sdr_get_sensor_name failed for FRU: %d snr_num: %d", + fru, snr_num); +#endif + } + } else { + ret = pal_get_sensor_name(fru, snr_num, name); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "pal_get_sensor_name failed for FRU: %d snr_num: %d", + fru, snr_num); +#endif + } } - while ((bytes_rd = read(fd, buf, sizeof(sdr_full_t))) > 0) { - if (bytes_rd != sizeof(sdr_full_t)) { - syslog(LOG_ERR, "sdr_init: read returns %d bytes\n", bytes_rd); + return ret; +} + +/* Get the threshold values from the SDRs */ +static int +get_sdr_thresh_val(uint8_t fru, sdr_full_t *sdr, uint8_t snr_num, + uint8_t thresh, void *value) { + + int ret; + uint8_t x; + uint8_t m_lsb, m_msb, m; + uint8_t b_lsb, b_msb, b; + int8_t b_exp, r_exp; + uint8_t thresh_val; + + switch (thresh) { + case UCR_THRESH: + thresh_val = sdr->uc_thresh; + break; + case UNC_THRESH: + thresh_val = sdr->unc_thresh; + break; + case UNR_THRESH: + thresh_val = sdr->unr_thresh; + break; + case LCR_THRESH: + thresh_val = sdr->lc_thresh; + break; + case LNC_THRESH: + thresh_val = sdr->lnc_thresh; + break; + case LNR_THRESH: + thresh_val = sdr->lnr_thresh; + break; + case POS_HYST: + thresh_val = sdr->pos_hyst; + break; + case NEG_HYST: + thresh_val = sdr->neg_hyst; + break; + default: +#ifdef DEBUG + syslog(LOG_ERR, "get_sdr_thresh_val: reading unknown threshold val"); +#endif return -1; + } + + // y = (mx + b * 10^b_exp) * 10^r_exp + x = thresh_val; + + m_lsb = sdr->m_val; + m_msb = sdr->m_tolerance >> 6; + m = (m_msb << 8) | m_lsb; + + b_lsb = sdr->b_val; + b_msb = sdr->b_accuracy >> 6; + b = (b_msb << 8) | b_lsb; + + // exponents are 2's complement 4-bit number + b_exp = sdr->rb_exp & 0xF; + if (b_exp > 7) { + b_exp = (~b_exp + 1) & 0xF; + b_exp = -b_exp; + } + r_exp = (sdr->rb_exp >> 4) & 0xF; + if (r_exp > 7) { + r_exp = (~r_exp + 1) & 0xF; + r_exp = -r_exp; + } + + * (float *) value = ((m * x) + (b * pow(10, b_exp))) * (pow(10, r_exp)); + + return 0; +} + + + +/* + * Populate all fields of thresh_sensor_t struct for a particular sensor. + * Incase the threshold value is 0 mask the check for that threshvold + * value in flag field. + */ +static int +_sdr_get_snr_thresh(uint8_t fru, sdr_full_t *sdr, uint8_t snr_num, + uint8_t flag, thresh_sensor_t *snr) { + + int ret; + int value; + float fvalue; + uint8_t op, modifier; + + snr->flag = flag; + snr->curr_state = NORMAL_STATE; + + if (_sdr_get_sensor_name(sdr, snr->name)) { +#ifdef DEBUG + syslog(LOG_WARNING, "sdr_get_sensor_name: FRU %d: num: 0x%X: reading name" + " from SDR failed.", fru, snr_num); +#endif + return -1; + } + + // TODO: Add support for modifier (Mostly modifier is zero) + if (_sdr_get_sensor_units(sdr, &op, &modifier, snr->units)) { +#ifdef DEBUG + syslog(LOG_WARNING, "sdr_get_sensor_units: FRU %d: num 0x%X: reading units" + " from SDR failed.", fru, snr_num); +#endif + return -1; + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, UCR_THRESH, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, UCR_THRESH", + fru, snr_num, snr->name); +#endif + } else { + snr->ucr_thresh = fvalue; + if (!(fvalue)) { + snr->flag = CLEARBIT(snr->flag, UCR_THRESH); + } + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, UNC_THRESH, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, UNC_THRESH", + fru, snr_num, snr->name); +#endif + } else { + snr->unc_thresh = fvalue; + if (!(fvalue)) { + snr->flag = CLEARBIT(snr->flag, UNC_THRESH); + } + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, UNR_THRESH, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, UNR_THRESH", + fru, snr_num, snr->name); +#endif + } else { + snr->unr_thresh = fvalue; + if (!(fvalue)) { + snr->flag = CLEARBIT(snr->flag, UNR_THRESH); + } + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, LCR_THRESH, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, LCR_THRESH", + fru, snr_num, snr->name); +#endif + } else { + snr->lcr_thresh = fvalue; + if (!(fvalue)) { + snr->flag = CLEARBIT(snr->flag, LCR_THRESH); } + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, LNC_THRESH, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, LNC_THRESH", + fru, snr_num, snr->name); +#endif + } else { + snr->lnc_thresh = fvalue; + if (!(fvalue)) { + snr->flag = CLEARBIT(snr->flag, LNC_THRESH); + } + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, LNR_THRESH, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, LNR_THRESH", + fru, snr_num, snr->name); +#endif + } else { + snr->lnr_thresh = fvalue; + if (!(fvalue)) { + snr->flag = CLEARBIT(snr->flag, LNR_THRESH); + } + } - sdr = (sdr_full_t *) buf; - snr_num = sdr->sensor_num; - sinfo[snr_num].valid = true; - memcpy(&sinfo[snr_num].sdr, sdr, sizeof(sdr_full_t)); + if (get_sdr_thresh_val(fru, sdr, snr_num, POS_HYST, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, POS_HYST", + fru, snr_num, snr->name); +#endif + } else { + snr->pos_hyst = fvalue; + } + + if (get_sdr_thresh_val(fru, sdr, snr_num, NEG_HYST, &fvalue)) { +#ifdef DEBUG + syslog(LOG_ERR, + "get_sdr_thresh_val: failed for FRU: %d, num: 0x%X, %-16s, NEG_HYST", + fru, snr_num, snr->name); +#endif + } else { + snr->neg_hyst = fvalue; } return 0; } +int +sdr_get_snr_thresh(uint8_t fru,uint8_t snr_num, uint8_t flag, + thresh_sensor_t *snr) { + + int ret = 0; + sdr_full_t *sdr; +#ifdef DEBUG + int cnt = 0; +#endif /* DEBUG */ + int retry = 0; + + sensor_info_t sinfo[MAX_SENSOR_NUM] = {0}; + + ret = pal_sensor_sdr_init(fru, sinfo); + + while (ret == ERR_NOT_READY) { + + if (retry++ > MAX_RETRIES_SDR_INIT) { + syslog(LOG_INFO, "sdr_get_snr_thresh: failed for fru: %d", fru); + return -1; + } +#ifdef DEBUG + syslog(LOG_INFO, "sdr_get_snr_thresh: fru: %d, ret: %d cnt: %d", fru, ret, cnt++); +#endif /* DEBUG */ + sleep(1); + ret = pal_sensor_sdr_init(fru, sinfo); + } + + + if (ret < 0) { + sdr = NULL; + } else { + sdr = &sinfo[snr_num].sdr; + } + + if (sdr != NULL) { + ret = _sdr_get_snr_thresh(fru, sdr, snr_num, flag, snr); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "_sdr_get_snr_thresh failed for FRU: %d snr_num: %d", + fru, snr_num); +#endif + } + } else { + + snr->flag = flag; + ret = pal_get_sensor_name(fru, snr_num, snr->name); + ret = pal_get_sensor_units(fru, snr_num, snr->units); + ret = pal_get_sensor_threshold(fru, snr_num, UCR_THRESH, &(snr->ucr_thresh)); + if (!(snr->ucr_thresh)) { + snr->flag = CLEARBIT(snr->flag, UCR_THRESH); + } + ret = pal_get_sensor_threshold(fru, snr_num, UNC_THRESH, &(snr->unc_thresh)); + if (!(snr->unc_thresh)) { + snr->flag = CLEARBIT(snr->flag, UNC_THRESH); + } + ret = pal_get_sensor_threshold(fru, snr_num, UNR_THRESH, &(snr->unr_thresh)); + if (!(snr->unr_thresh)) { + snr->flag = CLEARBIT(snr->flag, UNR_THRESH); + } + ret = pal_get_sensor_threshold(fru, snr_num, LCR_THRESH, &(snr->lcr_thresh)); + if (!(snr->lcr_thresh)) { + snr->flag = CLEARBIT(snr->flag, LCR_THRESH); + } + ret = pal_get_sensor_threshold(fru, snr_num, LNC_THRESH, &(snr->lnc_thresh)); + if (!(snr->lnc_thresh)) { + snr->flag = CLEARBIT(snr->flag, LNC_THRESH); + } + ret = pal_get_sensor_threshold(fru, snr_num, LNR_THRESH, &(snr->lnr_thresh)); + if (!(snr->lnr_thresh)) { + snr->flag = CLEARBIT(snr->flag, LNR_THRESH); + } + ret = pal_get_sensor_threshold(fru, snr_num, POS_HYST, &(snr->pos_hyst)); + ret = pal_get_sensor_threshold(fru, snr_num, NEG_HYST, &(snr->neg_hyst)); + + } + + return ret; +} diff --git a/common/recipes-lib/sdr/files/sdr.h b/common/recipes-lib/sdr/files/sdr.h index c474fb1..c260914 100644 --- a/common/recipes-lib/sdr/files/sdr.h +++ b/common/recipes-lib/sdr/files/sdr.h @@ -23,21 +23,40 @@ #include <stdbool.h> #include <openbmc/ipmi.h> +#include <openbmc/pal.h> #ifdef __cplusplus extern "C" { #endif #define MAX_SDR_LEN 64 - +#define NORMAL_STATE 0x00 +#define MAX_SENSOR_NUM 0xFF #define MAX_SENSOR_RATE_UNIT 7 #define MAX_SENSOR_BASE_UNIT 92 -typedef struct _sensor_info_t { - bool valid; - sdr_full_t sdr; -} sensor_info_t; +#define SETBIT(x, y) (x | (1 << y)) +#define GETBIT(x, y) ((x & (1 << y)) > y) +#define CLEARBIT(x, y) (x & (~(1 << y))) +#define GETMASK(y) (1 << y) + +/* To hold the sensor info and calculated threshold values from the SDR */ +typedef struct { + uint8_t flag; + float ucr_thresh; + float unc_thresh; + float unr_thresh; + float lcr_thresh; + float lnc_thresh; + float lnr_thresh; + float pos_hyst; + float neg_hyst; + int curr_state; + char name[17]; + char units[64]; + +} thresh_sensor_t; /* List of all the Sensor Rate Units types. */ const char * sensor_rate_units[] = { @@ -150,11 +169,10 @@ const char * sensor_base_units[] = { "", /* 093 */ }; -int sdr_init(char *path, sensor_info_t *sinfo); - -int sdr_get_sensor_units(sdr_full_t *sdr, uint8_t *op, uint8_t *modifier, - char *units); -int sdr_get_sensor_name(sdr_full_t *sdr, char *name); +int sdr_get_sensor_name(uint8_t fru, uint8_t snr_num, char *name); +int sdr_get_sensor_units(uint8_t fru, uint8_t snr_num, char *units); +int sdr_get_snr_thresh(uint8_t fru, uint8_t snr_num, uint8_t flag, + thresh_sensor_t *snr); #ifdef __cplusplus } // extern "C" diff --git a/common/recipes-lib/sdr/libsdr_0.1.bb b/common/recipes-lib/sdr/libsdr_0.1.bb index 958e0c6..73ebf3f 100644 --- a/common/recipes-lib/sdr/libsdr_0.1.bb +++ b/common/recipes-lib/sdr/libsdr_0.1.bb @@ -16,7 +16,7 @@ SRC_URI = "file://Makefile \ S = "${WORKDIR}" -DEPENDS += " libipmi " +DEPENDS += " libipmi libpal " do_install() { install -d ${D}${libdir} diff --git a/common/recipes-rest/cherryPy/cherryPy_3.8.0.bb b/common/recipes-rest/cherryPy/cherryPy_3.8.0.bb new file mode 100644 index 0000000..3c2179e --- /dev/null +++ b/common/recipes-rest/cherryPy/cherryPy_3.8.0.bb @@ -0,0 +1,14 @@ +DESCRIPTION = "CherryPy HTTP framework" +SECTION = "base" +LICENSE = "BSD" +LIC_FILES_CHKSUM = "file://cherrypy/LICENSE.txt;md5=a476d86a3f85c89411ecaad012eed1e3" + +SRC_URI = "https://pypi.python.org/packages/source/C/CherryPy/CherryPy-${PV}.tar.gz" +SRC_URI[md5sum] = "542b96b2cd825e8120e8cd822bc18f4b" +SRC_URI[sha256sum] = "ffcdb43667d4098247efaf8c82dd36d3dd4f8e5dc768ef5e90b480899e523bea" + +S = "${WORKDIR}/CherryPy-${PV}" + +inherit setuptools + +FILES_${PN} += "/usr/lib/* /usr/share/cherrypy" diff --git a/common/recipes-rest/rest-api/files/node_server.py b/common/recipes-rest/rest-api/files/node_server.py index 57a5c42..cf64f03 100644 --- a/common/recipes-rest/rest-api/files/node_server.py +++ b/common/recipes-rest/rest-api/files/node_server.py @@ -56,7 +56,7 @@ class serverNode(node): else: res = 'success' - result = { "result": res } + result = { "result": res } return result @@ -64,6 +64,9 @@ def get_node_server(num): actions = ["power-on", "power-off", "power-cycle", - "graceful-shutdown" + "graceful-shutdown", + "12v-on", + "12v-off", + "12v-cycle" ] return serverNode(num = num, actions = actions) diff --git a/common/recipes-rest/rest-api/files/pal.py b/common/recipes-rest/rest-api/files/pal.py index 8faef30..f0e076d 100644 --- a/common/recipes-rest/rest-api/files/pal.py +++ b/common/recipes-rest/rest-api/files/pal.py @@ -67,6 +67,14 @@ def pal_set_server_power(slot_id, command): cmd.value = 2 elif command == 'graceful-shutdown': cmd.value = 3 + elif command == '12v-off': + cmd.value = 4 + elif command == '12v-on': + cmd.value = 5 + elif command == '12v-cycle': + cmd.value = 6 + else: + return -1 ret = lpal_hndl.pal_set_server_power(slot_id, cmd) if ret: return -1 diff --git a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py b/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py deleted file mode 100644 index 7c126d9..0000000 --- a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/python -tt -# Copyright 2015-present Facebook. All rights reserved. -# -# This program file 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; version 2 of the License. -# -# 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 in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -from board_gpio_table import board_gpio_table -from soc_gpio_table import soc_gpio_table - -import openbmc_gpio -import openbmc_gpio_table - -import logging -import sys - - -def setup_board_gpio(soc_gpio_table, board_gpio_table, validate=True): - soc = openbmc_gpio_table.SocGPIOTable(soc_gpio_table) - gpio_configured = [] - for gpio in board_gpio_table: - try: - soc.config_function(gpio.gpio, write_through=False) - gpio_configured.append(gpio.gpio) - except openbmc_gpio_table.ConfigUnknownFunction as e: - # not multiple-function GPIO pin - pass - except openbmc_gpio_table.NotSmartEnoughException as e: - logging.error('Failed to configure "%s" for "%s": %s' - % (gpio.gpio, gpio.shadow, str(e))) - - soc.write_to_hw() - - if validate: - all_functions = set(soc.get_active_functions(refresh=True)) - for gpio in gpio_configured: - if gpio not in all_functions: - raise Exception('Failed to configure function "%s"' % gpio) - - for gpio in board_gpio_table: - openbmc_gpio.gpio_export(gpio.gpio, gpio.shadow) - if gpio.value == openbmc_gpio_table.GPIO_INPUT: - continue - elif gpio.value == openbmc_gpio_table.GPIO_OUT_HIGH: - openbmc_gpio.gpio_set(gpio.gpio, 1) - elif gpio.value == openbmc_gpio_table.GPIO_OUT_LOW: - openbmc_gpio.gpio_set(gpio.gpio, 0) - else: - raise Exception('Invalid value "%s"' % gpio.value) - -def main(): - print('Setting up GPIOs ... ', end='') - sys.stdout.flush() - openbmc_gpio.setup_shadow() - setup_board_gpio(soc_gpio_table, board_gpio_table) - print('Done') - sys.stdout.flush() - return 0 - -if __name__ == '__main__': - sys.exit(main()) diff --git a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py b/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py index dda8a98..d188dcb 100644 --- a/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py +++ b/common/recipes-utils/openbmc-gpio/files/openbmc_gpio_table.py @@ -21,6 +21,7 @@ from __future__ import unicode_literals from soc_gpio import soc_get_register +import openbmc_gpio import logging import os import sys @@ -267,3 +268,36 @@ class BoardGPIO(object): self.gpio = gpio self.shadow = shadow self.value = value + +def setup_board_gpio(soc_gpio_table, board_gpio_table, validate=True): + soc = SocGPIOTable(soc_gpio_table) + gpio_configured = [] + for gpio in board_gpio_table: + try: + soc.config_function(gpio.gpio, write_through=False) + gpio_configured.append(gpio.gpio) + except ConfigUnknownFunction as e: + # not multiple-function GPIO pin + pass + except NotSmartEnoughException as e: + logging.error('Failed to configure "%s" for "%s": %s' + % (gpio.gpio, gpio.shadow, str(e))) + + soc.write_to_hw() + + if validate: + all_functions = set(soc.get_active_functions(refresh=True)) + for gpio in gpio_configured: + if gpio not in all_functions: + raise Exception('Failed to configure function "%s"' % gpio) + + for gpio in board_gpio_table: + openbmc_gpio.gpio_export(gpio.gpio, gpio.shadow) + if gpio.value == GPIO_INPUT: + continue + elif gpio.value == GPIO_OUT_HIGH: + openbmc_gpio.gpio_set(gpio.gpio, 1) + elif gpio.value == GPIO_OUT_LOW: + openbmc_gpio.gpio_set(gpio.gpio, 0) + else: + raise Exception('Invalid value "%s"' % gpio.value) diff --git a/common/recipes-utils/openbmc-gpio/files/setup.py b/common/recipes-utils/openbmc-gpio/files/setup.py index 59c7de4..bf7be3d 100644 --- a/common/recipes-utils/openbmc-gpio/files/setup.py +++ b/common/recipes-utils/openbmc-gpio/files/setup.py @@ -18,6 +18,7 @@ from distutils.core import setup +from setup_board import board_py_modules setup( name = 'openbmc-gpio', @@ -31,6 +32,6 @@ setup( 'phymemory', 'soc_gpio', 'soc_gpio_table', - 'board_gpio_table', - ], + 'board_gpio_table', ] + + board_py_modules , ) diff --git a/common/recipes-utils/openbmc-gpio/files/setup_board.py b/common/recipes-utils/openbmc-gpio/files/setup_board.py new file mode 100644 index 0000000..aff7398 --- /dev/null +++ b/common/recipes-utils/openbmc-gpio/files/setup_board.py @@ -0,0 +1,23 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +# This is a dummy board GPIO table. If this is included in the final image, +# please double check the configuration of your image to define the correct +# GPIO table to be used for your board. + +board_py_modules = [ +] diff --git a/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb b/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb index 6bf4cc1..a2b46d4 100644 --- a/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb +++ b/common/recipes-utils/openbmc-gpio/openbmc-gpio_0.1.bb @@ -25,12 +25,12 @@ SRC_URI = " \ file://board_gpio_table.py \ file://openbmc_gpio.py \ file://openbmc_gpio_table.py \ - file://openbmc_gpio_setup.py \ file://openbmc_gpio_util.py \ file://phymemory.py \ file://setup.py \ file://soc_gpio.py \ file://soc_gpio_table.py \ + file://setup_board.py \ " S = "${WORKDIR}" @@ -41,9 +41,6 @@ OPENBMC_GPIO_UTILS = " \ OPENBMC_GPIO_SOC_TABLE = "soc_gpio_table.py" -# Change OPENBMC_GPIO_SETUP to "0" to exclude openbmc_gpio_setup.py from the image -OPENBMC_GPIO_SETUP = "1" - inherit distutils DEPENDS_${PN} = "python python-distribute update-rc.d-native" @@ -63,13 +60,5 @@ do_install_append() { for f in ${OPENBMC_GPIO_UTILS}; do install -m 755 $f ${localbindir}/${f} done - - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/rcS.d - if [ "${OPENBMC_GPIO_SETUP}" == "1" ]; then - install -m 755 openbmc_gpio_setup.py ${D}${sysconfdir}/init.d/openbmc_gpio_setup.py - update-rc.d -r ${D} openbmc_gpio_setup.py start 59 S . - fi } -FILES_${PN} += "/usr/local/bin ${sysconfdir}" diff --git a/common/recipes-utils/spatula/files/setup-spatula.sh b/common/recipes-utils/spatula/files/setup-spatula.sh index 391a212..238f395 100644 --- a/common/recipes-utils/spatula/files/setup-spatula.sh +++ b/common/recipes-utils/spatula/files/setup-spatula.sh @@ -31,7 +31,7 @@ . /etc/init.d/functions ACTION="$1" -CMD="/usr/local/bin/spatula_wrapper.py" +CMD="/usr/local/bin/spatula_wrapper.py --lldp" case "$ACTION" in start) echo -n "Setting up Spatula: " diff --git a/common/recipes-utils/spatula/files/spatula_wrapper.py b/common/recipes-utils/spatula/files/spatula_wrapper.py index 2717bef..770e4e8 100644 --- a/common/recipes-utils/spatula/files/spatula_wrapper.py +++ b/common/recipes-utils/spatula/files/spatula_wrapper.py @@ -24,35 +24,81 @@ import os import subprocess import time import argparse +import re SPATULA_FILE = '/etc/spatula/spatula' +LLDP_UTIL = '/usr/bin/lldp-util' LOG_FORMAT = '[%(levelname)s] %(asctime)s: %(message)s' DATE_FORMAT = '%Y-%m-%d %H:%M:%S' DEFAULT_SLEEP = 900 # default sleep 15 mins +DEFAULT_PORT = 8087 +DEFAULT_INTERFACE = 'usb0' class SpatulaWrapper(object): def __init__(self, address='fe80::2', interface='usb0', - port=8087, ssl=False): - proto = 'http' - if ssl: - proto = 'https' + port=8087, tls=False, lldp=False): + self.interface = interface + self.lldp = lldp + self.port = port + self.proto = 'http' + if tls: + self.proto = 'https' + # not used if auto-discovering self.url = '{proto}://{address}%{iface}:{port}'.format( - proto = proto, + proto = self.proto, address = address, - iface = interface, - port = port) + iface = self.interface, + port = self.port) + + def _getLldpMessage(self): + try: + if os.path.exists(LLDP_UTIL): + # request a single packet and time out in 30 seconds + lldp = subprocess.Popen([LLDP_UTIL, '-n', '4', '-t', '30'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + found = [] + for line in lldp.stdout: + # example (one line): + # LLDP: local_port=eth0 \ + # remote_system=rsw1bz.19.snc1.facebook.com \ + # remote_port=00:90:fb:52:1a:49 + if line.startswith('LLDP: '): + matches = re.findall(r'\w+=\S+', line.replace('LLDP: ', '')) + matches = [m.split('=', 1) for m in matches] + found.append(dict(matches)) + if not found: + raise Exception('timed out waiting for LLDP packet') + # dedupe before returning since we may get multiple packets + # from the same device + return [dict(t) for t in set([tuple(d.items()) for d in found])] + else: + raise Exception('missing lldp-util: {}'.format(LLDP_UTIL)) + except Exception as err: + raise Exception('failed discovering management system via LLDP: {}'.format(err)) def _getSpatula(self, endpoint='/spatula'): ''' Get the executable spatula script from the host. ''' - url = '{}{}'.format(self.url, endpoint) - try: - request = urllib2.Request(url) - response = urllib2.urlopen(request) - return response.read() - except Exception as err: - raise Exception('failed getting Spatula {}: {}'.format(url, err)) + urls = [] + urls.append('{}{}'.format(self.url, endpoint)) + if self.lldp: + for lldp in self._getLldpMessage(): + urls.append('{proto}://{address}%{iface}:{port}{endpoint}'.format( + proto = self.proto, + address = lldp['remote_system'], + iface = lldp['local_port'], + port = self.port, + endpoint = endpoint)) + for url in urls: + try: + request = urllib2.Request(url) + response = urllib2.urlopen(request) + return response.read() + except Exception as err: + continue + raise Exception('failed getting Spatula {}: {}'.format(urls, err)) def _success(self, endpoint='/success'): ''' @@ -114,7 +160,18 @@ if __name__ == '__main__': args = argparse.ArgumentParser() args.add_argument('-s', '--sleep', default=DEFAULT_SLEEP, help='Sleep time between spatula runs (default=%(default)s)') + args.add_argument('--interface', '-i', default=DEFAULT_INTERFACE, + help='Interface to use for management system') + args.add_argument('--port', '-p', default=DEFAULT_PORT, + help='Port to contact on management system') + args.add_argument('--lldp', default=False, action="store_true", + help='Automatically discover management system with LLDP') + args.add_argument('--tls', default=False, action="store_true", + help='Connect to bmc_proxy using TLS') params = args.parse_args() logging.basicConfig(format=LOG_FORMAT, datefmt=DATE_FORMAT) - wrapper = SpatulaWrapper() + wrapper = SpatulaWrapper(interface=params.interface, + tls=params.tls, + port=params.port, + lldp=params.lldp) wrapper.run(params.sleep) diff --git a/meta-aspeed/conf/distro/include/tclibc-eglibc.inc b/meta-aspeed/conf/distro/include/tclibc-eglibc.inc new file mode 100644 index 0000000..15f5ee5 --- /dev/null +++ b/meta-aspeed/conf/distro/include/tclibc-eglibc.inc @@ -0,0 +1,40 @@ +# +# eglibc specific configuration +# + +LIBCEXTENSION = "${@['', '-gnu'][(d.getVar('ABIEXTENSION', True) or '') != '']}" + +# Add glibc overrides to the overrides for eglibc. +LIBCOVERRIDE = ":libc-glibc" +OVERRIDES .= "${LIBCOVERRIDE}" + +PREFERRED_PROVIDER_virtual/libiconv ?= "eglibc" +PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?= "nativesdk-eglibc" +PREFERRED_PROVIDER_virtual/nativesdk-libintl ?= "nativesdk-eglibc" +PREFERRED_PROVIDER_virtual/libintl ?= "eglibc" +PREFERRED_PROVIDER_virtual/libc ?= "eglibc" +PREFERRED_PROVIDER_virtual/nativesdk-libc ?= "nativesdk-eglibc" +PREFERRED_PROVIDER_virtual/libc-locale ?= "eglibc-locale" + +CXXFLAGS += "-fvisibility-inlines-hidden" + +LIBC_DEPENDENCIES = "libsegfault \ + eglibc \ + eglibc-dbg \ + eglibc-dev \ + eglibc-utils \ + eglibc-thread-db \ + ${@get_libc_locales_dependencies(d)}" + +LIBC_LOCALE_DEPENDENCIES = "\ + eglibc-localedata-i18n \ + eglibc-gconv-ibm850 \ + eglibc-gconv-cp1252 \ + eglibc-gconv-iso8859-1 \ + eglibc-gconv-iso8859-15" + +def get_libc_locales_dependencies(d): + if 'libc-locales' in (d.getVar('DISTRO_FEATURES', True) or '').split() : + return d.getVar('LIBC_LOCALE_DEPENDENCIES', True) or '' + else: + return '' diff --git a/meta-aspeed/conf/machine/include/ast1250.inc b/meta-aspeed/conf/machine/include/ast1250.inc index 099fdb0..210e3b5 100644 --- a/meta-aspeed/conf/machine/include/ast1250.inc +++ b/meta-aspeed/conf/machine/include/ast1250.inc @@ -11,12 +11,14 @@ EXTRA_IMAGEDEPENDS += "u-boot" # Uncomment the following line to enable the hard floating point abi. Note that # this breaks some binary libraries and 3D (neither of which ship with # meta-yocto). For maximum compatibility, leave this disabled. -DEFAULTTUNE ?= "arm926ejs" require conf/machine/include/tune-arm926ejs.inc PREFERRED_PROVIDER_virtual/kernel ?= "linux-aspeed" PREFERRED_VERSION_linux-aspeed ?= "2.6.28%" +PREFERRED_VERSION_u-boot ?= "v2013.07" +PREFERRED_VERSION_u-boot-fw-utils ?= "v2013.07" + KERNEL_IMAGETYPE ?= "uImage" KERNEL_EXTRA_ARGS ?= "UIMAGE_LOADADDR=0x40008000" diff --git a/meta-aspeed/recipes-bsp/u-boot/files/patch-2013.07/0003-u-boot-snapshot-of-OpenBMC-f926614.patch b/meta-aspeed/recipes-bsp/u-boot/files/patch-2013.07/0003-u-boot-snapshot-of-OpenBMC-f926614.patch new file mode 100644 index 0000000..559e65b --- /dev/null +++ b/meta-aspeed/recipes-bsp/u-boot/files/patch-2013.07/0003-u-boot-snapshot-of-OpenBMC-f926614.patch @@ -0,0 +1,13 @@ +diff --git a/meta-aspeed/recipes-bsp/u-boot/files/u-boot-v2013.07/include/configs/fbyosemite.h b/meta-aspeed/recipes-bsp/u-boot/files/u-boot-v2013.07/include/configs/fbyosemite.h +index 73a3cf9..397ca48 100644 +--- a/meta-aspeed/recipes-bsp/u-boot/files/u-boot-v2013.07/include/configs/fbyosemite.h ++++ b/meta-aspeed/recipes-bsp/u-boot/files/u-boot-v2013.07/include/configs/fbyosemite.h +@@ -155,7 +155,7 @@ + */ + #define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */ + #define PHYS_SDRAM_1 0x40000000 /* SDRAM Bank #1 */ +-#define PHYS_SDRAM_1_SIZE 0x8000000 /* 128 MB */ ++#define PHYS_SDRAM_1_SIZE 0x10000000 /* 256 MB */ + + #define CONFIG_SYS_SDRAM_BASE 0x40000000 + diff --git a/meta-aspeed/recipes-bsp/u-boot/u-boot-fw-utils_2013.07%.bbappend b/meta-aspeed/recipes-bsp/u-boot/u-boot-fw-utils_2013.07%.bbappend deleted file mode 100644 index be61682..0000000 --- a/meta-aspeed/recipes-bsp/u-boot/u-boot-fw-utils_2013.07%.bbappend +++ /dev/null @@ -1,13 +0,0 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/files:" - -SRC_URI += "file://fw_env.config \ - file://patch-2013.07/0000-u-boot-aspeed-064.patch \ - file://patch-2013.07/0001-u-boot-openbmc.patch \ - file://patch-2013.07/0002-Create-snapshot-of-OpenBMC.patch;striplevel=6 \ - " -do_install_append() { - if [ -e ${WORKDIR}/fw_env.config ] ; then - install -d ${D}${sysconfdir} - install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config - fi -} diff --git a/meta-aspeed/recipes-bsp/u-boot/u-boot-fw-utils_2013.07.bb b/meta-aspeed/recipes-bsp/u-boot/u-boot-fw-utils_2013.07.bb new file mode 100644 index 0000000..fcf8ac8 --- /dev/null +++ b/meta-aspeed/recipes-bsp/u-boot/u-boot-fw-utils_2013.07.bb @@ -0,0 +1,38 @@ +SUMMARY = "U-Boot bootloader fw_printenv/setenv utilities" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=1707d6db1d42237583f50183a5651ecb" +SECTION = "bootloader" +DEPENDS = "mtd-utils" + +# This revision corresponds to the tag "v2013.07" +# We use the revision in order to avoid having to fetch it from the +# repo during parse +SRCREV = "62c175fbb8a0f9a926c88294ea9f7e88eb898f6c" + +PV = "v2013.07" + +SRC_URI = "git://git.denx.de/u-boot.git;branch=master;protocol=git \ + file://patch-2013.07/0000-u-boot-aspeed-064.patch \ + file://patch-2013.07/0001-u-boot-openbmc.patch \ + file://patch-2013.07/0002-Create-snapshot-of-OpenBMC.patch;striplevel=6 \ + file://patch-2013.07/0003-u-boot-snapshot-of-OpenBMC-f926614.patch;striplevel=6 \ + " + +S = "${WORKDIR}/git" + +EXTRA_OEMAKE = 'HOSTCC="${CC}" HOSTSTRIP="true"' + +inherit uboot-config + +do_compile () { + oe_runmake ${UBOOT_MACHINE} + oe_runmake env +} + +do_install () { + install -d ${D}${base_sbindir} + install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_printenv + install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_setenv +} + +PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/meta-aspeed/recipes-bsp/u-boot/u-boot.inc b/meta-aspeed/recipes-bsp/u-boot/u-boot.inc new file mode 100644 index 0000000..cb1c403 --- /dev/null +++ b/meta-aspeed/recipes-bsp/u-boot/u-boot.inc @@ -0,0 +1,78 @@ +SUMMARY = "Universal Boot Loader for embedded devices" +HOMEPAGE = "http://www.denx.de/wiki/U-Boot/WebHome" +SECTION = "bootloaders" +PROVIDES = "virtual/bootloader" + +inherit uboot-config deploy + +EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}"' + +# Allow setting an additional version string that will be picked up by the +# u-boot build system and appended to the u-boot version. If the .scmversion +# file already exists it will not be overwritten. +UBOOT_LOCALVERSION ?= "" + +# Some versions of u-boot use .bin and others use .img. By default use .bin +# but enable individual recipes to change this value. +UBOOT_SUFFIX ?= "bin" +UBOOT_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}" +UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}" +UBOOT_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_SUFFIX}" +UBOOT_MAKE_TARGET ?= "all" + +# Some versions of u-boot build an SPL (Second Program Loader) image that +# should be packaged along with the u-boot binary as well as placed in the +# deploy directory. For those versions they can set the following variables +# to allow packaging the SPL. +SPL_BINARY ?= "" +SPL_IMAGE ?= "${SPL_BINARY}-${MACHINE}-${PV}-${PR}" +SPL_SYMLINK ?= "${SPL_BINARY}-${MACHINE}" + +do_compile () { + if [ "${@base_contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then + sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' config.mk + fi + + unset LDFLAGS + unset CFLAGS + unset CPPFLAGS + + if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ] + then + echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion + echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion + fi + + oe_runmake ${UBOOT_MACHINE} + oe_runmake ${UBOOT_MAKE_TARGET} +} + +do_install () { + if [ -e ${WORKDIR}/fw_env.config ] ; then + install -d ${D}${sysconfdir} + install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config + fi +} + +FILES_${PN} = "${sysconfdir}" +FILESPATH =. "${FILE_DIRNAME}/u-boot-git/${MACHINE}:" + +do_deploy () { + install -d ${DEPLOYDIR} + install ${S}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE} + + cd ${DEPLOYDIR} + rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK} + ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK} + ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY} + + if [ "x${SPL_BINARY}" != "x" ] + then + install ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE} + rm -f ${DEPLOYDIR}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_SYMLINK} + ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARY} + ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK} + fi +} + +addtask deploy before do_build after do_compile diff --git a/meta-aspeed/recipes-bsp/u-boot/u-boot_2013.07%.bbappend b/meta-aspeed/recipes-bsp/u-boot/u-boot_2013.07%.bbappend deleted file mode 100644 index a2f26a5..0000000 --- a/meta-aspeed/recipes-bsp/u-boot/u-boot_2013.07%.bbappend +++ /dev/null @@ -1,6 +0,0 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/files:" - -SRC_URI += "file://patch-2013.07/0000-u-boot-aspeed-064.patch \ - file://patch-2013.07/0001-u-boot-openbmc.patch \ - file://patch-2013.07/0002-Create-snapshot-of-OpenBMC.patch;striplevel=6 \ - " diff --git a/meta-aspeed/recipes-bsp/u-boot/u-boot_2013.07.bb b/meta-aspeed/recipes-bsp/u-boot/u-boot_2013.07.bb new file mode 100644 index 0000000..253c525 --- /dev/null +++ b/meta-aspeed/recipes-bsp/u-boot/u-boot_2013.07.bb @@ -0,0 +1,23 @@ +require u-boot.inc + +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=1707d6db1d42237583f50183a5651ecb \ + file://README;beginline=1;endline=22;md5=78b195c11cb6ef63e6985140db7d7bab" + +# This revision corresponds to the tag "v2013.07" +# We use the revision in order to avoid having to fetch it from the repo during parse +SRCREV = "62c175fbb8a0f9a926c88294ea9f7e88eb898f6c" + +PV = "v2013.07" + +SRC_URI = "git://git.denx.de/u-boot.git;branch=master \ + file://fw_env.config \ + file://patch-2013.07/0000-u-boot-aspeed-064.patch \ + file://patch-2013.07/0001-u-boot-openbmc.patch \ + file://patch-2013.07/0002-Create-snapshot-of-OpenBMC.patch;striplevel=6 \ + file://patch-2013.07/0003-u-boot-snapshot-of-OpenBMC-f926614.patch;striplevel=6 \ + " + +S = "${WORKDIR}/git" + +PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/meta-aspeed/recipes-core/eglibc/cross-localedef-native_2.19.bb b/meta-aspeed/recipes-core/eglibc/cross-localedef-native_2.19.bb new file mode 100644 index 0000000..3ce0e1d --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/cross-localedef-native_2.19.bb @@ -0,0 +1,49 @@ +SUMMARY = "Cross locale generation tool for eglibc" +HOMEPAGE = "http://www.eglibc.org/home" +SECTION = "libs" +LICENSE = "LGPL-2.1" + +LIC_DIR = "${WORKDIR}/eglibc-${PV}/libc" +LIC_FILES_CHKSUM = "file://${LIC_DIR}/LICENSES;md5=e9a558e243b36d3209f380deb394b213 \ + file://${LIC_DIR}/COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://${LIC_DIR}/posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ + file://${LIC_DIR}/COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" + + +inherit native +inherit autotools + +# pick up an eglibc patch +FILESPATH = "${FILE_DIRNAME}/eglibc-${PV}" + +SRC_URI = "http://downloads.yoctoproject.org/releases/eglibc/eglibc-${PV}-svnr25243.tar.bz2 \ + file://fix_for_centos_5.8.patch;patchdir=.. \ + " +SRC_URI[md5sum] = "197836c2ba42fb146e971222647198dd" +SRC_URI[sha256sum] = "baaa030531fc308f7820c46acdf8e1b2f8e3c1f40bcd28b6e440d1c95d170d4c" + +S = "${WORKDIR}/eglibc-${PV}/localedef" + +do_unpack_append() { + bb.build.exec_func('do_move_ports', d) +} + +do_move_ports() { + if test -d ${WORKDIR}/eglibc-${PV}/ports ; then + rm -rf ${WORKDIR}/libc/ports + mv ${WORKDIR}/eglibc-${PV}/ports ${WORKDIR}/libc/ + fi +} + +EXTRA_OECONF = "--with-glibc=${WORKDIR}/eglibc-${PV}/libc" +CFLAGS += "-DNOT_IN_libc=1" + +do_configure () { + ${S}/configure ${EXTRA_OECONF} +} + + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${B}/localedef ${D}${bindir}/cross-localedef +} diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-R_ARM_TLS_DTPOFF32.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-R_ARM_TLS_DTPOFF32.patch new file mode 100644 index 0000000..b4489e9 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-R_ARM_TLS_DTPOFF32.patch @@ -0,0 +1,56 @@ + +Quote from bug 1443 which explains what the patch does : + + We build some random program and link it with -lust. When we run it, + it dies with a SIGSEGV before reaching main(). + + Libust.so depends on liburcu-bp.so from the usermode-rcu package. + Although libust.so is not prelinked, liburcu-bp.so IS prelinked; this + is critical. + + Libust.so uses a TLS / __thread variable that is defined in liburcu- + bp.so. There are special ARM-specific relocation types that allow two + shared libraries to share thread-specific data. This is critical too. + + One more critical issue: although liburcu-bp.so is prelinked, we can't + load it at its prelinked address, because we also link against + librt.so, and librt.so uses that address. + + The dynamic linker is forced to relink liburcu-bp.so at a different + address. In the course of relinking, it processes the special ARM + relocation record mentioned above. The prelinker has already filled + in the information, which is a short offset into a table of thread- + specific data that is allocated per-thread for each library that uses + TLS. Because the normal behavior of a relocation is to add the symbol + value to an addend stored at the address being relocated, we end up + adding the short offset to itself, doubling it. + + Now we have an awkward situation. The libust.so library doesn't know + about the addend, so its TLS data for this element is correct. The + liburcu-bp.so library has a different offset for the element. When we + go to initialize the element for the first time in liburcu-bp.so, we + write the address of the result at the doubled (broken) offset. + Later, when we refer to the address from libust.so, we check the value + at the correct offset, but it's NULL, so we eat hot SIGSEGV. + +Upstream-Status: Pending + +Signed-off-by: Andrei Dinu <andrei.adrianx.dinu@intel.com> +--- + .../libc/ports/sysdeps/arm/dl-machine.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +ndex 8d905e8..dcfa71e 100644 +--- libc.orig/ports/sysdeps/arm/dl-machine.h ++++ libc/ports/sysdeps/arm/dl-machine.h +@@ -503,7 +503,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, + + case R_ARM_TLS_DTPOFF32: + if (sym != NULL) +- *reloc_addr += sym->st_value; ++ *reloc_addr = sym->st_value; + break; + + case R_ARM_TLS_TPOFF32: +-- + diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-eglibc-menuconfig-support.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-eglibc-menuconfig-support.patch new file mode 100644 index 0000000..4559a11 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-eglibc-menuconfig-support.patch @@ -0,0 +1,912 @@ +Pulled from +http://www.eglibc.org/archives/patches/msg01042.html + +Upstream-Status: Pending +Signed-off-by: Khem + +Hi, + +This patch adds 'make menuconfig' support to EGLIBC. + + +EGLIBC can re-use the Linux kernel kconfig host tools ('conf' and 'mconf') unmodified, by passing appropriate environment variables and with some pre- and post-processing on the input/output config files. + +There are three new make targets supported, which all are defined in the new libc/options-config/Makefile, which is included by the top-level libc/Makefile: + +- 'make defconfig'. This passes 'libc/option-groups.defaults' to 'conf' as a default config, and outputs 'option-groups.config' to the top-level build directory, which will be the same as the default config. + +- 'make config'. This is the same line-oriented interface as in the Linux kernel. Input and output is 'option-groups.config' in the top-level build directory. + +- 'make menuconfig'. This is the same menu-based interface as in the Linux kernel. Input and output is 'option-groups.config' in the top-level build directory. + + +Pre-Processing: + + +The Linux kernel kconfig tools expect a prefix of "CONFIG_" on all config option names, but EGLIBC expects a prefix of "OPTION_". The pre-processing script, libc/options-config/config-preproc.pl, simply replaces "CONFIG_ with "OPTION_" in the given config file. The libc/options-config/Makefile passes the script output to a temporary config file, which is then passed to 'conf' or 'mconf'. + +Post-Processing (libc/options-config/config-postproc.pl): + + +- Disabled options are output as a comment line of the form "# CONFIG_FOO is not set". This needs to be changed to an explicit "CONFIG_FOO=n" in order to be compatible with 'option-groups.awk' which generates the option-groups.h header. + +- "CONFIG_" prefix is changed back to "OPTION_". + + +- The kconfig tools will not output anything for options that depend on a parent option, when the parent option is disabled. This implicit disable must be converted to an explicit "CONFIG_FOO=n" in order to be compatible with the way EGLIBC overrides the default option settings in 'libc/option-groups.defaults' with those in 'option-groups.config'. + + +A new configure option, '--with-kconfig=<PATH>', tells EGLIBC where to find the pre-built 'conf' and 'mconf' host tools from Linux kernel builds. + +libc/EGLIBC.cross-building is updated to include instructions for using '--with-kconfig' for the final EGLIBC build, and shows how and when to run 'make *config'. + +libc/EGLIBC.option-groups is updated to include new information on the menuconfig support. + +Thanks, + +attached is the updated patch to address above issues. + +Steve + +-- +Steve Longerbeam | Senior Embedded Engineer, ESD Services +Mentor Embedded(tm) | 46871 Bayside Parkway, Fremont, CA 94538 +P 510.354.5838 | M 408.410.2735 +Nucleus(r) | Linux(r) | Android(tm) | Services | UI | Multi-OS + + +Index: libc/EGLIBC.cross-building +=================================================================== +--- libc.orig/EGLIBC.cross-building ++++ libc/EGLIBC.cross-building +@@ -243,9 +243,29 @@ full EGLIBC build: + > $src/libc/configure \ + > --prefix=/usr \ + > --with-headers=$sysroot/usr/include \ ++ > --with-kconfig=$obj/linux/scripts/kconfig \ + > --build=$build \ + > --host=$target \ + > --disable-profile --without-gd --without-cvs --enable-add-ons ++ ++Note the additional '--with-kconfig' option. This tells EGLIBC where to ++find the host config tools used by the kernel 'make config' and 'make ++menuconfig'. These tools can be re-used by EGLIBC for its own 'make ++*config' support, which will create 'option-groups.config' for you. ++But first make sure those tools have been built by running some ++dummy 'make *config' calls in the kernel directory: ++ ++ $ cd $obj/linux ++ $ PATH=$tools/bin:$PATH make config \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ $ PATH=$tools/bin:$PATH make menuconfig \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ ++Now we can configure and build the full EGLIBC: ++ ++ $ cd $obj/eglibc ++ $ PATH=$tools/bin:$PATH make defconfig ++ $ PATH=$tools/bin:$PATH make menuconfig + $ PATH=$tools/bin:$PATH make + $ PATH=$tools/bin:$PATH make install install_root=$sysroot + +Index: libc/configure.ac +=================================================================== +--- libc.orig/configure.ac ++++ libc/configure.ac +@@ -127,6 +127,16 @@ AC_ARG_WITH([headers], + [sysheaders='']) + AC_SUBST(sysheaders) + ++AC_ARG_WITH([kconfig], ++ AC_HELP_STRING([--with-kconfig=PATH], ++ [location of kconfig tools to use (from Linux ++ kernel builds) to re-use for configuring EGLIBC ++ option groups]), ++ [KCONFIG_TOOLS=$withval], ++ [KCONFIG_TOOLS='']) ++AC_SUBST(KCONFIG_TOOLS) ++ ++ + AC_SUBST(use_default_link) + AC_ARG_WITH([default-link], + AC_HELP_STRING([--with-default-link], +Index: libc/config.make.in +=================================================================== +--- libc.orig/config.make.in ++++ libc/config.make.in +@@ -45,6 +45,8 @@ sysincludes = @SYSINCLUDES@ + c++-sysincludes = @CXX_SYSINCLUDES@ + all-warnings = @all_warnings@ + ++kconfig_tools = @KCONFIG_TOOLS@ ++ + have-z-combreloc = @libc_cv_z_combreloc@ + have-z-execstack = @libc_cv_z_execstack@ + have-Bgroup = @libc_cv_Bgroup@ +Index: libc/options-config/config-postproc.pl +=================================================================== +--- /dev/null ++++ libc/options-config/config-postproc.pl +@@ -0,0 +1,54 @@ ++#!/usr/bin/perl ++ ++$usage = "usage: $0 <default config file> <config file>\n"; ++ ++die "$usage" unless @ARGV; ++$defaults = shift @ARGV; ++die "$usage" unless @ARGV; ++die "Could not open $ARGV[0]" unless -T $ARGV[0]; ++ ++sub yank { ++ @option = grep($_ ne $_[0], @option); ++} ++ ++open(DEFAULTS, $defaults) || die "Could not open $defaults\n"; ++ ++# get the full list of available options using the default config file ++$i = 0; ++while (<DEFAULTS>) { ++ if (/^\s*OPTION_(\w+)\s*=/) { ++ $option[$i++] = $1; ++ } ++} ++ ++# now go through the config file, making the necessary changes ++while (<>) { ++ if (/Linux Kernel Configuration/) { ++ # change title ++ s/Linux Kernel/Option Groups/; ++ print; ++ } elsif (/^\s*CONFIG_(\w+)\s*=/) { ++ # this is an explicit option set line, change CONFIG_ to OPTION_ ++ # before printing and remove this option from option list ++ $opt = $1; ++ yank($opt); ++ s/CONFIG_/OPTION_/g; ++ print; ++ } elsif (/^\s*#\s+CONFIG_(\w+) is not set/) { ++ # this is a comment line, change CONFIG_ to OPTION_, remove this ++ # option from option list, and convert to explicit OPTION_FOO=n ++ $opt = $1; ++ yank($opt); ++ s/CONFIG_/OPTION_/g; ++ print "OPTION_$opt=n\n"; ++ } else { ++ print; ++ } ++} ++ ++# any options left in @options, are options that were not mentioned in ++# the config file, and implicitly that means the option must be set =n, ++# so do that here. ++foreach $opt (@option) { ++ print "OPTION_$opt=n\n"; ++} +Index: libc/options-config/config-preproc.pl +=================================================================== +--- /dev/null ++++ libc/options-config/config-preproc.pl +@@ -0,0 +1,8 @@ ++#!/usr/bin/perl ++ ++if (@ARGV) { ++ while (<>) { ++ s/OPTION_/CONFIG_/g; ++ print; ++ } ++} +Index: libc/options-config/Makefile +=================================================================== +--- /dev/null ++++ libc/options-config/Makefile +@@ -0,0 +1,55 @@ ++# =========================================================================== ++# EGLIBC option-groups configuration targets ++# These targets are included from top-level makefile ++ ++ifneq ($(kconfig_tools),) ++ifneq (no,$(PERL)) ++ ++ocdir := options-config ++ ++OconfigDefaults := option-groups.defaults ++OconfigDefaults_tmp := $(common-objpfx).tmp.defconfig ++OconfigDef := option-groups.def ++Oconfig := $(common-objpfx)option-groups.config ++Oconfig_tmp := $(common-objpfx).tmp.config ++ ++conf := $(kconfig_tools)/conf ++mconf := $(kconfig_tools)/mconf ++ ++preproc := $(PERL) $(ocdir)/config-preproc.pl ++postproc := $(PERL) $(ocdir)/config-postproc.pl ++ ++PHONY += defconfig config menuconfig ++ ++defconfig: $(conf) $(OconfigDefaults) $(OconfigDef) ++ rm -f $(OconfigDefaults_tmp) ++ rm -f $(Oconfig_tmp) ++ $(preproc) $(OconfigDefaults) > $(OconfigDefaults_tmp) ++ KCONFIG_CONFIG=$(Oconfig_tmp) $< --defconfig=$(OconfigDefaults_tmp) \ ++ $(OconfigDef) ++ $(postproc) $(OconfigDefaults) $(Oconfig_tmp) > $(Oconfig) ++ rm $(Oconfig_tmp) ++ rm $(OconfigDefaults_tmp) ++ ++config: $(conf) $(OconfigDefaults) $(OconfigDef) ++ rm -f $(Oconfig_tmp) ++ $(preproc) $(wildcard $(Oconfig)) > $(Oconfig_tmp) ++ KCONFIG_CONFIG=$(Oconfig_tmp) $< --oldaskconfig $(OconfigDef) ++ $(postproc) $(OconfigDefaults) $(Oconfig_tmp) > $(Oconfig) ++ rm $(Oconfig_tmp) ++ ++menuconfig: $(mconf) $(OconfigDefaults) $(OconfigDef) ++ rm -f $(Oconfig_tmp) ++ $(preproc) $(wildcard $(Oconfig)) > $(Oconfig_tmp) ++ KCONFIG_CONFIG=$(Oconfig_tmp) $< $(OconfigDef) ++ $(postproc) $(OconfigDefaults) $(Oconfig_tmp) > $(Oconfig) ++ rm $(Oconfig_tmp) ++ ++# Help text used by make help ++help: ++ @echo ' defconfig - New config with default from default config' ++ @echo ' config - Update current config utilising a line-oriented program' ++ @echo ' menuconfig - Update current config utilising a menu based program' ++ ++endif ++endif +Index: libc/option-groups.def +=================================================================== +--- libc.orig/option-groups.def ++++ libc/option-groups.def +@@ -4,19 +4,19 @@ + # + # An entry of the form: + # +-# config OPTION_GROUP_NAME ++# config GROUP_NAME + # bool "one-line explanation of what this option group controls" + # help + # Multi-line help explaining the option group's meaning in + # some detail, terminated by indentation level. + # +-# defines an option group whose variable is OPTION_GROUP_NAME, with ++# defines an option group whose variable is GROUP_NAME, with + # meaningful values 'y' (enabled) and 'n' (disabled). The + # documentation is formatted to be consumed by some sort of + # interactive configuration interface, but EGLIBC doesn't have such an + # interface yet. + # +-# An option may have a 'depends' line, indicating which other options ++# An option may have a 'depends on' line, indicating which other options + # must also be enabled if this option is. At present, EGLIBC doesn't + # check that these dependencies are satisfied. + # +@@ -41,9 +41,9 @@ + # although this simply reestablishes the value already set by + # 'option-groups.defaults'. + +-config OPTION_EGLIBC_ADVANCED_INET6 ++config EGLIBC_ADVANCED_INET6 + bool "IPv6 Advanced Sockets API support (RFC3542)" +- depends OPTION_EGLIBC_INET ++ depends on EGLIBC_INET + help + This option group includes the functions specified by RFC 3542, + "Advanced Sockets Application Program Interface (API) for +@@ -71,7 +71,7 @@ config OPTION_EGLIBC_ADVANCED_INET6 + inet6_rth_segments + inet6_rth_space + +-config OPTION_EGLIBC_BACKTRACE ++config EGLIBC_BACKTRACE + bool "Functions for producing backtraces" + help + This option group includes functions for producing a list of +@@ -85,7 +85,7 @@ config OPTION_EGLIBC_BACKTRACE + backtrace_symbols + backtrace_symbols_fd + +-config OPTION_EGLIBC_BIG_MACROS ++config EGLIBC_BIG_MACROS + bool "Use extensive inline code" + help + This option group specifies whether certain pieces of code +@@ -93,7 +93,7 @@ config OPTION_EGLIBC_BIG_MACROS + group is not selected, function calls will be used instead, + hence reducing the library footprint. + +-config OPTION_EGLIBC_BSD ++config EGLIBC_BSD + bool "BSD-specific functions, and their compatibility stubs" + help + This option group includes functions specific to BSD kernels. +@@ -109,10 +109,9 @@ config OPTION_EGLIBC_BSD + revoke + setlogin + +-config OPTION_EGLIBC_CXX_TESTS ++config EGLIBC_CXX_TESTS + bool "Tests that link against the standard C++ library." +- depends OPTION_POSIX_WIDE_CHAR_DEVICE_IO +- depends OPTION_EGLIBC_LIBM ++ depends on POSIX_WIDE_CHAR_DEVICE_IO && EGLIBC_LIBM + help + This option group does not include any C library functions; + instead, it controls which EGLIBC tests an ordinary 'make +@@ -121,23 +120,22 @@ config OPTION_EGLIBC_CXX_TESTS + run. + + The standard C++ library depends on the math library 'libm' and +- the wide character I/O functions included in EGLIBC. If those +- option groups are disabled, this test must also be disabled. ++ the wide character I/O functions included in EGLIBC. So those ++ option groups must be enabled if this test is enabled. + +-config OPTION_EGLIBC_CATGETS ++config EGLIBC_CATGETS + bool "Functions for accessing message catalogs" +- depends OPTION_EGLIBC_LOCALE_CODE ++ depends on EGLIBC_LOCALE_CODE + help + This option group includes functions for accessing message + catalogs: catopen, catclose, and catgets. + +- This option group depends on the OPTION_EGLIBC_LOCALE_CODE +- option group; if you disable that, you must also disable this. ++ This option group depends on the EGLIBC_LOCALE_CODE ++ option group. + +-config OPTION_EGLIBC_CHARSETS ++config EGLIBC_CHARSETS + bool "iconv/gconv character set conversion libraries" + help +- + This option group includes support for character sets other + than ASCII (ANSI_X3.4-1968) and Unicode and ISO-10646 in their + various encodings. This affects both the character sets +@@ -198,16 +196,16 @@ config OPTION_EGLIBC_CHARSETS + WCHAR_T - EGLIBC's internal form (target-endian, + 32-bit ISO 10646) + +-config OPTION_EGLIBC_CRYPT ++config EGLIBC_CRYPT + bool "Encryption library" + help + This option group includes the `libcrypt' library which + provides functions for one-way encryption. Supported + encryption algorithms include MD5, SHA-256, SHA-512 and DES. + +-config OPTION_EGLIBC_CRYPT_UFC ++config EGLIBC_CRYPT_UFC + bool "Ultra fast `crypt' implementation" +- depends OPTION_EGLIBC_CRYPT ++ depends on EGLIBC_CRYPT + help + This option group provides ultra fast DES-based implementation of + the `crypt' function. When this option group is disabled, +@@ -216,7 +214,7 @@ config OPTION_EGLIBC_CRYPT_UFC + errno to ENOSYS if /salt/ passed does not correspond to either MD5, + SHA-256 or SHA-512 algorithm. + +-config OPTION_EGLIBC_DB_ALIASES ++config EGLIBC_DB_ALIASES + bool "Functions for accessing the mail aliases database" + help + This option group includues functions for looking up mail +@@ -233,7 +231,7 @@ config OPTION_EGLIBC_DB_ALIASES + When this option group is disabled, the NSS service libraries + also lack support for querying their mail alias tables. + +-config OPTION_EGLIBC_ENVZ ++config EGLIBC_ENVZ + bool "Functions for handling envz-style environment vectors." + help + This option group contains functions for creating and operating +@@ -248,7 +246,7 @@ config OPTION_EGLIBC_ENVZ + envz_entry envz_remove + envz_get envz_strip + +-config OPTION_EGLIBC_FCVT ++config EGLIBC_FCVT + bool "Functions for converting floating-point numbers to strings" + help + This option group includes functions for converting +@@ -262,14 +260,14 @@ config OPTION_EGLIBC_FCVT + fcvt_r qfcvt_r + gcvt qgcvt + +-config OPTION_EGLIBC_FMTMSG ++config EGLIBC_FMTMSG + bool "Functions for formatting messages" + help + This option group includes the following functions: + + addseverity fmtmsg + +-config OPTION_EGLIBC_FSTAB ++config EGLIBC_FSTAB + bool "Access functions for 'fstab'" + help + This option group includes functions for reading the mount +@@ -283,7 +281,7 @@ config OPTION_EGLIBC_FSTAB + getfsent setfsent + getfsfile + +-config OPTION_EGLIBC_FTRAVERSE ++config EGLIBC_FTRAVERSE + bool "Functions for traversing file hierarchies" + help + This option group includes functions for traversing file +@@ -297,9 +295,9 @@ config OPTION_EGLIBC_FTRAVERSE + fts_set nftw64 + fts_close + +-config OPTION_EGLIBC_GETLOGIN ++config EGLIBC_GETLOGIN + bool "The getlogin function" +- depends OPTION_EGLIBC_UTMP ++ depends on EGLIBC_UTMP + help + This function group includes the 'getlogin' and 'getlogin_r' + functions, which return the user name associated by the login +@@ -309,17 +307,17 @@ config OPTION_EGLIBC_GETLOGIN + fall back on 'getlogin' to find the user's login name for tilde + expansion when the 'HOME' environment variable is not set. + +-config OPTION_EGLIBC_IDN ++config EGLIBC_IDN + bool "International domain names support" + help + This option group includes the `libcidn' library which + provides support for international domain names. + +-config OPTION_EGLIBC_INET ++config EGLIBC_INET + bool "Networking support" + help + This option group includes networking-specific functions and +- data. With OPTION_EGLIBC_INET disabled, the EGLIBC ++ data. With EGLIBC_INET disabled, the EGLIBC + installation and API changes as follows: + + - The following libraries are not installed: +@@ -439,14 +437,14 @@ config OPTION_EGLIBC_INET + use Unix-domain sockets to communicate with the syslog daemon; + syslog is valuable in non-networked contexts. + +-config OPTION_EGLIBC_INET_ANL ++config EGLIBC_INET_ANL + bool "Asynchronous name lookup" +- depends OPTION_EGLIBC_INET ++ depends on EGLIBC_INET + help + This option group includes the `libanl' library which + provides support for asynchronous name lookup. + +-config OPTION_EGLIBC_LIBM ++config EGLIBC_LIBM + bool "libm (math library)" + help + This option group includes the 'libm' library, containing +@@ -464,7 +462,7 @@ config OPTION_EGLIBC_LIBM + group, you will not be able to build 'libstdc++' against the + resulting EGLIBC installation. + +-config OPTION_EGLIBC_LOCALES ++config EGLIBC_LOCALES + bool "Locale definitions" + help + This option group includes all locale definitions other than +@@ -472,17 +470,17 @@ config OPTION_EGLIBC_LOCALES + only the "C" locale is supported. + + +-config OPTION_EGLIBC_LOCALE_CODE ++config EGLIBC_LOCALE_CODE + bool "Locale functions" +- depends OPTION_POSIX_C_LANG_WIDE_CHAR ++ depends on POSIX_C_LANG_WIDE_CHAR + help + This option group includes locale support functions, programs, +- and libraries. With OPTION_EGLIBC_LOCALE_FUNCTIONS disabled, ++ and libraries. With EGLIBC_LOCALE_CODE disabled, + EGLIBC supports only the 'C' locale (also known as 'POSIX'), + and ignores the settings of the 'LANG' and 'LC_*' environment + variables. + +- With OPTION_EGLIBC_LOCALE_CODE disabled, the following ++ With EGLIBC_LOCALE_CODE disabled, the following + functions are omitted from libc: + + duplocale localeconv nl_langinfo rpmatch strfmon_l +@@ -491,46 +489,43 @@ config OPTION_EGLIBC_LOCALE_CODE + Furthermore, only the LC_CTYPE and LC_TIME categories of the + standard "C" locale are available. + +- The OPTION_EGLIBC_CATGETS option group depends on this option +- group; if you disable OPTION_EGLIBC_LOCALE_CODE, you must also +- disable OPTION_EGLIBC_CATGETS. ++ The EGLIBC_CATGETS option group depends on this option group. ++ + +-config OPTION_EGLIBC_MEMUSAGE ++config EGLIBC_MEMUSAGE + bool "Memory profiling library" + help + This option group includes the `libmemusage' library and + the `memusage' and `memusagestat' utilities. + These components provide memory profiling functions. + +- OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE ++ EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE + + Libmemusage library buffers the profiling data in memory + before writing it out to disk. By default, the library + allocates 1.5M buffer, which can be substantial for some +- systems. OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option ++ systems. EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option + allows to change the default buffer size. It specifies + the number of entries the buffer should have. + On most architectures one buffer entry amounts to 48 bytes, + so setting this option to the value of 512 will reduce the size of + the memory buffer to 24K. + +-config OPTION_EGLIBC_NIS ++config EGLIBC_NIS + bool "Support for NIS, NIS+, and the special 'compat' services." +- depends OPTION_EGLIBC_INET +- depends OPTION_EGLIBC_SUNRPC ++ depends on EGLIBC_INET && EGLIBC_SUNRPC + help + This option group includes the NIS, NIS+, and 'compat' Name + Service Switch service libraries. When it is disabled, those + services libraries are not installed; you should remove any + references to them from your 'nsswitch.conf' file. + +- This option group depends on the OPTION_EGLIBC_INET option ++ This option group depends on the EGLIBC_INET option + group; you must enable that to enable this option group. + +-config OPTION_EGLIBC_NSSWITCH ++config EGLIBC_NSSWITCH + bool "Name service switch (nsswitch) support" + help +- + This option group includes support for the 'nsswitch' facility. + With this option group enabled, all EGLIBC functions for + accessing various system databases (passwords and groups; +@@ -544,12 +539,12 @@ config OPTION_EGLIBC_NSSWITCH + 'option-groups.config' file must set the following two + variables: + +- OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG ++ EGLIBC_NSSWITCH_FIXED_CONFIG + + Set this to the name of a file whose contents observe the + same syntax as an ordinary '/etc/nsswitch.conf' file. The + EGLIBC build process parses this file just as EGLIBC would +- at run time if OPTION_EGLIBC_NSSWITCH were enabled, and ++ at run time if EGLIBC_NSSWITCH were enabled, and + produces a C library that uses the nsswitch service + libraries to search for database entries as this file + specifies, instead of consulting '/etc/nsswitch.conf' at run +@@ -567,7 +562,7 @@ config OPTION_EGLIBC_NSSWITCH + you will probably want to delete references to databases not + needed on your system. + +- OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS ++ EGLIBC_NSSWITCH_FIXED_FUNCTIONS + + The EGLIBC build process uses this file to decide which + functions to make available from which service libraries. +@@ -585,28 +580,28 @@ config OPTION_EGLIBC_NSSWITCH + Be sure to mention each function in each service you wish to + use. If you do not mention a service's function here, the + EGLIBC database access functions will not find it, even if +- it is listed in the OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG ++ it is listed in the EGLIBC_NSSWITCH_FIXED_CONFIG + file. + +- In this arrangement, EGLIBC will not use the 'dlopen' and +- 'dlsym' functions to find database access functions. Instead, +- libc hard-codes references to the service libraries' database +- access functions. You must explicitly link your program +- against the name service libraries (those whose names start +- with 'libnss_', in the sysroot's '/lib' directory) whose +- functions you intend to use. This arrangement helps +- system-wide static analysis tools decide which functions a +- system actually uses. +- +- Note that some nsswitch service libraries require other option +- groups to be enabled; for example, the OPTION_EGLIBC_INET +- option group must be enabled to use the 'libnss_dns.so.2' +- service library, which uses the Domain Name System network +- protocol to answer queries. ++ In this arrangement, EGLIBC will not use the 'dlopen' and ++ 'dlsym' functions to find database access functions. Instead, ++ libc hard-codes references to the service libraries' database ++ access functions. You must explicitly link your program ++ against the name service libraries (those whose names start ++ with 'libnss_', in the sysroot's '/lib' directory) whose ++ functions you intend to use. This arrangement helps ++ system-wide static analysis tools decide which functions a ++ system actually uses. ++ ++ Note that some nsswitch service libraries require other option ++ groups to be enabled; for example, the EGLIBC_INET ++ option group must be enabled to use the 'libnss_dns.so.2' ++ service library, which uses the Domain Name System network ++ protocol to answer queries. + +-config OPTION_EGLIBC_RCMD ++config EGLIBC_RCMD + bool "Support for 'rcmd' and related library functions" +- depends OPTION_EGLIBC_INET ++ depends on EGLIBC_INET + help + This option group includes functions for running commands on + remote machines via the 'rsh' protocol, and doing authentication +@@ -622,7 +617,7 @@ config OPTION_EGLIBC_RCMD + rresvport ruserpass + rresvport_af + +-config OPTION_EGLIBC_RTLD_DEBUG ++config EGLIBC_RTLD_DEBUG + bool "Runtime linker debug print outs" + help + This option group enables debug output of the runtime linker +@@ -633,7 +628,7 @@ config OPTION_EGLIBC_RTLD_DEBUG + the `ldd' utility which may also be used by the prelinker. + In particular, the `--unused' ldd option will not work correctly. + +-config OPTION_EGLIBC_SPAWN ++config EGLIBC_SPAWN + bool "Support for POSIX posix_spawn functions" + help + This option group includes the POSIX functions for executing +@@ -669,7 +664,7 @@ config OPTION_EGLIBC_SPAWN + disabled, those programs will only operate on uncompressed + charmap files. + +-config OPTION_EGLIBC_STREAMS ++config EGLIBC_STREAMS + bool "Support for accessing STREAMS." + help + This option group includes functions for reading and writing +@@ -685,14 +680,14 @@ config OPTION_EGLIBC_STREAMS + isastream fdetach + putmsg + +-config OPTION_EGLIBC_SUNRPC ++config EGLIBC_SUNRPC + bool "Support for the Sun 'RPC' protocol." +- depends OPTION_EGLIBC_INET ++ depends on EGLIBC_INET + help + This option group includes support for the Sun RPC protocols, + including the 'rpcgen' and 'rpcinfo' programs. + +-config OPTION_EGLIBC_UTMP ++config EGLIBC_UTMP + bool "Older access functions for 'utmp' login records" + help + This option group includes the older 'utent' family of +@@ -719,9 +714,9 @@ config OPTION_EGLIBC_UTMP + + libutil.so (and libutil.a) + +-config OPTION_EGLIBC_UTMPX ++config EGLIBC_UTMPX + bool "POSIX access functions for 'utmp' login records" +- depends OPTION_EGLIBC_UTMP ++ depends on EGLIBC_UTMP + help + This option group includes the POSIX functions for reading and + writing user login records in the 'utmp' file (usually +@@ -742,21 +737,21 @@ config OPTION_EGLIBC_UTMPX + updwtmpx + utmpxname + +-config OPTION_EGLIBC_WORDEXP ++config EGLIBC_WORDEXP + bool "Shell-style word expansion" + help + This option group includes the 'wordexp' function for + performing word expansion in the manner of the shell, and the + accompanying 'wordfree' function. + +-config OPTION_POSIX_C_LANG_WIDE_CHAR ++config POSIX_C_LANG_WIDE_CHAR + bool "ISO C library wide character functions, excluding I/O" + help + This option group includes the functions defined by the ISO C + standard for working with wide and multibyte characters in + memory. Functions for reading and writing wide and multibyte + characters from and to files call in the +- OPTION_POSIX_WIDE_CHAR_DEVICE_IO option group. ++ POSIX_WIDE_CHAR_DEVICE_IO option group. + + This option group includes the following functions: + +@@ -778,14 +773,14 @@ config OPTION_POSIX_C_LANG_WIDE_CHAR + mbrlen wcscoll wcstol + mbrtowc wcscpy wcstold + +-config OPTION_POSIX_REGEXP ++config POSIX_REGEXP + bool "Regular expressions" + help + This option group includes the POSIX regular expression + functions, and the associated non-POSIX extensions and + compatibility functions. + +- With OPTION_POSIX_REGEXP disabled, the following functions are ++ With POSIX_REGEXP disabled, the following functions are + omitted from libc: + + re_comp re_max_failures regcomp +@@ -799,9 +794,9 @@ config OPTION_POSIX_REGEXP + <regexp.h> header file, 'compile', 'step', and 'advance', is + omitted. + +-config OPTION_POSIX_REGEXP_GLIBC ++config POSIX_REGEXP_GLIBC + bool "Regular expressions from GLIBC" +- depends OPTION_POSIX_REGEXP ++ depends on POSIX_REGEXP + help + This option group specifies which regular expression + library to use. The choice is between regex +@@ -810,9 +805,9 @@ config OPTION_POSIX_REGEXP_GLIBC + optimized for speed; regex from libiberty is more than twice + as small while still is enough for most practical purposes. + +-config OPTION_POSIX_WIDE_CHAR_DEVICE_IO ++config POSIX_WIDE_CHAR_DEVICE_IO + bool "Input and output functions for wide characters" +- depends OPTION_POSIX_C_LANG_WIDE_CHAR ++ depends on POSIX_C_LANG_WIDE_CHAR + help + This option group includes functions for reading and writing + wide characters to and from <stdio.h> streams. +Index: libc/Makefile +=================================================================== +--- libc.orig/Makefile ++++ libc/Makefile +@@ -24,6 +24,7 @@ endif + + include Makeconfig + ++include options-config/Makefile + + # This is the default target; it makes everything except the tests. + .PHONY: all +Index: libc/configure +=================================================================== +--- libc.orig/configure ++++ libc/configure +@@ -621,6 +621,7 @@ KSH + libc_cv_have_bash2 + BASH_SHELL + libc_cv_gcc_static_libgcc ++KCONFIG_TOOLS + CXX_SYSINCLUDES + SYSINCLUDES + AUTOCONF +@@ -734,6 +735,7 @@ with_fp + with_binutils + with_selinux + with_headers ++with_kconfig + with_default_link + enable_sanity_checks + enable_shared +@@ -1438,6 +1440,9 @@ Optional Packages: + --with-selinux if building with SELinux support + --with-headers=PATH location of system headers to use (for example + /usr/src/linux/include) [default=compiler default] ++ --with-kconfig=PATH location of kconfig tools to use (from Linux kernel ++ builds) to re-use for configuring EGLIBC option ++ groups + --with-default-link do not use explicit linker scripts + --with-cpu=CPU select code for CPU variant + +@@ -3401,6 +3406,14 @@ fi + + + ++# Check whether --with-kconfig was given. ++if test "${with_kconfig+set}" = set; then ++ withval=$with_kconfig; KCONFIG_TOOLS=$withval ++else ++ KCONFIG_TOOLS='' ++fi ++ ++ + + # Check whether --with-default-link was given. + if test "${with_default_link+set}" = set; then : +Index: libc/EGLIBC.option-groups +=================================================================== +--- libc.orig/EGLIBC.option-groups ++++ libc/EGLIBC.option-groups +@@ -56,33 +56,9 @@ disable option groups one by one, until + + The Option Groups + +-EGLIBC currently implements the following option groups, also +-documented in the file 'option-groups.def': +- +-OPTION_EGLIBC_CATGETS +- This option group includes functions for accessing message +- catalogs: catopen, catclose, and catgets. +- +-OPTION_EGLIBC_LOCALES +- This option group includes all locale definitions other than +- those for the "C" locale. If this option group is omitted, then +- only the "C" locale is supported. +- +-OPTION_EGLIBC_LIBM +- This option group includes the 'libm' library, containing +- mathematical functions. If this option group is omitted, then +- an EGLIBC installation does not include shared or unshared versions +- of the math library. +- +- Note that this does not remove all floating-point related +- functionality from EGLIBC; for example, 'printf' and 'scanf' +- can still print and read floating-point values with this option +- group disabled. +- +- Note that the ISO Standard C++ library 'libstdc++' depends on +- EGLIBC's math library 'libm'. If you disable this option +- group, you will not be able to build 'libstdc++' against the +- resulting EGLIBC installation. ++To see the current full list of implemented option groups, refer to the ++file 'option-groups.def' at the top of the source tree, or run ++'make menuconfig' from the top-level build directory. + + The POSIX.1-2001 specification includes a suggested partition of all + the functions in the POSIX C API into option groups: math functions +@@ -110,6 +86,18 @@ data, but include mathematical functions + OPTION_EGLIBC_LOCALES = n + OPTION_EGLIBC_LIBM = y + ++Like the Linux kernel, EGLIBC supports a similar set of '*config' make ++targets to make it easier to create 'option-groups.config', with all ++dependencies between option groups automatically satisfied. Run ++'make help' to see the list of supported make config targets. For ++example, 'make menuconfig' will update the current config utilising a ++menu based program. ++ ++The option group names and their type (boolean, int, hex, string), help ++description, and dependencies with other option groups, are described by ++'option-groups.def' at the top of the source tree, analogous to the ++'Kconfig' files in the Linux kernel. ++ + In general, each option group variable controls whether a given set of + object files in EGLIBC is compiled and included in the final + libraries, or omitted from the build. +@@ -132,22 +120,3 @@ under development. + + We have used the system to subset some portions of EGLIBC's + functionality. It needs to be extended to cover more of the library. +- +-At the moment, EGLIBC performs no sanity checks on the contents of +-'option-groups.config'; if an option group's name is mistyped, the +-option group is silently included in the build. EGLIBC should check +-that all variables set in 'option-groups.config' are proper option +-group names, and that their values are appropriate. +- +-Some portions of EGLIBC depend on others; for example, the Sun Remote +-Procedure Call functions in 'sunrpc' depend on the networking +-functions in 'inet'. The sanity checking described above should check +-that the selection configuration satisfies dependencies within EGLIBC, +-and produce a legible error message if it does not. At the moment, +-inconsistent configurations produce link errors late in the build +-process. +- +-The Linux kernel's configuration system provides interactive +-interfaces for creating and modifying configuration files (which also +-perform the sanity checking and dependency tracking described above). +-EGLIBC should provide similar interfaces. diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch new file mode 100644 index 0000000..a8463ea --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0001-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch @@ -0,0 +1,36 @@ +From 713d822908d1b2ae8403af7f9375c7054ed3dd49 Mon Sep 17 00:00:00 2001 +From: Ting Liu <b28495@freescale.com> +Date: Wed, 19 Dec 2012 04:39:57 -0600 +Subject: [PATCH] eglibc: run libm-err-tab.pl with specific dirs in ${S} + +libm-err-tab.pl will parse all the files named "libm-test-ulps" +in the given dir recursively. To avoid parsing the one in +${S}/.pc/ (it does exist after eglibc adds aarch64 support, +${S}/.pc/aarch64-0001-glibc-fsf-v1-eaf6f205.patch/ports/sysdeps/ +aarch64/libm-test-ulps), run libm-err-tab.pl with specific dirs +in ${S}. + +Upstream-Status: inappropriate [OE specific] + +Signed-off-by: Ting Liu <b28495@freescale.com> +--- + manual/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/manual/Makefile b/manual/Makefile +index 6fddff0..7af242e 100644 +--- a/manual/Makefile ++++ b/manual/Makefile +@@ -109,7 +109,8 @@ $(objpfx)libm-err.texi: $(objpfx)stamp-libm-err + $(objpfx)stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\ + $(dir)/libm-test-ulps)) + pwd=`pwd`; \ +- $(PERL) $< $$pwd/.. > $(objpfx)libm-err-tmp ++ $(PERL) $< $$pwd/../ports > $(objpfx)libm-err-tmp ++ $(PERL) $< $$pwd/../sysdeps >> $(objpfx)libm-err-tmp + $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi + touch $@ + +-- +1.7.9.7 + diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0002-eglibc-menuconfig-hex-string-options.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0002-eglibc-menuconfig-hex-string-options.patch new file mode 100644 index 0000000..7caba48 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0002-eglibc-menuconfig-hex-string-options.patch @@ -0,0 +1,169 @@ +pulled from + +http://www.eglibc.org/archives/patches/msg01043.html + + +Upstream-Status: Pending +Signed-off-by: Khem + + +This patch builds on the menuconfig patch for EGLIBC. + + +There are a few options that have non-boolean types, that would benefit from the new 'make *config' support: + +EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE (int) +EGLIBC_NSSWITCH_FIXED_CONFIG (string) +EGLIBC_NSSWITCH_FIXED_FUNCTIONS (string) + + +The patch converts these to real options in libc/option-groups.def. Also, libc/scripts/option-groups.awk is modified to output a '#define' line for int, hex, or string options encountered in the config file. + +In the post-processing script config-postproc.pl, a small change is needed: for any boolean option FOO that is implicitly disabled in the kconfig output, make sure that option is indeed a boolean before printing the explicit OPTION_FOO=n. + +Finally, libc/malloc/Makefile passes __OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE as a CPPFLAGS, which is not necessary anymore because this macro will now be present in the generated header. + +attached is the updated patch to address above issues. + +Steve + +-- +Steve Longerbeam | Senior Embedded Engineer, ESD Services +Mentor Embedded(tm) | 46871 Bayside Parkway, Fremont, CA 94538 +P 510.354.5838 | M 408.410.2735 +Nucleus(r) | Linux(r) | Android(tm) | Services | UI | Multi-OS + + +Index: libc/malloc/Makefile +=================================================================== +--- libc.orig/malloc/Makefile 2012-01-04 22:06:18.000000000 -0800 ++++ libc/malloc/Makefile 2012-05-09 19:35:28.598682105 -0700 +@@ -48,10 +48,6 @@ + ifeq ($(OPTION_EGLIBC_MEMUSAGE),y) + extra-libs = libmemusage + extra-libs-others = $(extra-libs) +- +-ifdef OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE +-CPPFLAGS-memusage += -D__OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE=$(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE) +-endif + endif + + libmemusage-routines = memusage +Index: libc/option-groups.def +=================================================================== +--- libc.orig/option-groups.def 2012-05-09 19:33:48.398677256 -0700 ++++ libc/option-groups.def 2012-05-09 19:35:28.610682107 -0700 +@@ -513,8 +513,11 @@ + the `memusage' and `memusagestat' utilities. + These components provide memory profiling functions. + +- EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE +- ++config EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE ++ int "Memory profiling library buffer size" ++ depends on EGLIBC_MEMUSAGE ++ default "32768" ++ help + Libmemusage library buffers the profiling data in memory + before writing it out to disk. By default, the library + allocates 1.5M buffer, which can be substantial for some +@@ -553,8 +556,11 @@ + 'option-groups.config' file must set the following two + variables: + +- EGLIBC_NSSWITCH_FIXED_CONFIG +- ++config EGLIBC_NSSWITCH_FIXED_CONFIG ++ string "Nsswitch fixed config filename" ++ depends on !EGLIBC_NSSWITCH ++ default "" ++ help + Set this to the name of a file whose contents observe the + same syntax as an ordinary '/etc/nsswitch.conf' file. The + EGLIBC build process parses this file just as EGLIBC would +@@ -576,8 +582,11 @@ + you will probably want to delete references to databases not + needed on your system. + +- EGLIBC_NSSWITCH_FIXED_FUNCTIONS +- ++config EGLIBC_NSSWITCH_FIXED_FUNCTIONS ++ string "Nsswitch fixed functions filename" ++ depends on !EGLIBC_NSSWITCH ++ default "" ++ help + The EGLIBC build process uses this file to decide which + functions to make available from which service libraries. + The file 'nss/fixed-nsswitch.functions' serves as a sample +Index: libc/options-config/config-postproc.pl +=================================================================== +--- libc.orig/options-config/config-postproc.pl 2012-05-09 19:33:36.530676681 -0700 ++++ libc/options-config/config-postproc.pl 2012-05-09 19:35:28.610682107 -0700 +@@ -8,7 +8,7 @@ + die "Could not open $ARGV[0]" unless -T $ARGV[0]; + + sub yank { +- @option = grep($_ ne $_[0], @option); ++ @option = grep(!($_ =~ /$_[0]\s*=/), @option); + } + + open(DEFAULTS, $defaults) || die "Could not open $defaults\n"; +@@ -16,7 +16,7 @@ + # get the full list of available options using the default config file + $i = 0; + while (<DEFAULTS>) { +- if (/^\s*OPTION_(\w+)\s*=/) { ++ if (/^\s*OPTION_(\w+\s*=.*$)/) { + $option[$i++] = $1; + } + } +@@ -35,8 +35,9 @@ + s/CONFIG_/OPTION_/g; + print; + } elsif (/^\s*#\s+CONFIG_(\w+) is not set/) { +- # this is a comment line, change CONFIG_ to OPTION_, remove this +- # option from option list, and convert to explicit OPTION_FOO=n ++ # this is a comment line for an unset boolean option, change CONFIG_ ++ # to OPTION_, remove this option from option list, and convert to ++ # explicit OPTION_FOO=n + $opt = $1; + yank($opt); + s/CONFIG_/OPTION_/g; +@@ -46,9 +47,12 @@ + } + } + +-# any options left in @options, are options that were not mentioned in ++# any boolean options left in @options, are options that were not mentioned in + # the config file, and implicitly that means the option must be set =n, + # so do that here. + foreach $opt (@option) { +- print "OPTION_$opt=n\n"; ++ if ($opt =~ /=\s*[yn]/) { ++ $opt =~ s/=\s*[yn]/=n/; ++ print "OPTION_$opt\n"; ++ } + } +Index: libc/scripts/option-groups.awk +=================================================================== +--- libc.orig/scripts/option-groups.awk 2012-01-04 22:06:00.000000000 -0800 ++++ libc/scripts/option-groups.awk 2012-05-09 19:35:28.610682107 -0700 +@@ -46,9 +46,15 @@ + print "#define __" var " 1" + else if (vars[var] == "n") + print "/* #undef __" var " */" +- # Ignore variables that don't have boolean values. +- # Ideally, this would be driven by the types given in +- # option-groups.def. ++ else if (vars[var] ~ /^[0-9]+/ || ++ vars[var] ~ /^0x[0-9aAbBcCdDeEfF]+/ || ++ vars[var] ~ /^\"/) ++ print "#define __" var " " vars[var] ++ else ++ print "/* #undef __" var " */" ++ # Ignore variables that don't have boolean, int, hex, or ++ # string values. Ideally, this would be driven by the types ++ # given in option-groups.def. + } + } + diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0003-eglibc-menuconfig-build-instructions.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0003-eglibc-menuconfig-build-instructions.patch new file mode 100644 index 0000000..d137f5b --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/0003-eglibc-menuconfig-build-instructions.patch @@ -0,0 +1,176 @@ +Pulled from + +http://www.eglibc.org/archives/patches/msg01035.html + +Upstream-Status: Pending +Signed-off-by: Khem + +As part of the menuconfig development, I encountered some outdated information in the cross-build instructions, libc/EGLIBC.cross-building. This patch updates the file with new (and tested) instructions. It is unrelated to the menuconfig support, but applies after. + +My testing was done with an ARM target, and an x86_64 Linux host, so I converted the instructions to use those host/target types from the original i686/powerpc. Hope that's ok. + + +Thanks, + +-- +Steve Longerbeam | Senior Embedded Engineer, ESD Services +Mentor Embedded(tm) | 46871 Bayside Parkway, Fremont, CA 94538 +P 510.354.5838 | M 408.410.2735 +Nucleus(r) | Linux(r) | Android(tm) | Services | UI | Multi-OS + + + EGLIBC.cross-building | 59 +++++++++++++++++++++++++++++--------------------- + 1 file changed, 35 insertions(+), 24 deletions(-) + +Index: libc/EGLIBC.cross-building +=================================================================== +--- libc.orig/EGLIBC.cross-building 2012-05-09 19:33:36.522676681 -0700 ++++ libc/EGLIBC.cross-building 2012-05-09 19:36:13.918684298 -0700 +@@ -47,31 +47,34 @@ + EGLIBC requires recent versions of the GNU binutils, GCC, and the + Linux kernel. The web page <http://www.eglibc.org/prerequisites> + documents the current requirements, and lists patches needed for +-certain target architectures. As of this writing, EGLIBC required +-binutils 2.17, GCC 4.1, and Linux 2.6.19.1. ++certain target architectures. As of this writing, these build ++instructions have been tested with binutils 2.22.51, GCC 4.6.2, ++and Linux 3.1. + + First, let's set some variables, to simplify later commands. We'll +-build EGLIBC and GCC for a PowerPC target, known to the Linux kernel +-as 'powerpc', and we'll do the build on an Intel Linux box: ++build EGLIBC and GCC for an ARM target, known to the Linux kernel ++as 'arm', and we'll do the build on an Intel x86_64 Linux box: + +- $ build=i686-pc-linux-gnu ++ $ build=x86_64-pc-linux-gnu + $ host=$build +- $ target=powerpc-none-linux-gnu +- $ linux_arch=powerpc ++ $ target=arm-none-linux-gnueabi ++ $ linux_arch=arm + + We're using the aforementioned versions of Binutils, GCC, and Linux: + +- $ binutilsv=binutils-2.17 +- $ gccv=gcc-4.1.1 +- $ linuxv=linux-2.6.20 ++ $ binutilsv=binutils-2.22.51 ++ $ gccv=gcc-4.6.2 ++ $ linuxv=linux-3.1 + + We're carrying out the entire process under '~/cross-build', which +-contains unpacked source trees: ++contains unpacked source trees for binutils, gcc, and linux kernel, ++along with EGLIBC svn trunk (which can be checked-out with ++'svn co http://www.eglibc.org/svn/trunk eglibc'): + +- $ top=$HOME/cross-build/ppc ++ $ top=$HOME/cross-build/$target + $ src=$HOME/cross-build/src + $ ls $src +- binutils-2.17 gcc-4.1.1 libc linux-2.6.20 ++ binutils-2.22.51 eglibc gcc-4.6.2 linux-3.1 + + We're going to place our build directories in a subdirectory 'obj', + we'll install the cross-development toolchain in 'tools', and we'll +@@ -99,7 +102,7 @@ + + The First GCC + +-For our work, we need a cross-compiler targeting a PowerPC Linux ++For our work, we need a cross-compiler targeting an ARM Linux + system. However, that configuration includes the shared library + 'libgcc_s.so', which is compiled against the EGLIBC headers (which we + haven't installed yet) and linked against 'libc.so' (which we haven't +@@ -125,7 +128,8 @@ + > --prefix=$tools \ + > --without-headers --with-newlib \ + > --disable-shared --disable-threads --disable-libssp \ +- > --disable-libgomp --disable-libmudflap \ ++ > --disable-libgomp --disable-libmudflap --disable-libquadmath \ ++ > --disable-decimal-float --disable-libffi \ + > --enable-languages=c + $ PATH=$tools/bin:$PATH make + $ PATH=$tools/bin:$PATH make install +@@ -162,12 +166,13 @@ + > CXX=$tools/bin/$target-g++ \ + > AR=$tools/bin/$target-ar \ + > RANLIB=$tools/bin/$target-ranlib \ +- > $src/libc/configure \ ++ > $src/eglibc/libc/configure \ + > --prefix=/usr \ + > --with-headers=$sysroot/usr/include \ + > --build=$build \ + > --host=$target \ +- > --disable-profile --without-gd --without-cvs --enable-add-ons ++ > --disable-profile --without-gd --without-cvs \ ++ > --enable-add-ons=nptl,libidn,../ports + + The option '--prefix=/usr' may look strange, but you should never + configure EGLIBC with a prefix other than '/usr': in various places, +@@ -181,6 +186,11 @@ + The '--with-headers' option tells EGLIBC where the Linux headers have + been installed. + ++The '--enable-add-ons=nptl,libidn,../ports' option tells EGLIBC to look ++for the listed glibc add-ons. Most notably the ports add-on (located ++just above the libc sources in the EGLIBC svn tree) is required to ++support ARM targets. ++ + We can now use the 'install-headers' makefile target to install the + headers: + +@@ -223,6 +233,7 @@ + > --prefix=$tools \ + > --with-sysroot=$sysroot \ + > --disable-libssp --disable-libgomp --disable-libmudflap \ ++ > --disable-libffi --disable-libquadmath \ + > --enable-languages=c + $ PATH=$tools/bin:$PATH make + $ PATH=$tools/bin:$PATH make install +@@ -240,13 +251,14 @@ + > CXX=$tools/bin/$target-g++ \ + > AR=$tools/bin/$target-ar \ + > RANLIB=$tools/bin/$target-ranlib \ +- > $src/libc/configure \ ++ > $src/eglibc/libc/configure \ + > --prefix=/usr \ + > --with-headers=$sysroot/usr/include \ + > --with-kconfig=$obj/linux/scripts/kconfig \ + > --build=$build \ + > --host=$target \ +- > --disable-profile --without-gd --without-cvs --enable-add-ons ++ > --disable-profile --without-gd --without-cvs \ ++ > --enable-add-ons=nptl,libidn,../ports + + Note the additional '--with-kconfig' option. This tells EGLIBC where to + find the host config tools used by the kernel 'make config' and 'make +@@ -337,15 +349,15 @@ + ELF Header: + ... + Type: EXEC (Executable file) +- Machine: PowerPC ++ Machine: ARM + + ... + Program Headers: + Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align + PHDR 0x000034 0x10000034 0x10000034 0x00100 0x00100 R E 0x4 +- INTERP 0x000134 0x10000134 0x10000134 0x0000d 0x0000d R 0x1 +- [Requesting program interpreter: /lib/ld.so.1] +- LOAD 0x000000 0x10000000 0x10000000 0x008f0 0x008f0 R E 0x10000 ++ INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1 ++ [Requesting program interpreter: /lib/ld-linux.so.3] ++ LOAD 0x000000 0x00008000 0x00008000 0x0042c 0x0042c R E 0x8000 + ... + + Looking at the dynamic section of the installed 'libgcc_s.so', we see +@@ -357,7 +369,6 @@ + Dynamic section at offset 0x1083c contains 24 entries: + Tag Type Name/Value + 0x00000001 (NEEDED) Shared library: [libc.so.6] +- 0x00000001 (NEEDED) Shared library: [ld.so.1] + 0x0000000e (SONAME) Library soname: [libgcc_s.so.1] + ... + diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/GLRO_dl_debug_mask.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/GLRO_dl_debug_mask.patch new file mode 100644 index 0000000..7258c82 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/GLRO_dl_debug_mask.patch @@ -0,0 +1,143 @@ +Its controlled by __OPTION_EGLIBC_RTLD_DEBUG +so we should use GLRO_dl_debug_mask + +Singed-off-by: Khem Raj <raj.khem@gmail.com> + +Upstream-Status: Pending +Index: libc/elf/dl-open.c +=================================================================== +--- libc.orig/elf/dl-open.c 2012-10-25 10:18:12.000000000 -0700 ++++ libc/elf/dl-open.c 2013-01-09 11:49:02.635577870 -0800 +@@ -155,7 +155,7 @@ + ns->_ns_main_searchlist->r_list[new_nlist++] = map; + + /* We modify the global scope. Report this. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_SCOPES, 0)) + _dl_debug_printf ("\nadd %s [%lu] to global scope\n", + map->l_name, map->l_ns); + } +@@ -298,7 +298,7 @@ + LIBC_PROBE (map_complete, 3, args->nsid, r, new); + + /* Print scope information. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_SCOPES, 0)) + _dl_show_scope (new, 0); + + /* Only do lazy relocation if `LD_BIND_NOW' is not set. */ +@@ -515,7 +515,7 @@ + } + + /* Print scope information. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_SCOPES, 0)) + _dl_show_scope (imap, from_scope); + } + +Index: libc/ports/sysdeps/mips/dl-lookup.c +=================================================================== +--- libc.orig/ports/sysdeps/mips/dl-lookup.c 2012-08-17 12:39:53.000000000 -0700 ++++ libc/ports/sysdeps/mips/dl-lookup.c 2013-01-09 11:49:02.635577870 -0800 +@@ -111,7 +111,7 @@ + continue; + + /* Print some debugging info if wanted. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0)) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_SYMBOLS, 0)) + _dl_debug_printf ("symbol=%s; lookup in file=%s [%lu]\n", + undef_name, + map->l_name[0] ? map->l_name : rtld_progname, +@@ -432,7 +432,7 @@ + hash table. */ + if (__builtin_expect (tab->size, 0)) + { +- assert (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK); ++ assert (GLRO_dl_debug_mask & DL_DEBUG_PRELINK); + __rtld_lock_unlock_recursive (tab->lock); + goto success; + } +@@ -681,7 +681,7 @@ + } + + /* Display information if we are debugging. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) + _dl_debug_printf ("\ + \nfile=%s [%lu]; needed by %s [%lu] (relocation dependency)\n\n", + map->l_name[0] ? map->l_name : rtld_progname, +@@ -788,7 +788,7 @@ + { + if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) + && skip_map == NULL +- && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED)) ++ && !(GLRO_dl_debug_mask & DL_DEBUG_UNUSED)) + { + /* We could find no value for a strong reference. */ + const char *reference_name = undef_map ? undef_map->l_name : ""; +@@ -861,7 +861,7 @@ + if (__builtin_expect (current_value.m->l_used == 0, 0)) + current_value.m->l_used = 1; + +- if (__builtin_expect (GLRO(dl_debug_mask) ++ if (__builtin_expect (GLRO_dl_debug_mask + & (DL_DEBUG_BINDINGS|DL_DEBUG_PRELINK), 0)) + _dl_debug_bindings (undef_name, undef_map, ref, + ¤t_value, version, type_class, protected); +@@ -926,7 +926,7 @@ + { + const char *reference_name = undef_map->l_name; + +- if (GLRO(dl_debug_mask) & DL_DEBUG_BINDINGS) ++ if (GLRO_dl_debug_mask & DL_DEBUG_BINDINGS) + { + _dl_debug_printf ("binding file %s [%lu] to %s [%lu]: %s symbol `%s'", + (reference_name[0] +@@ -942,7 +942,7 @@ + _dl_debug_printf_c ("\n"); + } + #ifdef SHARED +- if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) ++ if (GLRO_dl_debug_mask & DL_DEBUG_PRELINK) + { + int conflict = 0; + struct sym_val val = { NULL, NULL }; +Index: libc/elf/rtld.c +=================================================================== +--- libc.orig/elf/rtld.c 2012-10-10 08:35:46.000000000 -0700 ++++ libc/elf/rtld.c 2013-01-09 11:49:02.635577870 -0800 +@@ -2118,7 +2118,7 @@ + GLRO(dl_init_all_dirs) = GL(dl_all_dirs); + + /* Print scope information. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0)) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_SCOPES, 0)) + { + _dl_debug_printf ("\nInitial object scopes\n"); + +Index: libc/elf/dl-lookup.c +=================================================================== +--- libc.orig/elf/dl-lookup.c 2012-08-17 12:39:53.000000000 -0700 ++++ libc/elf/dl-lookup.c 2013-01-09 11:49:02.635577870 -0800 +@@ -771,7 +771,7 @@ + { + if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) + && skip_map == NULL +- && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED)) ++ && !(GLRO_dl_debug_mask & DL_DEBUG_UNUSED)) + { + /* We could find no value for a strong reference. */ + const char *reference_name = undef_map ? undef_map->l_name : ""; +Index: libc/elf/get-dynamic-info.h +=================================================================== +--- libc.orig/elf/get-dynamic-info.h 2012-12-02 13:11:45.000000000 -0800 ++++ libc/elf/get-dynamic-info.h 2013-01-09 12:53:51.015657653 -0800 +@@ -157,7 +157,7 @@ + them. Therefore to avoid breaking existing applications the + best we can do is add a warning during debugging with the + intent of notifying the user of the problem. */ +- if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0) ++ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0) + && l->l_flags_1 & ~DT_1_SUPPORTED_MASK) + _dl_debug_printf ("\nWARNING: Unsupported flag value(s) of 0x%x in DT_FLAGS_1.\n", + l->l_flags_1 & ~DT_1_SUPPORTED_MASK); diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/IO-acquire-lock-fix.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/IO-acquire-lock-fix.patch new file mode 100644 index 0000000..cf58035 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/IO-acquire-lock-fix.patch @@ -0,0 +1,17 @@ +import http://sourceware.org/ml/libc-ports/2007-12/msg00000.html + +Upstream-Status: Pending + +Index: libc/bits/stdio-lock.h +=================================================================== +--- libc.orig/bits/stdio-lock.h 2009-10-28 14:34:19.000000000 -0700 ++++ libc/bits/stdio-lock.h 2009-10-28 14:34:54.000000000 -0700 +@@ -50,6 +50,8 @@ __libc_lock_define_recursive (typedef, _ + _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, (_fp)); \ + _IO_flockfile (_fp) + ++# define _IO_acquire_lock_clear_flags2(_fp) _IO_acquire_lock (_fp) ++ + # define _IO_release_lock(_fp) \ + _IO_funlockfile (_fp); \ + _IO_cleanup_region_end (0) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/add_resource_h_to_wait_h.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/add_resource_h_to_wait_h.patch new file mode 100644 index 0000000..f5023c0 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/add_resource_h_to_wait_h.patch @@ -0,0 +1,20 @@ +The older versions of perf still require sys/resource.h to be +present in this header, the newer version of perf in 3.2 and +beyond directly include sys/resource.h + +Upstream-Status: Inapproriate [older kernel/perf specific] + +Signed-off-by: Saul Wold <sgw@linux.intel.com> + +Index: libc/posix/sys/wait.h +=================================================================== +--- libc.orig/posix/sys/wait.h ++++ libc/posix/sys/wait.h +@@ -28,6 +28,7 @@ + __BEGIN_DECLS + + #include <signal.h> ++#include <sys/resource.h> + + /* These macros could also be defined in <stdlib.h>. */ + #if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/eglibc-svn-arm-lowlevellock-include-tls.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/eglibc-svn-arm-lowlevellock-include-tls.patch new file mode 100644 index 0000000..4313aa5 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/eglibc-svn-arm-lowlevellock-include-tls.patch @@ -0,0 +1,21 @@ +In file included from ../nptl/sysdeps/unix/sysv/linux/libc-lowlevellock.c:21: +../nptl/sysdeps/unix/sysv/linux/lowlevellock.c: In function '__lll_lock_wait_private': +../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: warning: implicit declaration of function 'THREAD_GETMEM' +../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: 'THREAD_SELF' undeclared (first use in this function) +../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: (Each undeclared identifier is reported only once +../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: for each function it appears in.) +../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: 'header' undeclared (first use in this function) +make[4]: *** [/var/tmp/portage/sys-libs/glibc-2.7-r1/work/build-default-armv4l-unknown-linux-gnu-nptl/nptl/rtld-libc-lowlevellock.os] Error 1 + +Upstream-Status: Pending + +--- libc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h.orig ++++ libc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h +@@ -25,6 +25,7 @@ + #include <atomic.h> + #include <sysdep.h> + #include <kernel-features.h> ++#include <tls.h> + + #define FUTEX_WAIT 0 + #define FUTEX_WAKE 1 diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/eglibc_fix_findidx_parameters.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/eglibc_fix_findidx_parameters.patch new file mode 100644 index 0000000..bbf4605 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/eglibc_fix_findidx_parameters.patch @@ -0,0 +1,38 @@ +Upstream-Status: backport + +Imported patch from: http://www.eglibc.org/archives/patches/msg01124.html + +Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com> +2012/05/09 + +Index: libc/posix/xregex.c +=================================================================== +--- libc.orig/posix/xregex.c ++++ libc/posix/xregex.c +@@ -2943,7 +2943,7 @@ PREFIX(regex_compile) (const char *ARG_P + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_INDIRECTWC); + +- idx = findidx ((const wint_t**)&cp); ++ idx = findidx ((const wint_t**)&cp, -1); + if (idx == 0 || cp < (wint_t*) str + c1) + /* This is no valid character. */ + FREE_STACK_RETURN (REG_ECOLLATE); +@@ -3392,7 +3392,7 @@ PREFIX(regex_compile) (const char *ARG_P + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); + +- idx = findidx (&cp); ++ idx = findidx (&cp, -1); + if (idx == 0 || cp < str + c1) + /* This is no valid character. */ + FREE_STACK_RETURN (REG_ECOLLATE); +@@ -6363,7 +6363,7 @@ byte_re_match_2_internal (struct re_patt + } + str_buf[i] = TRANSLATE(*(d+i)); + str_buf[i+1] = '\0'; /* sentinel */ +- idx2 = findidx ((const wint_t**)&cp); ++ idx2 = findidx ((const wint_t**)&cp, -1); + } + + /* Update d, however d will be incremented at diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/etc/ld.so.conf b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/etc/ld.so.conf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/etc/ld.so.conf diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fileops-without-wchar-io.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fileops-without-wchar-io.patch new file mode 100644 index 0000000..2ca0bca --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fileops-without-wchar-io.patch @@ -0,0 +1,22 @@ +Fix error like + +/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/work/mips64-oe-linux/eglibc-2.16-r2+svnr19383/build-mips64-oe-linux/libc_pic.os: In function `_IO_new_file_fopen': +/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/work/mips64-oe-linux/eglibc-2.16-r2+svnr19383/eglibc-2_16/libc/libio/fileops.c:431: undefined reference to `_IO_file_close_it_internal' +collect2: error: ld returned 1 exit status + + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Pending +Index: libc/libio/fileops.c +=================================================================== +--- libc.orig/libio/fileops.c 2012-07-04 18:25:47.000000000 -0700 ++++ libc/libio/fileops.c 2012-07-24 00:21:17.220322557 -0700 +@@ -428,7 +428,7 @@ + result->_mode = 1; + #else + /* Treat this as if we couldn't find the given character set. */ +- (void) INTUSE(_IO_file_close_it) (fp); ++ (void) _IO_file_close_it (fp); + __set_errno (EINVAL); + return NULL; + #endif diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fix-tibetian-locales.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fix-tibetian-locales.patch new file mode 100644 index 0000000..25c43a9 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fix-tibetian-locales.patch @@ -0,0 +1,38 @@ +cross localedef fails to compile these locales because name_fmt field is empty +It is not acceptable for cross localedef and it errors out + +LC_NAME: field `name_fmt' not defined + +We therefore give a dummy string to the format, the real fix needs some native +tibetian person to define proper name_fmt + +Upstream-Status: Pending + +Signed-off-by: Khem Raj <raj.khem@gmail.com> + +Index: libc/localedata/locales/bo_CN +=================================================================== +--- libc.orig/localedata/locales/bo_CN 2012-11-17 09:50:14.000000000 -0800 ++++ libc/localedata/locales/bo_CN 2013-01-04 08:55:15.593612288 -0800 +@@ -145,7 +145,7 @@ + LC_NAME + % FIXME + +-name_fmt "" ++name_fmt "FIXME" + % name_gen "FIXME" + % name_miss "FIXME" + % name_mr "FIXME" +Index: libc/localedata/locales/bo_IN +=================================================================== +--- libc.orig/localedata/locales/bo_IN 2012-11-17 09:50:14.000000000 -0800 ++++ libc/localedata/locales/bo_IN 2013-01-04 08:54:12.345609028 -0800 +@@ -70,7 +70,7 @@ + + LC_NAME + % FIXME +-name_fmt "" ++name_fmt "FIXME" + % name_gen "FIXME" + % name_miss "FIXME" + % name_mr "FIXME" diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fix_for_centos_5.8.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fix_for_centos_5.8.patch new file mode 100644 index 0000000..7618c99 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fix_for_centos_5.8.patch @@ -0,0 +1,18 @@ +Upstream-Status: Inappropriate [other] + +This is a hack to fix building the locale bits on an older +CentOs 5.X machine + +Index: eglibc-2_16/libc/locale/programs/config.h +=================================================================== +--- eglibc-2_16.orig/libc/locale/programs/config.h ++++ eglibc-2_16/libc/locale/programs/config.h +@@ -19,6 +19,8 @@ + #ifndef _LD_CONFIG_H + #define _LD_CONFIG_H 1 + ++#define DUMMY_LOCALE_T ++ + /* Use the internal textdomain used for libc messages. */ + #define PACKAGE _libc_intl_domainname + #ifndef VERSION diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fsl-ppc-no-fsqrt.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fsl-ppc-no-fsqrt.patch new file mode 100644 index 0000000..511ee9d --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/fsl-ppc-no-fsqrt.patch @@ -0,0 +1,100 @@ +Create e5500 specific math_private.h and let it include when compiling for e5500/64bit core +We prefefine __CPU_HAS_FSQRT to 0 and then in general ppc64 math_private.h we check if its +already defined before redefining it. This way we can ensure that on e5500 builds it wont +emit fsqrt intructions + +-Khem + +Upstream-Status: Pending + +Index: libc/sysdeps/powerpc/fpu/math_private.h +=================================================================== +--- libc.orig/sysdeps/powerpc/fpu/math_private.h ++++ libc/sysdeps/powerpc/fpu/math_private.h +@@ -25,10 +25,12 @@ + #include <dl-procinfo.h> + #include_next <math_private.h> + +-# if __WORDSIZE == 64 || defined _ARCH_PWR4 +-# define __CPU_HAS_FSQRT 1 +-# else +-# define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0) ++# ifndef __CPU_HAS_FSQRT ++# if __WORDSIZE == 64 || defined _ARCH_PWR4 ++# define __CPU_HAS_FSQRT 1 ++# else ++# define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0) ++# endif + # endif + + extern double __slow_ieee754_sqrt (double); +Index: libc/ports/sysdeps/powerpc/powerpc64/e5500/fpu/math_private.h +=================================================================== +--- /dev/null ++++ libc/ports/sysdeps/powerpc/powerpc64/e5500/fpu/math_private.h +@@ -0,0 +1,9 @@ ++#ifndef _E5500_MATH_PRIVATE_H_ ++#define _E5500_MATH_PRIVATE_H_ 1 ++/* E5500 core FPU does not implement ++ fsqrt */ ++ ++#define __CPU_HAS_FSQRT 0 ++#include_next <math_private.h> ++ ++#endif /* _E5500_MATH_PRIVATE_H_ */ +Index: libc/ports/sysdeps/powerpc/powerpc64/e6500/fpu/math_private.h +=================================================================== +--- /dev/null ++++ libc/ports/sysdeps/powerpc/powerpc64/e6500/fpu/math_private.h +@@ -0,0 +1,9 @@ ++#ifndef _E6500_MATH_PRIVATE_H_ ++#define _E6500_MATH_PRIVATE_H_ 1 ++/* E6500 core FPU does not implement ++ fsqrt */ ++ ++#define __CPU_HAS_FSQRT 0 ++#include_next <math_private.h> ++ ++#endif /* _E6500_MATH_PRIVATE_H_ */ +Index: libc/ports/sysdeps/powerpc/powerpc32/e500mc/fpu/math_private.h +=================================================================== +--- /dev/null ++++ libc/ports/sysdeps/powerpc/powerpc32/e500mc/fpu/math_private.h +@@ -0,0 +1,9 @@ ++#ifndef _E500MC_MATH_PRIVATE_H_ ++#define _E500MC_MATH_PRIVATE_H_ 1 ++/* E500MC core FPU does not implement ++ fsqrt */ ++ ++#define __CPU_HAS_FSQRT 0 ++#include_next <math_private.h> ++ ++#endif /* _E500MC_MATH_PRIVATE_H_ */ +Index: libc/ports/sysdeps/powerpc/powerpc32/e5500/fpu/math_private.h +=================================================================== +--- /dev/null ++++ libc/ports/sysdeps/powerpc/powerpc32/e5500/fpu/math_private.h +@@ -0,0 +1,9 @@ ++#ifndef _E5500_MATH_PRIVATE_H_ ++#define _E5500_MATH_PRIVATE_H_ 1 ++/* E5500 core FPU does not implement ++ fsqrt */ ++ ++#define __CPU_HAS_FSQRT 0 ++#include_next <math_private.h> ++ ++#endif /* _E5500_MATH_PRIVATE_H_ */ +Index: libc/ports/sysdeps/powerpc/powerpc32/e6500/fpu/math_private.h +=================================================================== +--- /dev/null ++++ libc/ports/sysdeps/powerpc/powerpc32/e6500/fpu/math_private.h +@@ -0,0 +1,9 @@ ++#ifndef _E6500_MATH_PRIVATE_H_ ++#define _E6500_MATH_PRIVATE_H_ 1 ++/* E6500 core FPU does not implement ++ fsqrt */ ++ ++#define __CPU_HAS_FSQRT 0 ++#include_next <math_private.h> ++ ++#endif /* _E6500_MATH_PRIVATE_H_ */ diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/generate-supported.mk b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/generate-supported.mk new file mode 100644 index 0000000..d2a28c2 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/generate-supported.mk @@ -0,0 +1,11 @@ +#!/usr/bin/make + +include $(IN) + +all: + rm -f $(OUT) + touch $(OUT) + for locale in $(SUPPORTED-LOCALES); do \ + [ $$locale = true ] && continue; \ + echo $$locale | sed 's,/, ,' >> $(OUT); \ + done diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/glibc.fix_sqrt2.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/glibc.fix_sqrt2.patch new file mode 100644 index 0000000..689b79c --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/glibc.fix_sqrt2.patch @@ -0,0 +1,1516 @@ +Signed-of-by: Edmar Wienskoski <edmar@freescale.com> +Upstream-Status: Pending + +Index: libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +Index: libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +Index: libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +Index: libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +Index: libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +Index: libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +=================================================================== +--- /dev/null ++++ libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <math.h> ++#include <math_private.h> ++#include <fenv_libc.h> ++#include <inttypes.h> ++ ++#include <sysdep.h> ++#include <ldsodefs.h> ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/603e/fpu +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies +@@ -0,0 +1,2 @@ ++# e300c3 is a variant of 603e so use the same optimizations for sqrt ++powerpc/powerpc32/603e/fpu +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e500mc/fpu +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e5500/fpu +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e6500/fpu +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc64/e5500/fpu +Index: libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies +=================================================================== +--- /dev/null ++++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc64/e6500/fpu diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/grok_gold.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/grok_gold.patch new file mode 100644 index 0000000..d46737a --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/grok_gold.patch @@ -0,0 +1,34 @@ +Make ld --version output matching grok gold's output + +adapted from from upstream branch roland/gold-vs-libc + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Backport + + +Index: libc/configure +=================================================================== +--- libc.orig/configure ++++ libc/configure +@@ -4654,7 +4654,7 @@ else + # Found it, now check the version. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD" >&5 + $as_echo_n "checking version of $LD... " >&6; } +- ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` ++ ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU [Bbinutilsd][^.]* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*) +Index: libc/configure.ac +=================================================================== +--- libc.orig/configure.ac ++++ libc/configure.ac +@@ -990,7 +990,7 @@ AC_CHECK_PROG_VER(AS, $AS, --version, + [GNU assembler.* \([0-9]*\.[0-9.]*\)], + [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], AS=: critic_missing="$critic_missing as") + AC_CHECK_PROG_VER(LD, $LD, --version, +- [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)], ++ [GNU [Bbinutilsd][^.]* \([0-9][0-9]*\.[0-9.]*\)], + [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], LD=: critic_missing="$critic_missing ld") + + # These programs are version sensitive. diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/initgroups_keys.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/initgroups_keys.patch new file mode 100644 index 0000000..be29856 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/initgroups_keys.patch @@ -0,0 +1,20 @@ +This is needed since initgroups belongs to NET group +so when NET is disabled in eglibc build then it reports +as undefined symbol + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Pending + +Index: libc/nss/getent.c +=================================================================== +--- libc.orig/nss/getent.c 2012-03-09 09:41:57.099581559 -0800 ++++ libc/nss/getent.c 2012-03-09 09:42:13.095582334 -0800 +@@ -898,7 +898,7 @@ + D(group) + D(gshadow) + DN(hosts) +-D(initgroups) ++DN(initgroups) + DN(netgroup) + DN(networks) + D(passwd) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ld-search-order.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ld-search-order.patch new file mode 100644 index 0000000..e83a0ad --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ld-search-order.patch @@ -0,0 +1,56 @@ +Upstream-Status: Inappropriate [embedded specific] + +The default lib search path order is: + + 1) LD_LIBRARY_PATH + 2) RPATH from the binary + 3) ld.so.cache + 4) default search paths embedded in the linker + +For nativesdk binaries which are being used alongside binaries on a host system, we +need the search paths to firstly search the shipped nativesdk libs but then also +cover the host system. For example we want the host system's libGL and this may be +in a non-standard location like /usr/lib/mesa. The only place the location is know +about is in the ld.so.cache of the host system. + +Since nativesdk has a simple structure and doesn't need to use a cache itself, we +repurpose the cache for use as a last resort in finding host system binaries. This +means we need to switch the order of 3 and 4 above to make this work effectively. + +RP 14/10/2010 + +Index: libc/elf/dl-load.c +=================================================================== +--- libc.orig/elf/dl-load.c 2012-12-02 13:11:45.000000000 -0800 ++++ libc/elf/dl-load.c 2013-01-09 07:00:59.135223084 -0800 +@@ -2215,7 +2215,14 @@ + fd = open_path (name, namelen, mode & __RTLD_SECURE, + &loader->l_runpath_dirs, &realname, &fb, loader, + LA_SER_RUNPATH, &found_other_class); +- ++ /* try the default path. */ ++ if (fd == -1 ++ && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL ++ || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1)) ++ && rtld_search_dirs.dirs != (void *) -1) ++ fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs, ++ &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); ++ /* Finally try ld.so.cache */ + #ifdef USE_LDCONFIG + if (fd == -1 + && (__builtin_expect (! (mode & __RTLD_SECURE), 1) +@@ -2283,14 +2290,6 @@ + } + #endif + +- /* Finally, try the default path. */ +- if (fd == -1 +- && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL +- || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1)) +- && rtld_search_dirs.dirs != (void *) -1) +- fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs, +- &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); +- + /* Add another newline when we are tracing the library loading. */ + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) + _dl_debug_printf ("\n"); diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/mips-rld-map-check.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/mips-rld-map-check.patch new file mode 100644 index 0000000..9b646fe --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/mips-rld-map-check.patch @@ -0,0 +1,26 @@ + +On mips target, binutils currently sets DT_MIPS_RLD_MAP to 0 in dynamic +section if a --version-script sets _RLD_MAP to local. This is apparently +a binutils bug, but libc shouldn't segfault in this case. + +see also: http://sourceware.org/bugilla/show_bug.cgi?id=11615 + +Upstream-Status: Pending + +9/19/2010 - added by Qing He <qing.he@intel.com> + + +--- +diff -ru glibc-2.10.1.orig/ports/sysdeps/mips/dl-machine.h glibc-2.10.1/ports/sysdeps/mips/dl-machine.h +--- glibc-2.10.1.orig/ports/sysdeps/mips/dl-machine.h 2009-05-16 16:36:20.000000000 +0800 ++++ glibc-2.10.1/ports/sysdeps/mips/dl-machine.h 2010-09-19 09:11:53.000000000 +0800 +@@ -70,7 +70,8 @@ + /* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in + with the run-time address of the r_debug structure */ + #define ELF_MACHINE_DEBUG_SETUP(l,r) \ +-do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \ ++do { if ((l)->l_info[DT_MIPS (RLD_MAP)] && \ ++ (l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) \ + *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \ + (ElfW(Addr)) (r); \ + } while (0) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/multilib_readlib.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/multilib_readlib.patch new file mode 100644 index 0000000..1542b1b --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/multilib_readlib.patch @@ -0,0 +1,17 @@ +Upstream-Status: Inappropriate [embedded specific] + +Replace the OECORE_KNOWN_INTERPRETER_NAMES with the value of +variable EGLIBC_KNOWN_INTERPRETER_NAMES. + +Lianhao Lu, 08/01/2011 + +--- libc/elf/readlib.c.orig 2011-08-12 17:05:51.864470837 +0800 ++++ libc/elf/readlib.c 2011-08-12 17:06:39.346942074 +0800 +@@ -52,6 +52,7 @@ + #ifdef SYSDEP_KNOWN_INTERPRETER_NAMES + SYSDEP_KNOWN_INTERPRETER_NAMES + #endif ++ OECORE_KNOWN_INTERPRETER_NAMES + }; + + static struct known_names known_libs[] = diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppc-sqrt_finite.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppc-sqrt_finite.patch new file mode 100644 index 0000000..6ea666b --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppc-sqrt_finite.patch @@ -0,0 +1,184 @@ +on ppc fixes the errors like below +| ./.libs/libpulsecore-1.1.so: undefined reference to `__sqrt_finite' +| collect2: ld returned 1 exit status + +Upstream-Status: Pending + +ChangeLog + +2012-01-06 Khem Raj <raj.khem@gmail.com> + + * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c: Add __*_finite alias. + Remove cruft. + * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c: Ditto. + * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c: Ditto. + * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c: Ditto. + +Index: libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -39,14 +39,8 @@ static const float half = 0.5; + We find the actual square root and half of its reciprocal + simultaneously. */ + +-#ifdef __STDC__ + double + __ieee754_sqrt (double b) +-#else +-double +-__ieee754_sqrt (b) +- double b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -132,3 +126,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -37,14 +37,8 @@ static const float threehalf = 1.5; + We find the reciprocal square root and use that to compute the actual + square root. */ + +-#ifdef __STDC__ + float + __ieee754_sqrtf (float b) +-#else +-float +-__ieee754_sqrtf (b) +- float b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -39,14 +39,8 @@ static const float half = 0.5; + We find the actual square root and half of its reciprocal + simultaneously. */ + +-#ifdef __STDC__ + double + __ieee754_sqrt (double b) +-#else +-double +-__ieee754_sqrt (b) +- double b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -132,3 +126,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -37,14 +37,8 @@ static const float threehalf = 1.5; + We find the reciprocal square root and use that to compute the actual + square root. */ + +-#ifdef __STDC__ + float + __ieee754_sqrtf (float b) +-#else +-float +-__ieee754_sqrtf (b) +- float b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppc_slow_ieee754_sqrt.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppc_slow_ieee754_sqrt.patch new file mode 100644 index 0000000..60532cb --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppc_slow_ieee754_sqrt.patch @@ -0,0 +1,365 @@ + __ieee754_sqrt{,f} are now inline functions and call out __slow versions + + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Pending +Index: libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -40,7 +40,7 @@ static const float half = 0.5; + simultaneously. */ + + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -38,7 +38,7 @@ static const float threehalf = 1.5; + square root. */ + + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -93,4 +93,10 @@ __ieee754_sqrtf (float b) + } + return f_washf (b); + } ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -40,7 +40,7 @@ static const float half = 0.5; + simultaneously. */ + + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -38,7 +38,7 @@ static const float threehalf = 1.5; + square root. */ + + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -93,4 +93,11 @@ __ieee754_sqrtf (float b) + } + return f_washf (b); + } ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +Index: libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +Index: libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +=================================================================== +--- libc.orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppce6500-32b_slow_ieee754_sqrt.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppce6500-32b_slow_ieee754_sqrt.patch new file mode 100644 index 0000000..4c6c107 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/ppce6500-32b_slow_ieee754_sqrt.patch @@ -0,0 +1,47 @@ + __ieee754_sqrt{,f} are now inline functions and call out __slow versions + + +Signed-off-by: chunrong guo <B40290@freescale.com> +Upstream-Status: Pending + +diff -rNu libc-orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +--- libc-orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c 2014-04-08 04:39:58.487229887 -0500 ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c 2014-04-08 04:40:52.643069198 -0500 +@@ -41,10 +41,10 @@ + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +diff -rNu libc-orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +--- libc-orig/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c 2014-04-08 04:39:58.487229887 -0500 ++++ libc/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c 2014-04-08 04:41:26.017067682 -0500 +@@ -39,10 +39,10 @@ + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/relocatable_sdk.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/relocatable_sdk.patch new file mode 100644 index 0000000..ca5f17b --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/relocatable_sdk.patch @@ -0,0 +1,108 @@ +Upstream-Status: Inappropriate [SDK specific] + +This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings +and lengths as well as ld.so.cache path in the dynamic loader to specific +sections in memory. The sections that contain paths have been allocated a 4096 +byte section, which is the maximum path length in linux. This will allow the +relocating script to parse the ELF binary, detect the section and easily replace +the strings in a certain path. + +Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> + +Index: libc/elf/interp.c +=================================================================== +--- libc.orig/elf/interp.c ++++ libc/elf/interp.c +@@ -16,5 +16,5 @@ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp"))) ++const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp"))) + = RUNTIME_LINKER; +Index: libc/elf/dl-load.c +=================================================================== +--- libc.orig/elf/dl-load.c ++++ libc/elf/dl-load.c +@@ -144,8 +144,8 @@ static size_t max_capstrlen attribute_re + /* Get the generated information about the trusted directories. */ + #include "trusted-dirs.h" + +-static const char system_dirs[] = SYSTEM_DIRS; +-static const size_t system_dirs_len[] = ++static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS; ++volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) = + { + SYSTEM_DIRS_LEN + }; +Index: libc/elf/dl-cache.c +=================================================================== +--- libc.orig/elf/dl-cache.c ++++ libc/elf/dl-cache.c +@@ -133,6 +133,10 @@ do \ + while (0) + + ++const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) = ++ SYSCONFDIR "/ld.so.cache"; ++ ++ + int + internal_function + _dl_cache_libcmp (const char *p1, const char *p2) +Index: libc/elf/ldconfig.c +=================================================================== +--- libc.orig/elf/ldconfig.c ++++ libc/elf/ldconfig.c +@@ -166,6 +166,9 @@ static struct argp argp = + options, parse_opt, NULL, doc, NULL, more_help, NULL + }; + ++ ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); ++ + /* Check if string corresponds to an important hardware capability or + a platform. */ + static int +Index: libc/sysdeps/generic/dl-cache.h +=================================================================== +--- libc.orig/sysdeps/generic/dl-cache.h ++++ libc/sysdeps/generic/dl-cache.h +@@ -27,10 +27,6 @@ + ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) + #endif + +-#ifndef LD_SO_CACHE +-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" +-#endif +- + #ifndef add_system_dir + # define add_system_dir(dir) add_dir (dir) + #endif +Index: libc/elf/rtld.c +=================================================================== +--- libc.orig/elf/rtld.c ++++ libc/elf/rtld.c +@@ -99,6 +99,7 @@ uintptr_t __pointer_chk_guard_local + strong_alias (__pointer_chk_guard_local, __pointer_chk_guard) + #endif + ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); + + /* List of auditing DSOs. */ + static struct audit_list +@@ -1031,12 +1032,12 @@ of this helper program; chances are you + --list list all dependencies and how they are resolved\n\ + --verify verify that given object really is a dynamically linked\n\ + object we can handle\n\ +- --inhibit-cache Do not use " LD_SO_CACHE "\n\ ++ --inhibit-cache Do not use %s\n\ + --library-path PATH use given PATH instead of content of the environment\n\ + variable LD_LIBRARY_PATH\n\ + --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\ + in LIST\n\ +- --audit LIST use objects named in LIST as auditors\n"); ++ --audit LIST use objects named in LIST as auditors\n", LD_SO_CACHE); + + ++_dl_skip_args; + --_dl_argc; diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-2.19/relocatable_sdk_fix_openpath.patch b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/relocatable_sdk_fix_openpath.patch new file mode 100644 index 0000000..f164f8f --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-2.19/relocatable_sdk_fix_openpath.patch @@ -0,0 +1,41 @@ +Upstream-Status: Inappropriate [SDK specific] + +eglibc-nativesdk: Fix buffer overrun with a relocated SDK + +When ld-linux-*.so.2 is relocated to a path that is longer than the +original fixed location, the dynamic loader will crash in open_path +because it implicitly assumes that max_dirnamelen is a fixed size that +never changes. + +The allocated buffer will not be large enough to contain the directory +path string which is larger than the fixed location provided at build +time. + +Signed-off-by: Jason Wessel <jason.wessel@windriver.com> + +--- + elf/dl-load.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -1919,7 +1919,19 @@ open_path (const char *name, size_t name + given on the command line when rtld is run directly. */ + return -1; + ++ do ++ { ++ struct r_search_path_elem *this_dir = *dirs; ++ if (this_dir->dirnamelen > max_dirnamelen) ++ { ++ max_dirnamelen = this_dir->dirnamelen; ++ } ++ } ++ while (*++dirs != NULL); ++ + buf = alloca (max_dirnamelen + max_capstrlen + namelen); ++ ++ dirs = sps->dirs; + do + { + struct r_search_path_elem *this_dir = *dirs; diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-collateral.inc b/meta-aspeed/recipes-core/eglibc/eglibc-collateral.inc new file mode 100644 index 0000000..8feca09 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-collateral.inc @@ -0,0 +1,12 @@ +INHIBIT_DEFAULT_DEPS = "1" +LICENSE = "GPLv2 & LGPLv2.1" +HOMEPAGE = "http://www.eglibc.org/" + +do_fetch[noexec] = "1" +do_unpack[noexec] = "1" +do_patch[noexec] = "1" +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install[depends] += "virtual/${MLPREFIX}libc:do_populate_sysroot" + diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-common.inc b/meta-aspeed/recipes-core/eglibc/eglibc-common.inc new file mode 100644 index 0000000..d18786a --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-common.inc @@ -0,0 +1,9 @@ +SUMMARY = "Embedded GLIBC (GNU C Library)" +DESCRIPTION = "Embedded GLIBC (EGLIBC) is a variant of the GNU C Library (GLIBC) that is designed to work well on embedded systems. EGLIBC strives to be source and binary compatible with GLIBC. EGLIBC's goals include reduced footprint, configurable components, better support for cross-compilation and cross-testing." +HOMEPAGE = "http://www.eglibc.org/home" +SECTION = "libs" +LICENSE = "GPLv2 & LGPLv2.1" +LIC_FILES_CHKSUM ?= "file://LICENSES;md5=07a394b26e0902b9ffdec03765209770 \ + file://COPYING;md5=393a5ca445f6965873eca0259a17f833 \ + file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ + file://COPYING.LIB;md5=bbb461211a33b134d42ed5ee802b37ff " diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-initial.inc b/meta-aspeed/recipes-core/eglibc/eglibc-initial.inc new file mode 100644 index 0000000..39d553e --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-initial.inc @@ -0,0 +1,78 @@ +DEPENDS = "linux-libc-headers virtual/${TARGET_PREFIX}gcc-initial" +PROVIDES = "virtual/${TARGET_PREFIX}libc-initial" + +PACKAGES = "" +PACKAGES_DYNAMIC = "" + +STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}" +STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${TARGET_ARCH}" +TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TARGET}" + +do_configure () { + sed -ie 's,{ (exit 1); exit 1; }; },{ (exit 0); }; },g' ${S}/configure + chmod +x ${S}/configure + (cd ${S} && gnu-configize) || die "failure in running gnu-configize" + find ${S} -name "configure" | xargs touch + ${S}/configure --host=${TARGET_SYS} --build=${BUILD_SYS} \ + --prefix=/usr \ + --without-cvs --disable-sanity-checks \ + --with-headers=${STAGING_DIR_TARGET}${includedir} \ + --with-kconfig=${STAGING_BINDIR_NATIVE} \ + --enable-hacker-mode --enable-addons +} + +do_compile () { + : +} + +do_install () { + oe_runmake cross-compiling=yes install_root=${D} \ + includedir='${includedir}' prefix='${prefix}' \ + install-bootstrap-headers=yes install-headers + + oe_runmake csu/subdir_lib + mkdir -p ${D}${libdir}/ + install -m 644 csu/crt[1in].o ${D}${libdir} + + # Two headers -- stubs.h and features.h -- aren't installed by install-headers, + # so do them by hand. We can tolerate an empty stubs.h for the moment. + # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html + mkdir -p ${D}${includedir}/gnu/ + touch ${D}${includedir}/gnu/stubs.h + cp ${S}/include/features.h ${D}${includedir}/features.h + + if [ -e ${B}/bits/stdio_lim.h ]; then + cp ${B}/bits/stdio_lim.h ${D}${includedir}/bits/ + fi + # add links to linux-libc-headers: final eglibc build need this. + for t in linux asm asm-generic; do + ln -s ${STAGING_DIR_TARGET}${includedir}/$t ${D}${includedir}/ + done +} + +do_install_locale() { + : +} + +do_siteconfig () { + : +} + +SSTATEPOSTINSTFUNCS += "eglibcinitial_sstate_postinst" +eglibcinitial_sstate_postinst() { + if [ "${BB_CURRENTTASK}" = "populate_sysroot" -o "${BB_CURRENTTASK}" = "populate_sysroot_setscene" ] + then + # Recreate the symlinks to ensure they point to the correct location + for t in linux asm asm-generic; do + rm -f ${STAGING_DIR_TCBOOTSTRAP}${includedir}/$t + ln -s ${STAGING_DIR_TARGET}${includedir}/$t ${STAGING_DIR_TCBOOTSTRAP}${includedir}/ + done + fi +} + +do_populate_sysroot[sstate-outputdirs] = "${STAGING_DIR_TCBOOTSTRAP}/" + +# We don't install any scripts so there is nothing to evacuate +do_evacuate_scripts () { + : +} diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-initial_2.19.bb b/meta-aspeed/recipes-core/eglibc/eglibc-initial_2.19.bb new file mode 100644 index 0000000..de45079 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-initial_2.19.bb @@ -0,0 +1,11 @@ +require eglibc_${PV}.bb +require eglibc-initial.inc + +DEPENDS += "kconfig-frontends-native" + +# main eglibc recipes muck with TARGET_CPPFLAGS to point into +# final target sysroot but we +# are not there when building eglibc-initial +# so reset it here + +TARGET_CPPFLAGS = "" diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-ld.inc b/meta-aspeed/recipes-core/eglibc/eglibc-ld.inc new file mode 100644 index 0000000..6261ae3 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-ld.inc @@ -0,0 +1,56 @@ +def ld_append_if_tune_exists(d, infos, dict): + tune = d.getVar("DEFAULTTUNE", True) or "" + libdir = d.getVar("base_libdir", True) or "" + if tune in dict: + infos['ldconfig'].add('{"' + libdir + '/' + dict[tune][0] + '",' + dict[tune][1] + ' }') + infos['lddrewrite'].add(libdir+'/'+dict[tune][0]) + +def eglibc_dl_info(d): + ld_info_all = { + "mips": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64-n32": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mipsel": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64el-n32": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64el": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips-nf": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64-nf-n32": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64-nf": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64el-nf-n32": ["ld.so.1", "FLAG_ELF_LIBC6"], + "mips64el-nf": ["ld.so.1", "FLAG_ELF_LIBC6"], + "powerpc": ["ld.so.1", "FLAG_ELF_LIBC6"], + "powerpc-nf": ["ld.so.1", "FLAG_ELF_LIBC6"], + "powerpc64": ["ld64.so.1", "FLAG_ELF_LIBC6"], + "powerpc64-nf": ["ld64.so.1", "FLAG_ELF_LIBC6"], + "core2-32": ["ld-linux.so.2", "FLAG_ELF_LIBC6"], + "core2-64": ["ld-linux-x86-64.so.2", "FLAG_ELF_LIBC6"], + "x86": ["ld-linux.so.2", "FLAG_ELF_LIBC6"], + "x86-64": ["ld-linux-x86-64.so.2", "FLAG_ELF_LIBC6"], + "i586": ["ld-linux.so.2", "FLAG_ELF_LIBC6"], + "corei7-32": ["ld-linux.so.2", "FLAG_ELF_LIBC6"], + "corei7-64": ["ld-linux-x86-64.so.2", "FLAG_ELF_LIBC6"], + } + + infos = {'ldconfig':set(), 'lddrewrite':set()} + ld_append_if_tune_exists(d, infos, ld_info_all) + + #DEFAULTTUNE_MULTILIB_ORIGINAL + original_tune=d.getVar("DEFAULTTUNE_MULTILIB_ORIGINAL",True) + if original_tune: + localdata = bb.data.createCopy(d) + localdata.setVar("DEFAULTTUNE", original_tune) + ld_append_if_tune_exists(localdata, infos, ld_info_all) + + variants = d.getVar("MULTILIB_VARIANTS", True) or "" + for item in variants.split(): + localdata = bb.data.createCopy(d) + overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item + localdata.setVar("OVERRIDES", overrides) + bb.data.update_data(localdata) + ld_append_if_tune_exists(localdata, infos, ld_info_all) + infos['ldconfig'] = ','.join(infos['ldconfig']) + infos['lddrewrite'] = ' '.join(infos['lddrewrite']) + return infos + +EGLIBC_KNOWN_INTERPRETER_NAMES = "${@eglibc_dl_info(d)['ldconfig']}" +RTLDLIST = "${@eglibc_dl_info(d)['lddrewrite']}" diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-locale.inc b/meta-aspeed/recipes-core/eglibc/eglibc-locale.inc new file mode 100644 index 0000000..4da5abd --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-locale.inc @@ -0,0 +1,96 @@ +include eglibc-collateral.inc + +SUMMARY = "Locale data from eglibc" + +BPN = "eglibc" +LOCALEBASEPN = "${MLPREFIX}eglibc" + +# eglibc-collateral.inc inhibits all default deps, but do_package needs objcopy +# ERROR: objcopy failed with exit code 127 (cmd was 'i586-webos-linux-objcopy' --only-keep-debug 'eglibc-locale/2.17-r0/package/usr/lib/gconv/IBM1166.so' 'eglibc-locale/2.17-r0/package/usr/lib/gconv/.debug/IBM1166.so') +# ERROR: Function failed: split_and_strip_files +BINUTILSDEP = "virtual/${MLPREFIX}${TARGET_PREFIX}binutils:do_populate_sysroot" +BINUTILSDEP_class-nativesdk = "virtual/${TARGET_PREFIX}binutils-crosssdk:do_populate_sysroot" +do_package[depends] += "${BINUTILSDEP}" + +# Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION +# is set. The idea is to avoid running localedef on the target (at first boot) +# to decrease initial boot time and avoid localedef being killed by the OOM +# killer which used to effectively break i18n on machines with < 128MB RAM. + +# default to disabled +ENABLE_BINARY_LOCALE_GENERATION ?= "0" +ENABLE_BINARY_LOCALE_GENERATION_pn-nativesdk-eglibc-locale = "0" + +#enable locale generation on these arches +# BINARY_LOCALE_ARCHES is a space separated list of regular expressions +BINARY_LOCALE_ARCHES ?= "arm.* i[3-6]86 x86_64 powerpc mips mips64" + +# set "1" to use cross-localedef for locale generation +# set "0" for qemu emulation of native localedef for locale generation +LOCALE_GENERATION_WITH_CROSS-LOCALEDEF = "1" + +PROVIDES = "virtual/libc-locale" + +PACKAGES = "localedef ${PN}-dbg" + +PACKAGES_DYNAMIC = "^locale-base-.* \ + ^eglibc-gconv-.* ^eglibc-charmap-.* ^eglibc-localedata-.* ^eglibc-binary-localedata-.* \ + ^glibc-gconv-.* ^glibc-charmap-.* ^glibc-localedata-.* ^glibc-binary-localedata-.* \ + ^${MLPREFIX}eglibc-gconv$" + +# Create a eglibc-binaries package +ALLOW_EMPTY_${BPN}-binaries = "1" +PACKAGES += "${BPN}-binaries" +RRECOMMENDS_${BPN}-binaries = "${@" ".join([p for p in d.getVar('PACKAGES', True).split() if p.find("eglibc-binary") != -1])}" + +# Create a eglibc-charmaps package +ALLOW_EMPTY_${BPN}-charmaps = "1" +PACKAGES += "${BPN}-charmaps" +RRECOMMENDS_${BPN}-charmaps = "${@" ".join([p for p in d.getVar('PACKAGES', True).split() if p.find("eglibc-charmap") != -1])}" + +# Create a eglibc-gconvs package +ALLOW_EMPTY_${BPN}-gconvs = "1" +PACKAGES += "${BPN}-gconvs" +RRECOMMENDS_${BPN}-gconvs = "${@" ".join([p for p in d.getVar('PACKAGES', True).split() if p.find("eglibc-gconv") != -1])}" + +# Create a eglibc-localedatas package +ALLOW_EMPTY_${BPN}-localedatas = "1" +PACKAGES += "${BPN}-localedatas" +RRECOMMENDS_${BPN}-localedatas = "${@" ".join([p for p in d.getVar('PACKAGES', True).split() if p.find("eglibc-localedata") != -1])}" + +DESCRIPTION_localedef = "eglibc: compile locale definition files" + +# eglibc-gconv is dynamically added into PACKAGES, thus +# FILES_eglibc-gconv will not be automatically extended in multilib. +# Explicitly add ${MLPREFIX} for FILES_eglibc-gconv. +FILES_${MLPREFIX}eglibc-gconv = "${libdir}/gconv/*" +FILES_${PN}-dbg += "${libdir}/gconv/.debug/*" +FILES_localedef = "${bindir}/localedef" + +LOCALETREESRC = "${STAGING_INCDIR}/eglibc-locale-internal-${MULTIMACH_TARGET_SYS}" + +do_install () { + mkdir -p ${D}${bindir} ${D}${datadir} ${D}${libdir} + if [ -n "$(ls ${LOCALETREESRC}/${bindir})" ]; then + cp -fpPR ${LOCALETREESRC}/${bindir}/* ${D}${bindir} + fi + if [ -n "$(ls ${LOCALETREESRC}/${localedir})" ]; then + mkdir -p ${D}${localedir} + cp -fpPR ${LOCALETREESRC}/${localedir}/* ${D}${localedir} + fi + if [ -e ${LOCALETREESRC}/${libdir}/gconv ]; then + cp -fpPR ${LOCALETREESRC}/${libdir}/gconv ${D}${libdir} + fi + if [ -e ${LOCALETREESRC}/${datadir}/i18n ]; then + cp -fpPR ${LOCALETREESRC}/${datadir}/i18n ${D}${datadir} + fi + if [ -e ${LOCALETREESRC}/${datadir}/locale ]; then + cp -fpPR ${LOCALETREESRC}/${datadir}/locale ${D}${datadir} + fi + chown root.root -R ${D} + cp -fpPR ${LOCALETREESRC}/SUPPORTED ${WORKDIR} +} + +inherit libc-package + +BBCLASSEXTEND = "nativesdk" diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-locale_2.19.bb b/meta-aspeed/recipes-core/eglibc/eglibc-locale_2.19.bb new file mode 100644 index 0000000..ce6c1d2 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-locale_2.19.bb @@ -0,0 +1 @@ +require eglibc-locale.inc diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-mtrace.inc b/meta-aspeed/recipes-core/eglibc/eglibc-mtrace.inc new file mode 100644 index 0000000..d68783e --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-mtrace.inc @@ -0,0 +1,13 @@ +include eglibc-collateral.inc + +SUMMARY = "mtrace utility provided by eglibc" +DESCRIPTION = "mtrace utility provided by eglibc" +RDEPENDS_${PN} = "perl" +RPROVIDES_${PN} = "libc-mtrace" + +SRC = "${STAGING_INCDIR}/eglibc-scripts-internal-${MULTIMACH_TARGET_SYS}" + +do_install() { + install -d -m 0755 ${D}${bindir} + install -m 0755 ${SRC}/mtrace ${D}${bindir}/ +} diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-mtrace_2.19.bb b/meta-aspeed/recipes-core/eglibc/eglibc-mtrace_2.19.bb new file mode 100644 index 0000000..6fa2be9 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-mtrace_2.19.bb @@ -0,0 +1 @@ +require eglibc-mtrace.inc diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-options.inc b/meta-aspeed/recipes-core/eglibc/eglibc-options.inc new file mode 100644 index 0000000..0432758 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-options.inc @@ -0,0 +1,162 @@ +def eglibc_cfg(feature, tokens, cnf): + if type(tokens) == type(""): + tokens = [tokens] + if feature: + cnf.extend([token + '=y' for token in tokens]) + else: + for token in tokens: + cnf.extend([token + '=n']) + if token == 'OPTION_EGLIBC_NSSWITCH': + cnf.extend(["OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG=\"${S}/nss/nsswitch.conf\""]) + cnf.extend(["OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS=\"${S}/nss/fixed-nsswitch.functions\""]) + +# Map distro features to eglibc options settings +def features_to_eglibc_settings(d): + cnf = ([]) + + ipv4 = base_contains('DISTRO_FEATURES', 'ipv4', True, False, d) + ipv6 = base_contains('DISTRO_FEATURES', 'ipv6', True, False, d) + libc_backtrace = base_contains('DISTRO_FEATURES', 'libc-backtrace', True, False, d) + libc_big_macros = base_contains('DISTRO_FEATURES', 'libc-big-macros', True, False, d) + libc_bsd = base_contains('DISTRO_FEATURES', 'libc-bsd', True, False, d) + libc_cxx_tests = base_contains('DISTRO_FEATURES', 'libc-cxx-tests', True, False, d) + libc_catgets = base_contains('DISTRO_FEATURES', 'libc-catgets', True, False, d) + libc_charsets = base_contains('DISTRO_FEATURES', 'libc-charsets', True, False, d) + libc_crypt = base_contains('DISTRO_FEATURES', 'libc-crypt', True, False, d) + libc_crypt_ufc = base_contains('DISTRO_FEATURES', 'libc-crypt-ufc', True, False, d) + libc_db_aliases = base_contains('DISTRO_FEATURES', 'libc-db-aliases', True, False, d) + libc_envz = base_contains('DISTRO_FEATURES', 'libc-envz', True, False, d) + libc_fcvt = base_contains('DISTRO_FEATURES', 'libc-fcvt', True, False, d) + libc_fmtmsg = base_contains('DISTRO_FEATURES', 'libc-fmtmsg', True, False, d) + libc_fstab = base_contains('DISTRO_FEATURES', 'libc-fstab', True, False, d) + libc_ftraverse = base_contains('DISTRO_FEATURES', 'libc-ftraverse', True, False, d) + libc_getlogin = base_contains('DISTRO_FEATURES', 'libc-getlogin', True, False, d) + libc_idn = base_contains('DISTRO_FEATURES', 'libc-idn', True, False, d) + libc_inet_anl = base_contains('DISTRO_FEATURES', 'libc-inet-anl', True, False, d) + libc_libm = base_contains('DISTRO_FEATURES', 'libc-libm', True, False, d) + libc_locales = base_contains('DISTRO_FEATURES', 'libc-locales', True, False, d) + libc_locale_code = base_contains('DISTRO_FEATURES', 'libc-locale-code', True, False, d) + libc_memusage = base_contains('DISTRO_FEATURES', 'libc-memusage', True, False, d) + libc_nis = base_contains('DISTRO_FEATURES', 'libc-nis', True, False, d) + libc_nsswitch = base_contains('DISTRO_FEATURES', 'libc-nsswitch', True, False, d) + libc_rcmd = base_contains('DISTRO_FEATURES', 'libc-rcmd', True, False, d) + libc_rtld_debug = base_contains('DISTRO_FEATURES', 'libc-rtld-debug', True, False, d) + libc_spawn = base_contains('DISTRO_FEATURES', 'libc-spawn', True, False, d) + libc_streams = base_contains('DISTRO_FEATURES', 'libc-streams', True, False, d) + libc_sunrpc = base_contains('DISTRO_FEATURES', 'libc-sunrpc', True, False, d) + libc_utmp = base_contains('DISTRO_FEATURES', 'libc-utmp', True, False, d) + libc_utmpx = base_contains('DISTRO_FEATURES', 'libc-utmpx', True, False, d) + libc_wordexp = base_contains('DISTRO_FEATURES', 'libc-wordexp', True, False, d) + libc_posix_clang_wchar = base_contains('DISTRO_FEATURES', 'libc-posix-clang-wchar', True, False, d) + libc_posix_regexp = base_contains('DISTRO_FEATURES', 'libc-posix-regexp', True, False, d) + libc_posix_regexp_glibc = base_contains('DISTRO_FEATURES', 'libc-posix-regexp-glibc', True, False, d) + libc_posix_wchar_io = base_contains('DISTRO_FEATURES', 'libc-posix-wchar-io', True, False, d) + + # arrange the dependencies among eglibc configuable options according to file option-groups.def from eglibc source code + new_dep = True + while new_dep: + new_dep = False + + if ipv6 and not ipv4: + new_dep = True + ipv4 = True + + if ipv4 and not libc_nsswitch: + new_dep = True + libc_nsswitch = True + + if libc_cxx_tests: + if not libc_posix_wchar_io: + new_dep = True + libc_posix_wchar_io = True + if not libc_libm: + new_dep = True + libc_libm = True + + if libc_catgets and not libc_locale_code: + new_dep = True + libc_locale_code = True + + if libc_crypt_ufc and not libc_crypt: + new_dep = True + libc_crypt = True + + if libc_getlogin and not libc_utmp: + new_dep = True + libc_utmp = True + + if libc_inet_anl and not ipv4: + new_dep = True + ipv4 = True + + if libc_locale_code and not libc_posix_clang_wchar: + new_dep = True + libc_posix_clang_wchar = True + + if libc_nis: + if not ipv4: + new_dep = True + ipv4 = True + if not libc_sunrpc: + new_dep = True + libc_sunrpc = True + + if libc_rcmd and not ipv4: + new_dep = True + ipv4 = True + + if libc_sunrpc and not ipv4: + new_dep = True + ipv4 = True + + if libc_utmpx and not libc_utmp: + new_dep = True + libc_utmp = True + + if libc_posix_regexp_glibc and not libc_posix_regexp: + new_dep = True + libc_posix_regexp = True + + if libc_posix_wchar_io and not libc_posix_clang_wchar: + new_dep = True + libc_posix_clang_wchar = True + + eglibc_cfg(ipv6, 'OPTION_EGLIBC_ADVANCED_INET6', cnf) + eglibc_cfg(libc_backtrace, 'OPTION_EGLIBC_BACKTRACE', cnf) + eglibc_cfg(libc_big_macros, 'OPTION_EGLIBC_BIG_MACROS', cnf) + eglibc_cfg(libc_bsd, 'OPTION_EGLIBC_BSD', cnf) + eglibc_cfg(libc_cxx_tests, 'OPTION_EGLIBC_CXX_TESTS', cnf) + eglibc_cfg(libc_catgets, 'OPTION_EGLIBC_CATGETS', cnf) + eglibc_cfg(libc_charsets, 'OPTION_EGLIBC_CHARSETS', cnf) + eglibc_cfg(libc_crypt, 'OPTION_EGLIBC_CRYPT', cnf) + eglibc_cfg(libc_crypt_ufc, 'OPTION_EGLIBC_CRYPT_UFC', cnf) + eglibc_cfg(libc_db_aliases, 'OPTION_EGLIBC_DB_ALIASES', cnf) + eglibc_cfg(libc_envz, 'OPTION_EGLIBC_ENVZ', cnf) + eglibc_cfg(libc_fcvt, 'OPTION_EGLIBC_FCVT', cnf) + eglibc_cfg(libc_fmtmsg, 'OPTION_EGLIBC_FMTMSG', cnf) + eglibc_cfg(libc_fstab, 'OPTION_EGLIBC_FSTAB', cnf) + eglibc_cfg(libc_ftraverse, 'OPTION_EGLIBC_FTRAVERSE', cnf) + eglibc_cfg(libc_getlogin, 'OPTION_EGLIBC_GETLOGIN', cnf) + eglibc_cfg(libc_idn, 'OPTION_EGLIBC_IDN', cnf) + eglibc_cfg(ipv4, 'OPTION_EGLIBC_INET', cnf) + eglibc_cfg(libc_inet_anl, 'OPTION_EGLIBC_INET_ANL', cnf) + eglibc_cfg(libc_libm, 'OPTION_EGLIBC_LIBM', cnf) + eglibc_cfg(libc_locales, 'OPTION_EGLIBC_LOCALES', cnf) + eglibc_cfg(libc_locale_code, 'OPTION_EGLIBC_LOCALE_CODE', cnf) + eglibc_cfg(libc_memusage, 'OPTION_EGLIBC_MEMUSAGE', cnf) + eglibc_cfg(libc_nis, 'OPTION_EGLIBC_NIS', cnf) + eglibc_cfg(libc_nsswitch, 'OPTION_EGLIBC_NSSWITCH', cnf) + eglibc_cfg(libc_rcmd, 'OPTION_EGLIBC_RCMD', cnf) + eglibc_cfg(libc_rtld_debug, 'OPTION_EGLIBC_RTLD_DEBUG', cnf) + eglibc_cfg(libc_spawn, 'OPTION_EGLIBC_SPAWN', cnf) + eglibc_cfg(libc_streams, 'OPTION_EGLIBC_STREAMS', cnf) + eglibc_cfg(libc_sunrpc, 'OPTION_EGLIBC_SUNRPC', cnf) + eglibc_cfg(libc_utmp, 'OPTION_EGLIBC_UTMP', cnf) + eglibc_cfg(libc_utmpx, 'OPTION_EGLIBC_UTMPX', cnf) + eglibc_cfg(libc_wordexp, 'OPTION_EGLIBC_WORDEXP', cnf) + eglibc_cfg(libc_posix_clang_wchar, 'OPTION_POSIX_C_LANG_WIDE_CHAR', cnf) + eglibc_cfg(libc_posix_regexp, 'OPTION_POSIX_REGEXP', cnf) + eglibc_cfg(libc_posix_regexp_glibc, 'OPTION_POSIX_REGEXP_GLIBC', cnf) + eglibc_cfg(libc_posix_wchar_io, 'OPTION_POSIX_WIDE_CHAR_DEVICE_IO', cnf) + + return "\n".join(cnf) diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-package.inc b/meta-aspeed/recipes-core/eglibc/eglibc-package.inc new file mode 100644 index 0000000..6721819 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-package.inc @@ -0,0 +1,155 @@ +# +# For now, we will skip building of a gcc package if it is a uclibc one +# and our build is not a uclibc one, and we skip a eglibc one if our build +# is a uclibc build. +# +# See the note in gcc/gcc_3.4.0.oe +# + +python __anonymous () { + import bb, re + uc_os = (re.match('.*uclibc*', d.getVar('TARGET_OS', True)) != None) + if uc_os: + raise bb.parse.SkipPackage("incompatible with target %s" % + d.getVar('TARGET_OS', True)) +} + +# Set this to zero if you don't want ldconfig in the output package +USE_LDCONFIG ?= "1" + +PACKAGES = "${PN}-dbg catchsegv sln nscd ldd ${PN}-utils eglibc-thread-db ${PN}-pic libcidn libmemusage libsegfault ${PN}-pcprofile libsotruss ${PN} eglibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc" + +# The ld.so in this eglibc supports the GNU_HASH +RPROVIDES_${PN} = "glibc rtld(GNU_HASH)" +RPROVIDES_${PN}-utils = "glibc-utils" +RPROVIDES_${PN}-mtrace = "glibc-mtrace libc-mtrace" +RPROVIDES_${PN}-pic = "glibc-pic" +RPROVIDES_${PN}-dev = "glibc-dev libc6-dev virtual-libc-dev" +RPROVIDES_${PN}-staticdev = "glibc-staticdev" +RPROVIDES_${PN}-doc = "glibc-doc" +RPROVIDES_eglibc-extra-nss = "glibc-extra-nss" +RPROVIDES_eglibc-thread-db = "glibc-thread-db" +RPROVIDES_${PN}-pcprofile = "glibc-pcprofile" +RPROVIDES_${PN}-dbg = "glibc-dbg" +libc_baselibs = "${base_libdir}/libcrypt*.so.* ${base_libdir}/libcrypt-*.so ${base_libdir}/libc.so.* ${base_libdir}/libc-*.so ${base_libdir}/libm*.so.* ${base_libdir}/libm-*.so ${base_libdir}/ld*.so.* ${base_libdir}/ld-*.so ${base_libdir}/libpthread*.so.* ${base_libdir}/libpthread-*.so ${base_libdir}/libresolv*.so.* ${base_libdir}/libresolv-*.so ${base_libdir}/librt*.so.* ${base_libdir}/librt-*.so ${base_libdir}/libutil*.so.* ${base_libdir}/libutil-*.so ${base_libdir}/libnsl*.so.* ${base_libdir}/libnsl-*.so ${base_libdir}/libnss_files*.so.* ${base_libdir}/libnss_files-*.so ${base_libdir}/libnss_compat*.so.* ${base_libdir}/libnss_compat-*.so ${base_libdir}/libnss_dns*.so.* ${base_libdir}/libnss_dns-*.so ${base_libdir}/libdl*.so.* ${base_libdir}/libdl-*.so ${base_libdir}/libanl*.so.* ${base_libdir}/libanl-*.so ${base_libdir}/libBrokenLocale*.so.* ${base_libdir}/libBrokenLocale-*.so" + +FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${@base_conditional('USE_LDCONFIG', '1', '${base_sbindir}/ldconfig ${sysconfdir}/ld.so.conf', '', d)}" +FILES_ldd = "${bindir}/ldd" +FILES_libsegfault = "${base_libdir}/libSegFault*" +FILES_libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*" +FILES_libmemusage = "${base_libdir}/libmemusage.so" +FILES_eglibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*" +FILES_sln = "/sbin/sln" +FILES_${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o" +FILES_libsotruss = "${libdir}/audit/sotruss-lib.so" +FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}" +FILES_${PN}-dev += "${bindir}/rpcgen ${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal" +FILES_${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a" +FILES_nscd = "${sbindir}/nscd*" +FILES_${PN}-mtrace = "${bindir}/mtrace" +FILES_${PN}-utils = "${bindir}/* ${sbindir}/*" +FILES_${PN}-dbg += "${libexecdir}/*/.debug ${libdir}/audit/.debug" +FILES_catchsegv = "${bindir}/catchsegv" +RDEPENDS_catchsegv = "libsegfault" +FILES_${PN}-pcprofile = "${base_libdir}/libpcprofile.so" +FILES_eglibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so" +RPROVIDES_${PN}-dev += "libc-dev" +RPROVIDES_${PN}-staticdev += "libc-staticdev" + +SUMMARY_sln = "The static ln" +DESCRIPTION_sln = "Similar to the 'ln' utility, but statically linked. sln is useful to make symbolic links to dynamic libraries if the dynamic linking system, for some reason, is not functional." +SUMMARY_nscd = "Name service cache daemon" +DESCRIPTION_nscd = "nscd, name service cache daemon, caches name service lookups for the passwd, group and hosts information. It can damatically improvide performance with remote, such as NIS or NIS+, name services." +SUMMARY_eglibc-extra-nss = "hesiod, NIS and NIS+ nss libraries" +DESCRIPTION_eglibc-extra-nss = "eglibc: nis, nisplus and hesiod search services." +SUMMARY_ldd = "print shared library dependencies" +DESCRIPTION_ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line." +SUMMARY_${PN}-utils = "Miscellaneous utilities provided by eglibc" +DESCRIPTION_${PN}-utils = "Miscellaneous utilities including getconf, iconf, locale, gencat, tzselect, zic, rpcinfo, ..." +DESCRIPTION_libsotruss = "Library to support sotruss which traces calls through PLTs" + +inherit libc-common multilib_header + +do_install_append () { + rm -f ${D}${sysconfdir}/localtime + rm -rf ${D}${localstatedir} + + # remove empty eglibc dir + if [ -d ${D}${libdir}/eglibc -a ! -e ${D}${libdir}/eglibc/pt_chown ]; then + rmdir ${D}${libdir}/eglibc + fi + oe_multilib_header bits/syscall.h + + if [ -f ${D}${bindir}/mtrace ]; then + sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace + fi + rm -rf ${D}${includedir}/rpcsvc/rquota* + # Info dir listing isn't interesting at this point so remove it if it exists. + if [ -e "${D}${infodir}/dir" ]; then + rm -f ${D}${infodir}/dir + fi + + if [ "${USE_LDCONFIG}" != "1" ]; then + # We won't ship this file (see FILES above) so let's not install it + rm -f ${D}${sysconfdir}/ld.so.conf + # This directory will be empty now so remove it too. + # But check whether it exists first, since it won't for eglibc-initial. + if [ -d ${D}${sysconfdir} ]; then + rmdir ${D}${sysconfdir} + fi + fi +} + +do_install_locale () { + dest=${D}/${includedir}/eglibc-locale-internal-${MULTIMACH_TARGET_SYS} + install -d ${dest}${base_libdir} ${dest}${bindir} ${dest}${libdir} ${dest}${datadir} + if [ "${base_libdir}" != "${libdir}" ]; then + cp -fpPR ${D}${base_libdir}/* ${dest}${base_libdir} + fi + if [ -e ${D}${bindir}/localedef ]; then + mv -f ${D}${bindir}/localedef ${dest}${bindir} + fi + if [ -e ${D}${libdir}/gconv ]; then + mv -f ${D}${libdir}/gconv ${dest}${libdir} + fi + if [ -e ${D}${exec_prefix}/lib ]; then + cp -fpPR ${D}${exec_prefix}/lib ${dest}${exec_prefix} + fi + if [ -e ${D}${datadir}/i18n ]; then + mv ${D}${datadir}/i18n ${dest}${datadir} + fi + cp -fpPR ${D}${datadir}/* ${dest}${datadir} + rm -rf ${D}${datadir}/locale/ + cp -fpPR ${WORKDIR}/SUPPORTED ${dest} +} + +addtask do_install_locale after do_install before do_populate_sysroot do_package + +bashscripts = "mtrace sotruss xtrace" + +do_evacuate_scripts () { + target=${D}${includedir}/eglibc-scripts-internal-${MULTIMACH_TARGET_SYS} + mkdir -p $target + for i in ${bashscripts}; do + if [ -f ${D}${bindir}/$i ]; then + cp ${D}${bindir}/$i $target/ + fi + done +} + +addtask evacuate_scripts after do_install before do_populate_sysroot do_package + +PACKAGE_PREPROCESS_FUNCS += "eglibc_package_preprocess" + +eglibc_package_preprocess () { + rm -rf ${PKGD}/${includedir}/eglibc-locale-internal-${MULTIMACH_TARGET_SYS} + rm -rf ${PKGD}/${includedir}/eglibc-scripts-internal-${MULTIMACH_TARGET_SYS} + for i in ${bashscripts}; do + rm -f ${PKGD}${bindir}/$i + done + rm -rf ${PKGD}/${localedir} + if [ "${libdir}" != "${exec_prefix}/lib" ]; then + # This dir only exists to hold locales + rm -rf ${PKGD}${exec_prefix}/lib + fi +} diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-scripts.inc b/meta-aspeed/recipes-core/eglibc/eglibc-scripts.inc new file mode 100644 index 0000000..9ca6673 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-scripts.inc @@ -0,0 +1,16 @@ +include eglibc-collateral.inc + +SUMMARY = "utility scripts provided by eglibc" +DESCRIPTION = "utility scripts provided by eglibc" +RDEPENDS_${PN} = "bash eglibc-mtrace" + +SRC = "${STAGING_INCDIR}/eglibc-scripts-internal-${MULTIMACH_TARGET_SYS}" + +bashscripts = "sotruss xtrace" + +do_install() { + install -d -m 0755 ${D}${bindir} + for i in ${bashscripts}; do + install -m 0755 ${SRC}/$i ${D}${bindir}/ + done +} diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-scripts_2.19.bb b/meta-aspeed/recipes-core/eglibc/eglibc-scripts_2.19.bb new file mode 100644 index 0000000..3113362 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-scripts_2.19.bb @@ -0,0 +1 @@ +require eglibc-scripts.inc diff --git a/meta-aspeed/recipes-core/eglibc/eglibc-testing.inc b/meta-aspeed/recipes-core/eglibc/eglibc-testing.inc new file mode 100644 index 0000000..ab3ec15 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc-testing.inc @@ -0,0 +1,79 @@ +do_compile_append () { + # now generate script to drive testing + echo "#!/usr/bin/env sh" >${B}/${HOST_PREFIX}testeglibc + set >> ${B}/${HOST_PREFIX}testeglibc + # prune out the unneeded vars + sed -i -e "/^BASH/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^USER/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^OPT/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^DIRSTACK/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^EUID/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^FUNCNAME/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^GROUPS/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^HOST/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^HOME/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^IFS/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^LC_ALL/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^LOGNAME/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^MACHTYPE/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^OSTYPE/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^PIPE/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^SHELL/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^'/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^UID/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^TERM/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^PATCH_GET/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^PKG_/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^POSIXLY_/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^PPID/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^PS4/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^Q/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^SHLVL/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^STAGING/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${HOST_PREFIX}testeglibc + sed -i -e "/^PSEUDO/d" ${B}/${HOST_PREFIX}testeglibc + + # point to real sysroot not the toolchain bootstrap sysroot + sed -i -e "s/\-tcbootstrap//g" ${B}/${HOST_PREFIX}testeglibc + + # use the final cross-gcc to test since some tests need libstdc++ + sed -i -e "s/^PATH=.*\.gcc-cross-initial\:/PATH=/g" ${B}/${HOST_PREFIX}testeglibc + + # append execution part script +cat >> ${B}/${HOST_PREFIX}testeglibc << STOP +target="\$1" +if [ "x\$target" = "x" ] +then + echo "Please specify the target machine and remote user in form of user@target" + exit 1; +fi +ssh \$target ls \$PWD\ 2>&1 > /dev/null +if [ "x\$?" != "x0" ] +then + echo "Failed connecting to \$target it could be because of:" + echo "1. You dont have passwordless ssh setup to access \$target" + echo "2. NFS share on \$target is not mounted or if mounted then not matching the build tree layout." + echo " The tree should be accessible at same location on build host and target" + echo " You can add nfs-server to IMAGE_FEATURES to get the nfs client on target" + echo "3. nfs server on build host is not running." + echo " Please make sure that you have 'no_root_squash' added in /etc/exports if you want" + echo " to test as root user on target (usually its recommended to create a non" + echo " root user." + echo " As a sanity check make sure that target can read/write to the eglibc build tree" + echo " Please refer to ${S}/EGLIBC.cross-testing for further instructions on setup" + exit 1 +fi + echo "# we test using cross compiler from real sysroot therefore override the" > ${B}/configparms + echo "# definitions that come from ${B}/config.make" >> ${B}/configparms + + fgrep tcbootstrap ${B}/config.make > ${B}/configparms + sed -i -e "s/\-tcbootstrap//g" ${B}/configparms +wrapper="${S}/scripts/cross-test-ssh.sh \$target" +localedef="${STAGING_BINDIR_NATIVE}/cross-localedef --little-endian --uint32-align=4" +make tests-clean +make cross-localedef="\$localedef" cross-test-wrapper="\$wrapper" -k check +rm -rf ${B}/configparms +STOP + + chmod +x ${B}/${HOST_PREFIX}testeglibc +} diff --git a/meta-aspeed/recipes-core/eglibc/eglibc.inc b/meta-aspeed/recipes-core/eglibc/eglibc.inc new file mode 100644 index 0000000..c0b2494 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc.inc @@ -0,0 +1,84 @@ +require eglibc-common.inc +require eglibc-ld.inc +require eglibc-testing.inc + +STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}" +STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${TARGET_ARCH}" +PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:" + +TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TCBOOTSTRAP}" + +# eglibc can't be built without optimization, if someone tries to compile an +# entire image as -O0, we override it with -O2 here and give a note about it. +def get_optimization(d): + selected_optimization = d.getVar("SELECTED_OPTIMIZATION", True) + if base_contains("SELECTED_OPTIMIZATION", "-O0", "x", "", d) == "x": + bb.note("eglibc can't be built with -O0, -O2 will be used instead.") + return selected_optimization.replace("-O0", "-O2") + return selected_optimization + +SELECTED_OPTIMIZATION := "${@get_optimization(d)}" + +# siteconfig.bbclass runs configure which needs a working compiler +# For the compiler to work we need a working libc yet libc isn't +# in the sysroots directory at this point. This means the libc.so +# linker script won't work as the --sysroot setting isn't correct. +# Here we create a hacked up libc linker script and pass in the right +# flags to let configure work. Ugly. +EXTRASITECONFIG = "CFLAGS='${CFLAGS} -Wl,-L${WORKDIR}/site_config_libc -L${WORKDIR}/site_config_libc -L${SYSROOT_DESTDIR}${libdir} -L${SYSROOT_DESTDIR}${base_libdir} -Wl,-L${SYSROOT_DESTDIR}${libdir} -Wl,-L${SYSROOT_DESTDIR}${base_libdir}'" +siteconfig_do_siteconfig_gencache_prepend = " \ + mkdir -p ${WORKDIR}/site_config_libc; \ + cp ${SYSROOT_DESTDIR}${libdir}/libc.so ${WORKDIR}/site_config_libc; \ + sed -i -e 's# ${base_libdir}# ${SYSROOT_DESTDIR}${base_libdir}#g' -e 's# ${libdir}# ${SYSROOT_DESTDIR}${libdir}#g' ${WORKDIR}/site_config_libc/libc.so; \ +" + +# nptl needs unwind support in gcc, which can't be built without glibc. +DEPENDS = "virtual/${TARGET_PREFIX}gcc-initial libgcc-initial linux-libc-headers virtual/${TARGET_PREFIX}libc-initial" +# nptl needs libgcc but dlopens it, so our shlibs code doesn't detect this +#RDEPENDS_${PN} += "${@['','libgcc']['nptl' in '${GLIBC_ADDONS}']}" +PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc" +PROVIDES += "virtual/libintl virtual/libiconv" +inherit autotools +require eglibc-options.inc + +LEAD_SONAME = "libc.so" + +CACHED_CONFIGUREVARS += "ac_cv_path_KSH=${base_bindir}/bash \ + ac_cv_path_BASH_SHELL=${base_bindir}/bash \ + libc_cv_localedir=${localedir} \ + libc_cv_ssp=no \ + " + +GLIBC_EXTRA_OECONF ?= "" +GLIBC_EXTRA_OECONF_class-nativesdk = "" +INHIBIT_DEFAULT_DEPS = "1" + +ARM_INSTRUCTION_SET = "arm" + +# eglibc uses PARALLELMFLAGS variable to pass parallel build info so transfer +# PARALLEL_MAKE into PARALLELMFLAGS and empty out PARALLEL_MAKE +EGLIBCPARALLELISM := "PARALLELMFLAGS="${PARALLEL_MAKE}"" +EXTRA_OEMAKE[vardepsexclude] += "EGLIBCPARALLELISM" +EXTRA_OEMAKE += "${EGLIBCPARALLELISM}" +PARALLEL_MAKE = "" + +# eglibc make-syscalls.sh has a number of issues with /bin/dash and +# it's output which make calls via the SHELL also has issues, so +# ensure make uses /bin/bash +EXTRA_OEMAKE += "SHELL=/bin/bash" + +OE_FEATURES = "${@features_to_eglibc_settings(d)}" +do_configure_prepend() { + sed -e "s#@BASH@#/bin/sh#" -i ${S}/elf/ldd.bash.in + echo '${OE_FEATURES}' > ${B}/option-groups.config +} + +do_configure_append() { + oe_runmake config + + # Remove quotation marks from OPTION_EGLIBC_NSSWITCH_FIXED_*. This will + # avoid install error. + sed -i 's/^OPTION_EGLIBC_NSSWITCH_FIXED_\(.*\)="\(.*\)"$/OPTION_EGLIBC_NSSWITCH_FIXED_\1=\2/' option-groups.config +} + +GLIBC_ADDONS ?= "ports,nptl,libidn" diff --git a/meta-aspeed/recipes-core/eglibc/eglibc_2.19.bb b/meta-aspeed/recipes-core/eglibc/eglibc_2.19.bb new file mode 100644 index 0000000..c65e6a5 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/eglibc_2.19.bb @@ -0,0 +1,147 @@ +require eglibc.inc + +DEPENDS += "gperf-native kconfig-frontends-native" + +SRC_URI = "http://downloads.yoctoproject.org/releases/eglibc/eglibc-${PV}-svnr25243.tar.bz2 \ + file://eglibc-svn-arm-lowlevellock-include-tls.patch \ + file://IO-acquire-lock-fix.patch \ + file://mips-rld-map-check.patch \ + file://etc/ld.so.conf \ + file://generate-supported.mk \ + file://glibc.fix_sqrt2.patch \ + file://multilib_readlib.patch \ + file://ppc-sqrt_finite.patch \ + file://GLRO_dl_debug_mask.patch \ + file://initgroups_keys.patch \ + file://eglibc_fix_findidx_parameters.patch \ + file://ppc_slow_ieee754_sqrt.patch \ + file://fileops-without-wchar-io.patch \ + file://add_resource_h_to_wait_h.patch \ + file://0001-eglibc-menuconfig-support.patch \ + file://0002-eglibc-menuconfig-hex-string-options.patch \ + file://0003-eglibc-menuconfig-build-instructions.patch \ + file://fsl-ppc-no-fsqrt.patch \ + file://0001-R_ARM_TLS_DTPOFF32.patch \ + file://0001-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch \ + file://fix-tibetian-locales.patch \ + file://ppce6500-32b_slow_ieee754_sqrt.patch \ + file://grok_gold.patch \ + " +SRC_URI[md5sum] = "197836c2ba42fb146e971222647198dd" +SRC_URI[sha256sum] = "baaa030531fc308f7820c46acdf8e1b2f8e3c1f40bcd28b6e440d1c95d170d4c" + +LIC_FILES_CHKSUM = "file://LICENSES;md5=e9a558e243b36d3209f380deb394b213 \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" + +SRC_URI_append_class-nativesdk = " file://ld-search-order.patch \ + file://relocatable_sdk.patch \ + file://relocatable_sdk_fix_openpath.patch \ + " +S = "${WORKDIR}/eglibc-${PV}/libc" +B = "${WORKDIR}/build-${TARGET_SYS}" + +PACKAGES_DYNAMIC = "" + +# the -isystem in bitbake.conf screws up glibc do_stage +BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}" +TARGET_CPPFLAGS = "-I${STAGING_DIR_TARGET}${includedir}" + +GLIBC_BROKEN_LOCALES = " _ER _ET so_ET yn_ER sid_ET tr_TR mn_MN gez_ET gez_ER bn_BD te_IN es_CR.ISO-8859-1" + +FILESPATH = "${@base_set_filespath([ '${FILE_DIRNAME}/eglibc-${PV}', '${FILE_DIRNAME}/eglibc', '${FILE_DIRNAME}/files', '${FILE_DIRNAME}' ], d)}" + +# +# For now, we will skip building of a gcc package if it is a uclibc one +# and our build is not a uclibc one, and we skip a glibc one if our build +# is a uclibc build. +# +# See the note in gcc/gcc_3.4.0.oe +# + +python __anonymous () { + import re + uc_os = (re.match('.*uclibc$', d.getVar('TARGET_OS', True)) != None) + if uc_os: + raise bb.parse.SkipPackage("incompatible with target %s" % + d.getVar('TARGET_OS', True)) +} + +export libc_cv_slibdir = "${base_libdir}" + +EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \ + --without-cvs --disable-profile \ + --disable-debug --without-gd \ + --enable-clocale=gnu \ + --enable-add-ons \ + --with-headers=${STAGING_INCDIR} \ + --without-selinux \ + --enable-obsolete-rpc \ + --with-kconfig=${STAGING_BINDIR_NATIVE} \ + ${GLIBC_EXTRA_OECONF}" + +EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}" + +do_patch_append() { + bb.build.exec_func('do_fix_readlib_c', d) +} + +# for mips eglibc now builds syscall tables for all abi's +# so we make sure that we choose right march option which is +# compatible with o32,n32 and n64 abi's +# e.g. -march=mips32 is not compatible with n32 and n64 therefore +# we filter it out in such case -march=from-abi which will be +# mips1 when using o32 and mips3 when using n32/n64 + +TUNE_CCARGS_mips := "${@oe_filter_out('-march=mips32', '${TUNE_CCARGS}', d)}" +TUNE_CCARGS_mipsel := "${@oe_filter_out('-march=mips32', '${TUNE_CCARGS}', d)}" + +do_fix_readlib_c () { + sed -i -e 's#OECORE_KNOWN_INTERPRETER_NAMES#${EGLIBC_KNOWN_INTERPRETER_NAMES}#' ${S}/elf/readlib.c +} + +do_configure () { +# override this function to avoid the autoconf/automake/aclocal/autoheader +# calls for now +# don't pass CPPFLAGS into configure, since it upsets the kernel-headers +# version check and doesn't really help with anything + if [ -z "`which rpcgen`" ]; then + echo "rpcgen not found. Install glibc-devel." + exit 1 + fi + (cd ${S} && gnu-configize) || die "failure in running gnu-configize" + find ${S} -name "configure" | xargs touch + CPPFLAGS="" oe_runconf +} + +rpcsvc = "bootparam_prot.x nlm_prot.x rstat.x \ + yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \ + rusers.x spray.x nfs_prot.x rquota.x key_prot.x" + +do_compile () { + # -Wl,-rpath-link <staging>/lib in LDFLAGS can cause breakage if another glibc is in staging + unset LDFLAGS + base_do_compile + ( + cd ${S}/sunrpc/rpcsvc + for r in ${rpcsvc}; do + h=`echo $r|sed -e's,\.x$,.h,'` + rpcgen -h $r -o $h || bbwarn "unable to generate header for $r" + done + ) + echo "Adjust ldd script" + if [ -n "${RTLDLIST}" ] + then + prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed 's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'` + if [ "${prevrtld}" != "${RTLDLIST}" ] + then + sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${prevrtld} ${RTLDLIST}\"#" + fi + fi + +} + +require eglibc-package.inc + +BBCLASSEXTEND = "nativesdk" diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch new file mode 100644 index 0000000..cdfeaea --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch @@ -0,0 +1,331 @@ +Upstream-Status: Inappropriate [embedded specific] + +We run the ldconfig in the cross fashion. make the code bitsize aware so that +we can cross build ldconfig cache for various architectures. + +Richard Purdie <richard.purdie@linuxfoundation.org> 2009/05/19 +Nitin A Kamble <nitin.a.kamble@intel.com> 2009/03/29 + +Index: ldconfig-native-2.12.1/readelflib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readelflib.c ++++ ldconfig-native-2.12.1/readelflib.c +@@ -40,39 +40,212 @@ do \ + + /* Returns 0 if everything is ok, != 0 in case of error. */ + int +-process_elf_file (const char *file_name, const char *lib, int *flag, ++process_elf_file32 (const char *file_name, const char *lib, int *flag, + unsigned int *osversion, char **soname, void *file_contents, + size_t file_length) + { + int i; + unsigned int j; +- ElfW(Addr) loadaddr; ++ Elf32_Addr loadaddr; + unsigned int dynamic_addr; + size_t dynamic_size; + char *program_interpreter; + +- ElfW(Ehdr) *elf_header; +- ElfW(Phdr) *elf_pheader, *segment; +- ElfW(Dyn) *dynamic_segment, *dyn_entry; ++ Elf32_Ehdr *elf_header; ++ Elf32_Phdr *elf_pheader, *segment; ++ Elf32_Dyn *dynamic_segment, *dyn_entry; + char *dynamic_strings; + +- elf_header = (ElfW(Ehdr) *) file_contents; ++ elf_header = (Elf32_Ehdr *) file_contents; + *osversion = 0; + +- if (elf_header->e_ident [EI_CLASS] != ElfW (CLASS)) ++ if (elf_header->e_type != ET_DYN) + { +- if (opt_verbose) ++ error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, ++ elf_header->e_type); ++ return 1; ++ } ++ ++ /* Get information from elf program header. */ ++ elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents); ++ check_ptr (elf_pheader); ++ ++ /* The library is an elf library, now search for soname and ++ libc5/libc6. */ ++ *flag = FLAG_ELF; ++ ++ loadaddr = -1; ++ dynamic_addr = 0; ++ dynamic_size = 0; ++ program_interpreter = NULL; ++ for (i = 0, segment = elf_pheader; ++ i < elf_header->e_phnum; i++, segment++) ++ { ++ check_ptr (segment); ++ ++ switch (segment->p_type) + { +- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) +- error (0, 0, _("%s is a 32 bit ELF file.\n"), file_name); +- else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64) +- error (0, 0, _("%s is a 64 bit ELF file.\n"), file_name); +- else +- error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name); ++ case PT_LOAD: ++ if (loadaddr == (Elf32_Addr) -1) ++ loadaddr = segment->p_vaddr - segment->p_offset; ++ break; ++ ++ case PT_DYNAMIC: ++ if (dynamic_addr) ++ error (0, 0, _("more than one dynamic segment\n")); ++ ++ dynamic_addr = segment->p_offset; ++ dynamic_size = segment->p_filesz; ++ break; ++ ++ case PT_INTERP: ++ program_interpreter = (char *) (file_contents + segment->p_offset); ++ check_ptr (program_interpreter); ++ ++ /* Check if this is enough to classify the binary. */ ++ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]); ++ ++j) ++ if (strcmp (program_interpreter, interpreters[j].soname) == 0) ++ { ++ *flag = interpreters[j].flag; ++ break; ++ } ++ break; ++ ++ case PT_NOTE: ++ if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) ++ { ++ Elf32_Word *abi_note = (Elf32_Word *) (file_contents ++ + segment->p_offset); ++ Elf32_Addr size = segment->p_filesz; ++ ++ while (abi_note [0] != 4 || abi_note [1] != 16 ++ || abi_note [2] != 1 ++ || memcmp (abi_note + 3, "GNU", 4) != 0) ++ { ++#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word))) ++ Elf32_Addr) note_size = 3 * sizeof (Elf32_Word)) ++ + ROUND (abi_note[0]) ++ + ROUND (abi_note[1]); ++ ++ if (size - 32 < note_size || note_size == 0) ++ { ++ size = 0; ++ break; ++ } ++ size -= note_size; ++ abi_note = (void *) abi_note + note_size; ++ } ++ ++ if (size == 0) ++ break; ++ ++ *osversion = (abi_note [4] << 24) | ++ ((abi_note [5] & 0xff) << 16) | ++ ((abi_note [6] & 0xff) << 8) | ++ (abi_note [7] & 0xff); ++ } ++ break; ++ ++ default: ++ break; ++ } ++ ++ } ++ if (loadaddr == (Elf32_Addr) -1) ++ { ++ /* Very strange. */ ++ loadaddr = 0; ++ } ++ ++ /* Now we can read the dynamic sections. */ ++ if (dynamic_size == 0) ++ return 1; ++ ++ dynamic_segment = (Elf32_Dyn *) (file_contents + dynamic_addr); ++ check_ptr (dynamic_segment); ++ ++ /* Find the string table. */ ++ dynamic_strings = NULL; ++ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ ++dyn_entry) ++ { ++ check_ptr (dyn_entry); ++ if (dyn_entry->d_tag == DT_STRTAB) ++ { ++ dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); ++ check_ptr (dynamic_strings); ++ break; + } +- return 1; + } + ++ if (dynamic_strings == NULL) ++ return 1; ++ ++ /* Now read the DT_NEEDED and DT_SONAME entries. */ ++ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ ++dyn_entry) ++ { ++ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) ++ { ++ char *name = dynamic_strings + dyn_entry->d_un.d_val; ++ check_ptr (name); ++ ++ if (dyn_entry->d_tag == DT_NEEDED) ++ { ++ ++ if (*flag == FLAG_ELF) ++ { ++ /* Check if this is enough to classify the binary. */ ++ for (j = 0; ++ j < sizeof (known_libs) / sizeof (known_libs [0]); ++ ++j) ++ if (strcmp (name, known_libs [j].soname) == 0) ++ { ++ *flag = known_libs [j].flag; ++ break; ++ } ++ } ++ } ++ ++ else if (dyn_entry->d_tag == DT_SONAME) ++ *soname = xstrdup (name); ++ ++ /* Do we have everything we need? */ ++ if (*soname && *flag != FLAG_ELF) ++ return 0; ++ } ++ } ++ ++ /* We reach this point only if the file doesn't contain a DT_SONAME ++ or if we can't classify the library. If it doesn't have a ++ soname, return the name of the library. */ ++ if (*soname == NULL) ++ *soname = xstrdup (lib); ++ ++ return 0; ++} ++ ++int ++process_elf_file64 (const char *file_name, const char *lib, int *flag, ++ unsigned int *osversion, char **soname, void *file_contents, ++ size_t file_length) ++{ ++ int i; ++ unsigned int j; ++ Elf64_Addr loadaddr; ++ unsigned int dynamic_addr; ++ size_t dynamic_size; ++ char *program_interpreter; ++ ++ Elf64_Ehdr *elf_header; ++ Elf64_Phdr *elf_pheader, *segment; ++ Elf64_Dyn *dynamic_segment, *dyn_entry; ++ char *dynamic_strings; ++ ++ elf_header = (Elf64_Ehdr *) file_contents; ++ *osversion = 0; ++ + if (elf_header->e_type != ET_DYN) + { + error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, +@@ -81,7 +254,7 @@ process_elf_file (const char *file_name, + } + + /* Get information from elf program header. */ +- elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents); ++ elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents); + check_ptr (elf_pheader); + + /* The library is an elf library, now search for soname and +@@ -100,7 +273,7 @@ process_elf_file (const char *file_name, + switch (segment->p_type) + { + case PT_LOAD: +- if (loadaddr == (ElfW(Addr)) -1) ++ if (loadaddr == (Elf64_Addr) -1) + loadaddr = segment->p_vaddr - segment->p_offset; + break; + +@@ -129,16 +302,16 @@ process_elf_file (const char *file_name, + case PT_NOTE: + if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) + { +- ElfW(Word) *abi_note = (ElfW(Word) *) (file_contents ++ Elf64_Word *abi_note = (Elf64_Word *) (file_contents + + segment->p_offset); +- ElfW(Addr) size = segment->p_filesz; ++ Elf64_Addr size = segment->p_filesz; + + while (abi_note [0] != 4 || abi_note [1] != 16 + || abi_note [2] != 1 + || memcmp (abi_note + 3, "GNU", 4) != 0) + { +-#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word))) +- ElfW(Addr) note_size = 3 * sizeof (ElfW(Word)) ++#define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word)) ++ Elf64_Addr note_size = 3 * sizeof (Elf64_Word) + + ROUND (abi_note[0]) + + ROUND (abi_note[1]); + +@@ -166,7 +339,7 @@ process_elf_file (const char *file_name, + } + + } +- if (loadaddr == (ElfW(Addr)) -1) ++ if (loadaddr == (Elf64_Addr) -1) + { + /* Very strange. */ + loadaddr = 0; +@@ -176,7 +349,7 @@ process_elf_file (const char *file_name, + if (dynamic_size == 0) + return 1; + +- dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr); ++ dynamic_segment = (Elf64_Dyn *) (file_contents + dynamic_addr); + check_ptr (dynamic_segment); + + /* Find the string table. */ +@@ -233,3 +406,33 @@ process_elf_file (const char *file_name, + + return 0; + } ++/* Returns 0 if everything is ok, != 0 in case of error. */ ++int ++process_elf_file (const char *file_name, const char *lib, int *flag, ++ unsigned int *osversion, char **soname, void *file_contents, ++ size_t file_length) ++{ ++ int i; ++ unsigned int j; ++ ElfW(Addr) loadaddr; ++ unsigned int dynamic_addr; ++ size_t dynamic_size; ++ char *program_interpreter; ++ ++ ElfW(Ehdr) *elf_header; ++ ElfW(Phdr) *elf_pheader, *segment; ++ ElfW(Dyn) *dynamic_segment, *dyn_entry; ++ char *dynamic_strings; ++ ++ elf_header = (ElfW(Ehdr) *) file_contents; ++ *osversion = 0; ++ ++ if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) ++ return process_elf_file32(file_name, lib,flag, osversion, soname, file_contents, file_length); ++ else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64) ++ return process_elf_file64(file_name, lib,flag, osversion, soname, file_contents, file_length); ++ error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name); ++ return 1; ++} ++ ++ diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/README b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/README new file mode 100644 index 0000000..43fb983 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/README @@ -0,0 +1,8 @@ +The files are pulled verbatim from glibc 2.5 and then patched to allow +standalone compilation of ldconfig. + +Richard Purdie +OpenedHand Ltd. + +Upgraded the ldconfig recipe to eglibc 2.12.1 +Nitin A Kamble <nitin.a.kamble@intel.com> 2011/03/29 diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch new file mode 100644 index 0000000..7f8e4db --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch @@ -0,0 +1,454 @@ +Upstream-Status: Inappropriate [embedded specific] + +Do data input/output handling according to endien-ness of the library file. That +enables use of ldconfig in the cross fashion for any architecture. + +2011/04/04 +Richard Purdie <richard.purdie@linuxfoundation.org> +Nitin Kamble <nitin.a.kamble@intel.com> + +Index: ldconfig-native-2.12.1/readelflib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readelflib.c ++++ ldconfig-native-2.12.1/readelflib.c +@@ -38,6 +38,28 @@ do \ + } \ + while (0); + ++int be; ++static uint16_t read16(uint16_t x, int be) ++{ ++ if (be) ++ return be16toh(x); ++ return le16toh(x); ++} ++ ++static uint32_t read32(uint32_t x, int be) ++{ ++ if (be) ++ return be32toh(x); ++ return le32toh(x); ++} ++ ++static uint64_t read64(uint64_t x, int be) ++{ ++ if (be) ++ return be64toh(x); ++ return le64toh(x); ++} ++ + /* Returns 0 if everything is ok, != 0 in case of error. */ + int + process_elf_file32 (const char *file_name, const char *lib, int *flag, +@@ -59,15 +81,17 @@ process_elf_file32 (const char *file_nam + elf_header = (Elf32_Ehdr *) file_contents; + *osversion = 0; + +- if (elf_header->e_type != ET_DYN) ++ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB); ++ ++ if (read16(elf_header->e_type, be) != ET_DYN) + { + error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, +- elf_header->e_type); ++ read16(elf_header->e_type, be)); + return 1; + } + + /* Get information from elf program header. */ +- elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents); ++ elf_pheader = (Elf32_Phdr *) (read32(elf_header->e_phoff, be) + file_contents); + check_ptr (elf_pheader); + + /* The library is an elf library, now search for soname and +@@ -79,27 +103,27 @@ process_elf_file32 (const char *file_nam + dynamic_size = 0; + program_interpreter = NULL; + for (i = 0, segment = elf_pheader; +- i < elf_header->e_phnum; i++, segment++) ++ i < read16(elf_header->e_phnum, be); i++, segment++) + { + check_ptr (segment); + +- switch (segment->p_type) ++ switch (read32(segment->p_type, be)) + { + case PT_LOAD: + if (loadaddr == (Elf32_Addr) -1) +- loadaddr = segment->p_vaddr - segment->p_offset; ++ loadaddr = read32(segment->p_vaddr, be) - read32(segment->p_offset, be); + break; + + case PT_DYNAMIC: + if (dynamic_addr) + error (0, 0, _("more than one dynamic segment\n")); + +- dynamic_addr = segment->p_offset; +- dynamic_size = segment->p_filesz; ++ dynamic_addr = read32(segment->p_offset, be); ++ dynamic_size = read32(segment->p_filesz, be); + break; + + case PT_INTERP: +- program_interpreter = (char *) (file_contents + segment->p_offset); ++ program_interpreter = (char *) (file_contents + read32(segment->p_offset, be)); + check_ptr (program_interpreter); + + /* Check if this is enough to classify the binary. */ +@@ -113,20 +137,20 @@ process_elf_file32 (const char *file_nam + break; + + case PT_NOTE: +- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) ++ if (!*osversion && read32(segment->p_filesz, be) >= 32 && segment->p_align >= 4) + { + Elf32_Word *abi_note = (Elf32_Word *) (file_contents +- + segment->p_offset); +- Elf32_Addr size = segment->p_filesz; ++ + read32(segment->p_offset, be)); ++ Elf32_Addr size = read32(segment->p_filesz, be); + +- while (abi_note [0] != 4 || abi_note [1] != 16 +- || abi_note [2] != 1 ++ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16 ++ || read32(abi_note [2], be) != 1 + || memcmp (abi_note + 3, "GNU", 4) != 0) + { +-#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word))) +- Elf32_Addr) note_size = 3 * sizeof (Elf32_Word)) +- + ROUND (abi_note[0]) +- + ROUND (abi_note[1]); ++#define ROUND(len) (((len) + sizeof (Elf32_Word) - 1) & -sizeof (Elf32_Word)) ++ Elf32_Addr note_size = 3 * sizeof (Elf32_Word) ++ + ROUND (read32(abi_note[0], be)) ++ + ROUND (read32(abi_note[1], be)); + + if (size - 32 < note_size || note_size == 0) + { +@@ -140,10 +164,10 @@ process_elf_file32 (const char *file_nam + if (size == 0) + break; + +- *osversion = (abi_note [4] << 24) | +- ((abi_note [5] & 0xff) << 16) | +- ((abi_note [6] & 0xff) << 8) | +- (abi_note [7] & 0xff); ++ *osversion = (read32(abi_note [4], be) << 24) | ++ ((read32(abi_note [5], be) & 0xff) << 16) | ++ ((read32(abi_note [6], be) & 0xff) << 8) | ++ (read32(abi_note [7], be) & 0xff); + } + break; + +@@ -167,13 +191,13 @@ process_elf_file32 (const char *file_nam + + /* Find the string table. */ + dynamic_strings = NULL; +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { + check_ptr (dyn_entry); +- if (dyn_entry->d_tag == DT_STRTAB) ++ if (read32(dyn_entry->d_tag, be) == DT_STRTAB) + { +- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); ++ dynamic_strings = (char *) (file_contents + read32(dyn_entry->d_un.d_val, be) - loadaddr); + check_ptr (dynamic_strings); + break; + } +@@ -183,15 +207,15 @@ process_elf_file32 (const char *file_nam + return 1; + + /* Now read the DT_NEEDED and DT_SONAME entries. */ +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { +- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) ++ if (read32(dyn_entry->d_tag, be) == DT_NEEDED || read32(dyn_entry->d_tag, be) == DT_SONAME) + { +- char *name = dynamic_strings + dyn_entry->d_un.d_val; ++ char *name = dynamic_strings + read32(dyn_entry->d_un.d_val, be); + check_ptr (name); + +- if (dyn_entry->d_tag == DT_NEEDED) ++ if (read32(dyn_entry->d_tag, be) == DT_NEEDED) + { + + if (*flag == FLAG_ELF) +@@ -208,7 +232,7 @@ process_elf_file32 (const char *file_nam + } + } + +- else if (dyn_entry->d_tag == DT_SONAME) ++ else if (read32(dyn_entry->d_tag, be) == DT_SONAME) + *soname = xstrdup (name); + + /* Do we have everything we need? */ +@@ -246,15 +270,17 @@ process_elf_file64 (const char *file_nam + elf_header = (Elf64_Ehdr *) file_contents; + *osversion = 0; + +- if (elf_header->e_type != ET_DYN) ++ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB); ++ ++ if (read16(elf_header->e_type, be) != ET_DYN) + { + error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name, +- elf_header->e_type); ++ read16(elf_header->e_type, be)); + return 1; + } + + /* Get information from elf program header. */ +- elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents); ++ elf_pheader = (Elf64_Phdr *) (read64(elf_header->e_phoff, be) + file_contents); + check_ptr (elf_pheader); + + /* The library is an elf library, now search for soname and +@@ -266,27 +292,27 @@ process_elf_file64 (const char *file_nam + dynamic_size = 0; + program_interpreter = NULL; + for (i = 0, segment = elf_pheader; +- i < elf_header->e_phnum; i++, segment++) ++ i < read16(elf_header->e_phnum, be); i++, segment++) + { + check_ptr (segment); + +- switch (segment->p_type) ++ switch (read32(segment->p_type, be)) + { + case PT_LOAD: + if (loadaddr == (Elf64_Addr) -1) +- loadaddr = segment->p_vaddr - segment->p_offset; ++ loadaddr = read64(segment->p_vaddr, be) - read64(segment->p_offset, be); + break; + + case PT_DYNAMIC: + if (dynamic_addr) + error (0, 0, _("more than one dynamic segment\n")); + +- dynamic_addr = segment->p_offset; +- dynamic_size = segment->p_filesz; ++ dynamic_addr = read64(segment->p_offset, be); ++ dynamic_size = read32(segment->p_filesz, be); + break; + + case PT_INTERP: +- program_interpreter = (char *) (file_contents + segment->p_offset); ++ program_interpreter = (char *) (file_contents + read64(segment->p_offset, be)); + check_ptr (program_interpreter); + + /* Check if this is enough to classify the binary. */ +@@ -300,20 +326,21 @@ process_elf_file64 (const char *file_nam + break; + + case PT_NOTE: +- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4) ++ if (!*osversion && read32(segment->p_filesz, be) >= 32 && read32(segment->p_align, be) >= 4) + { + Elf64_Word *abi_note = (Elf64_Word *) (file_contents +- + segment->p_offset); +- Elf64_Addr size = segment->p_filesz; ++ + read64(segment->p_offset, be)); ++ Elf64_Addr size = read32(segment->p_filesz, be); + +- while (abi_note [0] != 4 || abi_note [1] != 16 +- || abi_note [2] != 1 ++ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16 ++ || read32(abi_note [2], be) != 1 + || memcmp (abi_note + 3, "GNU", 4) != 0) + { ++#undef ROUND + #define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word)) + Elf64_Addr note_size = 3 * sizeof (Elf64_Word) +- + ROUND (abi_note[0]) +- + ROUND (abi_note[1]); ++ + ROUND (read32(abi_note[0], be)) ++ + ROUND (read32(abi_note[1], be)); + + if (size - 32 < note_size || note_size == 0) + { +@@ -327,10 +354,10 @@ process_elf_file64 (const char *file_nam + if (size == 0) + break; + +- *osversion = (abi_note [4] << 24) | +- ((abi_note [5] & 0xff) << 16) | +- ((abi_note [6] & 0xff) << 8) | +- (abi_note [7] & 0xff); ++ *osversion = (read32(abi_note [4], be) << 24) | ++ ((read32(abi_note [5], be) & 0xff) << 16) | ++ ((read32(abi_note [6], be) & 0xff) << 8) | ++ (read32(abi_note [7], be) & 0xff); + } + break; + +@@ -354,13 +381,13 @@ process_elf_file64 (const char *file_nam + + /* Find the string table. */ + dynamic_strings = NULL; +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { + check_ptr (dyn_entry); +- if (dyn_entry->d_tag == DT_STRTAB) ++ if (read64(dyn_entry->d_tag, be) == DT_STRTAB) + { +- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); ++ dynamic_strings = (char *) (file_contents + read64(dyn_entry->d_un.d_val, be) - loadaddr); + check_ptr (dynamic_strings); + break; + } +@@ -370,15 +397,15 @@ process_elf_file64 (const char *file_nam + return 1; + + /* Now read the DT_NEEDED and DT_SONAME entries. */ +- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL; + ++dyn_entry) + { +- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) ++ if (read64(dyn_entry->d_tag, be) == DT_NEEDED || read64(dyn_entry->d_tag, be) == DT_SONAME) + { +- char *name = dynamic_strings + dyn_entry->d_un.d_val; ++ char *name = dynamic_strings + read64(dyn_entry->d_un.d_val, be); + check_ptr (name); + +- if (dyn_entry->d_tag == DT_NEEDED) ++ if (read64(dyn_entry->d_tag, be) == DT_NEEDED) + { + + if (*flag == FLAG_ELF) +@@ -395,7 +422,7 @@ process_elf_file64 (const char *file_nam + } + } + +- else if (dyn_entry->d_tag == DT_SONAME) ++ else if (read64(dyn_entry->d_tag, be) == DT_SONAME) + *soname = xstrdup (name); + + /* Do we have everything we need? */ +Index: ldconfig-native-2.12.1/readlib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readlib.c ++++ ldconfig-native-2.12.1/readlib.c +@@ -169,7 +169,8 @@ process_file (const char *real_file_name + ret = 1; + } + /* Libraries have to be shared object files. */ +- else if (elf_header->e_type != ET_DYN) ++ else if ((elf_header->e_ident[EI_DATA] == ELFDATA2MSB && be16toh(elf_header->e_type) != ET_DYN) || ++ (elf_header->e_ident[EI_DATA] == ELFDATA2LSB && le16toh(elf_header->e_type) != ET_DYN)) + ret = 1; + else if (process_elf_file (file_name, lib, flag, osversion, soname, + file_contents, statbuf.st_size)) +Index: ldconfig-native-2.12.1/cache.c +=================================================================== +--- ldconfig-native-2.12.1.orig/cache.c ++++ ldconfig-native-2.12.1/cache.c +@@ -39,6 +39,29 @@ + # define N_(msgid) msgid + #define _(msg) msg + ++extern int be; ++ ++static uint16_t write16(uint16_t x, int be) ++{ ++ if (be) ++ return htobe16(x); ++ return htole16(x); ++} ++ ++static uint32_t write32(uint32_t x, int be) ++{ ++ if (be) ++ return htobe32(x); ++ return htole32(x); ++} ++ ++static uint64_t write64(uint64_t x, int be) ++{ ++ if (be) ++ return htobe64(x); ++ return htole64(x); ++} ++ + struct cache_entry + { + char *lib; /* Library name. */ +@@ -279,7 +302,12 @@ save_cache (const char *cache_name) + /* Number of normal cache entries. */ + int cache_entry_old_count = 0; + +- for (entry = entries; entry != NULL; entry = entry->next) ++ if (be) ++ printf("saving cache in big endian encoding\n"); ++ else ++ printf("saving cache in little endian encoding\n"); ++ ++ for (entry = entries; entry != NULL; entry = entry->next) + { + /* Account the final NULs. */ + total_strlen += strlen (entry->lib) + strlen (entry->path) + 2; +@@ -310,7 +338,7 @@ save_cache (const char *cache_name) + memset (file_entries, '\0', sizeof (struct cache_file)); + memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1); + +- file_entries->nlibs = cache_entry_old_count; ++ file_entries->nlibs = write32(cache_entry_old_count, be); + } + + struct cache_file_new *file_entries_new = NULL; +@@ -330,8 +358,8 @@ save_cache (const char *cache_name) + memcpy (file_entries_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1); + +- file_entries_new->nlibs = cache_entry_count; +- file_entries_new->len_strings = total_strlen; ++ file_entries_new->nlibs = write32(cache_entry_count, be); ++ file_entries_new->len_strings = write32(total_strlen, be); + } + + /* Pad for alignment of cache_file_new. */ +@@ -358,9 +386,9 @@ save_cache (const char *cache_name) + /* First the library. */ + if (opt_format != 2 && entry->hwcap == 0) + { +- file_entries->libs[idx_old].flags = entry->flags; ++ file_entries->libs[idx_old].flags = write32(entry->flags, be); + /* XXX: Actually we can optimize here and remove duplicates. */ +- file_entries->libs[idx_old].key = str_offset + pad; ++ file_entries->libs[idx_old].key = write32(str_offset + pad, be); + } + if (opt_format != 0) + { +@@ -368,10 +396,10 @@ save_cache (const char *cache_name) + not doing so makes the code easier, the string table + always begins at the beginning of the the new cache + struct. */ +- file_entries_new->libs[idx_new].flags = entry->flags; +- file_entries_new->libs[idx_new].osversion = entry->osversion; +- file_entries_new->libs[idx_new].hwcap = entry->hwcap; +- file_entries_new->libs[idx_new].key = str_offset; ++ file_entries_new->libs[idx_new].flags = write32(entry->flags, be); ++ file_entries_new->libs[idx_new].osversion = write32(entry->osversion, be); ++ file_entries_new->libs[idx_new].hwcap = write64(entry->hwcap, be); ++ file_entries_new->libs[idx_new].key = write32(str_offset, be); + } + + size_t len = strlen (entry->lib) + 1; +@@ -379,9 +407,9 @@ save_cache (const char *cache_name) + str_offset += len; + /* Then the path. */ + if (opt_format != 2 && entry->hwcap == 0) +- file_entries->libs[idx_old].value = str_offset + pad; ++ file_entries->libs[idx_old].value = write32(str_offset + pad, be); + if (opt_format != 0) +- file_entries_new->libs[idx_new].value = str_offset; ++ file_entries_new->libs[idx_new].value = write32(str_offset, be); + len = strlen (entry->path) + 1; + str = mempcpy (str, entry->path, len); + str_offset += len; diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch new file mode 100644 index 0000000..a18b2c2 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch @@ -0,0 +1,113 @@ +Upstream-Status: Inappropriate [fix poky patch] + +This patch fixes build issues with a previous endian-ness_handling.patch on +distros that don't have macros referenced + +7/20/2011 +Matthew McClintock <msm@freescale.com> + +diff -purN ldconfig-native-2.12.1.orig/endian_extra.h ldconfig-native-2.12.1/endian_extra.h +--- ldconfig-native-2.12.1.orig/endian_extra.h 1969-12-31 18:00:00.000000000 -0600 ++++ ldconfig-native-2.12.1/endian_extra.h 2011-07-19 18:09:14.323048417 -0500 +@@ -0,0 +1,64 @@ ++/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <endian.h> ++ ++#ifndef _ENDIAN_EXTRA_H ++#define _ENDIAN_EXTRA_H 1 ++ ++/* Don't redefine these macros if they already exist */ ++#ifndef htobe16 ++#ifdef __USE_BSD ++/* Conversion interfaces. */ ++# include <byteswap.h> ++ ++# if __BYTE_ORDER == __LITTLE_ENDIAN ++# define htobe16(x) __bswap_16 (x) ++# define htole16(x) (x) ++# define be16toh(x) __bswap_16 (x) ++# define le16toh(x) (x) ++ ++# define htobe32(x) __bswap_32 (x) ++# define htole32(x) (x) ++# define be32toh(x) __bswap_32 (x) ++# define le32toh(x) (x) ++ ++# define htobe64(x) __bswap_64 (x) ++# define htole64(x) (x) ++# define be64toh(x) __bswap_64 (x) ++# define le64toh(x) (x) ++# else ++# define htobe16(x) (x) ++# define htole16(x) __bswap_16 (x) ++# define be16toh(x) (x) ++# define le16toh(x) __bswap_16 (x) ++ ++# define htobe32(x) (x) ++# define htole32(x) __bswap_32 (x) ++# define be32toh(x) (x) ++# define le32toh(x) __bswap_32 (x) ++ ++# define htobe64(x) (x) ++# define htole64(x) __bswap_64 (x) ++# define be64toh(x) (x) ++# define le64toh(x) __bswap_64 (x) ++# endif ++#endif ++#endif ++ ++#endif /* endian_extra.h */ +diff -purN ldconfig-native-2.12.1.orig/cache.c ldconfig-native-2.12.1/cache.c +--- ldconfig-native-2.12.1.orig/cache.c 2011-07-19 18:21:28.347041301 -0500 ++++ ldconfig-native-2.12.1/cache.c 2011-07-19 18:22:54.118048064 -0500 +@@ -39,6 +39,8 @@ + # define N_(msgid) msgid + #define _(msg) msg + ++#include "endian_extra.h" ++ + extern int be; + + static uint16_t write16(uint16_t x, int be) +diff -purN ldconfig-native-2.12.1.orig/readelflib.c ldconfig-native-2.12.1/readelflib.c +--- ldconfig-native-2.12.1.orig/readelflib.c 2011-07-19 18:21:28.346041593 -0500 ++++ ldconfig-native-2.12.1/readelflib.c 2011-07-19 18:23:05.324059875 -0500 +@@ -25,6 +25,9 @@ + + /* check_ptr checks that a pointer is in the mmaped file and doesn't + point outside it. */ ++ ++#include "endian_extra.h" ++ + #undef check_ptr + #define check_ptr(ptr) \ + do \ +diff -purN ldconfig-native-2.12.1.orig/readlib.c ldconfig-native-2.12.1/readlib.c +--- ldconfig-native-2.12.1.orig/readlib.c 2011-07-19 18:21:28.346041593 -0500 ++++ ldconfig-native-2.12.1/readlib.c 2011-07-19 18:23:23.877046210 -0500 +@@ -40,6 +40,8 @@ + + #include "ldconfig.h" + ++#include "endian_extra.h" ++ + #define _(msg) msg + + #define Elf32_CLASS ELFCLASS32 diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch new file mode 100644 index 0000000..4e9aab9 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch @@ -0,0 +1,24 @@ +Upstream-Status: Inappropriate [embedded specific] + +The native version of ldconfig was using native definition of LD_SO (i.e. +ld-linux-x86-64.so.2 ) which is not correct for doing the cross ldconfig. +This was causing libc.so on the target marked as ELF lib rather than +FLAG_ELF_LIBC6 in the ld.so.cache. + +Nitin A Kamble <nitin.a.kamble@intel.com> 2011/04/4 + +Index: ldconfig-native-2.12.1/readlib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readlib.c ++++ ldconfig-native-2.12.1/readlib.c +@@ -51,6 +51,10 @@ struct known_names + int flag; + }; + ++/* don't use host's definition of LD_SO */ ++#undef LD_SO ++#define LD_SO "ld.so.1" ++ + static struct known_names interpreters[] = + { + { "/lib/" LD_SO, FLAG_ELF_LIBC6 }, diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch new file mode 100644 index 0000000..5ed4f6f --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-default-to-all-multilib-dirs.patch @@ -0,0 +1,37 @@ +Upstream-Status: Inappropriate [embedded specific] + +make ldconfig default to both /lib+/usr/lib, /lib32+/usr/lib32 and +/lib64+/usr/lib64 on bi-ABI architectures. + +--- + ldconfig.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff -urpN a/ldconfig.c b/ldconfig.c +--- a/ldconfig.c ++++ b/ldconfig.c +@@ -52,7 +52,11 @@ + + #define SYSCONFDIR "/etc" + #define LIBDIR "/usr/lib" ++#define LIBDIR32 "/usr/lib32" ++#define LIBDIR64 "/usr/lib64" + #define SLIBDIR "/lib" ++#define SLIBDIR32 "/lib32" ++#define SLIBDIR64 "/lib64" + # define N_(msgid) msgid + #define _(msg) msg + +@@ -1373,6 +1377,12 @@ main (int argc, char **argv) + add_system_dir (SLIBDIR); + if (strcmp (SLIBDIR, LIBDIR)) + add_system_dir (LIBDIR); ++ add_system_dir (SLIBDIR32); ++ if (strcmp (SLIBDIR32, LIBDIR32)) ++ add_system_dir (LIBDIR32); ++ add_system_dir (SLIBDIR64); ++ if (strcmp (SLIBDIR64, LIBDIR64)) ++ add_system_dir (LIBDIR64); + } + + const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 Binary files differnew file mode 100644 index 0000000..dc1e798 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch new file mode 100644 index 0000000..52986e6 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch @@ -0,0 +1,471 @@ +Upstream-Status: Inappropriate [embedded specific] + +enable standalone building of ldconfig + +--- + cache.c | 11 +- + chroot_canon.c | 7 + + dl-cache.c | 235 --------------------------------------------------------- + dl-cache.h | 3 + ldconfig.c | 27 ++++-- + readlib.c | 7 + + xstrdup.c | 11 -- + 7 files changed, 45 insertions(+), 256 deletions(-) + +Index: ldconfig-native-2.12.1/cache.c +=================================================================== +--- ldconfig-native-2.12.1.orig/cache.c ++++ ldconfig-native-2.12.1/cache.c +@@ -16,6 +16,9 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #include <errno.h> + #include <error.h> + #include <dirent.h> +@@ -31,8 +34,10 @@ + #include <sys/stat.h> + #include <sys/types.h> + +-#include <ldconfig.h> +-#include <dl-cache.h> ++#include "ldconfig.h" ++#include "dl-cache.h" ++# define N_(msgid) msgid ++#define _(msg) msg + + struct cache_entry + { +Index: ldconfig-native-2.12.1/chroot_canon.c +=================================================================== +--- ldconfig-native-2.12.1.orig/chroot_canon.c ++++ ldconfig-native-2.12.1/chroot_canon.c +@@ -17,6 +17,9 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #include <stdlib.h> + #include <string.h> + #include <unistd.h> +@@ -27,7 +30,9 @@ + #include <stddef.h> + #include <stdint.h> + +-#include <ldconfig.h> ++#include "ldconfig.h" ++ ++#define __set_errno(Val) errno = (Val) + + #ifndef PATH_MAX + #define PATH_MAX 1024 +Index: ldconfig-native-2.12.1/dl-cache.c +=================================================================== +--- ldconfig-native-2.12.1.orig/dl-cache.c ++++ ldconfig-native-2.12.1/dl-cache.c +@@ -20,12 +20,12 @@ + + #include <assert.h> + #include <unistd.h> +-#include <ldsodefs.h> ++//#include "ldsodefs.h" + #include <sys/mman.h> + #include <dl-cache.h> + #include <dl-procinfo.h> + +-#include <stdio-common/_itoa.h> ++//#include "_itoa.h" + + #ifndef _DL_PLATFORMS_COUNT + # define _DL_PLATFORMS_COUNT 0 +@@ -39,103 +39,7 @@ static size_t cachesize; + /* 1 if cache_data + PTR points into the cache. */ + #define _dl_cache_verify_ptr(ptr) (ptr < cache_data_size) + +-#define SEARCH_CACHE(cache) \ +-/* We use binary search since the table is sorted in the cache file. \ +- The first matching entry in the table is returned. \ +- It is important to use the same algorithm as used while generating \ +- the cache file. */ \ +-do \ +- { \ +- left = 0; \ +- right = cache->nlibs - 1; \ +- \ +- while (left <= right) \ +- { \ +- __typeof__ (cache->libs[0].key) key; \ +- \ +- middle = (left + right) / 2; \ +- \ +- key = cache->libs[middle].key; \ +- \ +- /* Make sure string table indices are not bogus before using \ +- them. */ \ +- if (! _dl_cache_verify_ptr (key)) \ +- { \ +- cmpres = 1; \ +- break; \ +- } \ +- \ +- /* Actually compare the entry with the key. */ \ +- cmpres = _dl_cache_libcmp (name, cache_data + key); \ +- if (__builtin_expect (cmpres == 0, 0)) \ +- { \ +- /* Found it. LEFT now marks the last entry for which we \ +- know the name is correct. */ \ +- left = middle; \ +- \ +- /* There might be entries with this name before the one we \ +- found. So we have to find the beginning. */ \ +- while (middle > 0) \ +- { \ +- __typeof__ (cache->libs[0].key) key; \ +- \ +- key = cache->libs[middle - 1].key; \ +- /* Make sure string table indices are not bogus before \ +- using them. */ \ +- if (! _dl_cache_verify_ptr (key) \ +- /* Actually compare the entry. */ \ +- || _dl_cache_libcmp (name, cache_data + key) != 0) \ +- break; \ +- --middle; \ +- } \ +- \ +- do \ +- { \ +- int flags; \ +- __typeof__ (cache->libs[0]) *lib = &cache->libs[middle]; \ +- \ +- /* Only perform the name test if necessary. */ \ +- if (middle > left \ +- /* We haven't seen this string so far. Test whether the \ +- index is ok and whether the name matches. Otherwise \ +- we are done. */ \ +- && (! _dl_cache_verify_ptr (lib->key) \ +- || (_dl_cache_libcmp (name, cache_data + lib->key) \ +- != 0))) \ +- break; \ +- \ +- flags = lib->flags; \ +- if (_dl_cache_check_flags (flags) \ +- && _dl_cache_verify_ptr (lib->value)) \ +- { \ +- if (best == NULL || flags == GLRO(dl_correct_cache_id)) \ +- { \ +- HWCAP_CHECK; \ +- best = cache_data + lib->value; \ +- \ +- if (flags == GLRO(dl_correct_cache_id)) \ +- /* We've found an exact match for the shared \ +- object and no general `ELF' release. Stop \ +- searching. */ \ +- break; \ +- } \ +- } \ +- } \ +- while (++middle <= right); \ +- break; \ +- } \ +- \ +- if (cmpres < 0) \ +- left = middle + 1; \ +- else \ +- right = middle - 1; \ +- } \ +- } \ +-while (0) +- +- + int +-internal_function + _dl_cache_libcmp (const char *p1, const char *p2) + { + while (*p1 != '\0') +@@ -172,139 +76,3 @@ _dl_cache_libcmp (const char *p1, const + } + return *p1 - *p2; + } +- +- +-/* Look up NAME in ld.so.cache and return the file name stored there, +- or null if none is found. */ +- +-const char * +-internal_function +-_dl_load_cache_lookup (const char *name) +-{ +- int left, right, middle; +- int cmpres; +- const char *cache_data; +- uint32_t cache_data_size; +- const char *best; +- +- /* Print a message if the loading of libs is traced. */ +- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) +- _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE); +- +- if (cache == NULL) +- { +- /* Read the contents of the file. */ +- void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize, +- PROT_READ); +- +- /* We can handle three different cache file formats here: +- - the old libc5/glibc2.0/2.1 format +- - the old format with the new format in it +- - only the new format +- The following checks if the cache contains any of these formats. */ +- if (file != MAP_FAILED && cachesize > sizeof *cache +- && memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1) == 0) +- { +- size_t offset; +- /* Looks ok. */ +- cache = file; +- +- /* Check for new version. */ +- offset = ALIGN_CACHE (sizeof (struct cache_file) +- + cache->nlibs * sizeof (struct file_entry)); +- +- cache_new = (struct cache_file_new *) ((void *) cache + offset); +- if (cachesize < (offset + sizeof (struct cache_file_new)) +- || memcmp (cache_new->magic, CACHEMAGIC_VERSION_NEW, +- sizeof CACHEMAGIC_VERSION_NEW - 1) != 0) +- cache_new = (void *) -1; +- } +- else if (file != MAP_FAILED && cachesize > sizeof *cache_new +- && memcmp (file, CACHEMAGIC_VERSION_NEW, +- sizeof CACHEMAGIC_VERSION_NEW - 1) == 0) +- { +- cache_new = file; +- cache = file; +- } +- else +- { +- if (file != MAP_FAILED) +- __munmap (file, cachesize); +- cache = (void *) -1; +- } +- +- assert (cache != NULL); +- } +- +- if (cache == (void *) -1) +- /* Previously looked for the cache file and didn't find it. */ +- return NULL; +- +- best = NULL; +- +- if (cache_new != (void *) -1) +- { +- uint64_t platform; +- +- /* This is where the strings start. */ +- cache_data = (const char *) cache_new; +- +- /* Now we can compute how large the string table is. */ +- cache_data_size = (const char *) cache + cachesize - cache_data; +- +- platform = _dl_string_platform (GLRO(dl_platform)); +- if (platform != (uint64_t) -1) +- platform = 1ULL << platform; +- +-#define _DL_HWCAP_TLS_MASK (1LL << 63) +- uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & GLRO(dl_hwcap_mask)) +- | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK); +- +- /* Only accept hwcap if it's for the right platform. */ +-#define HWCAP_CHECK \ +- if (lib->hwcap & hwcap_exclude) \ +- continue; \ +- if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \ +- continue; \ +- if (_DL_PLATFORMS_COUNT \ +- && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \ +- && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \ +- continue +- SEARCH_CACHE (cache_new); +- } +- else +- { +- /* This is where the strings start. */ +- cache_data = (const char *) &cache->libs[cache->nlibs]; +- +- /* Now we can compute how large the string table is. */ +- cache_data_size = (const char *) cache + cachesize - cache_data; +- +-#undef HWCAP_CHECK +-#define HWCAP_CHECK do {} while (0) +- SEARCH_CACHE (cache); +- } +- +- /* Print our result if wanted. */ +- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0) +- && best != NULL) +- _dl_debug_printf (" trying file=%s\n", best); +- +- return best; +-} +- +-#ifndef MAP_COPY +-/* If the system does not support MAP_COPY we cannot leave the file open +- all the time since this would create problems when the file is replaced. +- Therefore we provide this function to close the file and open it again +- once needed. */ +-void +-_dl_unload_cache (void) +-{ +- if (cache != NULL && cache != (struct cache_file *) -1) +- { +- __munmap (cache, cachesize); +- cache = NULL; +- } +-} +-#endif +Index: ldconfig-native-2.12.1/dl-cache.h +=================================================================== +--- ldconfig-native-2.12.1.orig/dl-cache.h ++++ ldconfig-native-2.12.1/dl-cache.h +@@ -101,5 +101,4 @@ struct cache_file_new + (((addr) + __alignof__ (struct cache_file_new) -1) \ + & (~(__alignof__ (struct cache_file_new) - 1))) + +-extern int _dl_cache_libcmp (const char *p1, const char *p2) +- internal_function; ++extern int _dl_cache_libcmp (const char *p1, const char *p2); +Index: ldconfig-native-2.12.1/ldconfig.c +=================================================================== +--- ldconfig-native-2.12.1.orig/ldconfig.c ++++ ldconfig-native-2.12.1/ldconfig.c +@@ -16,6 +16,9 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #define PROCINFO_CLASS static + #include <alloca.h> + #include <argp.h> +@@ -39,10 +42,20 @@ + #include <glob.h> + #include <libgen.h> + +-#include <ldconfig.h> +-#include <dl-cache.h> ++#include "ldconfig.h" ++#include "dl-cache.h" ++ ++#include "dl-procinfo.h" ++ ++#include "argp.h" ++ ++ ++#define SYSCONFDIR "/etc" ++#define LIBDIR "/usr/lib" ++#define SLIBDIR "/lib" ++# define N_(msgid) msgid ++#define _(msg) msg + +-#include <dl-procinfo.h> + + #ifdef _DL_FIRST_PLATFORM + # define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT) +@@ -55,7 +68,7 @@ + #endif + + /* Get libc version number. */ +-#include <version.h> ++#include "version.h" + + #define PACKAGE _libc_intl_domainname + +@@ -152,8 +165,8 @@ static const struct argp_option options[ + { NULL, 0, NULL, 0, NULL, 0 } + }; + +-#define PROCINFO_CLASS static +-#include <dl-procinfo.c> ++//#define PROCINFO_CLASS static ++//#include <dl-procinfo.c> + + /* Short description of program. */ + static const char doc[] = N_("Configure Dynamic Linker Run Time Bindings."); +@@ -291,6 +304,7 @@ parse_opt (int key, char *arg, struct ar + return 0; + } + ++#define REPORT_BUGS_TO "mailing list : poky@yoctoproject.org" + /* Print bug-reporting information in the help message. */ + static char * + more_help (int key, const char *text, void *input) +@@ -315,7 +329,7 @@ For bug reporting instructions, please s + static void + print_version (FILE *stream, struct argp_state *state) + { +- fprintf (stream, "ldconfig %s%s\n", PKGVERSION, VERSION); ++ fprintf (stream, "ldconfig (Hacked Poky Version)\n"); + fprintf (stream, gettext ("\ + Copyright (C) %s Free Software Foundation, Inc.\n\ + This is free software; see the source for copying conditions. There is NO\n\ +@@ -1233,6 +1247,7 @@ set_hwcap (void) + hwcap_mask = strtoul (mask, NULL, 0); + } + ++const char _libc_intl_domainname[] = "libc"; + + int + main (int argc, char **argv) +Index: ldconfig-native-2.12.1/readlib.c +=================================================================== +--- ldconfig-native-2.12.1.orig/readlib.c ++++ ldconfig-native-2.12.1/readlib.c +@@ -22,6 +22,9 @@ + development version. Besides the simplification, it has also been + modified to read some other file formats. */ + ++#define _LARGEFILE64_SOURCE ++#define _GNU_SOURCE ++ + #include <a.out.h> + #include <elf.h> + #include <error.h> +@@ -35,7 +38,9 @@ + #include <sys/stat.h> + #include <gnu/lib-names.h> + +-#include <ldconfig.h> ++#include "ldconfig.h" ++ ++#define _(msg) msg + + #define Elf32_CLASS ELFCLASS32 + #define Elf64_CLASS ELFCLASS64 +Index: ldconfig-native-2.12.1/xstrdup.c +=================================================================== +--- ldconfig-native-2.12.1.orig/xstrdup.c ++++ ldconfig-native-2.12.1/xstrdup.c +@@ -16,15 +16,10 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +-#ifdef HAVE_CONFIG_H +-# include <config.h> +-#endif ++#define _GNU_SOURCE ++ ++#include <string.h> + +-#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC +-# include <string.h> +-#else +-# include <strings.h> +-#endif + void *xmalloc (size_t n) __THROW; + char *xstrdup (char *string) __THROW; + diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch new file mode 100644 index 0000000..27bc411 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch @@ -0,0 +1,36 @@ +Upstream-Status: Pending + +Coming from this bug: http://sourceware.org/bugzilla/show_bug.cgi?id=11149 + +Nitin A Kamble <nitin.a.kamble@intel.com>2011/03/29 + +--- ldconfig-native-2.12.1.orig/ldconfig.c ++++ ldconfig-native-2.12.1/ldconfig.c +@@ -1359,14 +1359,9 @@ main (int argc, char **argv) + + const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; + if (opt_chroot) +- { +- aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); +- if (aux_cache_file == NULL) +- error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"), +- _PATH_LDCONFIG_AUX_CACHE); +- } ++ aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); + +- if (! opt_ignore_aux_cache) ++ if (! opt_ignore_aux_cache && aux_cache_file) + load_aux_cache (aux_cache_file); + else + init_aux_cache (); +@@ -1376,7 +1371,8 @@ main (int argc, char **argv) + if (opt_build_cache) + { + save_cache (cache_file); +- save_aux_cache (aux_cache_file); ++ if (aux_cache_file) ++ save_aux_cache (aux_cache_file); + } + + return 0; + diff --git a/meta-aspeed/recipes-core/eglibc/ldconfig-native_2.12.1.bb b/meta-aspeed/recipes-core/eglibc/ldconfig-native_2.12.1.bb new file mode 100644 index 0000000..75ffbf6 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/ldconfig-native_2.12.1.bb @@ -0,0 +1,32 @@ +SUMMARY = "A standalone native ldconfig build" + +LICENSE = "GPLv2+" + +LIC_FILES_CHKSUM = "file://${S}/ldconfig.c;endline=17;md5=1d15f20937c055cb5de2329a4c054399" + +SRC_URI = "file://ldconfig-native-2.12.1.tar.bz2 \ + file://ldconfig.patch \ + file://ldconfig_aux-cache_path_fix.patch \ + file://32and64bit.patch \ + file://endian-ness_handling.patch \ + file://flag_fix.patch \ + file://endianess-header.patch \ + file://ldconfig-default-to-all-multilib-dirs.patch \ +" + +PR = "r2" + +FILESPATH = "${FILE_DIRNAME}/${PN}-${PV}/" + +inherit native + +S = "${WORKDIR}/${PN}-${PV}" + +do_compile () { + $CC ldconfig.c -std=gnu99 chroot_canon.c xmalloc.c xstrdup.c cache.c readlib.c -I. dl-cache.c -o ldconfig +} + +do_install () { + install -d ${D}/${bindir}/ + install ldconfig ${D}/${bindir}/ +} diff --git a/meta-aspeed/recipes-core/eglibc/site_config/funcs b/meta-aspeed/recipes-core/eglibc/site_config/funcs new file mode 100644 index 0000000..ccc8539 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/site_config/funcs @@ -0,0 +1,474 @@ +a64l +abs +access +__adjtimex +alarm +alphasort +argz_append +__argz_count +argz_create_sep +argz_insert +__argz_next +argz_next +__argz_stringify +argz_stringify +asprintf +atexit +atof +atoi +bcmp +bcopy +bindresvport +bind_textdomain_codeset +btowc +bzero +calloc +canonicalize_file_name +catgets +cfgetospeed +cfsetispeed +cfsetspeed +chmod +chown +chroot +clock +close +closedir +closelog +confstr +connect +daemon +dcgettext +difftime +dirfd +dirname +dngettext +dup2 +ecvt +endgrent +endmntent +endpwent +endutent +endutxent +epoll_ctl +err +ether_hostton +ether_ntohost +euidaccess +execv +fchdir +fchmod +fchmodat +fchown +fchownat +fcntl +fcvt +fdatasync +fdopendir +feof_unlocked +fgets_unlocked +fgetxattr +finite +flistxattr +flock +flockfile +fnmatch +fork +fpathconf +__fpending +fprintf +free +freeaddrinfo +freeifaddrs +fseeko +__fsetlocking +fsetxattr +fstat64 +fstat +fstatfs +fsync +ftello +ftime +ftruncate +funlockfile +futimes +futimesat +gai_strerror +gcvt +getaddrinfo +getc_unlocked +getcwd +getdelim +getdomainname +getdtablesize +getegid +getenv +geteuid +getgid +getgrent +getgrent_r +getgrgid_r +getgrnam +getgrnam_r +getgrouplist +getgroups +gethostbyaddr_r +gethostbyname2 +gethostbyname +gethostbyname_r +gethostent +gethostid +gethostname +getifaddrs +getline +getloadavg +getmntent +getmsg +getnameinfo +getnetbyaddr_r +getnetgrent_r +getopt +getopt_long +getopt_long_only +getpagesize +getpass +getpeername +getpgrp +getpid +getppid +getprotoent_r +getpwent +getpwent_r +getpwnam +getpwnam_r +getpwuid +getpwuid_r +getresuid +getrlimit +getrusage +getservbyname +getservbyname_r +getservbyport_r +getservent +getservent_r +getspnam +getspnam_r +gettimeofday +getttyent +getttynam +getuid +getusershell +getutent +getutid +getutline +getutmp +getutmpx +getutxent +getutxid +getutxline +getwd +getxattr +glob +gmtime +gmtime_r +grantpt +group_member +herror +hstrerror +iconv +iconv_open +if_freenameindex +if_indextoname +if_nameindex +if_nametoindex +index +inet_addr +inet_aton +inet_ntoa +inet_ntop +inet_pton +initgroups +innetgr +iruserok +isascii +isatty +isblank +isgraph +isinf +isnan +isprint +isspace +iswalnum +iswcntrl +iswctype +iswprint +iswspace +iswupper +isxdigit +kill +killpg +lchown +lckpwdf +lgetxattr +link +listxattr +llistxattr +localtime +localtime_r +lockf +lrand48 +lsearch +lseek64 +lsetxattr +lstat +mallinfo +malloc +mblen +mbrlen +mbrtowc +mbsinit +mbsrtowcs +mbtowc +memalign +memchr +memcmp +memcpy +memmove +mempcpy +memrchr +memset +mkdir +mkdirat +mkdtemp +mkfifo +mknod +mkstemp64 +mkstemp +mktime +mlock +mmap +mtrace +munlock +munmap +nanosleep +nice +nl_langinfo +ntp_adjtime +ntp_gettime +_obstack_free +on_exit +open64 +open +openat +opendir +openlog +pathconf +pipe +poll +popen +posix_memalign +prctl +pread +printf +__progname +pselect +pthread_mutex_lock +ptsname +putenv +putgrent +putpwent +putspent +pututline +pututxline +putwc +pwrite +qsort +raise +rand +random +rand_r +read +readdir +readdir_r +readlink +realloc +realpath +re_comp +recvmsg +re_exec +regcomp +regexec +remove +rename +re_search +rmdir +rpmatch +rresvport_af +ruserok +ruserok_af +sbrk +scandir +sched_setscheduler +sched_yield +__secure_getenv +select +semctl +semget +sendmsg +setbuf +setbuffer +setegid +setenv +seteuid +setgid +setgroups +sethostname +setitimer +_setjmp +setjmp +setlinebuf +setlocale +setmntent +setpgid +setpgrp +setpriority +setregid +setresgid +setresuid +setreuid +setrlimit +setsid +setsockopt +settimeofday +setuid +setutent +setutxent +setvbuf +setxattr +sgetspent +shmat +shmctl +shmdt +shmget +shutdown +sigaction +sigaddset +sigaltstack +sigblock +sigemptyset +sighold +siginterrupt +signal +sigprocmask +sigset +sigsetmask +sigstack +sigsuspend +sigvec +snprintf +socket +socketpair +sprintf +srand48 +srand +srandom +sscanf +stat +statfs +statvfs +stime +stpcpy +strcasecmp +strcasestr +strchr +strchrnul +strcmp +strcspn +strdup +strerror +strerror_r +strftime +strlen +strncasecmp +strncmp +strndup +strnlen +strpbrk +strptime +strrchr +strsep +strsignal +strspn +strstr +strtod +strtoimax +strtok_r +strtol +strtoll +strtoul +strtoull +strtoumax +strverscmp +strxfrm +symlink +sync +sysconf +sysctl +sysinfo +syslog +_sys_siglist +sys_siglist +system +tcgetattr +tcgetpgrp +tcsetattr +tcsetpgrp +time +timegm +times +timezone +tmpnam +towlower +towupper +truncate +tsearch +ttyname +tzset +ulimit +umask +uname +unlink +unsetenv +unshare +updwtmp +updwtmpx +usleep +ustat +utime +utimes +utmpname +utmpxname +valloc +vasprintf +verrx +vfork +vfprintf +vfscanf +vhangup +vprintf +vsnprintf +vsprintf +wait3 +wait4 +waitpid +wcrtomb +wcscoll +wcsdup +wcslen +wctob +wctomb +wctype +wcwidth +wmemchr +wmemcpy +wmempcpy diff --git a/meta-aspeed/recipes-core/eglibc/site_config/headers b/meta-aspeed/recipes-core/eglibc/site_config/headers new file mode 100644 index 0000000..609ab53 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/site_config/headers @@ -0,0 +1,156 @@ +aio.h +alloca.h +argz.h +arpa/inet.h +arpa/nameser.h +asm/byteorder.h +asm/ioctls.h +asm/page.h +asm/types.h +assert.h +byteswap.h +crypt.h +ctype.h +dirent.h +dlfcn.h +elf.h +endian.h +err.h +errno.h +execinfo.h +fcntl.h +features.h +float.h +fstab.h +ftw.h +getopt.h +glob.h +grp.h +iconv.h +ifaddrs.h +inttypes.h +langinfo.h +lastlog.h +libgen.h +libintl.h +limits.h +linux/capability.h +linux/fd.h +linux/fs.h +linux/hayesesp.h +linux/hdreg.h +linux/icmp.h +linux/in6.h +linux/joystick.h +linux/ptrace.h +linux/serial.h +linux/sonypi.h +linux/unistd.h +linux/utsname.h +linux/version.h +locale.h +malloc.h +math.h +mcheck.h +memory.h +mntent.h +mqueue.h +netdb.h +net/if.h +netinet/ether.h +netinet/in.h +netinet/ip6.h +netinet/ip.h +netinet/tcp.h +netinet/udp.h +netipx/ipx.h +net/route.h +paths.h +poll.h +pthread.h +pty.h +pwd.h +regex.h +resolv.h +rpc/rpc.h +rpc/types.h +sched.h +scsi/scsi.h +search.h +semaphore.h +setjmp.h +sgtty.h +shadow.h +signal.h +stdarg.h +stdbool.h +stdc +stddef.h +stdint.h +stdio.h +stdlib.h +string.h +strings.h +stropts.h +sys/bitypes.h +sys/cdefs.h +sys/dir.h +sys/epoll.h +sysexits.h +sys/fcntl.h +sys/file.h +sys/fsuid.h +sys/ioctl.h +sys/ipc.h +syslog.h +sys/mman.h +sys/mount.h +sys/mtio.h +sys/param.h +sys/poll.h +sys/prctl.h +sys/ptrace.h +sys/queue.h +sys/reg.h +sys/resource.h +sys/select.h +sys/sem.h +sys/shm.h +sys/signal.h +sys/socket.h +sys/socketvar.h +sys/soundcard.h +sys/statfs.h +sys/stat.h +sys/statvfs.h +sys/stropts.h +sys/swap.h +sys/sysctl.h +sys/sysinfo.h +sys/sysmacros.h +sys/termios.h +sys/timeb.h +sys/time.h +sys/times.h +sys/timex.h +sys/types.h +sys/uio.h +sys/un.h +sys/unistd.h +sys/user.h +sys/utsname.h +sys/vfs.h +sys/wait.h +termio.h +termios.h +time.h +ttyent.h +ulimit.h +unistd.h +ustat.h +utime.h +utmp.h +utmpx.h +values.h +wchar.h +wctype.h diff --git a/meta-aspeed/recipes-core/eglibc/site_config/types b/meta-aspeed/recipes-core/eglibc/site_config/types new file mode 100644 index 0000000..178bd85 --- /dev/null +++ b/meta-aspeed/recipes-core/eglibc/site_config/types @@ -0,0 +1,21 @@ +char +char * +double +float +int +long +long double +long int +long long +long long int +short +short int +signed char +unsigned char +unsigned int +unsigned long +unsigned long int +unsigned long long int +unsigned short +unsigned short int +void * diff --git a/meta-aspeed/recipes-kernel/linux/files/patch-2.6.28.9/0033-Linux-snapshot-of-OpenBMC-f926614.patch b/meta-aspeed/recipes-kernel/linux/files/patch-2.6.28.9/0033-Linux-snapshot-of-OpenBMC-f926614.patch new file mode 100644 index 0000000..4e4c76e --- /dev/null +++ b/meta-aspeed/recipes-kernel/linux/files/patch-2.6.28.9/0033-Linux-snapshot-of-OpenBMC-f926614.patch @@ -0,0 +1,978 @@ +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/arch/arm/plat-aspeed/dev-i2c.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/arch/arm/plat-aspeed/dev-i2c.c +index fffa480..a6f75b1 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/arch/arm/plat-aspeed/dev-i2c.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/arch/arm/plat-aspeed/dev-i2c.c +@@ -634,6 +634,9 @@ static struct i2c_board_info __initdata wedge100_i2c_bus5[] = { + { + I2C_BOARD_INFO("fb_panther_plus", 0x40), + }, ++ { ++ I2C_BOARD_INFO("com_e_driver", 0x33), ++ } + }; + + static struct i2c_board_info __initdata wedge100_i2c_bus6[] = { +@@ -767,11 +770,17 @@ static struct i2c_board_info __initdata ast_i2c_board_info_11[] = { + //Under I2C Dev 12 + static struct i2c_board_info __initdata ast_i2c_board_info_12[] = { + // Mezz Card LAN_SMB bus (PHY, Temp. Sensor) ++ { ++ //I2C_BOARD_INFO("tmp75", 0x1f), ++ }, + }; + + //Under I2C Dev 13 + static struct i2c_board_info __initdata ast_i2c_board_info_13[] = { + // Mezz Card Mezz_SMB bus (FRUID, GPIO expander, QSFP+) ++ { ++ I2C_BOARD_INFO("24c64", 0x51), ++ }, + }; + + /* end of CONFIG_YOSEMITE */ +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/hwmon/ast_adc.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/hwmon/ast_adc.c +index 8f5aa54..e21d52e 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/hwmon/ast_adc.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/hwmon/ast_adc.c +@@ -525,7 +525,7 @@ ast_show_adc(struct device *dev, struct device_attribute *attr, char *sysfsbuf) + break; + case 1: //value + voltage = ast_get_voltage(sensor_attr->index); +- return sprintf(sysfsbuf, "%d.%d (V)\n",voltage/100, voltage%100); ++ return sprintf(sysfsbuf, "%d.%02d (V)\n",voltage/100, voltage%100); + break; + case 2: //alarm + return sprintf(sysfsbuf, "%d \n", ast_get_adc_alarm(ast_adc,sensor_attr->index)); +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/i2c/busses/i2c-ast.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/i2c/busses/i2c-ast.c +index 9bb3154..48f0192 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/i2c/busses/i2c-ast.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/i2c/busses/i2c-ast.c +@@ -49,14 +49,22 @@ + /***************************************************************************/ + + #ifdef CONFIG_AST_I2C_SLAVE_RDWR +-#define I2C_S_BUF_SIZE 64 +-#define I2C_S_RX_BUF_NUM 4 ++#define I2C_S_BUF_SIZE 256 ++#define I2C_S_RX_BUF_NUM 20 + #define BUFF_FULL 0xff00 + #define BUFF_ONGOING 1 + #endif + + #define AST_LOCKUP_DETECTED (0x1 << 15) + ++// Enable SCL/SDA pull LOW detection for Yosemite platform ++#ifdef CONFIG_YOSEMITE ++#define AST_I2C_LOW_TIMEOUT 0x07 ++#else ++#define AST_I2C_LOW_TIMEOUT 0x00 ++#endif //CONFIG_YOSEMITE ++ ++ + struct ast_i2c_dev { + struct ast_i2c_driver_data *ast_i2c_data; + struct device *dev; +@@ -192,12 +200,12 @@ static void ast_i2c_dev_init(struct ast_i2c_dev *i2c_dev) + , I2C_FUN_CTRL_REG); + + /* Set AC Timing */ +- ast_i2c_write(i2c_dev, 0x3, I2C_AC_TIMING_REG2); ++ ast_i2c_write(i2c_dev, AST_I2C_LOW_TIMEOUT, I2C_AC_TIMING_REG2); + ast_i2c_write(i2c_dev, select_i2c_clock(i2c_dev), I2C_AC_TIMING_REG1); + }else { + /* target apeed is xxKhz*/ + ast_i2c_write(i2c_dev, select_i2c_clock(i2c_dev), I2C_AC_TIMING_REG1); +- ast_i2c_write(i2c_dev, AST_NO_TIMEOUT_CTRL, I2C_AC_TIMING_REG2); ++ ast_i2c_write(i2c_dev, AST_I2C_LOW_TIMEOUT, I2C_AC_TIMING_REG2); + } + #else + /* target apeed is xxKhz*/ +@@ -252,6 +260,7 @@ static void ast_i2c_slave_buff_init(struct ast_i2c_dev *i2c_dev) + static void ast_i2c_slave_rdwr_xfer(struct ast_i2c_dev *i2c_dev) + { + int i; ++ int count = 0; + unsigned long flags; + + spin_lock_irqsave(&i2c_dev->slave_rx_lock, flags); +@@ -265,15 +274,31 @@ static void ast_i2c_slave_rdwr_xfer(struct ast_i2c_dev *i2c_dev) + } + } + if(i == I2C_S_RX_BUF_NUM) { +- printk("RX buffer full ........use tmp msgs buff \n"); +- //TODO... ++ // dev_err(i2c_dev->dev, "RX buffer full ........use tmp msgs buff \n"); ++ for(i=0; i<I2C_S_RX_BUF_NUM; i++) { ++ if((i2c_dev->slave_rx_msg[i].flags == 0) && (i2c_dev->slave_rx_msg[i].addr == BUFF_ONGOING)) { ++ count++; ++ i2c_dev->slave_rx_msg[i].addr = 0; ++ } ++ } ++ ++ if (count) { ++ dev_err(i2c_dev->dev, "Cleared slave ongoing buffers of count: %d\n", count); ++ } ++ ++ for(i=0; i<I2C_S_RX_BUF_NUM; i++) { ++ if((i2c_dev->slave_rx_msg[i].flags == 0) && (i2c_dev->slave_rx_msg[i].addr != BUFF_ONGOING)) { ++ i2c_dev->slave_rx_msg[i].addr = BUFF_ONGOING; ++ break; ++ } ++ } + } + //printk("I2C_SLAVE_EVENT_START_WRITE ... %d \n", i); + + i2c_dev->slave_msgs = &i2c_dev->slave_rx_msg[i]; + break; + case I2C_SLAVE_EVENT_START_READ: +- //printk("I2C_SLAVE_EVENT_START_READ ERROR .. not imple \n"); ++ // printk("I2C_SLAVE_EVENT_START_READ ERROR .. not imple \n"); + i2c_dev->slave_msgs = &i2c_dev->slave_tx_msg; + break; + case I2C_SLAVE_EVENT_WRITE: +@@ -379,17 +404,17 @@ ast_i2c_bus_error_recover(struct ast_i2c_dev *i2c_dev) + + if ((sts & AST_I2CD_SDA_LINE_STS) && (sts & AST_I2CD_SCL_LINE_STS)) { + //Means bus is idle. +- dev_dbg(i2c_dev->dev, "I2C bus (%d) is idle. I2C slave doesn't exist?!\n", i2c_dev->bus_id); ++ dev_err(i2c_dev->dev, "I2C bus (%d) is idle. I2C slave doesn't exist?!\n", i2c_dev->bus_id); + return -1; + } + +- dev_dbg(i2c_dev->dev, "ERROR!! I2C(%d) bus hanged, try to recovery it!\n", i2c_dev->bus_id); ++ dev_err(i2c_dev->dev, "ERROR!! I2C(%d) bus hanged, try to recovery it!\n", i2c_dev->bus_id); + + + if ((sts & AST_I2CD_SDA_LINE_STS) && !(sts & AST_I2CD_SCL_LINE_STS)) { + //if SDA == 1 and SCL == 0, it means the master is locking the bus. + //Send a stop command to unlock the bus. +- dev_dbg(i2c_dev->dev, "I2C's master is locking the bus, try to stop it.\n"); ++ dev_err(i2c_dev->dev, "I2C's master is locking the bus, try to stop it.\n"); + // + init_completion(&i2c_dev->cmd_complete); + i2c_dev->cmd_err = 0; +@@ -401,15 +426,15 @@ ast_i2c_bus_error_recover(struct ast_i2c_dev *i2c_dev) + + if(i2c_dev->cmd_err && + i2c_dev->cmd_err != AST_I2CD_INTR_STS_NORMAL_STOP) { +- dev_dbg(i2c_dev->dev, "recovery error \n"); ++ dev_err(i2c_dev->dev, "recovery error \n"); + return -1; + } + + if (r == 0) { +- dev_dbg(i2c_dev->dev, "recovery timed out\n"); ++ dev_err(i2c_dev->dev, "recovery timed out\n"); + return -1; + } else { +- dev_dbg(i2c_dev->dev, "Recovery successfully\n"); ++ dev_err(i2c_dev->dev, "Recovery successfully\n"); + return 0; + } + +@@ -417,19 +442,20 @@ ast_i2c_bus_error_recover(struct ast_i2c_dev *i2c_dev) + } else if (!(sts & AST_I2CD_SDA_LINE_STS)) { + //else if SDA == 0, the device is dead. We need to reset the bus + //And do the recovery command. +- dev_dbg(i2c_dev->dev, "I2C's slave is dead, try to recover it\n"); ++ dev_err(i2c_dev->dev, "I2C's slave is dead, try to recover it\n"); + //Let's retry 10 times + for (i = 0; i < 10; i++) { + ast_i2c_dev_init(i2c_dev); + //Do the recovery command BIT11 + init_completion(&i2c_dev->cmd_complete); ++ i2c_dev->cmd_err = 0; + ast_i2c_write(i2c_dev, AST_I2CD_BUS_RECOVER_CMD_EN, I2C_CMD_REG); + + r = wait_for_completion_interruptible_timeout(&i2c_dev->cmd_complete, + i2c_dev->adap.timeout*HZ); + if (i2c_dev->cmd_err != 0 && + i2c_dev->cmd_err != AST_I2CD_INTR_STS_NORMAL_STOP) { +- dev_dbg(i2c_dev->dev, "ERROR!! Failed to do recovery command(0x%08x)\n", i2c_dev->cmd_err); ++ dev_err(i2c_dev->dev, "ERROR!! Failed to do recovery command(0x%08x)\n", i2c_dev->cmd_err); + return -1; + } + //Check 0x14's SDA and SCL status +@@ -438,14 +464,14 @@ ast_i2c_bus_error_recover(struct ast_i2c_dev *i2c_dev) + break; + } + if (i == 10) { +- dev_dbg(i2c_dev->dev, "ERROR!! recover failed\n"); ++ dev_err(i2c_dev->dev, "ERROR!! recover failed\n"); + return -1; + } + } else { +- dev_dbg(i2c_dev->dev, "Don't know how to handle this case?!\n"); ++ dev_err(i2c_dev->dev, "Don't know how to handle this case?!\n"); + return -1; + } +- dev_dbg(i2c_dev->dev, "Recovery successfully\n"); ++ dev_err(i2c_dev->dev, "Recovery successfully\n"); + return 0; + } + +@@ -472,7 +498,8 @@ static int ast_i2c_wait_bus_not_busy(struct ast_i2c_dev *i2c_dev) + } + + if (timeout <= 0) { +- return -EAGAIN; ++ //TODO: sometimes the slave operation flag is not reset properly so go ahead with checking bus busy signal ++ dev_err(i2c_dev->dev, "slave operation set, check busy status line\n"); + } + + // Wait for Bus to go IDLE +@@ -491,6 +518,8 @@ static int ast_i2c_wait_bus_not_busy(struct ast_i2c_dev *i2c_dev) + return 0; + } + ++ // TODO: hack to reset slave operation flag manually ++ i2c_dev->slave_operation = 0; + return 0; + } + +@@ -499,9 +528,6 @@ static void ast_i2c_do_dma_xfer(struct ast_i2c_dev *i2c_dev) + u32 cmd = 0; + int i; + +- i2c_dev->master_xfer_mode = DMA_XFER; +- i2c_dev->slave_xfer_mode = DMA_XFER; +- + if(i2c_dev->slave_operation == 1) { + if(i2c_dev->slave_msgs->flags & I2C_M_RD) { + //DMA tx mode +@@ -683,9 +709,6 @@ static void ast_i2c_do_pool_xfer(struct ast_i2c_dev *i2c_dev) + int i; + u32 *tx_buf; + +- i2c_dev->master_xfer_mode = BUFF_XFER; +- i2c_dev->slave_xfer_mode = BUFF_XFER; +- + #if defined(CONFIG_ARCH_AST2400) + ast_i2c_write(i2c_dev, + (ast_i2c_read(i2c_dev, I2C_FUN_CTRL_REG) & +@@ -872,12 +895,6 @@ static void ast_i2c_do_byte_xfer(struct ast_i2c_dev *i2c_dev) + u8 *xfer_buf; + u32 cmd = 0; + +- i2c_dev->master_xfer_mode = BYTE_XFER; +- i2c_dev->master_xfer_len = 1; +- +- i2c_dev->slave_xfer_mode = BYTE_XFER; +- i2c_dev->slave_xfer_len = 1; +- + if(i2c_dev->slave_operation == 1) { + dev_dbg(i2c_dev->dev,"S cnt %d, xf len %d \n",i2c_dev->slave_xfer_cnt, i2c_dev->slave_msgs->len); + if(i2c_dev->slave_msgs->flags & I2C_M_RD) { +@@ -973,14 +990,16 @@ static void ast_i2c_slave_xfer_done(struct ast_i2c_dev *i2c_dev) + u32 xfer_len; + int i; + u8 *rx_buf; ++ unsigned long flags; + + dev_dbg(i2c_dev->dev, "ast_i2c_slave_xfer_done [%d]\n",i2c_dev->slave_xfer_mode); + ++ + if (i2c_dev->slave_msgs->flags & I2C_M_RD) { + //tx done , only check tx count ... +- if(i2c_dev->master_xfer_mode == BYTE_XFER) { ++ if(i2c_dev->slave_xfer_mode == BYTE_XFER) { + xfer_len = 1; +- } else if (i2c_dev->master_xfer_mode == BUFF_XFER) { ++ } else if (i2c_dev->slave_xfer_mode == BUFF_XFER) { + xfer_len = AST_I2CD_TX_DATA_BUF_GET(ast_i2c_read(i2c_dev, I2C_BUF_CTRL_REG)); + xfer_len++; + dev_dbg(i2c_dev->dev,"S tx buff done len %d \n",xfer_len); +@@ -1004,10 +1023,12 @@ static void ast_i2c_slave_xfer_done(struct ast_i2c_dev *i2c_dev) + i2c_dev->slave_msgs->buf[i2c_dev->slave_xfer_cnt] = 0; + i2c_dev->slave_msgs->len = i2c_dev->slave_xfer_cnt; + } else { ++ if (i2c_dev->slave_xfer_cnt == 0) ++ dev_err(i2c_dev->dev,"Possible first byte failure issue\n"); + i2c_dev->slave_msgs->buf[i2c_dev->slave_xfer_cnt] = ast_i2c_read(i2c_dev,I2C_BYTE_BUF_REG) >> 8; + } + dev_dbg(i2c_dev->dev,"rx buff %d, [%x] \n",i2c_dev->slave_xfer_cnt ,i2c_dev->slave_msgs->buf[i2c_dev->slave_xfer_cnt]); +- } else if (i2c_dev->master_xfer_mode == BUFF_XFER) { ++ } else if (i2c_dev->slave_xfer_mode == BUFF_XFER) { + xfer_len = AST_I2CD_RX_BUF_ADDR_GET(ast_i2c_read(i2c_dev, I2C_BUF_CTRL_REG)); + if(xfer_len == 0) + xfer_len = AST_I2C_PAGE_SIZE; +@@ -1056,7 +1077,7 @@ static void ast_i2c_slave_xfer_done(struct ast_i2c_dev *i2c_dev) + i2c_dev->slave_xfer_cnt = 0; + } else { + if(i2c_dev->slave_xfer_cnt == i2c_dev->slave_msgs->len) { +- dev_dbg(i2c_dev->dev,"slave next msgs \n"); ++ dev_err(i2c_dev->dev,"slave next msgs with len %d\n", i2c_dev->slave_xfer_cnt); + #ifdef CONFIG_AST_I2C_SLAVE_RDWR + ast_i2c_slave_rdwr_xfer(i2c_dev); + #else +@@ -1068,6 +1089,8 @@ static void ast_i2c_slave_xfer_done(struct ast_i2c_dev *i2c_dev) + i2c_dev->do_slave_xfer(i2c_dev); + } + ++ // Read the current state for clearing up the slave mode ++ i2c_dev->state = (ast_i2c_read(i2c_dev,I2C_CMD_REG) >> 19) & 0xf; + + if(AST_I2CD_IDLE == i2c_dev->state) { + dev_dbg(i2c_dev->dev,"** Slave go IDLE **\n"); +@@ -1077,7 +1100,10 @@ static void ast_i2c_slave_xfer_done(struct ast_i2c_dev *i2c_dev) + i2c_dev->ast_i2c_data->free_pool_buff_page(i2c_dev->req_page); + } + +- } ++ } else if (i2c_dev->slave_event == I2C_SLAVE_EVENT_STOP) { ++ // TODO: hack to reset slave operation flag in case the stop is received ++ i2c_dev->slave_operation = 0; ++ } + + } + +@@ -1212,6 +1238,8 @@ unlock_out: + static void ast_i2c_slave_addr_match(struct ast_i2c_dev *i2c_dev) + { + u8 match; ++ unsigned long flags; ++ + + i2c_dev->slave_operation = 1; + i2c_dev->slave_xfer_cnt = 0; +@@ -1219,7 +1247,6 @@ static void ast_i2c_slave_addr_match(struct ast_i2c_dev *i2c_dev) + i2c_dev->slave_msgs->buf[0] = match; + dev_dbg(i2c_dev->dev, "S Start Addr match [%x] \n",match); + +- + if(match & 1) { + i2c_dev->slave_event = I2C_SLAVE_EVENT_START_READ; + } else { +@@ -1228,23 +1255,33 @@ static void ast_i2c_slave_addr_match(struct ast_i2c_dev *i2c_dev) + + #ifdef CONFIG_AST_I2C_SLAVE_RDWR + ast_i2c_slave_rdwr_xfer(i2c_dev); +- i2c_dev->slave_msgs->buf[0] = match; +- i2c_dev->slave_xfer_cnt = 1; ++ i2c_dev->slave_msgs->buf[0] = match; ++ i2c_dev->slave_xfer_cnt = 1; ++ // Reset the length field as we have received new slave address match ++ i2c_dev->slave_msgs->len = 0x0; + #else + i2c_dev->ast_i2c_data->slave_xfer(i2c_dev->slave_event, &(i2c_dev->slave_msgs)); + i2c_dev->slave_xfer_cnt = 0; + #endif + +- //request +- if(i2c_dev->ast_i2c_data->slave_dma == BYTE_MODE) ++ //request: set slave_xfer_mode properly based on slave_dma mode ++ if(i2c_dev->ast_i2c_data->slave_dma == BYTE_MODE) { + i2c_dev->do_slave_xfer = ast_i2c_do_byte_xfer; +- else if (i2c_dev->ast_i2c_data->slave_dma == DMA_MODE) ++ i2c_dev->slave_xfer_mode = BYTE_XFER; ++ i2c_dev->slave_xfer_len = 1; ++ } else if (i2c_dev->ast_i2c_data->slave_dma == DMA_MODE) { + i2c_dev->do_slave_xfer = ast_i2c_do_dma_xfer; +- else { +- if(i2c_dev->ast_i2c_data->request_pool_buff_page(&(i2c_dev->req_page)) == 0) ++ i2c_dev->slave_xfer_mode = DMA_XFER; ++ } else { ++ if(i2c_dev->ast_i2c_data->request_pool_buff_page(&(i2c_dev->req_page)) == 0) { + i2c_dev->do_slave_xfer = ast_i2c_do_pool_xfer; +- else ++ i2c_dev->slave_xfer_mode = BUFF_XFER; ++ } else { + i2c_dev->do_slave_xfer = ast_i2c_do_byte_xfer; ++ dev_err(i2c_dev->dev,"i2cdriver: pool request failed for slave\n"); ++ i2c_dev->slave_xfer_mode = BYTE_XFER; ++ i2c_dev->slave_xfer_len = 1; ++ } + } + + i2c_dev->do_slave_xfer(i2c_dev); +@@ -1254,6 +1291,7 @@ static void ast_i2c_slave_addr_match(struct ast_i2c_dev *i2c_dev) + static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + { + u32 sts; ++ u32 temp; + + struct ast_i2c_dev *i2c_dev = dev_id; + u32 isr_sts = readl(i2c_dev->ast_i2c_data->reg_gr); +@@ -1280,17 +1318,15 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + } + + if(AST_I2CD_INTR_STS_ABNORMAL & sts) { +- i2c_dev->cmd_err |= AST_I2CD_INTR_STS_ABNORMAL; +- // Turn off interrupts for further abnormal +- // conditions until we fix this one. +- ast_i2c_write(i2c_dev, +- ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) & +- ~AST_I2CD_ABNORMAL_INTR_EN, +- I2C_INTR_CTRL_REG); +- complete(&i2c_dev->cmd_complete); +- sts &= ~AST_I2CD_INTR_STS_ABNORMAL; ++ // TODO: observed abnormal interrupt happening when the bus is stressed with traffic ++ dev_err(i2c_dev->dev, "abnormal interrupt happens with status: %x, slave mode: %d\n", sts, i2c_dev->slave_operation); + // Need to clear the interrupt + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_ABNORMAL, I2C_INTR_STS_REG); ++ ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_ABNORMAL; ++ complete(&i2c_dev->cmd_complete); ++ ++ return IRQ_HANDLED; + } + + switch(sts) { +@@ -1316,15 +1352,47 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + ast_i2c_master_xfer_done(i2c_dev); + + } else { +- printk("ast_i2c: TX_ACK | NORMAL_STOP; xfer_last %d\n", i2c_dev->xfer_last); ++ dev_err(i2c_dev->dev,"ast_i2c: TX_ACK | NORMAL_STOP; xfer_last %d\n", i2c_dev->xfer_last); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_ACK | AST_I2CD_INTR_STS_NORMAL_STOP, I2C_INTR_STS_REG); ++ uint32_t new_val = ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) | ++ AST_I2CD_NORMAL_STOP_INTR_EN | ++ AST_I2CD_TX_ACK_INTR_EN; ++ ast_i2c_write(i2c_dev, new_val, I2C_INTR_CTRL_REG); ++ //take care ++ i2c_dev->cmd_err |= AST_LOCKUP_DETECTED; ++ complete(&i2c_dev->cmd_complete); ++ } ++ break; ++ case AST_I2CD_INTR_STS_TX_ACK | AST_I2CD_INTR_STS_NORMAL_STOP | AST_I2CD_INTR_STS_SLAVE_MATCH : ++ if((i2c_dev->xfer_last == 1) && (i2c_dev->slave_operation == 0)) { ++ dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_TX_ACK | AST_I2CD_INTR_STS_NORMAL_STOP | AST_I2CD_INTR_STS_SLAVE_MATCH= %x\n",sts); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_ACK | AST_I2CD_INTR_STS_NORMAL_STOP, I2C_INTR_STS_REG); ++ //take care ++ ast_i2c_write(i2c_dev, ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) | ++ AST_I2CD_TX_ACK_INTR_EN, I2C_INTR_CTRL_REG); ++ ast_i2c_master_xfer_done(i2c_dev); ++ ++ // Handle the new slave match interrupt ++ ast_i2c_slave_addr_match(i2c_dev); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SLAVE_MATCH, I2C_INTR_STS_REG); ++ } else { ++ dev_err(i2c_dev->dev, "Slave TX_ACK | NORMAL_STOP | AST_I2CD_INTR_STS_SLAVE_MATCH; xfer_last %d\n", i2c_dev->xfer_last); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_ACK | AST_I2CD_INTR_STS_NORMAL_STOP, I2C_INTR_STS_REG); + uint32_t new_val = ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) | +- AST_I2CD_NORMAL_STOP_INTR_EN | ++ AST_I2CD_NORMAL_STOP_INTR_EN | + AST_I2CD_TX_ACK_INTR_EN; + ast_i2c_write(i2c_dev, new_val, I2C_INTR_CTRL_REG); + //take care + i2c_dev->cmd_err |= AST_LOCKUP_DETECTED; + complete(&i2c_dev->cmd_complete); ++ ++ // stop previous slave transaction ++ i2c_dev->slave_event = I2C_SLAVE_EVENT_STOP; ++ ast_i2c_slave_xfer_done(i2c_dev); ++ ++ // Handle the new slave match interrupt ++ ast_i2c_slave_addr_match(i2c_dev); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SLAVE_MATCH, I2C_INTR_STS_REG); + } + break; + +@@ -1332,9 +1400,8 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + if(i2c_dev->slave_operation == 1) { + i2c_dev->slave_event = I2C_SLAVE_EVENT_NACK; + ast_i2c_slave_xfer_done(i2c_dev); +- dev_dbg(i2c_dev->dev, "S clear isr: AST_I2CD_INTR_STS_TX_NAK = %x\n",sts); ++ dev_err(i2c_dev->dev, "S clear isr: AST_I2CD_INTR_STS_TX_NAK = %x\n",sts); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_NAK, I2C_INTR_STS_REG); +- + } else { + dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_TX_NAK = %x\n",sts); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_NAK, I2C_INTR_STS_REG); +@@ -1352,7 +1419,10 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + case AST_I2CD_INTR_STS_TX_NAK | AST_I2CD_INTR_STS_NORMAL_STOP: + if(i2c_dev->slave_operation == 1) { + printk("SLAVE TODO .... \n"); +- ++ i2c_dev->slave_operation = 0; ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_NAK | AST_I2CD_INTR_STS_NORMAL_STOP, I2C_INTR_STS_REG); ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_TX_NAK | AST_I2CD_INTR_STS_NORMAL_STOP; ++ complete(&i2c_dev->cmd_complete); + } else { + dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_TX_NAK| AST_I2CD_INTR_STS_NORMAL_STOP = %x\n",sts); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_NAK | AST_I2CD_INTR_STS_NORMAL_STOP, I2C_INTR_STS_REG); +@@ -1365,12 +1435,17 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + //Issue : Workaround for I2C slave mode + case AST_I2CD_INTR_STS_TX_NAK | AST_I2CD_INTR_STS_SLAVE_MATCH: + if(i2c_dev->slave_operation == 1) { +- i2c_dev->slave_event = I2C_SLAVE_EVENT_NACK; +- ast_i2c_slave_xfer_done(i2c_dev); ++ dev_err(i2c_dev->dev, "i2cdriver: TX_NAK and Slave match sts = %x\n",sts); + ast_i2c_slave_addr_match(i2c_dev); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_NAK | AST_I2CD_INTR_STS_SLAVE_MATCH , I2C_INTR_STS_REG); + } else { + printk("ERROR !!!!\n"); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_NAK, I2C_INTR_STS_REG); ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_TX_NAK; ++ complete(&i2c_dev->cmd_complete); ++ ++ ast_i2c_slave_addr_match(i2c_dev); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SLAVE_MATCH , I2C_INTR_STS_REG); + } + break; + case AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_SLAVE_MATCH: +@@ -1378,7 +1453,17 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + dev_dbg(i2c_dev->dev, "S clear isr: AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_SLAVE_MATCH = %x\n",sts); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_SLAVE_MATCH, I2C_INTR_STS_REG); + break; ++ case AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_SLAVE_MATCH | AST_I2CD_INTR_STS_ARBIT_LOSS: ++ dev_err(i2c_dev->dev, "M clear isr: sts = %x\n",sts); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_ARBIT_LOSS, I2C_INTR_STS_REG); ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_ARBIT_LOSS; ++ ast_i2c_write(i2c_dev, ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) | ++ AST_I2CD_RX_DOWN_INTR_EN, I2C_INTR_CTRL_REG); ++ complete(&i2c_dev->cmd_complete); + ++ ast_i2c_slave_addr_match(i2c_dev); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_SLAVE_MATCH, I2C_INTR_STS_REG); ++ break; + case AST_I2CD_INTR_STS_RX_DOWN: + if(i2c_dev->slave_operation == 1) { + i2c_dev->slave_event = I2C_SLAVE_EVENT_WRITE; +@@ -1389,7 +1474,6 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_RX_DOWN = %x\n",sts); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_RX_DOWN, I2C_INTR_STS_REG); + ast_i2c_master_xfer_done(i2c_dev); +- + } + break; + +@@ -1407,7 +1491,7 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + complete(&i2c_dev->cmd_complete); + } + break; +- case (AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_NORMAL_STOP): ++ case AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_NORMAL_STOP: + /* Whether or not we're done, the hardware thinks we're done, so bail. */ + if(i2c_dev->slave_operation == 0) { + dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_NORMAL_STOP = %x\n",sts); +@@ -1416,18 +1500,47 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + ast_i2c_write(i2c_dev, ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) | + AST_I2CD_RX_DOWN_INTR_EN, I2C_INTR_CTRL_REG); + ast_i2c_master_xfer_done(i2c_dev); +- } ++ } else { ++ dev_err(i2c_dev->dev, "S clear isr: AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_NORMAL_STOP = %x\n",sts); ++ i2c_dev->slave_event = I2C_SLAVE_EVENT_STOP; ++ ast_i2c_slave_xfer_done(i2c_dev); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_RX_DOWN | AST_I2CD_INTR_STS_NORMAL_STOP, I2C_INTR_STS_REG); ++ ast_i2c_write(i2c_dev, ast_i2c_read(i2c_dev,I2C_INTR_CTRL_REG) | ++ AST_I2CD_RX_DOWN_INTR_EN, I2C_INTR_CTRL_REG); ++ ast_i2c_master_xfer_done(i2c_dev); ++ } + break; + case AST_I2CD_INTR_STS_ARBIT_LOSS: +- dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_ARBIT_LOSS = %x\n",sts); ++ dev_err(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_ARBIT_LOSS = %x\n",sts); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_ARBIT_LOSS, I2C_INTR_STS_REG); + i2c_dev->cmd_err |= AST_I2CD_INTR_STS_ARBIT_LOSS; + complete(&i2c_dev->cmd_complete); + break; + case AST_I2CD_INTR_STS_SCL_TO: ++ dev_err(i2c_dev->dev, "SCL LOW detected with sts = %x, slave mode: %x\n",sts, i2c_dev->slave_operation); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SCL_TO, I2C_INTR_STS_REG); ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_SCL_TO; ++ complete(&i2c_dev->cmd_complete); ++ ++ // Reset i2c controller ++ temp = ast_i2c_read(i2c_dev,I2C_FUN_CTRL_REG); ++ ++ ast_i2c_write(i2c_dev, temp & ~(AST_I2CD_SLAVE_EN | AST_I2CD_MASTER_EN), I2C_FUN_CTRL_REG); ++ ++ ast_i2c_write(i2c_dev, temp, I2C_FUN_CTRL_REG); ++ break; ++ case AST_I2CD_INTR_STS_SLAVE_MATCH | AST_I2CD_INTR_STS_SCL_TO: ++ dev_err(i2c_dev->dev, "SCL LOW detected with sts = %x, slave mode: %x\n",sts, i2c_dev->slave_operation); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SCL_TO | AST_I2CD_INTR_STS_SLAVE_MATCH, I2C_INTR_STS_REG); + i2c_dev->cmd_err |= AST_I2CD_INTR_STS_SCL_TO; + complete(&i2c_dev->cmd_complete); + ++ // Reset i2c controller ++ temp = ast_i2c_read(i2c_dev,I2C_FUN_CTRL_REG); ++ ++ ast_i2c_write(i2c_dev, temp & ~(AST_I2CD_SLAVE_EN | AST_I2CD_MASTER_EN), I2C_FUN_CTRL_REG); ++ ++ ast_i2c_write(i2c_dev, temp, I2C_FUN_CTRL_REG); + break; + case AST_I2CD_INTR_STS_GCALL_ADDR: + i2c_dev->cmd_err |= AST_I2CD_INTR_STS_GCALL_ADDR; +@@ -1437,24 +1550,26 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + case AST_I2CD_INTR_STS_SMBUS_DEF_ADDR: + break; + case AST_I2CD_INTR_STS_SMBUS_DEV_ALT: +- + break; + + case AST_I2CD_INTR_STS_SMBUS_ARP_ADDR: + break; + case AST_I2CD_INTR_STS_SDA_DL_TO: ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SDA_DL_TO, I2C_INTR_STS_REG); ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_SDA_DL_TO; ++ complete(&i2c_dev->cmd_complete); + break; + case AST_I2CD_INTR_STS_BUS_RECOVER: +- dev_dbg(i2c_dev->dev, "M clear isr: AST_I2CD_INTR_STS_BUS_RECOVER= %x\n",sts); ++ dev_err(i2c_dev->dev, "Bus recover with sts= %x, slave mode: %x\n",sts, i2c_dev->slave_operation); + ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_BUS_RECOVER, I2C_INTR_STS_REG); + complete(&i2c_dev->cmd_complete); + break; + default: +- //TODO: Clearing this interrupt for now, but needs to cleanup this ISR function +- ast_i2c_write(i2c_dev, sts, I2C_INTR_STS_REG); ++ printk("GR %x : Status : %x, bus_id %d\n",i2c_dev->ast_i2c_data->reg_gr, sts, i2c_dev->bus_id); + + // Handle Arbitration Loss + if (sts & AST_I2CD_INTR_STS_ARBIT_LOSS) { ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_ARBIT_LOSS, I2C_INTR_STS_REG); + i2c_dev->cmd_err |= AST_I2CD_INTR_STS_ARBIT_LOSS; + complete(&i2c_dev->cmd_complete); + sts &= (~AST_I2CD_INTR_STS_ARBIT_LOSS); +@@ -1462,22 +1577,35 @@ static irqreturn_t i2c_ast_handler(int this_irq, void *dev_id) + + // Handle the write transaction ACK + if (sts & AST_I2CD_INTR_STS_TX_ACK) { ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_ACK, I2C_INTR_STS_REG); + ast_i2c_master_xfer_done(i2c_dev); +- complete(&i2c_dev->cmd_complete); + sts &= (~AST_I2CD_INTR_STS_TX_ACK); + } + ++ // Handle Normal Stop conditon ++ if (sts & AST_I2CD_INTR_STS_NORMAL_STOP) { ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_TX_ACK, I2C_INTR_STS_REG); ++ sts &= (~AST_I2CD_INTR_STS_NORMAL_STOP); ++ i2c_dev->cmd_err |= AST_I2CD_INTR_STS_NORMAL_STOP; ++ complete(&i2c_dev->cmd_complete); ++ } ++ + // Handle the Slave address match + if (sts & AST_I2CD_INTR_STS_SLAVE_MATCH) { + ast_i2c_slave_addr_match(i2c_dev); + sts &= (~AST_I2CD_INTR_STS_SLAVE_MATCH); ++ ast_i2c_write(i2c_dev, AST_I2CD_INTR_STS_SLAVE_MATCH, I2C_INTR_STS_REG); + } + ++ + // TODO: Debug print for any unhandled condition + if(sts) { + printk("GR %x : Status : %x, bus_id %d\n",i2c_dev->ast_i2c_data->reg_gr, sts, i2c_dev->bus_id); + } + ++ //TODO: Clearing this interrupt for now, but needs to cleanup this ISR function ++ ast_i2c_write(i2c_dev, sts, I2C_INTR_STS_REG); ++ + return IRQ_HANDLED; + } + +@@ -1492,16 +1620,25 @@ static int ast_i2c_do_msgs_xfer(struct ast_i2c_dev *i2c_dev, struct i2c_msg *msg + + spin_lock_irqsave(&i2c_dev->master_lock, flags); + +- //request +- if(i2c_dev->ast_i2c_data->master_dma == BYTE_MODE) ++ //request: update master_xfer_mode based on master_dma selection ++ if(i2c_dev->ast_i2c_data->master_dma == BYTE_MODE) { + i2c_dev->do_master_xfer = ast_i2c_do_byte_xfer; +- else if (i2c_dev->ast_i2c_data->master_dma == DMA_MODE) ++ i2c_dev->master_xfer_mode = BYTE_XFER; ++ i2c_dev->master_xfer_len = 1; ++ } else if (i2c_dev->ast_i2c_data->master_dma == DMA_MODE) { + i2c_dev->do_master_xfer = ast_i2c_do_dma_xfer; +- else { +- if(i2c_dev->ast_i2c_data->request_pool_buff_page(&(i2c_dev->req_page)) == 0) ++ i2c_dev->master_xfer_mode = DMA_XFER; ++ } else { ++ if(i2c_dev->ast_i2c_data->request_pool_buff_page(&(i2c_dev->req_page)) == 0) { + i2c_dev->do_master_xfer = ast_i2c_do_pool_xfer; +- else ++ i2c_dev->master_xfer_mode = BUFF_XFER; ++ } else { + i2c_dev->do_master_xfer = ast_i2c_do_byte_xfer; ++ dev_err(i2c_dev->dev, "i2cdriver: pool request failed for master\n"); ++ i2c_dev->master_xfer_mode = BYTE_XFER; ++ i2c_dev->master_xfer_len = 1; ++ ++ } + } + + // printk("start xfer ret = %d \n",ret); +@@ -1534,7 +1671,7 @@ static int ast_i2c_do_msgs_xfer(struct ast_i2c_dev *i2c_dev, struct i2c_msg *msg + i2c_dev->master_msgs = NULL; + + if (ret == 0) { +- dev_dbg(i2c_dev->dev, "controller timed out\n"); ++ dev_err(i2c_dev->dev, "controller timed out\n"); + i2c_dev->state = (ast_i2c_read(i2c_dev,I2C_CMD_REG) >> 19) & 0xf; + // printk("sts [%x], isr sts [%x] \n",i2c_dev->state, ast_i2c_read(i2c_dev,I2C_INTR_STS_REG)); + ret = -ETIMEDOUT; +@@ -1564,9 +1701,10 @@ static int ast_i2c_do_msgs_xfer(struct ast_i2c_dev *i2c_dev, struct i2c_msg *msg + + } + stop: +- init_completion(&i2c_dev->cmd_complete); + if(i2c_dev->cmd_err & AST_I2CD_INTR_STS_NORMAL_STOP) + goto out; ++ init_completion(&i2c_dev->cmd_complete); ++ i2c_dev->cmd_err = 0; + ast_i2c_write(i2c_dev, AST_I2CD_M_STOP_CMD, I2C_CMD_REG); + wait_for_completion_interruptible_timeout(&i2c_dev->cmd_complete, + i2c_dev->adap.timeout*HZ); +@@ -1605,7 +1743,7 @@ static int ast_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) + ret = ast_i2c_do_msgs_xfer(i2c_dev, msgs, num); + if (ret != -EAGAIN) + goto out; +- dev_dbg(&adap->dev, "Retrying transmission [%d]\n",i); ++ dev_dbg(&i2c_dev->adap.dev, "Retrying transmission [%d]\n",i); + udelay(100); + } + +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/net/ftgmac100_26.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/net/ftgmac100_26.c +index 3a5d796..f558d38 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/net/ftgmac100_26.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/net/ftgmac100_26.c +@@ -901,6 +901,41 @@ void Enable_Broadcast_Filter (struct net_device * dev) + lp->Retry = 0; + } + ++void Disable_Multicast_Filter (struct net_device * dev) ++{ ++ struct ftgmac100_priv *lp = (struct ftgmac100_priv *)dev->priv; ++ unsigned long Combined_Channel_ID; ++ struct sk_buff * skb; ++ ++ do { ++ skb = dev_alloc_skb (TX_BUF_SIZE + 16); ++ memset(skb->data, 0, TX_BUF_SIZE + 16); ++//TX ++ lp->InstanceID++; ++ lp->NCSI_Request.IID = lp->InstanceID; ++ lp->NCSI_Request.Command = DISABLE_GLOBAL_MULTICAST_FILTERING; ++ Combined_Channel_ID = (lp->NCSI_Cap.Package_ID << 5) + lp->NCSI_Cap.Channel_ID; ++ lp->NCSI_Request.Channel_ID = Combined_Channel_ID; ++ lp->NCSI_Request.Payload_Length = 0; ++ memcpy ((unsigned char *)skb->data, &lp->NCSI_Request, 30); ++ copy_data (dev, skb, lp->NCSI_Request.Payload_Length); ++ skb->len = 30 + lp->NCSI_Request.Payload_Length + 4; ++ ftgmac100_wait_to_send_packet (skb, dev); ++//RX ++ NCSI_Rx(dev); ++ if (((lp->NCSI_Respond.IID != lp->InstanceID) || (lp->NCSI_Respond.Command != (DISABLE_GLOBAL_MULTICAST_FILTERING | 0x80)) || (lp->NCSI_Respond.Response_Code != COMMAND_COMPLETED)) && (lp->Retry != RETRY_COUNT)) { ++ printk ("Retry: Command = %x, Response_Code = %x\n", lp->NCSI_Request.Command, lp->NCSI_Respond.Response_Code); ++ printk ("IID: %x:%x, Command: %x:%x\n", lp->InstanceID, lp->NCSI_Respond.IID, lp->NCSI_Request.Command, lp->NCSI_Respond.Command); ++ lp->Retry++; ++ lp->InstanceID--; ++ } ++ else { ++ lp->Retry = 0; ++ } ++ } while ((lp->Retry != 0) && (lp->Retry <= RETRY_COUNT)); ++ lp->Retry = 0; ++} ++ + void Disable_VLAN (struct net_device * dev) + { + struct ftgmac100_priv *lp = (struct ftgmac100_priv *)dev->priv; +@@ -1416,6 +1451,8 @@ static void ftgmac100_enable( struct net_device *dev ) + Enable_Set_MAC_Address(dev); + //Enable Broadcast Filter + Enable_Broadcast_Filter(dev); ++//Disable Multicast Filter ++ Disable_Multicast_Filter(dev); + //Disable VLAN + Disable_VLAN(dev); + //Enable AEN +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/serial/8250.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/serial/8250.c +index f16da59..d01c1c7 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/serial/8250.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/serial/8250.c +@@ -127,6 +127,11 @@ static unsigned long probe_rsa[PORT_RSA_MAX]; + static unsigned int probe_rsa_count; + #endif /* CONFIG_SERIAL_8250_RSA */ + ++struct rs485_wait_state { ++ int gpio; ++ int waiting; ++}; ++ + struct uart_8250_port { + struct uart_port port; + struct timer_list timer; /* "no irq" timer */ +@@ -156,6 +161,8 @@ struct uart_8250_port { + */ + void (*pm)(struct uart_port *port, + unsigned int state, unsigned int old); ++ ++ struct rs485_wait_state rs485_wait_state; + }; + + struct irq_info { +@@ -169,6 +176,9 @@ struct irq_info { + static struct hlist_head irq_lists[NR_IRQ_HASH]; + static DEFINE_MUTEX(hash_mutex); /* Used to walk the hash */ + ++#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) ++static void wait_for_xmitr(struct uart_8250_port *up, int bits); ++ + /* + * Here we define the default xmit fifo size used for each type of UART. + */ +@@ -530,6 +540,31 @@ static void serial_dl_write(struct uart_8250_port *up, int value) + #define serial_dl_write(up, value) _serial_dl_write(up, value) + #endif + ++// unfortunately it seems the gpio switch for RS485 can be late even with the ++// wait queue based wakeup of the task waiting on its completion, so we *have* ++// to do the gpio switch in the interrupt handler. ++static void rs485_wait_end(struct uart_8250_port *up) { ++ struct rs485_wait_state *rs485_wait_state = ++ &up->rs485_wait_state; ++ if (rs485_wait_state->waiting) { ++ int status; ++ status = serial_in(up, UART_LSR); ++ // no interrupt will be fire for shift register (TEMT) so we have to spin ++ // on it. ++ if (status & UART_LSR_THRE) { ++ wait_for_xmitr(up, BOTH_EMPTY); ++ // turn off RS485 DE pin ++ if (rs485_wait_state->gpio) ++ gpio_set_value(rs485_wait_state->gpio, 0); ++ // grab any phantom char seen on RX when transceiver switches ++ (void) serial_inp(up, UART_RX); ++ // enable read ++ up->port.ignore_status_mask &= ~UART_LSR_DR; ++ rs485_wait_state->waiting = 0; ++ } ++ } ++} ++ + /* + * For the 16C950 + */ +@@ -1235,6 +1270,7 @@ static inline void __stop_tx(struct uart_8250_port *p) + p->ier &= ~UART_IER_THRI; + serial_out(p, UART_IER, p->ier); + } ++ uart_write_wakeup(&p->port); + } + + static void serial8250_stop_tx(struct uart_port *port) +@@ -1436,7 +1472,7 @@ static unsigned int check_modem_status(struct uart_8250_port *up) + if (status & UART_MSR_DCTS) + uart_handle_cts_change(&up->port, status & UART_MSR_CTS); + +- wake_up_interruptible(&up->port.info->delta_msr_wait); ++ wake_up_interruptible(&up->port.info->delta_msr_wait); + } + + return status; +@@ -1462,6 +1498,7 @@ static void serial8250_handle_port(struct uart_8250_port *up) + if (status & UART_LSR_THRE) + transmit_chars(up); + ++ rs485_wait_end(up); + spin_unlock_irqrestore(&up->port.lock, flags); + } + +@@ -1777,8 +1814,6 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) + spin_unlock_irqrestore(&up->port.lock, flags); + } + +-#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) +- + /* + * Wait for transmitter & holding register to empty + */ +@@ -2539,8 +2574,13 @@ static int serial8250_ioctl(struct uart_port *port, unsigned int cmd, unsigned l + int ret = -ENOIOCTLCMD; + // kernel-space RS485 drain-and-switch hack + if (cmd == TIOCSERWAITTEMT) { +- // wait for kernel buffers and UART FIFO to both empty + struct circ_buf *xmit = &up->port.info->xmit; ++ spin_lock_irqsave(&up->port.lock, flags); ++ up->rs485_wait_state.gpio = arg; ++ up->rs485_wait_state.waiting = 1; ++ spin_unlock_irqrestore(&up->port.lock, flags); ++ ++ // wait for kernel buffers and UART FIFO to both empty + wait_event_interruptible( + thre_wait, + uart_circ_empty(xmit) && +@@ -2548,14 +2588,6 @@ static int serial8250_ioctl(struct uart_port *port, unsigned int cmd, unsigned l + // spin until TEMT (transmit shift register empty) + spin_lock_irqsave(&up->port.lock, flags); + wait_for_xmitr(up, BOTH_EMPTY); +- if (arg != 0) { +- // turn off RS485 DE pin +- gpio_set_value(arg, 0); +- } +- // grab any phantom char seen on RX when transceiver switches +- (void) serial_inp(up, UART_RX); +- // enable read +- up->port.ignore_status_mask &= ~UART_LSR_DR; + spin_unlock_irqrestore(&up->port.lock, flags); + return 0; + } +@@ -2607,6 +2639,8 @@ static void __init serial8250_isa_init_ports(void) + + init_timer(&up->timer); + up->timer.function = serial8250_timeout; ++ up->rs485_wait_state.waiting = 0; ++ up->rs485_wait_state.gpio = 0; + + /* + * ALPHA_KLUDGE_MCR needs to be killed. +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/usb/gadget/aspeed_udc.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/usb/gadget/aspeed_udc.c +index a65e52a..51cb34c 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/usb/gadget/aspeed_udc.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/usb/gadget/aspeed_udc.c +@@ -580,10 +580,10 @@ static void ep_dequeue_locked(struct ast_ep* ep, struct ast_usb_request *req) { + + static void ep_dequeue_all(struct ast_ep* ep, int status) { + struct ast_usb_request *req; +- struct ast_usb_request *n; + unsigned long flags; + spin_lock_irqsave(&ep->lock, flags); +- list_for_each_entry_safe(req, n, &ep->queue, queue) { ++ while (!list_empty(&ep->queue)) { ++ req = list_entry(ep->queue.next, struct ast_usb_request, queue); + ep_dequeue_locked(ep, req); + req->req.status = status; + if(req->req.complete) { +@@ -654,8 +654,14 @@ static void ep_txrx_check_done(struct ast_ep* ep) { + spin_lock_irqsave(&ep->lock, flags); + status = ep_hreadl(ep, DESC_STATUS); + // if txrx complete; +- if(!(status & 0xff) && +- !list_empty(&ep->queue)) { ++ if (!(status & 0xff)) { ++ /* DMA is done */ ++ ep->dma_busy = 0; ++ /* if the list is empty, nothing to do */ ++ if (list_empty(&ep->queue)) { ++ spin_unlock_irqrestore(&ep->lock, flags); ++ return; ++ } + req = list_entry(ep->queue.next, struct ast_usb_request, queue); + if(!req->in_transit) { + spin_unlock_irqrestore(&ep->lock, flags); +@@ -663,7 +669,6 @@ static void ep_txrx_check_done(struct ast_ep* ep) { + } + //head rq completed + req->in_transit = 0; +- ep->dma_busy = 0; + if(!ep->to_host) { + req->lastpacket = (status >> 16) & 0x3ff; + __cpuc_flush_kern_all(); +diff --git a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/watchdog/ast_wdt.c b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/watchdog/ast_wdt.c +index e599a55..cfe70a1 100644 +--- a/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/watchdog/ast_wdt.c ++++ b/meta-aspeed/recipes-kernel/linux/files/linux-aspeed-2.6.28.9/drivers/watchdog/ast_wdt.c +@@ -450,7 +450,7 @@ static int ast_wdt_open(struct inode *inode, struct file *file) + + static int ast_wdt_release(struct inode *inode, struct file *file) + { +- if (expect_close != 42 || !nowayout) ++ if (expect_close != 42 && !nowayout) + { + /* handles the case where the device is closed without the "magic + * close" character (anything that is not 'V' qualifies -- see the diff --git a/meta-aspeed/recipes-kernel/linux/linux-aspeed.inc b/meta-aspeed/recipes-kernel/linux/linux-aspeed.inc index a66c7e1..5e28e76 100644 --- a/meta-aspeed/recipes-kernel/linux/linux-aspeed.inc +++ b/meta-aspeed/recipes-kernel/linux/linux-aspeed.inc @@ -11,16 +11,22 @@ do_compile[depends] = "libgcc:do_populate_sysroot" inherit kernel # auto load the following modules -module_autoload_tun = "tun" -module_autoload_at24 = "at24" -module_autoload_ads7828 = "ads7828" -module_autoload_pcf8574 = "pcf8574" -module_autoload_max127 = "max127" +KERNEL_MODULE_AUTOLOAD += " \ + adm1275 \ + ads7828 \ + at24 \ + fb_panther_plus \ + max127 \ + pcf8574 \ + pfe1100 \ + pmbus_core \ + tun \ +" + +KERNEL_MODULE_PROBECONF += " \ + max127 \ +" module_conf_max127 = "options max127 scaling=24414" -module_autoload_pmbus_core = "pmbus_core" -module_autoload_pfe1100 = "pfe1100" -module_autoload_fb_panther_plus = "fb_panther_plus" -module_autoload_adm1275 = "adm1275" # Do not install kernel in rootfs do_install[postfuncs] += "remove_kernel_image_from_rootfs" diff --git a/meta-aspeed/recipes-kernel/linux/linux-aspeed_2.6.28.9.bb b/meta-aspeed/recipes-kernel/linux/linux-aspeed_2.6.28.9.bb index 9a76066..7798bab 100644 --- a/meta-aspeed/recipes-kernel/linux/linux-aspeed_2.6.28.9.bb +++ b/meta-aspeed/recipes-kernel/linux/linux-aspeed_2.6.28.9.bb @@ -3,7 +3,7 @@ SRCREV = "1e85856853e24e9013d142adaad38c2adc7e48ac" SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;protocol=https;branch=linux-2.6.28.y \ - file://patch-2.6.28.9/0000-linux-aspeed-064.patch \ + file://patch-2.6.28.9/0000-linux-aspeed-064.patch;striplevel=1 \ file://patch-2.6.28.9/0000-linux-openbmc.patch \ file://patch-2.6.28.9/0001-MTD-fix-m25p80-64-bit-divisions.patch \ file://patch-2.6.28.9/0005-mtd-Bug-in-m25p80.c-during-whole-chip-erase.patch \ @@ -23,28 +23,37 @@ SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git file://patch-2.6.28.9/0001-bzip2-lzma-library-support-for-gzip-bzip2-and-lzma-d.patch \ file://patch-2.6.28.9/0002-bzip2-lzma-config-and-initramfs-support-for-bzip2-lz.patch \ file://patch-2.6.28.9/0032-Create-snapshot-of-OpenBMC.patch \ + file://patch-2.6.28.9/0033-Linux-snapshot-of-OpenBMC-f926614.patch;striplevel=6 \ " -S = "${WORKDIR}/git" - LINUX_VERSION ?= "2.6.28.9" LINUX_VERSION_EXTENSION ?= "-aspeed" PR = "r1" PV = "${LINUX_VERSION}" +include linux-aspeed.inc + +S = "${WORKDIR}/git" + # Install bounds.h for external module install # The default install script handles this. However, it looks for bounds.h from # 'include/generated', which doesnot match 2.6.28, where the file is in # 'include/linux'. -do_install[postfuncs] += "install_bounds_h" -install_bounds_h() { - kerneldir=${D}${KERNEL_SRC_PATH} - if [ -f include/linux/bounds.h ]; then - cp -l include/linux/bounds.h $kerneldir/include/linux/bounds.h - fi +addtask create_generated after do_compile before do_shared_workdir +do_create_generated() { + install -d ${B}/include/generated + cp -l ${B}/include/linux/bounds.h ${B}/include/generated/bounds.h } -KERNEL_CONFIG_COMMAND = "oe_runmake wedge_defconfig && oe_runmake oldconfig" +# With Fido, ${KERNEL_SRC} is set to ${STAGING_KERENL_DIR}, which is passed +# to kernel module build. So, copy all .h files from the build direcory to +# the ${STAGING_KERNEL_DIR} +addtask copy_to_kernelsrc after do_shared_workdir before do_compile_kernelmodules +do_copy_to_kernelsrc() { + kerneldir=${STAGING_KERNEL_DIR}/include/linux + install -d ${kerneldir} + cp -l ${B}/include/linux/* ${kerneldir}/ +} -include linux-aspeed.inc +KERNEL_CC += " --sysroot=${PKG_CONFIG_SYSROOT_DIR}" diff --git a/meta-aspeed/recipes-utils/openbmc-gpio/files/ast2400_gpio_table.py b/meta-aspeed/recipes-utils/openbmc-gpio/files/ast2400_gpio_table.py new file mode 100644 index 0000000..68d4203 --- /dev/null +++ b/meta-aspeed/recipes-utils/openbmc-gpio/files/ast2400_gpio_table.py @@ -0,0 +1,1022 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from openbmc_gpio_table import ( + BitsEqual, BitsNotEqual, And, Or, Function) + + +# The fallowing table is generated using: +# python ast_gpio_parser.py data/ast2400-gpio.csv +# DO NOT MODIFY THE TABLE!!! +# Manual modification will be overridden!!! + +soc_gpio_table = { + 'A1': [ + Function('SD1WP#', BitsEqual(0x90, [0], 0x1)), + Function('SDA13', BitsEqual(0x90, [26], 0x1)), + Function('GPIOC7', None) + ], + 'A10': [ + Function('GPIOU0', BitsEqual(0xa0, [8], 0x1)), + Function('RMII2TXD0', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2TXD0', None) + ], + 'A11': [ + Function('GPIOV0', BitsEqual(0xa0, [16], 0x1)), + Function('RMII1CRSDV', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1RXD2', None) + ], + 'A12': [ + Function('GPIOT0', BitsEqual(0xa0, [0], 0x1)), + Function('RMII1TXEN', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1TXCK', None) + ], + 'A13': [ + Function('GPIOT5', BitsEqual(0xa0, [5], 0x1)), + Function('UNDEFINED5', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1TXD3', None) + ], + 'A14': [ + Function('SGPSCK', BitsEqual(0x84, [0], 0x1)), + Function('GPIOG0', None) + ], + 'A15': [ + Function('NRI3', BitsEqual(0x80, [19], 0x1)), + Function('GPIE2(Out)', Or(BitsEqual(0x8c, [13], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE3', None) + ], + 'A16': [ + Function('SD2CD#', BitsEqual(0x90, [1], 0x1)), + Function('GPID6(In)', Or(BitsEqual(0x8c, [11], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD6', None) + ], + 'A17': [ + Function('SD2DAT1', BitsEqual(0x90, [1], 0x1)), + Function('GPID2(Out)', Or(BitsEqual(0x8c, [9], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD3', None) + ], + 'A18': [ + Function('SD2CLK', BitsEqual(0x90, [1], 0x1)), + Function('GPID0(In)', Or(BitsEqual(0x8c, [8], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD0', None) + ], + 'A19': [ + Function('NRTS4', BitsEqual(0x80, [29], 0x1)), + Function('SIOSCI#', Or(BitsEqual(0xa4, [15], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOF5', None) + ], + 'A2': [ + Function('SD1DAT0', BitsEqual(0x90, [0], 0x1)), + Function('SCL11', BitsEqual(0x90, [24], 0x1)), + Function('GPIOC2', None) + ], + 'A20': [ + Function('NDSR4', BitsEqual(0x80, [26], 0x1)), + Function('SIOPWRGD', Or(BitsEqual(0xa4, [13], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOF2', None) + ], + 'A3': [ + Function('MDC2', BitsEqual(0x90, [2], 0x1)), + Function('TIMER7', BitsEqual(0x80, [6], 0x1)), + Function('GPIOA6', None) + ], + 'A4': [ + Function('TIMER3', BitsEqual(0x80, [2], 0x1)), + Function('GPIOA2', None) + ], + 'A5': [ + Function('MDIO1', BitsEqual(0x88, [31], 0x1)), + Function('GPIOR7', None) + ], + 'A6': [ + Function('ROMD14', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('TXD6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH6', None) + ], + 'A7': [ + Function('ROMD11', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('NRI6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH3', None) + ], + 'A8': [ + Function('ROMD8', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('NCTS6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH0', None) + ], + 'A9': [ + Function('GPIOV4', BitsEqual(0xa0, [20], 0x1)), + Function('RMII2RXD0', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2RXD0', None) + ], + 'AA1': [ + Function('VPIB8', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [30], 0x1))), + Function('TXD2', BitsEqual(0x84, [30], 0x1)), + Function('GPIOM6', None) + ], + 'AA2': [ + Function('VPIG2', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x88, [2], 0x1))), + Function('PWM2', BitsEqual(0x88, [2], 0x1)), + Function('GPION2', None) + ], + 'AA22': [ + Function('FLBUSY#', BitsEqual(0x84, [6], 0x1)), + Function('GPIOG6', None) + ], + 'AA3': [ + Function('VPIG6', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [6], 0x1))), + Function('PWM6', BitsEqual(0x88, [6], 0x1)), + Function('GPION6', None) + ], + 'AA4': [ + Function('VPIR0', And(BitsEqual(0x90, [5, 4], 0x3), BitsEqual(0x88, [10], 0x1))), + Function('GPIOO2/TACH2', None) + ], + 'AA5': [ + Function('VPIR3', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [13], 0x1))), + Function('GPIOO5/TACH5', None) + ], + 'AA6': [ + Function('VPIR9', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [19], 0x1))), + Function('GPIOP3/TACH11', None) + ], + 'AA7': [ + Function('BMCINT', BitsEqual(0x88, [22], 0x1)), + Function('GPIOP6/TACH14', None) + ], + 'AB1': [ + Function('VPIG3', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x88, [3], 0x1))), + Function('PWM3', BitsEqual(0x88, [3], 0x1)), + Function('GPION3', None) + ], + 'AB2': [ + Function('VPIG7', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [7], 0x1))), + Function('PWM7', BitsEqual(0x88, [7], 0x1)), + Function('GPION7', None) + ], + 'AB20': [ + Function('USB2_HDN', BitsEqual(0x90, [29], 0x1)), + Function('USB2_DN', None) + ], + 'AB21': [ + Function('USB2_HDP', BitsEqual(0x90, [29], 0x1)), + Function('USB2_DP', None) + ], + 'AB3': [ + Function('VPIR1', And(BitsEqual(0x90, [5, 4], 0x3), BitsEqual(0x88, [11], 0x1))), + Function('GPIOO3/TACH3', None) + ], + 'AB4': [ + Function('VPIR4', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [14], 0x1))), + Function('GPIOO6/TACH6', None) + ], + 'AB5': [ + Function('VPIR7', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [17], 0x1))), + Function('GPIOP1/TACH9', None) + ], + 'AB7': [ + Function('FLACK', BitsEqual(0x88, [23], 0x1)), + Function('GPIOP7/TACH15', None) + ], + 'B1': [ + Function('SCL4', BitsEqual(0x90, [17], 0x1)), + Function('GPIOQ2', None) + ], + 'B10': [ + Function('GPIOU1', BitsEqual(0xa0, [9], 0x1)), + Function('RMII2TXD1', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2TXD1', None) + ], + 'B11': [ + Function('GPIOU7', BitsEqual(0xa0, [15], 0x1)), + Function('RMII1RXD1', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1RXD1', None) + ], + 'B12': [ + Function('GPIOT1', BitsEqual(0xa0, [1], 0x1)), + Function('UNDEFINED3', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1TXCTL', None) + ], + 'B13': [ + Function('OSCCLK', BitsEqual(0x2c, [1], 0x1)), + Function('WDTRST1', BitsEqual(0x84, [4], 0x1)), + Function('GPIOG4', None) + ], + 'B14': [ + Function('RXD3', BitsEqual(0x80, [23], 0x1)), + Function('GPIE6(Out)', Or(BitsEqual(0x8c, [15], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE7', None) + ], + 'B15': [ + Function('NDSR3', BitsEqual(0x80, [18], 0x1)), + Function('GPIE2(In)', Or(BitsEqual(0x8c, [13], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE2', None) + ], + 'B16': [ + Function('SD2DAT3', BitsEqual(0x90, [1], 0x1)), + Function('GPID4(Out)', Or(BitsEqual(0x8c, [10], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD5', None) + ], + 'B17': [ + Function('SD2DAT0', BitsEqual(0x90, [1], 0x1)), + Function('GPID2(In)', Or(BitsEqual(0x8c, [9], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD2', None) + ], + 'B18': [ + Function('NDTR4', BitsEqual(0x80, [28], 0x1)), + Function('GPIOF4', None) + ], + 'B19': [ + Function('NDCD4', BitsEqual(0x80, [25], 0x1)), + Function('SIOPBI#', Or(BitsEqual(0xa4, [12], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOF1', None) + ], + 'B2': [ + Function('SD1CD#', BitsEqual(0x90, [0], 0x1)), + Function('SCL13', BitsEqual(0x90, [26], 0x1)), + Function('GPIOC6', None) + ], + 'B22': [ + Function('SPICS0#', BitsNotEqual(0x70, [13, 12], 0x0)), + Function('VBCS#', BitsEqual(0x70, [5], 0x1)), + Function('GPIOI4', None) + ], + 'B3': [ + Function('SD1CMD', BitsEqual(0x90, [0], 0x1)), + Function('SDA10', BitsEqual(0x90, [23], 0x1)), + Function('GPIOC1', None) + ], + 'B4': [ + Function('SDA9', BitsEqual(0x90, [22], 0x1)), + Function('TIMER6', BitsEqual(0x80, [5], 0x1)), + Function('GPIOA5', None) + ], + 'B5': [ + Function('MAC2LINK', BitsEqual(0x80, [1], 0x1)), + Function('GPIOA1', None) + ], + 'B6': [ + Function('ROMD13', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('NRTS6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH5', None) + ], + 'B7': [ + Function('ROMD10', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('NDSR6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH2', None) + ], + 'B9': [ + Function('GPIOV3', BitsEqual(0xa0, [19], 0x1)), + Function('UNDEFINED10', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2RXCTL', None) + ], + 'C1': [ + Function('SCL6', BitsEqual(0x90, [19], 0x1)), + Function('GPIOK2', None) + ], + 'C10': [ + Function('GPIOU2', BitsEqual(0xa0, [10], 0x1)), + Function('UNDEFINED7', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2TXD2', None) + ], + 'C11': [ + Function('GPIOU6', BitsEqual(0xa0, [14], 0x1)), + Function('RMII1RXD0', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1RXD0', None) + ], + 'C12': [ + Function('GPIOT2', BitsEqual(0xa0, [2], 0x1)), + Function('RMII1TXD0', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1TXD0', None) + ], + 'C13': [ + Function('SGPSI1', BitsEqual(0x84, [3], 0x1)), + Function('GPIOG3', None) + ], + 'C14': [ + Function('TXD3', BitsEqual(0x80, [22], 0x1)), + Function('GPIE6(In)', Or(BitsEqual(0x8c, [15], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE6', None) + ], + 'C15': [ + Function('NDCD3', BitsEqual(0x80, [17], 0x1)), + Function('GPIE0(Out)', Or(BitsEqual(0x8c, [12], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE1', None) + ], + 'C16': [ + Function('SD2DAT2', BitsEqual(0x90, [1], 0x1)), + Function('GPID4(In)', Or(BitsEqual(0x8c, [10], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD4', None) + ], + 'C17': [ + Function('RXD4', BitsEqual(0x80, [31], 0x1)), + Function('GPIOF7', None) + ], + 'C18': [ + Function('SPIDO', BitsNotEqual(0x70, [13, 12], 0x0)), + Function('VBDO', BitsEqual(0x70, [5], 0x1)), + Function('GPIOI6', None) + ], + 'C2': [ + Function('SDA3', BitsEqual(0x90, [16], 0x1)), + Function('GPIOQ1', None) + ], + 'C20': [ + Function('SYSDI', BitsEqual(0x70, [13], 0x1)), + Function('GPIOI3', None) + ], + 'C21': [ + Function('SIOS3#', Or(BitsEqual(0xa4, [8], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOY0', None) + ], + 'C22': [ + Function('SYSCS#', BitsEqual(0x70, [13], 0x1)), + Function('GPIOI0', None) + ], + 'C3': [ + Function('SD1DAT3', BitsEqual(0x90, [0], 0x1)), + Function('SDA12', BitsEqual(0x90, [25], 0x1)), + Function('GPIOC5', None) + ], + 'C4': [ + Function('SD1CLK', BitsEqual(0x90, [0], 0x1)), + Function('SCL10', BitsEqual(0x90, [23], 0x1)), + Function('GPIOC0', None) + ], + 'C5': [ + Function('SCL9', BitsEqual(0x90, [22], 0x1)), + Function('TIMER5', BitsEqual(0x80, [4], 0x1)), + Function('GPIOA4', None) + ], + 'C6': [ + Function('MDC1', BitsEqual(0x88, [30], 0x1)), + Function('GPIOR6', None) + ], + 'C7': [ + Function('ROMD9', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('NDCD6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH1', None) + ], + 'C8': [ + Function('GPIOV7', BitsEqual(0xa0, [23], 0x1)), + Function('RMII2RXER', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2RXD3', None) + ], + 'C9': [ + Function('GPIOV2', BitsEqual(0xa0, [18], 0x1)), + Function('RMII2RCLK', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2RXCK', None) + ], + 'D1': [ + Function('SDA7', BitsEqual(0x90, [20], 0x1)), + Function('GPIOK5', None) + ], + 'D10': [ + Function('GPIOU3', BitsEqual(0xa0, [11], 0x1)), + Function('UNDEFINED8', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2TXD3', None) + ], + 'D11': [ + Function('GPIOU5', BitsEqual(0xa0, [13], 0x1)), + Function('UNDEFINED9', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1RXCTL', None) + ], + 'D12': [ + Function('GPIOT3', BitsEqual(0xa0, [3], 0x1)), + Function('RMII1TXD1', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1TXD1', None) + ], + 'D13': [ + Function('SGPSI0', BitsEqual(0x84, [2], 0x1)), + Function('GPIOG2', None) + ], + 'D14': [ + Function('NRTS3', BitsEqual(0x80, [21], 0x1)), + Function('GPIE4(Out)', Or(BitsEqual(0x8c, [14], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE5', None) + ], + 'D15': [ + Function('NCTS3', BitsEqual(0x80, [16], 0x1)), + Function('GPIE0(In)', Or(BitsEqual(0x8c, [12], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE0', None) + ], + 'D16': [ + Function('SD2CMD', BitsEqual(0x90, [1], 0x1)), + Function('GPID0(Out)', Or(BitsEqual(0x8c, [8], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD1', None) + ], + 'D17': [ + Function('NRI4', BitsEqual(0x80, [27], 0x1)), + Function('SIOPBO#', Or(BitsEqual(0xa4, [14], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOF3', None) + ], + 'D18': [ + Function('NCTS4', BitsEqual(0x80, [24], 0x1)), + Function('GPIOF0', None) + ], + 'D19': [ + Function('SYSDO', BitsEqual(0x70, [13], 0x1)), + Function('GPIOI2', None) + ], + 'D2': [ + Function('SDA5', BitsEqual(0x90, [18], 0x1)), + Function('GPIOK1', None) + ], + 'D3': [ + Function('SCL3', BitsEqual(0x90, [16], 0x1)), + Function('GPIOQ0', None) + ], + 'D4': [ + Function('SD1DAT2', BitsEqual(0x90, [0], 0x1)), + Function('SCL12', BitsEqual(0x90, [25], 0x1)), + Function('GPIOC4', None) + ], + 'D5': [ + Function('MDIO2', BitsEqual(0x90, [2], 0x1)), + Function('TIMER8', BitsEqual(0x80, [7], 0x1)), + Function('GPIOA7', None) + ], + 'D6': [ + Function('MAC1LINK', BitsEqual(0x80, [0], 0x1)), + Function('GPIOA0', None) + ], + 'D7': [ + Function('ROMD12', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('NDTR6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH4', None) + ], + 'D8': [ + Function('GPIOV6', BitsEqual(0xa0, [22], 0x1)), + Function('RMII2CRSDV', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2RXD2', None) + ], + 'D9': [ + Function('GPIOT6', BitsEqual(0xa0, [6], 0x1)), + Function('RMII2TXEN', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2TXCK', None) + ], + 'E10': [ + Function('GPIOV1', BitsEqual(0xa0, [17], 0x1)), + Function('RMII1RXER', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1RXD3', None) + ], + 'E11': [ + Function('GPIOU4', BitsEqual(0xa0, [12], 0x1)), + Function('RMII1RCLK', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1RXCK', None) + ], + 'E12': [ + Function('GPIOT4', BitsEqual(0xa0, [4], 0x1)), + Function('UNDEFINED4', BitsEqual(0x70, [6], 0x0)), + Function('RGMII1TXD2', None) + ], + 'E13': [ + Function('SGPSLD', BitsEqual(0x84, [1], 0x1)), + Function('GPIOG1', None) + ], + 'E14': [ + Function('NDTR3', BitsEqual(0x80, [20], 0x1)), + Function('GPIE4(In)', Or(BitsEqual(0x8c, [14], 0x1), BitsEqual(0x70, [22], 0x1))), + Function('GPIOE4', None) + ], + 'E15': [ + Function('SD2WP#', BitsEqual(0x90, [1], 0x1)), + Function('GPID6(Out)', Or(BitsEqual(0x8c, [11], 0x1), BitsEqual(0x70, [21], 0x1))), + Function('GPIOD7', None) + ], + 'E16': [ + Function('TXD4', BitsEqual(0x80, [30], 0x1)), + Function('GPIOF6', None) + ], + 'E18': [ + Function('EXTRST#', And(BitsEqual(0x80, [15], 0x1), And(BitsEqual(0x90, [31], 0x0), BitsEqual(0x3c, [3], 0x1)))), + Function('SPICS1#', And(BitsEqual(0x80, [15], 0x1), BitsEqual(0x90, [31], 0x1))), + Function('GPIOB7', None) + ], + 'E19': [ + Function('LPCRST#', Or(BitsEqual(0x80, [12], 0x1), BitsEqual(0x70, [14], 0x1))), + Function('GPIOB4', None) + ], + 'E2': [ + Function('SCL7', BitsEqual(0x90, [20], 0x1)), + Function('GPIOK4', None) + ], + 'E20': [ + Function('SPIDI', BitsNotEqual(0x70, [13, 12], 0x0)), + Function('VBDI', BitsEqual(0x70, [5], 0x1)), + Function('GPIOI7', None) + ], + 'E3': [ + Function('SCL5', BitsEqual(0x90, [18], 0x1)), + Function('GPIOK0', None) + ], + 'E5': [ + Function('SD1DAT1', BitsEqual(0x90, [0], 0x1)), + Function('SDA11', BitsEqual(0x90, [24], 0x1)), + Function('GPIOC3', None) + ], + 'E6': [ + Function('TIMER4', BitsEqual(0x80, [3], 0x1)), + Function('GPIOA3', None) + ], + 'E7': [ + Function('ROMD15', Or(BitsEqual(0x90, [6], 0x1), BitsEqual(0x70, [4, 1, 0], 0x4))), + Function('RXD6', BitsEqual(0x90, [7], 0x1)), + Function('GPIOH7', None) + ], + 'E8': [ + Function('GPIOV5', BitsEqual(0xa0, [21], 0x1)), + Function('RMII2RXD1', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2RXD1', None) + ], + 'E9': [ + Function('GPIOT7', BitsEqual(0xa0, [7], 0x1)), + Function('UNDEFINED6', BitsEqual(0x70, [7], 0x0)), + Function('RGMII2TXCTL', None) + ], + 'F18': [ + Function('SALT4', BitsEqual(0x80, [11], 0x1)), + Function('GPIOB3', None) + ], + 'F20': [ + Function('SIOS5#', Or(BitsEqual(0xa4, [9], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOY1', None) + ], + 'F3': [ + Function('SDA8', BitsEqual(0x90, [21], 0x1)), + Function('GPIOK7', None) + ], + 'F4': [ + Function('SDA6', BitsEqual(0x90, [19], 0x1)), + Function('GPIOK3', None) + ], + 'F5': [ + Function('SDA4', BitsEqual(0x90, [17], 0x1)), + Function('GPIOQ3', None) + ], + 'G18': [ + Function('SYSCK', BitsEqual(0x70, [13], 0x1)), + Function('GPIOI1', None) + ], + 'G19': [ + Function('SPICK', BitsNotEqual(0x70, [13, 12], 0x0)), + Function('VBCK', BitsEqual(0x70, [5], 0x1)), + Function('GPIOI5', None) + ], + 'G20': [ + Function('SIOPWREQ#', Or(BitsEqual(0xa4, [10], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOY2', None) + ], + 'G5': [ + Function('SCL8', BitsEqual(0x90, [21], 0x1)), + Function('GPIOK6', None) + ], + 'H1': [ + Function('UNDEFINED2', BitsEqual(0x90, [28], 0x1)), + Function('GPIOQ7', None) + ], + 'H18': [ + Function('SALT3', BitsEqual(0x80, [10], 0x1)), + Function('GPIOB2', None) + ], + 'H2': [ + Function('UNDEFINED1', BitsEqual(0x90, [28], 0x1)), + Function('GPIOQ6', None) + ], + 'H20': [ + Function('LPCPME#', BitsEqual(0x80, [14], 0x1)), + Function('GPIOB6', None) + ], + 'H3': [ + Function('SDA14', BitsEqual(0x90, [27], 0x1)), + Function('GPIOQ5', None) + ], + 'H4': [ + Function('SCL14', BitsEqual(0x90, [27], 0x1)), + Function('GPIOQ4', None) + ], + 'J20': [ + Function('SALT2', BitsEqual(0x80, [9], 0x1)), + Function('GPIOB1', None) + ], + 'J21': [ + Function('SALT1', BitsEqual(0x80, [8], 0x1)), + Function('GPIOB0', None) + ], + 'J3': [ + Function('SGPMI', BitsEqual(0x84, [11], 0x1)), + Function('GPIOJ3', None) + ], + 'J4': [ + Function('SGPMLD', BitsEqual(0x84, [9], 0x1)), + Function('GPIOJ1', None) + ], + 'J5': [ + Function('SGPMCK', BitsEqual(0x84, [8], 0x1)), + Function('GPIOJ0', None) + ], + 'K18': [ + Function('ROMA23', And(BitsEqual(0x8c, [7], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR5', And(BitsEqual(0x8c, [7], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOS7', None) + ], + 'K20': [ + Function('SIOONCTRL#', Or(BitsEqual(0xa4, [11], 0x1), BitsEqual(0x70, [19], 0x0))), + Function('GPIOY3', None) + ], + 'K3': [ + Function('UB11_HDN2', BitsEqual(0x90, [3], 0x1)), + Function('UB11_DN', None) + ], + 'K4': [ + Function('UB11_HDP2', BitsEqual(0x90, [3], 0x1)), + Function('UB11_DP', None) + ], + 'K5': [ + Function('SGPMO', BitsEqual(0x84, [10], 0x1)), + Function('GPIOJ2', None) + ], + 'L1': [ + Function('GPIW4', BitsEqual(0xa0, [28], 0x1)), + Function('ADC4', None) + ], + 'L18': [ + Function('ROMA10', And(BitsEqual(0xa4, [24], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOG0', And(BitsEqual(0xa4, [24], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOAA0', None) + ], + 'L19': [ + Function('ROMA11', And(BitsEqual(0xa4, [25], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOG1', And(BitsEqual(0xa4, [25], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOAA1', None) + ], + 'L2': [ + Function('GPIW3', BitsEqual(0xa0, [27], 0x1)), + Function('ADC3', None) + ], + 'L20': [ + Function('ROMA12', And(BitsEqual(0xa4, [26], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOG2', And(BitsEqual(0xa4, [26], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOAA2', None) + ], + 'L21': [ + Function('ROMA13', And(BitsEqual(0xa4, [27], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOG3', And(BitsEqual(0xa4, [27], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOAA3', None) + ], + 'L22': [ + Function('ROMA22', And(BitsEqual(0x8c, [6], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR4', And(BitsEqual(0x8c, [6], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOS6', None) + ], + 'L3': [ + Function('GPIW2', BitsEqual(0xa0, [26], 0x1)), + Function('ADC2', None) + ], + 'L4': [ + Function('GPIW1', BitsEqual(0xa0, [25], 0x1)), + Function('ADC1', None) + ], + 'L5': [ + Function('GPIW0', BitsEqual(0xa0, [24], 0x1)), + Function('ADC0', None) + ], + 'M1': [ + Function('GPIX1', BitsEqual(0xa4, [1], 0x1)), + Function('ADC9', None) + ], + 'M18': [ + Function('ROMA19', And(BitsEqual(0xa8, [1], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR1', And(BitsEqual(0xa8, [1], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAB1', None) + ], + 'M19': [ + Function('ROMA17', And(BitsEqual(0xa4, [31], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOG7', And(BitsEqual(0xa4, [31], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAA7', None) + ], + 'M2': [ + Function('GPIX0', BitsEqual(0xa4, [0], 0x1)), + Function('ADC8', None) + ], + 'M20': [ + Function('ROMA18', And(BitsEqual(0xa8, [0], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR0', And(BitsEqual(0xa8, [0], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAB0', None) + ], + 'M21': [ + Function('ROMA8', And(BitsEqual(0xa4, [22], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB6', And(BitsEqual(0xa4, [22], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ6', None) + ], + 'M22': [ + Function('ROMA9', And(BitsEqual(0xa4, [23], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB7', And(BitsEqual(0xa4, [23], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ7', None) + ], + 'M3': [ + Function('GPIW7', BitsEqual(0xa0, [31], 0x1)), + Function('ADC7', None) + ], + 'M4': [ + Function('GPIW6', BitsEqual(0xa0, [30], 0x1)), + Function('ADC6', None) + ], + 'M5': [ + Function('GPIW5', BitsEqual(0xa0, [29], 0x1)), + Function('ADC5', None) + ], + 'N1': [ + Function('GPIX6', BitsEqual(0xa4, [6], 0x1)), + Function('ADC14', None) + ], + 'N18': [ + Function('ROMA15', And(BitsEqual(0xa4, [29], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOG5', And(BitsEqual(0xa4, [29], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAA5', None) + ], + 'N19': [ + Function('ROMA16', And(BitsEqual(0xa4, [30], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOG6', And(BitsEqual(0xa4, [30], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAA6', None) + ], + 'N2': [ + Function('GPIX5', BitsEqual(0xa4, [5], 0x1)), + Function('ADC13', None) + ], + 'N20': [ + Function('ROMA21', And(BitsEqual(0xa8, [3], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR3', And(BitsEqual(0xa8, [3], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAB3', None) + ], + 'N21': [ + Function('ROMWE#', BitsEqual(0x8c, [5], 0x1)), + Function('GPIOS5', None) + ], + 'N22': [ + Function('ROMA20', And(BitsEqual(0xa8, [2], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR2', And(BitsEqual(0xa8, [2], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAB2', None) + ], + 'N3': [ + Function('GPIX4', BitsEqual(0xa4, [4], 0x1)), + Function('ADC12', None) + ], + 'N4': [ + Function('GPIX3', BitsEqual(0xa4, [3], 0x1)), + Function('ADC11', None) + ], + 'N5': [ + Function('GPIX2', BitsEqual(0xa4, [2], 0x1)), + Function('ADC10', None) + ], + 'P18': [ + Function('ROMA3', And(BitsEqual(0xa4, [17], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB1', And(BitsEqual(0xa4, [17], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ1', None) + ], + 'P19': [ + Function('ROMA4', And(BitsEqual(0xa4, [18], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB2', And(BitsEqual(0xa4, [18], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ2', None) + ], + 'P20': [ + Function('ROMA5', And(BitsEqual(0xa4, [19], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB3', And(BitsEqual(0xa4, [19], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ3', None) + ], + 'P21': [ + Function('ROMA6', And(BitsEqual(0xa4, [20], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB4', And(BitsEqual(0xa4, [20], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ4', None) + ], + 'P22': [ + Function('ROMA7', And(BitsEqual(0xa4, [21], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB5', And(BitsEqual(0xa4, [21], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ5', None) + ], + 'P5': [ + Function('GPIX7', BitsEqual(0xa4, [7], 0x1)), + Function('ADC15', None) + ], + 'R18': [ + Function('ROMOE#', BitsEqual(0x8c, [4], 0x1)), + Function('GPIOS4', None) + ], + 'R22': [ + Function('ROMA2', And(BitsEqual(0xa4, [16], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOB0', And(BitsEqual(0xa4, [16], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOZ0', None) + ], + 'T1': [ + Function('DDCDAT', BitsEqual(0x84, [15], 0x1)), + Function('GPIOJ7', None) + ], + 'T18': [ + Function('ROMA14', And(BitsEqual(0xa4, [28], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOG4', And(BitsEqual(0xa4, [28], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOAA4', None) + ], + 'T19': [ + Function('ROMD5', And(BitsEqual(0x8c, [1], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOHS', And(BitsEqual(0x8c, [1], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOS1', None) + ], + 'T2': [ + Function('DDCCLK', BitsEqual(0x84, [14], 0x1)), + Function('GPIOJ6', None) + ], + 'T4': [ + Function('VGAHS', BitsEqual(0x84, [12], 0x1)), + Function('GPIOJ4', None) + ], + 'T5': [ + Function('VPIDE', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [17], 0x1))), + Function('NDCD1', BitsEqual(0x84, [17], 0x1)), + Function('GPIOL1', None) + ], + 'U1': [ + Function('NCTS1', BitsEqual(0x84, [16], 0x1)), + Function('GPIOL0', None) + ], + 'U18': [ + Function('FLWP#', BitsEqual(0x84, [7], 0x1)), + Function('GPIOG7', None) + ], + 'U19': [ + Function('ROMCS4#', BitsEqual(0x88, [27], 0x1)), + Function('GPIOR3', None) + ], + 'U2': [ + Function('VGAVS', BitsEqual(0x84, [13], 0x1)), + Function('GPIOJ5', None) + ], + 'U20': [ + Function('ROMD7', And(BitsEqual(0x8c, [3], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOCLK', And(BitsEqual(0x8c, [3], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOS3', None) + ], + 'U21': [ + Function('ROMD4', And(BitsEqual(0x8c, [0], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPODE', And(BitsEqual(0x8c, [0], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOS0', None) + ], + 'U3': [ + Function('VPIODD', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [18], 0x1))), + Function('NDSR1', BitsEqual(0x84, [18], 0x1)), + Function('GPIOL2', None) + ], + 'U4': [ + Function('VPIVS', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [20], 0x1))), + Function('NDTR1', BitsEqual(0x84, [20], 0x1)), + Function('GPIOL4', None) + ], + 'U5': [ + Function('VPIB1', And(BitsEqual(0x90, [5, 4], 0x3), BitsEqual(0x84, [23], 0x1))), + Function('RXD1', BitsEqual(0x84, [23], 0x1)), + Function('GPIOL7', None) + ], + 'V1': [ + Function('VPIHS', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [19], 0x1))), + Function('NRI1', BitsEqual(0x84, [19], 0x1)), + Function('GPIOL3', None) + ], + 'V2': [ + Function('VPICLK', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [21], 0x1))), + Function('NRTS1', BitsEqual(0x84, [21], 0x1)), + Function('GPIOL5', None) + ], + 'V20': [ + Function('ROMCS1#', BitsEqual(0x88, [24], 0x1)), + Function('GPIOR0', None) + ], + 'V21': [ + Function('ROMA24', And(BitsEqual(0x88, [28], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR6', And(BitsEqual(0x88, [28], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOR4', None) + ], + 'V22': [ + Function('ROMD6', And(BitsEqual(0x8c, [2], 0x1), BitsEqual(0x94, [1, 0], 0x0))), + Function('VPOVS', And(BitsEqual(0x8c, [2], 0x1), BitsNotEqual(0x94, [1, 0], 0x0))), + Function('GPIOS2', None) + ], + 'V3': [ + Function('VPIB2', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [24], 0x1))), + Function('NCTS2', BitsEqual(0x84, [24], 0x1)), + Function('GPIOM0', None) + ], + 'V4': [ + Function('VPIB5', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [27], 0x1))), + Function('NRI2', BitsEqual(0x84, [27], 0x1)), + Function('GPIOM3', None) + ], + 'V5': [ + Function('VPIB9', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [31], 0x1))), + Function('RXD2', BitsEqual(0x84, [31], 0x1)), + Function('GPIOM7', None) + ], + 'V6': [ + Function('VPIG8', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [8], 0x1))), + Function('GPIOO0/TACH0', None) + ], + 'V7': [ + Function('VPIR5', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [15], 0x1))), + Function('GPIOO7/TACH7', None) + ], + 'W1': [ + Function('VPIB0', And(BitsEqual(0x90, [5, 4], 0x3), BitsEqual(0x84, [22], 0x1))), + Function('TXD1', BitsEqual(0x84, [22], 0x1)), + Function('GPIOL6', None) + ], + 'W2': [ + Function('VPIB3', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [25], 0x1))), + Function('NDCD2', BitsEqual(0x84, [25], 0x1)), + Function('GPIOM1', None) + ], + 'W21': [ + Function('ROMCS2#', BitsEqual(0x88, [25], 0x1)), + Function('GPIOR1', None) + ], + 'W22': [ + Function('ROMA25', And(BitsEqual(0x88, [29], 0x1), BitsEqual(0x94, [1], 0x0))), + Function('VPOR7', And(BitsEqual(0x88, [29], 0x1), BitsEqual(0x94, [1], 0x1))), + Function('GPIOR5', None) + ], + 'W3': [ + Function('VPIB6', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [28], 0x1))), + Function('NDTR2', BitsEqual(0x84, [28], 0x1)), + Function('GPIOM4', None) + ], + 'W4': [ + Function('VPIG0', And(BitsEqual(0x90, [5, 4], 0x3), BitsEqual(0x88, [0], 0x1))), + Function('PWM0', BitsEqual(0x88, [0], 0x1)), + Function('GPION0', None) + ], + 'W5': [ + Function('VPIG4', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x88, [4], 0x1))), + Function('PWM4', BitsEqual(0x88, [4], 0x1)), + Function('GPION4', None) + ], + 'W6': [ + Function('VPIR2', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [12], 0x1))), + Function('GPIOO4/TACH4', None) + ], + 'W7': [ + Function('VPIR8', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [18], 0x1))), + Function('GPIOP2/TACH10', None) + ], + 'Y1': [ + Function('VPIB4', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [26], 0x1))), + Function('NDSR2', BitsEqual(0x84, [26], 0x1)), + Function('GPIOM2', None) + ], + 'Y2': [ + Function('VPIB7', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x84, [29], 0x1))), + Function('NRTS2', BitsEqual(0x84, [29], 0x1)), + Function('GPIOM5', None) + ], + 'Y21': [ + Function('USBCKI', BitsEqual(0x70, [23], 0x1)), + Function('WDTRST2', BitsEqual(0x84, [5], 0x1)), + Function('GPIOG5', None) + ], + 'Y22': [ + Function('ROMCS3#', BitsEqual(0x88, [26], 0x1)), + Function('GPIOR2', None) + ], + 'Y3': [ + Function('VPIG1', And(BitsEqual(0x90, [5, 4], 0x3), BitsEqual(0x88, [1], 0x1))), + Function('PWM1', BitsEqual(0x88, [1], 0x1)), + Function('GPION1', None) + ], + 'Y4': [ + Function('VPIG5', And(BitsNotEqual(0x90, [5, 4], 0x0), BitsEqual(0x88, [5], 0x1))), + Function('PWM5', BitsEqual(0x88, [5], 0x1)), + Function('GPION5', None) + ], + 'Y5': [ + Function('VPIG9', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [9], 0x1))), + Function('GPIOO1/TACH1', None) + ], + 'Y6': [ + Function('VPIR6', And(BitsEqual(0x90, [5, 4], 0x2), BitsEqual(0x88, [16], 0x1))), + Function('GPIOP0/TACH8', None) + ], +} diff --git a/meta-aspeed/recipes-utils/openbmc-gpio/files/ast_gpio_parser.py b/meta-aspeed/recipes-utils/openbmc-gpio/files/ast_gpio_parser.py new file mode 100644 index 0000000..acc4c1a --- /dev/null +++ b/meta-aspeed/recipes-utils/openbmc-gpio/files/ast_gpio_parser.py @@ -0,0 +1,204 @@ +#!/usr/bin/python -tt +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import argparse +import csv +import logging +import re +import sys + +FUNC_SYMBOL = 'Function' +AND_SYMBOL = 'And' +OR_SYMBOL = 'Or' +BE_SYMBOL = 'BitsEqual' +BNE_SYMBOL = 'BitsNotEqual' + + +class CsvReader: + ''' + A class for parsing the CSV files containing the pin mapping data. + ''' + def __init__(self, path): + self.path = path + + fileobj = open(path, 'r') + self.reader = csv.reader(fileobj, delimiter=b',', quotechar=b'"') + + def next(self): + try: + line = self.reader.next() + except StopIteration: + return None + return line + + +class Expression(object): + def __init__(self, exp): + self.exp = exp + + def parse(self): + # Strap[4,1:0]=100 + m = re.match('([^\[]+)\[(.+)\](!*=)([01]+)', self.exp) + # ('Strap', '4,1:0', '=', '100') + try: + if len(m.groups()) != 4: + raise + scuname = m.group(1) + if scuname.lower() == 'strap': + scu = 0x70 + elif scuname.startswith('SCU'): + scu = int(scuname[3:], 16) + + bits = [] + for bit in m.group(2).split(','): + if ':' in bit: + # it is a range + s, _, e = bit.partition(':') + ss = int(s) + ee = int(e) + if ss < ee: + assert 0 <= ss and ee <= 31 + bits += range(ss, ee + 1) + else: + assert 0 <= ee and ss <= 31 + bits += range(ee, ss + 1) + else: + bits += [int(bit)] + if m.group(3) == '!=': + cond = BNE_SYMBOL + else: + cond = BE_SYMBOL + value = int(m.group(4), 2) + return '%s(0x%x, %s, 0x%x)' \ + % (cond, scu, sorted(bits, reverse=True), value) + except Exception as e: + logging.exception('Failed to parse expression "%s"', self.exp) + + +class Conditions(object): + def __init__(self, cond): + self.cond = re.sub('\s+', '', cond) + + def _next_condition_pos(self, cur): + for idx in range(cur, len(self.cond)): + c = self.cond[idx] + if c == '&' or c == '|': + return idx + return -1 + + def _get_expression(self, exp): + if exp == '': + return None + return Expression(exp).parse() + + def _parse(self, idx): + next_idx = self._next_condition_pos(idx + 1) + if next_idx == -1: + # end of string + return self._get_expression(self.cond[idx:]) + + prev = self._get_expression(self.cond[idx:next_idx]) + if self.cond[next_idx] == '&': + cond = AND_SYMBOL + else: + cond = OR_SYMBOL + return '%s(%s, %s)' % (cond, prev, self._parse(next_idx + 1)) + + def parse(self): + return self._parse(0) + + +class AstGPIO(object): + def __init__(self, data): + self.data = data + self.undefined_func = 1 + self.pins = {} + self.functions = set() + + def _parse_conditions(self, cond): + return Conditions(cond).parse() + + def _parse_funcs(self, parts): + func_fmt = FUNC_SYMBOL + '(\'{func}\', {cond})' + if len(parts) < 1: + return [] + # Unable to process SIORD + if 'SIORD' in ' '.join(parts): + logging.warning('Unable to process SIORD. Ignore') + return [] + func = parts[0] + if func == '': + # nothing after + return [] + if func == '-': + func = 'UNDEFINED%d' % self.undefined_func + self.undefined_func += 1 + assert func not in self.functions + self.functions.add(func) + if len(parts) == 1: + # just has the function name, the last function + return [func_fmt.format(func=func, cond=None)] + cond = self._parse_conditions(parts[1]) + return [func_fmt.format(func=func, cond=cond)] \ + + self._parse_funcs(parts[2:]) + + def parse(self): + while True: + line = self.data.next() + if line is None: + break + + logging.debug('Parsing line: %s' % line) + + # V21,ROMA24,SCU88[28]=1 & SCU94[1]=0,VPOR6,SCU88[28]=1 & SCU94[1]=1,GPIOR4 + pin = line[0] + if pin == "": + # empty line + continue + funcs = self._parse_funcs(line[1:]) + logging.debug('%s: %s' % (pin, funcs)) + assert pin not in self.pins + self.pins[pin] = funcs + + def print(self, out): + for pin in sorted(self.pins): + if len(self.pins[pin]) == 0: + logging.warning('Pin "%s" has no function defined. Skip' % pin) + continue + out.write(' \'%s\': [\n %s\n ],\n' + % (pin, ',\n '.join(self.pins[pin]))) + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('data', help='The GPIO data file') + args = ap.parse_args() + + logging.basicConfig(level=logging.INFO, format='%(asctime)s: %(message)s') + + gpio = AstGPIO(CsvReader(args.data)) + gpio.parse() + gpio.print(sys.stdout) + + +rc = main() +sys.exit(rc) diff --git a/meta-aspeed/recipes-utils/openbmc-gpio/files/data/ast2400-gpio.csv b/meta-aspeed/recipes-utils/openbmc-gpio/files/data/ast2400-gpio.csv new file mode 100644 index 0000000..d41460e --- /dev/null +++ b/meta-aspeed/recipes-utils/openbmc-gpio/files/data/ast2400-gpio.csv @@ -0,0 +1,225 @@ +D6,MAC1LINK,SCU80[0]=1,GPIOA0,, +B5,MAC2LINK,SCU80[1]=1,GPIOA1,, +A4,TIMER3,SCU80[2]=1,GPIOA2,, +E6,TIMER4,SCU80[3]=1,GPIOA3,, +C5,SCL9,SCU90[22]=1,TIMER5,SCU80[4]=1,GPIOA4 +B4,SDA9,SCU90[22]=1,TIMER6,SCU80[5]=1,GPIOA5 +A3,MDC2,SCU90[2]=1,TIMER7,SCU80[6]=1,GPIOA6 +D5,MDIO2,SCU90[2]=1,TIMER8,SCU80[7]=1,GPIOA7 +J21,SALT1,SCU80[8]=1,GPIOB0,, +J20,SALT2,SCU80[9]=1,GPIOB1,, +H18,SALT3,SCU80[10]=1,GPIOB2,, +F18,SALT4,SCU80[11]=1,GPIOB3,, +E19,LPCRST#,SCU80[12]=1 | Strap[14]=1,GPIOB4,, +H19,LPCPD#,SCU80[13]=1 & SIORD30[1]=0,LPCSMI#,SCU80[13]=1 & SIORD30[1]=1,GPIOB5 +H20,LPCPME#,SCU80[14]=1,GPIOB6,, +E18,EXTRST#,SCU80[15]=1 & SCU90[31]=0 & SCU3C[3]=1,SPICS1#,SCU80[15]=1 & SCU90[31]=1,GPIOB7 +C4,SD1CLK,SCU90[0]=1,SCL10,SCU90[23]=1,GPIOC0 +B3,SD1CMD,SCU90[0]=1,SDA10,SCU90[23]=1,GPIOC1 +A2,SD1DAT0,SCU90[0]=1,SCL11,SCU90[24]=1,GPIOC2 +E5,SD1DAT1,SCU90[0]=1,SDA11,SCU90[24]=1,GPIOC3 +D4,SD1DAT2,SCU90[0]=1,SCL12,SCU90[25]=1,GPIOC4 +C3,SD1DAT3,SCU90[0]=1,SDA12,SCU90[25]=1,GPIOC5 +B2,SD1CD#,SCU90[0]=1,SCL13,SCU90[26]=1,GPIOC6 +A1,SD1WP#,SCU90[0]=1,SDA13,SCU90[26]=1,GPIOC7 +,,,,, +A18,SD2CLK,SCU90[1]=1,GPID0(In),SCU8C[8]=1 | Strap[21]=1,GPIOD0 +D16,SD2CMD,SCU90[1]=1,GPID0(Out),SCU8C[8]=1 | Strap[21]=1,GPIOD1 +B17,SD2DAT0,SCU90[1]=1,GPID2(In),SCU8C[9]=1 | Strap[21]=1,GPIOD2 +A17,SD2DAT1,SCU90[1]=1,GPID2(Out),SCU8C[9]=1 | Strap[21]=1,GPIOD3 +C16,SD2DAT2,SCU90[1]=1,GPID4(In),SCU8C[10]=1 | Strap[21]=1,GPIOD4 +B16,SD2DAT3,SCU90[1]=1,GPID4(Out),SCU8C[10]=1 | Strap[21]=1,GPIOD5 +A16,SD2CD#,SCU90[1]=1,GPID6(In),SCU8C[11]=1 | Strap[21]=1,GPIOD6 +E15,SD2WP#,SCU90[1]=1,GPID6(Out),SCU8C[11]=1 | Strap[21]=1,GPIOD7 +D15,NCTS3,SCU80[16]=1,GPIE0(In),SCU8C[12]=1 | Strap[22]=1,GPIOE0 +C15,NDCD3,SCU80[17]=1,GPIE0(Out),SCU8C[12]=1 | Strap[22]=1,GPIOE1 +B15,NDSR3,SCU80[18]=1,GPIE2(In),SCU8C[13]=1 | Strap[22]=1,GPIOE2 +A15,NRI3,SCU80[19]=1,GPIE2(Out),SCU8C[13]=1 | Strap[22]=1,GPIOE3 +E14,NDTR3,SCU80[20]=1,GPIE4(In),SCU8C[14]=1 | Strap[22]=1,GPIOE4 +D14,NRTS3,SCU80[21]=1,GPIE4(Out),SCU8C[14]=1 | Strap[22]=1,GPIOE5 +C14,TXD3,SCU80[22]=1,GPIE6(In),SCU8C[15]=1 | Strap[22]=1,GPIOE6 +B14,RXD3,SCU80[23]=1,GPIE6(Out),SCU8C[15]=1 | Strap[22]=1,GPIOE7 +D18,NCTS4,SCU80[24]=1,GPIOF0,, +B19,NDCD4,SCU80[25]=1,SIOPBI#,SCUA4[12]=1 | Strap[19]=0,GPIOF1 +A20,NDSR4,SCU80[26]=1,SIOPWRGD,SCUA4[13]=1 | Strap[19]=0,GPIOF2 +D17,NRI4,SCU80[27]=1,SIOPBO#,SCUA4[14]=1 | Strap[19]=0,GPIOF3 +B18,NDTR4,SCU80[28]=1,GPIOF4,, +A19,NRTS4,SCU80[29]=1,SIOSCI#,SCUA4[15]=1 | Strap[19]=0,GPIOF5 +E16,TXD4,SCU80[30]=1,GPIOF6,, +C17,RXD4,SCU80[31]=1,GPIOF7,, +A14,SGPSCK,SCU84[0]=1,GPIOG0,, +E13,SGPSLD,SCU84[1]=1,GPIOG1,, +D13,SGPSI0,SCU84[2]=1,GPIOG2,, +C13,SGPSI1,SCU84[3]=1,GPIOG3,, +,,,,, +B13,OSCCLK,SCU2C[1]=1,WDTRST1,SCU84[4]=1,GPIOG4 +Y21,USBCKI,Strap[23]=1,WDTRST2,SCU84[5]=1,GPIOG5 +AA22,FLBUSY#,SCU84[6]=1,GPIOG6,, +U18,FLWP#,SCU84[7]=1,GPIOG7,, +A8,ROMD8,"SCU90[6]=1 | Strap[4,1:0]=100",NCTS6,SCU90[7]=1,GPIOH0 +C7,ROMD9,"SCU90[6]=1 | Strap[4,1:0]=100",NDCD6,SCU90[7]=1,GPIOH1 +B7,ROMD10,"SCU90[6]=1 | Strap[4,1:0]=100",NDSR6,SCU90[7]=1,GPIOH2 +A7,ROMD11,"SCU90[6]=1 | Strap[4,1:0]=100",NRI6,SCU90[7]=1,GPIOH3 +D7,ROMD12,"SCU90[6]=1 | Strap[4,1:0]=100",NDTR6,SCU90[7]=1,GPIOH4 +B6,ROMD13,"SCU90[6]=1 | Strap[4,1:0]=100",NRTS6,SCU90[7]=1,GPIOH5 +A6,ROMD14,"SCU90[6]=1 | Strap[4,1:0]=100",TXD6,SCU90[7]=1,GPIOH6 +E7,ROMD15,"SCU90[6]=1 | Strap[4,1:0]=100",RXD6,SCU90[7]=1,GPIOH7 +C22,SYSCS#,Strap[13]=1,GPIOI0,, +G18,SYSCK,Strap[13]=1,GPIOI1,, +D19,SYSDO,Strap[13]=1,GPIOI2,, +C20,SYSDI,Strap[13]=1,GPIOI3,, +B22,SPICS0#,Strap[13:12]!=0,VBCS#,Strap[5]=1,GPIOI4 +G19,SPICK,Strap[13:12]!=0,VBCK,Strap[5]=1,GPIOI5 +C18,SPIDO,Strap[13:12]!=0,VBDO,Strap[5]=1,GPIOI6 +E20,SPIDI,Strap[13:12]!=0,VBDI,Strap[5]=1,GPIOI7 +J5,SGPMCK,SCU84[8]=1,GPIOJ0,, +J4,SGPMLD,SCU84[9]=1,GPIOJ1,, +K5,SGPMO,SCU84[10]=1,GPIOJ2,, +J3,SGPMI,SCU84[11]=1,GPIOJ3,, +T4,VGAHS,SCU84[12]=1,GPIOJ4,, +U2,VGAVS,SCU84[13]=1,GPIOJ5,, +T2,DDCCLK,SCU84[14]=1,GPIOJ6,, +T1,DDCDAT,SCU84[15]=1,GPIOJ7,, +,,,,, +E3,SCL5,SCU90[18]=1,GPIOK0,, +D2,SDA5,SCU90[18]=1,GPIOK1,, +C1,SCL6,SCU90[19]=1,GPIOK2,, +F4,SDA6,SCU90[19]=1,GPIOK3,, +E2,SCL7,SCU90[20]=1,GPIOK4,, +D1,SDA7,SCU90[20]=1,GPIOK5,, +G5,SCL8,SCU90[21]=1,GPIOK6,, +F3,SDA8,SCU90[21]=1,GPIOK7,, +U1,NCTS1,SCU84[16]=1,GPIOL0,, +T5,VPIDE,SCU90[5:4]!=0 & SCU84[17]=1,NDCD1,SCU84[17]=1,GPIOL1 +U3,VPIODD,SCU90[5:4]!=0 & SCU84[18]=1,NDSR1,SCU84[18]=1,GPIOL2 +V1,VPIHS,SCU90[5:4]!=0 & SCU84[19]=1,NRI1,SCU84[19]=1,GPIOL3 +U4,VPIVS,SCU90[5:4]!=0 & SCU84[20]=1,NDTR1,SCU84[20]=1,GPIOL4 +V2,VPICLK,SCU90[5:4]!=0 & SCU84[21]=1,NRTS1,SCU84[21]=1,GPIOL5 +W1,VPIB0,SCU90[5:4]=11 & SCU84[22]=1,TXD1,SCU84[22]=1,GPIOL6 +U5,VPIB1,SCU90[5:4]=11 & SCU84[23]=1,RXD1,SCU84[23]=1,GPIOL7 +V3,VPIB2,SCU90[5:4]!=0 & SCU84[24]=1,NCTS2,SCU84[24]=1,GPIOM0 +W2,VPIB3,SCU90[5:4]!=0 & SCU84[25]=1,NDCD2,SCU84[25]=1,GPIOM1 +Y1,VPIB4,SCU90[5:4]!=0 & SCU84[26]=1,NDSR2,SCU84[26]=1,GPIOM2 +V4,VPIB5,SCU90[5:4]!=0 & SCU84[27]=1,NRI2,SCU84[27]=1,GPIOM3 +W3,VPIB6,SCU90[5:4]!=0 & SCU84[28]=1,NDTR2,SCU84[28]=1,GPIOM4 +Y2,VPIB7,SCU90[5:4]!=0 & SCU84[29]=1,NRTS2,SCU84[29]=1,GPIOM5 +AA1,VPIB8,SCU90[5:4]!=0 & SCU84[30]=1,TXD2,SCU84[30]=1,GPIOM6 +V5,VPIB9,SCU90[5:4]!=0 & SCU84[31]=1,RXD2,SCU84[31]=1,GPIOM7 +W4,VPIG0,SCU90[5:4]=11 & SCU88[0]=1,PWM0,SCU88[0]=1,GPION0 +Y3,VPIG1,SCU90[5:4]=11 & SCU88[1]=1,PWM1,SCU88[1]=1,GPION1 +AA2,VPIG2,SCU90[5:4]!=0 & SCU88[2]=1,PWM2,SCU88[2]=1,GPION2 +AB1,VPIG3,SCU90[5:4]!=0 & SCU88[3]=1,PWM3,SCU88[3]=1,GPION3 +,,,,, +W5,VPIG4,SCU90[5:4]!=0 & SCU88[4]=1,PWM4,SCU88[4]=1,GPION4 +Y4,VPIG5,SCU90[5:4]!=0 & SCU88[5]=1,PWM5,SCU88[5]=1,GPION5 +AA3,VPIG6,SCU90[5:4]=10 & SCU88[6]=1,PWM6,SCU88[6]=1,GPION6 +AB2,VPIG7,SCU90[5:4]=10 & SCU88[7]=1,PWM7,SCU88[7]=1,GPION7 +V6,VPIG8,SCU90[5:4]=10 & SCU88[8]=1,GPIOO0/TACH0,, +Y5,VPIG9,SCU90[5:4]=10 & SCU88[9]=1,GPIOO1/TACH1,, +AA4,VPIR0,SCU90[5:4]=11 & SCU88[10]=1,GPIOO2/TACH2,, +AB3,VPIR1,SCU90[5:4]=11 & SCU88[11]=1,GPIOO3/TACH3,, +W6,VPIR2,SCU90[5:4]=10 & SCU88[12]=1,GPIOO4/TACH4,, +AA5,VPIR3,SCU90[5:4]=10 & SCU88[13]=1,GPIOO5/TACH5,, +AB4,VPIR4,SCU90[5:4]=10 & SCU88[14]=1,GPIOO6/TACH6,, +V7,VPIR5,SCU90[5:4]=10 & SCU88[15]=1,GPIOO7/TACH7,, +Y6,VPIR6,SCU90[5:4]=10 & SCU88[16]=1,GPIOP0/TACH8,, +AB5,VPIR7,SCU90[5:4]=10 & SCU88[17]=1,GPIOP1/TACH9,, +W7,VPIR8,SCU90[5:4]=10 & SCU88[18]=1,GPIOP2/TACH10,, +AA6,VPIR9,SCU90[5:4]=10 & SCU88[19]=1,GPIOP3/TACH11,, +AA7,BMCINT,SCU88[22]=1,GPIOP6/TACH14,, +AB7,FLACK,SCU88[23]=1,GPIOP7/TACH15,, +D3,SCL3,SCU90[16]=1,GPIOQ0,, +C2,SDA3,SCU90[16]=1,GPIOQ1,, +B1,SCL4,SCU90[17]=1,GPIOQ2,, +F5,SDA4,SCU90[17]=1,GPIOQ3,, +H4,SCL14,SCU90[27]=1,GPIOQ4,, +H3,SDA14,SCU90[27]=1,GPIOQ5,, +H2,-,SCU90[28]=1,GPIOQ6,, +H1,-,SCU90[28]=1,GPIOQ7,, +V20,ROMCS1#,SCU88[24]=1,GPIOR0,, +W21,ROMCS2#,SCU88[25]=1,GPIOR1,, +,,,,, +Y22,ROMCS3#,SCU88[26]=1,GPIOR2,, +U19,ROMCS4#,SCU88[27]=1,GPIOR3,, +V21,ROMA24,SCU88[28]=1 & SCU94[1]=0,VPOR6,SCU88[28]=1 & SCU94[1]=1,GPIOR4 +W22,ROMA25,SCU88[29]=1 & SCU94[1]=0,VPOR7,SCU88[29]=1 & SCU94[1]=1,GPIOR5 +C6,MDC1,SCU88[30]=1,GPIOR6, , +A5,MDIO1,SCU88[31]=1,GPIOR7, , +U21,ROMD4,SCU8C[0]=1 & SCU94[1:0]=0,VPODE,SCU8C[0]=1 & SCU94[1:0]!=0,GPIOS0 +T19,ROMD5,SCU8C[1]=1 & SCU94[1:0]=0,VPOHS,SCU8C[1]=1 & SCU94[1:0]!=0,GPIOS1 +V22,ROMD6,SCU8C[2]=1 & SCU94[1:0]=0,VPOVS,SCU8C[2]=1 & SCU94[1:0]!=0,GPIOS2 +U20,ROMD7,SCU8C[3]=1 & SCU94[1:0]=0,VPOCLK,SCU8C[3]=1 & SCU94[1:0]!=0,GPIOS3 +R18,ROMOE#,SCU8C[4]=1,GPIOS4, , +N21,ROMWE#,SCU8C[5]=1,GPIOS5, , +L22,ROMA22,SCU8C[6]=1 & SCU94[1]=0,VPOR4,SCU8C[6]=1 & SCU94[1]=1,GPIOS6 +K18,ROMA23,SCU8C[7]=1 & SCU94[1]=0,VPOR5,SCU8C[7]=1 & SCU94[1]=1,GPIOS7 +A12,GPIOT0,SCUA0[0]=1,RMII1TXEN,Strap[6]=0,RGMII1TXCK +B12,GPIOT1,SCUA0[1]=1,-,Strap[6]=0,RGMII1TXCTL +C12,GPIOT2,SCUA0[2]=1,RMII1TXD0,Strap[6]=0,RGMII1TXD0 +D12,GPIOT3,SCUA0[3]=1,RMII1TXD1,Strap[6]=0,RGMII1TXD1 +E12,GPIOT4,SCUA0[4]=1,-,Strap[6]=0,RGMII1TXD2 +A13,GPIOT5,SCUA0[5]=1,-,Strap[6]=0,RGMII1TXD3 +D9,GPIOT6,SCUA0[6]=1,RMII2TXEN,Strap[7]=0,RGMII2TXCK +E9,GPIOT7,SCUA0[7]=1,-,Strap[7]=0,RGMII2TXCTL +A10,GPIOU0,SCUA0[8]=1,RMII2TXD0,Strap[7]=0,RGMII2TXD0 +B10,GPIOU1,SCUA0[9]=1,RMII2TXD1,Strap[7]=0,RGMII2TXD1 +C10,GPIOU2,SCUA0[10]=1,-,Strap[7]=0,RGMII2TXD2 +D10,GPIOU3,SCUA0[11]=1,-,Strap[7]=0,RGMII2TXD3 +E11,GPIOU4,SCUA0[12]=1,RMII1RCLK,Strap[6]=0,RGMII1RXCK +D11,GPIOU5,SCUA0[13]=1,-,Strap[6]=0,RGMII1RXCTL +,,,,, +C11,GPIOU6,SCUA0[14]=1,RMII1RXD0,Strap[6]=0,RGMII1RXD0 +B11,GPIOU7,SCUA0[15]=1,RMII1RXD1,Strap[6]=0,RGMII1RXD1 +A11,GPIOV0,SCUA0[16]=1,RMII1CRSDV,Strap[6]=0,RGMII1RXD2 +E10,GPIOV1,SCUA0[17]=1,RMII1RXER,Strap[6]=0,RGMII1RXD3 +C9,GPIOV2,SCUA0[18]=1,RMII2RCLK,Strap[7]=0,RGMII2RXCK +B9,GPIOV3,SCUA0[19]=1,-,Strap[7]=0,RGMII2RXCTL +A9,GPIOV4,SCUA0[20]=1,RMII2RXD0,Strap[7]=0,RGMII2RXD0 +E8,GPIOV5,SCUA0[21]=1,RMII2RXD1,Strap[7]=0,RGMII2RXD1 +D8,GPIOV6,SCUA0[22]=1,RMII2CRSDV,Strap[7]=0,RGMII2RXD2 +C8,GPIOV7,SCUA0[23]=1,RMII2RXER,Strap[7]=0,RGMII2RXD3 +L5,GPIW0,SCUA0[24]=1,ADC0,, +L4,GPIW1,SCUA0[25]=1,ADC1,, +L3,GPIW2,SCUA0[26]=1,ADC2,, +L2,GPIW3,SCUA0[27]=1,ADC3,, +L1,GPIW4,SCUA0[28]=1,ADC4,, +M5,GPIW5,SCUA0[29]=1,ADC5,, +M4,GPIW6,SCUA0[30]=1,ADC6,, +M3,GPIW7,SCUA0[31]=1,ADC7,, +M2,GPIX0,SCUA4[0]=1,ADC8,, +M1,GPIX1,SCUA4[1]=1,ADC9,, +N5,GPIX2,SCUA4[2]=1,ADC10,, +N4,GPIX3,SCUA4[3]=1,ADC11,, +N3,GPIX4,SCUA4[4]=1,ADC12,, +N2,GPIX5,SCUA4[5]=1,ADC13,, +N1,GPIX6,SCUA4[6]=1,ADC14,, +P5,GPIX7,SCUA4[7]=1,ADC15,, +C21,SIOS3#,SCUA4[8]=1 | Strap[19]=0,GPIOY0,, +F20,SIOS5#,SCUA4[9]=1 | Strap[19]=0,GPIOY1,, +,,,,, +G20,SIOPWREQ#,SCUA4[10]=1 | Strap[19]=0,GPIOY2,, +K20,SIOONCTRL#,SCUA4[11]=1 | Strap[19]=0,GPIOY3,, +R22,ROMA2,SCUA4[16]=1 & SCU94[1:0]=0,VPOB0,SCUA4[16]=1 & SCU94[1:0]!=0,GPIOZ0 +P18,ROMA3,SCUA4[17]=1 & SCU94[1:0]=0,VPOB1,SCUA4[17]=1 & SCU94[1:0]!=0,GPIOZ1 +P19,ROMA4,SCUA4[18]=1 & SCU94[1:0]=0,VPOB2,SCUA4[18]=1 & SCU94[1:0]!=0,GPIOZ2 +P20,ROMA5,SCUA4[19]=1 & SCU94[1:0]=0,VPOB3,SCUA4[19]=1 & SCU94[1:0]!=0,GPIOZ3 +P21,ROMA6,SCUA4[20]=1 & SCU94[1:0]=0,VPOB4,SCUA4[20]=1 & SCU94[1:0]!=0,GPIOZ4 +P22,ROMA7,SCUA4[21]=1 & SCU94[1:0]=0,VPOB5,SCUA4[21]=1 & SCU94[1:0]!=0,GPIOZ5 +M21,ROMA8,SCUA4[22]=1 & SCU94[1:0]=0,VPOB6,SCUA4[22]=1 & SCU94[1:0]!=0,GPIOZ6 +M22,ROMA9,SCUA4[23]=1 & SCU94[1:0]=0,VPOB7,SCUA4[23]=1 & SCU94[1:0]!=0,GPIOZ7 +L18,ROMA10,SCUA4[24]=1 & SCU94[1:0]=0,VPOG0,SCUA4[24]=1 & SCU94[1:0]!=0,GPIOAA0 +L19,ROMA11,SCUA4[25]=1 & SCU94[1:0]=0,VPOG1,SCUA4[25]=1 & SCU94[1:0]!=0,GPIOAA1 +L20,ROMA12,SCUA4[26]=1 & SCU94[1:0]=0,VPOG2,SCUA4[26]=1 & SCU94[1:0]!=0,GPIOAA2 +L21,ROMA13,SCUA4[27]=1 & SCU94[1:0]=0,VPOG3,SCUA4[27]=1 & SCU94[1:0]!=0,GPIOAA3 +T18,ROMA14,SCUA4[28]=1 & SCU94[1]=0,VPOG4,SCUA4[28]=1 & SCU94[1]=1,GPIOAA4 +N18,ROMA15,SCUA4[29]=1 & SCU94[1]=0,VPOG5,SCUA4[29]=1 & SCU94[1]=1,GPIOAA5 +N19,ROMA16,SCUA4[30]=1 & SCU94[1]=0,VPOG6,SCUA4[30]=1 & SCU94[1]=1,GPIOAA6 +M19,ROMA17,SCUA4[31]=1 & SCU94[1]=0,VPOG7,SCUA4[31]=1 & SCU94[1]=1,GPIOAA7 +M20,ROMA18,SCUA8[0]=1 & SCU94[1]=0,VPOR0,SCUA8[0]=1 & SCU94[1]=1,GPIOAB0 +M18,ROMA19,SCUA8[1]=1 & SCU94[1]=0,VPOR1,SCUA8[1]=1 & SCU94[1]=1,GPIOAB1 +N22,ROMA20,SCUA8[2]=1 & SCU94[1]=0,VPOR2,SCUA8[2]=1 & SCU94[1]=1,GPIOAB2 +N20,ROMA21,SCUA8[3]=1 & SCU94[1]=0,VPOR3,SCUA8[3]=1 & SCU94[1]=1,GPIOAB3 +K4,UB11_HDP2,SCU90[3]=1,UB11_DP,, +K3,UB11_HDN2,SCU90[3]=1,UB11_DN,, +AB21,USB2_HDP,SCU90[29]=1,USB2_DP,, +AB20,USB2_HDN,SCU90[29]=1,USB2_DN,, diff --git a/meta-aspeed/recipes-utils/openbmc-gpio/files/soc_gpio.py b/meta-aspeed/recipes-utils/openbmc-gpio/files/soc_gpio.py new file mode 100644 index 0000000..ea3c8d3 --- /dev/null +++ b/meta-aspeed/recipes-utils/openbmc-gpio/files/soc_gpio.py @@ -0,0 +1,42 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import phymemory + + +_soc_reg_map = {} + + +class SCUReg(phymemory.PhyMemory): + SCU_REG_MAX = 0x1A4 + SCU_ADDR_BASE = 0x1E6E2000 + def __init__(self, reg): + assert 0 <= reg <= self.SCU_REG_MAX + self.reg = reg + super(SCUReg, self).__init__(self.SCU_ADDR_BASE + reg, 'SCU%X' % reg) + + +def soc_get_register(addr): + if addr in _soc_reg_map: + return _soc_reg_map[addr] + reg = SCUReg(addr) + _soc_reg_map[addr] = reg + return reg diff --git a/meta-aspeed/recipes-utils/openbmc-gpio/openbmc-gpio_%.bbappend b/meta-aspeed/recipes-utils/openbmc-gpio/openbmc-gpio_%.bbappend new file mode 100644 index 0000000..a87a8c9 --- /dev/null +++ b/meta-aspeed/recipes-utils/openbmc-gpio/openbmc-gpio_%.bbappend @@ -0,0 +1,23 @@ +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += " \ + file://soc_gpio.py \ + file://ast2400_gpio_table.py \ + " diff --git a/meta-aspeed/recipes-utils/soc-utils/files/COPYING b/meta-aspeed/recipes-utils/soc-utils/files/COPYING new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/meta-aspeed/recipes-utils/soc-utils/files/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/meta-aspeed/recipes-utils/soc-utils/files/soc-utils.sh b/meta-aspeed/recipes-utils/soc-utils/files/soc-utils.sh new file mode 100644 index 0000000..33d772f --- /dev/null +++ b/meta-aspeed/recipes-utils/soc-utils/files/soc-utils.sh @@ -0,0 +1,20 @@ +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +scu_addr() { + echo $((0x1E6E2000 + 0x$1)) +} diff --git a/meta-aspeed/recipes-utils/soc-utils/openbmc-utils_%.bbappend b/meta-aspeed/recipes-utils/soc-utils/openbmc-utils_%.bbappend new file mode 100644 index 0000000..cb8d362 --- /dev/null +++ b/meta-aspeed/recipes-utils/soc-utils/openbmc-utils_%.bbappend @@ -0,0 +1,26 @@ +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += " \ + file://soc-utils.sh \ + " + +OPENBMC_UTILS_FILES += " \ + soc-utils.sh \ + " diff --git a/meta-facebook/meta-wedge/conf/bblayers.conf.sample b/meta-facebook/meta-wedge/conf/bblayers.conf.sample index e8b572a..90d4956 100644 --- a/meta-facebook/meta-wedge/conf/bblayers.conf.sample +++ b/meta-facebook/meta-wedge/conf/bblayers.conf.sample @@ -11,6 +11,7 @@ BBLAYERS ?= " \ ##OEROOT##/meta-yocto-bsp \ ##OEROOT##/meta-openembedded/meta-oe \ ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-python \ ##OEROOT##/meta-openbmc \ ##OEROOT##/meta-openbmc/meta-aspeed \ ##OEROOT##/meta-openbmc/meta-facebook/meta-wedge \ diff --git a/meta-facebook/meta-wedge/conf/local.conf.sample b/meta-facebook/meta-wedge/conf/local.conf.sample index 078ba23..7ddcaa6 100644 --- a/meta-facebook/meta-wedge/conf/local.conf.sample +++ b/meta-facebook/meta-wedge/conf/local.conf.sample @@ -138,3 +138,8 @@ EXTRA_USERS_PARAMS = " \ usermod -s /bin/bash root; \ usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \ " + +OLDEST_KERNEL = "2.6.28" + +INHERIT += "blacklist" +PNBLACKLIST[glibc] = "glibc 2.21 does not work with our kernel 2.6.28"
\ No newline at end of file diff --git a/meta-facebook/meta-wedge/conf/machine/wedge.conf b/meta-facebook/meta-wedge/conf/machine/wedge.conf index 3ed8ec1..49241aa 100644 --- a/meta-facebook/meta-wedge/conf/machine/wedge.conf +++ b/meta-facebook/meta-wedge/conf/machine/wedge.conf @@ -6,7 +6,9 @@ UBOOT_MACHINE_wedge = "wedge_config" require conf/machine/include/ast1250.inc -# configuration for preferred version of packages +# configuration for preferred version of packages PREFERRED_VERSION_libipmi = "0.1" PREFERRED_VERSION_ipmid = "0.1" PREFERRED_VERSION_rest-api = "0.1" + +TCLIBC = 'eglibc' diff --git a/meta-facebook/meta-wedge/recipes-core/busybox/busybox/syslog.conf b/meta-facebook/meta-wedge/recipes-core/busybox/busybox/syslog.conf new file mode 100644 index 0000000..817a9a9 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-core/busybox/busybox/syslog.conf @@ -0,0 +1,5 @@ +# /etc/syslog.conf Configuration file for busybox's syslogd utility +# Send emergency messages to the console +*.emerg /dev/console +# Store everything else +*.* /var/log/messages diff --git a/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend b/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend index b8641ee..0047f92 100644 --- a/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend +++ b/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend @@ -2,4 +2,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += " \ file://busybox.cfg \ - "
\ No newline at end of file + file://syslog.conf \ + " diff --git a/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc b/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc index 7cd89de..a31655e 100644 --- a/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc +++ b/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc @@ -39,6 +39,7 @@ NTP_PKGS = " \ # Include modules in rootfs IMAGE_INSTALL += " \ kernel-modules \ + u-boot \ u-boot-fw-utils \ openbmc-utils \ fan-ctrl \ @@ -54,6 +55,7 @@ IMAGE_INSTALL += " \ wedge-eeprom \ sms-kcsd \ rest-api \ + cherryPy \ bottle \ ipmid \ po-eeprom \ diff --git a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend b/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend index e715c27..7d74521 100644 --- a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend +++ b/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend @@ -1,18 +1,2 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" - -SRC_URI += "file://dhcpv6_up \ - file://dhcpv6_down \ - " - -do_install_append() { - # rules to request dhcpv6 - install -d ${D}/${sysconfdir}/network/if-up.d - install -m 755 ${WORKDIR}/dhcpv6_up ${D}${sysconfdir}/network/if-up.d/dhcpv6_up - install -d ${D}/${sysconfdir}/network/if-down.d - install -m 755 ${WORKDIR}/dhcpv6_down ${D}${sysconfdir}/network/if-down.d/dhcpv6_down -} - -FILES_${PN} += "${sysconfdir}/network/if-up.d/dhcpv6_up \ - ${sysconfdir}/network/if-down.d/dhcpv6_down \ - " diff --git a/meta-facebook/meta-wedge/recipes-kernel/linux/files/defconfig b/meta-facebook/meta-wedge/recipes-kernel/linux/files/defconfig new file mode 100644 index 0000000..41fe288 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-kernel/linux/files/defconfig @@ -0,0 +1,1480 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.28.9 +# Tue Feb 3 16:41:40 2015 +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_TIME=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_MMU=y +# CONFIG_NO_IOPORT is not set +CONFIG_GENERIC_HARDIRQS=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_HAVE_LATENCYTOP_SUPPORT=y +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_ARCH_HAS_ILOG2_U32 is not set +# CONFIG_ARCH_HAS_ILOG2_U64 is not set +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y +CONFIG_VECTORS_BASE=0xffff0000 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set +CONFIG_IKCONFIG=m +CONFIG_IKCONFIG_PROC=y +CONFIG_LOG_BUF_SHIFT=16 +# CONFIG_CGROUPS is not set +# CONFIG_GROUP_SCHED is not set +CONFIG_SYSFS_DEPRECATED=y +CONFIG_SYSFS_DEPRECATED_V2=y +# CONFIG_RELAY is not set +CONFIG_NAMESPACES=y +# CONFIG_UTS_NS is not set +# CONFIG_IPC_NS is not set +# CONFIG_USER_NS is not set +# CONFIG_PID_NS is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +# CONFIG_EMBEDDED is not set +CONFIG_UID16=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_EXTRA_PASS=y +CONFIG_HOTPLUG=y +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +CONFIG_COMPAT_BRK=y +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +# CONFIG_PROFILING is not set +# CONFIG_MARKERS is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_KMOD=y +CONFIG_BLOCK=y +# CONFIG_LBD is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_LSF is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_INTEGRITY is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_DEFAULT_AS is not set +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_CLASSIC_RCU=y +CONFIG_FREEZER=y + +# +# System Type +# +CONFIG_ARCH_ASPEED=y +# CONFIG_ARCH_AAEC2000 is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_CLPS7500 is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_EBSA110 is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_FOOTBRIDGE is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X is not set +# CONFIG_ARCH_IMX is not set +# CONFIG_ARCH_IOP13XX is not set +# CONFIG_ARCH_IOP32X is not set +# CONFIG_ARCH_IOP33X is not set +# CONFIG_ARCH_IXP23XX is not set +# CONFIG_ARCH_IXP2000 is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_L7200 is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_KS8695 is not set +# CONFIG_ARCH_NS9XXX is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_MV78XX0 is not set +# CONFIG_ARCH_MXC is not set +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_S3C2410 is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_LH7A40X is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_MSM is not set +CONFIG_IRMP=y +# CONFIG_PCEXT is not set +# CONFIG_REMOTEFX is not set +# CONFIG_ARCH_AST1100 is not set +# CONFIG_ARCH_AST2100 is not set +# CONFIG_ARCH_AST2200 is not set +# CONFIG_ARCH_AST2300 is not set +CONFIG_ARCH_AST2400=y +CONFIG_WEDGE=y +# CONFIG_ARCH_AST2500 is not set + +# +# FLASH Chip Select +# +# CONFIG_AST_CS0_NOR is not set +# CONFIG_AST_CS0_NAND is not set +CONFIG_AST_CS0_SPI=y +# CONFIG_AST_CS0_NONE is not set +# CONFIG_AST_CS1_NOR is not set +# CONFIG_AST_CS1_NAND is not set +# CONFIG_AST_CS1_SPI is not set +CONFIG_AST_CS1_NONE=y +# CONFIG_AST_CS2_NOR is not set +# CONFIG_AST_CS2_NAND is not set +# CONFIG_AST_CS2_SPI is not set +CONFIG_AST_CS2_NONE=y +# CONFIG_AST_CS3_NOR is not set +# CONFIG_AST_CS3_NAND is not set +# CONFIG_AST_CS3_SPI is not set +CONFIG_AST_CS3_NONE=y +# CONFIG_AST_CS4_NOR is not set +# CONFIG_AST_CS4_NAND is not set +# CONFIG_AST_CS4_SPI is not set +CONFIG_AST_CS4_NONE=y +# CONFIG_ARCH_AST1070 is not set +# CONFIG_AST_SCU_LOCK is not set + +# +# Boot options +# + +# +# Power management +# +CONFIG_PLAT_ASPEED=y + +# +# Processor Type +# +CONFIG_CPU_32=y +CONFIG_CPU_ARM926T=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_PABRT_NOIFAR=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y + +# +# Processor Features +# +CONFIG_ARM_THUMB=y +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +# CONFIG_OUTER_CACHE is not set + +# +# Bus support +# +CONFIG_ARM_AMBA=y +# CONFIG_PCI_SYSCALL is not set +# CONFIG_ARCH_SUPPORTS_MSI is not set +# CONFIG_PCCARD is not set + +# +# Kernel Features +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set +CONFIG_PAGE_OFFSET=0xC0000000 +# CONFIG_PREEMPT is not set +CONFIG_HZ=100 +CONFIG_AEABI=y +CONFIG_OABI_COMPAT=y +CONFIG_ARCH_FLATMEM_HAS_HOLES=y +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4096 +# CONFIG_RESOURCES_64BIT is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=0 +CONFIG_VIRT_TO_BUS=y +CONFIG_UNEVICTABLE_LRU=y +CONFIG_ALIGNMENT_TRAP=y + +# +# Boot options +# +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_CMDLINE="" +# CONFIG_XIP_KERNEL is not set +# CONFIG_KEXEC is not set + +# +# CPU Power Management +# +# CONFIG_CPU_IDLE is not set + +# +# Floating point emulation +# + +# +# At least one emulation must be selected +# +CONFIG_FPE_NWFPE=y +CONFIG_FPE_NWFPE_XP=y +# CONFIG_FPE_FASTFPE is not set +CONFIG_VFP=y + +# +# Userspace binary formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_HAVE_AOUT=y +CONFIG_BINFMT_AOUT=y +# CONFIG_BINFMT_MISC is not set + +# +# Power management options +# +CONFIG_PM=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_SLEEP=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_APM_EMULATION is not set +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +# CONFIG_XFRM_USER is not set +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_XFRM_MODE_TRANSPORT=y +CONFIG_INET_XFRM_MODE_TUNNEL=y +CONFIG_INET_XFRM_MODE_BEET=y +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_TCP_MD5SIG is not set +CONFIG_IPV6=m +# CONFIG_IPV6_PRIVACY is not set +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_XFRM_MODE_TRANSPORT=m +CONFIG_INET6_XFRM_MODE_TUNNEL=m +CONFIG_INET6_XFRM_MODE_BEET=m +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +CONFIG_IPV6_SIT=m +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_NET_DSA is not set +CONFIG_VLAN_8021Q=m +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=y +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_PHONET is not set +# CONFIG_WIRELESS is not set +# CONFIG_RFKILL is not set +# CONFIG_NET_9P is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_SYS_HYPERVISOR is not set +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +CONFIG_MTD=y +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y +# CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y +# CONFIG_MTD_AFS_PARTS is not set +# CONFIG_MTD_AR7_PARTS is not set + +# +# User Modules And Translation Layers +# +CONFIG_MTD_CHAR=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_FTL is not set +# CONFIG_NFTL is not set +# CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set +# CONFIG_SSFDC is not set +# CONFIG_MTD_OOPS is not set + +# +# RAM/ROM/Flash chip drivers +# +# CONFIG_MTD_CFI is not set +# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +CONFIG_MTD_MAP_BANK_WIDTH_2=y +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_ROM is not set +# CONFIG_MTD_ABSENT is not set + +# +# Mapping drivers for chip access +# +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PLATRAM is not set + +# +# Self-contained MTD device drivers +# +CONFIG_MTD_DATAFLASH=m +CONFIG_MTD_DATAFLASH_WRITE_VERIFY=y +# CONFIG_MTD_DATAFLASH_OTP is not set +CONFIG_MTD_M25P80=y +CONFIG_M25PXX_USE_FAST_READ=y +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLOCK2MTD is not set + +# +# Disk-On-Chip Device Drivers +# +# CONFIG_MTD_DOC2000 is not set +# CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set +# CONFIG_MTD_NAND is not set +# CONFIG_MTD_ONENAND is not set + +# +# UBI - Unsorted block images +# +# CONFIG_MTD_UBI is not set +# CONFIG_PARPORT is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=y +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_BLK_DEV_XIP is not set +# CONFIG_RD_BZIP2 is not set +CONFIG_RD_LZMA=y +CONFIG_RD_GZIP=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_MISC_DEVICES=y +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_C2PORT is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_TGT=y +# CONFIG_SCSI_NETLINK is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set +CONFIG_SCSI_SCAN_ASYNC=y +CONFIG_SCSI_WAIT_SCAN=m + +# +# SCSI Transports +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_DH is not set +# CONFIG_ATA is not set +# CONFIG_MD is not set +CONFIG_NETDEVICES=y +# CONFIG_DUMMY is not set +CONFIG_BONDING=m +# CONFIG_MACVLAN is not set +# CONFIG_EQUALIZER is not set +CONFIG_TUN=m +# CONFIG_VETH is not set +# CONFIG_NET_ETHERNET is not set +CONFIG_NETDEV_1000=y +CONFIG_ASPEEDMAC=y +# CONFIG_NETDEV_10000 is not set + +# +# Wireless LAN +# +# CONFIG_WLAN_PRE80211 is not set +# CONFIG_WLAN_80211 is not set +# CONFIG_IWLWIFI_LEDS is not set + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_ISDN is not set + +# +# Input device support +# +CONFIG_INPUT=y +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_GPIO is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_ELANTECH is not set +# CONFIG_MOUSE_PS2_TOUCHKIT is not set +CONFIG_MOUSE_SERIAL=y +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_AMBAKMI is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_VT_HW_CONSOLE_BINDING is not set +CONFIG_DEVKMEM=y +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_N_HDLC is not set +# CONFIG_RISCOM8 is not set +# CONFIG_SPECIALIX is not set +# CONFIG_RIO is not set +# CONFIG_STALDRV is not set + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=4 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 +# CONFIG_SERIAL_AST_DMA_UART is not set +# CONFIG_SERIAL_8250_EXTENDED is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_AMBA_PL010 is not set +# CONFIG_SERIAL_AMBA_PL011 is not set +# CONFIG_SERIAL_AST is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +# CONFIG_IPMI_HANDLER is not set +CONFIG_AST_MISC=y +# CONFIG_AST_VIDEO is not set +# CONFIG_ADC_CAT9883 is not set +# CONFIG_AST_SPI_BIOS is not set +CONFIG_AST_PECI=y +# CONFIG_AST_KCS is not set +# CONFIG_AST_GPIO is not set +# CONFIG_HW_RANDOM is not set +CONFIG_NVRAM=y +# CONFIG_R3964 is not set +# CONFIG_RAW_DRIVER is not set +# CONFIG_TCG_TPM is not set +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_HELPER_AUTO=y + +# +# I2C Hardware Bus support +# + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +CONFIG_I2C_AST=y +CONFIG_AST_I2C_SLAVE_MODE=y +CONFIG_AST_I2C_SLAVE_EEPROM=y +# CONFIG_AST_I2C_SLAVE_RDWR is not set +# CONFIG_I2C_SIMTEC is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_STUB is not set + +# +# Miscellaneous I2C Chip support +# +# CONFIG_DS1682 is not set +CONFIG_AT24=m +# CONFIG_SENSORS_EEPROM is not set +CONFIG_SENSORS_PCF8574=m +# CONFIG_PCF8575 is not set +# CONFIG_SENSORS_PCA9539 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_TPS65010 is not set +# CONFIG_SENSORS_MAX6875 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +CONFIG_SPI_AST=y +CONFIG_SPI_FMC=y +CONFIG_SPI_BITBANG=y + +# +# SPI Protocol Masters +# +CONFIG_SPI_AT25=m +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_TLE62X0 is not set +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO expanders: +# + +# +# I2C GPIO expanders: +# +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set + +# +# PCI GPIO expanders: +# + +# +# SPI GPIO expanders: +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MCP23S08 is not set +# CONFIG_W1 is not set +# CONFIG_POWER_SUPPLY is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7473 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +CONFIG_SENSORS_LM75=m +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +CONFIG_SENSORS_MAX127=m +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +CONFIG_SENSORS_ADS7828=m +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +CONFIG_SENSORS_AST_ADC=y +CONFIG_SENSORS_AST_PWM_FAN=y +CONFIG_SENSORS_FB_PANTHER_PLUS=m +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_SENSORS_ADM1275=m +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX8688 is not set +CONFIG_SENSORS_PFE1100=m +CONFIG_SENSORS_PFE3000=m +# CONFIG_SENSORS_UCD9000 is not set +# CONFIG_SENSORS_UCD9200 is not set +# CONFIG_SENSORS_ZL6100 is not set +# CONFIG_HWMON_DEBUG_CHIP is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +CONFIG_AST_WATCHDOG=y + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_ASIC3 is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_TC6393XB is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM8350_I2C is not set + +# +# Multimedia devices +# + +# +# Multimedia core support +# +# CONFIG_VIDEO_DEV is not set +# CONFIG_DVB_CORE is not set +# CONFIG_VIDEO_MEDIA is not set + +# +# Multimedia drivers +# +# CONFIG_DAB is not set + +# +# Graphics support +# +# CONFIG_VGASTATE is not set +# CONFIG_VIDEO_OUTPUT_CONTROL is not set +# CONFIG_FB is not set +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set + +# +# Display device support +# +# CONFIG_DISPLAY_SUPPORT is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y +# CONFIG_SOUND is not set +# CONFIG_HID_SUPPORT is not set +CONFIG_USB_SUPPORT=y +CONFIG_USB_ARCH_HAS_HCD=y +# CONFIG_USB_ARCH_HAS_OHCI is not set +CONFIG_USB_ARCH_HAS_EHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_SUSPEND is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_EHCI_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HWA_HCD is not set + +# +# AST USB Drivers +# +CONFIG_AST_USB_UHCI_HCD=y +# CONFIG_AST_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_AST_USB_UHCI_MULTIPORT_2 is not set +CONFIG_AST_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_EHCI_SPLIT_ISO is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; +# + +# +# see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +# CONFIG_USB_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_LIBUSUAL is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB port drivers +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_BERRY_CHARGE is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_PHIDGET is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_VST is not set +CONFIG_USB_GADGET=y +# CONFIG_USB_GADGET_DEBUG_FILES is not set +CONFIG_USB_GADGET_VBUS_DRAW=2 +CONFIG_USB_GADGET_SELECTED=y +# CONFIG_USB_GADGET_AT91 is not set +# CONFIG_USB_GADGET_ATMEL_USBA is not set +# CONFIG_USB_GADGET_FSL_USB2 is not set +# CONFIG_USB_GADGET_LH7A40X is not set +# CONFIG_USB_GADGET_OMAP is not set +# CONFIG_USB_GADGET_PXA25X is not set +# CONFIG_USB_GADGET_PXA27X is not set +# CONFIG_USB_GADGET_S3C2410 is not set +# CONFIG_USB_GADGET_M66592 is not set +# CONFIG_USB_GADGET_AMD5536UDC is not set +# CONFIG_USB_GADGET_FSL_QE is not set +# CONFIG_USB_GADGET_NET2280 is not set +# CONFIG_USB_GADGET_GOKU is not set +CONFIG_USB_GADGET_ASPEED_AST=y +CONFIG_USB_ASPEED_AST=y +# CONFIG_USB_GADGET_DUMMY_HCD is not set +CONFIG_USB_GADGET_DUALSPEED=y +CONFIG_USB_ZERO=m +CONFIG_USB_ETH=m +CONFIG_USB_ETH_RNDIS=y +CONFIG_USB_GADGETFS=m +CONFIG_USB_FILE_STORAGE=m +# CONFIG_USB_FILE_STORAGE_TEST is not set +CONFIG_USB_G_SERIAL=m +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_G_PRINTER is not set +CONFIG_USB_CDC_COMPOSITE=m +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_NEW_LEDS is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_HCTOSYS is not set +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8581 is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_DS3234 is not set + +# +# Platform RTC drivers +# +# CONFIG_RTC_DRV_CMOS is not set +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_V3020 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PL030 is not set +# CONFIG_RTC_DRV_PL031 is not set +CONFIG_RTC_DRV_ASPEED=y +# CONFIG_DMADEVICES is not set +# CONFIG_REGULATOR is not set +# CONFIG_UIO is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_EXT4_FS is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_FILE_LOCKING=y +# CONFIG_XFS_FS is not set +# CONFIG_OCFS2_FS is not set +CONFIG_DNOTIFY=y +CONFIG_INOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set +CONFIG_GENERIC_ACL=y + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NTFS_FS=y +# CONFIG_NTFS_DEBUG is not set +CONFIG_NTFS_RW=y + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_CONFIGFS_FS=m + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_YAFFS_FS=y +CONFIG_YAFFS_YAFFS1=y +# CONFIG_YAFFS_9BYTE_TAGS is not set +# CONFIG_YAFFS_DOES_ECC is not set +CONFIG_YAFFS_YAFFS2=y +CONFIG_YAFFS_AUTO_YAFFS2=y +# CONFIG_YAFFS_DISABLE_TAGS_ECC is not set +# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set +# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set +# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set +CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y +# CONFIG_YAFFS_EMPTY_LOST_AND_FOUND is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +# CONFIG_JFFS2_SUMMARY is not set +# CONFIG_JFFS2_FS_XATTR is not set +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set +CONFIG_JFFS2_ZLIB=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set +# CONFIG_NFS_V4 is not set +CONFIG_ROOT_NFS=y +# CONFIG_NFSD is not set +CONFIG_LOCKD=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_SUNRPC_REGISTER_V4 is not set +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +CONFIG_NLS_UTF8=y +# CONFIG_DLM is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_KERNEL is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_FRAME_POINTER=y +# CONFIG_RCU_CPU_STALL_DETECTOR is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_SYSCTL_SYSCALL_CHECK is not set +CONFIG_HAVE_FUNCTION_TRACER=y + +# +# Tracers +# +# CONFIG_DYNAMIC_PRINTK_DEBUG is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_DEBUG_USER is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_FILE_CAPABILITIES is not set +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=m +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_GF128MUL is not set +CONFIG_CRYPTO_NULL=y +# CONFIG_CRYPTO_CRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_SEQIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +# CONFIG_CRYPTO_CTR is not set +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set + +# +# Hash modes +# +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set + +# +# Digest +# +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set + +# +# Ciphers +# +# CONFIG_CRYPTO_AES is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set + +# +# Compression +# +CONFIG_CRYPTO_DEFLATE=m +# CONFIG_CRYPTO_LZO is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +# CONFIG_CRC_T10DIF is not set +CONFIG_CRC_ITU_T=m +CONFIG_CRC32=y +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_PLIST=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_DMA=y + + +# GUC USB Drivers +# +CONFIG_GUC_USB_UHCI_HCD=m +# CONFIG_GUC_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_GUC_USB_UHCI_MULTIPORT_2 is not set +CONFIG_GUC_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_GADGET_MUSB_HDRC is not set diff --git a/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend b/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend index 3c5b71c..4ff7eac 100644 --- a/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend +++ b/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend @@ -2,4 +2,7 @@ LINUX_VERSION_EXTENSION = "-wedge" COMPATIBLE_MACHINE = "wedge" -KERNEL_CONFIG_COMMAND = "oe_runmake wedge_defconfig && oe_runmake oldconfig" +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://defconfig \ + " diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/bitbang_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/bitbang/bitbang_0.1.bb deleted file mode 100644 index 443d81d..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/bitbang_0.1.bb +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -SUMMARY = "Device driver using GPIO bitbang" -DESCRIPTION = "Various device driver using GPIO bitbang" -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://bitbang.c;beginline=4;endline=16;md5=da35978751a9d71b73679307c4d296ec" - -SRC_URI = "file://src \ - " - -DEPENDS += "fbutils" - -S = "${WORKDIR}/src" - -do_install() { - install -d ${D}${bindir} - install -m 755 spi-bb ${D}${bindir}/spi-bb - install -m 755 mdio-bb ${D}${bindir}/mdio-bb -} - -FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/Makefile b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/Makefile deleted file mode 100644 index 102ac4e..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -all: spi-bb mdio-bb - -spi-bb: spi_bb.o bitbang.o gpio.o - $(CC) -o $@ $^ $(LDFLAGS) - -mdio-bb: mdio_bb.o bitbang.o gpio.o - $(CC) -o $@ $^ $(LDFLAGS) - -.PHONY: clean - -clean: - rm -rf *.o spi-bb mdio-bb diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.c deleted file mode 100644 index cf7dcd3..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "bitbang.h" - -#include <errno.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include "facebook/log.h" - -#define NANOSEC_IN_SEC (1000 * 1000 * 1000) - -#define BITBANG_FREQ_MAX (500 * 1000 * 1000) /* 500M Hz */ -#define BITBANG_FREQ_DEFAULT (1 * 1000 * 1000) /* 1M Hz */ - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -struct bitbang_handle { - bitbang_init_st bbh_init; - uint32_t bbh_half_clk; /* ns per clock cycle */ -}; - -void bitbang_init_default(bitbang_init_st *init) -{ - memset(init, sizeof(*init), 0); - init->bbi_clk_start = BITBANG_PIN_HIGH; - init->bbi_data_out = BITBANG_CLK_EDGE_FALLING; - init->bbi_data_in = BITBANG_CLK_EDGE_RISING; - init->bbi_freq = BITBANG_FREQ_DEFAULT; -} - -bitbang_handle_st* bitbang_open(const bitbang_init_st *init) -{ - bitbang_handle_st *hdl; - - if (!init || !init->bbi_pin_f - || !init->bbi_freq || init->bbi_freq > BITBANG_FREQ_MAX) { - LOG_ERR(EINVAL, "Invalid init structure"); - return NULL; - } - - hdl = calloc(1, sizeof(*hdl)); - if (!hdl) { - return NULL; - } - - hdl->bbh_init = *init; - hdl->bbh_half_clk = NANOSEC_IN_SEC / init->bbi_freq / 2; - - LOG_DBG("Bitbang open with initial %s, data out at %s, data in at %s, " - "freq at %uHz, half clk %uns", - (init->bbi_clk_start == BITBANG_PIN_LOW) ? "LOW" : "HIGH", - (init->bbi_data_out == BITBANG_CLK_EDGE_RISING) - ? "RISING" : "FALLING", - (init->bbi_data_in == BITBANG_CLK_EDGE_RISING) - ? "RISING" : "FALLING", - init->bbi_freq, hdl->bbh_half_clk); - - return hdl; -} - -void bitbang_close(bitbang_handle_st *hdl) -{ - free(hdl); -} - -/* - * The threshold (ns) to use spin instead of nanosleep(). - * Before adding the high resolution timer support, either spin or nanosleep() - * will not bring the process wakeup within 10ms. It turns out the system time - * update is also controlled by HZ (100). - * After I added the high resolution timer support, the spin works as the - * system time is updated more frequently. However, nanosleep() solution is - * still noticable slower comparing with spin. There could be some kernel - * scheduling tweak missing. Did not get time on that yet. - * For now, use 10ms as the threshold to determine if spin or nanosleep() - * is used. - */ -#define BITBANG_SPIN_THRESHOLD (10 * 1000 * 1000) - -static int sleep_ns(uint32_t clk) -{ - struct timespec req, rem; - int rc = 0; - if (clk <= BITBANG_SPIN_THRESHOLD) { - struct timespec orig; - rc = clock_gettime(CLOCK_MONOTONIC, &req); - orig = req; - while (!rc && clk) { - uint32_t tmp; - rc = clock_gettime(CLOCK_MONOTONIC, &rem); - tmp = (rem.tv_sec - req.tv_sec) * NANOSEC_IN_SEC; - if (rem.tv_nsec >= req.tv_nsec) { - tmp += rem.tv_nsec - req.tv_nsec; - } else { - tmp -= req.tv_nsec - rem.tv_nsec; - } - if (tmp >= clk) { - break; - } - clk -= tmp; - req = rem; - } - } else { - req.tv_sec = 0; - req.tv_nsec = clk; - while ((rc = nanosleep(&req, &rem)) == -1 && errno == EINTR) { - req = rem; - } - } - if (rc == -1) { - rc = errno; - LOG_ERR(rc, "Failed to sleep %u nanoseconds", clk); - } - return rc; -} - -int bitbang_io(const bitbang_handle_st *hdl, bitbang_io_st *io) -{ - int rc = 0; - uint32_t clk = hdl->bbh_half_clk; - const struct { - bitbang_pin_value_en value; - bitbang_clk_edge_en edge; - } clks[] = { - {BITBANG_PIN_HIGH, BITBANG_CLK_EDGE_FALLING}, - {BITBANG_PIN_LOW, BITBANG_CLK_EDGE_RISING}, - }; - int clk_idx; - int n_clk = 0; - int n_bits = 0; - const uint8_t *dout = io->bbio_dout; - uint8_t *din = io->bbio_din; - int bit_pos = 7; - bitbang_pin_func pin_f = hdl->bbh_init.bbi_pin_f; - void *context = hdl->bbh_init.bbi_context; - - if ((io->bbio_in_bits == 0 && io->bbio_din) - || (io->bbio_in_bits > 0 && !io->bbio_din)) { - rc = EINVAL; - LOG_ERR(rc, "Incorrect in bits and in buffer"); - goto out; - } - - if ((io->bbio_out_bits == 0 && io->bbio_dout) - || (io->bbio_out_bits > 0 && !io->bbio_dout)) { - rc = EINVAL; - LOG_ERR(rc, "Incorrect out bits and out buffer"); - goto out; - } - - if (io->bbio_in_bits == 0 && io->bbio_out_bits == 0) { - rc = EINVAL; - LOG_ERR(rc, "Both in and out bits are 0"); - goto out; - } - - if (hdl->bbh_init.bbi_clk_start == BITBANG_PIN_HIGH) { - clk_idx = 0; - } else { - clk_idx = 1; - } - - /* set the CLK pin start position */ - pin_f(BITBANG_CLK_PIN, clks[clk_idx].value, context); - - /* clear the first byte of din */ - if (din && io->bbio_in_bits) { - memset(din, 0, (io->bbio_in_bits + 7) / 8); - } - - do { - if ((rc = sleep_ns(clk))) { - goto out; - } - - /* output first */ - if (hdl->bbh_init.bbi_data_out == clks[clk_idx].edge) { - if (dout && n_bits < io->bbio_out_bits) { - pin_f(BITBANG_DATA_OUT, (*dout >> bit_pos) & 0x1, context); - } - } - - /* then, input */ - if (hdl->bbh_init.bbi_data_in == clks[clk_idx].edge) { - if (din && n_bits < io->bbio_in_bits) { - *din |= (pin_f(BITBANG_DATA_IN, 0, context) & 0x1) << bit_pos; - } - } - - if (++n_clk % 2 == 0) { - /* one bit for every 2 half clks */ - n_bits ++; - if (bit_pos == 0) { - if (dout) { - dout++; - } - if (din) { - din++; - } - bit_pos = 7; - } else { - bit_pos --; - } - } - clk_idx = 1 - clk_idx; - pin_f(BITBANG_CLK_PIN, clks[clk_idx].value, context); - } while (n_bits < MAX(io->bbio_in_bits, io->bbio_out_bits)); - - out: - - return -rc; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.h b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.h deleted file mode 100644 index 0f21a49..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef BITBANG_H -#define BITBANG_H - -#include <stdint.h> - -typedef enum { - BITBANG_CLK_PIN, - BITBANG_DATA_IN, - BITBANG_DATA_OUT, -} bitbang_pin_type_en; - -typedef enum { - BITBANG_PIN_LOW = 0, - BITBANG_PIN_HIGH = 1, -} bitbang_pin_value_en; - -typedef enum { - BITBANG_CLK_EDGE_RISING, - BITBANG_CLK_EDGE_FALLING, -} bitbang_clk_edge_en; - -typedef bitbang_pin_value_en (* bitbang_pin_func)( - bitbang_pin_type_en pin, bitbang_pin_value_en value, void *context); - -typedef struct { - bitbang_pin_value_en bbi_clk_start; - bitbang_clk_edge_en bbi_data_out; - bitbang_clk_edge_en bbi_data_in; - uint32_t bbi_freq; - bitbang_pin_func bbi_pin_f; - void *bbi_context; -} bitbang_init_st; - -typedef struct bitbang_handle bitbang_handle_st; - -void bitbang_init_default(bitbang_init_st *init); -bitbang_handle_st* bitbang_open(const bitbang_init_st *init); -void bitbang_close(bitbang_handle_st *hdl); - -typedef struct { - uint32_t bbio_in_bits; - uint32_t bbio_out_bits; - uint8_t *bbio_dout; - uint8_t *bbio_din; -} bitbang_io_st; - -int bitbang_io(const bitbang_handle_st *hdl, bitbang_io_st *io); - -#endif diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.c deleted file mode 100644 index 026aebc..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "gpio.h" - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/errno.h> - -#include "facebook/log.h" - -void gpio_init_default(gpio_st *g) { - g->gs_gpio = -1; - g->gs_fd = -1; -} - -int gpio_open(gpio_st *g, int gpio) -{ - char buf[128]; - int rc; - - snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/value", gpio); - rc = open(buf, O_RDWR); - if (rc == -1) { - rc = errno; - LOG_ERR(rc, "Failed to open %s", buf); - return -rc; - } - g->gs_fd = rc; - g->gs_gpio = gpio; - return 0; -} - -void gpio_close(gpio_st *g) -{ - if (g && g->gs_fd != -1) { - close(g->gs_fd); - } - gpio_init_default(g); -} - -gpio_value_en gpio_read(gpio_st *g) -{ - char buf[32] = {0}; - gpio_value_en v; - lseek(g->gs_fd, 0, SEEK_SET); - read(g->gs_fd, buf, sizeof(buf)); - v = atoi(buf) ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW; - LOG_VER("read gpio=%d value=%d %d", g->gs_gpio, atoi(buf), v); - return v; -} - -void gpio_write(gpio_st *g, gpio_value_en v) -{ - lseek(g->gs_fd, 0, SEEK_SET); - write(g->gs_fd, (v == GPIO_VALUE_HIGH) ? "1" : "0", 1); - LOG_VER("write gpio=%d value=%d", g->gs_gpio, v); -} - -int gpio_change_direction(gpio_st *g, gpio_direction_en dir) -{ - char buf[128]; - char *val; - int fd = -1; - int rc = 0; - - snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/direction", g->gs_gpio); - fd = open(buf, O_WRONLY); - if (fd == -1) { - rc = errno; - LOG_ERR(rc, "Failed to open %s", buf); - return -rc; - } - - val = (dir == GPIO_DIRECTION_IN) ? "in" : "out"; - write(fd, val, strlen(val)); - - LOG_VER("change gpio=%d direction=%s", g->gs_gpio, val); - - out: - if (fd != -1) { - close(fd); - } - return -rc; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.h b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.h deleted file mode 100644 index 3303986..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef GPIO_H -#define GPIO_H - -typedef struct { - int gs_gpio; - int gs_fd; -} gpio_st; - -typedef enum { - GPIO_DIRECTION_IN, - GPIO_DIRECTION_OUT, -} gpio_direction_en; - -typedef enum { - GPIO_VALUE_LOW = 0, - GPIO_VALUE_HIGH = 1, -} gpio_value_en; - -int gpio_open(gpio_st* g, int gpio); -void gpio_close(gpio_st *g); -gpio_value_en gpio_read(gpio_st *g); -void gpio_write(gpio_st *g, gpio_value_en v); -int gpio_change_direction(gpio_st *g, gpio_direction_en dir); - -#endif diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/mdio_bb.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/mdio_bb.c deleted file mode 100644 index ef0c567..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/mdio_bb.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "bitbang.h" -#include "gpio.h" - -#include <stdlib.h> -#include <unistd.h> - -#include "facebook/log.h" - - -typedef struct { - gpio_st m_mdc; - gpio_st m_mdio; -} mdio_context_st; - -/* - * 32b preamble, 2b start of frame, 2b operation code, - * 5b phy addr, 5b register addr, 2b turnaround, 16b data - */ -#define N_BITS (32 + 2 + 2 + 5 + 5 + 2 + 16) -#define N_BYTES (N_BITS + 7 / 8) - -#define START_OF_FRAME 0x1 -#define OP_READ 0x2 -#define OP_WRITE 0x1 -#define TURNAROUND 0x2 /* TA for write, for read, phy sends out TA */ - -void usage() -{ - fprintf(stderr, - "Usage:\n" - "mdio-bb: -c <GPIO for MDC> [-C <HIGH|low>]\n" - " -d <GPIO for MDIO> [-O <rising|FALLING>]\n" - " [-I <RISING|falling>] [-p] [-b]\n" - " <read|write> <phy address> <register address>\n" - " [value to write]\n"); -} - -bitbang_pin_value_en mdio_pin_f( - bitbang_pin_type_en pin, bitbang_pin_value_en value, void *context) -{ - mdio_context_st *ctx = (mdio_context_st *)context; - gpio_st *gpio; - bitbang_pin_value_en res; - - switch (pin) { - case BITBANG_CLK_PIN: - gpio = &ctx->m_mdc; - break; - case BITBANG_DATA_IN: - case BITBANG_DATA_OUT: - gpio = &ctx->m_mdio; - break; - } - if (pin == BITBANG_DATA_IN) { - res = gpio_read(gpio) ? BITBANG_PIN_HIGH : BITBANG_PIN_LOW; - } else { - res = value; - gpio_write(gpio, ((res == BITBANG_PIN_HIGH) - ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW)); - } - return res; -} - -int main(int argc, char* const argv[]) -{ - int opt; - int mdc = -1, mdio = -1; - bitbang_pin_value_en mdc_start = BITBANG_PIN_HIGH; - bitbang_clk_edge_en out_edge = BITBANG_CLK_EDGE_FALLING; - bitbang_clk_edge_en in_edge = BITBANG_CLK_EDGE_RISING; - int is_write; - uint32_t phy_addr; - uint32_t reg_addr; - uint32_t data; /* data to write/read*/ - uint8_t buf[N_BYTES]; - uint8_t *buf_p; - mdio_context_st ctx; - bitbang_init_st init; - bitbang_handle_st *hdl = NULL; - bitbang_io_st io; - int n_bits; - int i; - int rc = 0; - int preamble = 0; - int binary = 0; - - while ((opt = getopt(argc, argv, "bc:C:d:D:p")) != -1) { - switch (opt) { - case 'b': - binary = 1; - break; - case 'c': - mdc = atoi(optarg); - break; - case 'C': - if (!strcasecmp(optarg, "high")) { - mdc_start = BITBANG_PIN_HIGH; - } else if (!strcasecmp(optarg, "low")) { - mdc_start = BITBANG_PIN_LOW; - } else { - usage(); - exit(-1); - } - break; - case 'd': - mdio = atoi(optarg); - break; - case 'I': - if (!strcasecmp(optarg, "rising")) { - in_edge = BITBANG_CLK_EDGE_RISING; - } if (!strcasecmp(optarg, "falling")) { - in_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'O': - if (!strcasecmp(optarg, "rising")) { - out_edge = BITBANG_CLK_EDGE_RISING; - } if (!strcasecmp(optarg, "falling")) { - out_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'p': - preamble = 1; - break; - default: - usage(); - exit(-1); - } - } - - if (mdc < 0 || mdio < 0) { - usage(); - exit(-1); - } - - if (optind + 2 >= argc) { - usage(); - exit(-1); - } - - /* read or write */ - if (!strcasecmp(argv[optind], "read")) { - is_write = 0; - } else if (!strcasecmp(argv[optind], "write")) { - is_write = 1; - } else { - usage(); - exit(-1); - } - - /* phy address, 5 bits only, so must be <= 0x1f */ - phy_addr = strtoul(argv[optind + 1], NULL, 0); - if (phy_addr > 0x1f) { - usage(); - exit(-1); - } - - /* register address, 5 bits only, so must be <= 0x1f */ - reg_addr = strtoul(argv[optind + 2], NULL, 0); - if (reg_addr > 0x1f) { - usage(); - exit(-1); - } - - /* data */ - if (is_write) { - if ((!binary && (optind + 4 != argc)) || - (binary && (optind + 3 != argc))) { - usage(); - exit(-1); - } - if (binary) { - uint16_t temp = 0; - if (fread(&temp, sizeof(temp), 1, stdin) != 1) { - usage(); - exit(-1); - } - data = htons(temp); - } else { - data = strtoul(argv[optind + 3], NULL, 0); - } - if (data > 0xFFFF) { - usage(); - exit(-1); - } - } else { - if ((!binary && (optind + 3 != argc)) || - (binary && (optind + 2 != argc))) { - usage(); - exit(-1); - } - } - - /* open all gpio */ - memset(&ctx, sizeof(ctx), 0); - gpio_init_default(&ctx.m_mdc); - gpio_init_default(&ctx.m_mdio); - if (gpio_open(&ctx.m_mdc, mdc) || gpio_open(&ctx.m_mdio, mdio)) { - goto out; - } - - if (gpio_change_direction(&ctx.m_mdc, GPIO_DIRECTION_OUT) - || gpio_change_direction(&ctx.m_mdio, GPIO_DIRECTION_OUT)) { - goto out; - } - - bitbang_init_default(&init); - init.bbi_clk_start = mdc_start; - init.bbi_data_out = out_edge; - init.bbi_data_in = in_edge; - init.bbi_freq = 1000 * 1000; /* 1M Hz */ - init.bbi_pin_f = mdio_pin_f; - init.bbi_context = &ctx; - hdl = bitbang_open(&init); - if (!hdl) { - goto out; - } - - if (is_write) { - buf[0] = (data >> 8) & 0xFF; - buf[1] = data & 0xFF; - io.bbio_out_bits = 16; - io.bbio_dout = buf; - io.bbio_in_bits = 0; - io.bbio_din = NULL; - } else { - io.bbio_in_bits = 16; - io.bbio_din = buf; - io.bbio_out_bits = 0; - io.bbio_dout = NULL; - } - - /* preamble, 32b */ - buf_p = buf; - n_bits = 0; - if (preamble) { - /* 32 bit of 1 for preamble */ - for (i = 0; i < 4; i++) { - *buf_p++ = 0xFF; - } - n_bits += 32; - } - - /* - * MDIO transaction header is: - * 2b START, 2b OPER CODE, 5b PHY ADDR, 5b register addr, 2b TURNROUND - */ - *buf_p++ = (START_OF_FRAME << 6) | (((is_write) ? OP_WRITE : OP_READ) << 4) - | ((phy_addr >> 1) & 0xF); - *buf_p++ = ((phy_addr & 0x1) << 7) | ((reg_addr & 0x1F) << 2) | TURNAROUND; - if (is_write) { - *buf_p++ = (data >> 8) & 0xFF; - *buf_p++ = data & 0xFF; - /* total # of bits is transaction header + 2 bytes to write */ - n_bits += 2 + 2 + 5 + 5 + 2 + 16; - } else { - /* for read, master does not send TR, so, n_bits should not include TR */ - n_bits += 2 + 2 + 5 + 5; - } - - memset(&io, sizeof(io), 0); - io.bbio_out_bits = n_bits; - io.bbio_dout = buf; - io.bbio_in_bits = 0; - io.bbio_din = NULL; - - rc = bitbang_io(hdl, &io); - if (rc != 0) { - goto out; - } - - /* for read, need to do another io for (2b TR + 16b data) reading */ - if (!is_write) { - /* first, change the MDIO to input */ - gpio_change_direction(&ctx.m_mdio, GPIO_DIRECTION_IN); - /* then, run the clock for read */ - memset(&io, sizeof(io), 0); - io.bbio_out_bits = 0; - io.bbio_dout = NULL;; - io.bbio_in_bits = 18; - io.bbio_din = buf; - - rc = bitbang_io(hdl, &io); - if (rc != 0) { - goto out; - } - - data = ((buf[0] << 2) | (buf[1] >> 6)) & 0xFF; - data <<= 8; - data |= ((buf[1] << 2) | (buf[2] >> 6)) & 0xFF; - } - - if (binary) { - if (!is_write) { - uint16_t temp = ntohs(data); - fwrite(&temp, sizeof(temp), 1, stdout); - } - } else { - printf("%s: 0x%02x\n", (is_write) ? "Wrote" : "Read", data); - } - - out: - if (hdl) { - bitbang_close(hdl); - } - gpio_close(&ctx.m_mdc); - gpio_close(&ctx.m_mdio); - - return 0; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/spi_bb.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/spi_bb.c deleted file mode 100644 index ce366a5..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/spi_bb.c +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "bitbang.h" -#include "gpio.h" - -#include <stdlib.h> -#include <unistd.h> - -#include "facebook/log.h" - -void usage() -{ - fprintf(stderr, - "Usage:\n" - "spi-bb: -s <GPIO for CS> [-S <HIGH|low>]\n" - " -c <GPIO for CLK> [-C <HIGH|low>]\n" - " -o <GPIO for MOSI> [-O <rising|FALLING>]\n" - " -i <GPIO for MISO> [-I <RISING|falling>]\n" - " [-b]\n" - " < [-r <number of bits to read>]\n" - " [-w <number of bits to write> <byte 1> [... byte N]>\n\n" - "Note: If both '-r' and '-w' are provided, 'write' will be performed\n" - " before 'read'.\n"); -} - -typedef struct { - gpio_st sc_clk; - gpio_st sc_mosi; - gpio_st sc_miso; -} spi_context_st; - -bitbang_pin_value_en spi_pin_f( - bitbang_pin_type_en pin, bitbang_pin_value_en value, void *context) -{ - spi_context_st *ctx = (spi_context_st *)context; - gpio_st *gpio; - bitbang_pin_value_en res; - - switch (pin) { - case BITBANG_CLK_PIN: - gpio = &ctx->sc_clk; - break; - case BITBANG_DATA_IN: - gpio = &ctx->sc_miso; - break; - case BITBANG_DATA_OUT: - gpio = &ctx->sc_mosi; - break; - } - if (pin == BITBANG_DATA_IN) { - res = gpio_read(gpio) ? BITBANG_PIN_HIGH : BITBANG_PIN_LOW; - } else { - res = value; - gpio_write(gpio, ((res == BITBANG_PIN_HIGH) - ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW)); - } - return res; -} - -int main(int argc, char * const argv[]) -{ - bitbang_init_st init; - bitbang_handle_st *hdl = NULL; - int cs = -1, clk = -1, in = -1, out = -1; - gpio_st cs_gpio; - int opt; - int is_write = 0; - int is_read = 0; - int read_bits = 0; - int write_bits = 0; - int read_bytes = 0; - int write_bytes = 0; - int i; - uint8_t *read_buf = NULL;; - uint8_t *write_buf = NULL;; - bitbang_clk_edge_en dout_edge = BITBANG_CLK_EDGE_FALLING; - bitbang_clk_edge_en din_edge = BITBANG_CLK_EDGE_RISING; - bitbang_pin_value_en clk_start = BITBANG_PIN_HIGH; - bitbang_pin_value_en cs_value = BITBANG_PIN_HIGH; - spi_context_st ctx; - bitbang_io_st io; - int rc = 0; - int binary = 0; - - memset(&ctx, sizeof(ctx), 0); - gpio_init_default(&ctx.sc_clk); - gpio_init_default(&ctx.sc_mosi); - gpio_init_default(&ctx.sc_miso); - gpio_init_default(&cs_gpio); - - while ((opt = getopt(argc, argv, "bs:S:c:C:o:O:i:I:w:r:")) != -1) { - switch (opt) { - case 'b': - binary = 1; - break; - case 's': - cs = atoi(optarg); - break; - case 'S': - if (!strcmp(optarg, "high")) { - cs_value = BITBANG_PIN_HIGH; - } else if (!strcmp(optarg, "low")) { - cs_value = BITBANG_PIN_LOW; - } else { - usage(); - exit(-1); - } - break; - case 'c': - clk = atoi(optarg); - break; - case 'C': - if (!strcasecmp(optarg, "high")) { - clk_start = BITBANG_PIN_HIGH; - } else if (!strcasecmp(optarg, "low")) { - clk_start = BITBANG_PIN_LOW; - } else { - usage(); - exit(-1); - } - break; - case 'o': - out = atoi(optarg); - break; - case 'O': - if (!strcasecmp(optarg, "rising")) { - dout_edge = BITBANG_CLK_EDGE_RISING; - } else if (!strcasecmp(optarg, "falling")) { - dout_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'i': - in = atoi(optarg); - break; - case 'I': - if (!strcasecmp(optarg, "rising")) { - din_edge = BITBANG_CLK_EDGE_RISING; - } else if (!strcasecmp(optarg, "falling")) { - din_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'w': - is_write = 1; - write_bits = atoi(optarg); - if (write_bits <= 0) { - usage(); - exit(-1); - } - break; - case 'r': - is_read = 1; - read_bits = atoi(optarg); - if (read_bits <= 0) { - usage(); - exit(-1); - } - break; - default: - usage(); - exit(-1); - } - } - - if (clk < 0 || in < 0 || out < 0) { - usage(); - exit(-1); - } - - if ((!is_read && !is_write)) { - usage(); - exit(-1); - } - - write_bytes = ((write_bits + 7) / 8); - if (write_bytes) { - write_buf = calloc(write_bytes, sizeof(uint8_t)); - if (!write_buf) { - goto out; - } - if (binary) { - size_t written_bytes; - written_bytes = fread(write_buf, sizeof(*write_buf), write_bytes, stdin); - if( written_bytes != write_bytes ) { - goto out; - } - } else { - for (i = 0; i < write_bytes && i + optind < argc; i++) { - write_buf[i] = strtoul(argv[i + optind], NULL, 0); - } - } - } - - read_bytes = ((read_bits + 7) / 8); - if (read_bytes) { - read_buf = calloc(read_bytes, sizeof(uint8_t)); - if (!read_buf) { - goto out; - } - } - - if (gpio_open(&ctx.sc_clk, clk) || gpio_open(&ctx.sc_miso, in) - || gpio_open(&ctx.sc_mosi, out)) { - goto out; - } - - /* change GPIO directions, only MISO is input, all others are output */ - if (gpio_change_direction(&ctx.sc_clk, GPIO_DIRECTION_OUT) - || gpio_change_direction(&ctx.sc_miso, GPIO_DIRECTION_IN) - || gpio_change_direction(&ctx.sc_mosi, GPIO_DIRECTION_OUT)) { - goto out; - } - - if (cs != -1) { - if (gpio_open(&cs_gpio, cs)) { - goto out; - } - if (gpio_change_direction(&cs_gpio, GPIO_DIRECTION_OUT)) { - goto out; - } - } - - bitbang_init_default(&init); - init.bbi_clk_start = clk_start; - init.bbi_data_out = dout_edge; - init.bbi_data_in = din_edge; - init.bbi_freq = 1000 * 1000; /* 1M Hz */ - init.bbi_pin_f = spi_pin_f; - init.bbi_context = &ctx; - - hdl = bitbang_open(&init); - if (!hdl) { - goto out; - } - - if (cs != -1) { - /* have chip select */ - gpio_write(&cs_gpio, ((cs_value == BITBANG_PIN_HIGH) - ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW)); - } - - memset(&io, sizeof(io), 0); - io.bbio_in_bits = read_bits; - io.bbio_din = read_buf; - io.bbio_out_bits = write_bits; - io.bbio_dout = write_buf; - - rc = bitbang_io(hdl, &io); - if (rc != 0) { - goto out; - } - - if (binary) { - fwrite(read_buf, sizeof(*read_buf), read_bytes, stdout); - } else { - if (write_bits) { - printf("Wrote %u bits:", write_bits); - for (i = 0; i < write_bytes; i++) { - printf(" %02x", write_buf[i]); - } - printf("\n"); - } - - if (read_bits) { - printf("Read %u bits:", read_bits); - for (i = 0; i < read_bytes; i++) { - printf(" %02x", read_buf[i]); - } - printf("\n"); - } - } - - out: - if (hdl) { - bitbang_close(hdl); - } - gpio_close(&ctx.sc_clk); - gpio_close(&ctx.sc_miso); - gpio_close(&ctx.sc_mosi); - if (cs != -1) { - /* reset have chip select */ - gpio_write(&cs_gpio, ((cs_value == BITBANG_PIN_HIGH) - ? GPIO_VALUE_LOW : GPIO_VALUE_HIGH)); - gpio_close(&cs_gpio); - } - - if (read_buf) { - free(read_buf); - } - if (write_buf) { - free(write_buf); - } - return rc; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/Makefile b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/Makefile deleted file mode 100644 index fa9a8f4..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -all: fand - -fand: fand.cpp watchdog.cpp - $(CXX) -pthread -o $@ $^ $(LDFLAGS) -lwedge_eeprom - -.PHONY: clean - -clean: - rm -rf *.o fand diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/README b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/README deleted file mode 100644 index 2a92b9d..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/README +++ /dev/null @@ -1,5 +0,0 @@ -The AST PWM/Tach driver is in the kernel sources at drivers/hwmon/ast_pwm_fan.c - -There are 7 PWM output pins. Each PWM can be configured in one of 3 types (M, -N, or O). The clock settings for each type are configurable. See init_pwm.sh -for more comments about how we configure the settings. diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/fand.cpp b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/fand.cpp deleted file mode 100644 index 24e107c..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/fand.cpp +++ /dev/null @@ -1,851 +0,0 @@ -/* - * fand - * - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Daemon to manage the fan speed to ensure that we stay within a reasonable - * temperature range. We're using a simplistic algorithm to get started: - * - * If the fan is already on high, we'll move it to medium if we fall below - * a top temperature. If we're on medium, we'll move it to high - * if the temperature goes over the top value, and to low if the - * temperature falls to a bottom level. If the fan is on low, - * we'll increase the speed if the temperature rises to the top level. - * - * To ensure that we're not just turning the fans up, then back down again, - * we'll require an extra few degrees of temperature drop before we lower - * the fan speed. - * - * We check the RPM of the fans against the requested RPMs to determine - * whether the fans are failing, in which case we'll turn up all of - * the other fans and report the problem.. - * - * TODO: Implement a PID algorithm to closely track the ideal temperature. - * TODO: Determine if the daemon is already started. - */ - -/* Yeah, the file ends in .cpp, but it's a C program. Deal. */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> -#include <signal.h> -#include <syslog.h> -#include "watchdog.h" - -#include "facebook/wedge_eeprom.h" - -/* Sensor definitions */ - -#define INTERNAL_TEMPS(x) ((x) * 1000) // stored a C * 1000 -#define EXTERNAL_TEMPS(x) ((x) / 1000) - -#define I2C_BUS_3_DIR "/sys/class/i2c-adapter/i2c-3/" -#define I2C_BUS_4_DIR "/sys/class/i2c-adapter/i2c-4/" - -#define INTAKE_TEMP_DEVICE I2C_BUS_3_DIR "3-0048" -#define T2_TEMP_DEVICE I2C_BUS_3_DIR "3-0049" -#define EXHAUST_TEMP_DEVICE I2C_BUS_3_DIR "3-004a" -#define USERVER_TEMP_DEVICE I2C_BUS_4_DIR "4-0040" - -/* - * The sensor for the uServer CPU is not on the CPU itself, so it reads - * a little low. We are special casing this, but we should obviously - * be thinking about a way to generalize these tweaks, and perhaps - * the entire configuration. JSON file? - */ - -#define USERVER_TEMP_FUDGE INTERNAL_TEMPS(10) - -#define BAD_TEMP INTERNAL_TEMPS(-60) - -#define BAD_READ_THRESHOLD 4 /* How many times can reads fail */ -#define FAN_FAILURE_THRESHOLD 4 /* How many times can a fan fail */ - -#define PWM_DIR "/sys/devices/platform/ast_pwm_tacho.0" - -#define PWM_UNIT_MAX 96 - -#define LARGEST_DEVICE_NAME 120 - -#define GPIO_USERVER_POWER_DIRECTION "/sys/class/gpio/gpio25/direction" -#define GPIO_USERVER_POWER "/sys/class/gpio/gpio25/value" -#define GPIO_T2_POWER_DIRECTION "/sys/class/gpio/gpio41/direction" -#define GPIO_T2_POWER "/sys/class/gpio/gpio41/value" - -#define GPIO_FAN0_LED "/sys/class/gpio/gpio53/value" -#define GPIO_FAN1_LED "/sys/class/gpio/gpio54/value" -#define GPIO_FAN2_LED "/sys/class/gpio/gpio55/value" -#define GPIO_FAN3_LED "/sys/class/gpio/gpio72/value" - -const char *fan_led[] = {GPIO_FAN0_LED, GPIO_FAN1_LED, - GPIO_FAN2_LED, GPIO_FAN3_LED}; - -#define FAN_LED_RED "0" -#define FAN_LED_BLUE "1" - -#define GPIO_PIN_ID "/sys/class/gpio/gpio%d/value" -#define REV_IDS 3 -#define GPIO_REV_ID_START 192 - -#define BOARD_IDS 4 -#define GPIO_BOARD_ID_START 160 - -/* - * With hardware revisions after 3, we use a different set of pins for - * the BOARD_ID. - */ - -#define REV_ID_NEW_BOARD_ID 3 -#define GPIO_BOARD_ID_START_NEW 166 - -#define REPORT_TEMP 720 /* Report temp every so many cycles */ - -/* Sensor limits and tuning parameters */ - -#define INTAKE_LIMIT INTERNAL_TEMPS(60) -#define T2_LIMIT INTERNAL_TEMPS(95) -#define USERVER_LIMIT INTERNAL_TEMPS(75) - -#define TEMP_TOP INTERNAL_TEMPS(70) -#define TEMP_BOTTOM INTERNAL_TEMPS(40) - -/* - * Toggling the fan constantly will wear it out (and annoy anyone who - * can hear it), so we'll only turn down the fan after the temperature - * has dipped a bit below the point at which we'd otherwise switch - * things up. - */ - -#define COOLDOWN_SLOP INTERNAL_TEMPS(6) - -#define FAN_LOW 35 -#define FAN_MEDIUM 50 -#define FAN_HIGH 70 -#define FAN_MAX 99 - -/* - * Mapping physical to hardware addresses for fans; it's different for - * RPM measuring and PWM setting, naturally. Doh. - */ - -int fan_to_rpm_map[] = {3, 2, 0, 1}; -int fan_to_pwm_map[] = {7, 6, 0, 1}; - -#define FANS 4 - -/* - * The measured RPM of the fans doesn't match linearly to the requested - * rate. In addition, there are coaxially mounted fans, so the rear fans - * feed into the front fans. The rear fans will run slower since they're - * grabbing still air, and the front fants are getting an extra boost. - * - * We'd like to measure the fan RPM and compare it to the expected RPM - * so that we can detect failed fans, so we have a table (derived from - * hardware testing): - */ - -struct rpm_to_pct_map { - ushort pct; - ushort rpm; -}; - -struct rpm_to_pct_map rpm_front_map[] = {{30, 6150}, - {35, 7208}, - {40, 8195}, - {45, 9133}, - {50, 10017}, - {55, 10847}, - {60, 11612}, - {65, 12342}, - {70, 13057}, - {75, 13717}, - {80, 14305}, - {85, 14869}, - {90, 15384}, - {95, 15871}, - {100, 16095}}; - -struct rpm_to_pct_map rpm_rear_map[] = {{30, 3911}, - {35, 4760}, - {40, 5587}, - {45, 6434}, - {50, 7295}, - {55, 8187}, - {60, 9093}, - {65, 10008}, - {70, 10949}, - {75, 11883}, - {80, 12822}, - {85, 13726}, - {90, 14690}, - {95, 15516}, - {100, 15897}}; - -#define FAN_FAILURE_OFFSET 30 - -int fan_low = FAN_LOW; -int fan_medium = FAN_MEDIUM; -int fan_high = FAN_HIGH; -int fan_max = FAN_MAX; -int total_fans = FANS; -int fan_offset = 0; - -int temp_bottom = TEMP_BOTTOM; -int temp_top = TEMP_TOP; - -int report_temp = REPORT_TEMP; -bool verbose = false; - -void usage() { - fprintf(stderr, - "fand [-v] [-l <low-pct>] [-m <medium-pct>] " - "[-h <high-pct>]\n" - "\t[-b <temp-bottom>] [-t <temp-top>] [-r <report-temp>]\n\n" - "\tlow-pct defaults to %d%% fan\n" - "\tmedium-pct defaults to %d%% fan\n" - "\thigh-pct defaults to %d%% fan\n" - "\ttemp-bottom defaults to %dC\n" - "\ttemp-top defaults to %dC\n" - "\treport-temp defaults to every %d measurements\n\n" - "fand compensates for uServer temperature reading %d degrees low\n" - "kill with SIGUSR1 to stop watchdog\n", - fan_low, - fan_medium, - fan_high, - EXTERNAL_TEMPS(temp_bottom), - EXTERNAL_TEMPS(temp_top), - report_temp, - EXTERNAL_TEMPS(USERVER_TEMP_FUDGE)); - exit(1); -} - -/* We need to open the device each time to read a value */ - -int read_device(const char *device, int *value) { - FILE *fp; - int rc; - - fp = fopen(device, "r"); - if (!fp) { - int err = errno; - - syslog(LOG_INFO, "failed to open device %s", device); - return err; - } - - rc = fscanf(fp, "%d", value); - fclose(fp); - - if (rc != 1) { - syslog(LOG_INFO, "failed to read device %s", device); - return ENOENT; - } else { - return 0; - } -} - -/* We need to open the device again each time to write a value */ - -int write_device(const char *device, const char *value) { - FILE *fp; - int rc; - - fp = fopen(device, "w"); - if (!fp) { - int err = errno; - - syslog(LOG_INFO, "failed to open device for write %s", device); - return err; - } - - rc = fputs(value, fp); - fclose(fp); - - if (rc < 0) { - syslog(LOG_INFO, "failed to write device %s", device); - return ENOENT; - } else { - return 0; - } -} - -int read_temp(const char *device, int *value) { - char full_name[LARGEST_DEVICE_NAME + 1]; - - /* We set an impossible value to check for errors */ - *value = BAD_TEMP; - snprintf( - full_name, LARGEST_DEVICE_NAME, "%s/temp1_input", device); - return read_device(full_name, value); -} - -int read_gpio_value(const int id, const char *device, int *value) { - char full_name[LARGEST_DEVICE_NAME]; - - snprintf(full_name, LARGEST_DEVICE_NAME, device, id); - return read_device(full_name, value); -} - -int read_gpio_values(const int start, const int count, - const char *device, int *result) { - int status = 0; - int value; - - *result = 0; - for (int i = 0; i < count; i++) { - status |= read_gpio_value(start + i, GPIO_PIN_ID, &value); - *result |= value << i; - } - return status; -} - -int read_ids(int *rev_id, int *board_id) { - int status = 0; - int value; - - status = read_gpio_values(GPIO_REV_ID_START, REV_IDS, GPIO_PIN_ID, rev_id); - if (status != 0) { - syslog(LOG_INFO, "failed to read rev_id"); - return status; - } - - int board_id_start; - if (*rev_id >= REV_ID_NEW_BOARD_ID) { - board_id_start = GPIO_BOARD_ID_START_NEW; - } else { - board_id_start = GPIO_BOARD_ID_START; - } - - status = read_gpio_values(board_id_start, BOARD_IDS, GPIO_PIN_ID, board_id); - if (status != 0) { - syslog(LOG_INFO, "failed to read board_id"); - } - return status; -} - -bool is_two_fan_board(bool verbose) { - struct wedge_eeprom_st eeprom; - /* Retrieve the board type from EEPROM */ - if (wedge_eeprom_parse(NULL, &eeprom) == 0) { - /* able to parse EEPROM */ - if (verbose) { - syslog(LOG_INFO, "board type is %s", eeprom.fbw_location); - } - /* only WEDGE is NOT two-fan board */ - return strncasecmp(eeprom.fbw_location, "wedge", - sizeof(eeprom.fbw_location)); - } else { - int status; - int board_id = 0; - int rev_id = 0; - /* - * Could not parse EEPROM. Most likely, it is an old HW without EEPROM. - * In this case, use board ID to distinguish if it is wedge or 6-pack. - */ - status = read_ids(&rev_id, &board_id); - if (verbose) { - syslog(LOG_INFO, "rev ID %d, board id %d", rev_id, board_id); - } - if (status == 0 && board_id != 0xf) { - return true; - } else { - return false; - } - } -} - -int read_fan_value(const int fan, const char *device, int *value) { - char device_name[LARGEST_DEVICE_NAME]; - char output_value[LARGEST_DEVICE_NAME]; - char full_name[LARGEST_DEVICE_NAME]; - - snprintf(device_name, LARGEST_DEVICE_NAME, device, fan); - snprintf(full_name, LARGEST_DEVICE_NAME, "%s/%s", PWM_DIR, device_name); - return read_device(full_name, value); -} - -int write_fan_value(const int fan, const char *device, const int value) { - char full_name[LARGEST_DEVICE_NAME]; - char device_name[LARGEST_DEVICE_NAME]; - char output_value[LARGEST_DEVICE_NAME]; - - snprintf(device_name, LARGEST_DEVICE_NAME, device, fan); - snprintf(full_name, LARGEST_DEVICE_NAME, "%s/%s", PWM_DIR, device_name); - snprintf(output_value, LARGEST_DEVICE_NAME, "%d", value); - return write_device(full_name, output_value); -} - -/* Return fan speed as a percentage of maximum -- not necessarily linear. */ - -int fan_rpm_to_pct(const struct rpm_to_pct_map *table, - const int table_len, - int rpm) { - int i; - - for (i = 0; i < table_len; i++) { - if (table[i].rpm > rpm) { - break; - } - } - - /* - * If the fan RPM is lower than the lowest value in the table, - * we may have a problem -- fans can only go so slow, and it might - * have stopped. In this case, we'll return an interpolated - * percentage, as just returning zero is even more problematic. - */ - - if (i == 0) { - return (rpm * table[i].pct) / table[i].rpm; - } else if (i == table_len) { // Fell off the top? - return table[i - 1].pct; - } - - // Interpolate the right percentage value: - - int percent_diff = table[i].pct - table[i - 1].pct; - int rpm_diff = table[i].rpm - table[i - 1].rpm; - int fan_diff = table[i].rpm - rpm; - - return table[i].pct - (fan_diff * percent_diff / rpm_diff); -} - -int fan_speed_okay(const int fan, const int speed, const int slop) { - int front_fan, rear_fan; - int front_pct, rear_pct; - int real_fan; - int okay; - - /* - * The hardware fan numbers are different from the physical order - * in the box, so we have to map them: - */ - - real_fan = fan_to_rpm_map[fan]; - - front_fan = 0; - rear_fan = 0; - read_fan_value(real_fan, "tacho%d_rpm", &front_fan); - read_fan_value(real_fan + 4, "tacho%d_rpm", &rear_fan); - - front_pct = - fan_rpm_to_pct(rpm_front_map, - sizeof(rpm_front_map) / sizeof(struct rpm_to_pct_map), - front_fan); - rear_pct = - fan_rpm_to_pct(rpm_rear_map, - sizeof(rpm_rear_map) / sizeof(struct rpm_to_pct_map), - rear_fan); - - /* - * If the fans are broken, the measured rate will be rather - * different from the requested rate, and we can turn up the - * rest of the fans to compensate. The slop is the percentage - * of error that we'll tolerate. - * - * XXX: I suppose that we should only measure negative values; - * running too fast isn't really a problem. - */ - - okay = (abs(front_pct - speed) * 100 / speed < slop && - abs(rear_pct - speed) * 100 / speed < slop); - - if (!okay || verbose) { - syslog(!okay ? LOG_ALERT : LOG_INFO, - "fan %d rear %d (%d%%), front %d (%d%%), expected %d", - fan, - rear_fan, - rear_pct, - front_fan, - front_pct, - speed); - } - - return okay; -} - -/* Set fan speed as a percentage */ - -int write_fan_speed(const int fan, const int value) { - /* - * The hardware fan numbers for pwm control are different from - * both the physical order in the box, and the mapping for reading - * the RPMs per fan, above. - */ - - int real_fan = fan_to_pwm_map[fan]; - - if (value == 0) { - return write_fan_value(real_fan, "pwm%d_en", 0); - } else { - int unit = value * PWM_UNIT_MAX / 100; - int status; - - if (unit == PWM_UNIT_MAX) - unit = 0; - - if ((status = write_fan_value(real_fan, "pwm%d_type", 0)) != 0 || - (status = write_fan_value(real_fan, "pwm%d_rising", 0)) != 0 || - (status = write_fan_value(real_fan, "pwm%d_falling", unit)) != 0 || - (status = write_fan_value(real_fan, "pwm%d_en", 1)) != 0) { - return status; - } - } -} - -/* Set up fan LEDs */ - -int write_fan_led(const int fan, const char *color) -{ - return write_device(fan_led[fan], color); -} - -int server_shutdown(const char *why) { - int fan; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_max); - } - - syslog(LOG_EMERG, "Shutting down: %s", why); - write_device(GPIO_USERVER_POWER_DIRECTION, "out"); - write_device(GPIO_USERVER_POWER, "0"); - /* - * Putting T2 in reset generating a non-maskable interrupt to uS, - * the kernel running on uS might panic depending on its version. - * sleep 5s here to make sure uS is completely down. - */ - sleep(5); - write_device(GPIO_T2_POWER_DIRECTION, "out"); - write_device(GPIO_T2_POWER, "0"); - - /* - * We have to stop the watchdog, or the system will be automatically - * rebooted some seconds after fand exits (and stops kicking the - * watchdog). - */ - - stop_watchdog(); - - sleep(2); - exit(2); -} - -/* Gracefully shut down on receipt of a signal */ - -void fand_interrupt(int sig) -{ - int fan; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_max); - } - - syslog(LOG_ALERT, "Shutting down fand on signal %s", strsignal(sig)); - if (sig == SIGUSR1) { - stop_watchdog(); - } - exit(3); -} - -int main(int argc, char **argv) { - /* Sensor values */ - - int intake_temp; - int exhaust_temp; - int t2_temp; - int userver_temp; - - int fan_speed = FAN_HIGH; - int bad_reads = 0; - int fan_failure = 0; - int fan_speed_changes = 0; - int old_speed; - - int fan_bad[FANS]; - int fan; - - unsigned log_count = 0; // How many times have we logged our temps? - int opt; - int prev_fans_bad = 0; - - struct sigaction sa; - - sa.sa_handler = fand_interrupt; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGUSR1, &sa, NULL); - - while ((opt = getopt(argc, argv, "l:m:h:b:t:r:v")) != -1) { - switch (opt) { - case 'l': - fan_low = atoi(optarg); - break; - case 'm': - fan_medium = atoi(optarg); - break; - case 'h': - fan_high = atoi(optarg); - break; - case 'b': - temp_bottom = INTERNAL_TEMPS(atoi(optarg)); - break; - case 't': - temp_top = INTERNAL_TEMPS(atoi(optarg)); - break; - case 'r': - report_temp = atoi(optarg); - break; - case 'v': - verbose = true; - break; - default: - usage(); - break; - } - } - - if (optind > argc) { - usage(); - } - - if (temp_bottom > temp_top) { - fprintf(stderr, - "Should temp-bottom (%d) be higher than " - "temp-top (%d)? Starting anyway.\n", - EXTERNAL_TEMPS(temp_bottom), - EXTERNAL_TEMPS(temp_top)); - } - - if (fan_low > fan_medium || fan_low > fan_high || fan_medium > fan_high) { - fprintf(stderr, - "fan RPMs not strictly increasing " - "-- %d, %d, %d, starting anyway\n", - fan_low, - fan_medium, - fan_high); - } - - daemon(1, 0); - openlog("fand", LOG_CONS, LOG_DAEMON); - - /* Start watchdog in manual mode */ - start_watchdog(0); - - /* Set watchdog to persistent mode so timer expiry will happen independent - * of this process's liveliness. */ - set_persistent_watchdog(WATCHDOG_SET_PERSISTENT); - - if (is_two_fan_board(verbose)) { - /* Alternate, two fan configuration */ - total_fans = 2; - fan_offset = 2; /* fan 3 is the first */ - } - - for (fan = 0; fan < total_fans; fan++) { - fan_bad[fan] = 0; - write_fan_speed(fan + fan_offset, fan_speed); - write_fan_led(fan + fan_offset, FAN_LED_BLUE); - } - - sleep(5); /* Give the fans time to come up to speed */ - - while (1) { - int max_temp; - old_speed = fan_speed; - - /* Read sensors */ - - read_temp(INTAKE_TEMP_DEVICE, &intake_temp); - read_temp(EXHAUST_TEMP_DEVICE, &exhaust_temp); - read_temp(T2_TEMP_DEVICE, &t2_temp); - read_temp(USERVER_TEMP_DEVICE, &userver_temp); - - /* - * uServer can be powered down, but all of the rest of the sensors - * should be readable at any time. - */ - - if ((intake_temp == BAD_TEMP || exhaust_temp == BAD_TEMP || - t2_temp == BAD_TEMP)) { - bad_reads++; - } - - if (bad_reads > BAD_READ_THRESHOLD) { - server_shutdown("Some sensors couldn't be read"); - } - - if (log_count++ % report_temp == 0) { - syslog(LOG_DEBUG, - "Temp intake %d, t2 %d, userver %d, exhaust %d, " - "fan speed %d, speed changes %d", - intake_temp, - t2_temp, - userver_temp, - exhaust_temp, - fan_speed, - fan_speed_changes); - } - - /* Protection heuristics */ - - if (intake_temp > INTAKE_LIMIT) { - server_shutdown("Intake temp limit reached"); - } - - if (t2_temp > T2_LIMIT) { - server_shutdown("T2 temp limit reached"); - } - - if (userver_temp + USERVER_TEMP_FUDGE > USERVER_LIMIT) { - server_shutdown("uServer temp limit reached"); - } - - /* - * Calculate change needed -- we should eventually - * do something more sophisticated, like PID. - * - * We should use the intake temperature to adjust this - * as well. - */ - - if (t2_temp > userver_temp + USERVER_TEMP_FUDGE) { - max_temp = t2_temp; - } else { - max_temp = userver_temp + USERVER_TEMP_FUDGE; - } - - /* - * If recovering from a fan problem, spin down fans gradually in case - * temperatures are still high. Gradual spin down also reduces wear on - * the fans. - */ - if (fan_speed == fan_max) { - if (fan_failure == 0) { - fan_speed = fan_high; - } - } else if (fan_speed == fan_high) { - if (max_temp + COOLDOWN_SLOP < temp_top) { - fan_speed = fan_medium; - } - } else if (fan_speed == fan_medium) { - if (max_temp > temp_top) { - fan_speed = fan_high; - } else if (max_temp + COOLDOWN_SLOP < temp_bottom) { - fan_speed = fan_low; - } - } else {/* low */ - if (max_temp > temp_bottom) { - fan_speed = fan_medium; - } - } - - /* - * Update fans only if there are no failed ones. If any fans failed - * earlier, all remaining fans should continue to run at max speed. - */ - - if (fan_failure == 0 && fan_speed != old_speed) { - syslog(LOG_NOTICE, - "Fan speed changing from %d to %d", - old_speed, - fan_speed); - fan_speed_changes++; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_speed); - } - } - - /* - * Wait for some change. Typical I2C temperature sensors - * only provide a new value every second and a half, so - * checking again more quickly than that is a waste. - * - * We also have to wait for the fan changes to take effect - * before measuring them. - */ - - sleep(5); - - /* Check fan RPMs */ - - for (fan = 0; fan < total_fans; fan++) { - /* - * Make sure that we're within some percentage - * of the requested speed. - */ - if (fan_speed_okay(fan + fan_offset, fan_speed, FAN_FAILURE_OFFSET)) { - if (fan_bad[fan] > FAN_FAILURE_THRESHOLD) { - write_fan_led(fan + fan_offset, FAN_LED_BLUE); - syslog(LOG_NOTICE, - "Fan %d has recovered", - fan); - } - fan_bad[fan] = 0; - } else { - fan_bad[fan]++; - } - } - - fan_failure = 0; - for (fan = 0; fan < total_fans; fan++) { - if (fan_bad[fan] > FAN_FAILURE_THRESHOLD) { - fan_failure++; - write_fan_led(fan + fan_offset, FAN_LED_RED); - } - } - - if (fan_failure > 0) { - if (prev_fans_bad != fan_failure) { - syslog(LOG_ALERT, "%d fans failed", fan_failure); - } - - /* - * If fans are bad, we need to blast all of the - * fans at 100%; we don't bother to turn off - * the bad fans, in case they are all that is left. - * - * Note that we have a temporary bug with setting fans to - * 100% so we only do fan_max = 99%. - */ - - fan_speed = fan_max; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_speed); - } - - /* - * Fans can be hot swapped and replaced; in which case the fan daemon - * will automatically detect the new fan and (assuming the new fan isn't - * itself faulty), automatically readjust the speeds for all fans down - * to a more suitable rpm. The fan daemon does not need to be restarted. - */ - } - - /* Suppress multiple warnings for similar number of fan failures. */ - prev_fans_bad = fan_failure; - - /* if everything is fine, restart the watchdog countdown. If this process - * is terminated, the persistent watchdog setting will cause the system - * to reboot after the watchdog timeout. */ - kick_watchdog(); - } -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.cpp b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.cpp deleted file mode 100644 index ebb390a..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * watchdog - * - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "watchdog.h" - -#include <errno.h> -#include <fcntl.h> -#include <pthread.h> -#include <syslog.h> -#include <unistd.h> - -#define WATCHDOG_START_KEY "x" -#define WATCHDOG_STOP_KEY "X" -/* The "magic close" character (as defined in Linux watchdog specs). */ -#define WATCHDOG_PERSISTENT_KEY "V" -#define WATCHDOG_NON_PERSISTENT_KEY "a" - -static int watchdog_dev = -1; - -/* This is needed to prevent rapid consecutive stop/start watchdog calls from - * generating multiple threads. */ -static int watchdog_started = 0; - -static const char* watchdog_kick_key = WATCHDOG_PERSISTENT_KEY; -static pthread_t watchdog_tid; -static pthread_mutex_t watchdog_lock = PTHREAD_MUTEX_INITIALIZER; - -/* Forward declarations. */ -static void* watchdog_thread(void* args); -static int kick_watchdog_unsafe(); - -/* - * When started, this background thread will constantly reset the watchdog - * at every 5 second interval. - */ - -static void* watchdog_thread(void* args) { - - pthread_detach(pthread_self()); - - /* Make sure another instance of the thread hasn't already been started. */ - pthread_mutex_lock(&watchdog_lock); - if (watchdog_started) { - goto done; - } else { - watchdog_started = 1; - } - pthread_mutex_unlock(&watchdog_lock); - - /* Actual loop for refreshing the watchdog timer. */ - while (1) { - pthread_mutex_lock(&watchdog_lock); - if (watchdog_dev != -1) { - kick_watchdog_unsafe(); - } else { - break; - } - pthread_mutex_unlock(&watchdog_lock); - sleep(5); - } - - /* Broke out of loop because watchdog was stopped. */ - watchdog_started = 0; -done: - pthread_mutex_unlock(&watchdog_lock); - return NULL; -} - -/* - * Starts the watchdog timer. timer counts down and restarts the ARM chip - * upon timeout. use kick_watchdog() to restart the timer. - * - * Returns: 1 on success; 0 otherwise. - */ - -int start_watchdog(const int auto_mode) { - int status; - - pthread_mutex_lock(&watchdog_lock); - - /* Don't start the watchdog again if it has already been started. */ - if (watchdog_dev != -1) { - while ((status = write(watchdog_dev, WATCHDOG_START_KEY, 1)) == 0 - && errno == EINTR); - pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_ALERT, "system watchdog already started.\n"); - return 0; - } - - while (((watchdog_dev = open("/dev/watchdog", O_WRONLY)) == -1) && - errno == EINTR); - - /* Fail if watchdog device is invalid or if the user asked for auto - * mode and the thread failed to spawn. */ - if ((watchdog_dev == -1) || - (auto_mode == 1 && watchdog_started == 0 && - pthread_create(&watchdog_tid, NULL, watchdog_thread, NULL) != 0)) { - goto fail; - } - - while ((status = write(watchdog_dev, WATCHDOG_START_KEY, 1)) == 0 - && errno == EINTR); - pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_INFO, "system watchdog started.\n"); - return 1; - -fail: - if (watchdog_dev != -1) { - close(watchdog_dev); - watchdog_dev = -1; - } - - pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_ALERT, "system watchdog failed to start!\n"); - return 0; -} - -/* - * Toggles between watchdog persistent modes. In persistent mode, the watchdog - * timer will continue to tick even after process shutdown. Under non- - * persistent mode, the watchdog timer will automatically be disabled when the - * process shuts down. - */ -void set_persistent_watchdog(enum watchdog_persistent_en persistent) { - switch (persistent) { - case WATCHDOG_SET_PERSISTENT: - watchdog_kick_key = WATCHDOG_PERSISTENT_KEY; - break; - default: - watchdog_kick_key = WATCHDOG_NON_PERSISTENT_KEY; - break; - } - kick_watchdog(); -} - -/* - * Restarts the countdown timer on the watchdog, delaying restart by another - * timeout period (default: 11 seconds as configured in the device driver). - * - * This function assumes the watchdog lock has already been acquired and is - * only used internally within the watchdog code. - * - * Returns 1 on success; 0 or -1 indicates failure (check errno). - */ - -static int kick_watchdog_unsafe() { - int status = 0; - if (watchdog_dev != -1) { - while ((status = write(watchdog_dev, watchdog_kick_key, 1)) == 0 - && errno == EINTR); - } - return status; -} - -/* - * Acquires the watchdog lock and resets the watchdog atomically. For use by - * library users. - */ - -int kick_watchdog() { - int result; - pthread_mutex_lock(&watchdog_lock); - result = kick_watchdog_unsafe(); - pthread_mutex_unlock(&watchdog_lock); - - return result; -} - -/* Shuts down the watchdog gracefully and disables the watchdog timer so that - * restarts no longer happen. - */ - -void stop_watchdog() { - int status; - pthread_mutex_lock(&watchdog_lock); - if (watchdog_dev != -1) { - while ((status = write(watchdog_dev, WATCHDOG_STOP_KEY, 1)) == 0 - && errno == EINTR); - close(watchdog_dev); - watchdog_dev = -1; - syslog(LOG_INFO, "system watchdog stopped.\n"); - } - pthread_mutex_unlock(&watchdog_lock); -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.h b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.h deleted file mode 100644 index 19b9944..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * watchdog - * - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Utility library to handle the aspeed watchdog. Only one watchdog - * should be in use at any time throughout the entire system (multiple users - * will not cause adverse effects but the behavior of the watchdog becomes - * undefined). - * - * The watchdog can be started in either manual or automatic mode. In manual - * mode, the watchdog has to be constantly reset by the user via the - * kick_watchdog() function. Under automatic mode, the watchdog will - * run in a separate thread and reset the timer on its own so no intervention - * is required from the user. - * - * In both modes, the watchdog timer will not stop when the process is - * terminated, unless a call to stop_watchdog() has been made beforehand, or - * if the user runs in manual mode and uses a non persistent watchdog kick. - * - * The default timeout for the watchdog is 11 seconds. When this time period - * elapses, the ARM chip is restarted and the kernel is rebooted. Other - * hardware state is not reset, so this may introduce strange behavior on - * reboot (example: an I2C bus may be left in the open state, triggering - * constant interrupts). In rare cases, this could result in the kernel - * failing to fully restart itself and thus preclude the possibility of - * reinitializing the watchdog timer. Someone will then have to go over and - * physically restart the machine. - * - * The alternative to the soft reset is to request the watchdog device driver - * for a hard reset on timeout. However this will stop the fans. If the - * kernel fails to fully boot and restart the fan daemon, the system could - * overheat. For this reason, we've chosen to take the risk of a stuck soft - * reset instead. - * - */ - -/* Forward declarations. */ -int start_watchdog(const int auto_mode); -enum watchdog_persistent_en { - WATCHDOG_SET_PERSISTENT, - WATCHDOG_SET_NONPERSISTENT, -}; -void set_persistent_watchdog(enum watchdog_persistent_en persistent); -int kick_watchdog(); -void stop_watchdog(); diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl_0.1.bb deleted file mode 100644 index 6e0c980..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl_0.1.bb +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -SUMMARY = "Fan controller" -DESCRIPTION = "The utilities to control fan." -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://fand.cpp;beginline=6;endline=18;md5=da35978751a9d71b73679307c4d296ec" - -DEPENDS_append = "libwedge-eeprom update-rc.d-native" - -SRC_URI = "file://get_fan_speed.sh \ - file://init_pwm.sh \ - file://set_fan_speed.sh \ - file://README \ - file://setup-fan.sh \ - file://Makefile \ - file://fand.cpp \ - file://watchdog.h \ - file://watchdog.cpp \ - " - -S = "${WORKDIR}" - -binfiles = "get_fan_speed.sh \ - init_pwm.sh \ - set_fan_speed.sh \ - fand \ - " - -otherfiles = "README" - -pkgdir = "fan_ctrl" - -do_install() { - dst="${D}/usr/local/fbpackages/${pkgdir}" - bin="${D}/usr/local/bin" - install -d $dst - install -d $bin - for f in ${binfiles}; do - install -m 755 $f ${dst}/$f - ln -snf ../fbpackages/${pkgdir}/$f ${bin}/$f - done - for f in ${otherfiles}; do - install -m 644 $f ${dst}/$f - done - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/rcS.d - install -m 755 setup-fan.sh ${D}${sysconfdir}/init.d/setup-fan.sh - update-rc.d -r ${D} setup-fan.sh start 91 S . -} - -FBPACKAGEDIR = "${prefix}/local/fbpackages" - -FILES_${PN} = "${FBPACKAGEDIR}/fan_ctrl ${prefix}/local/bin ${sysconfdir} " - -# Inhibit complaints about .debug directories for the fand binary: - -INHIBIT_PACKAGE_DEBUG_SPLIT = "1" -INHIBIT_PACKAGE_STRIP = "1" diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/fbutils_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/fbutils/fbutils_0.1.bb deleted file mode 100644 index 753adbe..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/fbutils_0.1.bb +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -SUMMARY = "Utilities" -DESCRIPTION = "Various utilities" -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a" - -SRC_URI = "file://ast-functions \ - file://us_console.sh \ - file://sol.sh \ - file://power_led.sh \ - file://post_led.sh \ - file://reset_usb.sh \ - file://setup-gpio.sh \ - file://setup_rov.sh \ - file://mdio.py \ - file://bcm5396.py \ - file://bcm5396_util.py \ - file://mount_data0.sh \ - file://eth0_mac_fixup.sh \ - file://wedge_power.sh \ - file://power-on.sh \ - file://wedge_us_mac.sh \ - file://setup_switch.py \ - file://create_vlan_intf \ - file://watch-fc.sh \ - file://fcswitcher.sh \ - file://rc.early \ - file://rc.local \ - file://src \ - file://COPYING \ - " - -pkgdir = "utils" - -S = "${WORKDIR}" - -binfiles = "us_console.sh sol.sh power_led.sh post_led.sh \ - reset_usb.sh mdio.py setup_rov.sh wedge_power.sh wedge_us_mac.sh \ - bcm5396.py bcm5396_util.py setup_switch.py watch-fc.sh" - -DEPENDS_append = "update-rc.d-native" - -do_install() { - dst="${D}/usr/local/fbpackages/${pkgdir}" - install -d $dst - install -m 644 ast-functions ${dst}/ast-functions - localbindir="${D}/usr/local/bin" - install -d ${localbindir} - for f in ${binfiles}; do - install -m 755 $f ${dst}/${f} - ln -s ../fbpackages/${pkgdir}/${f} ${localbindir}/${f} - done - - # common lib and include files - install -d ${D}${includedir}/facebook - install -m 0644 src/include/log.h ${D}${includedir}/facebook/log.h - install -m 0644 src/include/i2c-dev.h ${D}${includedir}/facebook/i2c-dev.h - - # init - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/rcS.d - # the script to mount /mnt/data - install -m 0755 ${WORKDIR}/mount_data0.sh ${D}${sysconfdir}/init.d/mount_data0.sh - update-rc.d -r ${D} mount_data0.sh start 03 S . - install -m 0755 ${WORKDIR}/rc.early ${D}${sysconfdir}/init.d/rc.early - update-rc.d -r ${D} rc.early start 04 S . - install -m 755 setup-gpio.sh ${D}${sysconfdir}/init.d/setup-gpio.sh - update-rc.d -r ${D} setup-gpio.sh start 59 S . - # create VLAN intf automatically - install -d ${D}/${sysconfdir}/network/if-up.d - install -m 755 create_vlan_intf ${D}${sysconfdir}/network/if-up.d/create_vlan_intf - # networking is done after rcS, any start level within rcS - # for mac fixup should work - install -m 755 eth0_mac_fixup.sh ${D}${sysconfdir}/init.d/eth0_mac_fixup.sh - update-rc.d -r ${D} eth0_mac_fixup.sh start 70 S . - install -m 755 power-on.sh ${D}${sysconfdir}/init.d/power-on.sh - update-rc.d -r ${D} power-on.sh start 85 S . - install -m 755 fcswitcher.sh ${D}${sysconfdir}/init.d/fcswitcher.sh - update-rc.d -r ${D} fcswitcher.sh start 90 S . - install -m 0755 ${WORKDIR}/rc.local ${D}${sysconfdir}/init.d/rc.local - update-rc.d -r ${D} rc.local start 99 2 3 4 5 . -} - -FILES_${PN} += "/usr/local ${sysconfdir}" diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions deleted file mode 100644 index dd53ad1..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions +++ /dev/null @@ -1,222 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -DEVMEM=/sbin/devmem - -devmem_set_bit() { - local addr - local val - addr=$1 - val=$($DEVMEM $addr) - val=$((val | (0x1 << $2))) - $DEVMEM $addr 32 $val -} - -devmem_clear_bit() { - local addr - local val - addr=$1 - val=$($DEVMEM $addr) - val=$((val & ~(0x1 << $2))) - $DEVMEM $addr 32 $val -} - -scu_addr() { - echo $((0x1E6E2000 + 0x$1)) -} - -GPIODIR="/sys/class/gpio" -GPIOEXPORT="$GPIODIR/export" - -gpio_dir() { - echo "$GPIODIR/gpio$1" -} - -gpio_name2value() { - local first remaining base val - remaining=$1 - val=0 - while [ -n "$remaining" ]; do - first=${remaining:0:1} - case "$first" in - [[:lower:]]) - base=$(printf "%d" "'$first'") - base=$((base - 96)) - val=$((val * 26 + base)) - ;; - [[:upper:]]) - base=$(printf "%d" "'$first'") - base=$((base - 64)) - val=$((val * 26 + base)) - ;; - *) - if [ $val -gt 0 ]; then - val=$((val-1)) - fi - val=$((val * 8 + $remaining)) - break - ;; - esac - remaining=${remaining:1} - done - echo "$val" -} - -gpio_export() { - local gpio - gpio=$(gpio_name2value $1) - dir=$(gpio_dir $gpio) - if [ ! -d ${dir} ]; then - echo $gpio > $GPIOEXPORT - fi -} - -gpio_set() { - local gpio - local val - gpio=$(gpio_name2value $1) - val=$2 - dir=$(gpio_dir $gpio) - if [ ! -d ${dir} ]; then - echo $gpio > $GPIOEXPORT - fi - echo out > ${dir}/direction - echo $val > ${dir}/value -} - -gpio_get() { - local gpio - local val - gpio=$(gpio_name2value $1) - dir=$(gpio_dir $gpio) - if [ ! -d ${dir} ]; then - echo $gpio > $GPIOEXPORT - fi - echo in > ${dir}/direction - cat ${dir}/value -} - -wedge_iso_buf_enable() { - # GPIOC2 (18) to low, SCU90[0] and SCU90[24] must be 0 - devmem_clear_bit $(scu_addr 90) 0 - devmem_clear_bit $(scu_addr 90) 24 - gpio_set 18 0 -} - -wedge_iso_buf_disable() { - # GPIOC2 (18) to low, SCU90[0] and SCU90[24] must be 0 - devmem_clear_bit $(scu_addr 90) 0 - devmem_clear_bit $(scu_addr 90) 24 - gpio_set 18 1 -} - -wedge_is_us_on() { - local val n retries prog - if [ $# -gt 0 ]; then - retries="$1" - else - retries=1 - fi - if [ $# -gt 1 ]; then - prog="$2" - else - prog="" - fi - n=1 - while true; do - val=$(cat /sys/class/i2c-adapter/i2c-4/4-0040/gpio_inputs 2>/dev/null) - if [ -n "$val" ]; then - break - fi - n=$((n+1)) - if [ $n -gt $retries ]; then - echo -n " failed to read GPIO. " - val=0 - break - fi - echo -n "$prog" - sleep 1 - done - if [ "$((val & (0x1 << 14)))" != "0" ]; then - # powered on already - return 0 - else - return 1 - fi -} - - -# Return the board type, 'LC', 'FC-LEFT', 'FC-RIGHT', or, 'WEDGE' -wedge_board_type() { - local pn - pn=$(/usr/bin/weutil 2> /dev/null | grep -i '^Location on Fabric:') - case "$pn" in - *LEFT*) - echo 'FC-LEFT' - ;; - *RIGHT*) - echo 'FC-RIGHT' - ;; - *LC*) - echo 'LC' - ;; - *) - echo 'WEDGE' - ;; - esac -} - -# On FC, FAB_SLOT_ID (GPIOU0), low == FC0; high == FC1 -# On LC, Wedge, -# board rev < 3: -# GPIOU0(ID0), GPIOU1(ID1), GPIOU2(ID2), GPIOU3(ID3) -# else: -# GPIOU6(ID0), GPIOU7(ID1), GPIOV0(ID2), GPIOV1(ID3) -# -# ID[2:0] ID3 Slot# -# 000 0 1 -# 000 1 2 -# 001 0 3 -# 001 1 4 -# 010 0 5 -# 010 1 6 -# 011 0 7 -# 011 1 8 - -wedge_slot_id() { - local type slot id3 id2 id1 id0 FC_CARD_BASE board_rev - FC_CARD_BASE=65 - if [ "$1" = "FC-LEFT" ]; then - # fabric card left - slot=$(gpio_get U0) - slot=$((FC_CARD_BASE + slot * 2)) - elif [ "$1" = "FC-RIGHT" ]; then - # fabric card right - slot=$(gpio_get U0) - slot=$((FC_CARD_BASE + slot * 2 + 1)) - else - # either edge or LC - # need to check the board rev - board_rev=$(wedge_board_rev) - if [ $board_rev -lt 3 ]; then - id0=$(gpio_get U0) - id1=$(gpio_get U1) - id2=$(gpio_get U2) - id3=$(gpio_get U3) - else - id0=$(gpio_get U6) - id1=$(gpio_get U7) - id2=$(gpio_get V0) - id3=$(gpio_get V1) - fi - slot=$(((id2 * 4 + id1 * 2 + id0) * 2 + id3 + 1)) - fi - echo "$slot" -} - -# wedge_board_rev() is only valid after GPIO Y0, Y1, and Y2 are enabled -wedge_board_rev() { - local val0 val1 val2 - val0=$(cat /sys/class/gpio/gpio192/value 2>/dev/null) - val1=$(cat /sys/class/gpio/gpio193/value 2>/dev/null) - val2=$(cat /sys/class/gpio/gpio194/value 2>/dev/null) - echo $((val0 | (val1 << 1) | (val2 << 2))) -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46.py b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46.py deleted file mode 100644 index 368b807..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46.py +++ /dev/null @@ -1,260 +0,0 @@ -# Copyright 2004-present Facebook. All rights reserved. - -import subprocess -import struct -import sys - -class VerboseLogger: - def __init__(self, verbose=False): - self.verbose = verbose - - def _verbose_print(self, caption, bytestream=None): - ''' - Print a bytestream to stdout if verbose is enabled. - ''' - if self.verbose: - if bytestream is not None: - sys.stderr.write("{}: {}\n".format(caption, " ".join(['{:02X}'.format(ord(x)) for x in bytestream]))) - else: - sys.stderr.write("{}\n".format(caption)) - -class AT93C46SPI(VerboseLogger): - '''The class to access AT93C46 through SPI intf''' - SPI_CMD = 'spi-bb' - - def __init__(self, bus_width, gpio_cs, gpio_ck, gpio_do, gpio_di, - verbose=False): - if bus_width != 8 and bus_width != 16: - raise Exception("Invalid bus width for AT93C46!") - - self.bus_width = bus_width - self.gpio_cs = gpio_cs - self.gpio_ck = gpio_ck - self.gpio_do = gpio_do - self.gpio_di = gpio_di - self.verbose = verbose - - self.addr_bits = 6 if self.bus_width == 16 else 7 - self.addr_mask = 0x3F if self.bus_width == 16 else 0x7F - - def __shift(self, bytestream, value): - ''' - Shift an entire byte stream by value bits. - ''' - binary = "".join(['{:08b}'.format(ord(x)) for x in bytestream]) - if value > 0: - binary = binary[value:] + '0' * value - else: - binary = '0' * (-value) + binary[:value] - return "".join([chr(int(binary[x:x+8],2)) for x in range(0, len(binary), 8)]) - - def __io(self, op, addr, data=None): - ''' - Perform an IO operation against the EEPROM - ''' - write_bits = self.addr_bits + 3 - if data is not None: - # If giving data, we are doing a write command so - # no need to read any data. - write_bits = write_bits + self.bus_width - read_bits = 0 - else: - # If not giving data, we are doing either a read - # command or a set command, so read the result. - # We pad with an extra bit due to a dummy bit introduced - # by a delay for address decoding on chip. - read_bits = self.addr_bits + 4 + self.bus_width - - # Format the command itself - cmd_loc = 6 if self.bus_width == 16 else 7 - instruction = addr & self.addr_mask - instruction = instruction | ((0x4 | (op & 0x3)) << cmd_loc) - if data is not None: - if self.bus_width == 16: - write_data = struct.pack(">HH", instruction, data & 0xFFFF) - else: - write_data = struct.pack(">HB", instruction, data & 0xFF) - else: - write_data = struct.pack(">H", instruction) - write_data = self.__shift(write_data, 16 - (cmd_loc + 3)) - - self._verbose_print("Write data", write_data) - - # Run the command with the bitbang driver - if read_bits > 0: - data_portion = "-r {} -w {}".format(read_bits, write_bits) - else: - data_portion = "-w {}".format(write_bits) - - cmd = "{} -s {} -c {} -o {} -i {} -b {}".format( - self.SPI_CMD, self.gpio_cs, self.gpio_ck, self.gpio_do, - self.gpio_di, data_portion - ) - - self._verbose_print("Command: {}".format(cmd)) - - out = subprocess.Popen(cmd.split(), - stdout=subprocess.PIPE, - stdin = subprocess.PIPE)\ - .communicate(input=write_data) - - # Format the response - read_data = self.__shift(out[0], cmd_loc + 4) - if self.bus_width == 16: - read_data = read_data[:2] - self._verbose_print("Read data", read_data) - return struct.unpack(">H", read_data)[0] - else: - read_data = read_data[:1] - self._verbose_print("Read data", read_data) - return struct.unpack(">B", read_data)[0] - - def read(self, addr): - return self.__io(0x2, addr) - - def ewen(self): - self.__io(0x0, 0x3 << (self.addr_bits - 2)) - - def erase(self, addr): - self.__io(0x3, addr) - - def write(self, addr, data): - self.__io(0x1, addr, data) - - def eral(self): - self.__io(0x0, 0x2 << (self.addr_bits - 2)) - - def wral(self, data): - self.__io(0x0, 0x1 << (self.addr_bits - 2), data) - - def ewds(self): - self.__io(0x0, 0x0) - -class AT93C46(VerboseLogger): - ''' - The class which handles accessing memory on the AT93C46 chip. - ''' - AT93C46_MEMORY_SIZE = 128 - - def __init__(self, bus_width, gpio_cs, gpio_ck, gpio_do, gpio_di, - byte_swap, verbose=False): - self.bus_width = bus_width - self.verbose = verbose - self.byte_swap = byte_swap - - self.spi = AT93C46SPI(bus_width=bus_width, gpio_cs=gpio_cs, - gpio_ck=gpio_ck, gpio_do=gpio_do, - gpio_di=gpio_di, verbose=verbose) - - def __swap(self, value): - ''' - Swap bytes for a 16-bit integer if instructed to do so. - ''' - if self.bus_width == 16: - if self.byte_swap: - return ((value >> 8) & 0xFF) | ((value << 8) & 0xFF00) - else: - return value - else: - return value - - def erase(self, offset=None, limit=None): - ''' - Erase the chip. - ''' - if offset is None: - offset = 0 - if limit is None: - limit = self.AT93C46_MEMORY_SIZE - - if offset < 0 or offset + limit > self.AT93C46_MEMORY_SIZE: - raise Exception("Erase would be out of bounds!") - if self.bus_width == 16 and \ - ((offset & 1) != 0 or ((offset + limit) & 1) != 0): - raise Exception("Erase can't start or end on odd boundary in 16-bit mode!") - - if offset == 0 and limit == self.AT93C46_MEMORY_SIZE: - # Special case when we are erasing the entire chip - self.spi.ewen() - self.spi.eral() - self.spi.ewds() - - self._verbose_print("Erased entire chip") - else: - # Regular case - if self.bus_width == 16: - real_offset = offset / 2 - real_limit = limit / 2 - else: - real_offset = offset - real_limit = limit - - self.spi.ewen() - for addr in range(real_offset, real_offset + real_limit): - self.spi.erase(addr) - self.spi.ewds() - - self._verbose_print("Erased {} bytes from offset {}".format(limit, offset)) - - def read(self, offset=None, limit=None): - ''' - Read the chip into a memory buffer. - ''' - if offset is None: - offset = 0 - if limit is None: - limit = self.AT93C46_MEMORY_SIZE - - if offset < 0 or offset + limit > self.AT93C46_MEMORY_SIZE: - raise Exception("Read would be out of bounds!") - if self.bus_width == 16 and \ - ((offset & 1) != 0 or ((offset + limit) & 1) != 0): - raise Exception("Read can't start or end on odd boundary in 16-bit mode!") - - output = "" - if self.bus_width == 16: - real_offset = offset / 2 - real_limit = limit / 2 - pack_instruction = "=H" - else: - real_offset = offset - real_offset - pack_instruction = "=B" - - for addr in range(real_offset, real_offset + real_limit): - output = output + struct.pack(pack_instruction, self.__swap(self.spi.read(addr))) - - self._verbose_print("Read {} bytes from offset {}".format(limit, offset), output) - - return output - - def write(self, data, offset=None): - ''' - Write a memory buffer to the chip. - ''' - if offset is None: - offset = 0 - - if offset < 0 or offset + len(data) > self.AT93C46_MEMORY_SIZE: - raise Exception("Write would be out of bounds!") - if self.bus_width == 16 and \ - ((offset & 1) != 0 or ((offset + len(data)) & 1) != 0): - raise Exception("Write can't start or end on odd boundary in 16-bit mode!") - - if self.bus_width == 16: - offset_divisor = 2 - pack_instruction = "=H" - else: - offset_divisor = 1 - pack_instruction = "=B" - - self.spi.ewen() - for addr in range(offset, offset + len(data), offset_divisor): - actual_addr = addr / offset_divisor - value = self.__swap(struct.unpack(pack_instruction, data[(addr - offset):(addr - offset) + offset_divisor])[0]) - - self.spi.erase(actual_addr) - self.spi.write(actual_addr, value) - self.spi.ewds() - - self._verbose_print("Wrote {} bytes from offset {}".format(len(data), offset), data) diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46_util.py b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46_util.py deleted file mode 100755 index 8910002..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46_util.py +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/python -S -# Copyright 2004-present Facebook. All rights reserved. - -from argparse import ArgumentParser -from at93c46 import AT93C46, AT93C46SPI -import sys - -def get_raw(args): - return AT93C46SPI(args.bus_width, args.cs, args.clk, args.mosi, args.miso, - args.verbose) - -def get_chip(args): - return AT93C46(args.bus_width, args.cs, args.clk, args.mosi, args.miso, - args.byte_swap, args.verbose) - -def access_parser(ap): - # Default, based on currenct HW configuration - SPI_CS_DEFAULT = 68 - SPI_CLK_DEFAULT = 69 - SPI_MOSI_DEFAULT = 70 - SPI_MISO_DEFAULT = 71 - - spi_group = ap.add_argument_group('SPI Access') - spi_group.add_argument('--cs', type=int, default=SPI_CS_DEFAULT, - help='The GPIO number for SPI CS pin (default: %s)' - % SPI_CS_DEFAULT) - spi_group.add_argument('--clk', type=int, default=SPI_CLK_DEFAULT, - help='The GPIO number for SPI CLK pin (default: %s)' - % SPI_CLK_DEFAULT) - spi_group.add_argument('--mosi', type=int, default=SPI_MOSI_DEFAULT, - help='The GPIO number for SPI MOSI pin (default: %s)' - % SPI_MOSI_DEFAULT) - spi_group.add_argument('--miso', type=int, default=SPI_MISO_DEFAULT, - help='The GPIO number for SPI MISO pin (default: %s)' - % SPI_MISO_DEFAULT) - -def bus_width_parser(ap): - # Default, based on currenct HW configuration - AT83C46_BUS_WIDTH = 16 - - bus_group = ap.add_argument_group('Bus Width') - bus_group.add_argument('--bus-width', type=int, default=AT83C46_BUS_WIDTH, - help='The configured bus width (default: %s)' - % AT83C46_BUS_WIDTH) - -def read_raw(args): - raw = get_raw(args) - val = raw.read(args.address) - - if args.int: - print "{}".format(val) - else: - if args.bus_width == 16: - print "0x{:04X}".format(val) - else: - print "0x{:02X}".format(val) - -def write_raw(args): - if args.value[:2] == "0x": - value = int(args.value, 16) - else: - value = int(args.value) - - raw = get_raw(args) - raw.ewen() - raw.erase(args.address) - raw.write(args.address, value) - raw.ewds() - -def erase_raw(args): - raw = get_raw(args) - raw.ewen() - raw.erase(args.address) - raw.ewds() - -def raw_subparser(subparsers): - raw_parser = subparsers.add_parser('raw', help='Raw memory access') - raw_sub = raw_parser.add_subparsers() - - read_parser = raw_sub.add_parser('read', help='Read a single memory address') - read_parser.add_argument('address', type=int, help='The memory address') - read_parser.add_argument('--int', action='store_true', - help='Display output as an integer') - read_parser.set_defaults(func=read_raw) - - write_parser = raw_sub.add_parser('write', help='Write a single memory address') - write_parser.add_argument('address', type=int, help='The memory address') - write_parser.add_argument('value', type=str, help='The value to write, either integer or hex') - write_parser.set_defaults(func=write_raw) - - erase_parser = raw_sub.add_parser('erase', help='Erase a single memory address') - erase_parser.add_argument('address', type=int, help='The memory address') - erase_parser.set_defaults(func=erase_raw) - -def read_chip(args): - chip = get_chip(args) - data = chip.read(args.start, args.length) - - if args.file is None: - sys.stdout.write(data) - else: - fp = open(args.file, "wb") - fp.write(data) - -def write_chip(args): - chip = get_chip(args) - - # Either way, limit reads to the size of the chip - if args.file is None: - data = sys.stdin.read(AT93C46.AT93C46_MEMORY_SIZE) - else: - fp = open(args.file, "rb") - data = fp.read(AT93C46.AT93C46_MEMORY_SIZE) - - if args.length is not None: - # Make sure length is correct - if len(data) < args.length: - data = data + '\x00' * (args.length - len(data)) - if len(data) > args.length: - data = data[:args.length] - - chip.write(data, args.start) - -def erase_chip(args): - chip = get_chip(args) - chip.erase(args.start, args.length) - -def chip_subparser(subparsers): - chip_parser = subparsers.add_parser('chip', help='Chip-level access') - chip_sub = chip_parser.add_subparsers() - - read_parser = chip_sub.add_parser('read', help='Read from the chip') - read_parser.add_argument('--start', type=int, - help='The memory address to start at (default: 0)') - read_parser.add_argument('--length', type=int, - help='The number of bytes to read (default: whole chip)') - read_parser.add_argument('--file', type=str, - help='File to operate on (default: stdout)') - read_parser.add_argument('--byte-swap', action='store_true', - help='Byte swap values for 16-bit reads/writes') - read_parser.set_defaults(func=read_chip) - - write_parser = chip_sub.add_parser('write', help='Write to the chip') - write_parser.add_argument('--start', type=int, - help='The memory address to start at (default: 0)') - write_parser.add_argument('--length', type=int, - help='The number of bytes to write (default: file length)') - write_parser.add_argument('--file', type=str, - help='File to operate on (default: stdin)') - write_parser.add_argument('--byte-swap', action='store_true', - help='Byte swap values for 16-bit reads/writes') - write_parser.set_defaults(func=write_chip) - - erase_parser = chip_sub.add_parser('erase', help='Erase the chip') - erase_parser.add_argument('--start', type=int, - help='The memory address to start at (default: 0)') - erase_parser.add_argument('--length', type=int, - help='The number of bytes to erase (default: whole chip)') - erase_parser.set_defaults(func=erase_chip) - -if __name__ == "__main__": - # General arguments - ap = ArgumentParser() - ap.add_argument('--verbose', action='store_true', - help='Print verbose debugging information') - - # SPI and bus width arguments - access_parser(ap) - bus_width_parser(ap) - - # Functionality - subparsers = ap.add_subparsers() - raw_subparser(subparsers) - chip_subparser(subparsers) - - # Command runner - args = ap.parse_args() - args.func(args) diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/fcswitcher.sh b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/fcswitcher.sh deleted file mode 100755 index 53e24f3..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/fcswitcher.sh +++ /dev/null @@ -1,83 +0,0 @@ -#! /bin/sh -# -# Copyright 2014-present Facebook. All Rights Reserved. -# -# This program file 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; version 2 of the License. -# -# 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 in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -# - -### BEGIN INIT INFO -# Provides: usbcons -# Required-Start: -# Required-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Creates a virtual USB serial device and starts a console -# on it. -# -### END INIT INFO - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -NAME="FC Switcher" -DESC="FC Failover Daemon" - -# source function library -. /etc/init.d/functions - -. /usr/local/fbpackages/utils/ast-functions - -STOPPER= -ACTION="$1" - -case "$ACTION" in - start) - if [ "$(wedge_board_type)" = "LC" ]; then - # Ability to prevent this from starting by editing cmdline in u-boot. - # Keeping this here until I get gadget switching working properly. (t4906522) - /usr/local/bin/watch-fc.sh > /dev/null 2>&1 & - echo "$NAME." - else - echo 'skipping watch-fc.sh: only necessary on six-pack line cards.' - fi - ;; - stop) - echo -n "Stopping $DESC: " - killall watch-fc.sh - echo "$NAME." - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - killall watch-fc.sh - if [ "$(wedge_board_type)" = "LC" ]; then - sleep 1 - /usr/local/bin/watch-fc.sh > /dev/null 2>&1 & - echo "$NAME." - else - echo 'skipping watch-fc.sh: only necessary on six-pack line cards.' - fi - ;; - status) - status watch-fc.sh - exit $? - ;; - *) - N=${0##*/} - N=${N#[SK]??} - echo "Usage: $N {start|stop|status|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh index 1400464..4ff6f24 100755 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh @@ -56,12 +56,19 @@ target_volts=$(( $target_volts * 1 )) # normalize to decimal rmmod pmbus reload=$? -# Get current voltage value +# Get current voltage value. +# The device here is NCP4200. It turns out the first i2c transaction to this +# device always fails. The spec does not mention anything about NCP4200 i2c +# engine start delay. However, each time, when the isolation buffer between the +# BMC i2c controller and NCP4200 is disabled and re-enabled, the first i2c +# transaction to NCP4200 always fails. +# To workaround this issue, we are doing the first read twice. +cur_volts=$(i2cget -y 1 0x60 0x8b w 2> /dev/null) cur_volts=$(i2cget -y 1 0x60 0x8b w) cur_volts=$(( $cur_volts * 1 )) # normalize to decimal # Only bounce the T2 if we actually need to modify the voltage -if [ $cur_volts -ne $target_volts ]; then +if [ $cur_volts -ne $target_volts ]; then # Set values before turning out output; we're using "PCIE, then MCS" echo 1 > /sys/class/gpio/gpio42/value echo 1 > /sys/class/gpio/gpio43/value @@ -71,7 +78,7 @@ if [ $cur_volts -ne $target_volts ]; then echo out > /sys/class/gpio/gpio16/direction # T2 is in reset; note that this may cause NMI messages on the uServer, # which shouldn't be up anyway when this is first run. - + # Set the requested value to the current value to avoid rapid shifts i2cset -y 1 0x60 0x21 $cur_volts w # Enable the requested voltage @@ -81,7 +88,7 @@ if [ $cur_volts -ne $target_volts ]; then # Set the target voltage i2cset -y 1 0x60 0x21 $target_volts w - + sleep 1 # Let T2 come out of reset diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/src/include/log.h b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/src/include/log.h deleted file mode 100644 index a69d69e..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/src/include/log.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef LOG_H -#define LOG_H - -#include <stdio.h> -#include <string.h> - -//#define DEBUG -//#define VERBOSE - -#define _LOG(dst, fmt, ...) do { \ - fprintf(dst, "%s:%d " fmt "\n", \ - __FUNCTION__, __LINE__, ##__VA_ARGS__); \ - fflush(dst); \ -} while(0) - -#define LOG_ERR(err, fmt, ...) do { \ - char buf[128]; \ - strerror_r(err, buf, sizeof(buf)); \ - _LOG(stderr, "ERROR " fmt ": %s", ##__VA_ARGS__, buf); \ -} while(0) - -#define LOG_INFO(fmt, ...) do { \ - _LOG(stdout, fmt, ##__VA_ARGS__); \ -} while(0) - -#ifdef DEBUG -#define LOG_DBG(fmt, ...) do { \ - _LOG(stdout, fmt, ##__VA_ARGS__); \ -} while(0) -#else -#define LOG_DBG(fmt, ...) -#endif - -#ifdef VERBOSE -#define LOG_VER(fmt, ...) do { \ - _LOG(stdout, fmt, ##__VA_ARGS__); \ -} while(0) -#else -#define LOG_VER(fmt, ...) -#endif - -#endif diff --git a/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf b/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf index 44b6595..266a695 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf +++ b/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf @@ -7,12 +7,18 @@ bus "i2c-6" "ast_i2c.6" chip "tmp75-i2c-3-48" label temp1 "Inlet Temp" + set temp1_max 70 + set temp1_max_hyst 60 chip "tmp75-i2c-3-49" label temp1 "Switch Temp" + set temp1_max 70 + set temp1_max_hyst 60 chip "tmp75-i2c-3-4a" label temp1 "Outlet Temp" + set temp1_max 70 + set temp1_max_hyst 60 chip "tmp75-i2c-4-4c" label temp1 "Microserver Ambient Temp" diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile index 926bf52..fa1e932 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile @@ -15,7 +15,7 @@ # 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301 USA -override CFLAGS+=-D_GNU_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309 -Wall -Werror -std=c99 +override CFLAGS+=-D_GNU_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=199309 -Wall -Werror -std=c99 override LDFLAGS+=-pthread all: modbuscmd gpiowatch modbussim rackmond rackmondata diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py index a92cf8e..34a64f8 100755 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py @@ -2,11 +2,15 @@ from __future__ import print_function import os.path +import os +import fcntl import socket import struct import sys import argparse import traceback +import json +from tempfile import mkstemp import hexfile @@ -18,8 +22,32 @@ def auto_int(x): parser = argparse.ArgumentParser() parser.add_argument('--addr', type=auto_int, required=True, help="PSU Modbus Address") +parser.add_argument('--statusfile', default=None, + help="Write status to JSON file during process") +parser.add_argument('--rmfwfile', action='store_true', + help="Delete FW file after update completes") parser.add_argument('file', help="firmware file") +status = { + 'pid': os.getpid(), + 'state': 'started' +} + +statuspath = None + +def write_status(): + global status + if statuspath is None: + return + tmppath = statuspath + '~' + with open(tmppath, 'wb') as tfh: + tfh.write(json.dumps(status)) + os.rename(tmppath, statuspath) + +def status_state(state): + global status + status['state'] = state + write_status() class ModbusTimeout(Exception): pass @@ -193,6 +221,7 @@ def write_data(addr, data): def send_image(addr, fwimg): + global statuspath total_chunks = sum([len(s) for s in fwimg.segments]) / 8 sent_chunks = 0 for s in fwimg.segments: @@ -205,11 +234,15 @@ def send_image(addr, fwimg): if len(chunk) < 8: chunk = chunk + ("\xFF" * (8 - len(chunk))) sent_chunks += 1 - print("\r[%.2f%%] Sending chunk %d of %d..." % - (sent_chunks * 100.0 / total_chunks, - sent_chunks, total_chunks), end="") + # dont fill the restapi log with junk + if statuspath is None: + print("\r[%.2f%%] Sending chunk %d of %d..." % + (sent_chunks * 100.0 / total_chunks, + sent_chunks, total_chunks), end="") sys.stdout.flush() write_data(addr, str(bytearray(chunk))) + status['flash_progress_percent'] = sent_chunks * 100.0 / total_chunks + write_status() print("") @@ -241,28 +274,45 @@ def erase_flash(addr): def update_psu(addr, filename): + status_state('pausing_monitoring') pause_monitoring() + status_state('parsing_fw_file') fwimg = hexfile.load(filename) + status_state('bootloader_handshake') enter_bootloader(addr) start_programming(addr) challenge = get_challenge(addr) send_key(addr, delta_seccalckey(challenge)) + status_state('erase_flash') erase_flash(addr) + status_state('flashing') send_image(addr, fwimg) + status_state('verifying') verify_flash(addr) + status_state('resetting') reset_psu(addr) + status_state('done') def main(): args = parser.parse_args() + global statuspath + statuspath = args.statusfile + print("statusfile %s" % statuspath) try: update_psu(args.addr, args.file) - except: - traceback.print_exc() + except Exception, e: print("Firmware update failed") + global status + status['exception'] = traceback.format_exc() + status_state('failed') resume_monitoring() + if args.rmfwfile: + os.remove(args.file) sys.exit(1) resume_monitoring() + if args.rmfwfile: + os.remove(args.file) sys.exit(0) if __name__ == "__main__": diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py index e93dfae..130f26f 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py @@ -1,7 +1,4 @@ -from __future__ import print_function -import struct -import socket -import os, os.path +from rackmond import configure_rackmond reglist = [ {"begin": 0x0, #MFR_MODEL @@ -26,68 +23,198 @@ reglist = [ "length": 1, "keep": 10, # 10-sample ring buffer "flags": 1}, + {"begin": 0x6B, #BBU Battery Mode + "length": 1, + "keep": 10, # 10-sample ring buffer + "flags": 1}, + {"begin": 0x6C, #BBU Battery Status + "length": 1, + "keep": 10, # 10-sample ring buffer + "flags": 1}, + {"begin": 0x6D, #BBU Cell Voltage 1 + "length": 1, + "keep": 10}, + {"begin": 0x6E, #BBU Cell Voltage 2 + "length": 1, + "keep": 10}, + {"begin": 0x6F, #BBU Cell Voltage 3 + "length": 1, + "keep": 10}, + {"begin": 0x70, #BBU Cell Voltage 4 + "length": 1, + "keep": 10}, + {"begin": 0x71, #BBU Cell Voltage 5 + "length": 1, + "keep": 10}, + {"begin": 0x72, #BBU Cell Voltage 6 + "length": 1, + "keep": 10}, + {"begin": 0x73, #BBU Cell Voltage 7 + "length": 1, + "keep": 10}, + {"begin": 0x74, #BBU Cell Voltage 8 + "length": 1, + "keep": 10}, + {"begin": 0x75, #BBU Cell Voltage 9 + "length": 1, + "keep": 10}, + {"begin": 0x76, #BBU Cell Voltage 10 + "length": 1, + "keep": 10}, + {"begin": 0x77, #BBU Cell Voltage 11 + "length": 1, + "keep": 10}, + {"begin": 0x78, #BBU Cell Voltage 12 + "length": 1, + "keep": 10}, + {"begin": 0x79, #BBU Cell Voltage 13 + "length": 1, + "keep": 10}, + {"begin": 0x7A, #BBU Temp 1 + "length": 1, + "keep": 10}, + {"begin": 0x7B, #BBU Temp 2 + "length": 1, + "keep": 10}, + {"begin": 0x7C, #BBU Temp 3 + "length": 1, + "keep": 10}, + {"begin": 0x7D, #BBU Temp 4 + "length": 1, + "keep": 10}, + {"begin": 0x7E, #BBU Relative State of Charge + "length": 1, + "keep": 10}, + {"begin": 0x7F, #BBU Absolute State of Charge + "length": 1, + "keep": 10}, {"begin": 0x80, #Input VAC "length": 1, "keep": 10}, + {"begin": 0x81, #BBU Battery Voltage + "length": 1, + "keep": 10}, {"begin": 0x82, #Input Current AC "length": 1, "keep": 10}, + {"begin": 0x83, #BBU Battery Current + "length": 1, + "keep": 10}, {"begin": 0x84, #Battery Voltage "length": 1, "keep": 10}, + {"begin": 0x85, #BBU Average Current + "length": 1, + "keep": 10}, {"begin": 0x86, #Battery Current Output "length": 1}, + {"begin": 0x87, #BBU Remaining Capacity + "length": 1, + "keep": 10}, {"begin": 0x88, #Battery Current Input "length": 1}, + {"begin": 0x89, #BBU Full Charge Capacity + "length": 1, + "keep": 10}, {"begin": 0x8A, #Output Voltage (main converter) "length": 1, "keep": 10}, + {"begin": 0x8B, #BBU Run Time to Empty + "length": 1, + "keep": 10}, {"begin": 0x8C, #Output Current (main converter) "length": 1, "keep": 10}, + {"begin": 0x8D, #BBU Average Time to Empty + "length": 1, + "keep": 10}, {"begin": 0x8E, #IT Load Voltage Output "length": 1}, + {"begin": 0x8F, #BBU Charging Current + "length": 1}, {"begin": 0x90, #IT Load Current Output "length": 1}, + {"begin": 0x91, #BBU Charging Voltage + "length": 1, + "keep": 10}, {"begin": 0x92, #Bulk Cap Voltage "length": 1}, + {"begin": 0x93, #BBU Cycle Count + "length": 1, + "keep": 10}, {"begin": 0x94, #Input Power "length": 1, "keep": 10}, + {"begin": 0x95, #BBU Design Capacity + "length": 1}, {"begin": 0x96, #Output Power "length": 1, "keep": 10}, + {"begin": 0x97, #BBU Design Voltage + "length": 1}, {"begin": 0x98, #RPM Fan 0 "length": 1}, + {"begin": 0x99, #BBU At Rate + "length": 1}, {"begin": 0x9A, #RPM Fan 1 "length": 1}, + {"begin": 0x9B, #BBU At Rate Time to Full + "length": 1, + "keep": 10}, + {"begin": 0x9C, #BBU At Rate Time to Empty + "length": 1, + "keep": 10}, + {"begin": 0x9D, #BBU At Rate OK + "length": 1, + "keep": 10}, {"begin": 0x9E, #Temp 0 "length": 1}, + {"begin": 0x9F, #BBU Temp + "length": 1}, {"begin": 0xA0, #Temp 1 "length": 1}, + {"begin": 0xA1, #BBU Max Error + "length": 1}, + {"begin": 0xD0, #General Alarm Status Register + "length": 1}, + {"begin": 0xD1, #PFC Alarm Status Register + "length": 1}, + {"begin": 0xD2, #LLC Alarm Status Register + "length": 1}, + {"begin": 0xD3, #Current Feed Alarm Status Register + "length": 1}, + {"begin": 0xD4, #Auxiliary Alarm Status Register + "length": 1}, + {"begin": 0xD5, #Battery Charger Alarm Status Register + "length": 1}, + {"begin": 0xD7, #Temperature Alarm Status Register + "length": 1}, + {"begin": 0xD8, #Fan Alarm Status Register + "length": 1}, + {"begin": 0xD9, #Communication Alarm Status Register + "length": 1}, + {"begin": 0x106, #BBU Specification Info + "length": 1}, + {"begin": 0x107, #BBU Manufacturer Date + "length": 1}, + {"begin": 0x108, #BBU Serial Number + "length": 1}, + {"begin": 0x109, #BBU Device Chemistry + "length": 2}, + {"begin": 0x10B, #BBU Manufacturer Data + "length": 2}, + {"begin": 0x10D, #BBU Manufacturer Name + "length": 8}, + {"begin": 0x115, #BBU Device Name + "length": 8}, + {"begin": 0x11D, #FB Battery Status + "length": 4}, + {"begin": 0x121, #SoH results + "length": 1}, ] def main(): - COMMAND_TYPE_SET_CONFIG = 2 - config_command = struct.pack("@HxxH", - COMMAND_TYPE_SET_CONFIG, - len(reglist)) - for r in reglist: - keep = 1 - if "keep" in r: - keep = r["keep"] - flags = 0 - if "flags" in r: - flags = r["flags"] - monitor_interval = struct.pack("@HHHH", r["begin"], r["length"], keep, flags) - config_command += monitor_interval - - config_packet = struct.pack("H", len(config_command)) + config_command - srvpath = "/var/run/rackmond.sock" - if os.path.exists(srvpath): - client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - client.connect(srvpath) - client.send(config_packet) + configure_rackmond(reglist) if __name__ == "__main__": main() diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmond.py b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmond.py new file mode 100644 index 0000000..35dbaa5 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmond.py @@ -0,0 +1,26 @@ +import struct +import socket +import os, os.path + +def configure_rackmond(reglist): + COMMAND_TYPE_SET_CONFIG = 2 + config_command = struct.pack("@HxxH", + COMMAND_TYPE_SET_CONFIG, + len(reglist)) + for r in reglist: + keep = 1 + if "keep" in r: + keep = r["keep"] + flags = 0 + if "flags" in r: + flags = r["flags"] + monitor_interval = struct.pack("@HHHH", r["begin"], r["length"], keep, flags) + config_command += monitor_interval + + config_packet = struct.pack("H", len(config_command)) + config_command + srvpath = "/var/run/rackmond.sock" + if os.path.exists(srvpath): + client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + client.connect(srvpath) + client.send(config_packet) + diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh index 85a1e22..b592a35 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh @@ -16,5 +16,5 @@ echo -n "Starting rackmon background service..." echo "done." echo -n "Configuring rackmon service..." -python /etc/rackmon-config.py +PYTHONPATH=/etc python /etc/rackmon-config.py echo "done." diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb index 399f7c0..c7e78c9 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb @@ -34,6 +34,7 @@ SRC_URI = "file://Makefile \ file://rackmondata.c \ file://setup-rackmond.sh \ file://rackmon-config.py \ + file://rackmond.py \ file://psu-update-delta.py \ file://hexfile.py \ " @@ -66,6 +67,7 @@ do_install() { install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-rackmond.sh ${D}${sysconfdir}/init.d/setup-rackmond.sh install -m 755 rackmon-config.py ${D}${sysconfdir}/rackmon-config.py + install -m 755 rackmond.py ${D}${sysconfdir}/rackmond.py update-rc.d -r ${D} setup-rackmond.sh start 95 2 3 4 5 . } diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/bmc_command.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/bmc_command.py new file mode 100644 index 0000000..d4dc877 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/bmc_command.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python +# +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import os +import subprocess +import select +import sys +import time + +DEFAULT_TIMEOUT = 10 #sec + +# Note: Python 3.0 supports communicate() with a timeout option. +# If we upgrade to this version we will no longer need timed_communicate + +class TimeoutError(Exception): + def __init__(self, output, error): + super(TimeoutError, self).__init__('process timed out') + self.output = output + self.error = error + +class WaitTimeoutError(Exception): + pass + +def kill_process(proc): + proc.terminate() + try: + timed_wait(proc, 0.1) + except WaitTimeoutError: + proc.kill() + try: + timed_wait(proc, 0.1) + except WaitTimeoutError: + # This can happen if the process is stuck waiting inside a system + # call for a long time. There isn't much we can do unless we want + # to keep waiting forever. Just give up. The child process will + # remain around as a zombie until we exit. + pass + +def timed_wait(proc, timeout): + # There unfortunately isn't a great way to wait for a process with a + # timeout, other than polling. (Registering for SIGCHLD and sleeping might + # be one option, but that's fragile and not thread-safe.) + poll_interval = 0.1 + end_time = time.time() + timeout + while True: + if proc.poll() is not None: + return + time_left = max(end_time - time.time(), 0) + if time_left <= 0: + raise WaitTimeoutError() + time.sleep(min(time_left, poll_interval)) + +def timed_communicate(proc, timeout=DEFAULT_TIMEOUT): + end_time = time.time() + timeout + + p = select.poll() + outfd = proc.stdout.fileno() + errfd = proc.stderr.fileno() + p.register(outfd, select.POLLIN) + p.register(errfd, select.POLLIN) + results = {outfd: [], errfd: []} + remaining_fds = set([outfd, errfd]) + + bufsize = 4096 + while remaining_fds: + time_left = max(end_time - time.time(), 0) + r = p.poll(time_left * 1000) # poll() takes timeout in milliseconds + if not r: + kill_process(proc) + raise TimeoutError(b''.join(results[outfd]), + b''.join(results[errfd])) + for fd, flags in r: + # We didn't put the fds in non-blocking mode, but we know the fd + # has data to read, so os.read() will return immediately. + d = os.read(fd, bufsize) + if d: + results[fd].append(d) + else: + # EOF on this fd, stop listening on it + p.unregister(fd) + remaining_fds.remove(fd) + + try: + timed_wait(proc, max(end_time - time.time(), 0)) + except WaitTimeoutError: + kill_process(proc) + raise TimeoutError(b''.join(results[outfd]), + b''.join(results[errfd])) + + return b''.join(results[outfd]), b''.join(results[errfd]) diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py index 52c98d9..af3e75d 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py @@ -18,11 +18,13 @@ # Boston, MA 02110-1301 USA # - from ctypes import * -from bottle import route, run, template, request, response, ServerAdapter -from bottle import abort -from wsgiref.simple_server import make_server, WSGIRequestHandler, WSGIServer +import bottle +from cherrypy.wsgiserver import CherryPyWSGIServer +from cherrypy.wsgiserver.ssl_pyopenssl import pyOpenSSLAdapter +import datetime +import logging +import logging.config import json import ssl import socket @@ -34,13 +36,43 @@ import rest_bmc import rest_gpios import rest_modbus import rest_slotid +import rest_psu_update CONSTANTS = { 'certificate': '/usr/lib/ssl/certs/rest_server.pem', + 'key': '/usr/lib/ssl/private/rest_server_key.pem', +} + +LOGGER_CONF = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'default': { + 'format': '%(message)s' + }, + }, + 'handlers': { + 'file_handler': { + 'level': 'INFO', + 'formatter':'default', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename':'/tmp/rest.log', + 'maxBytes': 1048576, + 'backupCount': 3, + 'encoding': 'utf8' + }, + }, + 'loggers': { + '': { + 'handlers': ['file_handler'], + 'level': 'DEBUG', + 'propagate': True, + }, + } } # Handler for root resource endpoint -@route('/api') +@bottle.route('/api') def rest_api(): result = { "Information": { @@ -53,7 +85,7 @@ def rest_api(): return result # Handler for sys resource endpoint -@route('/api/sys') +@bottle.route('/api/sys') def rest_sys(): result = { "Information": { @@ -67,7 +99,7 @@ def rest_sys(): return result # Handler for sys/mb resource endpoint -@route('/api/sys/mb') +@bottle.route('/api/sys/mb') def rest_sys(): result = { "Information": { @@ -80,73 +112,110 @@ def rest_sys(): return result # Handler for sys/mb/fruid resource endpoint -@route('/api/sys/mb/fruid') +@bottle.route('/api/sys/mb/fruid') def rest_fruid_hdl(): return rest_fruid.get_fruid() # Handler for sys/bmc resource endpoint -@route('/api/sys/bmc') +@bottle.route('/api/sys/bmc') def rest_bmc_hdl(): return rest_bmc.get_bmc() # Handler for sys/server resource endpoint -@route('/api/sys/server') +@bottle.route('/api/sys/server') def rest_server_hdl(): return rest_server.get_server() # Handler for uServer resource endpoint -@route('/api/sys/server', method='POST') +@bottle.route('/api/sys/server', method='POST') def rest_server_act_hdl(): data = json.load(request.body) return rest_server.server_action(data) # Handler for sensors resource endpoint -@route('/api/sys/sensors') +@bottle.route('/api/sys/sensors') def rest_sensors_hdl(): return rest_sensors.get_sensors() # Handler for sensors resource endpoint -@route('/api/sys/gpios') +@bottle.route('/api/sys/gpios') def rest_gpios_hdl(): return rest_gpios.get_gpios() -@route('/api/sys/modbus_registers') +@bottle.route('/api/sys/modbus_registers') def modbus_registers_hdl(): return rest_modbus.get_modbus_registers() +@bottle.route('/api/sys/psu_update') +def psu_update_hdl(): + return rest_psu_update.get_jobs() + +@bottle.route('/api/sys/psu_update', method='POST') +def psu_update_hdl(): + data = json.load(request.body) + return rest_psu_update.begin_job(data) + # Handler for sensors resource endpoint -@route('/api/sys/slotid') +@bottle.route('/api/sys/slotid') def rest_slotid_hdl(): return rest_slotid.get_slotid() -run(host = "::", port = 8080) - # SSL Wrapper for Rest API -class SSLWSGIRefServer(ServerAdapter): +class SSLCherryPyServer(bottle.ServerAdapter): def run(self, handler): - if self.quiet: - class QuietHandler(WSGIRequestHandler): - def log_request(*args, **kw): pass - self.options['handler_class'] = QuietHandler - - # IPv6 Support - server_cls = self.options.get('server_class', WSGIServer) - - if ':' in self.host: - if getattr(server_cls, 'address_family') == socket.AF_INET: - class server_cls(server_cls): - address_family = socket.AF_INET6 - - srv = make_server(self.host, self.port, handler, - server_class=server_cls, **self.options) - srv.socket = ssl.wrap_socket ( - srv.socket, - certfile=CONSTANTS['certificate'], - server_side=True) - srv.serve_forever() - -# Use SSL if the certificate exists. Otherwise, run without SSL. -if os.access(CONSTANTS['certificate'], os.R_OK): - run(server=SSLWSGIRefServer(host="::", port=8443)) + server = CherryPyWSGIServer((self.host, self.port), handler) + server.ssl_adapter = pyOpenSSLAdapter(CONSTANTS['certificate'], CONSTANTS['key']) + try: + server.start() + finally: + server.stop() + + +def log_after_request(): + try: + length = bottle.response.content_length + except: + try: + length = len(bottle.response.body) + except: + length = 0 + + logging.info('{} - - [{}] "{} {} {}" {} {}'.format( + bottle.request.environ.get('REMOTE_ADDR'), + datetime.datetime.now().strftime('%d/%b/%Y %H:%M:%S'), + bottle.request.environ.get('REQUEST_METHOD'), + bottle.request.environ.get('REQUEST_URI'), + bottle.request.environ.get('SERVER_PROTOCOL'), + bottle.response.status_code, + length)) + + +# Error logging to log file +class ErrorLogging(object): + def write(self, err): + logging.error(err) + + +# Middleware to log the requests +class LogMiddleware(object): + def __init__(self, app): + self.app = app + + def __call__(self, e, h): + e['wsgi.errors'] = ErrorLogging() + ret_val = self.app(e, h) + log_after_request() + return ret_val + +# overwrite the stderr and stdout to log to the file +bottle._stderr = logging.error +bottle._stdout = logging.info +logging.config.dictConfig(LOGGER_CONF) + +bottle_app = LogMiddleware(bottle.app()) +# Use SSL if the certificate and key exists. Otherwise, run without SSL. +if (os.access(CONSTANTS['key'], os.R_OK) and + os.access(CONSTANTS['certificate'], os.R_OK)): + bottle.run(host = "::", port= 8443, server=SSLCherryPyServer, app=bottle_app) else: - run(host = "::", port = 8080) + bottle.run(host = "::", port = 8080, server='cherrypy', app=bottle_app) diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py index 167e1fa..3248e92 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py @@ -29,9 +29,10 @@ class FRU(Structure): ("fbw_product_name", c_char * 13), ("fbw_product_number", c_char * 10), ("fbw_assembly_number", c_char * 15), + ("fbw_facebook_pcba_number", c_char * 15), ("fbw_facebook_pcb_number", c_char * 15), - ("fbw_odm_pcb_number", c_char * 14), - ("fbw_odm_pcb_serial", c_char * 13), + ("fbw_odm_pcba_number", c_char * 14), + ("fbw_odm_pcba_serial", c_char * 13), ("fbw_production_state", c_ubyte), ("fbw_product_version", c_ubyte), ("fbw_product_subversion", c_ubyte), @@ -59,9 +60,10 @@ def get_fruid(): "Product Name": myfru.fbw_product_name, "Product Part Number": myfru.fbw_product_number, "System Assembly Part Number": myfru.fbw_assembly_number, + "Facebook PCBA Part Number": myfru.fbw_facebook_pcba_number, "Facebook PCB Part Number": myfru.fbw_facebook_pcb_number, - "ODM PCB Part Number": myfru.fbw_odm_pcb_number, - "ODM PCB Serial Number": myfru.fbw_odm_pcb_serial, + "ODM PCBA Part Number": myfru.fbw_odm_pcba_number, + "ODM PCBA Serial Number": myfru.fbw_odm_pcba_serial, "Product Production State": myfru.fbw_production_state, "Product Version": myfru.fbw_product_version, "Product Sub-Version": myfru.fbw_product_subversion, diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_psu_update.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_psu_update.py new file mode 100644 index 0000000..d0e57c7 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_psu_update.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +import subprocess +from subprocess import Popen +import os +import os.path +import json +import uuid +import urllib2 +from tempfile import mkstemp +from bottle import HTTPError + +UPDATE_JOB_DIR = '/var/rackmond/update_jobs' +UPDATERS = {'delta': '/usr/local/bin/psu-update-delta.py'} + +def get_jobs(): + jobs = [] + if not os.path.exists(UPDATE_JOB_DIR): + os.makedirs(UPDATE_JOB_DIR) + for f in os.listdir(UPDATE_JOB_DIR): + fullpath = os.path.join(UPDATE_JOB_DIR, f) + if f.endswith('.json') and os.path.isfile(fullpath): + with open(fullpath, 'r') as fh: + jdata = json.load(fh) + jdata['job_id'] = os.path.splitext(f)[0] + jobs.append(jdata) + return {'jobs': jobs} + +updater_process = None +def begin_job(jobdesc): + global updater_process + if updater_process is not None: + if updater_process.poll() is not None: + # Update complete + updater_process = None + else: + body = {'error': 'update_already_running', + 'pid': updater_process.pid } + raise HTTPError(409, body) + job_id = str(uuid.uuid1()) + (fwfd, fwfilepath) = mkstemp() + if not os.path.exists(UPDATE_JOB_DIR): + os.makedirs(UPDATE_JOB_DIR) + statusfilepath = os.path.join(UPDATE_JOB_DIR, str(job_id) + '.json') + status = {'pid': 0, + 'state': 'fetching' } + with open(statusfilepath, 'wb') as sfh: + sfh.write(json.dumps(status)) + fwdata = urllib2.urlopen(jobdesc['fw_url']) + with os.fdopen(fwfd, 'wb') as fwfile: + fwfile.write(fwdata.read()) + fwfile.flush() + updater = UPDATERS[jobdesc.get('updater', 'delta')] + updater_process = Popen([updater, + '--addr', str(jobdesc['address']), + '--statusfile', statusfilepath, + '--rmfwfile', + fwfilepath]) + status = {'pid': updater_process.pid, + 'state': 'starting' } + with open(statusfilepath, 'wb') as sfh: + sfh.write(json.dumps(status)) + return {'job_id': job_id, 'pid': updater_process.pid} diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py index fa65372..382513b 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py @@ -18,15 +18,23 @@ # Boston, MA 02110-1301 USA # - import json -import os import re +import subprocess +import bmc_command # Handler for sensors resource endpoint def get_sensors(): result = [] - data = os.popen('sensors').read() + proc = subprocess.Popen(['sensors'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + try: + data, err = bmc_command.timed_communicate(proc) + except bmc_command.TimeoutError as ex: + data = ex.output + err = ex.error + data = re.sub(r'\(.+?\)', '', data) for edata in data.split('\n\n'): adata = edata.split('\n', 1) @@ -40,6 +48,7 @@ def get_sensors(): continue sresult[tdata[0].strip()] = tdata[1].strip() result.append(sresult) + fresult = { "Information": result, "Actions": [], diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh index bdd79b6..2b274dc 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh @@ -27,6 +27,53 @@ # Short-Description: Set REST API handler ### END INIT INFO -echo -n "Setup REST API handler... " -/usr/local/bin/rest.py > /tmp/rest.log 2>&1 & -echo "done." +# source function library +. /etc/init.d/functions + +ACTION="$1" +CMD="/usr/local/bin/rest.py" +case "$ACTION" in + start) + echo -n "Setting up REST API handler: " + pid=$(ps | grep -v grep | grep $CMD | awk '{print $1}') + if [ $pid ]; then + echo "already running" + else + $CMD > /tmp/rest_start.log 2>&1 & + echo "done." + fi + ;; + stop) + echo -n "Stopping REST API handler: " + pid=$(ps | grep -v grep | grep $CMD | awk '{print $1}') + if [ $pid ]; then + kill $pid + fi + echo "done." + ;; + restart) + echo -n "Restarting REST API handler: " + pid=$(ps | grep -v grep | grep $CMD | awk '{print $1}') + if [ $pid ]; then + kill $pid + fi + sleep 1 + $CMD > /tmp/rest_start.log 2>&1 & + echo "done." + ;; + status) + if [[ -n $(ps | grep -v grep | grep $CMD | awk '{print $1}') ]]; then + echo "REST API handler is running" + else + echo "REST API is stopped" + fi + ;; + *) + N=${0##*/} + N=${N#[SK]??} + echo "Usage: $N {start|stop|status|restart}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb index 5dec4bf..2ed3f7f 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb @@ -33,11 +33,13 @@ SRC_URI = "file://setup-rest-api.sh \ file://rest_sensors.py \ file://rest_modbus.py \ file://rest_slotid.py \ + file://rest_psu_update.py \ + file://bmc_command.py \ " S = "${WORKDIR}" -binfiles = "rest.py rest_bmc.py rest_fruid.py rest_gpios.py rest_server.py rest_sensors.py rest_modbus.py rest_slotid.py setup-rest-api.sh" +binfiles = "rest.py rest_bmc.py rest_fruid.py rest_gpios.py rest_server.py rest_sensors.py bmc_command.py rest_modbus.py rest_slotid.py rest_psu_update.py setup-rest-api.sh" pkgdir = "rest-api" diff --git a/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh b/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh index 0030775..2e1ee67 100755 --- a/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh @@ -19,6 +19,15 @@ # modprobe g_cdc host_addr=02:00:00:00:00:02 dev_addr=02:00:00:00:00:01 +# For g-ether interface, if the remote side brings down the interface, BMC side +# still treats it as up. In this case, all packets through usb0 (i.e. NDP) will +# be queued in the kernel for this interface. Ether interface has the default +# TX queue length as 1000, which means there could be up to 1000 package queued +# in kernel for that. In our case, kmalloc-192 is exhausted when 298 packets +# are queued. +# To solve this issue, we change the TX queue length for usb0 to 64 to avoid +# memory exhaust. +ifconfig usb0 txqueuelen 64 while true; do getty /dev/ttyGS0 57600 sleep 1 diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c index e66941e..7e9b50d 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c @@ -29,8 +29,10 @@ #define FBW_EEPROM_FILE "/sys/class/i2c-adapter/i2c-6/6-0050/eeprom" #endif -#define FBW_EEPROM_VERSION 0 +#define FBW_EEPROM_VERSION0 0 #define FBW_EEPROM_V0_SIZE 162 +#define FBW_EEPROM_VERSION1 1 +#define FBW_EEPROM_V1_SIZE 174 /* * The eeprom size is 8K, we only use 157 bytes for v1 format. @@ -225,12 +227,17 @@ static int fbw_parse_buffer( /* confirm the version number, only version is supported */ fbw_copy_uint8(&eeprom->fbw_version, &cur, FBW_EEPROM_F_VERSION); - if (eeprom->fbw_version != FBW_EEPROM_VERSION) { + if ((eeprom->fbw_version != FBW_EEPROM_VERSION0) && + (eeprom->fbw_version != FBW_EEPROM_VERSION1)) { rc = EFAULT; LOG_ERR(rc, "Unsupported version number %u", eeprom->fbw_version); goto out; } else { - crc_len = FBW_EEPROM_V0_SIZE; + if (eeprom->fbw_version == FBW_EEPROM_VERSION0) { + crc_len = FBW_EEPROM_V0_SIZE; + } else if (eeprom->fbw_version == FBW_EEPROM_VERSION1) { + crc_len = FBW_EEPROM_V1_SIZE; + } assert(crc_len <= len); } @@ -257,20 +264,27 @@ static int fbw_parse_buffer( sizeof(eeprom->fbw_assembly_number), &cur, FBW_EEPROM_F_ASSEMBLY_NUMBER); - /* Facebook PCB Part Number: XXX-XXXXXXX-XX */ - fbw_copy_facebook_pcb_part(eeprom->fbw_facebook_pcb_number, - sizeof(eeprom->fbw_facebook_pcb_number), - &cur, FBW_EEPROM_F_FACEBOOK_PCB_NUMBER); + /* Facebook PCBA Part Number: XXX-XXXXXXX-XX */ + fbw_copy_facebook_pcb_part(eeprom->fbw_facebook_pcba_number, + sizeof(eeprom->fbw_facebook_pcba_number), + &cur, FBW_EEPROM_F_FACEBOOK_PCBA_NUMBER); + + /* Facebook PCBA Part Number: XXX-XXXXXXX-XX */ + if (eeprom->fbw_version >= FBW_EEPROM_VERSION1) { + fbw_copy_facebook_pcb_part(eeprom->fbw_facebook_pcb_number, + sizeof(eeprom->fbw_facebook_pcb_number), + &cur, FBW_EEPROM_F_FACEBOOK_PCB_NUMBER); + } /* ODM PCB Part Number: XXXXXXXXXXXX */ - fbw_strcpy(eeprom->fbw_odm_pcb_number, - sizeof(eeprom->fbw_odm_pcb_number), - &cur, FBW_EEPROM_F_ODM_PCB_NUMBER); + fbw_strcpy(eeprom->fbw_odm_pcba_number, + sizeof(eeprom->fbw_odm_pcba_number), + &cur, FBW_EEPROM_F_ODM_PCBA_NUMBER); /* ODM PCB Serial Number: XXXXXXXXXXXX */ - fbw_strcpy(eeprom->fbw_odm_pcb_serial, - sizeof(eeprom->fbw_odm_pcb_serial), - &cur, FBW_EEPROM_F_ODM_PCB_SERIAL); + fbw_strcpy(eeprom->fbw_odm_pcba_serial, + sizeof(eeprom->fbw_odm_pcba_serial), + &cur, FBW_EEPROM_F_ODM_PCBA_SERIAL); /* Product Production State */ fbw_copy_uint8(&eeprom->fbw_production_state, diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h index 2c4f39e..8aa012f 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h @@ -29,9 +29,10 @@ extern "C" { #define FBW_EEPROM_F_PRODUCT_NAME 12 #define FBW_EEPROM_F_PRODUCT_NUMBER 8 #define FBW_EEPROM_F_ASSEMBLY_NUMBER 12 +#define FBW_EEPROM_F_FACEBOOK_PCBA_NUMBER 12 #define FBW_EEPROM_F_FACEBOOK_PCB_NUMBER 12 -#define FBW_EEPROM_F_ODM_PCB_NUMBER 13 -#define FBW_EEPROM_F_ODM_PCB_SERIAL 12 +#define FBW_EEPROM_F_ODM_PCBA_NUMBER 13 +#define FBW_EEPROM_F_ODM_PCBA_SERIAL 12 #define FBW_EEPROM_F_PRODUCT_STATE 1 #define FBW_EEPROM_F_PRODUCT_VERSION 1 #define FBW_EEPROM_F_PRODUCT_SUBVERSION 1 @@ -60,14 +61,17 @@ struct wedge_eeprom_st { /* System Assembly Part Number XXX-XXXXXX-XX */ char fbw_assembly_number[FBW_EEPROM_F_ASSEMBLY_NUMBER + 3]; + /* Facebook PCBA Part Number: XXX-XXXXXXX-XX */ + char fbw_facebook_pcba_number[FBW_EEPROM_F_FACEBOOK_PCBA_NUMBER + 3]; + /* Facebook PCB Part Number: XXX-XXXXXXX-XX */ char fbw_facebook_pcb_number[FBW_EEPROM_F_FACEBOOK_PCB_NUMBER + 3]; /* ODM PCB Part Number: XXXXXXXXXXXX */ - char fbw_odm_pcb_number[FBW_EEPROM_F_ODM_PCB_NUMBER + 1]; + char fbw_odm_pcba_number[FBW_EEPROM_F_ODM_PCBA_NUMBER + 1]; /* ODM PCB Serial Number: XXXXXXXXXXXX */ - char fbw_odm_pcb_serial[FBW_EEPROM_F_ODM_PCB_SERIAL + 1]; + char fbw_odm_pcba_serial[FBW_EEPROM_F_ODM_PCBA_SERIAL + 1]; /* Product Production State */ uint8_t fbw_production_state; @@ -88,7 +92,7 @@ struct wedge_eeprom_st { char fbw_system_manufacturer[FBW_EEPROM_F_SYSTEM_MANUFACTURER + 1]; /* System Manufacturing Date: mm-dd-yy */ - char fbw_system_manufacturing_date[10]; + uint8_t fbw_system_manufacturing_date[10]; /* PCB Manufacturer: XXXXXXXXX */ char fbw_pcb_manufacturer[FBW_EEPROM_F_PCB_MANUFACTURER + 1]; diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c index 90aca10..49d7174 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c @@ -45,9 +45,10 @@ int main(int argc, const char *argv[]) printf("Product Name: %s\n", eeprom.fbw_product_name); printf("Product Part Number: %s\n", eeprom.fbw_product_number); printf("System Assembly Part Number: %s\n", eeprom.fbw_assembly_number); + printf("Facebook PCBA Part Number: %s\n", eeprom.fbw_facebook_pcba_number); printf("Facebook PCB Part Number: %s\n", eeprom.fbw_facebook_pcb_number); - printf("ODM PCB Part Number: %s\n", eeprom.fbw_odm_pcb_number); - printf("ODM PCB Serial Number: %s\n", eeprom.fbw_odm_pcb_serial); + printf("ODM PCBA Part Number: %s\n", eeprom.fbw_odm_pcba_number); + printf("ODM PCBA Serial Number: %s\n", eeprom.fbw_odm_pcba_serial); printf("Product Production State: %d\n", eeprom.fbw_production_state); printf("Product Version: %d\n", eeprom.fbw_product_version); printf("Product Sub-Version: %d\n", eeprom.fbw_product_subversion); @@ -58,11 +59,11 @@ int main(int argc, const char *argv[]) eeprom.fbw_system_manufacturing_date); printf("PCB Manufacturer: %s\n", eeprom.fbw_pcb_manufacturer); printf("Assembled At: %s\n", eeprom.fbw_assembled); - printf("Local MAC: %X:%X:%X:%X:%X:%X\n", + printf("Local MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", eeprom.fbw_local_mac[0], eeprom.fbw_local_mac[1], eeprom.fbw_local_mac[2], eeprom.fbw_local_mac[3], eeprom.fbw_local_mac[4], eeprom.fbw_local_mac[5]); - printf("Extended MAC Base: %X:%X:%X:%X:%X:%X\n", + printf("Extended MAC Base: %02X:%02X:%02X:%02X:%02X:%02X\n", eeprom.fbw_mac_base[0], eeprom.fbw_mac_base[1], eeprom.fbw_mac_base[2], eeprom.fbw_mac_base[3], eeprom.fbw_mac_base[4], eeprom.fbw_mac_base[5]); diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb index 3afbed1..ea41a98 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb @@ -31,6 +31,8 @@ do_install() { install -m 0755 weutil ${D}${bindir}/weutil } +RDEPENDS_${PN} = "libwedge-eeprom" + DEPENDS += "libwedge-eeprom" FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-wedge100/conf/bblayers.conf.sample b/meta-facebook/meta-wedge100/conf/bblayers.conf.sample new file mode 100644 index 0000000..5b69b43 --- /dev/null +++ b/meta-facebook/meta-wedge100/conf/bblayers.conf.sample @@ -0,0 +1,23 @@ +# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf +# changes incompatibly +LCONF_VERSION = "6" + +BBPATH = "${TOPDIR}" +BBFILES ?= "" + +BBLAYERS ?= " \ + ##OEROOT##/meta \ + ##OEROOT##/meta-yocto \ + ##OEROOT##/meta-yocto-bsp \ + ##OEROOT##/meta-openembedded/meta-oe \ + ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-python \ + ##OEROOT##/meta-openbmc \ + ##OEROOT##/meta-openbmc/meta-aspeed \ + ##OEROOT##/meta-openbmc/meta-facebook/meta-wedge \ + ##OEROOT##/meta-openbmc/meta-facebook/meta-wedge100 \ + " +BBLAYERS_NON_REMOVABLE ?= " \ + ##OEROOT##/meta \ + ##OEROOT##/meta-yocto \ + " diff --git a/meta-facebook/meta-wedge100/conf/conf-notes.txt b/meta-facebook/meta-wedge100/conf/conf-notes.txt new file mode 100644 index 0000000..becc2df --- /dev/null +++ b/meta-facebook/meta-wedge100/conf/conf-notes.txt @@ -0,0 +1,2 @@ +Common targets are: + wedge100-image diff --git a/meta-facebook/meta-wedge100/conf/layer.conf b/meta-facebook/meta-wedge100/conf/layer.conf new file mode 100644 index 0000000..63e14cb --- /dev/null +++ b/meta-facebook/meta-wedge100/conf/layer.conf @@ -0,0 +1,10 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "wedge100" +BBFILE_PATTERN_wedge100 = "^${LAYERDIR}/" +BBFILE_PRIORITY_wedge100 = "10" diff --git a/meta-facebook/meta-wedge100/conf/local.conf.sample b/meta-facebook/meta-wedge100/conf/local.conf.sample new file mode 100644 index 0000000..c322b71 --- /dev/null +++ b/meta-facebook/meta-wedge100/conf/local.conf.sample @@ -0,0 +1,145 @@ +# +# Local configuration file for building the OpenBMC image. +# + +# Always look for packages first in our own local package mirror +SOURCE_MIRROR_URL ?= "file://${TOPDIR}/../meta-openbmc/source_mirror/" +INHERIT += "own-mirrors" + +# Save local tarballs for all packages we download. +# This can be used to update our mirror directory above. +BB_GENERATE_MIRROR_TARBALLS = "1" + +# The following setting will prevent bitbake from downloading anything over the +# network. This can be used to ensure that we get everything from a local +# file:// mirror. +# +# Comment this out if you do need to download new packages from the internet. +# However, once you have downloaded the package you should check them into our +# mirror repository so that other developers will always get it from the mirror +# repo. +BB_NO_NETWORK = "fb-only" + +# Parallelism Options +# +# How many tasks bitbake should run in parallel: +BB_NUMBER_THREADS ?= "${@oe.utils.cpu_count()}" +# How many processes make should run in parallel: +PARALLEL_MAKE ?= "-j ${@oe.utils.cpu_count()}" + +# Machine Selection +MACHINE ??= "wedge100" + +# Build directory locationds. +# +#DL_DIR ?= "${TOPDIR}/downloads" +#SSTATE_DIR ?= "${TOPDIR}/sstate-cache" +#TMPDIR = "${TOPDIR}/tmp" + +# +# Default policy config +# We could eventually create our own distro config if desired, +# but for now we use the standard poky distro settings. +# +DISTRO ?= "poky" + +# Use RPM packages +PACKAGE_CLASSES ?= "package_rpm" + +# Extra image features. +# Currently we do not enable anything extra here. +#EXTRA_IMAGE_FEATURES = "" + +# We build on CentOS 6.3. +# Don't complain about it, even though it isn't in poky's default +# list of supported distros. +SANITY_TESTED_DISTROS_append ?= " CentOS-6.3 \n " + +# +# Additional image features +# +# The following is a list of additional classes to use when building images which +# enable extra features. Some available options which can be included in this variable +# are: +# - 'buildstats' collect build statistics +# - 'image-mklibs' to reduce shared library files size for an image +# - 'image-prelink' in order to prelink the filesystem image +# - 'image-swab' to perform host system intrusion detection +# NOTE: if listing mklibs & prelink both, then make sure mklibs is before prelink +# NOTE: mklibs also needs to be explicitly enabled for a given image, see local.conf.extended +USER_CLASSES ?= "buildstats image-mklibs image-prelink" + +# +# Interactive shell configuration +# +# Under certain circumstances the system may need input from you and to do this it +# can launch an interactive shell. It needs to do this since the build is +# multithreaded and needs to be able to handle the case where more than one parallel +# process may require the user's attention. The default is iterate over the available +# terminal types to find one that works. +# +# Examples of the occasions this may happen are when resolving patches which cannot +# be applied, to use the devshell or the kernel menuconfig +# +# Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none +# Note: currently, Konsole support only works for KDE 3.x due to the way +# newer Konsole versions behave +#OE_TERMINAL = "auto" +# By default disable interactive patch resolution (tasks will just fail instead): +PATCHRESOLVE = "noop" + +# +# Disk Space Monitoring during the build +# +# Monitor the disk space during the build. If there is less that 1GB of space or less +# than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully +# shutdown the build. If there is less that 100MB or 1K inodes, perform a hard abort +# of the build. The reason for this is that running completely out of space can corrupt +# files and damages the build in ways which may not be easily recoverable. +BB_DISKMON_DIRS = "\ + STOPTASKS,${TMPDIR},1G,100K \ + STOPTASKS,${DL_DIR},1G,100K \ + STOPTASKS,${SSTATE_DIR},1G,100K \ + ABORT,${TMPDIR},100M,1K \ + ABORT,${DL_DIR},100M,1K \ + ABORT,${SSTATE_DIR},100M,1K" + +# +# Shared-state files from other locations +# +# As mentioned above, shared state files are prebuilt cache data objects which can +# used to accelerate build time. This variable can be used to configure the system +# to search other mirror locations for these objects before it builds the data itself. +# +# This can be a filesystem directory, or a remote url such as http or ftp. These +# would contain the sstate-cache results from previous builds (possibly from other +# machines). This variable works like fetcher MIRRORS/PREMIRRORS and points to the +# cache locations to check for the shared objects. +# NOTE: if the mirror uses the same structure as SSTATE_DIR, you need to add PATH +# at the end as shown in the examples below. This will be substituted with the +# correct path within the directory structure. +#SSTATE_MIRRORS ?= "\ +#file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \ +#file://.* file:///some/local/dir/sstate/PATH" + + +# CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to +# track the version of this file when it was generated. This can safely be ignored if +# this doesn't mean anything to you. +CONF_VERSION = "1" + + +# Update root password to '0penBmc' and change the root shell back to bash. +# This default root password is used at the ODM and system integrator. It will be +# changed during provisioning at the datacenter. +INHERIT += "extrausers" + +EXTRA_USERS_PARAMS = " \ + usermod -s /bin/bash root; \ + usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \ + " + +OLDEST_KERNEL = "2.6.28" + +INHERIT += "blacklist" +PNBLACKLIST[glibc] = "glibc 2.21 does not work with our kernel 2.6.28" diff --git a/meta-facebook/meta-wedge100/conf/machine/wedge100.conf b/meta-facebook/meta-wedge100/conf/machine/wedge100.conf new file mode 100644 index 0000000..2416809 --- /dev/null +++ b/meta-facebook/meta-wedge100/conf/machine/wedge100.conf @@ -0,0 +1,18 @@ +#@TYPE: Machine +#@NAME: Wedge100 +#@DESCRIPTION: Machine configuration for Facebook Wedge100 + +UBOOT_MACHINE_wedge100 = "wedge100_config" + +require conf/machine/include/ast1250.inc + +# configuration for preferred version of packages +PREFERRED_VERSION_libipmi = "0.1" +PREFERRED_VERSION_ipmid = "0.1" +PREFERRED_VERSION_rest-api = "0.1" + +MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-i2c-dev-sysfs" +MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-cpld" +MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-com-e-driver" + +TCLIBC = 'eglibc' diff --git a/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/get_fan_speed.sh b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/get_fan_speed.sh new file mode 100755 index 0000000..042a72f --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/get_fan_speed.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +usage() { + echo "Usage: $0 [Fan Unit (1..5)]" >&2 +} + +FAN_DIR=/sys/class/i2c-adapter/i2c-8/8-0033 + +show_pwm() +{ + pwm="${FAN_DIR}/fantray${1}_pwm" + val=$(cat $pwm | head -n 1) + echo "$((val * 100 / 31))%" +} + +show_rpm() +{ + front_rpm="${FAN_DIR}/fan$((($1 * 2 - 1)))_input" + rear_rpm="${FAN_DIR}/fan$((($1 * 2)))_input" + echo "$(cat $front_rpm), $(cat $rear_rpm)" +} + +set -e + +# refer to the comments in init_pwn.sh regarding +# the fan unit and tacho mapping +if [ "$#" -eq 0 ]; then + FANS="1 2 3 4 5" +elif [ "$#" -eq 1 ]; then + if [ $1 -gt 5 ]; then + usage + exit 1 + fi + FANS="$1" +else + usage + exit 1 +fi + +for fan in $FANS; do + echo "Fan $fan RPMs: $(show_rpm $fan), ($(show_pwm $fan))" +done diff --git a/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/set_fan_speed.sh b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/set_fan_speed.sh new file mode 100755 index 0000000..ff5a584 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/set_fan_speed.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +usage() { + echo "Usage: $0 <PERCENT (0..100)> <Fan Unit (1..5)> " >&2 +} + +FAN_DIR=/sys/class/i2c-adapter/i2c-8/8-0033 + +set -e + +if [ "$#" -ne 2 ] && [ "$#" -ne 1 ]; then + usage + exit 1 +fi + +if [ "$#" -eq 1 ]; then + FANS="1 2 3 4 5" +else + FANS="$2" +fi + +# Convert the percentage to our 1/32th unit (0-31). +unit=$(( ( $1 * 31 ) / 100 )) + +for fan in $FANS; do + pwm="${FAN_DIR}/fantray${fan}_pwm" + echo "$unit" > $pwm + echo "Successfully set fan ${fan} speed to $1%" +done diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/watch-fc.sh b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh index d04b7cd..26691dc 100755..100644 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/watch-fc.sh +++ b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl/setup-fan.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright 2014-present Facebook. All Rights Reserved. # @@ -18,17 +18,16 @@ # Boston, MA 02110-1301 USA # -. /usr/local/fbpackages/utils/ast-functions +### BEGIN INIT INFO +# Provides: setup-fan +# Required-Start: board-id +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Set fan speed +### END INIT INFO -MAC1LINK=0 # GPIOA0 -FAB0_PRES=20 # GPIOC4 -FAB1_PRES=21 # GPIOC5 -while true; do - # fabN_pres: active low. - if [ $(gpio_get $FAB0_PRES) = 0 ]; then - gpio_set $MAC1LINK 0 - elif [ $(gpio_get $FAB1_PRES) = 0 ]; then - gpio_set $MAC1LINK 1 - fi - sleep 1 -done +echo -n "Setup fan speed... " +/usr/local/bin/set_fan_speed.sh 50 +/usr/local/bin/fand +echo "done." diff --git a/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend new file mode 100644 index 0000000..ff5f2d5 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-core/fan-ctrl/fan-ctrl_0.1.bbappend @@ -0,0 +1,46 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +DEPENDS_append = " update-rc.d-native" + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +SRC_URI += "file://get_fan_speed.sh \ + file://set_fan_speed.sh \ + file://setup-fan.sh \ + " + +S = "${WORKDIR}" + +binfiles = " \ + get_fan_speed.sh \ + set_fan_speed.sh \ + fand \ + " + +CXXFLAGS_prepend = "-DCONFIG_WEDGE100 " + +do_install() { + bin="${D}/usr/local/bin" + install -d $bin + for f in ${binfiles}; do + install -m 755 $f ${bin}/$f + done + install -d ${D}${sysconfdir}/init.d + install -d ${D}${sysconfdir}/rcS.d + install -m 755 setup-fan.sh ${D}${sysconfdir}/init.d/setup-fan.sh + update-rc.d -r ${D} setup-fan.sh start 91 S . +} diff --git a/meta-facebook/meta-wedge100/recipes-core/images/wedge100-image.bb b/meta-facebook/meta-wedge100/recipes-core/images/wedge100-image.bb new file mode 100644 index 0000000..291ebf0 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-core/images/wedge100-image.bb @@ -0,0 +1,82 @@ +inherit aspeed_uboot_image + +# /dev +require recipes-core/images/aspeed-dev.inc + +# Base this image on core-image-minimal +include recipes-core/images/core-image-minimal.bb + +# Changing the image compression from gz to lzma achieves 30% saving (~3M). +# However, the current u-boot does not have lzma enabled. Stick to gz +# until we generate a new u-boot image. +IMAGE_FSTYPES += "cpio.lzma.u-boot" +UBOOT_IMAGE_ENTRYPOINT = "0x40800000" + +PYTHON_PKGS = " \ + python-core \ + python-io \ + python-json \ + python-shell \ + python-subprocess \ + python-argparse \ + python-ctypes \ + python-datetime \ + python-email \ + python-threading \ + python-mime \ + python-pickle \ + python-misc \ + python-netserver \ + " + +NTP_PKGS = " \ + ntp \ + ntp-utils \ + sntp \ + ntpdate \ + " + +# Include modules in rootfs +IMAGE_INSTALL += " \ + kernel-modules \ + u-boot \ + u-boot-fw-utils \ + openbmc-utils \ + openbmc-gpio \ + fan-ctrl \ + rackmon \ + watchdog-ctrl \ + i2c-tools \ + sensor-setup \ + usb-console \ + oob-nic \ + lldp-util \ + lmsensors-sensors \ + wedge-eeprom \ + sms-kcsd \ + rest-api \ + bottle \ + ipmid \ + po-eeprom \ + bitbang \ + ${PYTHON_PKGS} \ + ${NTP_PKGS} \ + iproute2 \ + dhcp-client \ + jbi \ + flashrom \ + cherryPy \ + " + +IMAGE_FEATURES += " \ + ssh-server-openssh \ + tools-debug \ + " + +DISTRO_FEATURES += " \ + ext2 \ + ipv6 \ + nfs \ + usbgadget \ + usbhost \ + " diff --git a/meta-facebook/meta-wedge100/recipes-core/sysvinit/sysvinit-inittab_%.bbappend b/meta-facebook/meta-wedge100/recipes-core/sysvinit/sysvinit-inittab_%.bbappend new file mode 100644 index 0000000..6d4deb3 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-core/sysvinit/sysvinit-inittab_%.bbappend @@ -0,0 +1,5 @@ +# ttyS0 is UART5, connected through SYSCPLD, to debug board, if GPIOE0 is 1 +# ttyS1 is UART1, connected through SYSCPLD, to micro-server console, if GPIOE0 is 1 +# ttyS2 is UART3, connected to the front panel Console port +# ttyS3 is UART4, connected through SYSCPLD, to rackmon RS485 +SERIAL_CONSOLES = "57600;ttyS0 9600;ttyS2" diff --git a/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/COPYING b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/COPYING new file mode 100644 index 0000000..6d45519 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/Makefile b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/Makefile new file mode 100644 index 0000000..d3b524e --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/Makefile @@ -0,0 +1,31 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +obj-m := com_e_driver.o + +SRC := $(shell pwd) + +all: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install + +clean: + rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c + rm -f Module.markers Module.symvers modules.order + rm -rf .tmp_versions Modules.symvers diff --git a/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/com_e_driver.c b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/com_e_driver.c new file mode 100644 index 0000000..0a3df37 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/files/com_e_driver.c @@ -0,0 +1,365 @@ +/* + * com_e_driver.c - The i2c driver for COMe + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <linux/errno.h> +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/i2c_dev_sysfs.h> + +#ifdef DEBUG + +#define PP_DEBUG(fmt, ...) do { \ + printk(KERN_DEBUG "%s:%d " fmt "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} while (0) + +#else /* !DEBUG */ + +#define PP_DEBUG(fmt, ...) + +#endif + +static ssize_t i2c_dev_show_mac(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + uint8_t values[6]; + int ret_val; + + ret_val = i2c_dev_read_nbytes(dev, attr, values, 6); + if (ret_val < 0) { + return ret_val; + } + //values[] : mac address + return scnprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n", values[0], + values[1], values[2], values[3], values[4], values[5]); +} + +static ssize_t i2c_dev_show_date(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + uint8_t values[3]; + int ret_val; + + ret_val = i2c_dev_read_nbytes(dev, attr, values, 3); + if (ret_val < 0) { + return ret_val; + } + //values[0] : year + //values[1] : month + //values[2] : day + return scnprintf(buf, PAGE_SIZE, "%x/%x/%x\n", values[1], + values[2], values[0]); +} + +static ssize_t i2c_dev_show_version(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + uint8_t values[3]; + int ret_val; + + ret_val = i2c_dev_read_nbytes(dev, attr, values, 3); + if (ret_val < 0) { + return ret_val; + } + //values[0] : Version_R + //values[1] : Version_E + //values[2] : Version_T + return scnprintf(buf, PAGE_SIZE, "EC Version R=0x%02x E=0x%02x T=0x%2x\n", + values[0], values[1], values[2]); + +} + +static ssize_t i2c_dev_show_cpu_temp(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int ret_val; + + ret_val = i2c_dev_read_byte(dev, attr); + if (ret_val < 0) { + return ret_val; + } + return scnprintf(buf, PAGE_SIZE, "%u\n", ret_val); +} + +static ssize_t i2c_dev_show_voltage0(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int result; + + result = i2c_dev_read_word_littleendian(dev, attr); + if (result < 0) { + return result; + } + result = (result * 1000) / 341; + return scnprintf(buf, PAGE_SIZE, "%u\n", result); +} + +static ssize_t i2c_dev_show_voltage1(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int result; + + result = i2c_dev_read_word_littleendian(dev, attr); + if (result < 0) { + return result; + } + result = (result * 2000) / 341; + return scnprintf(buf, PAGE_SIZE, "%u\n", result); +} + +static ssize_t i2c_dev_show_voltage2(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int result; + + result = i2c_dev_read_word_littleendian(dev, attr); + if (result < 0) { + return result; + } + result = (result * 3200) / 341; + return scnprintf(buf, PAGE_SIZE, "%u\n", result); +} + +static ssize_t i2c_dev_show_voltage3(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int result; + + result = i2c_dev_read_word_littleendian(dev, attr); + if (result < 0) { + return result; + } + result = (result * 6600) / 341; + return scnprintf(buf, PAGE_SIZE, "%u\n", result); +} + +static const i2c_dev_attr_st com_e_attr_table[] = { + { + "temp1_input", // cpu_temp + NULL, + i2c_dev_show_cpu_temp, + NULL, + 0x0, 0, 8, + }, + { + "version", // version_r,_e,_t + NULL, + i2c_dev_show_version, + NULL, + 0x1D, 0, 24, + }, + { + "in0_input", // CPU_vcore + NULL, + i2c_dev_show_voltage0, + NULL, + 0x20, 0, 16, + }, + { + "in1_input",// 3V + NULL, + i2c_dev_show_voltage1, + NULL, + 0x22, 0, 16, + }, + { + "in2_input",// 5V + NULL, + i2c_dev_show_voltage2, + NULL, + 0x24, 0, 16, + }, + { + "date", + NULL, + i2c_dev_show_date, + NULL, + 0x2D, 0, 24, + }, + { + "in3_input",// 12V + NULL, + i2c_dev_show_voltage3, + NULL, + 0x30, 0, 16, + }, + { + "in4_input",// VDIMM + NULL, + i2c_dev_show_voltage0, + NULL, + 0x32, 0, 16, + }, + { + "product_name", + NULL, + i2c_dev_show_ascii, + NULL, + 0x3C, 0, 32, + }, + { + "customize_name", + NULL, + i2c_dev_show_ascii, + NULL, + 0x4D, 0, 24, + }, + { + "mac", + NULL, + i2c_dev_show_mac, + NULL, + 0x50, 0, 48, + }, + { + "serial_number", + NULL, + i2c_dev_show_ascii, + NULL, + 0x60, 0, 256, + }, + { + "in0_label", + "CPU Vcore", + i2c_dev_show_label, + NULL, + 0x0, 0, 0, + }, + { + "in1_label", + "+3V Voltage", + i2c_dev_show_label, + NULL, + 0x0, 0, 0, + }, + { + "in2_label", + "+5V Voltage", + i2c_dev_show_label, + NULL, + 0x0, 0, 0, + }, + { + "in3_label", + "+12V Voltage", + i2c_dev_show_label, + NULL, + 0x0, 0, 0, + }, + { + "in4_label", + "VDIMM Voltage", + i2c_dev_show_label, + NULL, + 0x0, 0, 0, + }, + { + "temp1_label", + "CPU Temp", + i2c_dev_show_label, + NULL, + 0x0, 0, 0, + }, +}; + +static i2c_dev_data_st com_e_data; + +/* + * COMe i2c addresses. + * normal_i2c is used in I2C_CLIENT_INSMOD_1() + */ +static const unsigned short normal_i2c[] = { + 0x33, I2C_CLIENT_END +}; + +/* + * Insmod parameters + */ +I2C_CLIENT_INSMOD_1(com_e); + +/* COMe id */ +static const struct i2c_device_id com_e_id[] = { + { "com_e_driver", com_e_id }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, com_e_id); + +/* Return 0 if detection is successful, -ENODEV otherwise */ +static int com_e_detect(struct i2c_client *client, int kind, + struct i2c_board_info *info) +{ + /* + * We don't currently do any detection of the COMe + */ + strlcpy(info->type, "com_e_driver", I2C_NAME_SIZE); + return 0; +} + +static int com_e_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int n_attrs = sizeof(com_e_attr_table) / sizeof(com_e_attr_table[0]); + return i2c_dev_sysfs_data_init(client, &com_e_data, + com_e_attr_table, n_attrs); +} + +static int com_e_remove(struct i2c_client *client) +{ + i2c_dev_sysfs_data_clean(client, &com_e_data); + return 0; +} + +static struct i2c_driver com_e_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "com_e_driver", + }, + .probe = com_e_probe, + .remove = com_e_remove, + .id_table = com_e_id, + .detect = com_e_detect, + /* addr_data is defined through I2C_CLIENT_INSMOD_1() */ + .address_data = &addr_data, +}; + +static int __init com_e_mod_init(void) +{ + return i2c_add_driver(&com_e_driver); +} + +static void __exit com_e_mod_exit(void) +{ + i2c_del_driver(&com_e_driver); +} + +MODULE_AUTHOR("Vineela Kukkadapu <vineelak@fb.com>"); +MODULE_DESCRIPTION("COM_E Driver"); +MODULE_LICENSE("GPL"); + +module_init(com_e_mod_init); +module_exit(com_e_mod_exit); diff --git a/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/kernel-module-com-e-driver_0.1.bb b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/kernel-module-com-e-driver_0.1.bb new file mode 100644 index 0000000..53f679e --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/com-e-mod/kernel-module-com-e-driver_0.1.bb @@ -0,0 +1,40 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +SUMMARY = "Wedge100 COMe driver" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" + +inherit module + +PR = "r0" +PV = "0.1" + +SRC_URI = "file://Makefile \ + file://com_e_driver.c \ + file://COPYING \ + " + +S = "${WORKDIR}" + +DEPENDS += "kernel-module-i2c-dev-sysfs" + +RDEPENDS_${PN} += "kernel-module-i2c-dev-sysfs" + +KERNEL_MODULE_AUTOLOAD += " \ + com_e_driver \ +" diff --git a/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/COPYING b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/COPYING new file mode 100644 index 0000000..6d45519 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/Makefile b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/Makefile new file mode 100644 index 0000000..bfbd786 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/Makefile @@ -0,0 +1,31 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +obj-m := syscpld.o fancpld.o + +SRC := $(shell pwd) + +all: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install + +clean: + rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c + rm -f Module.markers Module.symvers modules.order + rm -rf .tmp_versions Modules.symvers diff --git a/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/fancpld.c b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/fancpld.c new file mode 100644 index 0000000..65ea0d1 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/fancpld.c @@ -0,0 +1,396 @@ +/* + * fancpld.c - The i2c driver for FANBOARDCPLD + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +//#define DEBUG + +#include <linux/errno.h> +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/i2c_dev_sysfs.h> + +#ifdef DEBUG + +#define PP_DEBUG(fmt, ...) do { \ + printk(KERN_DEBUG "%s:%d " fmt "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} while (0) + +#else /* !DEBUG */ + +#define PP_DEBUG(fmt, ...) + +#endif + +static ssize_t fancpld_fan_rpm_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int val; + + val = i2c_dev_read_byte(dev, attr); + if (val < 0) { + return val; + } + /* Multiply by 150 to get the RPM */ + val *= 150; + + return scnprintf(buf, PAGE_SIZE, "%u\n", val); +} + +#define FANTRAY_PWM_HELP \ + "each value represents 1/32 duty cycle" +#define FANTRAY_LED_CTRL_HELP \ + "0x0: Under HW control\n" \ + "0x1: Red off, Blue on\n" \ + "0x2: Red on, Blue off\n" \ + "0x3: Red off, Blue off" +#define FANTRAY_LED_BLINK_HELP \ + "0: no blink\n" \ + "1: blink" + +static const i2c_dev_attr_st fancpld_attr_table[] = { + { + "board_rev", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0, 0, 4, + }, + { + "model_id", + "0x0: wedge100\n" + "0x1: 6-pack100 linecard\n" + "0x2: 6-pack100 fabric card\n" + "0x3: reserved", + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0, 4, 2, + }, + { + "cpld_rev", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 1, 0, 6, + }, + { + "cpld_released", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 1, 6, 1, + }, + { + "cpld_sub_rev", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 2, 0, 8, + }, + { + "slotid", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 3, 0, 5, + }, + { + "jaybox_gpio", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 4, 0, 8, + }, + { + "jaybox_status", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 5, 0, 2, + }, + { + "fantray_failure", + "bit value 0: fan tray has failure\n" + "bit value 1: fan try is good and alive", + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 9, 0, 5, + }, + { + "fan1_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x10, 0, 8, + }, + { + "fan2_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x11, 0, 8, + }, + { + "fan3_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x12, 0, 8, + }, + { + "fan4_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x13, 0, 8, + }, + { + "fan5_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x14, 0, 8, + }, + { + "fan6_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x15, 0, 8, + }, + { + "fan7_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x16, 0, 8, + }, + { + "fan8_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x17, 0, 8, + }, + { + "fan9_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x18, 0, 8, + }, + { + "fan10_input", + NULL, + fancpld_fan_rpm_show, + NULL, + 0x19, 0, 8, + }, + { + "fantray_present", + "0: present\n" + "1: not present", + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0x1d, 0, 5, + }, + { + "fantray1_pwm", + FANTRAY_PWM_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x20, 0, 5, + }, + { + "fantray2_pwm", + FANTRAY_PWM_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x21, 0, 5, + }, + { + "fantray3_pwm", + FANTRAY_PWM_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x22, 0, 5, + }, + { + "fantray4_pwm", + FANTRAY_PWM_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x23, 0, 5, + }, + { + "fantray5_pwm", + FANTRAY_PWM_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x24, 0, 5, + }, + { + "fantray1_led_ctrl", + FANTRAY_LED_CTRL_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x25, 0, 2, + }, + { + "fantray1_led_blink", + FANTRAY_LED_BLINK_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x25, 2, 1, + }, + { + "fantray2_led_ctrl", + FANTRAY_LED_CTRL_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x25, 4, 2, + }, + { + "fantray2_led_blink", + FANTRAY_LED_BLINK_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x25, 6, 1, + }, + { + "fantray3_led_ctrl", + FANTRAY_LED_CTRL_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x26, 0, 2, + }, + { + "fantray3_led_blink", + FANTRAY_LED_BLINK_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x26, 2, 1, + }, + { + "fantray4_led_ctrl", + FANTRAY_LED_CTRL_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x26, 4, 2, + }, + { + "fantray4_led_blink", + FANTRAY_LED_BLINK_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x26, 6, 1, + }, + { + "fantray5_led_ctrl", + FANTRAY_LED_CTRL_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x27, 0, 2, + }, + { + "fantray5_led_blink", + FANTRAY_LED_BLINK_HELP, + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x27, 2, 1, + }, +}; + +static i2c_dev_data_st fancpld_data; + +/* + * FANCPLD i2c addresses. + * normal_i2c is used in I2C_CLIENT_INSMOD_1() + */ +static const unsigned short normal_i2c[] = { + 0x33, I2C_CLIENT_END +}; + +/* + * Insmod parameters + */ +I2C_CLIENT_INSMOD_1(fancpld); + +/* FANCPLD id */ +static const struct i2c_device_id fancpld_id[] = { + { "fancpld", fancpld }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, fancpld_id); + +/* Return 0 if detection is successful, -ENODEV otherwise */ +static int fancpld_detect(struct i2c_client *client, int kind, + struct i2c_board_info *info) +{ + /* + * We don't currently do any detection of the FANCPLD + */ + strlcpy(info->type, "fancpld", I2C_NAME_SIZE); + return 0; +} + +static int fancpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int n_attrs = sizeof(fancpld_attr_table) / sizeof(fancpld_attr_table[0]); + return i2c_dev_sysfs_data_init(client, &fancpld_data, + fancpld_attr_table, n_attrs); +} + +static int fancpld_remove(struct i2c_client *client) +{ + i2c_dev_sysfs_data_clean(client, &fancpld_data); + return 0; +} + +static struct i2c_driver fancpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "fancpld", + }, + .probe = fancpld_probe, + .remove = fancpld_remove, + .id_table = fancpld_id, + .detect = fancpld_detect, + /* addr_data is defined through I2C_CLIENT_INSMOD_1() */ + .address_data = &addr_data, +}; + +static int __init fancpld_mod_init(void) +{ + return i2c_add_driver(&fancpld_driver); +} + +static void __exit fancpld_mod_exit(void) +{ + i2c_del_driver(&fancpld_driver); +} + +MODULE_AUTHOR("Tian Fang <tfang@fb.com>"); +MODULE_DESCRIPTION("FANCPLD Driver"); +MODULE_LICENSE("GPL"); + +module_init(fancpld_mod_init); +module_exit(fancpld_mod_exit); diff --git a/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/syscpld.c b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/syscpld.c new file mode 100644 index 0000000..1f5abeb --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/files/syscpld.c @@ -0,0 +1,281 @@ +/* + * syscpld.c - The i2c driver for SYSCPLD + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +//#define DEBUG + +#include <linux/errno.h> +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/i2c_dev_sysfs.h> + +#ifdef DEBUG + +#define PP_DEBUG(fmt, ...) do { \ + printk(KERN_DEBUG "%s:%d " fmt "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} while (0) + +#else /* !DEBUG */ + +#define PP_DEBUG(fmt, ...) + +#endif + +static const i2c_dev_attr_st syscpld_attr_table[] = { + { + "board_rev", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0, 0, 4, + }, + { + "model_id", + "0x0: wedge100\n" + "0x1: 6-pack100 linecard\n" + "0x2: 6-pack100 fabric card\n" + "0x3: reserved", + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0, 4, 2, + }, + { + "cpld_rev", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 1, 0, 6, + }, + { + "cpld_released", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 1, 6, 1, + }, + { + "cpld_sub_rev", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 2, 0, 8, + }, + { + "slotid", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 3, 0, 5, + }, + { + "psu1_present", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 8, 0, 1, + }, + { + "psu2_present", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 8, 1, 1, + }, + { + "fan_rackmon_present", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 8, 2, 1, + }, + { + "micro_srv_present", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 8, 3, 1, + }, + { + "th_rov", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0xb, 0, 4, + }, + { + "vcore_idsel", + NULL, + I2C_DEV_ATTR_SHOW_DEFAULT, + NULL, + 0xb, 4, 3, + }, + { + "uart_mux", + "0x0: UART_SELECT_BMC\n0x1: UART_SELECT_DBG\n" + "0x2: Force to select 0\n0x3: Force to select 1\n\n" + "UART_SEL\n" + "1: micro-server console connected to BMC\n" + "0: micro-server console connected to debug header", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x26, 0, 2, + }, + { + "heart_attach_en", + "0: no fan tray fatal error attack\n" + "1: fan-tray fatal error attack mode enabled", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x2e, 7, 1, + }, + { + "dual_boot_en", + "0: single boot\n" + "1: dual boot", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x2f, 0, 1, + }, + { + "2nd_flash_wp", + "0: writeable\n" + "1: write protected", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x2f, 1, 1, + }, + { + "pwr_cyc_all_n", + "0: power cycle all power\n" + "1: normal", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x30, 0, 1, + }, + { + "pwr_main_n", + "0: main power is off\n" + "1: main power is enabled", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x30, 1, 1, + }, + { + "pwr_usrv_en", + "0: micro-server power is off\n" + "1: micro-server power is on", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x30, 2, 1, + }, + { + "pwr_usrv_btn_en", + "0: micro-server power button is off\n" + "1: micro-server power button is on", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x30, 3, 1, + }, + { + "usrv_rst_n", + "0: write 0 to trigger micro-server reset" + "1: normal", + I2C_DEV_ATTR_SHOW_DEFAULT, + I2C_DEV_ATTR_STORE_DEFAULT, + 0x32, 0, 1, + }, +}; + +static i2c_dev_data_st syscpld_data; + +/* + * SYSCPLD i2c addresses. + * normal_i2c is used in I2C_CLIENT_INSMOD_1() + */ +static const unsigned short normal_i2c[] = { + 0x31, I2C_CLIENT_END +}; + +/* + * Insmod parameters + */ +I2C_CLIENT_INSMOD_1(syscpld); + +/* SYSCPLD id */ +static const struct i2c_device_id syscpld_id[] = { + { "syscpld", syscpld }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, syscpld_id); + +/* Return 0 if detection is successful, -ENODEV otherwise */ +static int syscpld_detect(struct i2c_client *client, int kind, + struct i2c_board_info *info) +{ + /* + * We don't currently do any detection of the SYSCPLD + */ + strlcpy(info->type, "syscpld", I2C_NAME_SIZE); + return 0; +} + +static int syscpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int n_attrs = sizeof(syscpld_attr_table) / sizeof(syscpld_attr_table[0]); + return i2c_dev_sysfs_data_init(client, &syscpld_data, + syscpld_attr_table, n_attrs); +} + +static int syscpld_remove(struct i2c_client *client) +{ + i2c_dev_sysfs_data_clean(client, &syscpld_data); + return 0; +} + +static struct i2c_driver syscpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "syscpld", + }, + .probe = syscpld_probe, + .remove = syscpld_remove, + .id_table = syscpld_id, + .detect = syscpld_detect, + /* addr_data is defined through I2C_CLIENT_INSMOD_1() */ + .address_data = &addr_data, +}; + +static int __init syscpld_mod_init(void) +{ + return i2c_add_driver(&syscpld_driver); +} + +static void __exit syscpld_mod_exit(void) +{ + i2c_del_driver(&syscpld_driver); +} + +MODULE_AUTHOR("Tian Fang <tfang@fb.com>"); +MODULE_DESCRIPTION("SYSCPLD Driver"); +MODULE_LICENSE("GPL"); + +module_init(syscpld_mod_init); +module_exit(syscpld_mod_exit); diff --git a/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/kernel-module-cpld_0.1.bb b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/kernel-module-cpld_0.1.bb new file mode 100644 index 0000000..dd0b6c6 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/cpld-mod/kernel-module-cpld_0.1.bb @@ -0,0 +1,42 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +SUMMARY = "Wedge100 CPLD drivers" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" + +inherit module + +PR = "r0" +PV = "0.1" + +SRC_URI = "file://Makefile \ + file://syscpld.c \ + file://fancpld.c \ + file://COPYING \ + " + +S = "${WORKDIR}" + +DEPENDS += "kernel-module-i2c-dev-sysfs" + +RDEPENDS_${PN} += "kernel-module-i2c-dev-sysfs" + +KERNEL_MODULE_AUTOLOAD += " \ + syscpld \ + fancpld \ +" diff --git a/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/COPYING b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/COPYING new file mode 100644 index 0000000..6d45519 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/Makefile b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/Makefile new file mode 100644 index 0000000..4be7b62 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/Makefile @@ -0,0 +1,31 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +obj-m := i2c_dev_sysfs.o + +SRC := $(shell pwd) + +all: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install + +clean: + rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c + rm -f Module.markers Module.symvers modules.order + rm -rf .tmp_versions Modules.symvers diff --git a/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.c b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.c new file mode 100644 index 0000000..96c1b98 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.c @@ -0,0 +1,349 @@ +/* + * i2c_dev_sysfs.c - The i2c device sysfs library + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +//#define DEBUG + +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/i2c.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/sysfs.h> + +#include "i2c_dev_sysfs.h" + +#ifdef DEBUG + +#define PP_DEBUG(fmt, ...) do { \ + printk(KERN_DEBUG "%s:%d " fmt "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} while (0) + +#else /* !DEBUG */ + +#define PP_DEBUG(fmt, ...) + +#endif + +ssize_t i2c_dev_show_label(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + i2c_sysfs_attr_st *i2c_attr = TO_I2C_SYSFS_ATTR(attr); + const i2c_dev_attr_st *dev_attr = i2c_attr->isa_i2c_attr; + + if (dev_attr->ida_help) { + return sprintf(buf, "%s\n", dev_attr->ida_help); + } + return sprintf(buf, "%s\n", dev_attr->ida_name); +} +EXPORT_SYMBOL_GPL(i2c_dev_show_label); + +int i2c_dev_read_byte(struct device *dev, + struct device_attribute *attr) +{ + struct i2c_client *client = to_i2c_client(dev); + i2c_dev_data_st *data = i2c_get_clientdata(client); + i2c_sysfs_attr_st *i2c_attr = TO_I2C_SYSFS_ATTR(attr); + const i2c_dev_attr_st *dev_attr = i2c_attr->isa_i2c_attr; + int val; + int val_mask; + + val_mask = ~(((-1) >> (dev_attr->ida_n_bits)) << (dev_attr->ida_n_bits)); + + mutex_lock(&data->idd_lock); + + val = i2c_smbus_read_byte_data(client, dev_attr->ida_reg); + + mutex_unlock(&data->idd_lock); + + if (val < 0) { + /* error case */ + return val; + } + + val = (val >> dev_attr->ida_bit_offset) & val_mask; + return val; +} +EXPORT_SYMBOL_GPL(i2c_dev_read_byte); + +int i2c_dev_read_nbytes(struct device *dev, + struct device_attribute *attr, + uint8_t values[], + int nbytes) +{ + struct i2c_client *client = to_i2c_client(dev); + i2c_dev_data_st *data = i2c_get_clientdata(client); + i2c_sysfs_attr_st *i2c_attr = TO_I2C_SYSFS_ATTR(attr); + const i2c_dev_attr_st *dev_attr = i2c_attr->isa_i2c_attr; + int i; + + mutex_lock(&data->idd_lock); + for (i = 0; i < nbytes; ++i) { + values[i] = i2c_smbus_read_byte_data(client, dev_attr->ida_reg + i); + if (values[i] < 0) { + mutex_unlock(&data->idd_lock); + return values[i]; + } + } + mutex_unlock(&data->idd_lock); + return nbytes; +} +EXPORT_SYMBOL_GPL(i2c_dev_read_nbytes); + +int i2c_dev_read_word_littleendian(struct device *dev, + struct device_attribute *attr) +{ + uint8_t values[2]; + int ret_val; + + ret_val = i2c_dev_read_nbytes(dev, attr, values, 2); + if (ret_val < 0) { + return ret_val; + } + // values[0] : LSB + // values[1] : MSB + return ((values[1]<<8) + values[0]); +} +EXPORT_SYMBOL_GPL(i2c_dev_read_word_littleendian); + +int i2c_dev_read_word_bigendian(struct device *dev, + struct device_attribute *attr) +{ + uint8_t values[2]; + int ret_val; + + ret_val = i2c_dev_read_nbytes(dev, attr, values, 2); + if (ret_val < 0) { + return ret_val; + } + // values[0] : MSB + // values[1] : LSB + return ((values[0]<<8) + values[1]); +} +EXPORT_SYMBOL_GPL(i2c_dev_read_word_bigendian); + +ssize_t i2c_dev_show_ascii(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + i2c_sysfs_attr_st *i2c_attr = TO_I2C_SYSFS_ATTR(attr); + const i2c_dev_attr_st *dev_attr = i2c_attr->isa_i2c_attr; + int nbytes, ret_val; + + nbytes = (dev_attr->ida_n_bits) / 8; + ret_val = i2c_dev_read_nbytes(dev, attr, buf, nbytes); + if (ret_val < 0) { + return ret_val; + } + //buf[] : ascii data + buf[nbytes] = '\n'; + return (nbytes + 1); +} +EXPORT_SYMBOL_GPL(i2c_dev_show_ascii); + +static ssize_t i2c_dev_sysfs_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + i2c_dev_data_st *data = i2c_get_clientdata(client); + i2c_sysfs_attr_st *i2c_attr = TO_I2C_SYSFS_ATTR(attr); + const i2c_dev_attr_st *dev_attr = i2c_attr->isa_i2c_attr; + int val; + int val_mask; + + if (!dev_attr->ida_show) { + return -EOPNOTSUPP; + } + + if (dev_attr->ida_show != I2C_DEV_ATTR_SHOW_DEFAULT) { + return dev_attr->ida_show(dev, attr, buf); + } + + val_mask = ~(((-1) >> (dev_attr->ida_n_bits)) << (dev_attr->ida_n_bits)); + + mutex_lock(&data->idd_lock); + + /* default handling */ + val = i2c_smbus_read_byte_data(client, dev_attr->ida_reg); + + mutex_unlock(&data->idd_lock); + + if (val < 0) { + /* error case */ + return val; + } + + val = (val >> dev_attr->ida_bit_offset) & val_mask; + + return scnprintf(buf, PAGE_SIZE, "0x%x%s%s\n", val, + (dev_attr->ida_help) ? "\n\nNote:\n" : "", + (dev_attr->ida_help) ? dev_attr->ida_help : ""); +} + +static ssize_t i2c_dev_sysfs_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + i2c_dev_data_st *data = i2c_get_clientdata(client); + i2c_sysfs_attr_st *i2c_attr = TO_I2C_SYSFS_ATTR(attr); + const i2c_dev_attr_st *dev_attr = i2c_attr->isa_i2c_attr; + int val; + int req_val; + int req_val_mask; + + if (!dev_attr->ida_store) { + return -EOPNOTSUPP; + } + + if (dev_attr->ida_store != I2C_DEV_ATTR_STORE_DEFAULT) { + return dev_attr->ida_store(dev, attr, buf, count); + } + + /* parse the buffer */ + if (sscanf(buf, "%i", &req_val) <= 0) { + return -EINVAL; + } + req_val_mask = ~(((-1) >> (dev_attr->ida_n_bits)) << (dev_attr->ida_n_bits)); + req_val &= req_val_mask; + + mutex_lock(&data->idd_lock); + + /* default handling, first read back the current value */ + val = i2c_smbus_read_byte_data(client, dev_attr->ida_reg); + + if (val < 0) { + /* fail to read */ + goto unlock_out; + } + + /* mask out all bits for the value requested */ + val &= ~(req_val_mask << dev_attr->ida_bit_offset); + val |= req_val << dev_attr->ida_bit_offset; + + val = i2c_smbus_write_byte_data(client, dev_attr->ida_reg, val); + + unlock_out: + mutex_unlock(&data->idd_lock); + + if (val < 0) { + /* error case */ + return val; + } + + return count; +} + +void i2c_dev_sysfs_data_clean(struct i2c_client *client, i2c_dev_data_st *data) +{ + if (!data) { + return; + } + if (data->idd_hwmon_dev) { + hwmon_device_unregister(data->idd_hwmon_dev); + } + if (data->idd_attr_group.attrs) { + sysfs_remove_group(&client->dev.kobj, &data->idd_attr_group); + kfree(data->idd_attr_group.attrs); + } + if (data->idd_attrs) { + kfree(data->idd_attrs); + } + memset(data, 0, sizeof(*data)); +} +EXPORT_SYMBOL_GPL(i2c_dev_sysfs_data_clean); + +int i2c_dev_sysfs_data_init(struct i2c_client *client, + i2c_dev_data_st *data, + const i2c_dev_attr_st *dev_attrs, + int n_attrs) +{ + int i; + int err; + i2c_sysfs_attr_st *cur_attr; + const i2c_dev_attr_st *cur_dev_attr; + struct attribute **cur_grp_attr; + + memset(data, 0, sizeof(*data)); + + i2c_set_clientdata(client, data); + mutex_init(&data->idd_lock); + + /* allocate all attribute */ + data->idd_attrs = kzalloc(sizeof(*data->idd_attrs) * n_attrs, GFP_KERNEL); + /* allocate the attribute group. +1 for the last NULL */ + data->idd_attr_group.attrs + = kzalloc(sizeof(*data->idd_attr_group.attrs) * (n_attrs + 1), GFP_KERNEL); + if (!data->idd_attrs || !data->idd_attr_group.attrs) { + err = -ENOMEM; + goto exit_cleanup; + } + PP_DEBUG("Allocated %u attributes", n_attrs); + + for (i = 0, + cur_attr = &data->idd_attrs[0], + cur_grp_attr = &data->idd_attr_group.attrs[0], + cur_dev_attr = dev_attrs; + i < n_attrs; + i++, cur_attr++, cur_grp_attr++, cur_dev_attr++) { + + mode_t mode = S_IRUGO; + if (cur_dev_attr->ida_store) { + mode |= S_IWUSR; + } + cur_attr->isa_dev_attr.attr.name = cur_dev_attr->ida_name; + cur_attr->isa_dev_attr.attr.mode = mode; + cur_attr->isa_dev_attr.show = i2c_dev_sysfs_show; + cur_attr->isa_dev_attr.store = i2c_dev_sysfs_store; + *cur_grp_attr = &cur_attr->isa_dev_attr.attr; + cur_attr->isa_i2c_attr = cur_dev_attr; + PP_DEBUG("Created attribute \"%s\"", cur_attr->isa_dev_attr.attr.name); + } + + /* Register sysfs hooks */ + if ((err = sysfs_create_group(&client->dev.kobj, &data->idd_attr_group))) { + goto exit_cleanup; + } + + data->idd_hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->idd_hwmon_dev)) { + err = PTR_ERR(data->idd_hwmon_dev); + data->idd_hwmon_dev = NULL; + goto exit_cleanup; + } + + PP_DEBUG("i2c device sysfs init data done"); + + return 0; + + exit_cleanup: + i2c_dev_sysfs_data_clean(client, data); + return err; +} +EXPORT_SYMBOL_GPL(i2c_dev_sysfs_data_init); + + +MODULE_AUTHOR("Tian Fang <tfang@fb.com>"); +MODULE_DESCRIPTION("i2c device sysfs attribute library"); +MODULE_LICENSE("GPL"); diff --git a/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.h b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.h new file mode 100644 index 0000000..47862cc --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.h @@ -0,0 +1,84 @@ +/* + * i2c_dev_sysfs.h - The i2c device sysfs library header + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef I2C_DEV_SYSFS_H +#define I2C_DEV_SYSFS_H + +#include <linux/device.h> +#include <linux/types.h> + +typedef ssize_t (*i2c_dev_attr_show_fn)(struct device *dev, + struct device_attribute *attr, + char *buf); +typedef ssize_t (*i2c_dev_attr_store_fn)(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count); + +#define I2C_DEV_ATTR_SHOW_DEFAULT (i2c_dev_attr_show_fn)(1) +#define I2C_DEV_ATTR_STORE_DEFAULT (i2c_dev_attr_store_fn)(1) + +typedef struct i2c_dev_attr_st_ { + const char *ida_name; + const char *ida_help; + i2c_dev_attr_show_fn ida_show; + i2c_dev_attr_store_fn ida_store; + int ida_reg; + int ida_bit_offset; + int ida_n_bits; +} i2c_dev_attr_st; + +typedef struct i2c_sysfs_attr_st_{ + struct device_attribute isa_dev_attr; + const i2c_dev_attr_st *isa_i2c_attr; +} i2c_sysfs_attr_st; + +#define TO_I2C_SYSFS_ATTR(_attr) \ + container_of(_attr, i2c_sysfs_attr_st, isa_dev_attr) + +typedef struct i2c_dev_data_st_ { + struct device *idd_hwmon_dev; + struct mutex idd_lock; + i2c_sysfs_attr_st *idd_attrs; + struct attribute_group idd_attr_group; +} i2c_dev_data_st; + +int i2c_dev_sysfs_data_init(struct i2c_client *client, + i2c_dev_data_st *data, + const i2c_dev_attr_st *dev_attrs, + int n_attrs); +void i2c_dev_sysfs_data_clean(struct i2c_client *client, i2c_dev_data_st *data); +int i2c_dev_read_byte(struct device *dev, + struct device_attribute *attr); +int i2c_dev_read_nbytes(struct device *dev, + struct device_attribute *attr, + uint8_t values[], + int nbytes); +int i2c_dev_read_word_littleendian(struct device *dev, + struct device_attribute *attr); +int i2c_dev_read_word_bigendian(struct device *dev, + struct device_attribute *attr); +ssize_t i2c_dev_show_label(struct device *dev, + struct device_attribute *attr, + char *buf); +ssize_t i2c_dev_show_ascii(struct device *dev, + struct device_attribute *attr, + char *buf); + +#endif diff --git a/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/kernel-module-i2c-dev-sysfs_0.1.bb b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/kernel-module-i2c-dev-sysfs_0.1.bb new file mode 100644 index 0000000..8e42144 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/i2c-dev-sysfs-mod/kernel-module-i2c-dev-sysfs_0.1.bb @@ -0,0 +1,42 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +SUMMARY = "Wedge100 i2c device library" +DESCRIPTION = "i2c device sysfs attribute library" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" + +inherit module + +PR = "r0" +PV = "0.1" + +SRC_URI = "file://Makefile \ + file://i2c_dev_sysfs.c \ + file://i2c_dev_sysfs.h \ + file://COPYING \ + " + +S = "${WORKDIR}" + +do_install_append() { + kerneldir=${STAGING_KERNEL_DIR}/include/linux + install -d ${kerneldir} + install -m 0644 i2c_dev_sysfs.h ${kerneldir}/ +} + +FILES_${PN}-dev = "${kerneldir}/i2c_dev_sysfs.h" diff --git a/meta-facebook/meta-wedge100/recipes-kernel/linux/files/defconfig b/meta-facebook/meta-wedge100/recipes-kernel/linux/files/defconfig new file mode 100644 index 0000000..0f9f0f7 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/linux/files/defconfig @@ -0,0 +1,1462 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.28.9 +# Wed Aug 5 18:43:53 2015 +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_TIME=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_MMU=y +# CONFIG_NO_IOPORT is not set +CONFIG_GENERIC_HARDIRQS=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_HAVE_LATENCYTOP_SUPPORT=y +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_ARCH_HAS_ILOG2_U32 is not set +# CONFIG_ARCH_HAS_ILOG2_U64 is not set +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y +CONFIG_VECTORS_BASE=0xffff0000 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set +CONFIG_IKCONFIG=m +CONFIG_IKCONFIG_PROC=y +CONFIG_LOG_BUF_SHIFT=16 +# CONFIG_CGROUPS is not set +# CONFIG_GROUP_SCHED is not set +CONFIG_SYSFS_DEPRECATED=y +CONFIG_SYSFS_DEPRECATED_V2=y +# CONFIG_RELAY is not set +CONFIG_NAMESPACES=y +# CONFIG_UTS_NS is not set +# CONFIG_IPC_NS is not set +# CONFIG_USER_NS is not set +# CONFIG_PID_NS is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +# CONFIG_EMBEDDED is not set +CONFIG_UID16=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_EXTRA_PASS=y +CONFIG_HOTPLUG=y +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +CONFIG_COMPAT_BRK=y +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +# CONFIG_PROFILING is not set +# CONFIG_MARKERS is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_KMOD=y +CONFIG_BLOCK=y +# CONFIG_LBD is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_LSF is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_INTEGRITY is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_DEFAULT_AS is not set +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_CLASSIC_RCU=y +CONFIG_FREEZER=y + +# +# System Type +# +CONFIG_ARCH_ASPEED=y +# CONFIG_ARCH_AAEC2000 is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_CLPS7500 is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_EBSA110 is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_FOOTBRIDGE is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X is not set +# CONFIG_ARCH_IMX is not set +# CONFIG_ARCH_IOP13XX is not set +# CONFIG_ARCH_IOP32X is not set +# CONFIG_ARCH_IOP33X is not set +# CONFIG_ARCH_IXP23XX is not set +# CONFIG_ARCH_IXP2000 is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_L7200 is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_KS8695 is not set +# CONFIG_ARCH_NS9XXX is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_MV78XX0 is not set +# CONFIG_ARCH_MXC is not set +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_S3C2410 is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_LH7A40X is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_MSM is not set +CONFIG_IRMP=y +# CONFIG_PCEXT is not set +# CONFIG_REMOTEFX is not set +# CONFIG_ARCH_AST1100 is not set +# CONFIG_ARCH_AST2100 is not set +# CONFIG_ARCH_AST2200 is not set +# CONFIG_ARCH_AST2300 is not set +CONFIG_ARCH_AST2400=y +# CONFIG_ARCH_AST2500 is not set + +# +# FLASH Chip Select +# +# CONFIG_AST_CS0_NOR is not set +# CONFIG_AST_CS0_NAND is not set +CONFIG_AST_CS0_SPI=y +# CONFIG_AST_CS0_NONE is not set +# CONFIG_AST_CS1_NOR is not set +# CONFIG_AST_CS1_NAND is not set +# CONFIG_AST_CS1_SPI is not set +CONFIG_AST_CS1_NONE=y +# CONFIG_AST_CS2_NOR is not set +# CONFIG_AST_CS2_NAND is not set +# CONFIG_AST_CS2_SPI is not set +CONFIG_AST_CS2_NONE=y +# CONFIG_AST_CS3_NOR is not set +# CONFIG_AST_CS3_NAND is not set +# CONFIG_AST_CS3_SPI is not set +CONFIG_AST_CS3_NONE=y +# CONFIG_AST_CS4_NOR is not set +# CONFIG_AST_CS4_NAND is not set +# CONFIG_AST_CS4_SPI is not set +CONFIG_AST_CS4_NONE=y +# CONFIG_ARCH_AST1070 is not set +# CONFIG_AST_SCU_LOCK is not set +# CONFIG_WEDGE is not set +CONFIG_WEDGE100=y +# CONFIG_YOSEMITE is not set + +# +# Boot options +# + +# +# Power management +# +CONFIG_PLAT_ASPEED=y + +# +# Processor Type +# +CONFIG_CPU_32=y +CONFIG_CPU_ARM926T=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_PABRT_NOIFAR=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y + +# +# Processor Features +# +CONFIG_ARM_THUMB=y +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +# CONFIG_OUTER_CACHE is not set + +# +# Bus support +# +CONFIG_ARM_AMBA=y +# CONFIG_PCI_SYSCALL is not set +# CONFIG_ARCH_SUPPORTS_MSI is not set +# CONFIG_PCCARD is not set + +# +# Kernel Features +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set +CONFIG_PAGE_OFFSET=0xC0000000 +# CONFIG_PREEMPT is not set +CONFIG_HZ=100 +CONFIG_AEABI=y +CONFIG_OABI_COMPAT=y +CONFIG_ARCH_FLATMEM_HAS_HOLES=y +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4096 +# CONFIG_RESOURCES_64BIT is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=0 +CONFIG_VIRT_TO_BUS=y +CONFIG_UNEVICTABLE_LRU=y +CONFIG_ALIGNMENT_TRAP=y + +# +# Boot options +# +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_CMDLINE="" +# CONFIG_XIP_KERNEL is not set +# CONFIG_KEXEC is not set + +# +# CPU Power Management +# +# CONFIG_CPU_IDLE is not set + +# +# Floating point emulation +# + +# +# At least one emulation must be selected +# +CONFIG_FPE_NWFPE=y +CONFIG_FPE_NWFPE_XP=y +# CONFIG_FPE_FASTFPE is not set +CONFIG_VFP=y + +# +# Userspace binary formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_HAVE_AOUT=y +CONFIG_BINFMT_AOUT=y +# CONFIG_BINFMT_MISC is not set + +# +# Power management options +# +CONFIG_PM=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_SLEEP=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_APM_EMULATION is not set +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +# CONFIG_XFRM_USER is not set +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_XFRM_MODE_TRANSPORT=y +CONFIG_INET_XFRM_MODE_TUNNEL=y +CONFIG_INET_XFRM_MODE_BEET=y +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_TCP_MD5SIG is not set +CONFIG_IPV6=m +# CONFIG_IPV6_PRIVACY is not set +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_XFRM_MODE_TRANSPORT=m +CONFIG_INET6_XFRM_MODE_TUNNEL=m +CONFIG_INET6_XFRM_MODE_BEET=m +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +CONFIG_IPV6_SIT=m +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_NET_DSA is not set +CONFIG_VLAN_8021Q=m +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=y +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_PHONET is not set +# CONFIG_WIRELESS is not set +# CONFIG_RFKILL is not set +# CONFIG_NET_9P is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_SYS_HYPERVISOR is not set +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +CONFIG_MTD=y +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y +# CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y +# CONFIG_MTD_AFS_PARTS is not set +# CONFIG_MTD_AR7_PARTS is not set + +# +# User Modules And Translation Layers +# +CONFIG_MTD_CHAR=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_FTL is not set +# CONFIG_NFTL is not set +# CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set +# CONFIG_SSFDC is not set +# CONFIG_MTD_OOPS is not set + +# +# RAM/ROM/Flash chip drivers +# +# CONFIG_MTD_CFI is not set +# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +CONFIG_MTD_MAP_BANK_WIDTH_2=y +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_ROM is not set +# CONFIG_MTD_ABSENT is not set + +# +# Mapping drivers for chip access +# +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PLATRAM is not set + +# +# Self-contained MTD device drivers +# +CONFIG_MTD_DATAFLASH=m +CONFIG_MTD_DATAFLASH_WRITE_VERIFY=y +# CONFIG_MTD_DATAFLASH_OTP is not set +CONFIG_MTD_M25P80=y +CONFIG_M25PXX_USE_FAST_READ=y +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLOCK2MTD is not set + +# +# Disk-On-Chip Device Drivers +# +# CONFIG_MTD_DOC2000 is not set +# CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set +# CONFIG_MTD_NAND is not set +# CONFIG_MTD_ONENAND is not set + +# +# UBI - Unsorted block images +# +# CONFIG_MTD_UBI is not set +# CONFIG_PARPORT is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=y +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_BLK_DEV_XIP is not set +# CONFIG_RD_BZIP2 is not set +CONFIG_RD_LZMA=y +CONFIG_RD_GZIP=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_MISC_DEVICES=y +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_C2PORT is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_TGT=y +# CONFIG_SCSI_NETLINK is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set +CONFIG_SCSI_SCAN_ASYNC=y +CONFIG_SCSI_WAIT_SCAN=m + +# +# SCSI Transports +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_DH is not set +# CONFIG_ATA is not set +# CONFIG_MD is not set +CONFIG_NETDEVICES=y +# CONFIG_DUMMY is not set +CONFIG_BONDING=m +# CONFIG_MACVLAN is not set +# CONFIG_EQUALIZER is not set +CONFIG_TUN=m +# CONFIG_VETH is not set +# CONFIG_NET_ETHERNET is not set +CONFIG_NETDEV_1000=y +CONFIG_ASPEEDMAC=y +# CONFIG_NETDEV_10000 is not set + +# +# Wireless LAN +# +# CONFIG_WLAN_PRE80211 is not set +# CONFIG_WLAN_80211 is not set +# CONFIG_IWLWIFI_LEDS is not set + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_ISDN is not set + +# +# Input device support +# +CONFIG_INPUT=y +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_GPIO is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_ELANTECH is not set +# CONFIG_MOUSE_PS2_TOUCHKIT is not set +CONFIG_MOUSE_SERIAL=y +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_AMBAKMI is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_VT_HW_CONSOLE_BINDING is not set +CONFIG_DEVKMEM=y +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_N_HDLC is not set +# CONFIG_RISCOM8 is not set +# CONFIG_SPECIALIX is not set +# CONFIG_RIO is not set +# CONFIG_STALDRV is not set + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=4 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 +# CONFIG_SERIAL_AST_DMA_UART is not set +# CONFIG_SERIAL_8250_EXTENDED is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_AMBA_PL010 is not set +# CONFIG_SERIAL_AMBA_PL011 is not set +# CONFIG_SERIAL_AST is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +# CONFIG_IPMI_HANDLER is not set +CONFIG_AST_MISC=y +# CONFIG_AST_VIDEO is not set +# CONFIG_ADC_CAT9883 is not set +# CONFIG_AST_SPI_BIOS is not set +CONFIG_AST_PECI=y +# CONFIG_AST_KCS is not set +# CONFIG_AST_GPIO is not set +# CONFIG_HW_RANDOM is not set +CONFIG_NVRAM=y +# CONFIG_R3964 is not set +# CONFIG_RAW_DRIVER is not set +# CONFIG_TCG_TPM is not set +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_HELPER_AUTO=y + +# +# I2C Hardware Bus support +# + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +CONFIG_I2C_AST=y +CONFIG_AST_I2C_SLAVE_MODE=y +CONFIG_AST_I2C_SLAVE_EEPROM=y +# CONFIG_AST_I2C_SLAVE_RDWR is not set +# CONFIG_I2C_SIMTEC is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_STUB is not set + +# +# Miscellaneous I2C Chip support +# +# CONFIG_DS1682 is not set +CONFIG_AT24=m +# CONFIG_SENSORS_EEPROM is not set +CONFIG_SENSORS_PCF8574=m +# CONFIG_PCF8575 is not set +# CONFIG_SENSORS_PCA9539 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_TPS65010 is not set +# CONFIG_SENSORS_MAX6875 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +CONFIG_SPI_AST=y +CONFIG_SPI_FMC=y +CONFIG_SPI_BITBANG=y + +# +# SPI Protocol Masters +# +CONFIG_SPI_AT25=m +CONFIG_SPI_SPIDEV=m +# CONFIG_SPI_TLE62X0 is not set +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO expanders: +# + +# +# I2C GPIO expanders: +# +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set + +# +# PCI GPIO expanders: +# + +# +# SPI GPIO expanders: +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MCP23S08 is not set +# CONFIG_W1 is not set +# CONFIG_POWER_SUPPLY is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7473 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +CONFIG_SENSORS_LM75=m +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +CONFIG_SENSORS_MAX127=m +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +CONFIG_SENSORS_ADS7828=m +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +CONFIG_SENSORS_AST_ADC=m +# CONFIG_SENSORS_AST_PWM_FAN is not set +CONFIG_SENSORS_FB_PANTHER_PLUS=m +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_SENSORS_ADM1275=m +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX8688 is not set +CONFIG_SENSORS_PFE1100=m +CONFIG_SENSORS_PFE3000=m +# CONFIG_SENSORS_UCD9000 is not set +# CONFIG_SENSORS_UCD9200 is not set +# CONFIG_SENSORS_ZL6100 is not set +# CONFIG_HWMON_DEBUG_CHIP is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +CONFIG_AST_WATCHDOG=y +CONFIG_AST_WATCHDOG_REARM_DUAL_BOOT=y + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_ASIC3 is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_TC6393XB is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM8350_I2C is not set + +# +# Multimedia devices +# + +# +# Multimedia core support +# +# CONFIG_VIDEO_DEV is not set +# CONFIG_DVB_CORE is not set +# CONFIG_VIDEO_MEDIA is not set + +# +# Multimedia drivers +# +# CONFIG_DAB is not set + +# +# Graphics support +# +# CONFIG_VGASTATE is not set +# CONFIG_VIDEO_OUTPUT_CONTROL is not set +# CONFIG_FB is not set +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set + +# +# Display device support +# +# CONFIG_DISPLAY_SUPPORT is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y +# CONFIG_SOUND is not set +# CONFIG_HID_SUPPORT is not set +CONFIG_USB_SUPPORT=y +CONFIG_USB_ARCH_HAS_HCD=y +# CONFIG_USB_ARCH_HAS_OHCI is not set +CONFIG_USB_ARCH_HAS_EHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_SUSPEND is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_EHCI_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HWA_HCD is not set + +# +# AST USB Drivers +# +CONFIG_AST_USB_UHCI_HCD=m +# CONFIG_AST_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_AST_USB_UHCI_MULTIPORT_2 is not set +CONFIG_AST_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_GADGET_MUSB_HDRC is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; +# + +# +# see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +# CONFIG_USB_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_LIBUSUAL is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB port drivers +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_BERRY_CHARGE is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_PHIDGET is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_VST is not set +CONFIG_USB_GADGET=y +# CONFIG_USB_GADGET_DEBUG_FILES is not set +CONFIG_USB_GADGET_VBUS_DRAW=2 +CONFIG_USB_GADGET_SELECTED=y +# CONFIG_USB_GADGET_AT91 is not set +# CONFIG_USB_GADGET_ATMEL_USBA is not set +# CONFIG_USB_GADGET_FSL_USB2 is not set +# CONFIG_USB_GADGET_LH7A40X is not set +# CONFIG_USB_GADGET_OMAP is not set +# CONFIG_USB_GADGET_PXA25X is not set +# CONFIG_USB_GADGET_PXA27X is not set +# CONFIG_USB_GADGET_S3C2410 is not set +# CONFIG_USB_GADGET_M66592 is not set +# CONFIG_USB_GADGET_AMD5536UDC is not set +# CONFIG_USB_GADGET_FSL_QE is not set +# CONFIG_USB_GADGET_NET2280 is not set +# CONFIG_USB_GADGET_GOKU is not set +CONFIG_USB_GADGET_ASPEED_AST=y +CONFIG_USB_ASPEED_AST=y +# CONFIG_USB_GADGET_DUMMY_HCD is not set +CONFIG_USB_GADGET_DUALSPEED=y +CONFIG_USB_ZERO=m +CONFIG_USB_ETH=m +CONFIG_USB_ETH_RNDIS=y +CONFIG_USB_GADGETFS=m +CONFIG_USB_FILE_STORAGE=m +# CONFIG_USB_FILE_STORAGE_TEST is not set +CONFIG_USB_G_SERIAL=m +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_G_PRINTER is not set +CONFIG_USB_CDC_COMPOSITE=m +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_NEW_LEDS is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_HCTOSYS is not set +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8581 is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_DS3234 is not set + +# +# Platform RTC drivers +# +# CONFIG_RTC_DRV_CMOS is not set +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_V3020 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PL030 is not set +# CONFIG_RTC_DRV_PL031 is not set +CONFIG_RTC_DRV_ASPEED=y +# CONFIG_DMADEVICES is not set +# CONFIG_REGULATOR is not set +# CONFIG_UIO is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_EXT4_FS is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_FILE_LOCKING=y +# CONFIG_XFS_FS is not set +# CONFIG_OCFS2_FS is not set +CONFIG_DNOTIFY=y +CONFIG_INOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set +CONFIG_GENERIC_ACL=y + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NTFS_FS=y +# CONFIG_NTFS_DEBUG is not set +CONFIG_NTFS_RW=y + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_CONFIGFS_FS=m + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +# CONFIG_JFFS2_SUMMARY is not set +# CONFIG_JFFS2_FS_XATTR is not set +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set +CONFIG_JFFS2_ZLIB=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set +# CONFIG_NFS_V4 is not set +CONFIG_ROOT_NFS=y +# CONFIG_NFSD is not set +CONFIG_LOCKD=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_SUNRPC_REGISTER_V4 is not set +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +CONFIG_NLS_UTF8=y +# CONFIG_DLM is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_KERNEL is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_FRAME_POINTER=y +# CONFIG_RCU_CPU_STALL_DETECTOR is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_SYSCTL_SYSCALL_CHECK is not set +CONFIG_HAVE_FUNCTION_TRACER=y + +# +# Tracers +# +# CONFIG_DYNAMIC_PRINTK_DEBUG is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_DEBUG_USER is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_FILE_CAPABILITIES is not set +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=m +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_GF128MUL is not set +CONFIG_CRYPTO_NULL=y +# CONFIG_CRYPTO_CRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_SEQIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +# CONFIG_CRYPTO_CTR is not set +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set + +# +# Hash modes +# +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set + +# +# Digest +# +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set + +# +# Ciphers +# +# CONFIG_CRYPTO_AES is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set + +# +# Compression +# +CONFIG_CRYPTO_DEFLATE=m +# CONFIG_CRYPTO_LZO is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +# CONFIG_CRC_T10DIF is not set +CONFIG_CRC_ITU_T=m +CONFIG_CRC32=y +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_PLIST=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_DMA=y diff --git a/meta-facebook/meta-wedge100/recipes-kernel/linux/linux-aspeed_2.6%.bbappend b/meta-facebook/meta-wedge100/recipes-kernel/linux/linux-aspeed_2.6%.bbappend new file mode 100644 index 0000000..fd0302e --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-kernel/linux/linux-aspeed_2.6%.bbappend @@ -0,0 +1,8 @@ +LINUX_VERSION_EXTENSION = "-wedge100" + +COMPATIBLE_MACHINE = "wedge100" + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://defconfig \ + " diff --git a/meta-facebook/meta-wedge100/recipes-utils/lm_sensors/files/wedge100.conf b/meta-facebook/meta-wedge100/recipes-utils/lm_sensors/files/wedge100.conf new file mode 100644 index 0000000..770d343 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/lm_sensors/files/wedge100.conf @@ -0,0 +1,78 @@ + +bus "i2c-3" "ast_i2c.3" + +bus "i2c-4" "ast_i2c.4" + +bus "i2c-8" "ast_i2c.8" + +chip "tmp75-i2c-3-48" + label temp1 "Outlet Middle Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "tmp75-i2c-3-49" + label temp1 "Inlet Middle Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "tmp75-i2c-3-4a" + label temp1 "Inlet Left Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "tmp75-i2c-3-4b" + label temp1 "Switch Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "tmp75-i2c-3-4c" + label temp1 "Inlet Right Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "tmp75-i2c-8-48" + label temp1 "Outlet Right Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "tmp75-i2c-8-49" + label temp1 "Outlet Left Temp" + set temp1_max 70 + set temp1_max_hyst 60 + +chip "fancpld-i2c-8-33" + label fan1 "Fan 1 front" + label fan2 "Fan 1 rear" + label fan3 "Fan 2 front" + label fan4 "Fan 2 rear" + label fan5 "Fan 3 front" + label fan6 "Fan 3 rear" + label fan7 "Fan 4 front" + label fan8 "Fan 4 rear" + label fan9 "Fan 5 front" + label fan10 "Fan 5 rear" + +chip "fb_panther_plus-*" + label temp1 "CPU Temp" + label temp2 "DIMM0 Temp" + ignore temp3 + ignore temp4 + ignore temp5 + +chip "ast_adc-isa-0000" + ignore in0 + ignore in1 + ignore in2 + ignore in3 + ignore in4 + label in5 "+1 Core Voltage" + label in6 "+1 Analog Voltage" + label in7 "+5 Voltage" + label in8 "+3.3 Voltage" + label in9 "+2.5 Voltage" + ignore in10 + ignore in11 + ignore in12 + ignore in13 + ignore in14 + ignore in15 diff --git a/meta-facebook/meta-wedge100/recipes-utils/lm_sensors/lmsensors_%.bbappend b/meta-facebook/meta-wedge100/recipes-utils/lm_sensors/lmsensors_%.bbappend new file mode 100644 index 0000000..23a3cc3 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/lm_sensors/lmsensors_%.bbappend @@ -0,0 +1,10 @@ + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://wedge100.conf \ + " + +do_install_board_config() { + install -d ${D}${sysconfdir}/sensors.d + install -m 644 ../wedge100.conf ${D}${sysconfdir}/sensors.d/wedge100.conf +} diff --git a/meta-facebook/meta-wedge100/recipes-utils/oob-nic/oob-nic_%.bbappend b/meta-facebook/meta-wedge100/recipes-utils/oob-nic/oob-nic_%.bbappend new file mode 100644 index 0000000..6f46ea6 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/oob-nic/oob-nic_%.bbappend @@ -0,0 +1,5 @@ +# No OOB NIC on wedge100. Just copy the i2craw +do_install() { + install -d ${D}${sbindir} + install -m 755 i2craw ${D}${sbindir}/i2craw +} diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_rev_table.py b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_rev_table.py new file mode 100644 index 0000000..353944e --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_rev_table.py @@ -0,0 +1,33 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from openbmc_gpio_table import BoardGPIO + +# The fallowing table is generated using: +# python wedge100_gpio_parser.py data/wedge100-BMC-gpio.csv +# DO NOT MODIFY THE TABLE!!! +# Manual modification will be overridden!!! + +board_gpio_rev_table = [ + BoardGPIO('GPIOY0', 'BOARD_REV_ID0'), + BoardGPIO('GPIOY1', 'BOARD_REV_ID1'), + BoardGPIO('GPIOY2', 'BOARD_REV_ID2'), +] diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_table_v1.py b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_table_v1.py new file mode 100644 index 0000000..d51bafb --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_table_v1.py @@ -0,0 +1,107 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from openbmc_gpio_table import BoardGPIO + + +# The fallowing table is generated using: +# python wedge100_gpio_parser.py data/wedge100-BMC-gpio.csv +# DO NOT MODIFY THE TABLE!!! +# Manual modification will be overridden!!! + +board_gpio_table_v1 = [ + BoardGPIO('GPIOB0', 'PANTHER_I2C_ALERT_N'), + BoardGPIO('GPIOB1', 'MSERV_NIC_SMBUS_ALERT_N'), + BoardGPIO('GPIOB2', 'DEBUG_PORT_UART_SEL_N'), + BoardGPIO('GPIOB4', 'LED_POSTCODE_4'), + BoardGPIO('GPIOB5', 'LED_POSTCODE_5'), + BoardGPIO('GPIOB6', 'LED_POSTCODE_6'), + BoardGPIO('GPIOB7', 'LED_POSTCODE_7'), + BoardGPIO('GPIOC2', 'ISO_BUF_EN'), + BoardGPIO('GPIOD0', 'BMC_PWR_BTN_IN_N'), + BoardGPIO('GPIOD1', 'BMC_PWR_BTN_OUT_N'), + BoardGPIO('GPIOD2', 'BMC_CPLD_RESET1'), + BoardGPIO('GPIOD3', 'BMC_CPLD_RESET2'), + BoardGPIO('GPIOD4', 'BMC_CPLD_RESET3'), + BoardGPIO('GPIOD5', 'BMC_CPLD_RESET4'), + BoardGPIO('GPIOD7', 'BMC_CPLD_QSFP_INT'), + BoardGPIO('GPIOE0', 'DEBUG_UART_SEL_0'), + BoardGPIO('GPIOE2', 'SWITCH_EEPROM1_WRT'), + BoardGPIO('GPIOE4', 'ISO_MICROSRV_PRSNT_N'), + BoardGPIO('GPIOE5', 'LED_PWR_BLUE'), + BoardGPIO('GPIOF0', 'MSERVE_ISOBUF_EN'), + BoardGPIO('GPIOF1', 'BMC_MAIN_RESET_N'), + BoardGPIO('GPIOF2', 'CPLD_JTAG_SEL'), + BoardGPIO('GPIOF4', 'MSERV_POWERUP'), + BoardGPIO('GPIOF5', 'RCKMON_RS485_DE'), + BoardGPIO('GPIOG0', 'LED_POSTCODE_0'), + BoardGPIO('GPIOG1', 'LED_POSTCODE_1'), + BoardGPIO('GPIOG2', 'LED_POSTCODE_2'), + BoardGPIO('GPIOG3', 'LED_POSTCODE_3'), + BoardGPIO('GPIOG4', 'BMC_WDTRST1'), + BoardGPIO('GPIOG5', 'BMC_WDTRST2'), + BoardGPIO('GPIOH3', 'QSFP_LED_POSITION'), + BoardGPIO('GPIOH4', 'PM_SM_ALERT_N'), + BoardGPIO('GPIOI4', 'BMC_EEPROM1_SPI_SS'), + BoardGPIO('GPIOI5', 'BMC_EEPROM1_SPI_SCK'), + BoardGPIO('GPIOI6', 'BMC_EEPROM1_SPI_MOSI'), + BoardGPIO('GPIOI7', 'BMC_EEPROM1_SPI_MISO'), + BoardGPIO('GPIOJ0', 'RCKMON_SPARE0'), + BoardGPIO('GPIOJ1', 'RCKMON_SPARE1'), + BoardGPIO('GPIOJ2', 'RCKMON_SPARE2'), + BoardGPIO('GPIOJ3', 'RCKMON_SPARE3'), + BoardGPIO('GPIOJ4', 'FANCARD_CPLD_TMS'), + BoardGPIO('GPIOJ5', 'FANCARD_CPLD_TCK'), + BoardGPIO('GPIOJ6', 'FANCARD_CPLD_TDI'), + BoardGPIO('GPIOJ7', 'FANCARD_CPLD_TDO'), + BoardGPIO('GPIOL5', 'BMC_UART_1_RTS'), + BoardGPIO('GPIOM0', 'CPLD_UPD_EN'), + BoardGPIO('GPIOM1', 'SMB_ALERT'), + BoardGPIO('GPIOM3', 'TH_POWERUP'), + BoardGPIO('GPIOM4', 'BMC_CPLD_TMS'), + BoardGPIO('GPIOM5', 'BMC_CPLD_TDI'), + BoardGPIO('GPIOM6', 'BMC_CPLD_TCK'), + BoardGPIO('GPIOM7', 'BMC_CPLD_TDO'), + BoardGPIO('GPIOO0', 'RCKMON_SPARE4'), + BoardGPIO('GPIOO1', 'RCKMON_SPARE5'), + BoardGPIO('GPIOO2', 'RCKMON_SPARE10'), + BoardGPIO('GPIOO3', 'RCKMON_SPARE11'), + BoardGPIO('GPIOO4', 'RCKMON_SPARE8'), + BoardGPIO('GPIOO5', 'RCKMON_SPARE9'), + BoardGPIO('GPIOO6', 'RCKMON_SPARE6'), + BoardGPIO('GPIOO7', 'RCKMON_SPARE7'), + BoardGPIO('GPIOP0', 'RMON1_PF'), + BoardGPIO('GPIOP1', 'RMON1_RF'), + BoardGPIO('GPIOP2', 'RMON2_PF'), + BoardGPIO('GPIOP3', 'RMON2_RF'), + BoardGPIO('GPIOP4', 'RMON3_PF'), + BoardGPIO('GPIOP5', 'RMON3_RF'), + BoardGPIO('GPIOP6', 'FANCARD_I2C_ALARM'), + BoardGPIO('GPIOP7', 'BMC_READY_N'), + BoardGPIO('GPIOQ4', 'BMC_CPLD_POWER_INT'), + BoardGPIO('GPIOQ5', 'BMC_CPLD_SPARE7'), + BoardGPIO('GPIOQ6', 'USB_OCS_N1'), + BoardGPIO('GPIOQ7', 'BMC_HEARTBEAT_N'), + BoardGPIO('GPIOR0', 'SPI_IBMC_BT_CS1_N_R'), + BoardGPIO('GPIOR6', 'SWITCH_MDC'), + BoardGPIO('GPIOR7', 'SWITCH_MDIO'), + BoardGPIO('GPIOS0', 'BMC_SPI_WP_N'), +] diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_table_v2.py b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_table_v2.py new file mode 100644 index 0000000..a95ecf4 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/board_gpio_table_v2.py @@ -0,0 +1,118 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from openbmc_gpio_table import BoardGPIO + + +# The fallowing table is generated using: +# python wedge100_gpio_parser.py data/wedge100-BMC-gpio.csv +# DO NOT MODIFY THE TABLE!!! +# Manual modification will be overridden!!! + +board_gpio_table_v2 = [ + BoardGPIO('GPIOB0', 'PANTHER_I2C_ALERT_N'), + BoardGPIO('GPIOB1', 'MSERV_NIC_SMBUS_ALERT_N'), + BoardGPIO('GPIOB2', 'DEBUG_PORT_UART_SEL_N'), + BoardGPIO('GPIOB5', 'LED_POSTCODE_5'), + BoardGPIO('GPIOB6', 'LED_POSTCODE_6'), + BoardGPIO('GPIOB7', 'LED_POSTCODE_7'), + BoardGPIO('GPIOC2', 'ISO_BUF_EN'), + BoardGPIO('GPIOD0', 'BMC_PWR_BTN_IN_N'), + BoardGPIO('GPIOD1', 'BMC_PWR_BTN_OUT_N'), + BoardGPIO('GPIOD2', 'BMC_CPLD_RESET1'), + BoardGPIO('GPIOD3', 'BMC_CPLD_RESET2'), + BoardGPIO('GPIOD4', 'BMC_CPLD_RESET3'), + BoardGPIO('GPIOD5', 'BMC_CPLD_RESET4'), + BoardGPIO('GPIOD7', 'BMC_CPLD_QSFP_INT'), + BoardGPIO('GPIOE0', 'DEBUG_UART_SEL_0'), + BoardGPIO('GPIOE2', 'SWITCH_EEPROM1_WRT'), + BoardGPIO('GPIOE4', 'ISO_MICROSRV_PRSNT_N'), + BoardGPIO('GPIOE5', 'LED_PWR_BLUE'), + BoardGPIO('GPIOF0', 'MSERVE_ISOBUF_EN'), + BoardGPIO('GPIOF1', 'BMC_MAIN_RESET_N'), + BoardGPIO('GPIOF2', 'CPLD_JTAG_SEL'), + BoardGPIO('GPIOF4', 'MSERV_POWERUP'), + BoardGPIO('GPIOF5', 'BMC_UART_4_RTS'), + BoardGPIO('GPIOG0', 'LED_POSTCODE_0'), + BoardGPIO('GPIOG1', 'LED_POSTCODE_1'), + BoardGPIO('GPIOG2', 'LED_POSTCODE_2'), + BoardGPIO('GPIOG3', 'LED_POSTCODE_3'), + BoardGPIO('GPIOG4', 'BMC_WDTRST1'), + BoardGPIO('GPIOG5', 'BMC_WDTRST2'), + BoardGPIO('GPIOG6', 'BMC_COM_NIC_ISOBUF_EN'), + BoardGPIO('GPIOG7', 'BMC_COM_PANTHER_ISOBUF_EN'), + BoardGPIO('GPIOH3', 'QSFP_LED_POSITION'), + BoardGPIO('GPIOH4', 'PM_SM_ALERT_N'), + BoardGPIO('GPIOI4', 'BMC_EEPROM1_SPI_SS'), + BoardGPIO('GPIOI5', 'BMC_EEPROM1_SPI_SCK'), + BoardGPIO('GPIOI6', 'BMC_EEPROM1_SPI_MOSI'), + BoardGPIO('GPIOI7', 'BMC_EEPROM1_SPI_MISO'), + BoardGPIO('GPIOJ0', 'RCKMON_SPARE0'), + BoardGPIO('GPIOJ1', 'RCKMON_SPARE1'), + BoardGPIO('GPIOJ2', 'RCKMON_SPARE2'), + BoardGPIO('GPIOJ3', 'RCKMON_SPARE3'), + BoardGPIO('GPIOJ4', 'FANCARD_CPLD_TMS'), + BoardGPIO('GPIOJ5', 'FANCARD_CPLD_TCK'), + BoardGPIO('GPIOJ6', 'FANCARD_CPLD_TDI'), + BoardGPIO('GPIOJ7', 'FANCARD_CPLD_TDO'), + BoardGPIO('GPIOL5', 'BMC_UART_1_RTS'), + BoardGPIO('GPIOM0', 'CPLD_UPD_EN'), + BoardGPIO('GPIOM1', 'SMB_ALERT'), + BoardGPIO('GPIOM3', 'TH_POWERUP'), + BoardGPIO('GPIOM4', 'BMC_CPLD_TMS'), + BoardGPIO('GPIOM5', 'BMC_CPLD_TDI'), + BoardGPIO('GPIOM6', 'BMC_CPLD_TCK'), + BoardGPIO('GPIOM7', 'BMC_CPLD_TDO'), + BoardGPIO('GPION0', 'ISO_COM_SUS_S3_N'), + BoardGPIO('GPION1', 'ISO_COM_SUS_S4_N'), + BoardGPIO('GPION2', 'ISO_COM_SUS_S5_N'), + BoardGPIO('GPION3', 'ISO_COM_SUS_STAT_N'), + BoardGPIO('GPION4', 'ISO_COM_BRG_WDT'), + BoardGPIO('GPION5', 'BRG_COM_BIOS_DIS0_N'), + BoardGPIO('GPION6', 'BRG_COM_BIOS_DIS1_N'), + BoardGPIO('GPION7', 'ISO_COM_PWROK'), + BoardGPIO('GPIOO0', 'COM_SPI_SEL'), + BoardGPIO('GPIOO1', 'COM6_BUF_EN'), + BoardGPIO('GPIOO2', 'RCKMON_SPARE4'), + BoardGPIO('GPIOO3', 'RCKMON_SPARE5'), + BoardGPIO('GPIOO4', 'TPM_SPI_SEL'), + BoardGPIO('GPIOO5', 'TPM_SPI_BUF_EN'), + BoardGPIO('GPIOO6', 'ISO_BRG_THRMTRIP_N'), + BoardGPIO('GPIOO7', 'ISO_BRG_THRM_N'), + BoardGPIO('GPIOP0', 'RMON1_PF'), + BoardGPIO('GPIOP1', 'RMON1_RF'), + BoardGPIO('GPIOP2', 'RMON2_PF'), + BoardGPIO('GPIOP3', 'RMON2_RF'), + BoardGPIO('GPIOP4', 'RMON3_PF'), + BoardGPIO('GPIOP5', 'RMON3_RF'), + BoardGPIO('GPIOP6', 'FANCARD_I2C_ALARM'), + BoardGPIO('GPIOP7', 'BMC_READY_N'), + BoardGPIO('GPIOQ4', 'BMC_CPLD_POWER_INT'), + BoardGPIO('GPIOQ5', 'BMC_CPLD_SPARE7'), + BoardGPIO('GPIOQ6', 'USB_OCS_N1'), + BoardGPIO('GPIOQ7', 'BMC_HEARTBEAT_N'), + BoardGPIO('GPIOR0', 'SPI_IBMC_BT_CS1_N_R'), + BoardGPIO('GPIOR6', 'SWITCH_MDC'), + BoardGPIO('GPIOR7', 'SWITCH_MDIO'), + BoardGPIO('GPIOS0', 'BMC_SPI_WP_N'), + BoardGPIO('GPIOY3', 'LED_POSTCODE_4'), +] + diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/data/wedge100-BMC-GPIO-DVT.csv b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/data/wedge100-BMC-GPIO-DVT.csv new file mode 100644 index 0000000..1ded15c --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/data/wedge100-BMC-GPIO-DVT.csv @@ -0,0 +1,104 @@ +J21,GPIOB0_SALT1,In,PANTHER_I2C_ALERT_N,panther i2c alert_n +J20,GPIOB1_SALT2,In,MSERV_NIC_SMBUS_ALERT_N,"micro server NIC SMBUS alert_n, active low" +H18,GPIOB2_SALT3,In,DEBUG_PORT_UART_SEL_N,The DEBUG_PORT_UART_SEL_N is connected to a push button in the front panel. When Debug port select button in Front panel is pressed DEBUG_PORT_UART_SEL_N becomes low. +E19,GPIOB4_LPCRST_N,Out,LPC_RST_N,Signal to reset LPC +H19,GPIOB5_LPCPD_N_LPCSMI_N,Out,LED_POSTCODE_5,LED 7-segment code bit-5 for facebook debug header +H20,GPIOB6_LPCPME_N,Out,LED_POSTCODE_6,LED 7-segment code bit-6 for facebook debug header +E18,GPIOB7_EXTRST_N_SPICS1_N,Out,LED_POSTCODE_7,LED 7-segment code bit-7 for facebook debug header +A2,GPIOC2_SD1DAT0_SCL11,Out,ISO_BUF_EN,"reserved for ISO_BUFFER control, in default serial resister is depop, use CPLD to control" +A18,GPIOD0_SD2CLK,,BMC_PWR_BTN_IN_N,to emulate Microserver power button function using BMC +D16,GPIOD1_SD2CMD,,BMC_PWR_BTN_OUT_N, +B17,GPIOD2_SD2DAT0,Out,BMC_CPLD_RESET1,Spare Reset signal connected to CPLD +A17,GPIOD3_SD2DAT1,Out,BMC_CPLD_RESET2,Spare Reset signal connected to CPLD +C16,GPIOD4_SD2DAT2,Out,BMC_CPLD_RESET3,Spare Reset signal connected to CPLD (USB_BRDG RST function moved to CPLD) +B16,GPIOD5_SD2DAT3,Out,BMC_CPLD_RESET4,Spare Reset signal connected to CPLD +E15,GPIOD7_SD2WP_N,In,BMC_CPLD_QSFP_INT,Intrerrupt from CPLD to BMC for any QSFP events (USB RESET function moved to CPLD) +D15,GPIOE0_NCTS3,Out,DEBUG_UART_SEL_0,FB debug connector UART select 0: BMC uART 1: microserver UART +B15,GPIOE2_NDSR3,out,SWITCH_EEPROM1_WRT,"0: BCM5387 SPI interface connect to SPI EEPROM +1: BCM5387 SPI interface connect to BMC SPI EEPROM interface +this bit is used as BCM5387 straping configuration too" +E14,GPIOE4_NDTR3,in,ISO_MICROSRV_PRSNT_N,"0: Microserver is present in PCIe slot +1: microserver is not present in PCIe slot" +D14,GPIOE5_NRTS3,out,LED_PWR_BLUE,"Power LED blue will be ON when LED_PWR_BLUE is high. +Power LED blue will be off when LED_PWR_BLUE is low" +D18,GPIOF0_NCTS4,Out,MSERVE_ISOBUF_EN,To enable isolation buffer dedicated for microserver com port +B19,GPIOF1_NDCD4_SIOPBI_N,Out,BMC_MAIN_RESET_N,BMC can request cpld to reset main power +A20,GPIOF2_NDSR4_SIOPWRGD,Out,CPLD_JTAG_SEL,"SYSCPLD upgrade enable, 0: jtag header program, 1: BMC programming" +B18,GPIOF4_NDTR4,Out,MSERV_POWERUP,To request cpld to turn on P12_uServer for microserver +A19,GPIOF5_NRTS4_SIOSCI_N,Out,BMC_UART_4_RTS,BMC com port 4 rts to cpld +E16,GPIOF6_TXD4,In,BMC_UART_4_TX,BMC com port to cpld +C17,GPIOF7_RXD4,Out,BMC_UART_4_RX,BMC com port to cpld +A14,GPIOG0_SGPSCK,Out,LED_POSTCODE_0,LED 7-segment code bit-0 for facebook debug header +E13,GPIOG1_SGPSLD,Out,LED_POSTCODE_1,LED 7-segment code bit-1 for facebook debug header +D13,GPIOG2_SGPSI0,Out,LED_POSTCODE_2,LED 7-segment code bit-2 for facebook debug header +C13,GPIOG3_SGPSI1,Out,LED_POSTCODE_3,LED 7-segment code bit-3 for facebook debug header +B13,GPIOG4_WDTRST1_OSCCLK,Out,BMC_WDTRST1,Watch dog timer reset1 output from BMC to CPLD +Y21,GPIOG5_WDTRST2_USBCKI,Out,BMC_WDTRST2,Watch dog timer reset2 output from BMC to CPLD +AA22,GPIOG6_FLBUSY_N,Out,BMC_COM_NIC_ISOBUF_EN,Active low signal to enable the isolation buffer for SMBUS to COMe +U18,GPIOG7_FLWP_N,Out,BMC_COM_PANTHER_ISOBUF_EN,Active low signal to enable the isolation buffer for I2C BUS to COMe +A7,GPIOH3_ROMD11_NRI6,In,QSFP_LED_POSITION,QSFP position select input +D7,GPIOH4_ROMD12_NDTR6,In,PM_SM_ALERT_N,SM bus alert from power manager (also connected to CPLD) +C22,GPIOI0_SYSCS_N,Out,BMC_TPM_SPI_CS_N,BMC SPI interface to SPI based TPM +G18,GPIOI1_SYSCK,Out,BMC_TPM_SPI_CLK,BMC SPI interface to SPI based TPM +D19,GPIOI2_SYSDO,Out,BMC_TPM_SPI_MOSI,BMC SPI interface to SPI based TPM +C20,GPIOI3_SYSDI,In,BMC_TPM_SPI_MISO,BMC SPI interface to SPI based TPM +B22,GPIOI4_SPICS0_N_VBCS_N,Out,BMC_EEPROM1_SPI_SS,"BMC SPI EEPROM interface connect to BCM5387 switch if SWITCH_EEPRM1_WRT is 1, " +G19,GPIOI5_SPICK_VBCK,Out,BMC_EEPROM1_SPI_SCK, +C18,GPIOI6_SPIDO_VBDO,Out,BMC_EEPROM1_SPI_MOSI, +E20,GPIOI7_SPIDI_VBDI,In,BMC_EEPROM1_SPI_MISO, +J5,GPIOJ0_SGPMCK,Bi,RCKMON_SPARE0,Spare gpios to rack mon card +J4,GPIOJ1_SGPMLD,Bi,RCKMON_SPARE1,Spare gpios to rack mon card +K5,GPIOJ2_SGPMO,Bi,RCKMON_SPARE2,Spare gpios to rack mon card +J3,GPIOJ3_SGPMI,Bi,RCKMON_SPARE3,Spare gpios to rack mon card +T4,VGAHS_GPIOJ4,,FANCARD_CPLD_TMS,"fancard CPLD JTAG upgrade interface, BMC output to CPLD TMS" +U2,VGAVS_GPIOJ5,,FANCARD_CPLD_TCK,"fancard CPLD JTAG upgrade interface, BMC output to CPLD TCK" +T2,DDCCLK_GPIOJ6,,FANCARD_CPLD_TDI,"fancard CPLD JTAG upgrade interface, BMC output to CPLD TDI" +T1,DDCDAT_GPIOJ7,,FANCARD_CPLD_TDO,"fancard CPLD JTAG upgrade interface, BMC input to CPLD TDO" +V2,GPIOL5_NRTS1_VPICLK,Out,BMC_UART_1_RTS,connect to SYSCPLD +W1,GPIOL6_TXD1_VPIB0,Out,BMC_UART_TX_1,connect to SYSCPLD +U5,GPIOL7_RXD1_VPIB1,In,BMC_UART_RX_1,connect to SYSCPLD +V3,GPIOM0_NCTS2_VPIB2,Out,CPLD_UPD_EN,"fan_card CPLD upgrade enable, 0: jtag header programming, 1: BMC programming" +W2,GPIOM1_NDCD2_VPIB3,In,SMB_ALERT,"Alert signal from cpld representing Alert from the power supplies(Vcore,vanlg,3.3)" +V4,GPIOM3_NRI2_VPIB5,out,TH_POWERUP,"tomahawk power up enable, active high. Connect to CPLD, cpld will control pwr1014a" +W3,GPIOM4_NDTR2_VPIB6,out,BMC_CPLD_TMS,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TMS" +Y2,GPIOM5_NRTS2_VPIB7,out,BMC_CPLD_TDI,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TDI" +AA1,GPIOM6_TXD2_VPIB8,out,BMC_CPLD_TCK,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TCK" +V5,GPIOM7_RXD2_VPIB9,In,BMC_CPLD_TDO,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TDO" +W4,GPION0_PWM0_VPIG0,In,ISO_COM_SUS_S3_N,s3 sleep signal from com(COME Signal) +Y3,GPION1_PWM1_VPIG1,In,ISO_COM_SUS_S4_N,s4 sleep signal from com (COME Signal) +AA2,GPION2_PWM2_VPIG2,In,ISO_COM_SUS_S5_N,s5 sleep signal from com (COME Signal) +AB1,GPION3_PWM3_VPIG3,In,ISO_COM_SUS_STAT_N,suspend status signal from com (COME Signal) +W5,GPION4_PWM4_VPIG4,In,ISO_COM_BRG_WDT,watch dog timer output from com(COME Signal) +Y4,GPION5_PWM5_VPIG5,Out,BRG_COM_BIOS_DIS0_N,BMC can select the bootdevice of COM (COME Signal) +AA3,GPION6_PWM6_VPIG6,Out,BRG_COM_BIOS_DIS1_N,BMC can select the bootdevice of COM (COME Signal) +AB2,GPION7_PWM7_VPIG7,Out,ISO_COM_PWROK,com power ok signal from BMC (COME Signal) +V6,GPIOO0_TACH0_VPIG8,Out,COM_SPI_SEL,"override signal from bmc to select bmc to upgrade com eeprom +0:On board spi flash +1:BMC can write into SPI flash" +Y5,GPIOO1_TACH1_VPIG9,Out,COM6_BUF_EN,Active low signal to enable isolation buffer dedicated for com signals +AA4,GPIOO2_TACH2_VPIR0,BI,RCKMON_SPARE4,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector +AB3,GPIOO3_TACH3_VPIR1,BI,RCKMON_SPARE5,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector +W6,GPIOO4_TACH4_VPIR2,Out,TPM_SPI_SEL,Signal from BMC to select whether BMC or COM SPI should go to TPM module. By default COM SPI is Selected. BMC can drive this signal high to select SPI from BMC +AA5,GPIOO5_TACH5_VPIR3,Out,TPM_SPI_BUF_EN,Signal from BMC to enable or disable the MUX which selects BMC or COM SPI to TPM module. Default the MUX is enabled .BMC can drive high to disable it. +AB4,GPIOO6_TACH6_VPIR4,In,ISO_BRG_THRMTRIP_N,"Active low Signal from COM to indicate processor over heating ,and com will go into s5 state (COME Signal)" +V7,GPIOO7_TACH7_VPIR5,Out,ISO_BRG_THRM_N,Active low Signal from BMC to indicate overtemperature (COME Signal) +Y6,GPIOP0_TACH8_VPIR6,In,RMON1_PF,"rack 1 monitor status, Power Failure, active low" +AB5,GPIOP1_TACH9_VPIR7,In,RMON1_RF,"rack 1 monitor status, redudancy Failure, active low" +W7,GPIOP2_TACH10_VPIR8,In,RMON2_PF,"rack 2 monitor status, Power Failure, active low" +AA6,GPIOP3_TACH11_VPIR9,In,RMON2_RF,"rack 2 monitor status, redudancy Failure, active low" +AB6,GPIOP4_TACH12,In,RMON3_PF,"rack 3 monitor status, Power Failure, active low" +Y7,GPIOP5_TACH13,In,RMON3_RF,"rack 3 monitor status, redudancy Failure, active low" +AA7,GPIOP6_TACH14_BMCINT,In,FANCARD_I2C_ALARM,"fan card alarm input, active low" +AB7,GPIOP7_TACH15_FLACK,out,BMC_READY_N,"0: BMC is ready for service. 1: BMC is not ready, or during initialization" +H4,GPIOQ4_SCL14,In,BMC_CPLD_POWER_INT,Intrerrupt from CPLD to BMC for any Power events +H3,GPIOQ5_SDA14,,BMC_CPLD_SPARE7,Spare GPIOs to CPLD +H2,GPIOQ6,out,USB_OCS_N1,over-current sense output to USB2513 hub +H1,GPIOQ7,out,BMC_HEARTBEAT_N,BMC heatbeat output to onboard heartbeat LED +V20,GPIOR0_ROMCS1_N,out,SPI_IBMC_BT_CS1_N_R,chip select to secondary boot SPI flash +C6,GPIOR6_MDC1,BI,SWITCH_MDC,MDC/MDIO to GE Switch +A5,GPIOR7_MDIO1,BI,SWITCH_MDIO, +U21,ROMD4_GPIOS0_VPODE,Out,BMC_SPI_WP_N,Write protect for Secondary Boot Flash. Connected to CPLD. CPLD will drive it to the flash chip +C21,GPIOY0_SIOS3_N,In,BOARD_REV_ID0,"Board ID input bit0, resister straping, connect to both BMC and CPLD" +F20,GPIOY1_SIOS5_N,In,BOARD_REV_ID1,"Board ID input bit1, resister straping, connect to both BMC and CPLD" +G20,GPIOY2_SIOPWREQ_N,In,BOARD_REV_ID2,"Board ID input bit2, resister straping, connect to both BMC and CPLD" +K20,GPIOY3_SIOONCTRL_N,,LED_POSTCODE_4,LED 7-segment code bit-4 for facebook debug header
\ No newline at end of file diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/data/wedge100-BMC-GPIO-EVT.csv b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/data/wedge100-BMC-GPIO-EVT.csv new file mode 100644 index 0000000..781d739 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/data/wedge100-BMC-GPIO-EVT.csv @@ -0,0 +1,83 @@ +J21,GPIOB0_SALT1,In,PANTHER_I2C_ALERT_N,panther i2c alert_n +J20,GPIOB1_SALT2,In,MSERV_NIC_SMBUS_ALERT_N,"micro server NIC SMBUS alert_n, active low" +H18,GPIOB2_SALT3,In,DEBUG_PORT_UART_SEL_N,The DEBUG_PORT_UART_SEL_N is connected to a push button in the front panel. When Debug port select button in Front panel is pressed DEBUG_PORT_UART_SEL_N becomes low. +E19,GPIOB4_LPCRST_N,Out,LED_POSTCODE_4,LED 7-segment code bit-4 for facebook debug header +H19,GPIOB5_LPCPD_N_LPCSMI_N,Out,LED_POSTCODE_5,LED 7-segment code bit-5 for facebook debug header +H20,GPIOB6_LPCPME_N,Out,LED_POSTCODE_6,LED 7-segment code bit-6 for facebook debug header +E18,GPIOB7_EXTRST_N_SPICS1_N,Out,LED_POSTCODE_7,LED 7-segment code bit-7 for facebook debug header +A2,GPIOC2_SD1DAT0_SCL11,Out,ISO_BUF_EN,"reserved for ISO_BUFFER control, in default serial resister is depop, use CPLD to control" +A18,GPIOD0_SD2CLK,,BMC_PWR_BTN_IN_N,to emulate Microserver power button function using BMC +D16,GPIOD1_SD2CMD,,BMC_PWR_BTN_OUT_N, +B17,GPIOD2_SD2DAT0,Out,BMC_CPLD_RESET1,Spare Reset signal connected to CPLD +A17,GPIOD3_SD2DAT1,Out,BMC_CPLD_RESET2,Spare Reset signal connected to CPLD +C16,GPIOD4_SD2DAT2,Out,BMC_CPLD_RESET3,Spare Reset signal connected to CPLD (USB_BRDG RST function moved to CPLD) +B16,GPIOD5_SD2DAT3,Out,BMC_CPLD_RESET4,Spare Reset signal connected to CPLD +E15,GPIOD7_SD2WP_N,In,BMC_CPLD_QSFP_INT,Intrerrupt from CPLD to BMC for any QSFP events (USB RESET function moved to CPLD) +D15,GPIOE0_NCTS3,Out,DEBUG_UART_SEL_0,FB debug connector UART select 0: BMC uART 1: microserver UART +B15,GPIOE2_NDSR3,out,SWITCH_EEPROM1_WRT,"0: BCM5387 SPI interface connect to SPI EEPROM +1: BCM5387 SPI interface connect to BMC SPI EEPROM interface +this bit is used as BCM5387 straping configuration too" +E14,GPIOE4_NDTR3,in,ISO_MICROSRV_PRSNT_N,"0: Microserver is present in PCIe slot +1: microserver is not present in PCIe slot" +D14,GPIOE5_NRTS3,out,LED_PWR_BLUE,"Power LED blue will be ON when LED_PWR_BLUE is high. +Power LED blue will be off when LED_PWR_BLUE is low" +D18,GPIOF0_NCTS4,Out,MSERVE_ISOBUF_EN,To enable isolation buffer dedicated for microserver com port +B19,GPIOF1_NDCD4_SIOPBI_N,Out,BMC_MAIN_RESET_N,BMC can request cpld to reset main power +A20,GPIOF2_NDSR4_SIOPWRGD,Out,CPLD_JTAG_SEL,"SYSCPLD upgrade enable, 0: jtag header program, 1: BMC programming" +B18,GPIOF4_NDTR4,Out,MSERV_POWERUP,To request cpld to turn on P12_uServer for microserver +A19,GPIOF5_NRTS4,Out,RCKMON_RS485_DE,RS485 Drive Enable (TX/RX Toggle) pin for rackmon +A14,GPIOG0_SGPSCK,Out,LED_POSTCODE_0,LED 7-segment code bit-0 for facebook debug header +E13,GPIOG1_SGPSLD,Out,LED_POSTCODE_1,LED 7-segment code bit-1 for facebook debug header +D13,GPIOG2_SGPSI0,Out,LED_POSTCODE_2,LED 7-segment code bit-2 for facebook debug header +C13,GPIOG3_SGPSI1,Out,LED_POSTCODE_3,LED 7-segment code bit-3 for facebook debug header +B13,GPIOG4_WDTRST1_OSCCLK,Out,BMC_WDTRST1,Watch dog timer reset1 output from BMC to CPLD +Y21,GPIOG5_WDTRST2_USBCKI,Out,BMC_WDTRST2,Watch dog timer reset2 output from BMC to CPLD +A7,GPIOH3_ROMD11_NRI6,In,QSFP_LED_POSITION,QSFP position select input +D7,GPIOH4_ROMD12_NDTR6,In,PM_SM_ALERT_N,SM bus alert from power manager (also connected to CPLD) +B22,GPIOI4_SPICS0_N_VBCS_N,Out,BMC_EEPROM1_SPI_SS,"BMC SPI EEPROM interface connect to BCM5387 switch if SWITCH_EEPRM1_WRT is 1, " +G19,GPIOI5_SPICK_VBCK,Out,BMC_EEPROM1_SPI_SCK, +C18,GPIOI6_SPIDO_VBDO,Out,BMC_EEPROM1_SPI_MOSI, +E20,GPIOI7_SPIDI_VBDI,In,BMC_EEPROM1_SPI_MISO, +J5,GPIOJ0_SGPMCK,Bi,RCKMON_SPARE0,Spare gpios to rack mon card +J4,GPIOJ1_SGPMLD,Bi,RCKMON_SPARE1,Spare gpios to rack mon card +K5,GPIOJ2_SGPMO,Bi,RCKMON_SPARE2,Spare gpios to rack mon card +J3,GPIOJ3_SGPMI,Bi,RCKMON_SPARE3,Spare gpios to rack mon card +T4,VGAHS_GPIOJ4,,FANCARD_CPLD_TMS,"fancard CPLD JTAG upgrade interface, BMC output to CPLD TMS" +U2,VGAVS_GPIOJ5,,FANCARD_CPLD_TCK,"fancard CPLD JTAG upgrade interface, BMC output to CPLD TCK" +T2,DDCCLK_GPIOJ6,,FANCARD_CPLD_TDI,"fancard CPLD JTAG upgrade interface, BMC output to CPLD TDI" +T1,DDCDAT_GPIOJ7,,FANCARD_CPLD_TDO,"fancard CPLD JTAG upgrade interface, BMC input to CPLD TDO" +V2,GPIOL5_NRTS1_VPICLK,Out,BMC_UART_1_RTS,connect to SYSCPLD +V3,GPIOM0_NCTS2_VPIB2,Out,CPLD_UPD_EN,"fan_card CPLD upgrade enable, 0: jtag header programming, 1: BMC programming" +W2,GPIOM1_NDCD2_VPIB3,In,SMB_ALERT,"Alert signal from cpld representing Alert from the power supplies(Vcore,vanlg,3.3)" +V4,GPIOM3_NRI2_VPIB5,out,TH_POWERUP,"tomahawk power up enable, active high. Connect to CPLD, cpld will control pwr1014a" +W3,GPIOM4_NDTR2_VPIB6,out,BMC_CPLD_TMS,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TMS" +Y2,GPIOM5_NRTS2_VPIB7,out,BMC_CPLD_TDI,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TDI" +AA1,GPIOM6_TXD2_VPIB8,out,BMC_CPLD_TCK,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TCK" +V5,GPIOM7_RXD2_VPIB9,In,BMC_CPLD_TDO,"SYSCPLD CPLD JTAG upgrade interface, BMC output to SYSCPLD TDO" +V6,GPIOO0_TACH0_VPIG8,BI,RCKMON_SPARE4,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector +Y5,GPIOO1_TACH1_VPIG9,BI,RCKMON_SPARE5,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector +AA4,GPIOO2_TACH2_VPIR0,BI,RCKMON_SPARE10,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector(now not connected) +AB3,GPIOO3_TACH3_VPIR1,BI,RCKMON_SPARE11,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector(now not connected) +W6,GPIOO4_TACH4_VPIR2,BI,RCKMON_SPARE8,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector(now not connected) +AA5,GPIOO5_TACH5_VPIR3,BI,RCKMON_SPARE9,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector(now not connected) +AB4,GPIOO6_TACH6_VPIR4,BI,RCKMON_SPARE6,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector(now not connected) +V7,GPIOO7_TACH7_VPIR5,BI,RCKMON_SPARE7,RCKMON_SPARE[0:11] connect to fan_ctrl_rmon card connector(now not connected) +Y6,GPIOP0_TACH8_VPIR6,In,RMON1_PF,"rack 1 monitor status, Power Failure, active low" +AB5,GPIOP1_TACH9_VPIR7,In,RMON1_RF,"rack 1 monitor status, redudancy Failure, active low" +W7,GPIOP2_TACH10_VPIR8,In,RMON2_PF,"rack 2 monitor status, Power Failure, active low" +AA6,GPIOP3_TACH11_VPIR9,In,RMON2_RF,"rack 2 monitor status, redudancy Failure, active low" +AB6,GPIOP4_TACH12,In,RMON3_PF,"rack 3 monitor status, Power Failure, active low" +Y7,GPIOP5_TACH13,In,RMON3_RF,"rack 3 monitor status, redudancy Failure, active low" +AA7,GPIOP6_TACH14_BMCINT,In,FANCARD_I2C_ALARM,"fan card alarm input, active low" +AB7,GPIOP7_TACH15_FLACK,out,BMC_READY_N,"0: BMC is ready for service. 1: BMC is not ready, or during initialization" +H4,GPIOQ4_SCL14,In,BMC_CPLD_POWER_INT,Intrerrupt from CPLD to BMC for any Power events +H3,GPIOQ5_SDA14,,BMC_CPLD_SPARE7,Spare GPIOs to CPLD +H2,GPIOQ6,out,USB_OCS_N1,over-current sense output to USB2513 hub +H1,GPIOQ7,out,BMC_HEARTBEAT_N,BMC heatbeat output to onboard heartbeat LED +C6,GPIOR6_MDC1,BI,SWITCH_MDC,MDC/MDIO to GE Switch +A5,GPIOR7_MDIO1,BI,SWITCH_MDIO, +V20,GPIOR0_ROMCS1_N,out,SPI_IBMC_BT_CS1_N_R,chip select to secondary boot SPI flash +U21,ROMD4_GPIOS0_VPODE,Out,BMC_SPI_WP_N,Write protect for Secondary Boot Flash. Connected to CPLD. CPLD will drive it to the flash chip +C21,GPIOY0_SIOS3_N,In,BOARD_REV_ID0,"Board ID input bit0, resister straping, connect to both BMC and CPLD" +F20,GPIOY1_SIOS5_N,In,BOARD_REV_ID1,"Board ID input bit1, resister straping, connect to both BMC and CPLD" +G20,GPIOY2_SIOPWREQ_N,In,BOARD_REV_ID2,"Board ID input bit2, resister straping, connect to both BMC and CPLD" diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py new file mode 100644 index 0000000..dd14763 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/openbmc_gpio_setup.py @@ -0,0 +1,75 @@ +#!/usr/bin/python -tt +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from board_gpio_rev_table import board_gpio_rev_table +from board_gpio_table_v1 import board_gpio_table_v1 +from board_gpio_table_v2 import board_gpio_table_v2 +from soc_gpio_table import soc_gpio_table +from openbmc_gpio_table import setup_board_gpio +from soc_gpio import soc_get_register + +import openbmc_gpio +import sys + +def set_register(): + ''' + For DVT/EVT boards the framework is not able to handle for GPIOS0 and + causes error : 'Failed to configure "GPIOS0" for "BMC_SPI_WP_N": + Not able to unsatisfy an AND condition'. In order to fix the error + set the specific bit in the register so the framework can handle it. + ''' + l_reg = soc_get_register(0x8C) + l_reg.clear_bit(0, write_through=True) + +def wedge_board_rev(soc_gpio_table, board_gpio_rev_table): + # Setup to read revision + setup_board_gpio(soc_gpio_table, board_gpio_rev_table) + # Read the gpio values + v0 = openbmc_gpio.gpio_get('BOARD_REV_ID0') + v1 = openbmc_gpio.gpio_get('BOARD_REV_ID1') + v2 = openbmc_gpio.gpio_get('BOARD_REV_ID2') + return ((v2 << 2) | (v1 << 1) | v0) + +def main(): + print('Setting up GPIOs ... ', end='') + sys.stdout.flush() + openbmc_gpio.setup_shadow() + version = wedge_board_rev(soc_gpio_table,board_gpio_rev_table) + # In order to satisy/unsatisfy conditions in setup_board_gpio() + # modify the registers + set_register() + if version is 1: + print('Using GPIO EVT table ', end='') + setup_board_gpio(soc_gpio_table, board_gpio_table_v1) + else: + if version is 2: + print('Using GPIO DVT table ', end='') + else: + print('Unexpected board version %s. Using GPIO DVT table. ' + % version, end='') + setup_board_gpio(soc_gpio_table, board_gpio_table_v2) + print('Done') + sys.stdout.flush() + return 0 + +if __name__ == '__main__': + sys.exit(main()) diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/setup_board.py b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/setup_board.py new file mode 100644 index 0000000..bb6ccb1 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/setup_board.py @@ -0,0 +1,22 @@ +# Copyright 2015-present Facebook. All rights reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +board_py_modules=[ + 'board_gpio_table_v1', + 'board_gpio_table_v2', + 'board_gpio_rev_table', +] diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/wedge100_gpio_parse.py b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/wedge100_gpio_parse.py new file mode 100644 index 0000000..b53f9de --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/files/wedge100_gpio_parse.py @@ -0,0 +1,102 @@ +#!/usr/bin/python -tt +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import argparse +import csv +import logging +import re +import sys + + +GPIO_SYMBOL = 'BoardGPIO' + + +class CsvReader: + ''' + A class for parsing the CSV files containing the board GPIO config + ''' + def __init__(self, path): + self.path = path + + fileobj = open(path, 'r') + self.reader = csv.reader(fileobj, delimiter=b',', quotechar=b'"') + + def next(self): + try: + line = self.reader.next() + except StopIteration: + return None + return line + + +class WedgeGPIO(object): + def __init__(self, data): + self.data = data + self.gpios = {} + self.names = set() + + def parse(self): + while True: + line = self.data.next() + if line is None: + break + + logging.debug('Parsing line: %s' % line) + + if len(line) < 4: + logging.error('No enough fields in "%s". Skip!' % line) + continue + + gpio = None + for part in line[1].split('_'): + if part.startswith('GPIO'): + gpio = part + break + if gpio is None: + logging.error('Cannot find GPIO file from "%s". Skip!' % line) + continue + + name = line[3] + assert gpio not in self.gpios and name not in self.names + self.gpios[gpio] = name + self.names.add(name) + + def print(self, out): + for gpio in sorted(self.gpios): + out.write(' %s(\'%s\', \'%s\'),\n' + % (GPIO_SYMBOL, gpio, self.gpios[gpio])) + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('data', help='The GPIO data file') + args = ap.parse_args() + + logging.basicConfig(level=logging.INFO, format='%(asctime)s: %(message)s') + + gpio = WedgeGPIO(CsvReader(args.data)) + gpio.parse() + gpio.print(sys.stdout) + + +rc = main() +sys.exit(rc) diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/openbmc-gpio_%.bbappend b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/openbmc-gpio_%.bbappend new file mode 100644 index 0000000..afc133a --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-gpio/openbmc-gpio_%.bbappend @@ -0,0 +1,36 @@ +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += " \ + file://board_gpio_table_v1.py \ + file://board_gpio_table_v2.py \ + file://board_gpio_rev_table.py \ + file://openbmc_gpio_setup.py \ + file://setup_board.py \ + " +OPENBMC_GPIO_SOC_TABLE = "ast2400_gpio_table.py" + +do_install_append() { + install -d ${D}${sysconfdir}/init.d + install -d ${D}${sysconfdir}/rcS.d + install -m 755 openbmc_gpio_setup.py ${D}${sysconfdir}/init.d/openbmc_gpio_setup.py + update-rc.d -r ${D} openbmc_gpio_setup.py start 59 S . +} + +FILES_${PN} += "/usr/local/bin ${sysconfdir}" diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/COPYING b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/COPYING new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/board-utils.sh b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/board-utils.sh new file mode 100644 index 0000000..a999a9c --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/board-utils.sh @@ -0,0 +1,81 @@ +# Copyright 2015-present Facebook. All Rights Reserved. + +SYSCPLD_SYSFS_DIR="/sys/class/i2c-adapter/i2c-12/12-0031" +PWR_MAIN_SYSFS="${SYSCPLD_SYSFS_DIR}/pwr_main_n" +PWR_USRV_SYSFS="${SYSCPLD_SYSFS_DIR}/pwr_usrv_en" +PWR_USRV_BTN_SYSFS="${SYSCPLD_SYSFS_DIR}/pwr_usrv_btn_en" +SLOTID_SYSFS="${SYSCPLD_SYSFS_DIR}/slotid" + +wedge_iso_buf_enable() { + # TODO, no isolation buffer + return 0 +} + +wedge_iso_buf_disable() { + # TODO, no isolation buffer + return 0 +} + +wedge_is_us_on() { + local val n retries prog + if [ $# -gt 0 ]; then + retries="$1" + else + retries=1 + fi + if [ $# -gt 1 ]; then + prog="$2" + else + prog="" + fi + if [ $# -gt 2 ]; then + default=$3 # value 0 means defaul is 'ON' + else + default=1 + fi + val=$(cat $PWR_USRV_SYSFS 2> /dev/null | head -n 1) + if [ -z "$val" ]; then + return $default + elif [ "$val" == "0x1" ]; then + return 0 # powered on + else + return 1 + fi +} + +wedge_board_type() { + echo 'WEDGE100' +} + +wedge_slot_id() { + printf "%d\n" $(cat $SLOTID_SYSFS) +} + +wedge_board_rev() { + local val0 val1 val2 + val0=$(gpio_get BOARD_REV_ID0) + val1=$(gpio_get BOARD_REV_ID1) + val2=$(gpio_get BOARD_REV_ID2) + echo $((val0 | (val1 << 1) | (val2 << 2))) +} + +# Should we enable OOB interface or not +wedge_should_enable_oob() { + # wedge100 uses BMC MAC since beginning + return -1 +} + +wedge_power_on_board() { + local val + # power on main power, uServer power, and enable power button + val=$(cat $PWR_MAIN_SYSFS | head -n 1) + if [ "$val" != "0x1" ]; then + echo 1 > $PWR_MAIN_SYSFS + sleep 2 + fi + val=$(cat $PWR_USRV_BTN_SYSFS | head -n 1) + if [ "$val" != "0x1" ]; then + echo 1 > $PWR_USRV_BTN_SYSFS + sleep 1 + fi +} diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/disable_watchdog.sh b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/disable_watchdog.sh new file mode 100644 index 0000000..07826d6 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/disable_watchdog.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +. /usr/local/bin/openbmc-utils.sh + +# Disable the dual boot watch dog +devmem_clear_bit 0x1e78502c 0 diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/power-on.sh b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/power-on.sh new file mode 100644 index 0000000..1f22dcf --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/power-on.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +### BEGIN INIT INFO +# Provides: power-on +# Required-Start: +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Power on micro-server +### END INIT INFO +. /usr/local/bin/openbmc-utils.sh + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin + +# make power button high to prepare for power on sequence +gpio_set BMC_PWR_BTN_OUT_N 1 + +# First power on TH, and if Panther+ is used, +# provide standby power to Panther+. +wedge_power_on_board + +echo -n "Checking microserver power status ... " +if wedge_is_us_on 10 "."; then + echo "on" + on=1 +else + echo "off" + on=0 +fi + +if [ $on -eq 0 ]; then + # Power on now + wedge_power.sh on -f +fi diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_power.sh b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_power.sh new file mode 100644 index 0000000..0ad93e6 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_power.sh @@ -0,0 +1,187 @@ +#!/bin/bash +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +. /usr/local/bin/openbmc-utils.sh + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin + +prog="$0" + +PWR_BTN_GPIO="BMC_PWR_BTN_OUT_N" +PWR_SYSTEM_SYSFS="${SYSCPLD_SYSFS_DIR}/pwr_cyc_all_n" +PWR_USRV_RST_SYSFS="${SYSCPLD_SYSFS_DIR}/usrv_rst_n" + +usage() { + echo "Usage: $prog <command> [command options]" + echo + echo "Commands:" + echo " status: Get the current microserver power status" + echo + echo " on: Power on microserver if not powered on already" + echo " options:" + echo " -f: Re-do power on sequence no matter if microserver has " + echo " been powered on or not." + echo + echo " off: Power off microserver ungracefully" + echo + echo " reset: Power reset microserver ungracefully" + echo " options:" + echo " -s: Power reset whole wedge system ungracefully" + echo +} + +do_status() { + echo -n "Microserver power is " + if wedge_is_us_on; then + echo "on" + else + echo "off" + fi + return 0 +} + +do_on_com_e() { + echo 1 > $PWR_USRV_SYSFS + return $? +} + +do_on() { + local force opt ret + force=0 + while getopts "f" opt; do + case $opt in + f) + force=1 + ;; + *) + usage + exit -1 + ;; + + esac + done + echo -n "Power on microserver ..." + if [ $force -eq 0 ]; then + # need to check if uS is on or not + if wedge_is_us_on 10 "."; then + echo " Already on. Skip!" + return 1 + fi + fi + + # power on sequence + do_on_com_e + ret=$? + if [ $ret -eq 0 ]; then + echo " Done" + else + echo " Failed" + fi + return $ret +} + +do_off_com_e() { + echo 0 > $PWR_USRV_SYSFS + return $? +} + +do_off() { + local ret + echo -n "Power off microserver ..." + do_off_com_e + ret=$? + if [ $ret -eq 0 ]; then + echo " Done" + else + echo " Failed" + fi + return $ret +} + +do_reset() { + local system opt pulse_us + system=0 + while getopts "s" opt; do + case $opt in + s) + system=1 + ;; + *) + usage + exit -1 + ;; + esac + done + if [ $system -eq 1 ]; then + pulse_us=100000 # 100ms + echo -n "Power reset whole system ..." + sleep 1 + echo 0 > $PWR_SYSTEM_SYSFS + # Echo 0 above should work already. However, after CPLD upgrade, + # We need to re-generate the pulse to make this work + usleep $pulse_us + echo 1 > $PWR_SYSTEM_SYSFS + usleep $pulse_us + echo 0 > $PWR_SYSTEM_SYSFS + usleep $pulse_us + echo 1 > $PWR_SYSTEM_SYSFS + else + if ! wedge_is_us_on; then + echo "Power resetting microserver that is powered off has no effect." + echo "Use '$prog on' to power the microserver on" + return -1 + fi + echo -n "Power reset microserver ..." + echo 0 > $PWR_USRV_RST_SYSFS + sleep 1 + echo 1 > $PWR_USRV_RST_SYSFS + fi + echo " Done" + return 0 +} + +if [ $# -lt 1 ]; then + usage + exit -1 +fi + +command="$1" +shift + +case "$command" in + status) + do_status $@ + ;; + on) + do_on $@ + ;; + off) + do_off $@ + ;; + reset) + do_reset $@ + ;; + *) + usage + exit -1 + ;; +esac + +exit $? diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_us_mac.sh b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_us_mac.sh new file mode 100644 index 0000000..8ad2fec --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_us_mac.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin + +. /usr/local/bin/openbmc-utils.sh + +if ! wedge_is_us_on; then + echo "Cannot retrive microserver MAC when microserver is powered off." 1>&2 + exit -2 +fi + +mac=$(i2cdump -f -y 0x4 0x33 b 2> /dev/null | grep '^50: '| awk '{ printf "%s:%s:%s:%s:%s:%s\n", $2, $3, $4, $5, $6, $7 }') + +if [ -n "$mac" -a "${mac/X/}" = "${mac}" ]; then + echo $mac + exit 0 +else + echo "Cannot find out the microserver MAC" 1>&2 + exit -1 +fi diff --git a/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/openbmc-utils_%.bbappend b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/openbmc-utils_%.bbappend new file mode 100644 index 0000000..87db374 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/openbmc-utils_%.bbappend @@ -0,0 +1,64 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://disable_watchdog.sh \ + file://board-utils.sh \ + " + +OPENBMC_UTILS_FILES += " \ + disable_watchdog.sh \ + " + +DEPENDS_append = " update-rc.d-native" + +do_install_board() { + # for backward compatible, create /usr/local/fbpackages/utils/ast-functions + olddir="/usr/local/fbpackages/utils" + install -d ${D}${olddir} + ln -s "/usr/local/bin/openbmc-utils.sh" "${D}${olddir}/ast-functions" + + # common lib and include files + install -d ${D}${includedir}/facebook + install -m 0644 src/include/i2c-dev.h ${D}${includedir}/facebook/i2c-dev.h + + # init + install -d ${D}${sysconfdir}/init.d + install -d ${D}${sysconfdir}/rcS.d + # the script to mount /mnt/data + install -m 0755 ${WORKDIR}/mount_data0.sh ${D}${sysconfdir}/init.d/mount_data0.sh + update-rc.d -r ${D} mount_data0.sh start 03 S . + install -m 0755 ${WORKDIR}/rc.early ${D}${sysconfdir}/init.d/rc.early + update-rc.d -r ${D} rc.early start 04 S . + + # networking is done after rcS, any start level within rcS + # for mac fixup should work + install -m 755 eth0_mac_fixup.sh ${D}${sysconfdir}/init.d/eth0_mac_fixup.sh + update-rc.d -r ${D} eth0_mac_fixup.sh start 70 S . + + install -m 755 power-on.sh ${D}${sysconfdir}/init.d/power-on.sh + update-rc.d -r ${D} power-on.sh start 85 S . + + install -m 0755 ${WORKDIR}/rc.local ${D}${sysconfdir}/init.d/rc.local + update-rc.d -r ${D} rc.local start 99 2 3 4 5 . + + install -m 0755 ${WORKDIR}/disable_watchdog.sh ${D}${sysconfdir}/init.d/disable_watchdog.sh + update-rc.d -r ${D} disable_watchdog.sh start 99 2 3 4 5 . +} + +FILES_${PN} += "${sysconfdir}" diff --git a/meta-facebook/meta-wedge100/recipes-utils/wedge-eeprom/libwedge-eeprom_0.1.bbappend b/meta-facebook/meta-wedge100/recipes-utils/wedge-eeprom/libwedge-eeprom_0.1.bbappend new file mode 100644 index 0000000..bb2fba7 --- /dev/null +++ b/meta-facebook/meta-wedge100/recipes-utils/wedge-eeprom/libwedge-eeprom_0.1.bbappend @@ -0,0 +1,18 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file 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; version 2 of the License. +# +# 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 in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +CFLAGS_prepend = "-DFBW_EEPROM_FILE=\\"/sys/class/i2c-adapter/i2c-6/6-0051/eeprom\\" " diff --git a/meta-facebook/meta-yosemite/conf/bblayers.conf.sample b/meta-facebook/meta-yosemite/conf/bblayers.conf.sample index 8827e9d..6c7c0c9 100644 --- a/meta-facebook/meta-yosemite/conf/bblayers.conf.sample +++ b/meta-facebook/meta-yosemite/conf/bblayers.conf.sample @@ -11,6 +11,7 @@ BBLAYERS ?= " \ ##OEROOT##/meta-yocto-bsp \ ##OEROOT##/meta-openembedded/meta-oe \ ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-python \ ##OEROOT##/meta-openbmc \ ##OEROOT##/meta-openbmc/meta-aspeed \ ##OEROOT##/meta-openbmc/meta-facebook/meta-yosemite \ diff --git a/meta-facebook/meta-yosemite/conf/local.conf.sample b/meta-facebook/meta-yosemite/conf/local.conf.sample index 9204236..6da6659 100644 --- a/meta-facebook/meta-yosemite/conf/local.conf.sample +++ b/meta-facebook/meta-yosemite/conf/local.conf.sample @@ -138,3 +138,8 @@ EXTRA_USERS_PARAMS = " \ usermod -s /bin/bash root; \ usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \ " + +OLDEST_KERNEL = "2.6.28" + +INHERIT += "blacklist" +PNBLACKLIST[glibc] = "glibc 2.21 does not work with our kernel 2.6.28" diff --git a/meta-facebook/meta-yosemite/conf/machine/yosemite.conf b/meta-facebook/meta-yosemite/conf/machine/yosemite.conf index cd48ed6..99d6caa 100644 --- a/meta-facebook/meta-yosemite/conf/machine/yosemite.conf +++ b/meta-facebook/meta-yosemite/conf/machine/yosemite.conf @@ -5,3 +5,5 @@ UBOOT_MACHINE_yosemite = "fbyosemite_config" require conf/machine/include/ast1250.inc + +TCLIBC = 'eglibc' diff --git a/meta-facebook/meta-yosemite/recipes-core/busybox/busybox/syslog.conf b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox/syslog.conf new file mode 100644 index 0000000..f033341 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox/syslog.conf @@ -0,0 +1,5 @@ +# /etc/syslog.conf Configuration file for busybox's syslogd utility +# Send emergency messages to the console +*.crit /mnt/data/logfile +# Store everything else +*.* /var/log/messages diff --git a/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend index b8641ee..0047f92 100644 --- a/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend +++ b/meta-facebook/meta-yosemite/recipes-core/busybox/busybox_%.bbappend @@ -2,4 +2,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += " \ file://busybox.cfg \ - "
\ No newline at end of file + file://syslog.conf \ + " diff --git a/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc b/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc index 5356c20..e316aa0 100644 --- a/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc +++ b/meta-facebook/meta-yosemite/recipes-core/images/yosemite-image.inc @@ -39,7 +39,9 @@ NTP_PKGS = " \ # Include modules in rootfs IMAGE_INSTALL += " \ kernel-modules \ + u-boot \ u-boot-fw-utils \ + healthd \ fbutils \ fan-ctrl \ watchdog-ctrl \ @@ -66,6 +68,13 @@ IMAGE_INSTALL += " \ power-util \ consoled \ cfg-util \ + fw-util \ + fpc-util \ + me-util \ + log-util \ + cherryPy \ + lldp-util \ + spatula \ " IMAGE_FEATURES += " \ diff --git a/meta-facebook/meta-yosemite/recipes-kernel/linux/files/defconfig b/meta-facebook/meta-yosemite/recipes-kernel/linux/files/defconfig new file mode 100644 index 0000000..d32f18e --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-kernel/linux/files/defconfig @@ -0,0 +1,1480 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.28.9 +# Tue Feb 3 16:41:40 2015 +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_TIME=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_MMU=y +# CONFIG_NO_IOPORT is not set +CONFIG_GENERIC_HARDIRQS=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_HAVE_LATENCYTOP_SUPPORT=y +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_ARCH_HAS_ILOG2_U32 is not set +# CONFIG_ARCH_HAS_ILOG2_U64 is not set +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y +CONFIG_VECTORS_BASE=0xffff0000 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set +CONFIG_IKCONFIG=m +CONFIG_IKCONFIG_PROC=y +CONFIG_LOG_BUF_SHIFT=16 +# CONFIG_CGROUPS is not set +# CONFIG_GROUP_SCHED is not set +CONFIG_SYSFS_DEPRECATED=y +CONFIG_SYSFS_DEPRECATED_V2=y +# CONFIG_RELAY is not set +CONFIG_NAMESPACES=y +# CONFIG_UTS_NS is not set +# CONFIG_IPC_NS is not set +# CONFIG_USER_NS is not set +# CONFIG_PID_NS is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +# CONFIG_EMBEDDED is not set +CONFIG_UID16=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_EXTRA_PASS=y +CONFIG_HOTPLUG=y +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +CONFIG_COMPAT_BRK=y +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +# CONFIG_PROFILING is not set +# CONFIG_MARKERS is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_KMOD=y +CONFIG_BLOCK=y +# CONFIG_LBD is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_LSF is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_INTEGRITY is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_DEFAULT_AS is not set +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_CLASSIC_RCU=y +CONFIG_FREEZER=y + +# +# System Type +# +CONFIG_ARCH_ASPEED=y +# CONFIG_ARCH_AAEC2000 is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_CLPS7500 is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_EBSA110 is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_FOOTBRIDGE is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X is not set +# CONFIG_ARCH_IMX is not set +# CONFIG_ARCH_IOP13XX is not set +# CONFIG_ARCH_IOP32X is not set +# CONFIG_ARCH_IOP33X is not set +# CONFIG_ARCH_IXP23XX is not set +# CONFIG_ARCH_IXP2000 is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_L7200 is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_KS8695 is not set +# CONFIG_ARCH_NS9XXX is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_MV78XX0 is not set +# CONFIG_ARCH_MXC is not set +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_S3C2410 is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_LH7A40X is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_MSM is not set +CONFIG_IRMP=y +# CONFIG_PCEXT is not set +# CONFIG_REMOTEFX is not set +# CONFIG_ARCH_AST1100 is not set +# CONFIG_ARCH_AST2100 is not set +# CONFIG_ARCH_AST2200 is not set +# CONFIG_ARCH_AST2300 is not set +CONFIG_ARCH_AST2400=y +CONFIG_YOSEMITE=y +# CONFIG_ARCH_AST2500 is not set + +# +# FLASH Chip Select +# +# CONFIG_AST_CS0_NOR is not set +# CONFIG_AST_CS0_NAND is not set +CONFIG_AST_CS0_SPI=y +# CONFIG_AST_CS0_NONE is not set +# CONFIG_AST_CS1_NOR is not set +# CONFIG_AST_CS1_NAND is not set +# CONFIG_AST_CS1_SPI is not set +CONFIG_AST_CS1_NONE=y +# CONFIG_AST_CS2_NOR is not set +# CONFIG_AST_CS2_NAND is not set +# CONFIG_AST_CS2_SPI is not set +CONFIG_AST_CS2_NONE=y +# CONFIG_AST_CS3_NOR is not set +# CONFIG_AST_CS3_NAND is not set +# CONFIG_AST_CS3_SPI is not set +CONFIG_AST_CS3_NONE=y +# CONFIG_AST_CS4_NOR is not set +# CONFIG_AST_CS4_NAND is not set +# CONFIG_AST_CS4_SPI is not set +CONFIG_AST_CS4_NONE=y +# CONFIG_ARCH_AST1070 is not set +# CONFIG_AST_SCU_LOCK is not set + +# +# Boot options +# + +# +# Power management +# +CONFIG_PLAT_ASPEED=y + +# +# Processor Type +# +CONFIG_CPU_32=y +CONFIG_CPU_ARM926T=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_PABRT_NOIFAR=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y + +# +# Processor Features +# +CONFIG_ARM_THUMB=y +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +# CONFIG_OUTER_CACHE is not set + +# +# Bus support +# +CONFIG_ARM_AMBA=y +# CONFIG_PCI_SYSCALL is not set +# CONFIG_ARCH_SUPPORTS_MSI is not set +# CONFIG_PCCARD is not set + +# +# Kernel Features +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set +CONFIG_PAGE_OFFSET=0xC0000000 +# CONFIG_PREEMPT is not set +CONFIG_HZ=100 +CONFIG_AEABI=y +CONFIG_OABI_COMPAT=y +CONFIG_ARCH_FLATMEM_HAS_HOLES=y +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4096 +# CONFIG_RESOURCES_64BIT is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=0 +CONFIG_VIRT_TO_BUS=y +CONFIG_UNEVICTABLE_LRU=y +CONFIG_ALIGNMENT_TRAP=y + +# +# Boot options +# +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_CMDLINE="" +# CONFIG_XIP_KERNEL is not set +# CONFIG_KEXEC is not set + +# +# CPU Power Management +# +# CONFIG_CPU_IDLE is not set + +# +# Floating point emulation +# + +# +# At least one emulation must be selected +# +CONFIG_FPE_NWFPE=y +CONFIG_FPE_NWFPE_XP=y +# CONFIG_FPE_FASTFPE is not set +CONFIG_VFP=y + +# +# Userspace binary formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_HAVE_AOUT=y +CONFIG_BINFMT_AOUT=y +# CONFIG_BINFMT_MISC is not set + +# +# Power management options +# +CONFIG_PM=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_SLEEP=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_APM_EMULATION is not set +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +# CONFIG_XFRM_USER is not set +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_XFRM_MODE_TRANSPORT=y +CONFIG_INET_XFRM_MODE_TUNNEL=y +CONFIG_INET_XFRM_MODE_BEET=y +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_TCP_MD5SIG is not set +CONFIG_IPV6=m +# CONFIG_IPV6_PRIVACY is not set +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_XFRM_MODE_TRANSPORT=m +CONFIG_INET6_XFRM_MODE_TUNNEL=m +CONFIG_INET6_XFRM_MODE_BEET=m +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +CONFIG_IPV6_SIT=m +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_NET_DSA is not set +CONFIG_VLAN_8021Q=m +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=y +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_PHONET is not set +# CONFIG_WIRELESS is not set +# CONFIG_RFKILL is not set +# CONFIG_NET_9P is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_SYS_HYPERVISOR is not set +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +CONFIG_MTD=y +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y +# CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y +# CONFIG_MTD_AFS_PARTS is not set +# CONFIG_MTD_AR7_PARTS is not set + +# +# User Modules And Translation Layers +# +CONFIG_MTD_CHAR=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_FTL is not set +# CONFIG_NFTL is not set +# CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set +# CONFIG_SSFDC is not set +# CONFIG_MTD_OOPS is not set + +# +# RAM/ROM/Flash chip drivers +# +# CONFIG_MTD_CFI is not set +# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +CONFIG_MTD_MAP_BANK_WIDTH_2=y +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_ROM is not set +# CONFIG_MTD_ABSENT is not set + +# +# Mapping drivers for chip access +# +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PLATRAM is not set + +# +# Self-contained MTD device drivers +# +CONFIG_MTD_DATAFLASH=m +CONFIG_MTD_DATAFLASH_WRITE_VERIFY=y +# CONFIG_MTD_DATAFLASH_OTP is not set +CONFIG_MTD_M25P80=y +CONFIG_M25PXX_USE_FAST_READ=y +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLOCK2MTD is not set + +# +# Disk-On-Chip Device Drivers +# +# CONFIG_MTD_DOC2000 is not set +# CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set +# CONFIG_MTD_NAND is not set +# CONFIG_MTD_ONENAND is not set + +# +# UBI - Unsorted block images +# +# CONFIG_MTD_UBI is not set +# CONFIG_PARPORT is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=y +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_BLK_DEV_XIP is not set +# CONFIG_RD_BZIP2 is not set +CONFIG_RD_LZMA=y +CONFIG_RD_GZIP=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_MISC_DEVICES=y +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_C2PORT is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_TGT=y +# CONFIG_SCSI_NETLINK is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set +CONFIG_SCSI_SCAN_ASYNC=y +CONFIG_SCSI_WAIT_SCAN=m + +# +# SCSI Transports +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_DH is not set +# CONFIG_ATA is not set +# CONFIG_MD is not set +CONFIG_NETDEVICES=y +# CONFIG_DUMMY is not set +CONFIG_BONDING=m +# CONFIG_MACVLAN is not set +# CONFIG_EQUALIZER is not set +CONFIG_TUN=m +# CONFIG_VETH is not set +# CONFIG_NET_ETHERNET is not set +CONFIG_NETDEV_1000=y +CONFIG_ASPEEDMAC=y +# CONFIG_NETDEV_10000 is not set + +# +# Wireless LAN +# +# CONFIG_WLAN_PRE80211 is not set +# CONFIG_WLAN_80211 is not set +# CONFIG_IWLWIFI_LEDS is not set + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_ISDN is not set + +# +# Input device support +# +CONFIG_INPUT=y +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_GPIO is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_ELANTECH is not set +# CONFIG_MOUSE_PS2_TOUCHKIT is not set +CONFIG_MOUSE_SERIAL=y +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_AMBAKMI is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_VT_HW_CONSOLE_BINDING is not set +CONFIG_DEVKMEM=y +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_N_HDLC is not set +# CONFIG_RISCOM8 is not set +# CONFIG_SPECIALIX is not set +# CONFIG_RIO is not set +# CONFIG_STALDRV is not set + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=5 +CONFIG_SERIAL_8250_RUNTIME_UARTS=5 +# CONFIG_SERIAL_AST_DMA_UART is not set +# CONFIG_SERIAL_8250_EXTENDED is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_AMBA_PL010 is not set +# CONFIG_SERIAL_AMBA_PL011 is not set +# CONFIG_SERIAL_AST is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +# CONFIG_IPMI_HANDLER is not set +CONFIG_AST_MISC=y +# CONFIG_AST_VIDEO is not set +# CONFIG_ADC_CAT9883 is not set +# CONFIG_AST_SPI_BIOS is not set +CONFIG_AST_PECI=y +# CONFIG_AST_KCS is not set +# CONFIG_AST_GPIO is not set +# CONFIG_HW_RANDOM is not set +CONFIG_NVRAM=y +# CONFIG_R3964 is not set +# CONFIG_RAW_DRIVER is not set +# CONFIG_TCG_TPM is not set +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_HELPER_AUTO=y + +# +# I2C Hardware Bus support +# + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +CONFIG_I2C_AST=y +CONFIG_AST_I2C_SLAVE_MODE=y +# CONFIG_AST_I2C_SLAVE_EEPROM is not set +CONFIG_AST_I2C_SLAVE_RDWR=y +# CONFIG_I2C_SIMTEC is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_STUB is not set + +# +# Miscellaneous I2C Chip support +# +# CONFIG_DS1682 is not set +CONFIG_AT24=m +# CONFIG_SENSORS_EEPROM is not set +CONFIG_SENSORS_PCF8574=m +# CONFIG_PCF8575 is not set +# CONFIG_SENSORS_PCA9539 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_TPS65010 is not set +# CONFIG_SENSORS_MAX6875 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +CONFIG_SPI_AST=y +CONFIG_SPI_FMC=y +CONFIG_SPI_BITBANG=y + +# +# SPI Protocol Masters +# +CONFIG_SPI_AT25=m +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_TLE62X0 is not set +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO expanders: +# + +# +# I2C GPIO expanders: +# +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set + +# +# PCI GPIO expanders: +# + +# +# SPI GPIO expanders: +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MCP23S08 is not set +# CONFIG_W1 is not set +# CONFIG_POWER_SUPPLY is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7473 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +CONFIG_SENSORS_LM75=m +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +CONFIG_SENSORS_MAX127=m +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +CONFIG_SENSORS_ADS7828=m +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +CONFIG_SENSORS_AST_ADC=y +CONFIG_SENSORS_AST_PWM_FAN=y +# CONFIG_SENSORS_FB_PANTHER_PLUS is not set +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_SENSORS_ADM1275=m +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX8688 is not set +CONFIG_SENSORS_PFE1100=m +CONFIG_SENSORS_PFE3000=m +# CONFIG_SENSORS_UCD9000 is not set +# CONFIG_SENSORS_UCD9200 is not set +# CONFIG_SENSORS_ZL6100 is not set +# CONFIG_HWMON_DEBUG_CHIP is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +CONFIG_AST_WATCHDOG=y + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_ASIC3 is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_TC6393XB is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM8350_I2C is not set + +# +# Multimedia devices +# + +# +# Multimedia core support +# +# CONFIG_VIDEO_DEV is not set +# CONFIG_DVB_CORE is not set +# CONFIG_VIDEO_MEDIA is not set + +# +# Multimedia drivers +# +# CONFIG_DAB is not set + +# +# Graphics support +# +# CONFIG_VGASTATE is not set +# CONFIG_VIDEO_OUTPUT_CONTROL is not set +# CONFIG_FB is not set +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set + +# +# Display device support +# +# CONFIG_DISPLAY_SUPPORT is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y +# CONFIG_SOUND is not set +# CONFIG_HID_SUPPORT is not set +CONFIG_USB_SUPPORT=y +CONFIG_USB_ARCH_HAS_HCD=y +# CONFIG_USB_ARCH_HAS_OHCI is not set +CONFIG_USB_ARCH_HAS_EHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_SUSPEND is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_EHCI_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HWA_HCD is not set + +# +# AST USB Drivers +# +CONFIG_AST_USB_UHCI_HCD=y +# CONFIG_AST_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_AST_USB_UHCI_MULTIPORT_2 is not set +CONFIG_AST_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_EHCI_SPLIT_ISO is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; +# + +# +# see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +# CONFIG_USB_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_LIBUSUAL is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB port drivers +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_BERRY_CHARGE is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_PHIDGET is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_VST is not set +CONFIG_USB_GADGET=y +# CONFIG_USB_GADGET_DEBUG_FILES is not set +CONFIG_USB_GADGET_VBUS_DRAW=2 +CONFIG_USB_GADGET_SELECTED=y +# CONFIG_USB_GADGET_AT91 is not set +# CONFIG_USB_GADGET_ATMEL_USBA is not set +# CONFIG_USB_GADGET_FSL_USB2 is not set +# CONFIG_USB_GADGET_LH7A40X is not set +# CONFIG_USB_GADGET_OMAP is not set +# CONFIG_USB_GADGET_PXA25X is not set +# CONFIG_USB_GADGET_PXA27X is not set +# CONFIG_USB_GADGET_S3C2410 is not set +# CONFIG_USB_GADGET_M66592 is not set +# CONFIG_USB_GADGET_AMD5536UDC is not set +# CONFIG_USB_GADGET_FSL_QE is not set +# CONFIG_USB_GADGET_NET2280 is not set +# CONFIG_USB_GADGET_GOKU is not set +CONFIG_USB_GADGET_ASPEED_AST=y +CONFIG_USB_ASPEED_AST=y +# CONFIG_USB_GADGET_DUMMY_HCD is not set +CONFIG_USB_GADGET_DUALSPEED=y +CONFIG_USB_ZERO=m +CONFIG_USB_ETH=m +CONFIG_USB_ETH_RNDIS=y +CONFIG_USB_GADGETFS=m +CONFIG_USB_FILE_STORAGE=m +# CONFIG_USB_FILE_STORAGE_TEST is not set +CONFIG_USB_G_SERIAL=m +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_G_PRINTER is not set +CONFIG_USB_CDC_COMPOSITE=m +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_NEW_LEDS is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_HCTOSYS is not set +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8581 is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_DS3234 is not set + +# +# Platform RTC drivers +# +# CONFIG_RTC_DRV_CMOS is not set +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_V3020 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PL030 is not set +# CONFIG_RTC_DRV_PL031 is not set +CONFIG_RTC_DRV_ASPEED=y +# CONFIG_DMADEVICES is not set +# CONFIG_REGULATOR is not set +# CONFIG_UIO is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_EXT4_FS is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_FILE_LOCKING=y +# CONFIG_XFS_FS is not set +# CONFIG_OCFS2_FS is not set +CONFIG_DNOTIFY=y +CONFIG_INOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set +CONFIG_GENERIC_ACL=y + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NTFS_FS=y +# CONFIG_NTFS_DEBUG is not set +CONFIG_NTFS_RW=y + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_CONFIGFS_FS=m + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_YAFFS_FS=y +CONFIG_YAFFS_YAFFS1=y +# CONFIG_YAFFS_9BYTE_TAGS is not set +# CONFIG_YAFFS_DOES_ECC is not set +CONFIG_YAFFS_YAFFS2=y +CONFIG_YAFFS_AUTO_YAFFS2=y +# CONFIG_YAFFS_DISABLE_TAGS_ECC is not set +# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set +# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set +# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set +CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y +# CONFIG_YAFFS_EMPTY_LOST_AND_FOUND is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +# CONFIG_JFFS2_SUMMARY is not set +# CONFIG_JFFS2_FS_XATTR is not set +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set +CONFIG_JFFS2_ZLIB=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set +# CONFIG_NFS_V4 is not set +CONFIG_ROOT_NFS=y +# CONFIG_NFSD is not set +CONFIG_LOCKD=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_SUNRPC_REGISTER_V4 is not set +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +CONFIG_NLS_UTF8=y +# CONFIG_DLM is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_KERNEL is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_FRAME_POINTER=y +# CONFIG_RCU_CPU_STALL_DETECTOR is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_SYSCTL_SYSCALL_CHECK is not set +CONFIG_HAVE_FUNCTION_TRACER=y + +# +# Tracers +# +# CONFIG_DYNAMIC_PRINTK_DEBUG is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_DEBUG_USER is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_FILE_CAPABILITIES is not set +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=m +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_GF128MUL is not set +CONFIG_CRYPTO_NULL=y +# CONFIG_CRYPTO_CRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_SEQIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +# CONFIG_CRYPTO_CTR is not set +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set + +# +# Hash modes +# +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set + +# +# Digest +# +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set + +# +# Ciphers +# +# CONFIG_CRYPTO_AES is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set + +# +# Compression +# +CONFIG_CRYPTO_DEFLATE=m +# CONFIG_CRYPTO_LZO is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +# CONFIG_CRC_T10DIF is not set +CONFIG_CRC_ITU_T=m +CONFIG_CRC32=y +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_PLIST=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_DMA=y + + +# GUC USB Drivers +# +CONFIG_GUC_USB_UHCI_HCD=m +# CONFIG_GUC_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_GUC_USB_UHCI_MULTIPORT_2 is not set +CONFIG_GUC_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_GADGET_MUSB_HDRC is not set diff --git a/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend b/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend index a317986..846b197 100644 --- a/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend +++ b/meta-facebook/meta-yosemite/recipes-kernel/linux/linux-aspeed_2.6%.bbappend @@ -2,4 +2,7 @@ LINUX_VERSION_EXTENSION = "-yosemite" COMPATIBLE_MACHINE = "yosemite" -KERNEL_CONFIG_COMMAND = "oe_runmake yosemite_defconfig && oe_runmake oldconfig" +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://defconfig \ + " diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb index ef7a15c..010e8cf 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/bic-cached_0.1.bb @@ -31,7 +31,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-bic-cached.sh ${D}${sysconfdir}/init.d/setup-bic-cached.sh - update-rc.d -r ${D} setup-bic-cached.sh start 66 S . + update-rc.d -r ${D} setup-bic-cached.sh start 66 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c index 3a2dd28..78e443d 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/bic-cached/files/bic-cached.c @@ -49,7 +49,7 @@ fruid_cache_init(uint8_t slot_id) { ret = bic_read_fruid(slot_id, 0, fruid_temp_path); if (ret) { - syslog(LOG_ALERT, "fruid_cache_init: bic_read_fruid returns %d\n", ret); + syslog(LOG_WARNING, "fruid_cache_init: bic_read_fruid returns %d\n", ret); } rename(fruid_temp_path, fruid_path); @@ -83,14 +83,14 @@ sdr_cache_init(uint8_t slot_id) { unlink(path); fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd < 0) { - syslog(LOG_ALERT, "sdr_cache_init: open fails for path: %s\n", path); + syslog(LOG_WARNING, "sdr_cache_init: open fails for path: %s\n", path); return; } while (1) { ret = bic_get_sdr(slot_id, &req, res, &rlen); if (ret) { - syslog(LOG_ALERT, "sdr_cache_init:bic_get_sdr returns %d\n", ret); + syslog(LOG_WARNING, "sdr_cache_init:bic_get_sdr returns %d\n", ret); continue; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh index 49ef55b..7876619 100755 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl/set_fan_speed.sh @@ -37,14 +37,14 @@ fi # refer to the comments in init_pwn.sh regarding # the fan unit and PWM mapping if [ "$#" -eq 1 ]; then - PWMS="0:0 1:0" + PWMS="0:0 1:1" else case "$2" in "0") PWMS="0:0" ;; "1") - PWMS="1:0" + PWMS="1:1" ;; *) usage diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend index d5659ae..eb91d6c 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fan-ctrl/fan-ctrl_0.1.bbappend @@ -51,7 +51,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-fan.sh ${D}${sysconfdir}/init.d/setup-fan.sh - update-rc.d -r ${D} setup-fan.sh start 91 S . + update-rc.d -r ${D} setup-fan.sh start 91 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c index 55cd56b..4139b44 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.c @@ -22,10 +22,15 @@ #include <stdio.h> #include <stdint.h> #include <fcntl.h> +#include <syslog.h> #include "bic.h" #define FRUID_READ_COUNT_MAX 0x30 +#define FRUID_WRITE_COUNT_MAX 0x30 +#define CPLD_WRITE_COUNT_MAX 0x50 #define SDR_READ_COUNT_MAX 0x1A +#define SIZE_SYS_GUID 16 +#define SIZE_IANA_ID 3 enum { IPMB_BUS_SLOT1 = 3, @@ -87,7 +92,9 @@ bic_ipmb_wrapper(uint8_t slot_id, uint8_t netfn, uint8_t cmd, ret = get_ipmb_bus_id(slot_id); if (ret < 0) { - printf("bic_ipmb_wrapper: Wrong Slot ID %d\n", slot_id); +#ifdef DEBUG + syslog(LOG_ERR, "bic_ipmb_wrapper: Wrong Slot ID %d\n", slot_id); +#endif return ret; } @@ -114,8 +121,11 @@ bic_ipmb_wrapper(uint8_t slot_id, uint8_t netfn, uint8_t cmd, // Invoke IPMB library handler lib_ipmb_handle(bus_id, tbuf, tlen, &rbuf, &rlen); + if (rlen == 0) { - printf("bic_ipmb_wrapper: Zero bytes received\n"); +#ifdef DEBUG + syslog(LOG_DEBUG, "bic_ipmb_wrapper: Zero bytes received\n"); +#endif return -1; } @@ -123,7 +133,9 @@ bic_ipmb_wrapper(uint8_t slot_id, uint8_t netfn, uint8_t cmd, res = (ipmb_res_t*) rbuf; if (res->cc) { - printf("bic_ipmb_wrapper: Completion Code: 0x%X\n", res->cc); +#ifdef DEBUG + syslog(LOG_ERR, "bic_ipmb_wrapper: Completion Code: 0x%X\n", res->cc); +#endif return -1; } @@ -148,17 +160,23 @@ bic_get_dev_id(uint8_t slot_id, ipmi_dev_id_t *dev_id) { // Get GPIO value and configuration int bic_get_gpio(uint8_t slot_id, bic_gpio_t *gpio) { + uint8_t tbuf[3] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[7] = {0x00}; uint8_t rlen = 0; int ret; - ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO, NULL, 0, (uint8_t*) gpio, &rlen); + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO, tbuf, 0x03, rbuf, &rlen); + + // Ignore first 3 bytes of IANA ID + memcpy((uint8_t*) gpio, &rbuf[3], 4); return ret; } int bic_get_gpio_config(uint8_t slot_id, uint8_t gpio, bic_gpio_config_t *gpio_config) { - uint8_t tbuf[4] = {0}; + uint8_t tbuf[7] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[4] = {0x00}; uint8_t rlen = 0; uint8_t tlen = 0; uint32_t pin; @@ -166,75 +184,245 @@ bic_get_gpio_config(uint8_t slot_id, uint8_t gpio, bic_gpio_config_t *gpio_confi pin = 1 << gpio; - tbuf[0] = pin & 0xFF; - tbuf[1] = (pin >> 8) & 0xFF; - tbuf[2] = (pin >> 16) & 0xFF; - tbuf[3] = (pin >> 24) & 0xFF; + tbuf[3] = pin & 0xFF; + tbuf[4] = (pin >> 8) & 0xFF; + tbuf[5] = (pin >> 16) & 0xFF; + tbuf[6] = (pin >> 24) & 0xFF; - tlen = 4; + tlen = 7; - ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO_CONFIG, tbuf, tlen, (uint8_t *) gpio_config, &rlen); + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_GPIO_CONFIG, tbuf, tlen, rbuf, &rlen); + + // Ignore IANA ID + *(uint8_t *) gpio_config = rbuf[3]; return ret; } int bic_set_gpio_config(uint8_t slot_id, uint8_t gpio, bic_gpio_config_t *gpio_config) { - uint8_t tbuf[5] = {0}; + uint8_t tbuf[8] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[4] = {0x00}; uint8_t rlen = 0; uint8_t tlen = 0; uint32_t pin; - uint8_t res; int ret; pin = 1 << gpio; - tbuf[0] = pin & 0xFF; - tbuf[1] = (pin >> 8) & 0xFF; - tbuf[2] = (pin >> 16) & 0xFF; - tbuf[3] = (pin >> 24) & 0xFF; - tbuf[4] = (*(uint8_t *) gpio_config) & 0x1F; + tbuf[3] = pin & 0xFF; + tbuf[4] = (pin >> 8) & 0xFF; + tbuf[5] = (pin >> 16) & 0xFF; + tbuf[6] = (pin >> 24) & 0xFF; + tbuf[7] = (*(uint8_t *) gpio_config) & 0x1F; - tlen = 5; + tlen = 8; ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_SET_GPIO_CONFIG, - tbuf, tlen, &res, &rlen); + tbuf, tlen, rbuf, &rlen); return ret; } // Get BIC Configuration int bic_get_config(uint8_t slot_id, bic_config_t *cfg) { + uint8_t tbuf[3] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[4] = {0x00}; uint8_t rlen = 0; int ret; ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_CONFIG, - NULL, 0x00, (uint8_t *) cfg, &rlen); + tbuf, 0x03, rbuf, &rlen); + // Ignore IANA ID + *(uint8_t *) cfg = rbuf[3]; + return ret; } // Set BIC Configuration int bic_set_config(uint8_t slot_id, bic_config_t *cfg) { + uint8_t tbuf[4] = {0x15, 0xA0, 0x00}; // IANA ID uint8_t rlen = 0; uint8_t rbuf[4] = {0}; int ret; + tbuf[3] = *(uint8_t *) cfg; + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_SET_CONFIG, - (uint8_t *) cfg, 1, rbuf, &rlen); + tbuf, 0x04, rbuf, &rlen); return ret; } // Read POST Buffer int bic_get_post_buf(uint8_t slot_id, uint8_t *buf, uint8_t *len) { + uint8_t tbuf[3] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[255] = {0x00}; + uint8_t rlen = 0; + int ret; + + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_POST_BUF, tbuf, 0x03, rbuf, &rlen); + + //Ignore IANA ID + memcpy(buf, &rbuf[3], rlen-3); + + *len = rlen - 3; + + return ret; +} + +// Read Firwmare Versions of various components +int +bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver) { + uint8_t tbuf[4] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[16] = {0x00}; + uint8_t rlen = 0; int ret; - ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_POST_BUF, NULL, 0, buf, len); + // Fill the component for which firmware is requested + tbuf[3] = comp; + + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_GET_FW_VER, tbuf, 0x04, rbuf, &rlen); + // fw version has to be between 2 and 5 bytes based on component + if (ret || (rlen < 2+SIZE_IANA_ID) || (rlen > 5+SIZE_IANA_ID)) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_get_fw_ver: ret: %d, rlen: %d\n", ret, rlen); +#endif + return -1; + } + + //Ignore IANA ID + memcpy(ver, &rbuf[3], rlen-3); return ret; } +// Update firmware for various components +static int +_update_fw(uint8_t slot_id, uint8_t target, uint32_t offset, uint16_t len, uint8_t *buf) { + uint8_t tbuf[256] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[16] = {0x00}; + uint8_t tlen = 0; + uint8_t rlen = 0; + int ret; + int retries = 3; + + // Fill the component for which firmware is requested + tbuf[3] = target; + + tbuf[4] = (offset) & 0xFF; + tbuf[5] = (offset >> 8) & 0xFF; + tbuf[6] = (offset >> 16) & 0xFF; + tbuf[7] = (offset >> 24) & 0xFF; + + tbuf[8] = len & 0xFF; + tbuf[9] = (len >> 8) & 0xFF; + + memcpy(&tbuf[10], buf, len); + + printf("_update_fw: target: %d, offset: %d, len: %d\n", target, offset, len); + + tlen = len + 10; + +bic_send: + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_UPDATE_FW, tbuf, tlen, rbuf, &rlen); + if ((ret) && (retries--)) { + sleep(1); + printf("_update_fw: retrying..\n"); + goto bic_send; + } + + return ret; +} + +int +bic_update_fw(uint8_t slot_id, uint8_t comp, char *path) { + int ret; + uint32_t offset; + uint16_t count; + uint8_t buf[256] = {0}; + uint8_t len = 0; + uint8_t target; + int fd; + + // Open the file exclusively for read + fd = open(path, O_RDONLY, 0666); + if (fd < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_update_fw: open fails for path: %s\n", path); +#endif + goto error_exit; + } + + // Write chunks of CPLD binary data in a loop + offset = 0; + while (1) { + // Read from file + count = read(fd, buf, CPLD_WRITE_COUNT_MAX); + if (count <= 0) { + break; + } + + if (count == CPLD_WRITE_COUNT_MAX) { + target = comp; + } else { + target = comp | 0x80; + } + + // Write to the CPLD + ret = _update_fw(slot_id, target, offset, count, buf); + if (ret) { + break; + } + + // Update counter + offset += count; + } + +error_exit: + if (fd > 0 ) { + close(fd); + } + + return ret; +} + +int +bic_me_xmit(uint8_t slot_id, uint8_t *txbuf, uint8_t txlen, uint8_t *rxbuf, uint8_t *rxlen) { + uint8_t tbuf[256] = {0x15, 0xA0, 0x00}; // IANA ID + uint8_t rbuf[256] = {0x00}; + uint8_t rlen = 0; + uint8_t tlen = 0; + int ret; + + // Fill the interface number as ME + tbuf[3] = BIC_INTF_ME; + + // Fill the data to be sent + memcpy(&tbuf[4], txbuf, txlen); + + // Send data length includes IANA ID and interface number + tlen = txlen + 4; + + ret = bic_ipmb_wrapper(slot_id, NETFN_OEM_1S_REQ, CMD_OEM_1S_MSG_OUT, tbuf, tlen, rbuf, &rlen); + if (ret ) { + return -1; + } + + // Make sure the received interface number is same + if (rbuf[3] != tbuf[3]) { + return -1; + } + + // Copy the received data to caller skipping header + memcpy(rxbuf, &rbuf[7], rlen-7); + + *rxlen = rlen-7; + + return 0; +} + // Read 1S server's FRUID int bic_get_fruid_info(uint8_t slot_id, uint8_t fru_id, ipmi_fruid_info_t *info) { @@ -279,19 +467,23 @@ bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path) { // Open the file exclusively for write fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd < 0) { - printf("bic_read_fruid: open fails for path: %s\n", path); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_fruid: open fails for path: %s\n", path); +#endif goto error_exit; } // Read the FRUID information ret = bic_get_fruid_info(slot_id, fru_id, &info); if (ret) { - printf("bic_read_fruid: bic_read_fruid_info returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_fruid: bic_read_fruid_info returns %d\n", ret); +#endif goto error_exit; } // Indicates the size of the FRUID - nread = (info.size_msb << 8) + (info.size_lsb); + nread = (info.size_msb << 6) + (info.size_lsb); // Read chunks of FRUID binary data in a loop offset = 0; @@ -304,7 +496,9 @@ bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path) { ret = _read_fruid(slot_id, fru_id, offset, count, rbuf, &rlen); if (ret) { - printf("bic_read_fruid: ipmb_wrapper fails\n"); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_fruid: ipmb_wrapper fails\n"); +#endif goto error_exit; } @@ -324,6 +518,79 @@ error_exit: return ret; } +static int +_write_fruid(uint8_t slot_id, uint8_t fru_id, uint32_t offset, uint8_t count, uint8_t *buf) { + int ret; + uint8_t tbuf[64] = {0}; + uint8_t rbuf[4] = {0}; + uint8_t tlen = 0; + uint8_t rlen = 0; + + tbuf[0] = fru_id; + tbuf[1] = offset & 0xFF; + tbuf[2] = (offset >> 8) & 0xFF; + + memcpy(&tbuf[3], buf, count); + tlen = count + 3; + + ret = bic_ipmb_wrapper(slot_id, NETFN_STORAGE_REQ, CMD_STORAGE_WRITE_FRUID_DATA, tbuf, tlen, rbuf, &rlen); + + if (ret) { + return ret; + } + + if (rbuf[0] != count) { + return -1; + } + + return ret; +} + +int +bic_write_fruid(uint8_t slot_id, uint8_t fru_id, const char *path) { + int ret; + uint32_t offset; + uint8_t count; + uint8_t buf[64] = {0}; + uint8_t len = 0; + int fd; + + // Open the file exclusively for read + fd = open(path, O_RDONLY, 0666); + if (fd < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_write_fruid: open fails for path: %s\n", path); +#endif + goto error_exit; + } + + // Write chunks of FRUID binary data in a loop + offset = 0; + while (1) { + // Read from file + count = read(fd, buf, FRUID_WRITE_COUNT_MAX); + if (count <= 0) { + break; + } + + // Write to the FRUID + ret = _write_fruid(slot_id, fru_id, offset, count, buf); + if (ret) { + break; + } + + // Update counter + offset += count; + } + +error_exit: + if (fd > 0 ) { + close(fd); + } + + return ret; +} + // Read System Event Log (SEL) int bic_get_sel_info(uint8_t slot_id, ipmi_sel_sdr_info_t *info) { @@ -398,7 +665,9 @@ bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, u // Get SDR reservation ID for the given record ret = _get_sdr_rsv(slot_id, &req->rsv_id); if (ret) { - printf("bic_read_sdr: _get_sdr_rsv returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_sdr: _get_sdr_rsv returns %d\n", ret); +#endif return ret; } @@ -411,7 +680,9 @@ bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, u ret = _get_sdr(slot_id, req, tbuf, &tlen); if (ret) { - printf("bic_read_sdr: _get_sdr returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_sdr: _get_sdr returns %d\n", ret); +#endif return ret; } @@ -439,7 +710,9 @@ bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *res, u ret = _get_sdr(slot_id, req, tbuf, &tlen); if (ret) { - printf("bic_read_sdr: _get_sdr returns %d\n", ret); +#ifdef DEBUG + syslog(LOG_ERR, "bic_read_sdr: _get_sdr returns %d\n", ret); +#endif return ret; } @@ -464,3 +737,19 @@ bic_read_sensor(uint8_t slot_id, uint8_t sensor_num, ipmi_sensor_reading_t *sens return ret; } + +int +bic_get_sys_guid(uint8_t slot_id, uint8_t *guid) { + int ret; + int rlen = 0; + + ret = bic_ipmb_wrapper(slot_id, NETFN_APP_REQ, CMD_APP_GET_SYSTEM_GUID, NULL, 0, guid, &rlen); + if (rlen != SIZE_SYS_GUID) { +#ifdef DEBUG + syslog(LOG_ERR, "bic_get_sys_guid: returned rlen of %d\n"); +#endif + return -1; + } + + return ret; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h index 47b0baa..7110574 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/bic/bic.h @@ -66,6 +66,23 @@ enum { RESERVED_31, }; +enum { + FW_CPLD = 1, + FW_BIC, + FW_ME, + FW_PVCCIN_VR, + FW_DDRAB_VR, + FW_P1V05_VR, + FW_PVCCGBE_VR, + FW_PVCCSCSUS_VR, +}; + +enum { + UPDATE_BIOS = 0, + UPDATE_CPLD, + UPDATE_BIC_BOOT +}; + // Bridge IC Spec typedef struct _bic_gpio_t { uint32_t pwrgood_cpu:1; @@ -138,6 +155,7 @@ int bic_get_post_buf(uint8_t slot_id, uint8_t *buf, uint8_t *len); int bic_get_fruid_info(uint8_t slot_id, uint8_t fru_id, ipmi_fruid_info_t *info); int bic_read_fruid(uint8_t slot_id, uint8_t fru_id, const char *path); +int bic_write_fruid(uint8_t slot_id, uint8_t fru_id, const char *path); int bic_get_sel_info(uint8_t slot_id, ipmi_sel_sdr_info_t *info); int bic_get_sel_rsv(uint8_t slot_id, uint16_t *rsv); @@ -149,6 +167,13 @@ int bic_get_sdr(uint8_t slot_id, ipmi_sel_sdr_req_t *req, ipmi_sel_sdr_res_t *re int bic_read_sensor(uint8_t slot_id, uint8_t sensor_num, ipmi_sensor_reading_t *sensor); +int bic_get_sys_guid(uint8_t slot_id, uint8_t *guid); + +int bic_get_fw_ver(uint8_t slot_id, uint8_t comp, uint8_t *ver); + +int bic_update_fw(uint8_t slot_id, uint8_t comp, char *path); +int bic_me_xmit(uint8_t slot_id, uint8_t *txbuf, uint8_t txlen, uint8_t *rxbuf, uint8_t *rxlen); + #ifdef __cplusplus } // extern "C" #endif diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile index bab4007..c207a7d 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/Makefile @@ -2,7 +2,7 @@ lib: libpal.so libpal.so: pal.c - $(CC) $(CFLAGS) -fPIC -c -o pal.o pal.c + $(CC) $(CFLAGS) -fPIC -c -pthread -o pal.o pal.c $(CC) -lbic -lyosemite_common -lyosemite_fruid -lyosemite_sensor -shared -o libpal.so pal.o -lc .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c index 93a5fbf..ec0be12 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.c @@ -27,6 +27,7 @@ #include <syslog.h> #include <sys/mman.h> #include <string.h> +#include <pthread.h> #include "pal.h" #define BIT(value, index) ((value >> index) & 1) @@ -45,8 +46,11 @@ #define GPIO_RST_BTN 144 #define GPIO_PWR_BTN 24 +#define GPIO_HB_LED 135 + #define GPIO_USB_SW0 36 #define GPIO_USB_SW1 37 +#define GPIO_USB_MUX_EN_N 147 #define GPIO_UART_SEL0 32 #define GPIO_UART_SEL1 33 @@ -68,20 +72,27 @@ #define AST_SCU_BASE 0x1e6e2000 #define PIN_CTRL1_OFFSET 0x80 #define PIN_CTRL2_OFFSET 0x84 +#define AST_WDT_BASE 0x1e785000 +#define WDT_OFFSET 0x10 #define UART1_TXD (1 << 22) #define UART2_TXD (1 << 30) #define UART3_TXD (1 << 22) #define UART4_TXD (1 << 30) -#define BIT(v, i) ((v >> i) & 1) #define DELAY_GRACEFUL_SHUTDOWN 1 -#define DELAY_POWER_OFF 5 - -static uint8_t gpio_rst_btn[5] = { 0, 57, 56, 59, 58 }; -static uint8_t gpio_led[5] = { 0, 97, 96, 99, 98 }; -static uint8_t gpio_prsnt[5] = { 0, 61, 60, 63, 62 }; -static uint8_t gpio_power[5] = { 0, 27, 25, 31, 29 }; +#define DELAY_POWER_OFF 6 +#define DELAY_POWER_CYCLE 10 +#define DELAY_12V_CYCLE 5 + +#define CRASHDUMP_BIN "/usr/local/bin/dump.sh" +#define CRASHDUMP_FILE "/mnt/data/crashdump_" +const static uint8_t gpio_rst_btn[] = { 0, 57, 56, 59, 58 }; +const static uint8_t gpio_led[] = { 0, 97, 96, 99, 98 }; +const static uint8_t gpio_id_led[] = { 0, 41, 40, 43, 42 }; +const static uint8_t gpio_prsnt[] = { 0, 61, 60, 63, 62 }; +const static uint8_t gpio_power[] = { 0, 27, 25, 31, 29 }; +const static uint8_t gpio_12v[] = { 0, 117, 116, 119, 118 }; const char pal_fru_list[] = "all, slot1, slot2, slot3, slot4, spb, nic"; const char pal_server_list[] = "slot1, slot2, slot3, slot4"; @@ -90,6 +101,16 @@ char * key_list[] = { "pwr_server2_last_state", "pwr_server3_last_state", "pwr_server4_last_state", +"sysfw_ver_slot1", +"sysfw_ver_slot2", +"sysfw_ver_slot3", +"sysfw_ver_slot4", +"identify_sled", +"identify_slot1", +"identify_slot2", +"identify_slot3", +"identify_slot4", +"timestamp_sled", "slot1_por_cfg", "slot2_por_cfg", "slot3_por_cfg", @@ -98,6 +119,29 @@ char * key_list[] = { LAST_KEY /* This is the last key of the list */ }; +char * def_val_list[] = { + "on", /* pwr_server1_last_state */ + "on", /* pwr_server2_last_state */ + "on", /* pwr_server3_last_state */ + "on", /* pwr_server4_last_state */ + "0", /* sysfw_ver_slot1 */ + "0", /* sysfw_ver_slot2 */ + "0", /* sysfw_ver_slot3 */ + "0", /* sysfw_ver_slot4 */ + "off", /* identify_sled */ + "off", /* identify_slot1 */ + "off", /* identify_slot2 */ + "off", /* identify_slot3 */ + "off", /* identify_slot4 */ + "0", /* timestamp_sled */ + "on", /* slot1_por_cfg */ + "on", /* slot2_por_cfg */ + "on", /* slot3_por_cfg */ + "on", /* slot4_por_cfg */ + /* Add more def values for the correspoding keys*/ + LAST_KEY /* Same as last entry of the key_list */ +}; + // Helper Functions static int read_device(const char *device, int *value) { @@ -107,15 +151,18 @@ read_device(const char *device, int *value) { fp = fopen(device, "r"); if (!fp) { int err = errno; - +#ifdef DEBUG syslog(LOG_INFO, "failed to open device %s", device); +#endif return err; } rc = fscanf(fp, "%d", value); fclose(fp); if (rc != 1) { +#ifdef DEBUG syslog(LOG_INFO, "failed to read device %s", device); +#endif return ENOENT; } else { return 0; @@ -130,8 +177,9 @@ write_device(const char *device, const char *value) { fp = fopen(device, "w"); if (!fp) { int err = errno; - +#ifdef DEBUG syslog(LOG_INFO, "failed to open device for write %s", device); +#endif return err; } @@ -139,7 +187,9 @@ write_device(const char *device, const char *value) { fclose(fp); if (rc < 0) { +#ifdef DEBUG syslog(LOG_INFO, "failed to write device %s", device); +#endif return ENOENT; } else { return 0; @@ -204,6 +254,42 @@ server_power_off(uint8_t slot_id, bool gs_flag) { return 0; } +// Control 12V to the server in a given slot +static int +server_12v_on(uint8_t slot_id) { + char vpath[64] = {0}; + + if (slot_id < 1 || slot_id > 4) { + return -1; + } + + sprintf(vpath, GPIO_VAL, gpio_12v[slot_id]); + + if (write_device(vpath, "1")) { + return -1; + } + + return 0; +} + +// Turn off 12V for the server in given slot +static int +server_12v_off(uint8_t slot_id) { + char vpath[64] = {0}; + + if (slot_id < 1 || slot_id > 4) { + return -1; + } + + sprintf(vpath, GPIO_VAL, gpio_12v[slot_id]); + + if (write_device(vpath, "0")) { + return -1; + } + + return 0; +} + // Debug Card's UART and BMC/SoL port share UART port and need to enable only // one TXD i.e. either BMC's TXD or Debug Port's TXD. static int @@ -216,7 +302,9 @@ control_sol_txd(uint8_t slot) { scu_fd = open("/dev/mem", O_RDWR | O_SYNC ); if (scu_fd < 0) { - syslog(LOG_ALERT, "control_sol_txd: open fails\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "control_sol_txd: open fails\n"); +#endif return -1; } @@ -295,7 +383,9 @@ pal_post_display(uint8_t status) { int ret; char *val; - syslog(LOG_ALERT, "pal_post_display: status is %d\n", status); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_post_display: status is %d\n", status); +#endif sprintf(path, GPIO_VAL, GPIO_POSTCODE_0); @@ -396,7 +486,9 @@ pal_post_display(uint8_t status) { post_exit: if (ret) { - syslog(LOG_ALERT, "write_device failed for %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif return -1; } else { return 0; @@ -453,11 +545,10 @@ pal_is_debug_card_prsnt(uint8_t *status) { return -1; } - // TODO: Logic is reversed until DVT board with h/w fix if (val == 0x0) { - *status = 0; - } else { *status = 1; + } else { + *status = 0; } return 0; @@ -466,11 +557,19 @@ pal_is_debug_card_prsnt(uint8_t *status) { int pal_get_server_power(uint8_t slot_id, uint8_t *status) { int ret; + char value[MAX_VALUE_LEN]; bic_gpio_t gpio; ret = bic_get_gpio(slot_id, &gpio); if (ret) { - return ret; + // Check for if the BIC is irresponsive due to 12V_OFF or 12V_CYCLE + pal_get_last_pwr_state(slot_id, value); + if (!(strcmp(value, "off"))) { + *status = SERVER_POWER_OFF; + return 0; + } else { + return ret; + } } if (gpio.pwrgood_cpu) { @@ -512,10 +611,18 @@ pal_set_server_power(uint8_t slot_id, uint8_t cmd) { break; case SERVER_POWER_CYCLE: - if (status == SERVER_POWER_ON) - return (server_power_off(slot_id, gs_flag) || server_power_on(slot_id)); - else if (status == SERVER_POWER_OFF) + if (status == SERVER_POWER_ON) { + if (server_power_off(slot_id, gs_flag)) + return -1; + + sleep(DELAY_POWER_CYCLE); + + return server_power_on(slot_id); + + } else if (status == SERVER_POWER_OFF) { + return (server_power_on(slot_id)); + } break; case SERVER_GRACEFUL_SHUTDOWN: @@ -525,6 +632,23 @@ pal_set_server_power(uint8_t slot_id, uint8_t cmd) { gs_flag = true; return server_power_off(slot_id, gs_flag); break; + + case SERVER_12V_ON: + return server_12v_on(slot_id); + break; + + case SERVER_12V_OFF: + return server_12v_off(slot_id); + break; + + case SERVER_12V_CYCLE: + if (server_12v_off(slot_id)) { + return -1; + } + + sleep(DELAY_12V_CYCLE); + + return (server_12v_on(slot_id)); default: return -1; } @@ -582,20 +706,20 @@ pal_get_hand_sw(uint8_t *pos) { loc = ((id8 << 3) | (id4 << 2) | (id2 << 1) | (id1)); switch(loc) { + case 0: + case 5: + *pos = HAND_SW_SERVER1; + break; case 1: case 6: - *pos = HAND_SW_SERVER1; + *pos = HAND_SW_SERVER2; break; case 2: case 7: - *pos = HAND_SW_SERVER2; + *pos = HAND_SW_SERVER3; break; case 3: case 8: - *pos = HAND_SW_SERVER3; - break; - case 4: - case 9: *pos = HAND_SW_SERVER4; break; default: @@ -657,9 +781,9 @@ pal_set_rst_btn(uint8_t slot, uint8_t status) { } if (status) { - val = "0"; - } else { val = "1"; + } else { + val = "0"; } sprintf(path, GPIO_VAL, gpio_rst_btn[slot]); @@ -694,6 +818,81 @@ pal_set_led(uint8_t slot, uint8_t status) { return 0; } +// Update Heartbeet LED +int +pal_set_hb_led(uint8_t status) { + char path[64] = {0}; + char *val; + + if (status) { + val = "1"; + } else { + val = "0"; + } + + sprintf(path, GPIO_VAL, GPIO_HB_LED); + if (write_device(path, val)) { + return -1; + } + + return 0; +} + +// Update the Identification LED for the given slot with the status +int +pal_set_id_led(uint8_t slot, uint8_t status) { + char path[64] = {0}; + char *val; + + if (slot < 1 || slot > 4) { + return -1; + } + + if (status) { + val = "1"; + } else { + val = "0"; + } + + sprintf(path, GPIO_VAL, gpio_id_led[slot]); + if (write_device(path, val)) { + return -1; + } + + return 0; +} + +static int +set_usb_mux(uint8_t state) { + int val; + char *new_state; + char path[64] = {0}; + + sprintf(path, GPIO_VAL, GPIO_USB_MUX_EN_N); + + if (read_device(path, &val)) { + return -1; + } + + // This GPIO Pin is active low + if (!val == state) + return 0; + + if (state) + new_state = "0"; + else + new_state = "1"; + + if (write_device(path, new_state) < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif + return -1; + } + + return 0; +} + // Update the USB Mux to the server at given slot int pal_switch_usb_mux(uint8_t slot) { @@ -702,36 +901,49 @@ pal_switch_usb_mux(uint8_t slot) { // Based on the USB mux table in Schematics switch(slot) { - case 1: + case HAND_SW_SERVER1: gpio_sw0 = "1"; gpio_sw1 = "0"; break; - case 2: + case HAND_SW_SERVER2: gpio_sw0 = "0"; gpio_sw1 = "0"; break; - case 3: + case HAND_SW_SERVER3: gpio_sw0 = "1"; gpio_sw1 = "1"; break; - case 4: + case HAND_SW_SERVER4: gpio_sw0 = "0"; gpio_sw1 = "1"; break; + case HAND_SW_BMC: + // Disable the USB MUX + if (set_usb_mux(USB_MUX_OFF) < 0) + return -1; + else + return 0; default: - // Default is for BMC itself return 0; } + // Enable the USB MUX + if (set_usb_mux(USB_MUX_ON) < 0) + return -1; + sprintf(path, GPIO_VAL, GPIO_USB_SW0); if (write_device(path, gpio_sw0) < 0) { - syslog(LOG_ALERT, "write_device failed for %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif return -1; } sprintf(path, GPIO_VAL, GPIO_USB_SW1); if (write_device(path, gpio_sw1) < 0) { - syslog(LOG_ALERT, "write_device failed for %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "write_device failed for %s\n", path); +#endif return -1; } @@ -750,25 +962,25 @@ pal_switch_uart_mux(uint8_t slot) { // Refer the UART select table in schematic switch(slot) { - case 1: + case HAND_SW_SERVER1: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "0"; gpio_uart_sel0 = "1"; gpio_uart_rx = "0"; break; - case 2: + case HAND_SW_SERVER2: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "0"; gpio_uart_sel0 = "0"; gpio_uart_rx = "0"; break; - case 3: + case HAND_SW_SERVER3: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "1"; gpio_uart_sel0 = "1"; gpio_uart_rx = "0"; break; - case 4: + case HAND_SW_SERVER4: gpio_uart_sel2 = "0"; gpio_uart_sel1 = "1"; gpio_uart_sel0 = "0"; @@ -816,7 +1028,9 @@ pal_switch_uart_mux(uint8_t slot) { uart_exit: if (ret) { - syslog(LOG_ALERT, "pal_switch_uart_mux: write_device failed: %s\n", path); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_switch_uart_mux: write_device failed: %s\n", path); +#endif return ret; } else { return 0; @@ -833,7 +1047,9 @@ pal_post_enable(uint8_t slot) { ret = bic_get_config(slot, &config); if (ret) { - syslog(LOG_ALERT, "post_enable: bic_get_config failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "post_enable: bic_get_config failed for fru: %d\n", slot); +#endif return ret; } @@ -841,7 +1057,9 @@ pal_post_enable(uint8_t slot) { ret = bic_set_config(slot, &config); if (ret) { - syslog(LOG_ALERT, "post_enable: bic_set_config failed\n"); +#ifdef DEBUG + syslog(LOG_WARNING, "post_enable: bic_set_config failed\n"); +#endif return ret; } @@ -937,14 +1155,18 @@ read_kv(char *key, char *value) { fp = fopen(key, "r"); if (!fp) { int err = errno; - syslog(LOG_ALERT, "read_kv: failed to open %s", key); +#ifdef DEBUG + syslog(LOG_WARNING, "read_kv: failed to open %s", key); +#endif return err; } rc = (int) fread(value, 1, MAX_VALUE_LEN, fp); fclose(fp); if (rc <= 0) { +#ifdef DEBUG syslog(LOG_INFO, "read_kv: failed to read %s", key); +#endif return ENOENT; } else { return 0; @@ -960,7 +1182,9 @@ write_kv(char *key, char *value) { fp = fopen(key, "w"); if (!fp) { int err = errno; - syslog(LOG_ALERT, "write_kv: failed to open %s", key); +#ifdef DEBUG + syslog(LOG_WARNING, "write_kv: failed to open %s", key); +#endif return err; } @@ -968,7 +1192,9 @@ write_kv(char *key, char *value) { fclose(fp); if (rc < 0) { - syslog(LOG_ALERT, "write_kv: failed to write to %s", key); +#ifdef DEBUG + syslog(LOG_WARNING, "write_kv: failed to write to %s", key); +#endif return ENOENT; } else { return 0; @@ -982,6 +1208,17 @@ pal_get_fru_id(char *str, uint8_t *fru) { } int +pal_get_fru_name(uint8_t fru, char *name) { + + return yosemite_common_fru_name(fru, name); +} + +int +pal_get_fru_sdr_path(uint8_t fru, char *path) { + return yosemite_sensor_sdr_path(fru, path); +} + +int pal_get_fru_sensor_list(uint8_t fru, uint8_t **sensor_list, int *cnt) { switch(fru) { @@ -997,22 +1234,39 @@ pal_get_fru_sensor_list(uint8_t fru, uint8_t **sensor_list, int *cnt) { *cnt = spb_sensor_cnt; break; case FRU_NIC: - *sensor_list = NULL; // (uint8_t *) nic_sensor_list; - *cnt = 0; //nic_sensor_cnt; + *sensor_list = (uint8_t *) nic_sensor_list; + *cnt = nic_sensor_cnt; break; default: - syslog(LOG_ALERT, "pal_get_fru_sensor_list: Wrong fru id %u", fru); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_fru_sensor_list: Wrong fru id %u", fru); +#endif return -1; } return 0; } int +pal_fruid_write(uint8_t fru, char *path) { + return bic_write_fruid(fru, 0, path); +} + +int +pal_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo) { + return yosemite_sensor_sdr_init(fru, sinfo); +} + +int pal_sensor_read(uint8_t fru, uint8_t sensor_num, void *value) { return yosemite_sensor_read(fru, sensor_num, value); } int +pal_get_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, void *value) { + return yosemite_sensor_threshold(fru, sensor_num, thresh, value); +} + +int pal_get_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { return yosemite_sensor_name(fru, sensor_num, name); } @@ -1028,6 +1282,11 @@ pal_get_fruid_path(uint8_t fru, char *path) { } int +pal_get_fruid_eeprom_path(uint8_t fru, char *path) { + return yosemite_get_fruid_eeprom_path(fru, path); +} + +int pal_get_fruid_name(uint8_t fru, char *name) { return yosemite_get_fruid_name(fru, name); } @@ -1073,7 +1332,9 @@ pal_get_key_value(char *key, char *value) { if (!strcmp(key, key_list[i])) { // Key is valid if ((ret = get_key_value(key, value)) < 0 ) { - syslog(LOG_ALERT, "pal_get_key_value: get_key_value failed. %d", ret); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_key_value: get_key_value failed. %d", ret); +#endif return ret; } return ret; @@ -1085,6 +1346,31 @@ pal_get_key_value(char *key, char *value) { } int +pal_set_def_key_value() { + + int ret; + int i; + char kpath[64] = {0}; + + i = 0; + while(strcmp(key_list[i], LAST_KEY)) { + + sprintf(kpath, KV_STORE, key_list[i]); + + if (access(kpath, F_OK) == -1) { + if ((ret = set_key_value(key_list[i], def_val_list[i])) < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "pal_set_def_key_value: set_key_value failed. %d", ret); +#endif + } + } + i++; + } + + return 0; +} + +int pal_set_key_value(char *key, char *value) { int ret; @@ -1096,8 +1382,9 @@ pal_set_key_value(char *key, char *value) { if (!strcmp(key, key_list[i])) { // Key is valid if ((ret = set_key_value(key, value)) < 0) { - syslog(LOG_ALERT, "pal_set_key_value: set_key_value failed. %d", ret); - printf("pal_set_key_value: ret = %d\n", ret); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_set_key_value: set_key_value failed. %d", ret); +#endif return ret; } return ret; @@ -1125,7 +1412,9 @@ pal_get_fru_devtty(uint8_t fru, char *devtty) { sprintf(devtty, "/dev/ttyS3"); break; default: - syslog(LOG_ALERT, "pal_get_fru_devtty: Wrong fru id %u", fru); +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_fru_devtty: Wrong fru id %u", fru); +#endif return -1; } return 0; @@ -1149,3 +1438,516 @@ pal_dump_key_value(void) { memset(value, 0, MAX_VALUE_LEN); } } + +int +pal_set_last_pwr_state(uint8_t fru, char *state) { + + int ret; + char key[MAX_KEY_LEN] = {0}; + + sprintf(key, "pwr_server%d_last_state", (int) fru); + + ret = pal_set_key_value(key, state); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "pal_set_last_pwr_state: pal_set_key_value failed for " + "fru %u", fru); +#endif + } + return ret; +} + +int +pal_get_last_pwr_state(uint8_t fru, char *state) { + int ret; + char key[MAX_KEY_LEN] = {0}; + + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + + sprintf(key, "pwr_server%d_last_state", (int) fru); + + ret = pal_get_key_value(key, state); + if (ret < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_last_pwr_state: pal_get_key_value failed for " + "fru %u", fru); +#endif + } + return ret; + case FRU_SPB: + case FRU_NIC: + sprintf(state, "on"); + return 0; + } +} + +int +pal_get_sys_guid(uint8_t slot, char *guid) { + int ret; + + return bic_get_sys_guid(slot, guid); +} + +int +pal_set_sysfw_ver(uint8_t slot, uint8_t *ver) { + int i; + char key[MAX_KEY_LEN] = {0}; + char str[MAX_VALUE_LEN] = {0}; + char tstr[10] = {0}; + + sprintf(key, "sysfw_ver_slot%d", (int) slot); + + for (i = 0; i < SIZE_SYSFW_VER; i++) { + sprintf(tstr, "%02x", ver[i]); + strcat(str, tstr); + } + + return pal_set_key_value(key, str); +} + +int +pal_get_sysfw_ver(uint8_t slot, uint8_t *ver) { + int i; + int j = 0; + int ret; + int msb, lsb; + char key[MAX_KEY_LEN] = {0}; + char str[MAX_VALUE_LEN] = {0}; + char tstr[4] = {0}; + + sprintf(key, "sysfw_ver_slot%d", (int) slot); + + ret = pal_get_key_value(key, str); + if (ret) { + return ret; + } + + for (i = 0; i < 2*SIZE_SYSFW_VER; i += 2) { + sprintf(tstr, "%c\n", str[i]); + msb = strtol(tstr, NULL, 16); + + sprintf(tstr, "%c\n", str[i+1]); + lsb = strtol(tstr, NULL, 16); + ver[j++] = (msb << 4) | lsb; + } + + return 0; +} + +int +pal_is_bmc_por(void) { + uint32_t scu_fd; + uint32_t wdt; + void *scu_reg; + void *scu_wdt; + + scu_fd = open("/dev/mem", O_RDWR | O_SYNC ); + if (scu_fd < 0) { + return 0; + } + + scu_reg = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, scu_fd, + AST_WDT_BASE); + scu_wdt = (char*)scu_reg + WDT_OFFSET; + + wdt = *(volatile uint32_t*) scu_wdt; + + munmap(scu_reg, PAGE_SIZE); + close(scu_fd); + + if (wdt & 0xff00) { + return 0; + } else { + return 1; + } +} + +int +pal_get_fru_discrete_list(uint8_t fru, uint8_t **sensor_list, int *cnt) { + + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + *sensor_list = (uint8_t *) bic_discrete_list; + *cnt = bic_discrete_cnt; + break; + case FRU_SPB: + case FRU_NIC: + return -1; + default: +#ifdef DEBUG + syslog(LOG_WARNING, "pal_get_fru_discrete_list: Wrong fru id %u", fru); +#endif + return -1; + } + return 0; +} + +static void +_print_sensor_discrete_log(uint8_t fru, uint8_t snr_num, char *snr_name, + uint8_t val, char *event) { + if (val) { + syslog(LOG_CRIT, "ASSERT: %s discrete - raised - FRU: %d, num: 0x%X," + " snr: %-16s val: %d", event, fru, snr_num, snr_name, val); + } else { + syslog(LOG_CRIT, "DEASSERT: %s discrete - settled - FRU: %d, num: 0x%X," + " snr: %-16s val: %d", event, fru, snr_num, snr_name, val); + } +} + +int +pal_sensor_discrete_check(uint8_t fru, uint8_t snr_num, char *snr_name, + uint8_t o_val, uint8_t n_val) { + + char name[32]; + bool valid = false; + uint8_t diff = o_val ^ n_val; + + if (GETBIT(diff, 0)) { + switch(snr_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SOC_Thermal_Trip"); + valid = true; + break; + case BIC_SENSOR_VR_HOT: + sprintf(name, "SOC_VR_Hot"); + valid = true; + break; + case BIC_SENSOR_CPU_DIMM_HOT: + sprintf(name, "SOC_Hot"); + valid = true; + break; + } + if (valid) { + _print_sensor_discrete_log( fru, snr_num, snr_name, GETBIT(n_val, 0), name); + valid = false; + } + } + + if (GETBIT(diff, 1)) { + switch(snr_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SOC_FIVR_Fault"); + valid = true; + break; + case BIC_SENSOR_VR_HOT: + sprintf(name, "SOC_DIMM_VR_Hot"); + valid = true; + break; + case BIC_SENSOR_CPU_DIMM_HOT: + sprintf(name, "SOC_MEMHOT"); + valid = true; + break; + } + if (valid) { + _print_sensor_discrete_log( fru, snr_num, snr_name, GETBIT(n_val, 1), name); + valid = false; + } + } + + if (GETBIT(diff, 2)) { + switch(snr_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SOC_Throttle"); + valid = true; + break; + } + if (valid) { + _print_sensor_discrete_log( fru, snr_num, snr_name, GETBIT(n_val, 2), name); + valid = false; + } + } +} + +static int +pal_store_crashdump(uint8_t fru) { + + return yosemite_common_crashdump(fru); +} + +int +pal_sel_handler(uint8_t fru, uint8_t snr_num) { + + switch(snr_num) { + case CATERR: + pal_store_crashdump(fru); + break; + } + + return 0; +} + +int +pal_get_event_sensor_name(uint8_t fru, uint8_t snr_num, char *name) { + + switch(snr_num) { + case SYSTEM_EVENT: + sprintf(name, "SYSTEM_EVENT"); + break; + case THERM_THRESH_EVT: + sprintf(name, "THERM_THRESH_EVT"); + break; + case BUTTON: + sprintf(name, "BUTTON"); + break; + case POWER_STATE: + sprintf(name, "POWER_STATE"); + break; + case CRITICAL_IRQ: + sprintf(name, "CRITICAL_IRQ"); + break; + case POST_ERROR: + sprintf(name, "POST_ERROR"); + break; + case MACHINE_CHK_ERR: + sprintf(name, "MACHINE_CHK_ERR"); + break; + case PCIE_ERR: + sprintf(name, "PCIE_ERR"); + break; + case IIO_ERR: + sprintf(name, "IIO_ERR"); + break; + case MEMORY_ECC_ERR: + sprintf(name, "MEMORY_ECC_ERR"); + break; + case PROCHOT_EXT: + sprintf(name, "PROCHOT_EXT"); + break; + case PWR_ERR: + sprintf(name, "PWR_ERR"); + break; + case CATERR: + sprintf(name, "CATERR"); + break; + default: + sprintf(name, "unknown"); + break; + } + + return 0; +} + +int +pal_parse_sel(uint8_t fru, uint8_t snr_num, uint8_t *event_data, + char *error_log) { + + char *ed = event_data; + char temp_log[128] = {0}; + uint8_t temp; + + switch(snr_num) { + case SYSTEM_EVENT: + sprintf(error_log, "SYSTEM_EVENT"); + if (ed[0] == 0xE5) { + strcat(error_log, ": Cause of Time change"); + + if (ed[2] == 0x00) + strcat(error_log, ": NTP"); + else if (ed[2] == 0x01) + strcat(error_log, ": Host RTL"); + else if (ed[2] == 0x02) + strcat(error_log, ": Set SEL time cmd "); + else if (ed[2] == 0x03) + strcat(error_log, ": Set SEL time UTC offset cmd"); + else + strcat(error_log, ": Unknown"); + + if (ed[1] == 0x00) + strcat(error_log, ": First Time"); + else if(ed[1] == 0x80) + strcat(error_log, ": Second Time"); + + } + break; + + case THERM_THRESH_EVT: + sprintf(error_log, "THERM_THRESH_EVT"); + if (ed[0] == 0x1) + strcat(error_log, ": Limit Exceeded"); + else + strcat(error_log, ": Unknown"); + break; + + case BUTTON: + sprintf(error_log, "BUTTON"); + if (ed[0] == 0x0) + strcat(error_log, ": Power button pressed"); + else if (ed[0] == 0x2) + strcat(error_log, ": Reset button pressed"); + else + strcat(error_log, ": Unknown"); + break; + + case POWER_STATE: + sprintf(error_log, "POWER_STATE"); + if (ed[0] == 0x0) + strcat(error_log, ": Transition to Running"); + else if (ed[0] == 0x2) + strcat(error_log, ": Transition to Power Off"); + else + strcat(error_log, ": Unknown"); + break; + + case CRITICAL_IRQ: + sprintf(error_log, "CRITICAL_IRQ"); + if (ed[0] == 0x0) + strcat(error_log, ": Diagnostic Interrupt"); + else + strcat(error_log, ": Unknown"); + break; + + case POST_ERROR: + sprintf(error_log, "POST_ERROR"); + if ((ed[0] & 0x0F) == 0x0) + strcat(error_log, ": System Firmware Error"); + else + strcat(error_log, ": Unknown"); + if (((ed[0] >> 6) & 0x03) == 0x3) { + // TODO: Need to implement IPMI spec based Post Code + strcat(error_log, ": IPMI Post Code"); + } else if (((ed[0] >> 6) & 0x03) == 0x2) { + sprintf(temp_log, "OEM Post Code: 0x%X 0x%X", ed[2], ed[1]); + strcat(error_log, temp_log); + } + break; + + case MACHINE_CHK_ERR: + sprintf(error_log, "MACHINE_CHK_ERR"); + if ((ed[0] & 0x0F) == 0x0B) { + strcat(error_log, ": Uncorrectable"); + } else if ((ed[0] & 0x0F) == 0x0C) { + strcat(error_log, ": Correctable"); + } else { + strcat(error_log, ": Unknown"); + } + + sprintf(temp_log, "Machine Check bank Number - %d ", ed[1]); + strcat(error_log, temp_log); + sprintf(temp_log, "CPU - %d, Core - %d ", ed[2] >> 5, ed[2] & 0x1F); + strcat(error_log, temp_log); + + break; + + case PCIE_ERR: + sprintf(error_log, "PCIE_ERR"); + if ((ed[0] & 0xF) == 0x4) + strcat(error_log, ": PCI PERR"); + else if ((ed[0] & 0xF) == 0x5) + strcat(error_log, ": PCI SERR"); + else if ((ed[0] & 0xF) == 0x7) + strcat(error_log, ": Correctable"); + else if ((ed[0] & 0xF) == 0x8) + strcat(error_log, ": Uncorrectable"); + else if ((ed[0] & 0xF) == 0xA) + strcat(error_log, ": Bus Fatal"); + else + strcat(error_log, ": Unknown"); + break; + + case IIO_ERR: + sprintf(error_log, "IIO_ERR"); + if ((ed[0] & 0xF) == 0) { + + sprintf(temp_log, ": CPU - %d, Error ID - 0x%X", (ed[2] & 0xE0) >> 5, + ed[1]); + strcat(error_log, temp_log); + + temp = ed[2] & 0x7; + if (temp == 0x0) + strcat(error_log, ": IRP0"); + else if (temp == 0x1) + strcat(error_log, ": IRP1"); + else if (temp == 0x2) + strcat(error_log, ": IIO-Core"); + else if (temp == 0x3) + strcat(error_log, ": VT-d"); + else if (temp == 0x4) + strcat(error_log, ": Intel Quick Data"); + else if (temp == 0x5) + strcat(error_log, ": Misc"); + else + strcat(error_log, ": Reserved"); + } + break; + + case MEMORY_ECC_ERR: + sprintf(error_log, "MEMORY_ECC_ERR"); + if ((ed[0] & 0x0F) == 0x0) + strcat(error_log, ": Correctable"); + else if ((ed[0] & 0x0F) == 0x1) + strcat(error_log, ": Uncorrectable"); + else if ((ed[0] & 0x0F) == 0x5) + strcat(error_log, ": Correctable ECC error Logging Limit Reached"); + else + strcat(error_log, ": Unknown"); + + if (((ed[1] & 0xC) >> 2) == 0x0) { + /* All Info Valid */ + sprintf(temp_log, ": CPU# - %d, CHN# - %d, DIMM# - %d ", + (ed[2] & 0xE0) >> 5, (ed[2] & 0x18) >> 3, ed[2] & 0x7); + } else if (((ed[1] & 0xC) >> 2) == 0x1) { + /* DIMM info not valid */ + sprintf(temp_log, ": CPU# - %d, CHN# - %d", + (ed[2] & 0xE0) >> 5, (ed[2] & 0x18) >> 3); + } else if (((ed[1] & 0xC) >> 2) == 0x2) { + /* CHN info not valid */ + sprintf(temp_log, ": CPU# - %d, DIMM# - %d ", + (ed[2] & 0xE0) >> 5, ed[2] & 0x7); + } else if (((ed[1] & 0xC) >> 2) == 0x3) { + /* CPU info not valid */ + sprintf(temp_log, ": CHN# - %d, DIMM# - %d ", + (ed[2] & 0x18) >> 3, ed[2] & 0x7); + } + strcat(error_log, temp_log); + + break; + + case PROCHOT_EXT: + sprintf(error_log, "PROCHOT_EXT"); + if ((ed[0] & 0xF) == 0xA) + strcat(error_log, ": Processor Thermal Throttling Offset"); + else + strcat(error_log, ": Unknown"); + break; + + if ((ed[1] & 0x3) == 0x1) + strcat(error_log, ": External (VR)"); + else if ((ed[1] & 0x3) == 0x0) + strcat(error_log, ": Native"); + break; + + sprintf(temp_log, ": SOC ID - %d", (ed[2] & 0xE0) >> 5); + strcat(error_log, temp_log); + + case PWR_ERR: + sprintf(error_log, "PWR_ERR"); + if (ed[0] == 0x2) + strcat(error_log, ": PCH_PWROK failure"); + else + strcat(error_log, ": Unknown"); + break; + + case CATERR: + sprintf(error_log, "CATERR"); + if (ed[0] == 0x0) + strcat(error_log, ": IERR"); + else if (ed[0] == 0xB) + strcat(error_log, ": MCERR"); + else + strcat(error_log, ": Unknown"); + break; + + default: + sprintf(error_log, "unknown"); + break; + } + + return 0; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h index 1d9f3b9..b3f542a 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/pal/pal.h @@ -30,13 +30,17 @@ extern "C" { #include <facebook/yosemite_fruid.h> #include <facebook/yosemite_sensor.h> -#define MAX_NUM_FRUS 6 #define MAX_KEY_LEN 64 #define MAX_VALUE_LEN 64 #define KV_STORE "/mnt/data/kv_store/%s" #define KV_STORE_PATH "/mnt/data/kv_store" +#define SETBIT(x, y) (x | (1 << y)) +#define GETBIT(x, y) ((x & (1 << y)) > y) +#define CLEARBIT(x, y) (x & (~(1 << y))) +#define GETMASK(y) (1 << y) + extern char * key_list[]; extern const char pal_fru_list[]; extern const char pal_server_list[]; @@ -47,10 +51,18 @@ enum { }; enum { + USB_MUX_OFF, + USB_MUX_ON, +}; + +enum { SERVER_POWER_OFF, SERVER_POWER_ON, SERVER_POWER_CYCLE, SERVER_GRACEFUL_SHUTDOWN, + SERVER_12V_OFF, + SERVER_12V_ON, + SERVER_12V_CYCLE, }; enum { @@ -61,6 +73,22 @@ enum { HAND_SW_BMC }; +enum { + SYSTEM_EVENT = 0xE9, + THERM_THRESH_EVT = 0x7D, + BUTTON = 0xAA, + POWER_STATE = 0xAB, + CRITICAL_IRQ = 0xEA, + POST_ERROR = 0x2B, + MACHINE_CHK_ERR = 0x40, + PCIE_ERR = 0x41, + IIO_ERR = 0x43, + MEMORY_ECC_ERR = 0X63, + PROCHOT_EXT = 0X51, + PWR_ERR = 0X56, + CATERR= 0xEB, +}; + int pal_get_platform_name(char *name); int pal_get_num_slots(uint8_t *num); int pal_is_server_prsnt(uint8_t slot_id, uint8_t *status); @@ -79,17 +107,40 @@ int pal_get_pwr_btn(uint8_t *status); int pal_get_rst_btn(uint8_t *status); int pal_set_rst_btn(uint8_t slot, uint8_t status); int pal_set_led(uint8_t slot, uint8_t status); +int pal_set_hb_led(uint8_t status); +int pal_set_id_led(uint8_t slot, uint8_t status); int pal_get_fru_id(char *fru_str, uint8_t *fru); +int pal_get_fru_name(uint8_t fru, char *name); int pal_get_fruid_path(uint8_t fru, char *path); +int pal_get_fruid_eeprom_path(uint8_t fru, char *path); int pal_get_fruid_name(uint8_t fru, char *name); +int pal_get_fru_sdr_path(uint8_t fru, char *path); int pal_get_sensor_units(uint8_t fru, uint8_t sensor_num, char *units); int pal_get_fru_sensor_list(uint8_t fru, uint8_t **sensor_list, int *cnt); +int pal_get_fru_discrete_list(uint8_t fru, uint8_t **sensor_list, int *cnt); +int pal_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo); int pal_sensor_read(uint8_t fru, uint8_t sensor_num, void *value); int pal_get_sensor_name(uint8_t fru, uint8_t sensor_num, char *name); +int pal_get_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, + void *value); int pal_get_key_value(char *key, char *value); int pal_set_key_value(char *key, char *value); +int pal_set_def_key_value(); void pal_dump_key_value(void); int pal_get_fru_devtty(uint8_t fru, char *devtty); +int pal_get_last_pwr_state(uint8_t fru, char *state); +int pal_set_last_pwr_state(uint8_t fru, char *state); +int pal_get_sys_guid(uint8_t slot, char *guid); +int pal_set_sysfw_ver(uint8_t slot, uint8_t *ver); +int pal_get_sysfw_ver(uint8_t slot, uint8_t *ver); +int pal_fruid_write(uint8_t slot, char *path); +int pal_is_bmc_por(void); +int pal_sensor_discrete_check(uint8_t fru, uint8_t snr_num, char *snr_name, + uint8_t o_val, uint8_t n_val); +int pal_get_event_sensor_name(uint8_t fru, uint8_t snr_num, char *name); +int pal_parse_sel(uint8_t fru, uint8_t snr_num, uint8_t *event_data, + char *error_log); +int pal_sel_handler(uint8_t fru, uint8_t snr_num); #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile index 76bf61f..40ea2a8 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/Makefile @@ -2,8 +2,8 @@ lib: libyosemite_common.so libyosemite_common.so: yosemite_common.c - $(CC) $(CFLAGS) -fPIC -c -o yosemite_common.o yosemite_common.c - $(CC) -shared -o libyosemite_common.so yosemite_common.o -lc + $(CC) $(CFLAGS) -fPIC -pthread -c -o yosemite_common.o yosemite_common.c + $(CC) -lpthread -shared -o libyosemite_common.so yosemite_common.o -lc .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c index e41690f..c638809 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.c @@ -27,8 +27,51 @@ #include <fcntl.h> #include <errno.h> #include <syslog.h> +#include <pthread.h> +#include <string.h> #include "yosemite_common.h" +#define CRASHDUMP_BIN "/usr/local/bin/dump.sh" +#define CRASHDUMP_FILE "/mnt/data/crashdump_" + +int +yosemite_common_fru_name(uint8_t fru, char *str) { + + switch(fru) { + case FRU_SLOT1: + sprintf(str, "slot1"); + break; + + case FRU_SLOT2: + sprintf(str, "slot2"); + break; + + case FRU_SLOT3: + sprintf(str, "slot3"); + break; + + case FRU_SLOT4: + sprintf(str, "slot4"); + break; + + case FRU_SPB: + sprintf(str, "spb"); + break; + + case FRU_NIC: + sprintf(str, "nic"); + break; + + default: +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_common_fru_id: Wrong fru id"); +#endif + return -1; + } + + return 0; +} + int yosemite_common_fru_id(char *str, uint8_t *fru) { @@ -47,9 +90,61 @@ yosemite_common_fru_id(char *str, uint8_t *fru) { } else if (!strcmp(str, "nic")) { *fru = FRU_NIC; } else { - syslog(LOG_ALERT, "yosemite_common_fru_id: Wrong fru id"); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_common_fru_id: Wrong fru id"); +#endif return -1; } return 0; } + +void * +generate_dump(void *arg) { + + uint8_t fru = *(uint8_t *) arg; + char cmd[128]; + char fruname[16]; + + yosemite_common_fru_name(fru, fruname); + + // HEADER LINE for the dump + memset(cmd, 0, 128); + sprintf(cmd, "%s time > %s%s", CRASHDUMP_BIN, CRASHDUMP_FILE, fruname); + system(cmd); + + // COREID dump + memset(cmd, 0, 128); + sprintf(cmd, "%s %s 48 coreid >> %s%s", CRASHDUMP_BIN, fruname, + CRASHDUMP_FILE, fruname); + system(cmd); + + // MSR dump + memset(cmd, 0, 128); + sprintf(cmd, "%s %s 48 msr >> %s%s", CRASHDUMP_BIN, fruname, + CRASHDUMP_FILE, fruname); + system(cmd); + + syslog(LOG_CRIT, "Crashdump for FRU: %d is generated.", fru); +} + +int +yosemite_common_crashdump(uint8_t fru) { + + if (access(CRASHDUMP_BIN, F_OK) == -1) { + syslog(LOG_CRIT, "Crashdump for FRU: %d failed : " + "crashdump binary is not preset", fru); + return 0; + } + + pthread_t t_dump; + + if (pthread_create(&t_dump, NULL, generate_dump, (void*) &fru) < 0) { + syslog(LOG_WARNING, "pal_store_crashdump: pthread_create for" + " FRU %d failed\n", fru); + } + + syslog(LOG_INFO, "Crashdump for FRU: %d is being generated.", fru); + + return 0; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h index 85d8638..f2128ef 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_common/yosemite_common.h @@ -25,6 +25,7 @@ extern "C" { #endif +#define MAX_NUM_FRUS 6 enum { FRU_ALL = 0, FRU_SLOT1 = 1, @@ -35,7 +36,9 @@ enum { FRU_NIC = 6, }; +int yosemite_common_fru_name(uint8_t fru, char *str); int yosemite_common_fru_id(char *str, uint8_t *fru); +int yosemite_common_crashdump(uint8_t fru); #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c index 226f2f8..d431d34 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.c @@ -48,13 +48,42 @@ yosemite_get_fruid_path(uint8_t fru, char *path) { sprintf(fname, "nic"); break; default: - syslog(LOG_ALERT, "yosemite_get_fruid_path: wrong fruid"); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_fruid_path: wrong fruid"); +#endif return -1; } sprintf(path, YOSEMITE_FRU_PATH, fname); return 0; } + +int +yosemite_get_fruid_eeprom_path(uint8_t fru, char *path) { + char fname[16] = {0}; + + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + return -1; + case FRU_SPB: + sprintf(path, "/sys/class/i2c-adapter/i2c-8/8-0051/eeprom"); + break; + case FRU_NIC: + sprintf(path, "/sys/class/i2c-adapter/i2c-12/12-0051/eeprom"); + break; + default: +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_fruid_eeprom_path: wrong fruid"); +#endif + return -1; + } + + return 0; +} + /* Populate char name[] with the path to the fru's name */ int yosemite_get_fruid_name(uint8_t fru, char *name) { @@ -79,7 +108,9 @@ yosemite_get_fruid_name(uint8_t fru, char *name) { sprintf(name, "CX4 NIC"); break; default: - syslog(LOG_ALERT, "yosemite_get_fruid_name: wrong fruid"); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_fruid_name: wrong fruid"); +#endif return -1; } return 0; diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h index 5c01267..78cdbe4 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_fruid/yosemite_fruid.h @@ -28,6 +28,7 @@ extern "C" { #endif int yosemite_get_fruid_path(uint8_t fru, char *path); +int yosemite_get_fruid_eeprom_path(uint8_t fru, char *path); int yosemite_get_fruid_name(uint8_t fru, char *name); #ifdef __cplusplus diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c index ac2c820..4f22500 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_gpio/yosemite_gpio.c @@ -102,12 +102,16 @@ yosemite_get_gpio_name(uint8_t fru, uint8_t gpio, char *name) { //TODO: Add support for BMC GPIO pins if (fru < 1 || fru > 4) { - syslog(LOG_ALERT, "yosemite_get_gpio_name: Wrong fru %u", fru); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_gpio_name: Wrong fru %u", fru); +#endif return -1; } if (gpio < 0 || gpio > MAX_GPIO_PINS) { - syslog(LOG_ALERT, "yosemite_get_gpio_name: Wrong gpio pin %u", gpio); +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_get_gpio_name: Wrong gpio pin %u", gpio); +#endif return -1; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile index 63b334c..dd013a9 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/Makefile @@ -3,7 +3,7 @@ lib: libyosemite_sensor.so libyosemite_sensor.so: yosemite_sensor.c $(CC) $(CFLAGS) -fPIC -c -o yosemite_sensor.o yosemite_sensor.c - $(CC) -lm -lbic -lsdr -lipmi -lipmb -lyosemite_common -shared -o libyosemite_sensor.so yosemite_sensor.o -lc + $(CC) -lm -lbic -lipmi -lipmb -lyosemite_common -shared -o libyosemite_sensor.so yosemite_sensor.o -lc .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c index 0f25e54..9d075ce 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.c @@ -24,6 +24,7 @@ #include <stdint.h> #include <stdbool.h> #include <math.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <syslog.h> @@ -51,6 +52,10 @@ #define UNIT_DIV 1000 +#define MEZZ_SENSOR_I2CBUS "11" +#define MEZZ_SENSOR_I2C_BUS_ADDR "0x1f" +#define MEZZ_SENSOR_TEMP_REGISTER "0x01" + #define BIC_SENSOR_READ_NA 0x20 #define MAX_SENSOR_NUM 0xFF @@ -77,6 +82,7 @@ const uint8_t bic_sensor_list[] = { BIC_SENSOR_VCCIN_VR_CURR, BIC_SENSOR_VCCIN_VR_VOL, BIC_SENSOR_INA230_POWER, + BIC_SENSOR_INA230_VOL, BIC_SENSOR_SOC_PACKAGE_PWR, BIC_SENSOR_SOC_TJMAX, BIC_SENSOR_VDDR_VR_POUT, @@ -88,6 +94,7 @@ const uint8_t bic_sensor_list[] = { BIC_SENSOR_VCC_SCSUS_VR_POUT, BIC_SENSOR_VCC_GBE_VR_POUT, BIC_SENSOR_VCC_GBE_VR_VOL, + BIC_SENSOR_1V05_PCH_VR_POUT, BIC_SENSOR_1V05_PCH_VR_VOL, BIC_SENSOR_SOC_DIMMA0_TEMP, BIC_SENSOR_SOC_DIMMA1_TEMP, @@ -101,22 +108,13 @@ const uint8_t bic_sensor_list[] = { BIC_SENSOR_PV_BAT, BIC_SENSOR_PVDDR, BIC_SENSOR_PVCC_GBE, +}; + +const uint8_t bic_discrete_list[] = { /* Discrete sensors */ - //BIC_SENSOR_SYSTEM_STATUS, - //BIC_SENSOR_SYS_BOOT_STAT, - //BIC_SENSOR_CPU_DIMM_HOT, - //BIC_SENSOR_PROC_FAIL, - //BIC_SENSOR_VR_HOT, - /* Event-only sensors */ - //BIC_SENSOR_POST_ERR, - //BIC_SENSOR_SPS_FW_HLTH, - //BIC_SENSOR_POWER_THRESH_EVENT, - //BIC_SENSOR_MACHINE_CHK_ERR, - //BIC_SENSOR_PCIE_ERR, - //BIC_SENSOR_OTHER_IIO_ERR, - //BIC_SENSOR_PROC_HOT_EXT, - //BIC_SENSOR_POWER_ERR, - //BIC_SENSOR_CAT_ERR, + BIC_SENSOR_SYSTEM_STATUS, + BIC_SENSOR_VR_HOT, + BIC_SENSOR_CPU_DIMM_HOT, }; // List of SPB sensors to be monitored @@ -130,10 +128,10 @@ const uint8_t spb_sensor_list[] = { SP_SENSOR_P5V, SP_SENSOR_P12V, SP_SENSOR_P3V3_STBY, - SP_SENSOR_P12V_SLOT0, SP_SENSOR_P12V_SLOT1, SP_SENSOR_P12V_SLOT2, SP_SENSOR_P12V_SLOT3, + SP_SENSOR_P12V_SLOT4, SP_SENSOR_P3V3, SP_SENSOR_HSC_IN_VOLT, SP_SENSOR_HSC_OUT_CURR, @@ -141,10 +139,63 @@ const uint8_t spb_sensor_list[] = { SP_SENSOR_HSC_IN_POWER, }; +// List of NIC sensors to be monitored +const uint8_t nic_sensor_list[] = { + MEZZ_SENSOR_TEMP, +}; + +float spb_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1] = {0}; +float nic_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1] = {0}; + +static void +sensor_thresh_array_init() { + static bool init_done = false; + + if (init_done) + return; + + spb_sensor_threshold[SP_SENSOR_INLET_TEMP][UCR_THRESH] = 40; + spb_sensor_threshold[SP_SENSOR_OUTLET_TEMP][UCR_THRESH] = 70; + spb_sensor_threshold[SP_SENSOR_FAN0_TACH][UCR_THRESH] = 10000; + spb_sensor_threshold[SP_SENSOR_FAN0_TACH][LCR_THRESH] = 500; + spb_sensor_threshold[SP_SENSOR_FAN1_TACH][UCR_THRESH] = 10000; + spb_sensor_threshold[SP_SENSOR_FAN1_TACH][LCR_THRESH] = 500; + //spb_sensor_threshold[SP_SENSOR_AIR_FLOW][UCR_THRESH] = {75.0, 0, 0, 0, 0, 0, 0, 0}; + spb_sensor_threshold[SP_SENSOR_P5V][UCR_THRESH] = 5.493; + spb_sensor_threshold[SP_SENSOR_P5V][LCR_THRESH] = 4.501; + spb_sensor_threshold[SP_SENSOR_P12V][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P3V3_STBY][UCR_THRESH] = 3.625; + spb_sensor_threshold[SP_SENSOR_P3V3_STBY][LCR_THRESH] = 2.973; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT1][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT1][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT2][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT2][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT3][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT3][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT4][UCR_THRESH] = 13.216; + spb_sensor_threshold[SP_SENSOR_P12V_SLOT4][LCR_THRESH] = 11.269; + spb_sensor_threshold[SP_SENSOR_P3V3][UCR_THRESH] = 3.625; + spb_sensor_threshold[SP_SENSOR_P3V3][LCR_THRESH] = 2.973; + spb_sensor_threshold[SP_SENSOR_HSC_IN_VOLT][UCR_THRESH] = 13.2; + spb_sensor_threshold[SP_SENSOR_HSC_IN_VOLT][LCR_THRESH] = 10.8; + spb_sensor_threshold[SP_SENSOR_HSC_OUT_CURR][UCR_THRESH] = 47.705; + spb_sensor_threshold[SP_SENSOR_HSC_TEMP][UCR_THRESH] = 120; + spb_sensor_threshold[SP_SENSOR_HSC_IN_POWER][UCR_THRESH] = 525; + + nic_sensor_threshold[MEZZ_SENSOR_TEMP][UCR_THRESH] = 80; + + init_done = true; +} + size_t bic_sensor_cnt = sizeof(bic_sensor_list)/sizeof(uint8_t); +size_t bic_discrete_cnt = sizeof(bic_discrete_list)/sizeof(uint8_t); + size_t spb_sensor_cnt = sizeof(spb_sensor_list)/sizeof(uint8_t); +size_t nic_sensor_cnt = sizeof(nic_sensor_list)/sizeof(uint8_t); + enum { FAN0 = 0, FAN1, @@ -161,12 +212,7 @@ enum { ADC_PIN7, }; -static sensor_info_t g_sinfo1[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo2[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo3[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo4[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo_spb[MAX_SENSOR_NUM] = {0}; -static sensor_info_t g_sinfo_nic[MAX_SENSOR_NUM] = {0}; +static sensor_info_t g_sinfo[MAX_NUM_FRUS][MAX_SENSOR_NUM] = {0}; static int read_device(const char *device, int *value) { @@ -177,7 +223,9 @@ read_device(const char *device, int *value) { if (!fp) { int err = errno; +#ifdef DEBUG syslog(LOG_INFO, "failed to open device %s", device); +#endif return err; } @@ -185,7 +233,9 @@ read_device(const char *device, int *value) { fclose(fp); if (rc != 1) { +#ifdef DEBUG syslog(LOG_INFO, "failed to read device %s", device); +#endif return ENOENT; } else { return 0; @@ -201,8 +251,9 @@ read_device_float(const char *device, float *value) { fp = fopen(device, "r"); if (!fp) { int err = errno; - +#ifdef DEBUG syslog(LOG_INFO, "failed to open device %s", device); +#endif return err; } @@ -210,7 +261,9 @@ read_device_float(const char *device, float *value) { fclose(fp); if (rc != 1) { +#ifdef DEBUG syslog(LOG_INFO, "failed to read device %s", device); +#endif return ENOENT; } @@ -271,46 +324,52 @@ read_hsc_value(const char *device, float *value) { } static int -bic_read_sensor_wrapper(uint8_t slot_id, uint8_t sensor_num, void *value) { +read_nic_temp(uint8_t snr_num, float *value) { + char command[64]; + char tmp[8]; + + if (snr_num == MEZZ_SENSOR_TEMP) { + sprintf(command, "i2cget -y %s %s %s b", MEZZ_SENSOR_I2CBUS, + MEZZ_SENSOR_I2C_BUS_ADDR, MEZZ_SENSOR_TEMP_REGISTER); + + FILE *fp = popen(command, "r"); + fscanf(fp, "%s", tmp); + pclose(fp); + + *value = (float) strtol(tmp, NULL, 16); + } + + return 0; +} + +static int +bic_read_sensor_wrapper(uint8_t fru, uint8_t sensor_num, bool discrete, + void *value) { + int ret; + sdr_full_t *sdr; ipmi_sensor_reading_t sensor; - ret = bic_read_sensor(slot_id, sensor_num, &sensor); + ret = bic_read_sensor(fru, sensor_num, &sensor); if (ret) { return ret; } if (sensor.flags & BIC_SENSOR_READ_NA) { +#ifdef DEBUG syslog(LOG_ERR, "bic_read_sensor_wrapper: Reading Not Available"); syslog(LOG_ERR, "bic_read_sensor_wrapper: sensor_num: 0x%X, flag: 0x%X", sensor_num, sensor.flags); +#endif return -1; } - if (sensor.status) { - //printf("bic_read_sensor_wrapper: Status Asserted: 0x%X\n", sensor.status); + if (discrete) { + *(float *) value = (float) sensor.status; + return 0; } - // Check SDR to convert raw value to actual - sdr_full_t *sdr; - - switch (slot_id) { - case 1: - sdr = &g_sinfo1[sensor_num].sdr; - break; - case 2: - sdr = &g_sinfo2[sensor_num].sdr; - break; - case 3: - sdr = &g_sinfo3[sensor_num].sdr; - break; - case 4: - sdr = &g_sinfo4[sensor_num].sdr; - break; - default: - syslog(LOG_ALERT, "bic_read_sensor_wrapper: Wrong Slot ID\n"); - return -1; - } + sdr = &g_sinfo[fru-1][sensor_num].sdr; // If the SDR is not type1, no need for conversion if (sdr->type !=1) { @@ -350,106 +409,148 @@ bic_read_sensor_wrapper(uint8_t slot_id, uint8_t sensor_num, void *value) { * (float *) value = ((m * x) + (b * pow(10, b_exp))) * (pow(10, r_exp)); + if ((sensor_num == BIC_SENSOR_SOC_THERM_MARGIN) && (* (float *) value > 0)) { + * (float *) value -= (float) THERMAL_CONSTANT; + } + return 0; } -/* Returns the all the SDRs for the particular fru# */ -static sensor_info_t * -get_struct_sensor_info(uint8_t fru) { - sensor_info_t *sinfo; - switch(fru) { +int +yosemite_sensor_sdr_path(uint8_t fru, char *path) { + +char fru_name[16] = {0}; + +switch(fru) { case FRU_SLOT1: - sinfo = g_sinfo1; + sprintf(fru_name, "%s", "slot1"); break; case FRU_SLOT2: - sinfo = g_sinfo2; + sprintf(fru_name, "%s", "slot2"); break; case FRU_SLOT3: - sinfo = g_sinfo3; + sprintf(fru_name, "%s", "slot3"); break; case FRU_SLOT4: - sinfo = g_sinfo4; + sprintf(fru_name, "%s", "slot4"); break; case FRU_SPB: - sinfo = g_sinfo_spb; + sprintf(fru_name, "%s", "spb"); break; case FRU_NIC: - sinfo = g_sinfo_nic; + sprintf(fru_name, "%s", "nic"); break; default: - syslog(LOG_ALERT, "yosemite_sdr_init: Wrong Slot ID\n"); - return NULL; - } - return sinfo; +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_sensor_sdr_path: Wrong Slot ID\n"); +#endif + return -1; } +sprintf(path, YOSEMITE_SDR_PATH, fru_name); + +if (access(path, F_OK) == -1) { + return -1; +} + +return 0; +} + +/* Populates all sensor_info_t struct using the path to SDR dump */ int -get_fru_sdr_path(uint8_t fru, char *path) { +sdr_init(char *path, sensor_info_t *sinfo) { +int fd; +uint8_t buf[MAX_SDR_LEN] = {0}; +uint8_t bytes_rd = 0; +uint8_t snr_num = 0; +sdr_full_t *sdr; + +while (access(path, F_OK) == -1) { + sleep(5); +} + +fd = open(path, O_RDONLY); +if (fd < 0) { + syslog(LOG_ERR, "sdr_init: open failed for %s\n", path); + return -1; +} + +while ((bytes_rd = read(fd, buf, sizeof(sdr_full_t))) > 0) { + if (bytes_rd != sizeof(sdr_full_t)) { + syslog(LOG_ERR, "sdr_init: read returns %d bytes\n", bytes_rd); + return -1; + } + + sdr = (sdr_full_t *) buf; + snr_num = sdr->sensor_num; + sinfo[snr_num].valid = true; + memcpy(&sinfo[snr_num].sdr, sdr, sizeof(sdr_full_t)); +} + +return 0; +} - char fru_name[16] = {0}; +int +yosemite_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo) { + int fd; + uint8_t buf[MAX_SDR_LEN] = {0}; + uint8_t bytes_rd = 0; + uint8_t sn = 0; + char path[64] = {0}; switch(fru) { case FRU_SLOT1: - sprintf(fru_name, "%s", "slot1"); - break; case FRU_SLOT2: - sprintf(fru_name, "%s", "slot2"); - break; case FRU_SLOT3: - sprintf(fru_name, "%s", "slot3"); - break; case FRU_SLOT4: - sprintf(fru_name, "%s", "slot4"); + if (yosemite_sensor_sdr_path(fru, path) < 0) { +#ifdef DEBUG + syslog(LOG_WARNING, "yosemite_sensor_sdr_init: get_fru_sdr_path failed\n"); +#endif + return ERR_NOT_READY; + } + + if (sdr_init(path, sinfo) < 0) { +#ifdef DEBUG + syslog(LOG_ERR, "yosemite_sensor_sdr_init: sdr_init failed for FRU %d", fru); +#endif + } break; + case FRU_SPB: - sprintf(fru_name, "%s", "spb"); - break; case FRU_NIC: - sprintf(fru_name, "%s", "nic"); - break; - default: - syslog(LOG_ALERT, "yosemite_sdr_init: Wrong Slot ID\n"); return -1; + break; } - sprintf(path, YOSEMITE_SDR_PATH, fru_name); - return 0; } static int yosemite_sdr_init(uint8_t fru) { - int fd; - uint8_t buf[MAX_SDR_LEN] = {0}; - uint8_t bytes_rd = 0; - uint8_t sn = 0; - char path[64] = {0}; - sensor_info_t *sinfo; - if (get_fru_sdr_path(fru, path) < 0) { - syslog(LOG_ALERT, "yosemite_sdr_init: get_fru_sdr_path failed\n"); - return -1; - } - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "yosemite_sdr_init: get_struct_sensor_info failed\n"); - return -1; - } + static bool init_done[MAX_NUM_FRUS] = {false}; + + if (!init_done[fru - 1]) { + + sensor_info_t *sinfo = g_sinfo[fru-1]; + + if (yosemite_sensor_sdr_init(fru, sinfo) < 0) + return ERR_NOT_READY; - if (sdr_init(path, sinfo) < 0) { - syslog(LOG_ERR, "yosemite_sdr_init: sdr_init failed for FRU %d", fru); + init_done[fru - 1] = true; } return 0; } static bool -is_server_prsnt(uint8_t slot_id) { +is_server_prsnt(uint8_t fru) { uint8_t gpio; int val; char path[64] = {0}; - switch(slot_id) { + switch(fru) { case 1: gpio = 61; break; @@ -482,44 +583,21 @@ is_server_prsnt(uint8_t slot_id) { /* Get the units for the sensor */ int yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units) { - static bool init_done = false; uint8_t op, modifier; sensor_info_t *sinfo; - if (!init_done) { - - if (is_server_prsnt(1) && (yosemite_sdr_init(FRU_SLOT1) != 0)) { + if (is_server_prsnt(fru) && (yosemite_sdr_init(fru) != 0)) { return -1; } - if (is_server_prsnt(2) && (yosemite_sdr_init(FRU_SLOT2) != 0)) { - return -1; - } - if (is_server_prsnt(3) && (yosemite_sdr_init(FRU_SLOT3) != 0)) { - return -1; - } - if (is_server_prsnt(4) && (yosemite_sdr_init(FRU_SLOT4) != 0)) { - return -1; - } - init_done = true; - } switch(fru) { case FRU_SLOT1: case FRU_SLOT2: case FRU_SLOT3: case FRU_SLOT4: - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "yosemite_sensor_units: get_struct_sensor_info failed\n"); - return -1; - } + sprintf(units, ""); + break; - if (sdr_get_sensor_units(&sinfo[sensor_num].sdr, &op, &modifier, units)) { - syslog(LOG_ALERT, "yosemite_sensor_units: FRU %d: num 0x%2X: reading units" - " from SDR failed.", fru, sensor_num); - return -1; - } - break; case FRU_SPB: switch(sensor_num) { case SP_SENSOR_INLET_TEMP: @@ -549,16 +627,10 @@ yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units) { case SP_SENSOR_P3V3_STBY: sprintf(units, "Volts"); break; - case SP_SENSOR_P12V_SLOT0: - sprintf(units, "Volts"); - break; case SP_SENSOR_P12V_SLOT1: - sprintf(units, "Volts"); - break; case SP_SENSOR_P12V_SLOT2: - sprintf(units, "Volts"); - break; case SP_SENSOR_P12V_SLOT3: + case SP_SENSOR_P12V_SLOT4: sprintf(units, "Volts"); break; case SP_SENSOR_P3V3: @@ -579,114 +651,132 @@ yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units) { } break; case FRU_NIC: - sprintf(units, ""); - break; + switch(sensor_num) { + case MEZZ_SENSOR_TEMP: + sprintf(units, "C"); + break; + } + break; } return 0; } -/* Get the name for the sensor */ int -yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { - static bool init_done = false; - uint8_t op, modifier; - sensor_info_t *sinfo; +yosemite_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, float *value) { - if (!init_done) { + sensor_thresh_array_init(); - if (is_server_prsnt(1) && (yosemite_sdr_init(FRU_SLOT1) != 0)) { - return -1; - } - if (is_server_prsnt(2) && (yosemite_sdr_init(FRU_SLOT2) != 0)) { - return -1; - } - if (is_server_prsnt(3) && (yosemite_sdr_init(FRU_SLOT3) != 0)) { - return -1; - } - if (is_server_prsnt(4) && (yosemite_sdr_init(FRU_SLOT4) != 0)) { - return -1; - } - init_done = true; + switch(fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: + break; + case FRU_SPB: + *value = spb_sensor_threshold[sensor_num][thresh]; + break; + case FRU_NIC: + *value = nic_sensor_threshold[sensor_num][thresh]; + break; } + return 0; +} + +/* Get the name for the sensor */ +int +yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { switch(fru) { case FRU_SLOT1: case FRU_SLOT2: case FRU_SLOT3: case FRU_SLOT4: - sinfo = get_struct_sensor_info(fru); - if (sinfo == NULL) { - syslog(LOG_ALERT, "yosemite_sensor_name: get_struct_sensor_info failed\n"); - return -1; - } - - if (sdr_get_sensor_name(&sinfo[sensor_num].sdr, name)) { - syslog(LOG_ALERT, "yosemite_sensor_name: FRU %d: num 0x%2X: reading units" - " from SDR failed.", fru, sensor_num); - return -1; + switch(sensor_num) { + case BIC_SENSOR_SYSTEM_STATUS: + sprintf(name, "SYSTEM_STATUS"); + break; + case BIC_SENSOR_SYS_BOOT_STAT: + sprintf(name, "SYS_BOOT_STAT"); + break; + case BIC_SENSOR_CPU_DIMM_HOT: + sprintf(name, "CPU_DIMM_HOT"); + break; + case BIC_SENSOR_PROC_FAIL: + sprintf(name, "PROC_FAIL"); + break; + case BIC_SENSOR_VR_HOT: + sprintf(name, "VR_HOT"); + break; + default: + sprintf(name, ""); + break; } - break; + case FRU_SPB: switch(sensor_num) { case SP_SENSOR_INLET_TEMP: - sprintf(name, "SP_SENSOR_INLET_TEMP"); + sprintf(name, "SP_INLET_TEMP"); break; case SP_SENSOR_OUTLET_TEMP: - sprintf(name, "SP_SENSOR_OUTLET_TEMP"); + sprintf(name, "SP_OUTLET_TEMP"); break; case SP_SENSOR_MEZZ_TEMP: - sprintf(name, "SP_SENSOR_MEZZ_TEMP"); + sprintf(name, "SP_MEZZ_TEMP"); break; case SP_SENSOR_FAN0_TACH: - sprintf(name, "SP_SENSOR_FAN0_TACH"); + sprintf(name, "SP_FAN0_TACH"); break; case SP_SENSOR_FAN1_TACH: - sprintf(name, "SP_SENSOR_FAN1_TACH"); + sprintf(name, "SP_FAN1_TACH"); break; case SP_SENSOR_AIR_FLOW: - sprintf(name, "SP_SENSOR_AIR_FLOW"); + sprintf(name, "SP_AIR_FLOW"); break; case SP_SENSOR_P5V: - sprintf(name, "SP_SENSOR_P5V"); + sprintf(name, "SP_P5V"); break; case SP_SENSOR_P12V: - sprintf(name, "SP_SENSOR_P12V"); + sprintf(name, "SP_P12V"); break; case SP_SENSOR_P3V3_STBY: - sprintf(name, "SP_SENSOR_P3V3_STBY"); - break; - case SP_SENSOR_P12V_SLOT0: - sprintf(name, "SP_SENSOR_P12V_SLOT0"); + sprintf(name, "SP_P3V3_STBY"); break; case SP_SENSOR_P12V_SLOT1: - sprintf(name, "SP_SENSOR_P12V_SLOT1"); + sprintf(name, "SP_P12V_SLOT1"); break; case SP_SENSOR_P12V_SLOT2: - sprintf(name, "SP_SENSOR_P12V_SLOT2"); + sprintf(name, "SP_P12V_SLOT2"); break; case SP_SENSOR_P12V_SLOT3: - sprintf(name, "SP_SENSOR_P12V_SLOT3"); + sprintf(name, "SP_P12V_SLOT3"); + break; + case SP_SENSOR_P12V_SLOT4: + sprintf(name, "SP_P12V_SLOT4"); break; case SP_SENSOR_P3V3: - sprintf(name, "SP_SENSOR_P3V3"); + sprintf(name, "SP_P3V3"); break; case SP_SENSOR_HSC_IN_VOLT: - sprintf(name, "SP_SENSOR_HSC_IN_VOLT"); + sprintf(name, "SP_HSC_IN_VOLT"); break; case SP_SENSOR_HSC_OUT_CURR: - sprintf(name, "SP_SENSOR_HSC_OUT_CURR"); + sprintf(name, "SP_HSC_OUT_CURR"); break; case SP_SENSOR_HSC_TEMP: - sprintf(name, "SP_SENSOR_HSC_TEMP"); + sprintf(name, "SP_HSC_TEMP"); break; case SP_SENSOR_HSC_IN_POWER: - sprintf(name, "SP_SENSOR_HSC_IN_POWER"); + sprintf(name, "SP_HSC_IN_POWER"); break; } break; case FRU_NIC: - sprintf(name, ""); + switch(sensor_num) { + case MEZZ_SENSOR_TEMP: + sprintf(name, "MEZZ_SENSOR_TEMP"); + break; + } break; } return 0; @@ -694,85 +784,100 @@ yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name) { int -yosemite_sensor_read(uint8_t slot_id, uint8_t sensor_num, void *value) { - static bool init_done = false; +yosemite_sensor_read(uint8_t fru, uint8_t sensor_num, void *value) { + float volt; float curr; + int ret; + bool discrete; + int i; - if (!init_done) { + switch (fru) { + case FRU_SLOT1: + case FRU_SLOT2: + case FRU_SLOT3: + case FRU_SLOT4: - if (is_server_prsnt(1) && (yosemite_sdr_init(FRU_SLOT1) != 0)) { - return -1; - } + if (!(is_server_prsnt(fru))) { + return -1; + } - if (is_server_prsnt(2) && (yosemite_sdr_init(FRU_SLOT2) != 0)) { - return -1; - } + ret = yosemite_sdr_init(fru); + if (ret < 0) { + return ret; + } - if (is_server_prsnt(3) && (yosemite_sdr_init(FRU_SLOT3) != 0)) { - return -1; - } + discrete = false; - if (is_server_prsnt(4) && (yosemite_sdr_init(FRU_SLOT4) != 0)) { - return -1; - } + i = 0; + while (i < bic_discrete_cnt) { + if (sensor_num == bic_discrete_list[i++]) { + discrete = true; + break; + } + } - init_done = true; - } + return bic_read_sensor_wrapper(fru, sensor_num, discrete, value); - switch(sensor_num) { - // Inlet, Outlet Temp - - case SP_SENSOR_INLET_TEMP: - return read_temp(SP_INLET_TEMP_DEVICE, (float*) value); - case SP_SENSOR_OUTLET_TEMP: - return read_temp(SP_OUTLET_TEMP_DEVICE, (float*) value); - - // Fan Tach Values - case SP_SENSOR_FAN0_TACH: - return read_fan_value(FAN0, FAN_TACH_RPM, (float*) value); - case SP_SENSOR_FAN1_TACH: - return read_fan_value(FAN1, FAN_TACH_RPM, (float*) value); - - // Various Voltages - case SP_SENSOR_P5V: - return read_adc_value(ADC_PIN0, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V: - return read_adc_value(ADC_PIN1, ADC_VALUE, (float*) value); - case SP_SENSOR_P3V3_STBY: - return read_adc_value(ADC_PIN2, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT0: - return read_adc_value(ADC_PIN3, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT1: - return read_adc_value(ADC_PIN4, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT2: - return read_adc_value(ADC_PIN5, ADC_VALUE, (float*) value); - case SP_SENSOR_P12V_SLOT3: - return read_adc_value(ADC_PIN6, ADC_VALUE, (float*) value); - case SP_SENSOR_P3V3: - return read_adc_value(ADC_PIN7, ADC_VALUE, (float*) value); - - // Hot Swap Controller - case SP_SENSOR_HSC_IN_VOLT: - return read_hsc_value(HSC_IN_VOLT, (float*) value); - case SP_SENSOR_HSC_OUT_CURR: - return read_hsc_value(HSC_OUT_CURR, (float*) value); - case SP_SENSOR_HSC_TEMP: - return read_hsc_value(HSC_TEMP, (float*) value); - case SP_SENSOR_HSC_IN_POWER: - if (read_hsc_value(HSC_IN_VOLT, &volt)) { - return -1; - } + case FRU_SPB: + switch(sensor_num) { - if (read_hsc_value(HSC_OUT_CURR, &curr)) { - return -1; - } + // Inlet, Outlet Temp + case SP_SENSOR_INLET_TEMP: + return read_temp(SP_INLET_TEMP_DEVICE, (float*) value); + case SP_SENSOR_OUTLET_TEMP: + return read_temp(SP_OUTLET_TEMP_DEVICE, (float*) value); - * (float*) value = volt * curr; - return 0; - default: - // For all others we assume the sensors are on Monolake - return bic_read_sensor_wrapper(slot_id, sensor_num, value); + // Fan Tach Values + case SP_SENSOR_FAN0_TACH: + return read_fan_value(FAN0, FAN_TACH_RPM, (float*) value); + case SP_SENSOR_FAN1_TACH: + return read_fan_value(FAN1, FAN_TACH_RPM, (float*) value); + + // Various Voltages + case SP_SENSOR_P5V: + return read_adc_value(ADC_PIN0, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V: + return read_adc_value(ADC_PIN1, ADC_VALUE, (float*) value); + case SP_SENSOR_P3V3_STBY: + return read_adc_value(ADC_PIN2, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT1: + return read_adc_value(ADC_PIN4, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT2: + return read_adc_value(ADC_PIN3, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT3: + return read_adc_value(ADC_PIN6, ADC_VALUE, (float*) value); + case SP_SENSOR_P12V_SLOT4: + return read_adc_value(ADC_PIN5, ADC_VALUE, (float*) value); + case SP_SENSOR_P3V3: + return read_adc_value(ADC_PIN7, ADC_VALUE, (float*) value); + + // Hot Swap Controller + case SP_SENSOR_HSC_IN_VOLT: + return read_hsc_value(HSC_IN_VOLT, (float*) value); + case SP_SENSOR_HSC_OUT_CURR: + return read_hsc_value(HSC_OUT_CURR, (float*) value); + case SP_SENSOR_HSC_TEMP: + return read_hsc_value(HSC_TEMP, (float*) value); + case SP_SENSOR_HSC_IN_POWER: + if (read_hsc_value(HSC_IN_VOLT, &volt)) { + return -1; + } + if (read_hsc_value(HSC_OUT_CURR, &curr)) { + return -1; + } + * (float*) value = volt * curr; + return 0; + } + break; + + case FRU_NIC: + switch(sensor_num) { + // Mezz Temp + case MEZZ_SENSOR_TEMP: + return read_nic_temp(MEZZ_SENSOR_TEMP, (float*) value); + } + break; } } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h index 0a33173..8775f15 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/files/yosemite_sensor/yosemite_sensor.h @@ -24,7 +24,6 @@ #include <stdbool.h> #include <openbmc/ipmi.h> #include <openbmc/ipmb.h> -#include <openbmc/sdr.h> #include <facebook/bic.h> #include <facebook/yosemite_common.h> @@ -32,6 +31,30 @@ extern "C" { #endif +#define MAX_SDR_LEN 64 +#define MAX_SENSOR_NUM 0xFF +#define MAX_SENSOR_THRESHOLD 8 +#define MAX_RETRIES_SDR_INIT 30 +#define THERMAL_CONSTANT 255 +#define ERR_NOT_READY -2 + +typedef struct _sensor_info_t { + bool valid; + sdr_full_t sdr; +} sensor_info_t; + +/* Enum for type of Upper and Lower threshold values */ +enum { + UCR_THRESH = 0x01, + UNC_THRESH, + UNR_THRESH, + LCR_THRESH, + LNC_THRESH, + LNR_THRESH, + POS_HYST, + NEG_HYST, +}; + // Sensors under Bridge IC enum { BIC_SENSOR_MB_OUTLET_TEMP = 0x01, @@ -51,6 +74,7 @@ enum { BIC_SENSOR_VCCIN_VR_CURR = 0x23, BIC_SENSOR_VCCIN_VR_VOL = 0x24, BIC_SENSOR_INA230_POWER = 0x29, + BIC_SENSOR_INA230_VOL = 0x2A, BIC_SENSOR_POST_ERR = 0x2B, //Event-only BIC_SENSOR_SOC_PACKAGE_PWR = 0x2C, BIC_SENSOR_SOC_TJMAX = 0x30, @@ -63,9 +87,9 @@ enum { BIC_SENSOR_VCC_SCSUS_VR_POUT = 0x38, BIC_SENSOR_VCC_GBE_VR_POUT = 0x39, BIC_SENSOR_POWER_THRESH_EVENT = 0x3B, //Event-only - //BIC_SENSOR_1V05_PCH_VR_POUT = 0x40, BIC_SENSOR_MACHINE_CHK_ERR = 0x40, //Event-only BIC_SENSOR_PCIE_ERR = 0x41, //Event-only + BIC_SENSOR_1V05_PCH_VR_POUT = 0x42, BIC_SENSOR_OTHER_IIO_ERR = 0x43, //Event-only BIC_SENSOR_PROC_HOT_EXT = 0x51, //Event-only BIC_SENSOR_VCC_GBE_VR_VOL = 0x54, @@ -102,10 +126,10 @@ enum { SP_SENSOR_P5V = 0xE0, SP_SENSOR_P12V = 0xE1, SP_SENSOR_P3V3_STBY = 0xE2, - SP_SENSOR_P12V_SLOT0 = 0xE3, - SP_SENSOR_P12V_SLOT1 = 0xE4, - SP_SENSOR_P12V_SLOT2 = 0xE5, - SP_SENSOR_P12V_SLOT3 = 0xE6, + SP_SENSOR_P12V_SLOT1 = 0xE3, + SP_SENSOR_P12V_SLOT2 = 0xE4, + SP_SENSOR_P12V_SLOT3 = 0xE5, + SP_SENSOR_P12V_SLOT4 = 0xE6, SP_SENSOR_P3V3 = 0xE7, SP_SENSOR_HSC_IN_VOLT = 0xC0, SP_SENSOR_HSC_OUT_CURR = 0xC1, @@ -113,18 +137,36 @@ enum { SP_SENSOR_HSC_IN_POWER = 0xC3, }; +enum{ + MEZZ_SENSOR_TEMP = 0x01, +}; extern const uint8_t bic_sensor_list[]; +extern const uint8_t bic_discrete_list[]; + extern const uint8_t spb_sensor_list[]; +extern const uint8_t nic_sensor_list[]; + +//extern float spb_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1]; + +//extern float nic_sensor_threshold[MAX_SENSOR_NUM][MAX_SENSOR_THRESHOLD + 1]; + extern size_t bic_sensor_cnt; +extern size_t bic_discrete_cnt; + extern size_t spb_sensor_cnt; -int yosemite_sensor_read(uint8_t slot_id, uint8_t sensor_num, void *value); +extern size_t nic_sensor_cnt; + +int yosemite_sensor_read(uint8_t fru, uint8_t sensor_num, void *value); int yosemite_sensor_name(uint8_t fru, uint8_t sensor_num, char *name); int yosemite_sensor_units(uint8_t fru, uint8_t sensor_num, char *units); -int get_fru_sdr_path(uint8_t fru, char *path); +int yosemite_sensor_sdr_path(uint8_t fru, char *path); +int yosemite_sensor_threshold(uint8_t fru, uint8_t sensor_num, uint8_t thresh, float *value); +int yosemite_sensor_sdr_init(uint8_t fru, sensor_info_t *sinfo); + #ifdef __cplusplus } // extern "C" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb index fbb4a15..4bbeef1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fblibs/libyosemite-sensor_0.1.bb @@ -9,7 +9,7 @@ LIC_FILES_CHKSUM = "file://yosemite_sensor.c;beginline=8;endline=20;md5=da359787 SRC_URI = "file://yosemite_sensor \ " -DEPENDS =+ " libipmi libipmb libbic libsdr libyosemite-common " +DEPENDS =+ " libipmi libipmb libbic libyosemite-common " S = "${WORKDIR}/yosemite_sensor" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb index 9a9f5fe..e00f558 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb @@ -83,7 +83,7 @@ do_install() { install -m 0755 ${WORKDIR}/rc.early ${D}${sysconfdir}/init.d/rc.early update-rc.d -r ${D} rc.early start 04 S . install -m 755 setup-gpio.sh ${D}${sysconfdir}/init.d/setup-gpio.sh - update-rc.d -r ${D} setup-gpio.sh start 59 S . + update-rc.d -r ${D} setup-gpio.sh start 59 5 . # create VLAN intf automatically #install -d ${D}/${sysconfdir}/network/if-up.d #install -m 755 create_vlan_intf ${D}${sysconfdir}/network/if-up.d/create_vlan_intf @@ -92,7 +92,7 @@ do_install() { #install -m 755 eth0_mac_fixup.sh ${D}${sysconfdir}/init.d/eth0_mac_fixup.sh #update-rc.d -r ${D} eth0_mac_fixup.sh start 70 S . install -m 755 power-on.sh ${D}${sysconfdir}/init.d/power-on.sh - update-rc.d -r ${D} power-on.sh start 85 S . + update-rc.d -r ${D} power-on.sh start 85 5 . #install -m 755 fcswitcher.sh ${D}${sysconfdir}/init.d/fcswitcher.sh #update-rc.d -r ${D} fcswitcher.sh start 90 S . install -m 0755 ${WORKDIR}/rc.local ${D}${sysconfdir}/init.d/rc.local diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c index 4a8966d..3ebc3f1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c @@ -55,6 +55,19 @@ util_get_device_id(uint8_t slot_id) { printf("Aux. FW Rev: 0x%X:0x%X:0x%X:0x%X\n", id.aux_fw_rev[0], id.aux_fw_rev[1],id.aux_fw_rev[2],id.aux_fw_rev[3]); } +static void +util_get_fw_ver(uint8_t slot_id) { + int i, j, ret; + uint8_t buf[16] = {0}; + for (i = 1; i <= 8; i++) { + ret = bic_get_fw_ver(slot_id, i, buf); + printf("version of comp: %d is", i); + for (j = 0; j < 10; j++) + printf("%02X:", buf[j]); + printf("\n"); + } +} + // Tests for reading GPIO values and configuration static void util_get_gpio(uint8_t slot_id) { @@ -363,6 +376,9 @@ main(int argc, char **argv) { slot_id = atoi(argv[1]); + util_get_fw_ver(slot_id); + +#if 0 util_get_device_id(slot_id); util_get_gpio(slot_id); @@ -381,4 +397,5 @@ main(int argc, char **argv) { util_get_sdr_info(slot_id); util_get_sdr(slot_id); util_read_sensor(slot_id); +#endif } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile new file mode 100644 index 0000000..cb90045 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: fpc-util + +fpc-util: fpc-util.c + $(CC) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fpc-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c new file mode 100644 index 0000000..93c1166 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c @@ -0,0 +1,85 @@ +/* + * fpc-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <facebook/bic.h> +#include <openbmc/pal.h> +#include <openbmc/ipmi.h> + +static void +print_usage_help(void) { + printf("Usage: fpc-util <slot1|slot2|slot3|slot4> --usb\n"); + printf(" fpc-util <slot1|slot2|slot3|slot4|all> --identify <on/off>\n"); +} + +int +main(int argc, char **argv) { + + uint8_t slot_id; + char tstr[64] = {0}; + + if (argc < 3) { + goto err_exit; + } + + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id = 2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id = 3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id = 4; + } else if (!strcmp(argv[1] , "all")) { + slot_id = 0; + } else { + goto err_exit; + } + + if (!strcmp(argv[2], "--usb")) { + printf("fpc-util: switching USB channel to slot%d\n", slot_id); + return pal_switch_usb_mux(slot_id); + } else if (!strcmp(argv[2], "--identify")) { + if (argc != 4) { + goto err_exit; + } + printf("fpc-util: identication for %s is %s\n", argv[1], argv[3]); + if (slot_id == 0) { + sprintf(tstr, "identify_sled"); + } else { + sprintf(tstr, "identify_slot%d", slot_id); + } + + return pal_set_key_value(tstr, argv[3]); + } else { + goto err_exit; + } + + return 0; +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile new file mode 100644 index 0000000..b56fca9 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: fw-util + +fw-util: fw-util.c + $(CC) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fw-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c new file mode 100644 index 0000000..2b472b3 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c @@ -0,0 +1,161 @@ +/* + * fw-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <facebook/bic.h> +#include <openbmc/pal.h> +#include <openbmc/ipmi.h> + +static void +print_usage_help(void) { + printf("Usage: fw_util <slot1|slot2|slot3|slot4> <--version>\n"); + printf(" fw_util <slot1|slot2|slot3|slot4> <--update> <--cpld> <path>\n"); +} + +// TODO: Need to confirm the interpretation of firmware version for print +// Right now using decimal to print the versions +static void +print_fw_ver(uint8_t slot_id) { + int i; + uint8_t ver[32] = {0}; + + // Print CPLD Version + if (bic_get_fw_ver(slot_id, FW_CPLD, ver)) { + return; + } + + printf("CPLD Version: 0x%02x%02x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print Bridge-IC Version + if (bic_get_fw_ver(slot_id, FW_BIC, ver)) { + return; + } + + printf("Bridge-IC Version: v%x.%x\n", ver[0], ver[1]); + + // Print ME Version + if (bic_get_fw_ver(slot_id, FW_ME, ver)){ + return; + } + + printf("ME Version: %x.%x.%x.%x%x\n", ver[0], ver[1], ver[2], ver[3], ver[4]); + + // Print PVCCIN VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCIN_VR, ver)){ + return; + } + + printf("PVCCIN VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print DDRAB VR Version + if (bic_get_fw_ver(slot_id, FW_DDRAB_VR, ver)){ + return; + } + + printf("DDRAB VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print P1V05 VR Version + if (bic_get_fw_ver(slot_id, FW_P1V05_VR, ver)){ + return; + } + + printf("P1V05 VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print PVCCGBE VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCGBE_VR, ver)){ + return; + } + + printf("PVCCGBE VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print PVCCSCSUS VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCSCSUS_VR, ver)){ + return; + } + + printf("PVCCSCSUS VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print BIOS version + if (pal_get_sysfw_ver(slot_id, ver)) { + return; + } + + // BIOS version response contains the length at offset 2 followed by ascii string + printf("BIOS Version: "); + for (i = 3; i < 3+ver[2]; i++) { + printf("%c", ver[i]); + } + printf("\n"); +} + +int +main(int argc, char **argv) { + + uint8_t slot_id; + + // Check for border conditions + if ((argc != 3) && (argc != 5)) { + goto err_exit; + } + + // Derive slot_id from first parameter + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id =2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id =3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id =4; + } else { + goto err_exit; + } + + // check operation to perform + if (!strcmp(argv[2], "--version")) { + // handle printing versions of f/w components + print_fw_ver(slot_id); + } else if (!strcmp(argv[2], "--update")) { + // handle firmware update + if (argc != 5) { + goto err_exit; + } + + if (!strcmp(argv[3], "--cpld")) { + return bic_update_fw(slot_id, UPDATE_CPLD, argv[4]); + } else { + goto err_exit; + } + } else { + goto err_exit; + } + + return 0; + +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh index 91797c5..10aad30 100755 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh @@ -106,6 +106,20 @@ devmem_clear_bit $(scu_addr 80) 8 gpio_export B0 +# Enable P3V3: GPIOS1(145) +# To use GPIOS1 (145), SCU8C[1], SCU94[0], and SCU94[1] must be 0 +devmem_clear_bit $(scu_addr 8C) 1 +devmem_clear_bit $(scu_addr 94) 0 +devmem_clear_bit $(scu_addr 94) 1 + +gpio_set S1 1 + +# PWRGD_P3V3: GPIOS2(146) +# To use GPIOS2 (146), SCU8C[2], SCU94[0], and SCU94[1] must be 0 +devmem_clear_bit $(scu_addr 8C) 2 +devmem_clear_bit $(scu_addr 94) 0 +devmem_clear_bit $(scu_addr 94) 1 + # Setup GPIOs to Mux Enable: GPIOS3(147), Channel Select: GPIOE4(36), GPIOE5(37) # To use GPIOS3 (147), SCU8C[3], SCU94[0], and SCU94[1] must be 0 @@ -123,11 +137,11 @@ devmem_clear_bit $(scu_addr 80) 21 devmem_clear_bit $(scu_addr 8C) 14 devmem_clear_bit $(scu_addr 70) 22 -gpio_export S3 -gpio_export E4 -gpio_export E5 +gpio_set S3 0 +gpio_set E4 1 +gpio_set E5 0 -# BMC_HEARTBEAT_N, heartbeat LED, GPIO Q7 +# BMC_HEARTBEAT_N, heartbeat LED, GPIO Q7(135) devmem_clear_bit $(scu_addr 90) 28 gpio_export Q7 @@ -204,6 +218,34 @@ devmem_clear_bit $(scu_addr 84) 27 gpio_set M3 1 + +# Identify LED for Slot#2: +# To use GPIOF0 (40), SCU80[24] must be 0 +devmem_clear_bit $(scu_addr 80) 24 + +gpio_set F0 1 + +# Identify LED for Slot#1: +# To use GPIOF1 (41), SCU80[25], SCUA4[12], must be 0 +devmem_clear_bit $(scu_addr 80) 25 +devmem_clear_bit $(scu_addr A4) 12 + +gpio_set F1 1 + +# Identify LED for Slot#4: +# To use GPIOF2 (42), SCU80[26], SCUA4[13], must be 0 +devmem_clear_bit $(scu_addr 80) 26 +devmem_clear_bit $(scu_addr A4) 13 + +gpio_set F2 1 + +# Identify LED for Slot#3: +# To use GPIOF3 (43), SCU80[27], SCUA4[14], must be 0 +devmem_clear_bit $(scu_addr 80) 27 +devmem_clear_bit $(scu_addr A4) 14 + +gpio_set F3 1 + # Front Panel Hand Switch GPIO setup # HAND_SW_ID1: GPIOR2(138) # To use GPIOR2, SCU88[26] must be 0 @@ -305,3 +347,55 @@ gpio_set H3 1 # RST_SLOT4_SYS_RESET_N: GPIOH2 (58) # To use GPIOH2, SCU90[6], SCU90[7] must be 0 gpio_set H2 1 + +# 12V_STBY Enable for Slots + +# P12V_STBY_SLOT1_EN: GPIOO5 (117) +# To use GPIOO5, SCU88[13] must be 0 +devmem_clear_bit $(scu_addr 88) 13 + +gpio_set O5 1 + +# P12V_STBY_SLOT2_EN: GPIOO4 (116) +# To use GPIOO4, SCU88[12] must be 0 +devmem_clear_bit $(scu_addr 88) 12 + +gpio_set O4 1 + +# P12V_STBY_SLOT3_EN: GPIOO7 (119) +# To use GPIOO7, SCU88[15] must be 0 +devmem_clear_bit $(scu_addr 88) 15 + +gpio_set O7 1 + +# P12V_STBY_SLOT4_EN: GPIOO6 (118) +# To use GPIOO6, SCU88[13] must be 0 +devmem_clear_bit $(scu_addr 88) 14 + +gpio_set O6 1 + +# PWRGD_P12V_STBY_SLOT1: GPIOP1 (121) +# To use GPIOP1, SCU88[17] must be 0 +devmem_clear_bit $(scu_addr 88) 17 +gpio_export P1 + +# PWRGD_P12V_STBY_SLOT2: GPIOP0 (120) +# To use GPIOP0, SCU88[16] must be 0 +devmem_clear_bit $(scu_addr 88) 16 +gpio_export P0 + +# PWRGD_P12V_STBY_SLOT3: GPIOP3 (123) +# To use GPIOP3, SCU88[19] must be 0 +devmem_clear_bit $(scu_addr 88) 19 +gpio_export P3 + +# PWRGD_P12V_STBY_SLOT4: GPIOP2 (122) +# To use GPIOP2, SCU88[18] must be 0 +devmem_clear_bit $(scu_addr 88) 18 +gpio_export P2 + +# TODO: Enable this pin after the HW issue is fixed +# Enable the the EXTRST functionality of GPIOB7 +#devmem_set_bit $(scu_addr 80) 15 +#devmem_clear_bit $(scu_addr 90) 31 +#devmem_set_bit $(scu_addr 3c) 3 diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c index aa921db..8eb772b 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c @@ -79,12 +79,6 @@ main(int argc, char **argv) { printf("SP_SENSOR_P3V3_STBY: %.2f Volts\n", fvalue); } - if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT0, &fvalue)) { - printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT0\n"); - } else { - printf("SP_SENSOR_P12V_SLOT0: %.2f Volts\n", fvalue); - } - if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT1, &fvalue)) { printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT1\n"); } else { @@ -103,6 +97,12 @@ main(int argc, char **argv) { printf("SP_SENSOR_P12V_SLOT3: %.2f Volts\n", fvalue); } + if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT4, &fvalue)) { + printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT4\n"); + } else { + printf("SP_SENSOR_P12V_SLOT4: %.2f Volts\n", fvalue); + } + if (yosemite_sensor_read(slot_id, SP_SENSOR_P3V3, &fvalue)) { printf("yosemite_sensor_read failed: SP_SENSOR_P3V3\n"); } else { diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb new file mode 100644 index 0000000..04665f1 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb @@ -0,0 +1,21 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Front Panel Control Utility" +DESCRIPTION = "Util to override the front panel control remotely" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fpc-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://fpc-util \ + " + +S = "${WORKDIR}/fpc-util" + +do_install() { + install -d ${D}${bindir} + install -m 0755 fpc-util ${D}${bindir}/fpc-util +} + +DEPENDS += "libpal" + +FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb new file mode 100644 index 0000000..80c3064 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb @@ -0,0 +1,21 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Firmware Utility" +DESCRIPTION = "Util for printing or updating firmware images" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fw-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://fw-util \ + " + +S = "${WORKDIR}/fw-util" + +do_install() { + install -d ${D}${bindir} + install -m 0755 fw-util ${D}${bindir}/fw-util +} + +DEPENDS += " libbic libpal" + +FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile index c542230..604fabf 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile +++ b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/Makefile @@ -2,7 +2,7 @@ all: front-paneld front-paneld: front-paneld.c - $(CC) -pthread -lpal -lbic -std=c99 -o $@ $^ $(LDFLAGS) + $(CC) -pthread -lpal -lbic -o $@ $^ $(LDFLAGS) .PHONY: clean diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c index 03849cd..5f1c1ff 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/files/front-paneld.c @@ -29,12 +29,15 @@ #include <sys/socket.h> #include <sys/un.h> #include <time.h> +#include <sys/time.h> #include <openbmc/ipmi.h> #include <openbmc/ipmb.h> #include <openbmc/pal.h> -#define BTN_MAX_SAMPLES 200 +#define BTN_MAX_SAMPLES 200 +#define BTN_POWER_OFF 40 #define MAX_NUM_SLOTS 4 +#define HB_TIMESTAMP_COUNT (60 * 60) // Helper function for msleep void @@ -55,7 +58,8 @@ debug_card_handler() { int curr = -1; int prev = -1; uint8_t prsnt; - uint8_t pos; + uint8_t pos ; + uint8_t prev_pos = -1; uint8_t lpc; int i, ret; @@ -67,24 +71,37 @@ debug_card_handler() { } curr = prsnt; - if (curr == prev) { - // No state change, continue - goto debug_card_out; + + // Check if Debug Card was either inserted or removed + if (curr != prev) { + + if (!curr) { + // Debug Card was removed + syslog(LOG_WARNING, "Debug Card Extraction\n"); + // Switch UART mux to BMC + ret = pal_switch_uart_mux(HAND_SW_BMC); + if (ret) { + goto debug_card_out; + } + } else { + // Debug Card was inserted + syslog(LOG_WARNING, "Debug Card Insertion\n"); + + } } + // If Debug Card is present if (curr) { - syslog(LOG_ALERT, "Debug Card Insertion\n"); - // Get current position of hand switch ret = pal_get_hand_sw(&pos); if (ret) { goto debug_card_out; } - // Switch USB mux based on hand switch - ret = pal_switch_usb_mux(pos); - if (ret) { - goto debug_card_out; + if (pos == prev_pos && pos != HAND_SW_BMC & !prev) { + goto display_post; } + + // Switch UART mux based on hand switch ret = pal_switch_uart_mux(pos); if (ret) { @@ -109,6 +126,7 @@ debug_card_handler() { goto debug_card_out; } +display_post: // Get last post code and display it ret = pal_post_get_last(pos, &lpc); if (ret) { @@ -119,24 +137,23 @@ debug_card_handler() { if (ret) { goto debug_card_out; } - } else { - syslog(LOG_ALERT, "Debug Card Extraction\n"); - // Switch UART mux to BMC - ret = pal_switch_uart_mux(HAND_SW_BMC); - if (ret) { - goto debug_card_out; - } + } + debug_card_done: prev = curr; + prev_pos = pos; debug_card_out: - sleep(1); + if (prsnt) + msleep(500); + else + sleep(1); } } // Thread to monitor the hand switch static void * -hand_sw_handler() { +usb_handler() { int curr = -1; int prev = -1; int ret; @@ -162,48 +179,6 @@ hand_sw_handler() { goto hand_sw_out; } - // If Debug Card is present, update UART MUX - ret = pal_is_debug_card_prsnt(&prsnt); - if (ret) { - goto hand_sw_out; - } - - if (prsnt) { - // Switch UART mux based on position - ret = pal_switch_uart_mux(pos); - if (ret) { - goto hand_sw_out; - } - - if (pos == HAND_SW_BMC) { - // For BMC, there is no need for POST enable/disable code - goto hand_sw_done; - } - - ret = pal_is_server_prsnt(pos, &prsnt); - if (ret || !prsnt) { - // Server at chosen position is not present - goto hand_sw_done; - } - - // Enable post for the chosen server - ret = pal_post_enable(pos); - if (ret) { - goto hand_sw_out; - } - - // Get last post code and display it - ret = pal_post_get_last(pos, &lpc); - if (ret) { - goto hand_sw_out; - } - - ret = pal_post_handle(pos, lpc); - if (ret) { - goto hand_sw_out; - } - } -hand_sw_done: prev = curr; hand_sw_out: sleep(1); @@ -235,7 +210,7 @@ rst_btn_handler() { } // Pass the reset button to the selected slot - syslog(LOG_ALERT, "reset button pressed\n"); + syslog(LOG_WARNING, "Reset button pressed\n"); ret = pal_set_rst_btn(pos, 0); if (ret) { goto rst_btn_out; @@ -248,14 +223,15 @@ rst_btn_handler() { msleep(100); continue; } - syslog(LOG_ALERT, "Reset button released\n"); + syslog(LOG_WARNING, "Reset button released\n"); + syslog(LOG_CRIT, "Reset Button pressed for FRU: %d\n", pos); ret = pal_set_rst_btn(pos, 1); goto rst_btn_out; } // handle error case if (i == BTN_MAX_SAMPLES) { - syslog(LOG_ALERT, "Reset button seems to stuck for long time\n"); + syslog(LOG_WARNING, "Reset button seems to stuck for long time\n"); goto rst_btn_out; } rst_btn_out: @@ -267,7 +243,7 @@ rst_btn_out: static void * pwr_btn_handler() { int ret; - uint8_t pos, btn; + uint8_t pos, btn, cmd; int i; uint8_t power; @@ -285,7 +261,7 @@ pwr_btn_handler() { goto pwr_btn_out; } - syslog(LOG_ALERT, "power button pressed\n"); + syslog(LOG_WARNING, "power button pressed\n"); // Wait for the button to be released for (i = 0; i < BTN_MAX_SAMPLES; i++) { @@ -294,13 +270,13 @@ pwr_btn_handler() { msleep(100); continue; } - syslog(LOG_ALERT, "power button released\n"); + syslog(LOG_WARNING, "power button released\n"); break; } // handle error case if (i == BTN_MAX_SAMPLES) { - syslog(LOG_ALERT, "Power button seems to stuck for long time\n"); + syslog(LOG_WARNING, "Power button seems to stuck for long time\n"); goto pwr_btn_out; } @@ -310,13 +286,96 @@ pwr_btn_handler() { goto pwr_btn_out; } + // Set power command should reverse of current power state + cmd = !power; + + // To determine long button press + if (i >= BTN_POWER_OFF) { + syslog(LOG_CRIT, "Power Button Long Press for FRU: %d\n", pos); + } else { + + // If current power state is ON and it is not a long press, + // the power off should be Graceful Shutdown + if (power == SERVER_POWER_ON) + cmd = SERVER_GRACEFUL_SHUTDOWN; + + syslog(LOG_CRIT, "Power Button Press for FRU: %d\n", pos); + } + // Reverse the power state of the given server - ret = pal_set_server_power(pos, !power); + ret = pal_set_server_power(pos, cmd); pwr_btn_out: msleep(100); } } +// Thread to handle Heart Beat LED and monitor SLED Cycles +static void * +hb_handler() { + int count = 0; + struct timespec ts; + struct timespec mts; + char tstr[64] = {0}; + char buf[128] = {0}; + uint8_t por = 0; + uint8_t time_init = 0; + long time_sled_on; + long time_sled_off; + + // Read the last timestamp from KV storage + pal_get_key_value("timestamp_sled", tstr); + time_sled_off = (long) strtoul(tstr, NULL, 10); + + // If this reset is due to Power-On-Reset, we detected SLED power OFF event + if (pal_is_bmc_por()) { + ctime_r(&time_sled_off, buf); + syslog(LOG_CRIT, "SLED Powered OFF at %s", buf); + } + + + while (1) { + // Toggle HB LED + pal_set_hb_led(1); + msleep(500); + pal_set_hb_led(0); + msleep(500); + + // Make sure the time is initialized properly + // Since there is no battery backup, the time could be reset to build time + if (time_init == 0) { + // Read current time + clock_gettime(CLOCK_REALTIME, &ts); + + if (ts.tv_sec < time_sled_off) { + continue; + } + + // If current time is more than the stored time, the date is correct + time_init = 1; + + // Need to log SLED ON event, if this is Power-On-Reset + if (pal_is_bmc_por()) { + // Get uptime + clock_gettime(CLOCK_MONOTONIC, &mts); + // To find out when SLED was on, subtract the uptime from current time + time_sled_on = ts.tv_sec - mts.tv_sec; + + ctime_r(&time_sled_on, buf); + // Log an event if this is Power-On-Reset + syslog(LOG_CRIT, "SLED Powered ON at %s", buf); + } + } + + // Store timestamp every one hour to keep track of SLED power + if (count++ == HB_TIMESTAMP_COUNT) { + clock_gettime(CLOCK_REALTIME, &ts); + sprintf(tstr, "%d", ts.tv_sec); + pal_set_key_value("timestamp_sled", tstr); + count = 0; + } + } +} + // Thread to handle LED state of the server at given slot static void * led_handler(void *num) { @@ -324,13 +383,21 @@ led_handler(void *num) { uint8_t prsnt; uint8_t power; uint8_t pos; - uint8_t ident; uint8_t led_blink; + uint8_t ident = 0; int led_on_time, led_off_time; + char identify[16] = {0}; + char tstr[64] = {0}; + int id_led_on_time = 200; + int id_led_off_time = 200; + int power_led_on_time = 500; + int power_led_off_time = 500; uint8_t slot = (*(int*) num) + 1; +#ifdef DEBUG syslog(LOG_INFO, "led_handler for slot %d\n", slot); +#endif ret = pal_is_server_prsnt(slot, &prsnt); if (ret || !prsnt) { @@ -340,6 +407,45 @@ led_handler(void *num) { } while (1) { + + // Check if this slot needs to be identified + ident = 0; + + // Check if sled needs to be identified + memset(identify, 0x0, 16); + ret = pal_get_key_value("identify_sled", identify); + if (ret == 0 && !strcmp(identify, "on")) { + ident = 0x1; + } + + // Check if slot needs to be identified + if (!ident) { + sprintf(tstr, "identify_slot%d", slot); + memset(identify, 0x0, 16); + ret = pal_get_key_value(tstr, identify); + if (ret == 0 && !strcmp(identify, "on")) { + ident = 0x1; + } + } + + if (ident) { + // Turn OFF Power LED + pal_set_led(slot, 0); + + // Start blinking the ID LED + pal_set_id_led(slot, 0); + + msleep(id_led_on_time); + + pal_set_id_led(slot, 1); + + msleep(id_led_off_time); + continue; + } else { + // Turn OFF ID LED + pal_set_id_led(slot, 1); + } + // Get power status for this slot ret = pal_get_server_power(slot, &power); if (ret) { @@ -354,27 +460,22 @@ led_handler(void *num) { continue; } - if (pos == slot) { - // This server is selcted one, set ident flag - ident = 1; - } else { - ident = 0; + if (pos == HAND_SW_BMC) { + // Start blinking the ID LED + pal_set_led(slot, 0); + + msleep(power_led_off_time); + + pal_set_led(slot, 1); + + msleep(power_led_on_time); + continue; } - // Update LED based on current state - if (ident) { - // If this is selected server the blink flag is one + if (pos == slot) { + // This server is selcted one, set led_blink flag led_blink = 1; - // update the blink rate based on power state - if (power) { - led_on_time = 900; - led_off_time = 100; - } else { - led_on_time = 100; - led_off_time = 900; - } } else { - // This server is not selected one led_blink = 0; } @@ -384,7 +485,16 @@ led_handler(void *num) { goto led_handler_out; } - // Since this is selected slot, start blinking the LED + // Set blink rate + if (power) { + led_on_time = 900; + led_off_time = 100; + } else { + led_on_time = 100; + led_off_time = 900; + } + + // Start blinking the LED ret = pal_set_led(slot, 1); if (ret) { goto led_handler_out; @@ -412,30 +522,47 @@ main (int argc, char * const argv[]) { pthread_t tid_debug_card; pthread_t tid_rst_btn; pthread_t tid_pwr_btn; + pthread_t tid_hb; pthread_t tid_leds[MAX_NUM_SLOTS]; int i; int *ip; + int rc; + int pid_file; + + pid_file = open("/var/run/front-paneld.pid", O_CREAT | O_RDWR, 0666); + rc = flock(pid_file, LOCK_EX | LOCK_NB); + if(rc) { + if(EWOULDBLOCK == errno) { + printf("Another front-paneld instance is running...\n"); + exit(-1); + } + } else { + daemon(0, 1); + openlog("front-paneld", LOG_CONS, LOG_DAEMON); + } - daemon(1, 0); - openlog("front-paneld", LOG_CONS, LOG_DAEMON); - if (pthread_create(&tid_debug_card, NULL, debug_card_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for debug card error\n"); + if (pthread_create(&tid_debug_card, NULL, debug_card_handler, NULL) < 0) { + syslog(LOG_WARNING, "pthread_create for debug card error\n"); exit(1); } - - if (pthread_create(&tid_hand_sw, NULL, hand_sw_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for hand switch error\n"); + if (pthread_create(&tid_hand_sw, NULL, usb_handler, NULL) < 0) { + syslog(LOG_WARNING, "pthread_create for hand switch error\n"); exit(1); } if (pthread_create(&tid_rst_btn, NULL, rst_btn_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for reset button error\n"); + syslog(LOG_WARNING, "pthread_create for reset button error\n"); exit(1); } if (pthread_create(&tid_pwr_btn, NULL, pwr_btn_handler, NULL) < 0) { - syslog(LOG_ALERT, "pthread_create for power button error\n"); + syslog(LOG_WARNING, "pthread_create for power button error\n"); + exit(1); + } + + if (pthread_create(&tid_hb, NULL, hb_handler, NULL) < 0) { + syslog(LOG_WARNING, "pthread_create for heart beat error\n"); exit(1); } @@ -443,15 +570,15 @@ main (int argc, char * const argv[]) { ip = malloc(sizeof(int)); *ip = i; if (pthread_create(&tid_leds[i], NULL, led_handler, (void*)ip) < 0) { - syslog(LOG_ALERT, "pthread_create for hand switch error\n"); + syslog(LOG_WARNING, "pthread_create for hand switch error\n"); exit(1); } } - pthread_join(tid_debug_card, NULL); pthread_join(tid_hand_sw, NULL); pthread_join(tid_rst_btn, NULL); pthread_join(tid_pwr_btn, NULL); + pthread_join(tid_hb, NULL); for (i = 0; i < MAX_NUM_SLOTS; i++) { pthread_join(tid_leds[i], NULL); } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb index 26db659..8eb4457 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/front-paneld/front-paneld_0.1.bb @@ -31,7 +31,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-front-paneld.sh ${D}${sysconfdir}/init.d/setup-front-paneld.sh - update-rc.d -r ${D} setup-front-paneld.sh start 67 S . + update-rc.d -r ${D} setup-front-paneld.sh start 67 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c index 9282e00..f4bf9f9 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/gpiod.c @@ -41,7 +41,7 @@ #define GETMASK(y) (1 << y) #define MAX_NUM_SLOTS 4 -#define GPIOD_READ_DELAY 1 +#define DELAY_GPIOD_READ 500000 // Polls each slot gpio values every 4*x usec #define SOCK_PATH_GPIO "/tmp/gpio_socket" /* To hold the gpio info and status */ @@ -77,7 +77,7 @@ get_struct_gpio_pin(uint8_t fru) { gpios = gpio_slot4; break; default: - syslog(LOG_ALERT, "get_struct_gpio_pin: Wrong SLOT ID %d\n", fru); + syslog(LOG_WARNING, "get_struct_gpio_pin: Wrong SLOT ID %d\n", fru); return NULL; } @@ -116,7 +116,7 @@ enable_gpio_intr_config(uint8_t fru, uint8_t gpio) { } if (verify_cfg.ie != cfg.ie) { - syslog(LOG_ALERT, "Slot_id: %u,Interrupt enabling FAILED for GPIO pin# %d", + syslog(LOG_WARNING, "Slot_id: %u,Interrupt enabling FAILED for GPIO pin# %d", fru, gpio); return -1; } @@ -133,22 +133,24 @@ enable_gpio_intr(uint8_t fru) { gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "enable_gpio_intr: get_struct_gpio_pin failed."); + syslog(LOG_WARNING, "enable_gpio_intr: get_struct_gpio_pin failed."); return; } for (i = 0; i < gpio_pin_cnt; i++) { + + gpios[i].flag = 0; + ret = enable_gpio_intr_config(fru, gpio_pin_list[i]); if (ret < 0) { - gpios[i].flag = 0; - syslog(LOG_ALERT, "enable_gpio_intr: Slot: %d, Pin %d interrupt enabling" + syslog(LOG_WARNING, "enable_gpio_intr: Slot: %d, Pin %d interrupt enabling" " failed", fru, gpio_pin_list[i]); - syslog(LOG_ALERT, "enable_gpio_intr: Disable check for Slot %d, Pin %d", + syslog(LOG_WARNING, "enable_gpio_intr: Disable check for Slot %d, Pin %d", fru, gpio_pin_list[i]); } else { gpios[i].flag = 1; #ifdef DEBUG - syslog(LOG_ALERT, "enable_gpio_intr: Enabled check for Slot: %d, Pin %d", + syslog(LOG_WARNING, "enable_gpio_intr: Enabled check for Slot: %d, Pin %d", fru, gpio_pin_list[i]); #endif /* DEBUG */ } @@ -164,12 +166,14 @@ populate_gpio_pins(uint8_t fru) { gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "populate_gpio_pins: get_struct_gpio_pin failed."); + syslog(LOG_WARNING, "populate_gpio_pins: get_struct_gpio_pin failed."); return; } for(i = 0; i < gpio_pin_cnt; i++) { - gpios[gpio_pin_list[i]].flag = 1; + // Only monitor the PWRGOOD_CPU pin + if (i == PWRGOOD_CPU) + gpios[gpio_pin_list[i]].flag = 1; } @@ -200,6 +204,7 @@ gpio_monitor_poll(uint8_t fru_flag) { uint8_t fru; uint32_t revised_pins, n_pin_val, o_pin_val[MAX_NUM_SLOTS + 1] = {0}; gpio_pin_t *gpios; + char pwr_state[MAX_VALUE_LEN]; uint32_t status; bic_gpio_t gpio = {0}; @@ -211,14 +216,16 @@ gpio_monitor_poll(uint8_t fru_flag) { ret = bic_get_gpio(fru, &gpio); if (ret) { - syslog(LOG_ALERT, "populate_gpio_pins: bic_get_gpio failed for " +#ifdef DEBUG + syslog(LOG_WARNING, "gpio_monitor_poll: bic_get_gpio failed for " " fru %u", fru); +#endif continue; } gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "gpio_monitor_poll: get_struct_gpio_pin failed for" + syslog(LOG_WARNING, "gpio_monitor_poll: get_struct_gpio_pin failed for" " fru %u", fru); continue; } @@ -227,7 +234,7 @@ gpio_monitor_poll(uint8_t fru_flag) { o_pin_val[fru] = 0; - for (i = 0; i <= MAX_GPIO_PINS; i++) { + for (i = 0; i < MAX_GPIO_PINS; i++) { if (gpios[i].flag == 0) continue; @@ -238,8 +245,8 @@ gpio_monitor_poll(uint8_t fru_flag) { o_pin_val[fru] = SETBIT(o_pin_val[fru], i); if (gpios[i].status == gpios[i].ass_val) { - syslog(LOG_CRIT, "ASSERT: fru: %u, gpio pin: %-20s, num: %d", - fru, gpios[i].name, i); + syslog(LOG_CRIT, "ASSERT: fru: %u, num: %d, gpio pin: %-20s", + fru, i, gpios[i].name); } } } @@ -248,48 +255,68 @@ gpio_monitor_poll(uint8_t fru_flag) { while(1) { for (fru = 1; fru <= MAX_NUM_SLOTS; fru++) { if (!(GETBIT(fru_flag, fru))) { - sleep(GPIOD_READ_DELAY); + usleep(DELAY_GPIOD_READ); continue; } gpios = get_struct_gpio_pin(fru); if (gpios == NULL) { - syslog(LOG_ALERT, "gpio_monitor_poll: get_struct_gpio_pin failed for" + syslog(LOG_WARNING, "gpio_monitor_poll: get_struct_gpio_pin failed for" " fru %u", fru); continue; } + memset(pwr_state, 0, MAX_VALUE_LEN); + pal_get_last_pwr_state(fru, pwr_state); + + /* Get the GPIO pins */ if ((ret = bic_get_gpio(fru, (bic_gpio_t *) &n_pin_val)) < 0) { - syslog(LOG_ALERT, "gpio_monitor_poll: bic_get_gpio failed for " - " fru %u", fru); + /* log the error message only when the CPU is on but not reachable. */ + if (!(strcmp(pwr_state, "on"))) { +#ifdef DEBUG + syslog(LOG_WARNING, "gpio_monitor_poll: bic_get_gpio failed for " + " fru %u", fru); +#endif + } continue; } if (o_pin_val[fru] == n_pin_val) { o_pin_val[fru] = n_pin_val; - sleep(GPIOD_READ_DELAY); + usleep(DELAY_GPIOD_READ); continue; } revised_pins = (n_pin_val ^ o_pin_val[fru]); for (i = 0; i < MAX_GPIO_PINS; i++) { - if (GETBIT(revised_pins, i) & gpios[i].flag) { + if (GETBIT(revised_pins, i) && (gpios[i].flag == 1)) { gpios[i].status = GETBIT(n_pin_val, i); // Check if the new GPIO val is ASSERT if (gpios[i].status == gpios[i].ass_val) { - syslog(LOG_CRIT, "ASSERT: fru: %u, gpio pin: %-20s, num: %d", - fru, gpios[i].name, i); + /* + * GPIO - PWRGOOD_CPU assert indicates that the CPU is turned off or in a bad shape. + * Raise an error and change the LPS from on to off or vice versa for deassert. + */ + if (!(strcmp(pwr_state, "on"))) + pal_set_last_pwr_state(fru, "off"); + + syslog(LOG_CRIT, "ASSERT: fru: %u, num: %d, gpio pin: %-20s", + fru, i, gpios[i].name); } else { - syslog(LOG_CRIT, "DEASSERT: fru: %u, gpio pin: %-20s, num: %d", - fru, gpios[i].name, i); + + if (!(strcmp(pwr_state, "off"))) + pal_set_last_pwr_state(fru, "on"); + + syslog(LOG_CRIT, "DEASSERT: fru: %u, num: %d, gpio pin: %-20s", + fru, i, gpios[i].name); } } } o_pin_val[fru] = n_pin_val; - sleep(GPIOD_READ_DELAY); + usleep(DELAY_GPIOD_READ); } /* For Loop for each fru */ } /* while loop */ @@ -297,7 +324,7 @@ gpio_monitor_poll(uint8_t fru_flag) { static void print_usage() { - printf("Usage: gpiod [ %s ]\n", "slot1, slot2, slot3, slot4"); + printf("Usage: gpiod [ %s ]\n", pal_server_list); } /* Spawns a pthread for each fru to monitor all the sensors on it */ diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh index 9e532f2..01df2cd 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/files/setup-gpiod.sh @@ -27,7 +27,28 @@ # Short-Description: Setup sensor monitoring ### END INIT INFO -# TODO: check for the if slot/server is present before starting the daemon +. /usr/local/fbpackages/utils/ast-functions + echo -n "Setup gpio monitoring for yosemite... " -/usr/local/bin/gpiod slot1 slot2 slot3 slot4 + +# Check for the slots present and run sensord for those slots only. +SLOTS= + if [ $(is_server_prsnt 1) == "1" ]; then + SLOTS="$SLOTS slot1" + fi + + if [ $(is_server_prsnt 2) == "1" ]; then + SLOTS="$SLOTS slot2" + fi + + if [ $(is_server_prsnt 3) == "1" ]; then + SLOTS="$SLOTS slot3" + fi + + if [ $(is_server_prsnt 4) == "1" ]; then + SLOTS="$SLOTS slot4" + fi + +/usr/local/bin/gpiod $SLOTS + echo "done." diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb index 2193a92..a815f36 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/gpiod/gpiod_0.1.bb @@ -50,7 +50,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-gpiod.sh ${D}${sysconfdir}/init.d/setup-gpiod.sh - update-rc.d -r ${D} setup-gpiod.sh start 91 S . + update-rc.d -r ${D} setup-gpiod.sh start 91 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend index bf2af1e..f2cc6a7 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmbd/ipmbd_0.1.bbappend @@ -3,6 +3,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" SRC_URI += " file://setup-ipmbd.sh \ " +DEPENDS_append = " fbutils " CFLAGS_prepend = " -DCONFIG_YOSEMITE" @@ -16,7 +17,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-ipmbd.sh ${D}${sysconfdir}/init.d/setup-ipmbd.sh - update-rc.d -r ${D} setup-ipmbd.sh start 65 S . + update-rc.d -r ${D} setup-ipmbd.sh start 65 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c index 5af03ce..938e076 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/bic.c @@ -42,7 +42,7 @@ lib_gpio_intr_handle(unsigned char *request, unsigned char req_len, // TODO: Need to update to reuse the socket instead of creating new if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: socket() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: socket() failed\n"); return; } @@ -51,12 +51,12 @@ lib_gpio_intr_handle(unsigned char *request, unsigned char req_len, len = strlen(remote.sun_path) + sizeof(remote.sun_family); if (connect(sockfd, (struct sockaddr *)&remote, len) == -1) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: connect() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: connect() failed\n"); return; } if (send(sockfd, request, req_len, 0) == -1) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: send() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: send() failed\n"); return; } @@ -64,9 +64,9 @@ lib_gpio_intr_handle(unsigned char *request, unsigned char req_len, *res_len = t; } else { if (t < 0) { - syslog(LOG_ALERT, "lib_gpio_intr_handle: recv() failed\n"); + syslog(LOG_WARNING, "lib_gpio_intr_handle: recv() failed\n"); } else { - printf("Server closed connection"); + syslog(LOG_WARNING, "Server closed connection"); } return; diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c index 04772d7..d3fb856 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/fruid.c @@ -34,12 +34,15 @@ #include "fruid.h" #define EEPROM_SPB "/sys/class/i2c-adapter/i2c-8/8-0051/eeprom" +#define EEPROM_NIC "/sys/class/i2c-adapter/i2c-12/12-0051/eeprom" #define BIN_SPB "/tmp/fruid_spb.bin" +#define BIN_NIC "/tmp/fruid_nic.bin" #define NAME_SPB "Side Plane Board" +#define NAME_NIC "Mezz Card" -#define BUF_SIZE 1024 +#define FRUID_SIZE 256 /* * copy_eeprom_to_bin - copy the eeprom to binary file im /tmp directory @@ -54,7 +57,7 @@ int copy_eeprom_to_bin(const char * eeprom_file, const char * bin_file) { int eeprom; int bin; - uint64_t tmp[BUF_SIZE]; + uint64_t tmp[FRUID_SIZE]; ssize_t bytes_rd, bytes_wr; errno = 0; @@ -75,13 +78,18 @@ int copy_eeprom_to_bin(const char * eeprom_file, const char * bin_file) { return errno; } - while ((bytes_rd = read(eeprom, tmp, BUF_SIZE)) > 0) { - bytes_wr = write(bin, tmp, bytes_rd); - if (bytes_wr != bytes_rd) { - syslog(LOG_ERR, "copy_eeprom_to_bin: write to %s file failed: %s", - bin_file, strerror(errno)); - return errno; - } + bytes_rd = read(eeprom, tmp, FRUID_SIZE); + if (bytes_rd != FRUID_SIZE) { + syslog(LOG_ERR, "copy_eeprom_to_bin: write to %s file failed: %s", + eeprom_file, strerror(errno)); + return errno; + } + + bytes_wr = write(bin, tmp, bytes_rd); + if (bytes_wr != bytes_rd) { + syslog(LOG_ERR, "copy_eeprom_to_bin: write to %s file failed: %s", + bin_file, strerror(errno)); + return errno; } close(bin); @@ -97,6 +105,7 @@ int plat_fruid_init(void) { int ret; ret = copy_eeprom_to_bin(EEPROM_SPB, BIN_SPB); + ret = copy_eeprom_to_bin(EEPROM_NIC, BIN_NIC); return ret; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/lan.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/lan.c new file mode 100644 index 0000000..3b36046 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/lan.c @@ -0,0 +1,127 @@ +/* + * lan.c + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */ +#include <arpa/inet.h> +#include <sys/socket.h> +#include <netdb.h> +#include <ifaddrs.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <net/if.h> +#include <linux/if_link.h> +#include <sys/ioctl.h> +#include <stdbool.h> +#include <openbmc/ipmi.h> + +#define ETH_INTF_NAME "eth0" + +#define IPV6_LINK_LOCAL_BYTE1 0xFE +#define IPV6_LINK_LOCAL_BYTE2 0x80 + +#define BYTE_MASK 0xFF +#define BYTE1_OFFSET 8 +#define BYTE2_OFFSET 16 +#define BYTE3_OFFSET 24 + +void plat_lan_init(lan_config_t *lan) +{ + struct ifaddrs *ifaddr, *ifa; + struct sockaddr_in *addr; + struct sockaddr_in6 *addr6; + int family, s, n, i; + unsigned long ip; + unsigned char *ip6; + int sd; + struct ifreq ifr; + uint8_t mac_addr[6]; + uint8_t eui_64_addr[8] = {0x0}; + bool slaac_flag = false; + char test[64]; + + if (getifaddrs(&ifaddr) == -1) { + return; + } + + for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { + if (ifa->ifa_addr == NULL) { + continue; + } + + if (strcmp(ifa->ifa_name, ETH_INTF_NAME)) { + continue; + } + + family = ifa->ifa_addr->sa_family; + + if (family == AF_INET) { + addr = (struct sockaddr_in*) ifa->ifa_addr; + ip = addr->sin_addr.s_addr; + + // copy the ip address from long to byte array with MSB first + lan->ip_addr[3] = (ip >> BYTE3_OFFSET) & BYTE_MASK; + lan->ip_addr[2] = (ip >> BYTE2_OFFSET) & BYTE_MASK; + lan->ip_addr[1] = (ip >> BYTE1_OFFSET) & BYTE_MASK; + lan->ip_addr[0] = ip & BYTE_MASK; + } else if (family == AF_INET6) { + addr6 = (struct sockaddr_in6*) ifa->ifa_addr; + ip6 = addr6->sin6_addr.s6_addr; + + // If the address is Link Local, Ignore it + if ((ip6[0] == IPV6_LINK_LOCAL_BYTE1) && (ip6[1] == IPV6_LINK_LOCAL_BYTE2)) { + continue; + } + + // Get the MAC address + sd = socket(PF_INET, SOCK_DGRAM, 0); + strcpy(ifr.ifr_name, ifa->ifa_name); + if(ioctl(sd, SIOCGIFHWADDR, &ifr) != -1) { + uint8_t* mac_addr = (uint8_t*)ifr.ifr_hwaddr.sa_data; + + /* + * SLAAC address has lower 8B as follows: + * 3B == First 24b MAC address + * 2B == FFFE + * 3B == Last 24b MAC address + */ + memcpy((void *)&eui_64_addr[0], (void *)&mac_addr[0], 3); + eui_64_addr[3] = 0xFF; + eui_64_addr[4] = 0xFE; + memcpy((void *)&eui_64_addr[5], (void *)&mac_addr[3], 3); + eui_64_addr[0] += 2; + + // Check if the address is SLAAC address. If yes, skip it. + if (!memcmp((void *)&ip6[8], (void *)eui_64_addr, 8)) { + slaac_flag = true; + } + } + + if (slaac_flag) + continue; + + // copy the ip address from array with MSB first + memcpy(lan->ip6_addr, ip6, SIZE_IP6_ADDR); + } + } + + freeifaddrs(ifaddr); +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c index 16cf98e..57ab5ec 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/files/sensor.c @@ -81,7 +81,7 @@ populate_mgmt_sensors(void) { // Add this sensor to the global table if (g_sensor_mgmt.num >= SENSOR_MGMT_MAX) { - syslog(LOG_ALERT, "populate_mgmt_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_mgmt_sensors: num exceeded\n"); return; } @@ -126,7 +126,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -166,7 +166,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -207,7 +207,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -245,7 +245,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -282,7 +282,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } @@ -323,7 +323,7 @@ populate_disc_sensors(void) { // Add this sensor to the global table if (g_sensor_disc.num >= SENSOR_DISC_MAX) { - syslog(LOG_ALERT, "populate_disc_sensors: num exceeded\n"); + syslog(LOG_WARNING, "populate_disc_sensors: num exceeded\n"); return; } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend index 4a92e78..57215c5 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/ipmid/ipmid_0.2.bbappend @@ -21,10 +21,13 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" SRC_URI += "file://setup-ipmid.sh \ file://sensor.c \ file://fruid.c \ + file://lan.c \ " S = "${WORKDIR}" +CFLAGS_prepend = " -DCONFIG_YOSEMITE " + do_install() { dst="${D}/usr/local/fbpackages/${pkgdir}" bin="${D}/usr/local/bin" @@ -35,7 +38,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-ipmid.sh ${D}${sysconfdir}/init.d/setup-ipmid.sh - update-rc.d -r ${D} setup-ipmid.sh start 64 S . + update-rc.d -r ${D} setup-ipmid.sh start 64 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile new file mode 100644 index 0000000..941ef10 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: me-util + +me-util: me-util.o + $(CC) $(CFLAGS) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o me-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c new file mode 100644 index 0000000..3a181b2 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c @@ -0,0 +1,119 @@ +/* + * me-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <string.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <facebook/bic.h> +#include <openbmc/ipmi.h> + +#define LOGFILE "/tmp/me-util.log" + +static void +print_usage_help(void) { + printf("Usage: me-util <slot1|slot2|slot3|slot4> <[0..n]data_bytes_to_send>\n"); +} + +int +main(int argc, char **argv) { + uint8_t slot_id; + uint8_t tbuf[256] = {0x00}; + uint8_t rbuf[256] = {0x00}; + uint8_t tlen = 0; + uint8_t rlen = 0; + int i; + int ret; + int logfd; + int len; + char log[128]; + char temp[8]; + + if (argc < 3) { + goto err_exit; + } + + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id = 2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id = 3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id = 4; + } else { + goto err_exit; + } + + for (i = 2; i < argc; i++) { + tbuf[tlen++] = (uint8_t)strtoul(argv[i], NULL, 0); + } + +#if 1 + ret = bic_me_xmit(slot_id, tbuf, tlen, rbuf, &rlen); + if (ret) { + return ret; + } +#endif + + // memcpy(rbuf, tbuf, tlen); + //rlen = tlen; + + + memset(log, 0, 128); + for (i = 0; i < rlen; i++) { + printf("%02X ", rbuf[i]); + memset(temp, 0, 8); + sprintf(temp, "%02X ", rbuf[i]); + strcat(log, temp); + } + printf("\n"); + sprintf(temp, "\n"); + strcat(log, temp); + + errno = 0; + + logfd = open(LOGFILE, O_CREAT | O_WRONLY); + if (logfd < 0) { + syslog(LOG_WARNING, "Opening a tmp file failed. errno: %d", errno); + return -1; + } + + len = write(logfd, log, strlen(log)); + if (len != strlen(log)) { + syslog(LOG_WARNING, "Error writing the log to the file"); + return -1; + } + + close(logfd); + + return 0; +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb new file mode 100644 index 0000000..02219f2 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb @@ -0,0 +1,38 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Management Engine Utility" +DESCRIPTION = "Util for communicating to Intel ME" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://me-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://me-util.c \ + file://Makefile \ + " + +S = "${WORKDIR}" + +binfiles = "me-util \ + " + +pkgdir = "me-util" + +DEPENDS = " libbic libpal " + +do_install() { + dst="${D}/usr/local/fbpackages/${pkgdir}" + bin="${D}/usr/local/bin" + install -d $dst + install -d $bin + for f in ${binfiles}; do + install -m 755 $f ${dst}/$f + ln -snf ../fbpackages/${pkgdir}/$f ${bin}/$f + done +} + +FBPACKAGEDIR = "${prefix}/local/fbpackages" + +FILES_${PN} = "${FBPACKAGEDIR}/me-util ${prefix}/local/bin" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend index ce33bba..701a8d1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/rest-api/rest-api_0.2.bbappend @@ -54,7 +54,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-rest-api.sh ${D}${sysconfdir}/init.d/setup-rest-api.sh - update-rc.d -r ${D} setup-rest-api.sh start 95 2 3 4 5 . + update-rc.d -r ${D} setup-rest-api.sh start 95 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh index 3f4b38e..f387d20 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/files/setup-sensord.sh @@ -29,7 +29,27 @@ . /usr/local/fbpackages/utils/ast-functions -# TODO: check for the if slot/server is present before starting the daemon echo -n "Setup sensor monitoring for yosemite... " -/usr/local/bin/sensord slot1 slot2 slot3 slot4 + +# Check for the slots present and run sensord for those slots only. +SLOTS= + if [ $(is_server_prsnt 1) == "1" ]; then + SLOTS="$SLOTS slot1" + fi + + if [ $(is_server_prsnt 2) == "1" ]; then + SLOTS="$SLOTS slot2" + fi + + if [ $(is_server_prsnt 3) == "1" ]; then + SLOTS="$SLOTS slot3" + fi + + if [ $(is_server_prsnt 4) == "1" ]; then + SLOTS="$SLOTS slot4" + fi + +SLOTS="$SLOTS spb nic" +/usr/local/bin/sensord $SLOTS + echo "done." diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend index 687a599..b920973 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend +++ b/meta-facebook/meta-yosemite/recipes-yosemite/sensor-mon/sensor-mon_0.1.bbappend @@ -22,11 +22,8 @@ SRC_URI += "file://setup-sensord.sh \ S = "${WORKDIR}" -CFLAGS_prepend = " -DCONFIG_YOSEMITE " -LDFLAGS_append = " -lyosemite_sensor " - -DEPENDS_append = "libyosemite-sensor update-rc.d-native" +DEPENDS_append = "update-rc.d-native" pkgdir = "sensor-mon" @@ -45,7 +42,7 @@ do_install() { install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-sensord.sh ${D}${sysconfdir}/init.d/setup-sensord.sh - update-rc.d -r ${D} setup-sensord.sh start 91 S . + update-rc.d -r ${D} setup-sensord.sh start 91 5 . } FBPACKAGEDIR = "${prefix}/local/fbpackages" |