diff options
author | Richard Braun <rbraun@sceen.net> | 2017-06-10 17:24:04 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-06-10 17:38:47 +0200 |
commit | b719ffa6583447ff933fbcf21274b376133cb992 (patch) | |
tree | 4bd7aaf9767dea632a1338041f0c6fdd0624f867 | |
parent | 562904ff8e2f5e40e4be76dc7c4d919a4bda05f8 (diff) |
Use log functions where appropriate
-rw-r--r-- | arch/x86/machine/acpi.c | 24 | ||||
-rw-r--r-- | arch/x86/machine/atkbd.c | 10 | ||||
-rw-r--r-- | arch/x86/machine/biosmem.c | 49 | ||||
-rw-r--r-- | arch/x86/machine/boot.c | 7 | ||||
-rw-r--r-- | arch/x86/machine/cpu.c | 22 | ||||
-rw-r--r-- | arch/x86/machine/ioapic.c | 8 | ||||
-rw-r--r-- | arch/x86/machine/lapic.c | 10 | ||||
-rw-r--r-- | arch/x86/machine/pmap.c | 4 | ||||
-rw-r--r-- | arch/x86/machine/strace.c | 15 | ||||
-rw-r--r-- | arch/x86/machine/uart.c | 10 | ||||
-rw-r--r-- | kern/arg.c | 4 | ||||
-rw-r--r-- | kern/console.c | 6 | ||||
-rw-r--r-- | kern/intr.c | 6 | ||||
-rw-r--r-- | kern/llsync.c | 4 | ||||
-rw-r--r-- | kern/percpu.c | 14 | ||||
-rw-r--r-- | kern/shell.c | 5 | ||||
-rw-r--r-- | kern/sref.c | 4 | ||||
-rw-r--r-- | kern/work.c | 10 | ||||
-rw-r--r-- | vm/vm_page.c | 30 |
19 files changed, 112 insertions, 130 deletions
diff --git a/arch/x86/machine/acpi.c b/arch/x86/machine/acpi.c index 6d5e06e..4da4d90 100644 --- a/arch/x86/machine/acpi.c +++ b/arch/x86/machine/acpi.c @@ -19,11 +19,11 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> #include <kern/init.h> #include <kern/kmem.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <machine/acpi.h> @@ -193,8 +193,7 @@ acpi_register_table(struct acpi_sdth *table) for (i = 0; i < ARRAY_SIZE(acpi_table_addrs); i++) if (strcmp(sig, acpi_table_addrs[i].sig) == 0) { if (acpi_table_addrs[i].table != NULL) { - printf("acpi: warning: table %s ignored:" - " already registered\n", sig); + log_warning("acpi: table %s ignored: already registered", sig); return; } @@ -202,7 +201,7 @@ acpi_register_table(struct acpi_sdth *table) return; } - printf("acpi: warning: table '%s' ignored: unknown table\n", sig); + log_warning("acpi: table '%s' ignored: unknown table", sig); } static struct acpi_sdth * __init @@ -225,8 +224,7 @@ acpi_check_tables(void) for (i = 0; i < ARRAY_SIZE(acpi_table_addrs); i++) if (acpi_table_addrs[i].table == NULL) { - printf("acpi: error: table %s missing\n", - acpi_table_addrs[i].sig); + log_err("acpi: table %s missing", acpi_table_addrs[i].sig); return -1; } @@ -359,7 +357,7 @@ acpi_find_rsdp(struct acpi_rsdp *rsdp) return 0; } - printf("acpi: unable to find root system description pointer\n"); + log_debug("acpi: unable to find root system description pointer"); return -1; } @@ -370,8 +368,8 @@ acpi_info(void) rsdt = acpi_lookup_table("RSDT"); assert(rsdt != NULL); - printf("acpi: revision: %u, oem: %.*s\n", rsdt->revision, - (int)sizeof(rsdt->oem_id), rsdt->oem_id); + log_debug("acpi: revision: %u, oem: %.*s", rsdt->revision, + (int)sizeof(rsdt->oem_id), rsdt->oem_id); } static struct acpi_sdth * __init @@ -409,7 +407,7 @@ acpi_copy_table(uint32_t addr) char sig[ACPI_SIG_SIZE]; acpi_table_sig(table, sig); - printf("acpi: table %s: invalid checksum\n", sig); + log_err("acpi: table %s: invalid checksum", sig); copy = NULL; goto out; } @@ -512,7 +510,7 @@ acpi_load_iso(const struct acpi_madt_entry_iso *iso) bool active_high, edge_triggered; if (iso->bus != 0) { - printf("acpi: error: invalid interrupt source override bus\n"); + log_err("acpi: invalid interrupt source override bus"); return; } @@ -525,7 +523,7 @@ acpi_load_iso(const struct acpi_madt_entry_iso *iso) active_high = false; break; default: - printf("acpi: error: invalid polarity\n"); + log_err("acpi: invalid polarity"); return; } @@ -538,7 +536,7 @@ acpi_load_iso(const struct acpi_madt_entry_iso *iso) edge_triggered = false; break; default: - printf("acpi: error: invalid trigger mode\n"); + log_err("acpi: invalid trigger mode"); return; } diff --git a/arch/x86/machine/atkbd.c b/arch/x86/machine/atkbd.c index 1ed4c86..da792bd 100644 --- a/arch/x86/machine/atkbd.c +++ b/arch/x86/machine/atkbd.c @@ -24,11 +24,11 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <kern/error.h> #include <kern/init.h> #include <kern/intr.h> +#include <kern/log.h> #include <kern/macros.h> #include <machine/atkbd.h> #include <machine/atcons.h> @@ -489,13 +489,13 @@ atkbd_read_status(bool check_out) * of hardware. */ if (status == 0xff) { - printf("atkbd: no keyboard controller\n"); + log_info("atkbd: no keyboard controller"); return ERROR_NODEV; } else if (status & ATKBD_STATUS_PARITY_ERROR) { - printf("atkbd: parity error\n"); + log_err("atkbd: parity error"); return ERROR_IO; } else if (status & ATKBD_STATUS_TIMEOUT_ERROR) { - printf("atkbd: timeout error\n"); + log_err("atkbd: timeout error"); return ERROR_TIMEDOUT; } @@ -849,7 +849,7 @@ atkbd_setup(void) error = intr_register(ATKBD_INTR1, atkbd_intr, NULL); if (error) { - printf("atkbd: error: unable to register interrupt handler\n"); + log_err("atkbd: unable to register interrupt handler"); return; } diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c index bfa22af..ec090d0 100644 --- a/arch/x86/machine/biosmem.c +++ b/arch/x86/machine/biosmem.c @@ -19,10 +19,10 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> #include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> @@ -34,8 +34,6 @@ #include <vm/vm_kmem.h> #include <vm/vm_page.h> -#define DEBUG 0 - #define BIOSMEM_MAX_BOOT_DATA 64 /* @@ -228,11 +226,9 @@ biosmem_unregister_boot_data(phys_addr_t start, phys_addr_t end) return; } -#if DEBUG - printf("biosmem: unregister boot data: %llx:%llx\n", - (unsigned long long)biosmem_boot_data_array[i].start, - (unsigned long long)biosmem_boot_data_array[i].end); -#endif /* DEBUG */ + log_debug("biosmem: unregister boot data: %llx:%llx", + (unsigned long long)biosmem_boot_data_array[i].start, + (unsigned long long)biosmem_boot_data_array[i].end); biosmem_nr_boot_data--; @@ -763,8 +759,6 @@ biosmem_directmap_end(void) } } -#if DEBUG - static const char * __init biosmem_type_desc(unsigned int type) { @@ -789,24 +783,20 @@ biosmem_map_show(void) { const struct biosmem_map_entry *entry, *end; - printf("biosmem: physical memory map:\n"); + log_debug("biosmem: physical memory map:"); for (entry = biosmem_map, end = entry + biosmem_map_size; entry < end; entry++) - printf("biosmem: %018llx:%018llx, %s\n", entry->base_addr, - entry->base_addr + entry->length, - biosmem_type_desc(entry->type)); + log_debug("biosmem: %018llx:%018llx, %s", entry->base_addr, + entry->base_addr + entry->length, + biosmem_type_desc(entry->type)); - printf("biosmem: heap: %llx:%llx\n", - (unsigned long long)biosmem_heap_start, - (unsigned long long)biosmem_heap_end); + log_debug("biosmem: heap: %llx:%llx", + (unsigned long long)biosmem_heap_start, + (unsigned long long)biosmem_heap_end); } -#else /* DEBUG */ -#define biosmem_map_show() -#endif /* DEBUG */ - static void __init biosmem_load_zone(struct biosmem_zone *zone, uint64_t max_phys_end) { @@ -819,13 +809,14 @@ biosmem_load_zone(struct biosmem_zone *zone, uint64_t max_phys_end) if (phys_end > max_phys_end) { if (max_phys_end <= phys_start) { - printf("biosmem: warning: zone %s physically unreachable, " - "not loaded\n", vm_page_zone_name(zone_index)); + log_warning("biosmem: zone %s physically unreachable, " + "not loaded", vm_page_zone_name(zone_index)); return; } - printf("biosmem: warning: zone %s truncated to %#llx\n", - vm_page_zone_name(zone_index), (unsigned long long)max_phys_end); + log_warning("biosmem: warning: zone %s truncated to %#llx", + vm_page_zone_name(zone_index), + (unsigned long long)max_phys_end); phys_end = max_phys_end; } @@ -901,11 +892,9 @@ biosmem_free_usable_range(phys_addr_t start, phys_addr_t end) { struct vm_page *page; -#if DEBUG - printf("biosmem: release to vm_page: %llx:%llx (%lluk)\n", - (unsigned long long)start, (unsigned long long)end, - (unsigned long long)((end - start) >> 10)); -#endif + log_debug("biosmem: release to vm_page: %llx:%llx (%lluk)", + (unsigned long long)start, (unsigned long long)end, + (unsigned long long)((end - start) >> 10)); while (start < end) { page = vm_page_lookup(start); diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c index 8812082..355b7df 100644 --- a/arch/x86/machine/boot.c +++ b/arch/x86/machine/boot.c @@ -45,7 +45,6 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> #include <kern/arg.h> @@ -350,11 +349,11 @@ boot_setup_paging(struct multiboot_raw_info *mbi, unsigned long eax) static void __init boot_show_version(void) { - printf(KERNEL_NAME "/" QUOTE(X15_X86_MACHINE) " " KERNEL_VERSION + log_info(KERNEL_NAME "/" QUOTE(X15_X86_MACHINE) " " KERNEL_VERSION #ifdef X15_X86_PAE - " PAE" + " PAE" #endif /* X15_X86_PAE */ - "\n"); + ); } static void * __init diff --git a/arch/x86/machine/cpu.c b/arch/x86/machine/cpu.c index 846b21e..4981ff6 100644 --- a/arch/x86/machine/cpu.c +++ b/arch/x86/machine/cpu.c @@ -18,10 +18,10 @@ #include <assert.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> #include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> @@ -591,22 +591,22 @@ cpu_check(const struct cpu *cpu) void cpu_info(const struct cpu *cpu) { - printf("cpu%u: %s, type %u, family %u, model %u, stepping %u\n", - cpu->id, cpu->vendor_id, cpu->type, cpu->family, cpu->model, - cpu->stepping); + log_info("cpu%u: %s, type %u, family %u, model %u, stepping %u", + cpu->id, cpu->vendor_id, cpu->type, cpu->family, cpu->model, + cpu->stepping); if (strlen(cpu->model_name) > 0) { - printf("cpu%u: %s\n", cpu->id, cpu->model_name); + log_info("cpu%u: %s", cpu->id, cpu->model_name); } if ((cpu->phys_addr_width != 0) && (cpu->virt_addr_width != 0)) { - printf("cpu%u: address widths: physical: %hu, virtual: %hu\n", - cpu->id, cpu->phys_addr_width, cpu->virt_addr_width); + log_info("cpu%u: address widths: physical: %hu, virtual: %hu", + cpu->id, cpu->phys_addr_width, cpu->virt_addr_width); } - printf("cpu%u: frequency: %llu.%02llu MHz\n", cpu->id, - (unsigned long long)cpu_freq / 1000000, - (unsigned long long)cpu_freq % 1000000); + log_info("cpu%u: frequency: %llu.%02llu MHz", cpu->id, + (unsigned long long)cpu_freq / 1000000, + (unsigned long long)cpu_freq % 1000000); } void __init @@ -654,7 +654,7 @@ cpu_mp_probe(void) pic_setup(); } - printf("cpu: %u processor(s) configured\n", cpu_count()); + log_info("cpu: %u processor(s) configured", cpu_count()); } void __init diff --git a/arch/x86/machine/ioapic.c b/arch/x86/machine/ioapic.c index 245c74c..cd3d2d3 100644 --- a/arch/x86/machine/ioapic.c +++ b/arch/x86/machine/ioapic.c @@ -18,12 +18,12 @@ #include <assert.h> #include <stdbool.h> #include <stdint.h> -#include <stdio.h> #include <kern/error.h> #include <kern/init.h> #include <kern/intr.h> #include <kern/kmem.h> +#include <kern/log.h> #include <kern/panic.h> #include <kern/spinlock.h> #include <machine/cpu.h> @@ -101,7 +101,7 @@ ioapic_alloc_iso(void) struct ioapic_iso *iso; if (ioapic_nr_isos >= ARRAY_SIZE(ioapic_isos)) { - printf("ioapic: error: too many interrupt overrides\n"); + log_err("ioapic: too many interrupt overrides"); return NULL; } @@ -201,8 +201,8 @@ ioapic_create(unsigned int apic_id, uintptr_t addr, unsigned int gsi_base) trap_register(TRAP_INTR_FIRST + i, ioapic_intr); } - printf("ioapic%u: version:%#x gsis:%u-%u\n", ioapic->id, - ioapic->version, ioapic->first_gsi, ioapic->last_gsi); + log_info("ioapic%u: version:%#x gsis:%u-%u", ioapic->id, + ioapic->version, ioapic->first_gsi, ioapic->last_gsi); ioapic_nr_devs++; return ioapic; diff --git a/arch/x86/machine/lapic.c b/arch/x86/machine/lapic.c index dad3bd7..c20eec7 100644 --- a/arch/x86/machine/lapic.c +++ b/arch/x86/machine/lapic.c @@ -19,9 +19,9 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> @@ -210,8 +210,8 @@ lapic_compute_freq(void) cpu_delay(LAPIC_TIMER_CAL_DELAY); c2 = lapic_read(&lapic_map->timer_ccr); lapic_bus_freq = (c1 - c2) * (1000000 / LAPIC_TIMER_CAL_DELAY); - printf("lapic: bus frequency: %u.%02u MHz\n", lapic_bus_freq / 1000000, - lapic_bus_freq % 1000000); + log_info("lapic: bus frequency: %u.%02u MHz", lapic_bus_freq / 1000000, + lapic_bus_freq % 1000000); lapic_write(&lapic_map->timer_icr, lapic_bus_freq / HZ); lapic_write(&lapic_map->svr, 0); } @@ -344,7 +344,7 @@ lapic_error_intr(struct trap_frame *frame) (void)frame; esr = lapic_read(&lapic_map->esr); - printf("lapic: error on cpu%u: esr:%08x\n", cpu_id(), esr); + log_err("lapic: error on cpu%u: esr:%08x", cpu_id(), esr); lapic_write(&lapic_map->esr, 0); lapic_eoi(); } @@ -353,7 +353,7 @@ void lapic_spurious_intr(struct trap_frame *frame) { (void)frame; - printf("lapic: warning: spurious interrupt\n"); + log_warning("lapic: spurious interrupt"); /* No EOI for this interrupt */ } diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c index 1aab9cc..0520c13 100644 --- a/arch/x86/machine/pmap.c +++ b/arch/x86/machine/pmap.c @@ -20,7 +20,6 @@ #include <assert.h> #include <stddef.h> -#include <stdio.h> #include <string.h> #include <kern/cpumap.h> @@ -28,6 +27,7 @@ #include <kern/init.h> #include <kern/kmem.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/mutex.h> #include <kern/panic.h> @@ -1162,7 +1162,7 @@ pmap_enter_local(struct pmap *pmap, uintptr_t va, phys_addr_t pa, page = vm_page_alloc(0, VM_PAGE_SEL_DIRECTMAP, VM_PAGE_PMAP); if (page == NULL) { - printf("pmap: warning: page table page allocation failure\n"); + log_warning("pmap: page table page allocation failure"); return ERROR_NOMEM; } diff --git a/arch/x86/machine/strace.c b/arch/x86/machine/strace.c index 8aea4b0..7ff47ef 100644 --- a/arch/x86/machine/strace.c +++ b/arch/x86/machine/strace.c @@ -21,6 +21,7 @@ #include <kern/init.h> #include <kern/kmem.h> +#include <kern/log.h> #include <kern/param.h> #include <machine/elf.h> #include <machine/multiboot.h> @@ -133,14 +134,14 @@ strace_copy_section(const struct elf_shdr *shdr) src = vm_kmem_map_pa(shdr->addr, shdr->size, &map_addr, &map_size); if (src == NULL) { - printf("strace: unable to map section\n"); + log_err("strace: unable to map section"); goto error_map; } copy = kmem_alloc(shdr->size); if (copy == NULL) { - printf("strace: unable to allocate section copy\n"); + log_err("strace: unable to allocate section copy"); goto error_copy; } @@ -191,12 +192,12 @@ strace_setup(const struct multiboot_raw_info *mbi) table = vm_kmem_map_pa(mbi->shdr_addr, size, &map_addr, &map_size); if (table == NULL) { - printf("strace: unable to map section headers table\n"); + log_err("strace: unable to map section headers table"); goto no_syms; } if (mbi->shdr_strndx >= mbi->shdr_num) { - printf("strace: invalid section names index\n"); + log_err("strace: invalid section names index"); goto error_shstrndx; } @@ -205,21 +206,21 @@ strace_setup(const struct multiboot_raw_info *mbi) &shstrtab_map_addr, &shstrtab_map_size); if (shstrtab == NULL) { - printf("strace: unable to map section names\n"); + log_err("strace: unable to map section names"); goto error_shstrtab; } symtab_hdr = strace_lookup_section(mbi, table, shstrtab, ".symtab"); if (symtab_hdr == NULL) { - printf("strace: unable to find symbol table\n"); + log_err("strace: unable to find symbol table"); goto error_symtab_lookup; } strtab_hdr = strace_lookup_section(mbi, table, shstrtab, ".strtab"); if (strtab_hdr == NULL) { - printf("strace: unable to find symbol string table\n"); + log_err("strace: unable to find symbol string table"); goto error_strtab_lookup; } diff --git a/arch/x86/machine/uart.c b/arch/x86/machine/uart.c index a4a01cb..22d3948 100644 --- a/arch/x86/machine/uart.c +++ b/arch/x86/machine/uart.c @@ -20,12 +20,12 @@ #include <assert.h> #include <stdint.h> -#include <stdio.h> #include <kern/console.h> #include <kern/error.h> #include <kern/init.h> #include <kern/intr.h> +#include <kern/log.h> #include <kern/macros.h> #include <machine/biosmem.h> #include <machine/io.h> @@ -180,8 +180,8 @@ uart_enable_intr(struct uart *uart) error = intr_register(uart->intr, uart_intr, uart); if (error) { - printf("uart%zu: error: unable to register interrupt %u\n", - uart_get_id(uart), uart->intr); + log_err("uart%zu: unable to register interrupt %u", + uart_get_id(uart), uart->intr); return; } @@ -312,8 +312,8 @@ uart_info(void) uart = uart_get_dev(i); if (uart->port != 0) { - printf("uart%zu: port:%#x irq:%u\n", i, (unsigned int)uart->port, - (unsigned int)uart->intr); + log_info("uart%zu: port:%#x irq:%u", i, (unsigned int)uart->port, + (unsigned int)uart->intr); } } } @@ -18,11 +18,11 @@ #include <assert.h> #include <stdbool.h> #include <stddef.h> -#include <stdio.h> #include <string.h> #include <kern/arg.h> #include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> @@ -72,7 +72,7 @@ arg_info(void) } cmdline[i] = '\0'; - printf("arg: %s\n", cmdline); + log_info("arg: %s", cmdline); } static const char * __init diff --git a/kern/console.c b/kern/console.c index fef4f65..bee400e 100644 --- a/kern/console.c +++ b/kern/console.c @@ -18,7 +18,6 @@ #include <assert.h> #include <stdbool.h> #include <stddef.h> -#include <stdio.h> #include <string.h> #include <kern/arg.h> @@ -26,6 +25,7 @@ #include <kern/init.h> #include <kern/console.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/mutex.h> #include <kern/spinlock.h> #include <kern/thread.h> @@ -128,10 +128,10 @@ console_register(struct console *console) console_dev = console; } - printf("console: %s registered\n", console->name); + log_info("console: %s registered", console->name); if (console == console_dev) { - printf("console: %s selected as active console\n", console->name); + log_info("console: %s selected as active console", console->name); } } diff --git a/kern/intr.c b/kern/intr.c index fe69e3e..ca733e2 100644 --- a/kern/intr.c +++ b/kern/intr.c @@ -24,13 +24,13 @@ #include <stdbool.h> #include <stddef.h> -#include <stdio.h> #include <kern/atomic.h> #include <kern/kmem.h> #include <kern/init.h> #include <kern/intr.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> @@ -388,7 +388,7 @@ intr_unregister(unsigned int intr, intr_handler_fn_t fn) handler = intr_entry_remove(intr_get_entry(intr), fn); if (handler == NULL) { - printf("intr: warning: attempting to unregister unknown handler\n"); + log_warning("intr: attempting to unregister unknown handler"); return; } @@ -410,7 +410,7 @@ intr_handle(unsigned int intr) spinlock_lock(&entry->lock); if (intr_entry_empty(entry)) { - printf("intr: spurious interrupt %u\n", intr); + log_warning("intr: spurious interrupt %u", intr); goto out; } diff --git a/kern/llsync.c b/kern/llsync.c index 1c5086f..4704e80 100644 --- a/kern/llsync.c +++ b/kern/llsync.c @@ -35,12 +35,12 @@ #include <assert.h> #include <stdbool.h> #include <stddef.h> -#include <stdio.h> #include <kern/condition.h> #include <kern/cpumap.h> #include <kern/init.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/llsync.h> #include <kern/llsync_i.h> #include <kern/macros.h> @@ -122,7 +122,7 @@ llsync_process_global_checkpoint(void) /* TODO Handle hysteresis */ if (!llsync_data.no_warning && (nr_works >= LLSYNC_NR_PENDING_WORKS_WARN)) { llsync_data.no_warning = 1; - printf("llsync: warning: large number of pending works\n"); + log_warning("llsync: large number of pending works\n"); } if (llsync_data.nr_registered_cpus == 0) { diff --git a/kern/percpu.c b/kern/percpu.c index a1f7df1..805825a 100644 --- a/kern/percpu.c +++ b/kern/percpu.c @@ -18,11 +18,11 @@ #include <assert.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> #include <kern/error.h> #include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> @@ -50,8 +50,8 @@ percpu_setup(void) unsigned int order; percpu_area_size = &_percpu_end - &_percpu; - printf("percpu: max_cpus: %u, section size: %zuk\n", X15_MAX_CPUS, - percpu_area_size >> 10); + log_info("percpu: max_cpus: %u, section size: %zuk", X15_MAX_CPUS, + percpu_area_size >> 10); assert(vm_page_aligned(percpu_area_size)); if (percpu_area_size == 0) { @@ -77,8 +77,8 @@ percpu_add(unsigned int cpu) if (cpu >= ARRAY_SIZE(percpu_areas)) { if (!percpu_skip_warning) { - printf("percpu: ignoring processor beyond id %zu\n", - ARRAY_SIZE(percpu_areas) - 1); + log_warning("percpu: ignoring processor beyond id %zu", + ARRAY_SIZE(percpu_areas) - 1); percpu_skip_warning = 1; } @@ -86,7 +86,7 @@ percpu_add(unsigned int cpu) } if (percpu_areas[cpu] != NULL) { - printf("percpu: error: id %u ignored, already registered\n", cpu); + log_err("percpu: id %u ignored, already registered", cpu); return ERROR_INVAL; } @@ -98,7 +98,7 @@ percpu_add(unsigned int cpu) page = vm_page_alloc(order, VM_PAGE_SEL_DIRECTMAP, VM_PAGE_KERNEL); if (page == NULL) { - printf("percpu: error: unable to allocate percpu area\n"); + log_err("percpu: unable to allocate percpu area"); return ERROR_NOMEM; } diff --git a/kern/shell.c b/kern/shell.c index 38f2991..c526b31 100644 --- a/kern/shell.c +++ b/kern/shell.c @@ -20,8 +20,9 @@ #include <kern/console.h> #include <kern/error.h> -#include <kern/init.h> #include <kern/hash.h> +#include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/mutex.h> #include <kern/shell.h> @@ -445,7 +446,7 @@ shell_cmd_add(struct shell_cmd *cmd) for (;;) { if (strcmp(cmd->name, tmp->name) == 0) { - printf("shell: %s: shell command name collision", cmd->name); + log_err("shell: %s: shell command name collision", cmd->name); return ERROR_EXIST; } diff --git a/kern/sref.c b/kern/sref.c index 9c2d776..5aad8da 100644 --- a/kern/sref.c +++ b/kern/sref.c @@ -44,12 +44,12 @@ #include <assert.h> #include <stdbool.h> #include <stddef.h> -#include <stdio.h> #include <kern/condition.h> #include <kern/cpumap.h> #include <kern/error.h> #include <kern/init.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/mutex.h> #include <kern/panic.h> @@ -503,7 +503,7 @@ sref_end_epoch(struct sref_queue *queue) if (!sref_data.no_warning && (sref_review_queue_size() >= SREF_NR_COUNTERS_WARN)) { sref_data.no_warning = 1; - printf("sref: warning: large number of counters in review queue\n"); + log_warning("sref: large number of counters in review queue"); } if (sref_data.nr_registered_cpus == 1) { diff --git a/kern/work.c b/kern/work.c index 5c33eb7..284b1e2 100644 --- a/kern/work.c +++ b/kern/work.c @@ -17,13 +17,13 @@ #include <assert.h> #include <stddef.h> -#include <stdio.h> #include <kern/bitmap.h> #include <kern/error.h> #include <kern/init.h> #include <kern/kmem.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> @@ -374,7 +374,7 @@ work_process(void *arg) if (error) { work_pool_free_id(pool, id); - printf("work: warning: unable to create worker thread\n"); + log_warning("work: unable to create worker thread"); } } } @@ -490,9 +490,9 @@ work_setup(void) work_pool_init(&work_pool_highprio, WORK_INVALID_CPU, WORK_PF_GLOBAL | WORK_PF_HIGHPRIO); - printf("work: threads per pool (per-cpu/global): %u/%u, spare: %u\n", - percpu_var(work_pool_cpu_main.max_threads, 0), - work_pool_main.max_threads, WORK_THREADS_SPARE); + log_info("work: threads per pool (per-cpu/global): %u/%u, spare: %u", + percpu_var(work_pool_cpu_main.max_threads, 0), + work_pool_main.max_threads, WORK_THREADS_SPARE); } void diff --git a/vm/vm_page.c b/vm/vm_page.c index edf213e..a6c8c6b 100644 --- a/vm/vm_page.c +++ b/vm/vm_page.c @@ -33,11 +33,11 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include <string.h> #include <kern/init.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/mutex.h> #include <kern/panic.h> @@ -48,8 +48,6 @@ #include <machine/types.h> #include <vm/vm_page.h> -#define DEBUG 0 - /* * Number of free block lists per zone. */ @@ -510,11 +508,9 @@ vm_page_load(unsigned int zone_index, phys_addr_t start, phys_addr_t end) zone->end = end; zone->heap_present = false; -#if DEBUG - printf("vm_page: load: %s: %llx:%llx\n", - vm_page_zone_name(zone_index), - (unsigned long long)start, (unsigned long long)end); -#endif + log_debug("vm_page: load: %s: %llx:%llx\n", + vm_page_zone_name(zone_index), + (unsigned long long)start, (unsigned long long)end); vm_page_zones_size++; } @@ -537,11 +533,9 @@ vm_page_load_heap(unsigned int zone_index, phys_addr_t start, phys_addr_t end) zone->avail_end = end; zone->heap_present = true; -#if DEBUG - printf("vm_page: heap: %s: %llx:%llx\n", - vm_page_zone_name(zone_index), - (unsigned long long)start, (unsigned long long)end); -#endif + log_debug("vm_page: heap: %s: %llx:%llx", + vm_page_zone_name(zone_index), + (unsigned long long)start, (unsigned long long)end); } int @@ -663,8 +657,8 @@ vm_page_setup(void) } table_size = vm_page_round(nr_pages * sizeof(struct vm_page)); - printf("vm_page: page table size: %zu entries (%zuk)\n", nr_pages, - table_size >> 10); + log_info("vm_page: page table size: %zu entries (%zuk)", nr_pages, + table_size >> 10); table = vm_page_bootalloc(table_size); va = (uintptr_t)table; @@ -781,8 +775,8 @@ vm_page_info(void) for (i = 0; i < vm_page_zones_size; i++) { zone = &vm_page_zones[i]; pages = (unsigned long)(zone->pages_end - zone->pages); - printf("vm_page: %s: pages: %lu (%luM), free: %lu (%luM)\n", - vm_page_zone_name(i), pages, pages >> (20 - PAGE_SHIFT), - zone->nr_free_pages, zone->nr_free_pages >> (20 - PAGE_SHIFT)); + log_info("vm_page: %s: pages: %lu (%luM), free: %lu (%luM)", + vm_page_zone_name(i), pages, pages >> (20 - PAGE_SHIFT), + zone->nr_free_pages, zone->nr_free_pages >> (20 - PAGE_SHIFT)); } } |