Changeset eebecdc in mainline for uspace/app


Ignore:
Timestamp:
2025-03-13T18:30:36Z (7 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

Location:
uspace/app
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/devctl/devctl.c

    re494d7b reebecdc  
    11/*
    2  * Copyright (c) 2011 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    198198}
    199199
     200static errno_t fun_quiesce(const char *path)
     201{
     202        devman_handle_t funh;
     203        errno_t rc;
     204
     205        rc = devman_fun_get_handle(path, &funh, 0);
     206        if (rc != EOK) {
     207                printf(NAME ": Error resolving device function '%s' (%s)\n",
     208                    path, str_error(rc));
     209                return rc;
     210        }
     211
     212        rc = devman_fun_quiesce(funh);
     213        if (rc != EOK) {
     214                printf(NAME ": Failed to offline function '%s' (%s)\n", path,
     215                    str_error(rc));
     216                return rc;
     217        }
     218
     219        return EOK;
     220}
     221
    200222static errno_t drv_list(void)
    201223{
     
    409431                        return 2;
    410432                }
     433        } else if (str_cmp(argv[1], "quiesce") == 0) {
     434                if (argc < 3) {
     435                        printf(NAME ": Argument missing.\n");
     436                        print_syntax();
     437                        return 1;
     438                }
     439
     440                rc = fun_quiesce(argv[2]);
     441                if (rc != EOK) {
     442                        return 2;
     443                }
    411444        } else if (str_cmp(argv[1], "list-drv") == 0) {
    412445                rc = drv_list();
  • uspace/app/shutdown-dlg/shutdown-dlg.c

    re494d7b reebecdc  
    4141#include <ui/fixed.h>
    4242#include <ui/label.h>
     43#include <ui/list.h>
    4344#include <ui/msgdialog.h>
    4445#include <ui/resource.h>
     46#include <ui/selectdialog.h>
    4547#include <ui/ui.h>
    4648#include <ui/window.h>
     
    5052static errno_t bg_wnd_paint(ui_window_t *, void *);
    5153static void shutdown_progress_destroy(shutdown_progress_t *);
    52 static errno_t shutdown_confirm_msg_create(shutdown_dlg_t *);
     54static errno_t shutdown_confirm_create(shutdown_dlg_t *);
    5355static errno_t shutdown_failed_msg_create(shutdown_dlg_t *);
    54 static errno_t shutdown_start(shutdown_dlg_t *);
     56static errno_t shutdown_start(shutdown_dlg_t *, sd_action_t);
    5557
    5658static ui_window_cb_t bg_window_cb = {
     
    7173};
    7274
    73 static void shutdown_confirm_msg_button(ui_msg_dialog_t *, void *, unsigned);
    74 static void shutdown_confirm_msg_close(ui_msg_dialog_t *, void *);
    75 
    76 static ui_msg_dialog_cb_t shutdown_confirm_msg_cb = {
    77         .button = shutdown_confirm_msg_button,
    78         .close = shutdown_confirm_msg_close
     75static void shutdown_confirm_bok(ui_select_dialog_t *, void *, void *);
     76static void shutdown_confirm_bcancel(ui_select_dialog_t *, void *);
     77static void shutdown_confirm_close(ui_select_dialog_t *, void *);
     78
     79static ui_select_dialog_cb_t shutdown_confirm_cb = {
     80        .bok = shutdown_confirm_bok,
     81        .bcancel = shutdown_confirm_bcancel,
     82        .close = shutdown_confirm_close
    7983};
    8084
     
    166170 * @return EOK on success or an error code
    167171 */
    168 static errno_t shutdown_confirm_msg_create(shutdown_dlg_t *sddlg)
    169 {
    170         ui_msg_dialog_params_t params;
    171         ui_msg_dialog_t *dialog;
    172         errno_t rc;
    173 
    174         ui_msg_dialog_params_init(&params);
     172static errno_t shutdown_confirm_create(shutdown_dlg_t *sddlg)
     173{
     174        ui_select_dialog_params_t params;
     175        ui_select_dialog_t *dialog;
     176        ui_list_entry_attr_t attr;
     177        errno_t rc;
     178
     179        ui_select_dialog_params_init(&params);
    175180        params.caption = "Shutdown";
    176         params.text = "Do you want to shut the system down?";
    177         params.choice = umdc_ok_cancel;
    178         params.flags |= umdf_topmost | umdf_center;
    179 
    180         rc = ui_msg_dialog_create(sddlg->ui, &params, &dialog);
     181        params.prompt = "Do you want to shut the system down?";
     182        params.flags |= usdf_topmost | usdf_center;
     183
     184        rc = ui_select_dialog_create(sddlg->ui, &params, &dialog);
    181185        if (rc != EOK)
    182186                return rc;
    183187
    184         ui_msg_dialog_set_cb(dialog, &shutdown_confirm_msg_cb, sddlg);
     188        /* Need an entry to select */
     189        ui_list_entry_attr_init(&attr);
     190
     191        attr.caption = "Power off";
     192        attr.arg = (void *)sd_poweroff;
     193        rc = ui_select_dialog_append(dialog, &attr);
     194        if (rc != EOK)
     195                goto error;
     196
     197        attr.caption = "Restart";
     198        attr.arg = (void *)sd_restart;
     199        rc = ui_select_dialog_append(dialog, &attr);
     200        if (rc != EOK)
     201                goto error;
     202
     203        ui_select_dialog_set_cb(dialog, &shutdown_confirm_cb, sddlg);
     204
     205        (void)ui_select_dialog_paint(dialog);
    185206
    186207        return EOK;
     208error:
     209        ui_select_dialog_destroy(dialog);
     210        return rc;
    187211}
    188212
     
    211235}
    212236
    213 /** Shutdown confirm message dialog button press.
     237/** Shutdown confirm dialog OK button press.
    214238 *
    215239 * @param dialog Message dialog
    216240 * @param arg Argument (ui_demo_t *)
    217  * @param bnum Button number
    218  */
    219 static void shutdown_confirm_msg_button(ui_msg_dialog_t *dialog,
    220     void *arg, unsigned bnum)
     241 * @param earg Entry argument
     242 */
     243static void shutdown_confirm_bok(ui_select_dialog_t *dialog, void *arg,
     244    void *earg)
    221245{
    222246        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
    223247
    224         ui_msg_dialog_destroy(dialog);
    225 
    226         if (bnum == 0)
    227                 shutdown_start(sddlg);
    228         else
    229                 ui_quit(sddlg->ui);
    230 }
    231 
    232 /** Shutdown confirm message dialog close request.
     248        ui_select_dialog_destroy(dialog);
     249
     250        shutdown_start(sddlg, (sd_action_t)earg);
     251}
     252
     253/** Shutdown confirm dialog Cancel button press.
    233254 *
    234255 * @param dialog Message dialog
    235256 * @param arg Argument (ui_demo_t *)
    236257 */
    237 static void shutdown_confirm_msg_close(ui_msg_dialog_t *dialog, void *arg)
     258static void shutdown_confirm_bcancel(ui_select_dialog_t *dialog, void *arg)
    238259{
    239260        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
    240261
    241         ui_msg_dialog_destroy(dialog);
     262        ui_select_dialog_destroy(dialog);
     263        ui_quit(sddlg->ui);
     264}
     265
     266/** Shutdown confirm message dialog close request.
     267 *
     268 * @param dialog Message dialog
     269 * @param arg Argument (ui_demo_t *)
     270 */
     271static void shutdown_confirm_close(ui_select_dialog_t *dialog, void *arg)
     272{
     273        shutdown_dlg_t *sddlg = (shutdown_dlg_t *) arg;
     274
     275        ui_select_dialog_destroy(dialog);
    242276        ui_quit(sddlg->ui);
    243277}
     
    386420}
    387421
    388 static errno_t shutdown_start(shutdown_dlg_t *sddlg)
     422/** Start shutdown.
     423 *
     424 * @param sddlg Shutdown dialog
     425 * @param action Shutdown actin
     426 * @return EOK on success or an error code
     427 */
     428static errno_t shutdown_start(shutdown_dlg_t *sddlg, sd_action_t action)
    389429{
    390430        errno_t rc;
     
    400440        }
    401441
    402         rc = system_shutdown(sddlg->system);
     442        rc = EINVAL;
     443
     444        switch (action) {
     445        case sd_poweroff:
     446                rc = system_poweroff(sddlg->system);
     447                break;
     448        case sd_restart:
     449                rc = system_restart(sddlg->system);
     450                break;
     451        }
     452
    403453        if (rc != EOK) {
    404454                printf("Failed requesting system shutdown.\n");
     
    469519        }
    470520
    471         (void)shutdown_confirm_msg_create(&sddlg);
     521        (void)shutdown_confirm_create(&sddlg);
    472522
    473523        ui_run(ui);
  • uspace/app/shutdown-dlg/shutdown-dlg.h

    re494d7b reebecdc  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6060} shutdown_dlg_t;
    6161
     62/** Shutdown action */
     63typedef enum {
     64        sd_poweroff = 1,
     65        sd_restart
     66} sd_action_t;
     67
    6268#endif
    6369
  • uspace/app/shutdown/shutdown.c

    re494d7b reebecdc  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939#include <fibril_synch.h>
    4040#include <nchoice.h>
     41#include <shutdown.h>
    4142#include <stdio.h>
    4243#include <stdbool.h>
     
    113114
    114115        rc = nchoice_add(nchoice, "Power off", (void *)(uintptr_t)sd_poweroff,
     116            0);
     117        if (rc != EOK) {
     118                printf(NAME ": Out of memory.\n");
     119                goto error;
     120        }
     121
     122        rc = nchoice_add(nchoice, "Restart", (void *)(uintptr_t)sd_restart,
    115123            0);
    116124        if (rc != EOK) {
     
    157165                        action = sd_poweroff;
    158166                        continue;
     167                } else if (str_cmp(*argv, "-r") == 0) {
     168                        --argc;
     169                        ++argv;
     170                        action = sd_restart;
     171                        continue;
    159172                }
    160173
     
    187200        }
    188201
    189         rc = system_shutdown(system);
     202        switch (action) {
     203        case sd_poweroff:
     204                rc = system_poweroff(system);
     205                break;
     206        case sd_restart:
     207                rc = system_restart(system);
     208                break;
     209        case sd_cancel:
     210                assert(false);
     211                rc = EINVAL;
     212                break;
     213        }
     214
    190215        if (rc != EOK) {
    191216                system_close(system);
     
    223248            "\tshutdown [<options>]\n"
    224249            "options:\n"
    225             "\t-p Power off\n");
     250            "\t-p Power off\n"
     251            "\t-r Restart off\n");
    226252}
    227253
  • uspace/app/shutdown/shutdown.h

    re494d7b reebecdc  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343typedef enum {
    4444        sd_poweroff = 1,
     45        sd_restart,
    4546        sd_cancel
    4647} sd_action_t;
  • uspace/app/trace/syscalls.c

    re494d7b reebecdc  
    11/*
    2  * Copyright (c) 2008 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4040        /* System management syscalls. */
    4141        [SYS_KIO] = { "kio", 3, V_INT_ERRNO },
     42        [SYS_REBOOT] = { "reboot", 0, V_ERRNO },
    4243
    4344        /* Thread and task related syscalls. */
Note: See TracChangeset for help on using the changeset viewer.