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 /arch | |
parent | 562904ff8e2f5e40e4be76dc7c4d919a4bda05f8 (diff) |
Use log functions where appropriate
Diffstat (limited to 'arch')
-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 |
10 files changed, 73 insertions, 86 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); } } } |