|
1 | 1 | #include <kernel.h> |
2 | 2 | #include <string.h> |
3 | 3 |
|
| 4 | +extern spinlock_t console_spinlock; |
| 5 | +extern spinlock_t debug_console_spinlock; |
| 6 | + |
4 | 7 | static int do_printf(const char *fmt, size_t max, va_list args, fnptr_t fn, void *ptr) |
5 | 8 | { |
6 | 9 | unsigned flags = 0, actual_wd = 0, count = 0, given_wd = 0; |
@@ -276,17 +279,23 @@ int dvprintf_help(unsigned c, [[maybe_unused]] void **ptr, [[maybe_unused]] cons |
276 | 279 |
|
277 | 280 | int vprintf(const char *fmt, va_list args) |
278 | 281 | { |
279 | | - return do_printf(fmt, SIZE_MAX, args, vprintf_help, NULL); |
| 282 | + lock_spinlock(&console_spinlock); |
| 283 | + int r = do_printf(fmt, SIZE_MAX, args, vprintf_help, NULL); |
| 284 | + unlock_spinlock(&console_spinlock); |
| 285 | + return r; |
280 | 286 | } |
281 | 287 |
|
282 | 288 | int dvprintf(const char *fmt, va_list args) |
283 | 289 | { |
284 | 290 | char counter[25]; |
| 291 | + lock_spinlock(&debug_console_spinlock); |
285 | 292 | do_itoa(get_ticks(), counter, 10); |
286 | 293 | dput('['); |
287 | 294 | dputstring(counter); |
288 | 295 | dputstring("]: "); |
289 | | - return do_printf(fmt, SIZE_MAX, args, dvprintf_help, NULL); |
| 296 | + int r = do_printf(fmt, SIZE_MAX, args, dvprintf_help, NULL); |
| 297 | + unlock_spinlock(&debug_console_spinlock); |
| 298 | + return r; |
290 | 299 | } |
291 | 300 |
|
292 | 301 | int printf(const char *fmt, ...) |
|
0 commit comments