Print this page
7158 powerd shouldn't call autos3 trigger on sparc

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/power/powerd.c
          +++ new/usr/src/cmd/power/powerd.c
↓ open down ↓ 116 lines elided ↑ open up ↑
 117  117  static char *autoshutdown_cmd[] = {
 118  118          "/usr/bin/sys-suspend",
 119  119          "-n", "-d", ":0", NULL
 120  120  };
 121  121  
 122  122  static char *power_button_cmd[] = {
 123  123          "/usr/bin/sys-suspend",
 124  124          "-h", "-d", ":0", NULL
 125  125  };
 126  126  
      127 +#ifdef __x86
 127  128  static char *autoS3_cmd[] = {
 128  129          "/usr/bin/sys-suspend",
 129  130          "-n", "-d", ":0", NULL
 130  131  };
      132 +#endif
 131  133  
 132  134  static char pidpath[] = PIDPATH;
 133  135  static char scratch[PATH_MAX];
 134  136  static char *prog;
 135  137  
 136  138  /* Local Functions */
 137  139  static void alarm_handler(int);
 138  140  static void thaw_handler(int);
 139  141  static void kill_handler(int);
 140  142  static void work_handler(int);
↓ open down ↓ 3 lines elided ↑ open up ↑
 144  146  static int run_idlecheck(void);
 145  147  static void set_alarm(time_t);
 146  148  static int poweroff(const char *, char **);
 147  149  static int is_ok2shutdown(time_t *);
 148  150  static int get_prom(int, prom_node_t, char *, char *, size_t);
 149  151  static void power_button_monitor(void *);
 150  152  static int open_pidfile(char *);
 151  153  static int write_pidfile(int, pid_t);
 152  154  static int read_cpr_config(void);
 153  155  static void system_activity_monitor(void);
      156 +#ifdef __x86
 154  157  static void autos3_monitor(void);
      158 +#endif
 155  159  static void do_attach(void);
 156  160  static void *attach_devices(void *);
 157  161  static int powerd_debug;
 158  162  
 159  163  /* PRINTFLIKE1 */
 160  164  static void
 161  165  logerror(const char *fmt, ...)
 162  166  {
 163  167          va_list args;
 164  168  
↓ open down ↓ 152 lines elided ↑ open up ↑
 317  321           * system if idle.
 318  322           */
 319  323          if (powerd_debug)
 320  324                  logerror("powerd starting system activity monitor.");
 321  325          if (thr_create(NULL, NULL,
 322  326              (void *(*)(void *))system_activity_monitor, NULL,
 323  327              THR_DAEMON, NULL) != 0) {
 324  328                  logerror("Unable to create thread to monitor system activity.");
 325  329          }
 326  330  
      331 +#ifdef __x86
 327  332          /*
 328  333           * Create a new thread to handle autos3 trigger
 329  334           */
 330  335          if (powerd_debug)
 331  336                  logerror("powerd starting autos3 monitor.");
 332  337          if (thr_create(NULL, NULL,
 333  338              (void *(*)(void *))autos3_monitor, NULL, THR_DAEMON, NULL) != 0) {
 334  339                  logerror("Unable to create thread to monitor autos3 activity.");
 335  340          }
      341 +#endif
 336  342  
 337  343          /*
 338  344           * Block until we receive an explicit terminate signal
 339  345           */
 340  346          (void) sigsuspend(&sigmask);
 341  347  
 342  348          return (1);
 343  349  }
 344  350  
 345  351  static void
↓ open down ↓ 34 lines elided ↑ open up ↑
 380  386          (void) thr_sigsetmask(0, 0, &sigmask);
 381  387          (void) sigdelset(&sigmask, SIGHUP);
 382  388          (void) sigdelset(&sigmask, SIGALRM);
 383  389          (void) sigdelset(&sigmask, SIGTHAW);
 384  390          (void) thr_sigsetmask(SIG_SETMASK, &sigmask, NULL);
 385  391          do {
 386  392                  (void) sigsuspend(&sigmask);
 387  393          } while (errno == EINTR);
 388  394  }
 389  395  
      396 +#ifdef __x86
 390  397  static void
 391  398  autos3_monitor(void)
 392  399  {
 393  400          struct pollfd poll_fd;
 394  401          srn_event_info_t srn_event;             /* contains suspend type */
 395  402          int fd, ret;
 396  403  
 397  404          fd = open(SRN, O_RDWR|O_EXCL|O_NDELAY);
 398  405          if (fd == -1) {
 399  406                  logerror("Unable to open %s: %s", SRN, strerror(errno));
↓ open down ↓ 40 lines elided ↑ open up ↑
 440  447                          break;
 441  448                  default:
 442  449                          logerror("Unsupported target state %d",
 443  450                              srn_event.ae_type);
 444  451                          continue;
 445  452                  }
 446  453                  (void) poweroff("AutoS3", autoS3_cmd);
 447  454                  continue;
 448  455          }
 449  456  }
      457 +#endif
 450  458  
 451  459  static int
 452  460  read_cpr_config(void)
 453  461  {
 454  462          int     asfd;
 455  463  
 456  464          if ((asfd = open(CPR_CONFIG, O_RDONLY)) < 0) {
 457  465                  logerror("Unable to open CPR config file '%s'", CPR_CONFIG);
 458  466                  return (-1);
 459  467          }
↓ open down ↓ 616 lines elided ↑ open up ↑
1076 1084  }
1077 1085  
1078 1086  #define PBUFSIZE        256
1079 1087  
1080 1088  /*
1081 1089   * Gets the value of a prom property at either root or options node.  It
1082 1090   * returns 1 if it is successful, otherwise it returns 0 .
1083 1091   */
1084 1092  static int
1085 1093  get_prom(int prom_fd, prom_node_t node_name,
1086      -        char *property_name, char *property_value, size_t len)
     1094 +    char *property_name, char *property_value, size_t len)
1087 1095  {
1088 1096          union {
1089 1097                  char buf[PBUFSIZE + sizeof (uint_t)];
1090 1098                  struct openpromio opp;
1091 1099          } oppbuf;
1092 1100          register struct openpromio *opp = &(oppbuf.opp);
1093 1101          int     got_it = 0;
1094 1102  
1095 1103          if (prom_fd == -1) {
1096 1104                  return (0);
↓ open down ↓ 260 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX