Changeset 61c91532 in mainline for kernel/generic/src/log/log.c


Ignore:
Timestamp:
2025-04-17T16:18:27Z (5 days ago)
Author:
GitHub <noreply@…>
Children:
634340fd
Parents:
a65ccc4 (diff), 888c06e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Wayne Thornton <wmthornton-dev@…> (2025-04-17 16:18:27)
git-committer:
GitHub <noreply@…> (2025-04-17 16:18:27)
Message:

Merge branch 'HelenOS:master' into master

File:
1 edited

Legend:

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

    ra65ccc4 r61c91532  
    4646#include <print.h>
    4747#include <printf_core.h>
    48 #include <putchar.h>
    4948#include <stdarg.h>
    5049#include <stdlib.h>
     
    6059
    6160/** Cyclic buffer holding the data for kernel log */
    62 uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
     61static uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
    6362
    6463/** Kernel log initialized */
     
    6665
    6766/** Position in the cyclic buffer where the first log entry starts */
    68 size_t log_start = 0;
     67static size_t log_start = 0;
    6968
    7069/** Sum of length of all log entries currently stored in the cyclic buffer */
    71 size_t log_used = 0;
     70static size_t log_used = 0;
    7271
    7372/** Log spinlock */
    74 SPINLOCK_STATIC_INITIALIZE_NAME(log_lock, "log_lock");
     73static IRQ_SPINLOCK_INITIALIZE(log_lock);
    7574
    7675/** Overall count of logged messages, which may overflow as needed */
     
    152151{
    153152        console_lock();
    154         spinlock_lock(&log_lock);
    155         spinlock_lock(&kio_lock);
     153        irq_spinlock_lock(&log_lock, true);
     154        irq_spinlock_lock(&kio_lock, true);
    156155
    157156        log_current_start = (log_start + log_used) % LOG_LENGTH;
     
    179178        log_used += log_current_len;
    180179
    181         kio_push_char('\n');
    182         spinlock_unlock(&kio_lock);
    183         spinlock_unlock(&log_lock);
     180        kio_push_bytes("\n", 1);
     181        irq_spinlock_unlock(&kio_lock, true);
     182        irq_spinlock_unlock(&log_lock, true);
    184183
    185184        /* This has to be called after we released the locks above */
     
    195194                return;
    196195
    197         spinlock_lock(&log_lock);
     196        irq_spinlock_lock(&log_lock, true);
    198197        if (next_for_uspace < log_used)
    199198                event_notify_0(EVENT_KLOG, true);
    200         spinlock_unlock(&log_lock);
     199        irq_spinlock_unlock(&log_lock, true);
    201200}
    202201
    203202static int log_printf_str_write(const char *str, size_t size, void *data)
    204203{
    205         size_t offset = 0;
    206 
    207         while (offset < size)
    208                 kio_push_char(str_decode(str, &offset, size));
    209 
     204        kio_push_bytes(str, size);
    210205        log_append((const uint8_t *)str, size);
    211 
    212206        return EOK;
    213207}
     
    307301                rc = EOK;
    308302
    309                 spinlock_lock(&log_lock);
     303                irq_spinlock_lock(&log_lock, true);
    310304
    311305                while (next_for_uspace < log_used) {
     
    337331                }
    338332
    339                 spinlock_unlock(&log_lock);
     333                irq_spinlock_unlock(&log_lock, true);
    340334
    341335                if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.