Ignore:
Timestamp:
Jul 20, 2017, 10:29:05 AM (7 years ago)
Author:
max@…
Message:

add a dumb lock for the console

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/x86_printf.c

    r234 r242  
    4242size_t cons_ptr __in_kdata = 0;
    4343
     44/* -------------------------------------------------------------------------- */
     45
     46static uint32_t x86_lock_val __in_kdata = 0;
     47
     48void x86_lock()
     49{
     50        while (!hal_atomic_cas(&x86_lock_val, 0, 1)) {
     51                /* wait */
     52        }
     53}
     54
     55void x86_unlock()
     56{
     57        while (!hal_atomic_cas(&x86_lock_val, 1, 0)) {
     58                /* wait */
     59        }
     60}
     61
     62/* -------------------------------------------------------------------------- */
     63
    4464void x86_panic(char *msg)
    4565{
     66        x86_lock();
    4667        x86_printf("!!!!! PANIC !!!!!\n");
    4768        x86_printf("-> %s\n", msg);
    4869        x86_printf("!!!!!!!!!!!!!!!!!\n");
     70        x86_unlock();
    4971        while (1);
    5072}
Note: See TracChangeset for help on using the changeset viewer.