Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/system/system.c

    r4285f384 r77a0119  
    3535 */
    3636
     37#include <devman.h>
    3738#include <fibril.h>
    3839#include <futil.h>
     
    4849#include <str.h>
    4950#include <loc.h>
     51#include <shutdown.h>
    5052#include <str_error.h>
    5153#include <config.h>
     
    8486
    8587static void system_srv_conn(ipc_call_t *, void *);
    86 static errno_t system_srv_shutdown(void *);
     88static errno_t system_srv_poweroff(void *);
     89static errno_t system_srv_restart(void *);
    8790
    8891system_ops_t system_srv_ops = {
    89         .shutdown = system_srv_shutdown
     92        .poweroff = system_srv_poweroff,
     93        .restart = system_srv_restart
    9094};
    9195
     
    519523        /* Eject all volumes. */
    520524
     525        log_msg(LOG_DEFAULT, LVL_NOTE, "Ejecting volumes.");
     526
    521527        rc = vol_create(&vol);
    522528        if (rc != EOK) {
     
    543549        free(part_ids);
    544550        vol_destroy(vol);
     551
    545552        return EOK;
    546553error:
     
    609616}
    610617
    611 /** System shutdown request.
     618/** System poweroff request.
    612619 *
    613620 * @param arg Argument (sys_srv_t *)
    614621 */
    615 static errno_t system_srv_shutdown(void *arg)
     622static errno_t system_srv_poweroff(void *arg)
    616623{
    617624        sys_srv_t *syssrv = (sys_srv_t *)arg;
    618625        errno_t rc;
    619626
    620         log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown");
     627        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff");
    621628
    622629        rc = system_sys_shutdown();
    623630        if (rc != EOK) {
    624                 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown failed");
     631                log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff failed");
    625632                system_srv_shutdown_failed(&syssrv->srv);
    626633        }
    627634
    628         log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown complete");
     635        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff complete");
     636        system_srv_shutdown_complete(&syssrv->srv);
     637        return EOK;
     638}
     639
     640/** System restart request.
     641 *
     642 * @param arg Argument (sys_srv_t *)
     643 */
     644static errno_t system_srv_restart(void *arg)
     645{
     646        sys_srv_t *syssrv = (sys_srv_t *)arg;
     647        errno_t rc;
     648
     649        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart");
     650
     651        rc = system_sys_shutdown();
     652        if (rc != EOK) {
     653                log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart failed");
     654                system_srv_shutdown_failed(&syssrv->srv);
     655        }
     656
     657        /* Quiesce the device tree. */
     658
     659        log_msg(LOG_DEFAULT, LVL_NOTE, "Quiescing devices.");
     660
     661        rc = devman_quiesce_devices("/hw");
     662        if (rc != EOK) {
     663                log_msg(LOG_DEFAULT, LVL_ERROR,
     664                    "Failed to quiesce device tree.");
     665                return rc;
     666        }
     667
     668        sys_reboot();
     669
     670        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart complete");
    629671        system_srv_shutdown_complete(&syssrv->srv);
    630672        return EOK;
Note: See TracChangeset for help on using the changeset viewer.