Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/log/log.c

    r690ad20 r163e34c  
    4646#include <print.h>
    4747#include <printf_core.h>
     48#include <putchar.h>
    4849#include <stdarg.h>
    4950#include <stdlib.h>
     
    5960
    6061/** Cyclic buffer holding the data for kernel log */
    61 static uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
     62uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
    6263
    6364/** Kernel log initialized */
     
    6566
    6667/** Position in the cyclic buffer where the first log entry starts */
    67 static size_t log_start = 0;
     68size_t log_start = 0;
    6869
    6970/** Sum of length of all log entries currently stored in the cyclic buffer */
    70 static size_t log_used = 0;
     71size_t log_used = 0;
    7172
    7273/** Log spinlock */
    73 static IRQ_SPINLOCK_INITIALIZE(log_lock);
     74SPINLOCK_STATIC_INITIALIZE_NAME(log_lock, "log_lock");
    7475
    7576/** Overall count of logged messages, which may overflow as needed */
     
    151152{
    152153        console_lock();
    153         irq_spinlock_lock(&log_lock, true);
    154         irq_spinlock_lock(&kio_lock, true);
     154        spinlock_lock(&log_lock);
     155        spinlock_lock(&kio_lock);
    155156
    156157        log_current_start = (log_start + log_used) % LOG_LENGTH;
     
    178179        log_used += log_current_len;
    179180
    180         kio_push_bytes("\n", 1);
    181         irq_spinlock_unlock(&kio_lock, true);
    182         irq_spinlock_unlock(&log_lock, true);
     181        kio_push_char('\n');
     182        spinlock_unlock(&kio_lock);
     183        spinlock_unlock(&log_lock);
    183184
    184185        /* This has to be called after we released the locks above */
     
    194195                return;
    195196
    196         irq_spinlock_lock(&log_lock, true);
     197        spinlock_lock(&log_lock);
    197198        if (next_for_uspace < log_used)
    198199                event_notify_0(EVENT_KLOG, true);
    199         irq_spinlock_unlock(&log_lock, true);
     200        spinlock_unlock(&log_lock);
    200201}
    201202
    202203static int log_printf_str_write(const char *str, size_t size, void *data)
    203204{
    204         kio_push_bytes(str, size);
     205        size_t offset = 0;
     206
     207        while (offset < size)
     208                kio_push_char(str_decode(str, &offset, size));
     209
    205210        log_append((const uint8_t *)str, size);
     211
    206212        return EOK;
    207213}
     
    301307                rc = EOK;
    302308
    303                 irq_spinlock_lock(&log_lock, true);
     309                spinlock_lock(&log_lock);
    304310
    305311                while (next_for_uspace < log_used) {
     
    331337                }
    332338
    333                 irq_spinlock_unlock(&log_lock, true);
     339                spinlock_unlock(&log_lock);
    334340
    335341                if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.