Changeset eebecdc in mainline for uspace/srv/system/system.c


Ignore:
Timestamp:
2025-03-13T18:30:36Z (5 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
e3e53cc
Parents:
e494d7b (diff), da54714 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge upstream/master into helenraid

File:
1 edited

Legend:

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

    re494d7b reebecdc  
    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
     
    520524        /* Eject all volumes. */
    521525
     526        log_msg(LOG_DEFAULT, LVL_NOTE, "Ejecting volumes.");
     527
    522528        rc = vol_create(&vol);
    523529        if (rc != EOK) {
     
    544550        free(part_ids);
    545551        vol_destroy(vol);
     552
    546553        return EOK;
    547554error:
     
    610617}
    611618
    612 /** System shutdown request.
     619/** System poweroff request.
    613620 *
    614621 * @param arg Argument (sys_srv_t *)
    615622 */
    616 static errno_t system_srv_shutdown(void *arg)
     623static errno_t system_srv_poweroff(void *arg)
    617624{
    618625        sys_srv_t *syssrv = (sys_srv_t *)arg;
    619626        errno_t rc;
    620627
    621         log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown");
     628        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff");
    622629
    623630        rc = system_sys_shutdown();
    624631        if (rc != EOK) {
    625                 log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown failed");
     632                log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff failed");
    626633                system_srv_shutdown_failed(&syssrv->srv);
    627634        }
    628635
    629         log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_shutdown complete");
     636        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_poweroff complete");
     637        system_srv_shutdown_complete(&syssrv->srv);
     638        return EOK;
     639}
     640
     641/** System restart request.
     642 *
     643 * @param arg Argument (sys_srv_t *)
     644 */
     645static errno_t system_srv_restart(void *arg)
     646{
     647        sys_srv_t *syssrv = (sys_srv_t *)arg;
     648        errno_t rc;
     649
     650        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart");
     651
     652        rc = system_sys_shutdown();
     653        if (rc != EOK) {
     654                log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart failed");
     655                system_srv_shutdown_failed(&syssrv->srv);
     656        }
     657
     658        /* Quiesce the device tree. */
     659
     660        log_msg(LOG_DEFAULT, LVL_NOTE, "Quiescing devices.");
     661
     662        rc = devman_quiesce_devices("/hw");
     663        if (rc != EOK) {
     664                log_msg(LOG_DEFAULT, LVL_ERROR,
     665                    "Failed to quiesce device tree.");
     666                return rc;
     667        }
     668
     669        sys_reboot();
     670
     671        log_msg(LOG_DEFAULT, LVL_NOTE, "system_srv_restart complete");
    630672        system_srv_shutdown_complete(&syssrv->srv);
    631673        return EOK;
Note: See TracChangeset for help on using the changeset viewer.