Changeset 242 for trunk/hal


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

add a dumb lock for the console

Location:
trunk/hal/x86_64/core
Files:
3 edited

Legend:

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

    r234 r242  
    6969        }
    7070
     71        x86_lock();
    7172        x86_printf("\n****** EXCEPTION OCCURRED ******\n");
    7273        x86_printf("%s\n", (char *)buf);
     
    7778                x86_printf("-> va  = %Z\n", rcr2());
    7879        x86_printf("****** EXCEPTION OCCURRED ******\n\n");
     80        x86_unlock();
    7981
    8082        while (1);
  • trunk/hal/x86_64/core/hal_internal.h

    r236 r242  
    7979
    8080/* x86_printf.c */
     81void x86_lock();
     82void x86_unlock();
     83
    8184void x86_panic(char *msg);
    8285void x86_putc(char c);
  • 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.