Changeset 40043e8 in mainline for kernel/generic/src/main/shutdown.c


Ignore:
Timestamp:
2019-07-18T08:25:42Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
0116f21
Parents:
2cc569a3
Message:

Restructering halt/reboot files

The function halt() and reboot() used to be stored
in two different c files and two different header
files which were named differently than the c files.
This commit merges those two functions into the
same file and provides an unique header file (shutdown.h)
for accessing them.

File:
1 edited

Legend:

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

    r2cc569a3 r40043e8  
    11/*
    22 * Copyright (c) 2007 Martin Decky
     3 * Copyright (c) 2001-2004 Jakub Jermar
    34 * All rights reserved.
    45 *
     
    3637 */
    3738
     39#include <shutdown.h>
     40#include <log.h>
     41#include <cpu.h>
     42#include <arch/asm.h>
    3843#include <arch.h>
     44#include <console/kconsole.h>
    3945#include <proc/task.h>
    40 #include <halt.h>
    41 #include <log.h>
     46
     47/** Halt flag */
     48atomic_t haltstate = 0;
     49
     50/** Halt wrapper
     51 *
     52 * Set halt flag and halt the CPU.
     53 *
     54 */
     55void halt(void)
     56{
     57#if (defined(CONFIG_DEBUG)) && (defined(CONFIG_KCONSOLE))
     58        bool rundebugger = false;
     59
     60        if (!atomic_load(&haltstate)) {
     61                atomic_store(&haltstate, 1);
     62                rundebugger = true;
     63        }
     64#else
     65        atomic_store(&haltstate, 1);
     66#endif
     67
     68        interrupts_disable();
     69
     70#if (defined(CONFIG_DEBUG)) && (defined(CONFIG_KCONSOLE))
     71        if ((rundebugger) && (kconsole_check_poll()))
     72                kconsole("panic", "\nLast resort kernel console ready.\n", false);
     73#endif
     74
     75        if (CPU)
     76                log(LF_OTHER, LVL_NOTE, "cpu%u: halted", CPU->id);
     77        else
     78                log(LF_OTHER, LVL_NOTE, "cpu: halted");
     79
     80        cpu_halt();
     81}
    4282
    4383void reboot(void)
Note: See TracChangeset for help on using the changeset viewer.