Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/main/shutdown.c

    rf35749e rbab75df6  
    11/*
    2  * Copyright (c) 2025 Jiri Svoboda
    32 * Copyright (c) 2007 Martin Decky
    43 * All rights reserved.
     
    3837
    3938#include <arch.h>
    40 #include <errno.h>
     39#include <proc/task.h>
    4140#include <halt.h>
    4241#include <log.h>
    43 #include <main/main.h>
    44 #include <main/shutdown.h>
    45 #include <proc/task.h>
    46 #include <proc/thread.h>
    47 
    48 static thread_t *reboot_thrd = NULL;
    49 SPINLOCK_INITIALIZE(reboot_lock);
    5042
    5143void reboot(void)
    5244{
    53         task_done(kernel_task);
     45        task_done();
    5446
    5547#ifdef CONFIG_DEBUG
     
    6153}
    6254
    63 /** Thread procedure for rebooting the system.
    64  *
    65  * @param arg Argument (unused)
    66  */
    67 static void reboot_thrd_proc(void *arg)
    68 {
    69         (void)arg;
    70 
    71         reboot();
    72 }
    73 
    74 /** Reboot the system.
    75  *
    76  * @return EOK if reboot started successfully. EBUSY if reboot already
    77  *         started, ENOMEM if out of memory.
    78  */
    79 sys_errno_t sys_reboot(void)
    80 {
    81         thread_t *thread;
    82 
    83         thread = thread_create(reboot_thrd_proc, NULL, kernel_task,
    84             THREAD_FLAG_NONE, "reboot");
    85         if (thread == NULL)
    86                 return ENOMEM;
    87 
    88         spinlock_lock(&reboot_lock);
    89 
    90         if (reboot_thrd != NULL) {
    91                 spinlock_unlock(&reboot_lock);
    92                 thread_put(thread);
    93                 return EBUSY;
    94         }
    95 
    96         reboot_thrd = thread;
    97 
    98         spinlock_unlock(&reboot_lock);
    99 
    100         thread_start(thread);
    101         thread_detach(thread);
    102 
    103         return EOK;
    104 }
    105 
    10655/** @}
    10756 */
Note: See TracChangeset for help on using the changeset viewer.