Changeset f35749e in mainline for uspace/lib/system/src


Ignore:
Timestamp:
2025-02-28T23:38:26Z (5 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
8300c72
Parents:
4285f384
Message:

System restart via shutdown -r

Location:
uspace/lib/system/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/system/src/system.c

    r4285f384 rf35749e  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    141141}
    142142
    143 /** Shut the system down.
     143/** Shut down and power the system off.
    144144 *
    145145 * This function is asynchronous. It returns immediately with success
     
    151151 * @return EOK on succes or an error code
    152152 */
    153 errno_t system_shutdown(system_t *system)
     153errno_t system_poweroff(system_t *system)
    154154{
    155155        async_exch_t *exch = async_exchange_begin(system->sess);
    156         errno_t rc = async_req_0_0(exch, SYSTEM_SHUTDOWN);
     156        errno_t rc = async_req_0_0(exch, SYSTEM_POWEROFF);
     157        async_exchange_end(exch);
     158
     159        return rc;
     160}
     161
     162/** Shut down and restart the system.
     163 *
     164 * This function is asynchronous. It returns immediately with success
     165 * if the system started shutting down. Once shutdown is completed,
     166 * the @c shutdown_complete callback is executed. If the shutdown fails,
     167 * the @c shutdown_fail callback is executed.
     168 *
     169 * @param system System control service
     170 * @return EOK on succes or an error code
     171 */
     172errno_t system_restart(system_t *system)
     173{
     174        async_exch_t *exch = async_exchange_begin(system->sess);
     175        errno_t rc = async_req_0_0(exch, SYSTEM_RESTART);
    157176        async_exchange_end(exch);
    158177
  • uspace/lib/system/src/system_srv.c

    r4285f384 rf35749e  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5555}
    5656
    57 static void system_shutdown_srv(system_srv_t *srv, ipc_call_t *icall)
     57static void system_poweroff_srv(system_srv_t *srv, ipc_call_t *icall)
    5858{
    5959        errno_t rc;
    6060
    61         if (srv->ops->shutdown == NULL) {
     61        if (srv->ops->poweroff == NULL) {
    6262                async_answer_0(icall, ENOTSUP);
    6363                return;
    6464        }
    6565
    66         rc = srv->ops->shutdown(srv->arg);
     66        rc = srv->ops->poweroff(srv->arg);
     67        async_answer_0(icall, rc);
     68}
     69
     70static void system_restart_srv(system_srv_t *srv, ipc_call_t *icall)
     71{
     72        errno_t rc;
     73
     74        if (srv->ops->restart == NULL) {
     75                async_answer_0(icall, ENOTSUP);
     76                return;
     77        }
     78
     79        rc = srv->ops->restart(srv->arg);
    6780        async_answer_0(icall, rc);
    6881}
     
    89102                        system_callback_create_srv(srv, &call);
    90103                        break;
    91                 case SYSTEM_SHUTDOWN:
    92                         system_shutdown_srv(srv, &call);
     104                case SYSTEM_POWEROFF:
     105                        system_poweroff_srv(srv, &call);
     106                        break;
     107                case SYSTEM_RESTART:
     108                        system_restart_srv(srv, &call);
    93109                        break;
    94110                default:
Note: See TracChangeset for help on using the changeset viewer.