Changeset c4cfe4c in mainline for kernel/generic/src/log/log.c
- Timestamp:
- 2025-04-17T16:01:16Z (5 days ago)
- Branches:
- master
- Children:
- 888c06e
- Parents:
- 1db4e2ae (diff), 250a435 (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:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:51:11)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 16:01:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/log/log.c
r1db4e2ae rc4cfe4c 46 46 #include <print.h> 47 47 #include <printf_core.h> 48 #include <putchar.h>49 48 #include <stdarg.h> 50 49 #include <stdlib.h> … … 60 59 61 60 /** Cyclic buffer holding the data for kernel log */ 62 uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));61 static uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE))); 63 62 64 63 /** Kernel log initialized */ … … 66 65 67 66 /** Position in the cyclic buffer where the first log entry starts */ 68 s ize_t log_start = 0;67 static size_t log_start = 0; 69 68 70 69 /** Sum of length of all log entries currently stored in the cyclic buffer */ 71 s ize_t log_used = 0;70 static size_t log_used = 0; 72 71 73 72 /** Log spinlock */ 74 SPINLOCK_STATIC_INITIALIZE_NAME(log_lock, "log_lock");73 static IRQ_SPINLOCK_INITIALIZE(log_lock); 75 74 76 75 /** Overall count of logged messages, which may overflow as needed */ … … 152 151 { 153 152 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); 156 155 157 156 log_current_start = (log_start + log_used) % LOG_LENGTH; … … 179 178 log_used += log_current_len; 180 179 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); 184 183 185 184 /* This has to be called after we released the locks above */ … … 195 194 return; 196 195 197 spinlock_lock(&log_lock);196 irq_spinlock_lock(&log_lock, true); 198 197 if (next_for_uspace < log_used) 199 198 event_notify_0(EVENT_KLOG, true); 200 spinlock_unlock(&log_lock);199 irq_spinlock_unlock(&log_lock, true); 201 200 } 202 201 203 202 static int log_printf_str_write(const char *str, size_t size, void *data) 204 203 { 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); 210 205 log_append((const uint8_t *)str, size); 211 212 206 return EOK; 213 207 } … … 307 301 rc = EOK; 308 302 309 spinlock_lock(&log_lock);303 irq_spinlock_lock(&log_lock, true); 310 304 311 305 while (next_for_uspace < log_used) { … … 337 331 } 338 332 339 spinlock_unlock(&log_lock);333 irq_spinlock_unlock(&log_lock, true); 340 334 341 335 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.