Changeset 571cc2d in mainline


Ignore:
Timestamp:
2025-04-17T15:14:03Z (5 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
d5b37b6
Parents:
af77459
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-11 15:56:15)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:14:03)
Message:

Use irq_spinlock_t instead of plain spinlock_t in console code

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/console.h

    raf77459 r571cc2d  
    6767extern void kio_flush(void);
    6868extern void kio_push_char(const char32_t);
    69 SPINLOCK_EXTERN(kio_lock);
     69extern irq_spinlock_t kio_lock;
    7070
    7171extern sys_errno_t sys_kio(int cmd, uspace_addr_t buf, size_t size);
  • kernel/generic/src/console/console.c

    raf77459 r571cc2d  
    8686
    8787/** Kernel log spinlock */
    88 SPINLOCK_INITIALIZE_NAME(kio_lock, "kio_lock");
     88IRQ_SPINLOCK_INITIALIZE(kio_lock);
    8989
    9090/** Physical memory area used for kio buffer */
     
    254254                return;
    255255
    256         spinlock_lock(&kio_lock);
     256        irq_spinlock_lock(&kio_lock, true);
    257257
    258258        if (kio_notified != kio_written) {
     
    261261        }
    262262
    263         spinlock_unlock(&kio_lock);
     263        irq_spinlock_unlock(&kio_lock, true);
    264264}
    265265
     
    274274                return;
    275275
    276         spinlock_lock(&kio_lock);
     276        irq_spinlock_lock(&kio_lock, true);
    277277
    278278        /* Print characters that weren't printed earlier */
     
    286286                 * the character.
    287287                 */
    288                 spinlock_unlock(&kio_lock);
     288                irq_spinlock_unlock(&kio_lock, true);
    289289                stdout->op->write(stdout, tmp);
    290                 spinlock_lock(&kio_lock);
    291         }
    292 
    293         spinlock_unlock(&kio_lock);
     290                irq_spinlock_lock(&kio_lock, true);
     291        }
     292
     293        irq_spinlock_unlock(&kio_lock, true);
    294294}
    295295
     
    308308        bool ordy = ((stdout) && (stdout->op->write));
    309309
    310         spinlock_lock(&kio_lock);
     310        irq_spinlock_lock(&kio_lock, true);
    311311        kio_push_char(ch);
    312         spinlock_unlock(&kio_lock);
     312        irq_spinlock_unlock(&kio_lock, true);
    313313
    314314        /* Output stored characters */
  • kernel/generic/src/log/log.c

    raf77459 r571cc2d  
    6060
    6161/** Cyclic buffer holding the data for kernel log */
    62 uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
     62static uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
    6363
    6464/** Kernel log initialized */
     
    6666
    6767/** Position in the cyclic buffer where the first log entry starts */
    68 size_t log_start = 0;
     68static size_t log_start = 0;
    6969
    7070/** Sum of length of all log entries currently stored in the cyclic buffer */
    71 size_t log_used = 0;
     71static size_t log_used = 0;
    7272
    7373/** Log spinlock */
    74 SPINLOCK_STATIC_INITIALIZE_NAME(log_lock, "log_lock");
     74static IRQ_SPINLOCK_INITIALIZE(log_lock);
    7575
    7676/** Overall count of logged messages, which may overflow as needed */
     
    152152{
    153153        console_lock();
    154         spinlock_lock(&log_lock);
    155         spinlock_lock(&kio_lock);
     154        irq_spinlock_lock(&log_lock, true);
     155        irq_spinlock_lock(&kio_lock, true);
    156156
    157157        log_current_start = (log_start + log_used) % LOG_LENGTH;
     
    180180
    181181        kio_push_char('\n');
    182         spinlock_unlock(&kio_lock);
    183         spinlock_unlock(&log_lock);
     182        irq_spinlock_unlock(&kio_lock, true);
     183        irq_spinlock_unlock(&log_lock, true);
    184184
    185185        /* This has to be called after we released the locks above */
     
    195195                return;
    196196
    197         spinlock_lock(&log_lock);
     197        irq_spinlock_lock(&log_lock, true);
    198198        if (next_for_uspace < log_used)
    199199                event_notify_0(EVENT_KLOG, true);
    200         spinlock_unlock(&log_lock);
     200        irq_spinlock_unlock(&log_lock, true);
    201201}
    202202
     
    307307                rc = EOK;
    308308
    309                 spinlock_lock(&log_lock);
     309                irq_spinlock_lock(&log_lock, true);
    310310
    311311                while (next_for_uspace < log_used) {
     
    337337                }
    338338
    339                 spinlock_unlock(&log_lock);
     339                irq_spinlock_unlock(&log_lock, true);
    340340
    341341                if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.