Changeset fd07e57b in mainline


Ignore:
Timestamp:
2014-01-05T21:25:41Z (10 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4aa2a27
Parents:
aacdb8e (diff), ca05e9b (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.
Message:

Merge cherrypicked kernel logger.

  • Old klog sybsystem was renamed to kio
  • Kernel and user-space log messages are stored in both logs (kernel logs end up in log/kernel file)
Files:
8 added
62 edited
3 moved

Legend:

Unmodified
Added
Removed
  • .bzrignore

    raacdb8e rfd07e57b  
    3333uspace/app/kill/kill
    3434uspace/app/killall/killall
    35 uspace/app/klog/klog
     35uspace/app/kio/kio
    3636uspace/app/loc/loc
    3737uspace/app/logset/logset
     
    8282uspace/dist/app/kill
    8383uspace/dist/app/killall
    84 uspace/dist/app/klog
     84uspace/dist/app/kio
    8585uspace/dist/app/loc
    8686uspace/dist/app/logset
     
    285285uspace/lib/posix/redefs-hide-libc-symbols.list
    286286uspace/lib/posix/redefs-show-posix-symbols.list
     287uspace/srv/klog/klog
     288uspace/dist/srv/klog
  • abi/include/abi/ipc/event.h

    raacdb8e rfd07e57b  
    3838/** Global events */
    3939typedef enum event_type {
    40         /** New data available in kernel log */
    41         EVENT_KLOG = 0,
     40        /** New data available in kernel character buffer */
     41        EVENT_KIO = 0,
    4242        /** Returning from kernel console to uspace */
    4343        EVENT_KCONSOLE,
    4444        /** A task/thread has faulted and will be terminated */
    4545        EVENT_FAULT,
     46        /** New data available in kernel log */
     47        EVENT_KLOG,
    4648        EVENT_END
    4749} event_type_t;
  • abi/include/abi/klog.h

    raacdb8e rfd07e57b  
    11/*
    2  * Copyright (c) 2012 Jakub Jermar
     2 * Copyright (c) 2014 Martin Sucha
    33 * All rights reserved.
    44 *
     
    3636#define ABI_KLOG_H_
    3737
    38 enum {
    39         KLOG_UNKNOW,
     38typedef enum {
    4039        KLOG_WRITE,
    41         KLOG_UPDATE,
    42         KLOG_COMMAND
    43 };
     40        KLOG_READ
     41} klog_operation_t;
    4442
    4543#endif
  • abi/include/abi/syscall.h

    raacdb8e rfd07e57b  
    3737
    3838typedef enum {
    39         SYS_KLOG = 0,
     39        SYS_KIO = 0,
    4040        SYS_TLS_SET = 1,  /* Hardcoded for AMD64, IA-32 (fibril.S in uspace) */
    4141       
     
    9999        SYS_DEBUG_ACTIVATE_CONSOLE,
    100100       
     101        SYS_KLOG,
     102       
    101103        SYSCALL_END
    102104} syscall_t;
  • boot/Makefile.common

    raacdb8e rfd07e57b  
    9696        $(USPACE_PATH)/srv/devman/devman \
    9797        $(USPACE_PATH)/srv/fs/locfs/locfs \
    98         $(USPACE_PATH)/srv/hid/compositor/compositor
     98        $(USPACE_PATH)/srv/hid/compositor/compositor \
     99        $(USPACE_PATH)/srv/klog/klog
    99100
    100101RD_SRVS_NON_ESSENTIAL = \
     
    161162        $(USPACE_PATH)/app/bdsh/bdsh \
    162163        $(USPACE_PATH)/app/getterm/getterm \
    163         $(USPACE_PATH)/app/klog/klog \
     164        $(USPACE_PATH)/app/kio/kio \
    164165        $(USPACE_PATH)/app/vlaunch/vlaunch \
    165166        $(USPACE_PATH)/app/vterm/vterm
  • contrib/arch/HelenOS.adl

    raacdb8e rfd07e57b  
    2222       
    2323        /* Kernel log */
    24         inst klog klog;
     24        inst kio kio;
    2525       
    2626        [/uspace/lib/libc/bind%ns]
     
    3030        [/uspace/lib/libc/bind%vfs]
    3131        [/uspace/lib/libc/bind%console]
    32         [/uspace/lib/libc/bind%klog]
     32        [/uspace/lib/libc/bind%kio]
    3333       
    3434        bind ns:kbd to console:kbd;
     
    5858        bind console:sys_console to kernel:sys_console;
    5959       
    60         bind klog:ns to ns:ns;
     60        bind kio:ns to ns:ns;
    6161};
  • contrib/arch/kernel/kernel.adl

    raacdb8e rfd07e57b  
    33 *****************************/
    44
    5 interface sys_klog {
     5interface sys_kio {
    66                /* Print using kernel facility */
    7                 sysarg_t sys_klog(int fd, const void *buf, size_t size);
    8         protocol:
    9                 ?sys_klog*
     7                sysarg_t sys_kio(int fd, const void *buf, size_t size);
     8        protocol:
     9                ?sys_kio*
    1010};
    1111
     
    251251frame sys_console {
    252252        provides:
    253                 sys_klog sys_klog;
     253                sys_kio sys_kio;
    254254                sys_console sys_console;
    255255};
     
    316316        inst sys_debug sys_debug;
    317317       
    318         delegate sys_klog to sys_console:sys_klog;
     318        delegate sys_kio to sys_console:sys_kio;
    319319        delegate sys_console to sys_console:sys_console;
    320320        delegate sys_tls to sys_proc:sys_tls;
  • contrib/arch/uspace/app/kio/kio.adl

    raacdb8e rfd07e57b  
    1 frame klog {
     1frame kio {
    22        requires:
    33                naming_service ns;
    44                [/uspace/lib/libc/requires]
    55        initialization:
    6                 !ns.ipc_m_share_in /* SERVICE_MEM_KLOG */
     6                !ns.ipc_m_share_in /* SERVICE_MEM_KIO */
    77        protocol:
    88                [/uspace/lib/libc/protocol]
  • contrib/arch/uspace/lib/libc/bind

    raacdb8e rfd07e57b  
    11/* Bind %% to kernel interfaces */
    2 bind %%:sys_klog to kernel:sys_klog;
     2bind %%:sys_kio to kernel:sys_kio;
    33bind %%:sys_tls to kernel:sys_tls;
    44bind %%:sys_thread to kernel:sys_thread;
  • contrib/arch/uspace/lib/libc/protocol

    raacdb8e rfd07e57b  
    11/* Protocol according to which libc uses kernel syscalls */
    22(
    3         !sys_klog.sys_klog +
     3        !sys_kio.sys_kio +
    44        !sys_tls.sys_tls_set +
    55        !sys_thread.sys_thread_create +
  • contrib/arch/uspace/lib/libc/requires

    raacdb8e rfd07e57b  
    11/* Kernel interfaces required by libc */
    2 sys_klog sys_klog;
     2sys_kio sys_kio;
    33sys_tls sys_tls;
    44sys_thread sys_thread;
  • contrib/arch/uspace/lib/libc/subsume

    raacdb8e rfd07e57b  
    11/* Subsume %% to kernel interfaces */
    2 subsume %%:sys_klog to sys_klog;
     2subsume %%:sys_kio to sys_kio;
    33subsume %%:sys_tls to sys_tls;
    44subsume %%:sys_thread to sys_thread;
  • contrib/arch/uspace/srv/ns/ns.adl

    raacdb8e rfd07e57b  
    66                sysarg_t ipc_m_connect_me_to(in sysarg_t service, in sysarg_t arg2, in sysarg_t arg3, in sysarg_t flags);
    77               
    8                 /* Share real-time clock page or klog page */
     8                /* Share real-time clock page or kio page */
    99                sysarg_t ipc_m_share_in(in sysarg_t as_area_base, in sysarg_t as_area_size, in sysarg_t service);
    1010               
  • kernel/Makefile

    raacdb8e rfd07e57b  
    212212        generic/src/debug/debug.c \
    213213        generic/src/interrupt/interrupt.c \
     214        generic/src/log/log.c \
    214215        generic/src/main/main.c \
    215216        generic/src/main/kinit.c \
  • kernel/arch/amd64/src/interrupt.c

    raacdb8e rfd07e57b  
    3535#include <arch/interrupt.h>
    3636#include <print.h>
     37#include <log.h>
    3738#include <debug.h>
    3839#include <panic.h>
     
    6667void istate_decode(istate_t *istate)
    6768{
    68         printf("cs =%0#18" PRIx64 "\trip=%0#18" PRIx64 "\t"
     69        log_printf("cs =%0#18" PRIx64 "\trip=%0#18" PRIx64 "\t"
    6970            "rfl=%0#18" PRIx64 "\terr=%0#18" PRIx64 "\n",
    7071            istate->cs, istate->rip, istate->rflags, istate->error_word);
    7172       
    7273        if (istate_from_uspace(istate))
    73                 printf("ss =%0#18" PRIx64 "\n", istate->ss);
    74        
    75         printf("rax=%0#18" PRIx64 "\trbx=%0#18" PRIx64 "\t"
     74                log_printf("ss =%0#18" PRIx64 "\n", istate->ss);
     75       
     76        log_printf("rax=%0#18" PRIx64 "\trbx=%0#18" PRIx64 "\t"
    7677            "rcx=%0#18" PRIx64 "\trdx=%0#18" PRIx64 "\n",
    7778            istate->rax, istate->rbx, istate->rcx, istate->rdx);
    7879       
    79         printf("rsi=%0#18" PRIx64 "\trdi=%0#18" PRIx64 "\t"
     80        log_printf("rsi=%0#18" PRIx64 "\trdi=%0#18" PRIx64 "\t"
    8081            "rbp=%0#18" PRIx64 "\trsp=%0#18" PRIx64 "\n",
    8182            istate->rsi, istate->rdi, istate->rbp,
     
    8384            (uintptr_t) &istate->rsp);
    8485       
    85         printf("r8 =%0#18" PRIx64 "\tr9 =%0#18" PRIx64 "\t"
     86        log_printf("r8 =%0#18" PRIx64 "\tr9 =%0#18" PRIx64 "\t"
    8687            "r10=%0#18" PRIx64 "\tr11=%0#18" PRIx64 "\n",
    8788            istate->r8, istate->r9, istate->r10, istate->r11);
    8889       
    89         printf("r12=%0#18" PRIx64 "\tr13=%0#18" PRIx64 "\t"
     90        log_printf("r12=%0#18" PRIx64 "\tr13=%0#18" PRIx64 "\t"
    9091            "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n",
    9192            istate->r12, istate->r13, istate->r14, istate->r15);
     
    193194                 */
    194195#ifdef CONFIG_DEBUG
    195                 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
     196                log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt (inum=%u)",
     197                    CPU->id, inum);
    196198#endif
    197199        }
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    raacdb8e rfd07e57b  
    4949#include <ddi/ddi.h>
    5050#include <ddi/device.h>
     51#include <log.h>
    5152
    5253#define GTA02_MEMORY_START      0x30000000      /* physical */
     
    149150        } else {
    150151                /* Spurious interrupt.*/
    151                 printf("cpu%d: spurious interrupt (inum=%d)\n",
     152                log(LF_ARCH, LVL_DEBUG, "cpu%d: spurious interrupt (inum=%d)",
    152153                    CPU->id, inum);
    153154        }
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    raacdb8e rfd07e57b  
    4343#include <console/console.h>
    4444#include <sysinfo/sysinfo.h>
    45 #include <print.h>
    4645#include <ddi/device.h>
    4746#include <mm/page.h>
     
    5352#include <abi/fb/visuals.h>
    5453#include <ddi/ddi.h>
    55 #include <print.h>
     54#include <log.h>
     55
    5656
    5757
     
    275275                        } else {
    276276                                /* Spurious interrupt.*/
    277                                 printf("cpu%d: spurious interrupt (inum=%d)\n",
     277                                log(LF_ARCH, LVL_DEBUG,
     278                                    "cpu%d: spurious interrupt (inum=%d)",
    278279                                    CPU->id, i);
    279280                        }
  • kernel/arch/ia32/src/drivers/i8259.c

    raacdb8e rfd07e57b  
    4242#include <arch/asm.h>
    4343#include <arch.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <interrupt.h>
    4646
     
    129129{
    130130#ifdef CONFIG_DEBUG
    131         printf("cpu%u: PIC spurious interrupt\n", CPU->id);
     131        log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt", CPU->id);
    132132#endif
    133133}
  • kernel/arch/ia32/src/smp/apic.c

    raacdb8e rfd07e57b  
    4242#include <interrupt.h>
    4343#include <arch/interrupt.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <arch/asm.h>
    4646#include <arch.h>
     
    135135{
    136136#ifdef CONFIG_DEBUG
    137         printf("cpu%u: APIC spurious interrupt\n", CPU->id);
     137        log(LF_ARCH, LVL_DEBUG, "cpu%u: APIC spurious interrupt", CPU->id);
    138138#endif
    139139}
     
    241241        esr.value = l_apic[ESR];
    242242       
    243         if (esr.send_checksum_error)
    244                 printf("Send Checksum Error\n");
    245         if (esr.receive_checksum_error)
    246                 printf("Receive Checksum Error\n");
    247         if (esr.send_accept_error)
    248                 printf("Send Accept Error\n");
    249         if (esr.receive_accept_error)
    250                 printf("Receive Accept Error\n");
    251         if (esr.send_illegal_vector)
    252                 printf("Send Illegal Vector\n");
    253         if (esr.received_illegal_vector)
    254                 printf("Received Illegal Vector\n");
    255         if (esr.illegal_register_address)
    256                 printf("Illegal Register Address\n");
     243        if (esr.err_bitmap) {
     244                log_begin(LF_ARCH, LVL_ERROR);
     245                log_printf("APIC errors detected:");
     246                if (esr.send_checksum_error)
     247                        log_printf("\nSend Checksum Error");
     248                if (esr.receive_checksum_error)
     249                        log_printf("\nReceive Checksum Error");
     250                if (esr.send_accept_error)
     251                        log_printf("\nSend Accept Error");
     252                if (esr.receive_accept_error)
     253                        log_printf("\nReceive Accept Error");
     254                if (esr.send_illegal_vector)
     255                        log_printf("\nSend Illegal Vector");
     256                if (esr.received_illegal_vector)
     257                        log_printf("\nReceived Illegal Vector");
     258                if (esr.illegal_register_address)
     259                        log_printf("\nIllegal Register Address");
     260                log_end();
     261        }
    257262       
    258263        return !esr.err_bitmap;
     
    270275                        retries = 0;
    271276#ifdef CONFIG_DEBUG
    272                         printf("IPI is pending.\n");
     277                        log(LF_ARCH, LVL_DEBUG, "IPI is pending.");
    273278#endif
    274279                        delay(20);
     
    489494{
    490495#ifdef LAPIC_VERBOSE
    491         printf("LVT on cpu%u, LAPIC ID: %" PRIu8 "\n",
     496        log_begin(LF_ARCH, LVL_DEBUG);
     497        log_printf("LVT on cpu%u, LAPIC ID: %" PRIu8 "\n",
    492498            CPU->id, l_apic_id());
    493499       
    494500        lvt_tm_t tm;
    495501        tm.value = l_apic[LVT_Tm];
    496         printf("LVT Tm: vector=%" PRIu8 ", %s, %s, %s\n",
     502        log_printf("LVT Tm: vector=%" PRIu8 ", %s, %s, %s\n",
    497503            tm.vector, delivs_str[tm.delivs], mask_str[tm.masked],
    498504            tm_mode_str[tm.mode]);
     
    500506        lvt_lint_t lint;
    501507        lint.value = l_apic[LVT_LINT0];
    502         printf("LVT LINT0: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
     508        log_printf("LVT LINT0: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
    503509            tm.vector, delmod_str[lint.delmod], delivs_str[lint.delivs],
    504510            intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode],
     
    506512       
    507513        lint.value = l_apic[LVT_LINT1];
    508         printf("LVT LINT1: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
     514        log_printf("LVT LINT1: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
    509515            tm.vector, delmod_str[lint.delmod], delivs_str[lint.delivs],
    510516            intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode],
     
    513519        lvt_error_t error;
    514520        error.value = l_apic[LVT_Err];
    515         printf("LVT Err: vector=%" PRIu8 ", %s, %s\n", error.vector,
     521        log_printf("LVT Err: vector=%" PRIu8 ", %s, %s\n", error.vector,
    516522            delivs_str[error.delivs], mask_str[error.masked]);
     523        log_end();
    517524#endif
    518525}
  • kernel/arch/ia32/src/smp/mps.c

    raacdb8e rfd07e57b  
    3636
    3737#include <config.h>
    38 #include <print.h>
     38#include <log.h>
    3939#include <debug.h>
    4040#include <arch/smp/mps.h>
     
    181181        buf[6] = 0;
    182182       
    183         printf("MPS: bus=%" PRIu8 " (%s)\n", bus->bus_id, buf);
     183        log(LF_ARCH, LVL_DEBUG, "MPS: bus=%" PRIu8 " (%s)", bus->bus_id, buf);
    184184#endif
    185185}
     
    205205{
    206206#ifdef MPSCT_VERBOSE
    207         printf("MPS: ");
     207        log_begin(LF_ARCH, LVL_DEBUG);
     208        log_printf("MPS: ");
    208209       
    209210        switch (iointr->intr_type) {
    210211        case 0:
    211                 printf("INT");
    212                 break;
    213         case 1:
    214                 printf("NMI");
    215                 break;
    216         case 2:
    217                 printf("SMI");
    218                 break;
    219         case 3:
    220                 printf("ExtINT");
    221                 break;
    222         }
    223        
    224         printf(", ");
     212                log_printf("INT");
     213                break;
     214        case 1:
     215                log_printf("NMI");
     216                break;
     217        case 2:
     218                log_printf("SMI");
     219                break;
     220        case 3:
     221                log_printf("ExtINT");
     222                break;
     223        }
     224       
     225        log_printf(", ");
    225226       
    226227        switch (iointr->poel & 3) {
    227228        case 0:
    228                 printf("bus-like");
    229                 break;
    230         case 1:
    231                 printf("active high");
    232                 break;
    233         case 2:
    234                 printf("reserved");
    235                 break;
    236         case 3:
    237                 printf("active low");
    238                 break;
    239         }
    240        
    241         printf(", ");
     229                log_printf("bus-like");
     230                break;
     231        case 1:
     232                log_printf("active high");
     233                break;
     234        case 2:
     235                log_printf("reserved");
     236                break;
     237        case 3:
     238                log_printf("active low");
     239                break;
     240        }
     241       
     242        log_printf(", ");
    242243       
    243244        switch ((iointr->poel >> 2) & 3) {
    244245        case 0:
    245                 printf("bus-like");
    246                 break;
    247         case 1:
    248                 printf("edge-triggered");
    249                 break;
    250         case 2:
    251                 printf("reserved");
    252                 break;
    253         case 3:
    254                 printf("level-triggered");
    255                 break;
    256         }
    257        
    258         printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8" pin=%"
    259             PRIu8 "\n", iointr->src_bus_id, iointr->src_bus_irq,
     246                log_printf("bus-like");
     247                break;
     248        case 1:
     249                log_printf("edge-triggered");
     250                break;
     251        case 2:
     252                log_printf("reserved");
     253                break;
     254        case 3:
     255                log_printf("level-triggered");
     256                break;
     257        }
     258       
     259        log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8" pin=%"
     260            PRIu8, iointr->src_bus_id, iointr->src_bus_irq,
    260261            iointr->dst_io_apic_id, iointr->dst_io_apic_pin);
     262        log_end();
    261263#endif
    262264}
     
    266268{
    267269#ifdef MPSCT_VERBOSE
    268         printf("MPS: ");
     270        log_begin(LF_ARCH, LVL_DEBUG);
     271        log_printf("MPS: ");
    269272       
    270273        switch (lintr->intr_type) {
    271274        case 0:
    272                 printf("INT");
    273                 break;
    274         case 1:
    275                 printf("NMI");
    276                 break;
    277         case 2:
    278                 printf("SMI");
    279                 break;
    280         case 3:
    281                 printf("ExtINT");
    282                 break;
    283         }
    284        
    285         printf(", ");
     275                log_printf("INT");
     276                break;
     277        case 1:
     278                log_printf("NMI");
     279                break;
     280        case 2:
     281                log_printf("SMI");
     282                break;
     283        case 3:
     284                log_printf("ExtINT");
     285                break;
     286        }
     287       
     288        log_printf(", ");
    286289       
    287290        switch (lintr->poel & 3) {
    288291        case 0:
    289                 printf("bus-like");
    290                 break;
    291         case 1:
    292                 printf("active high");
    293                 break;
    294         case 2:
    295                 printf("reserved");
    296                 break;
    297         case 3:
    298                 printf("active low");
    299                 break;
    300         }
    301        
    302         printf(", ");
     292                log_printf("bus-like");
     293                break;
     294        case 1:
     295                log_printf("active high");
     296                break;
     297        case 2:
     298                log_printf("reserved");
     299                break;
     300        case 3:
     301                log_printf("active low");
     302                break;
     303        }
     304       
     305        log_printf(", ");
    303306       
    304307        switch ((lintr->poel >> 2) & 3) {
    305308        case 0:
    306                 printf("bus-like");
    307                 break;
    308         case 1:
    309                 printf("edge-triggered");
    310                 break;
    311         case 2:
    312                 printf("reserved");
    313                 break;
    314         case 3:
    315                 printf("level-triggered");
    316                 break;
    317         }
    318        
    319         printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8" pin=%"
    320             PRIu8 "\n", lintr->src_bus_id, lintr->src_bus_irq,
     309                log_printf("bus-like");
     310                break;
     311        case 1:
     312                log_printf("edge-triggered");
     313                break;
     314        case 2:
     315                log_printf("reserved");
     316                break;
     317        case 3:
     318                log_printf("level-triggered");
     319                break;
     320        }
     321       
     322        log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8" pin=%"
     323            PRIu8, lintr->src_bus_id, lintr->src_bus_irq,
    321324            lintr->dst_l_apic_id, lintr->dst_l_apic_pin);
     325        log_end();
    322326#endif
    323327}
     
    332336                switch (cur[CT_EXT_ENTRY_TYPE]) {
    333337                default:
    334                         printf("MPS: Skipping MP Configuration Table extended "
    335                             "entry type %" PRIu8 "\n", cur[CT_EXT_ENTRY_TYPE]);
     338                        log(LF_ARCH, LVL_NOTE, "MPS: Skipping MP Configuration"
     339                            " Table extended entry type %" PRIu8,
     340                            cur[CT_EXT_ENTRY_TYPE]);
    336341                }
    337342        }
     
    341346{
    342347        if (ct->signature != CT_SIGNATURE) {
    343                 printf("MPS: Wrong ct->signature\n");
     348                log(LF_ARCH, LVL_WARN, "MPS: Wrong ct->signature");
    344349                return;
    345350        }
    346351       
    347352        if (!mps_ct_check()) {
    348                 printf("MPS: Wrong ct checksum\n");
     353                log(LF_ARCH, LVL_WARN, "MPS: Wrong ct checksum");
    349354                return;
    350355        }
    351356       
    352357        if (ct->oem_table) {
    353                 printf("MPS: ct->oem_table not supported\n");
     358                log(LF_ARCH, LVL_WARN, "MPS: ct->oem_table not supported");
    354359                return;
    355360        }
     
    402407                         * Something is wrong. Fallback to UP mode.
    403408                         */
    404                         printf("MPS: ct badness %" PRIu8 "\n", *cur);
     409                        log(LF_ARCH, LVL_WARN, "MPS: ct badness %" PRIu8, *cur);
    405410                        return;
    406411                }
     
    418423         * Not yet implemented.
    419424         */
    420         printf("MPS: Default configuration not supported\n");
     425        log(LF_ARCH, LVL_WARN, "MPS: Default configuration not supported");
    421426}
    422427
     
    449454       
    450455fs_found:
    451         printf("%p: MPS Floating Pointer Structure\n", fs);
     456        log(LF_ARCH, LVL_NOTE, "%p: MPS Floating Pointer Structure", fs);
    452457       
    453458        if ((fs->config_type == 0) && (fs->configuration_table)) {
    454459                if (fs->mpfib2 >> 7) {
    455                         printf("MPS: PIC mode not supported\n");
     460                        log(LF_ARCH, LVL_WARN, "MPS: PIC mode not supported\n");
    456461                        return;
    457462                }
  • kernel/arch/ia32/src/smp/smp.c

    raacdb8e rfd07e57b  
    5252#include <mm/slab.h>
    5353#include <mm/as.h>
    54 #include <print.h>
     54#include <log.h>
    5555#include <memstr.h>
    5656#include <arch/drivers/i8259.h>
     
    129129               
    130130                if (ops->cpu_apic_id(i) == bsp_l_apic) {
    131                         printf("kmp: bad processor entry #%u, will not send IPI "
    132                             "to myself\n", i);
     131                        log(LF_ARCH, LVL_ERROR, "kmp: bad processor entry #%u, "
     132                            "will not send IPI to myself", i);
    133133                        continue;
    134134                }
     
    162162                        if (waitq_sleep_timeout(&ap_completion_wq, 1000000,
    163163                            SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {
    164                                 printf("%s: waiting for cpu%u (APIC ID = %d) "
    165                                     "timed out\n", __FUNCTION__, i,
    166                                     ops->cpu_apic_id(i));
     164                                log(LF_ARCH, LVL_NOTE, "%s: waiting for cpu%u "
     165                                    "(APIC ID = %d) timed out", __FUNCTION__,
     166                                    i, ops->cpu_apic_id(i));
    167167                        }
    168168                } else
    169                         printf("INIT IPI for l_apic%d failed\n",
     169                        log(LF_ARCH, LVL_ERROR, "INIT IPI for l_apic%d failed",
    170170                            ops->cpu_apic_id(i));
    171171        }
  • kernel/arch/mips32/src/debugger.c

    raacdb8e rfd07e57b  
    3939#include <console/cmd.h>
    4040#include <print.h>
     41#include <log.h>
    4142#include <panic.h>
    4243#include <arch.h>
     
    294295        cmd_initialize(&bkpts_info);
    295296        if (!cmd_register(&bkpts_info))
    296                 printf("Cannot register command %s\n", bkpts_info.name);
     297                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     298                    bkpts_info.name);
    297299       
    298300        cmd_initialize(&delbkpt_info);
    299301        if (!cmd_register(&delbkpt_info))
    300                 printf("Cannot register command %s\n", delbkpt_info.name);
     302                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     303                    delbkpt_info.name);
    301304       
    302305        cmd_initialize(&addbkpt_info);
    303306        if (!cmd_register(&addbkpt_info))
    304                 printf("Cannot register command %s\n", addbkpt_info.name);
     307                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     308                    addbkpt_info.name);
    305309       
    306310        cmd_initialize(&addbkpte_info);
    307311        if (!cmd_register(&addbkpte_info))
    308                 printf("Cannot register command %s\n", addbkpte_info.name);
     312                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     313                    addbkpte_info.name);
    309314#endif /* CONFIG_KCONSOLE */
    310315}
  • kernel/arch/mips32/src/exception.c

    raacdb8e rfd07e57b  
    4848#include <arch/debugger.h>
    4949#include <symtab.h>
     50#include <log.h>
    5051
    5152static const char *exctable[] = {
     
    7475void istate_decode(istate_t *istate)
    7576{
    76         printf("epc=%#010" PRIx32 "\tsta=%#010" PRIx32 "\t"
     77        log_printf("epc=%#010" PRIx32 "\tsta=%#010" PRIx32 "\t"
    7778            "lo =%#010" PRIx32 "\thi =%#010" PRIx32 "\n",
    7879            istate->epc, istate->status, istate->lo, istate->hi);
    7980       
    80         printf("a0 =%#010" PRIx32 "\ta1 =%#010" PRIx32 "\t"
     81        log_printf("a0 =%#010" PRIx32 "\ta1 =%#010" PRIx32 "\t"
    8182            "a2 =%#010" PRIx32 "\ta3 =%#010" PRIx32 "\n",
    8283            istate->a0, istate->a1, istate->a2, istate->a3);
    8384       
    84         printf("t0 =%#010" PRIx32 "\tt1 =%#010" PRIx32 "\t"
     85        log_printf("t0 =%#010" PRIx32 "\tt1 =%#010" PRIx32 "\t"
    8586            "t2 =%#010" PRIx32 "\tt3 =%#010" PRIx32 "\n",
    8687            istate->t0, istate->t1, istate->t2, istate->t3);
    8788       
    88         printf("t4 =%#010" PRIx32 "\tt5 =%#010" PRIx32 "\t"
     89        log_printf("t4 =%#010" PRIx32 "\tt5 =%#010" PRIx32 "\t"
    8990            "t6 =%#010" PRIx32 "\tt7 =%#010" PRIx32 "\n",
    9091            istate->t4, istate->t5, istate->t6, istate->t7);
    9192       
    92         printf("t8 =%#010" PRIx32 "\tt9 =%#010" PRIx32 "\t"
     93        log_printf("t8 =%#010" PRIx32 "\tt9 =%#010" PRIx32 "\t"
    9394            "v0 =%#010" PRIx32 "\tv1 =%#010" PRIx32 "\n",
    9495            istate->t8, istate->t9, istate->v0, istate->v1);
    9596       
    96         printf("s0 =%#010" PRIx32 "\ts1 =%#010" PRIx32 "\t"
     97        log_printf("s0 =%#010" PRIx32 "\ts1 =%#010" PRIx32 "\t"
    9798            "s2 =%#010" PRIx32 "\ts3 =%#010" PRIx32 "\n",
    9899            istate->s0, istate->s1, istate->s2, istate->s3);
    99100       
    100         printf("s4 =%#010" PRIx32 "\ts5 =%#010" PRIx32 "\t"
     101        log_printf("s4 =%#010" PRIx32 "\ts5 =%#010" PRIx32 "\t"
    101102            "s6 =%#010" PRIx32 "\ts7 =%#010" PRIx32 "\n",
    102103            istate->s4, istate->s5, istate->s6, istate->s7);
    103104       
    104         printf("s8 =%#010" PRIx32 "\tat =%#010" PRIx32 "\t"
     105        log_printf("s8 =%#010" PRIx32 "\tat =%#010" PRIx32 "\t"
    105106            "kt0=%#010" PRIx32 "\tkt1=%#010" PRIx32 "\n",
    106107            istate->s8, istate->at, istate->kt0, istate->kt1);
    107108       
    108         printf("sp =%#010" PRIx32 "\tra =%#010" PRIx32 "\t"
     109        log_printf("sp =%#010" PRIx32 "\tra =%#010" PRIx32 "\t"
    109110            "gp =%#010" PRIx32 "\n",
    110111            istate->sp, istate->ra, istate->gp);
     
    194195                                 */
    195196#ifdef CONFIG_DEBUG
    196                                 printf("cpu%u: spurious interrupt (inum=%u)\n",
     197                                log(LF_ARCH, LVL_DEBUG,
     198                                    "cpu%u: spurious interrupt (inum=%u)",
    197199                                    CPU->id, i);
    198200#endif
  • kernel/arch/mips32/src/mm/tlb.c

    raacdb8e rfd07e57b  
    4343#include <synch/mutex.h>
    4444#include <print.h>
     45#include <log.h>
    4546#include <debug.h>
    4647#include <align.h>
     
    217218         */
    218219        if (index.p) {
    219                 printf("%s: TLBP failed in exception handler (badvaddr=%#"
     220                log(LF_ARCH, LVL_WARN, "%s: TLBP failed in exception handler (badvaddr=%#"
    220221                    PRIxn ", ASID=%d).\n", __func__, badvaddr,
    221222                    AS ? AS->asid : -1);
  • kernel/arch/ppc32/src/interrupt.c

    raacdb8e rfd07e57b  
    4444#include <arch/mm/pht.h>
    4545#include <print.h>
     46#include <log.h>
    4647
    4748void start_decrementer(void)
     
    5556void istate_decode(istate_t *istate)
    5657{
    57         printf("r0 =%0#10" PRIx32 "\tr1 =%0#10" PRIx32 "\t"
     58        log_printf("r0 =%0#10" PRIx32 "\tr1 =%0#10" PRIx32 "\t"
    5859            "r2 =%0#10" PRIx32 "\n", istate->r0, istate->sp, istate->r2);
    5960       
    60         printf("r3 =%0#10" PRIx32 "\tr4 =%0#10" PRIx32 "\t"
     61        log_printf("r3 =%0#10" PRIx32 "\tr4 =%0#10" PRIx32 "\t"
    6162            "r5 =%0#10" PRIx32 "\n", istate->r3, istate->r4, istate->r5);
    6263       
    63         printf("r6 =%0#10" PRIx32 "\tr7 =%0#10" PRIx32 "\t"
     64        log_printf("r6 =%0#10" PRIx32 "\tr7 =%0#10" PRIx32 "\t"
    6465            "r8 =%0#10" PRIx32 "\n", istate->r6, istate->r7, istate->r8);
    6566       
    66         printf("r9 =%0#10" PRIx32 "\tr10=%0#10" PRIx32 "\t"
     67        log_printf("r9 =%0#10" PRIx32 "\tr10=%0#10" PRIx32 "\t"
    6768            "r11=%0#10" PRIx32 "\n", istate->r9, istate->r10, istate->r11);
    6869       
    69         printf("r12=%0#10" PRIx32 "\tr13=%0#10" PRIx32 "\t"
     70        log_printf("r12=%0#10" PRIx32 "\tr13=%0#10" PRIx32 "\t"
    7071            "r14=%0#10" PRIx32 "\n", istate->r12, istate->r13, istate->r14);
    7172       
    72         printf("r15=%0#10" PRIx32 "\tr16=%0#10" PRIx32 "\t"
     73        log_printf("r15=%0#10" PRIx32 "\tr16=%0#10" PRIx32 "\t"
    7374            "r17=%0#10" PRIx32 "\n", istate->r15, istate->r16, istate->r17);
    7475       
    75         printf("r18=%0#10" PRIx32 "\tr19=%0#10" PRIx32 "\t"
     76        log_printf("r18=%0#10" PRIx32 "\tr19=%0#10" PRIx32 "\t"
    7677            "r20=%0#10" PRIx32 "\n", istate->r18, istate->r19, istate->r20);
    7778       
    78         printf("r21=%0#10" PRIx32 "\tr22=%0#10" PRIx32 "\t"
     79        log_printf("r21=%0#10" PRIx32 "\tr22=%0#10" PRIx32 "\t"
    7980            "r23=%0#10" PRIx32 "\n", istate->r21, istate->r22, istate->r23);
    8081       
    81         printf("r24=%0#10" PRIx32 "\tr25=%0#10" PRIx32 "\t"
     82        log_printf("r24=%0#10" PRIx32 "\tr25=%0#10" PRIx32 "\t"
    8283            "r26=%0#10" PRIx32 "\n", istate->r24, istate->r25, istate->r26);
    8384       
    84         printf("r27=%0#10" PRIx32 "\tr28=%0#10" PRIx32 "\t"
     85        log_printf("r27=%0#10" PRIx32 "\tr28=%0#10" PRIx32 "\t"
    8586            "r29=%0#10" PRIx32 "\n", istate->r27, istate->r28, istate->r29);
    8687       
    87         printf("r30=%0#10" PRIx32 "\tr31=%0#10" PRIx32 "\n",
     88        log_printf("r30=%0#10" PRIx32 "\tr31=%0#10" PRIx32 "\n",
    8889            istate->r30, istate->r31);
    8990       
    90         printf("cr =%0#10" PRIx32 "\tpc =%0#10" PRIx32 "\t"
     91        log_printf("cr =%0#10" PRIx32 "\tpc =%0#10" PRIx32 "\t"
    9192            "lr =%0#10" PRIx32 "\n", istate->cr, istate->pc, istate->lr);
    9293       
    93         printf("ctr=%0#10" PRIx32 "\txer=%0#10" PRIx32 "\t"
     94        log_printf("ctr=%0#10" PRIx32 "\txer=%0#10" PRIx32 "\t"
    9495            "dar=%0#10" PRIx32 "\n", istate->ctr, istate->xer, istate->dar);
    9596       
    96         printf("srr1=%0#10" PRIx32 "\n", istate->srr1);
     97        log_printf("srr1=%0#10" PRIx32 "\n", istate->srr1);
    9798}
    9899
     
    130131                         */
    131132#ifdef CONFIG_DEBUG
    132                         printf("cpu%u: spurious interrupt (inum=%" PRIu8 ")\n",
    133                             CPU->id, inum);
     133                        log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt"
     134                            " (inum=%" PRIu8 ")", CPU->id, inum);
    134135#endif
    135136                }
  • kernel/arch/sparc64/src/drivers/kbd.c

    raacdb8e rfd07e57b  
    4444#include <align.h>
    4545#include <str.h>
    46 #include <print.h>
     46#include <log.h>
    4747#include <sysinfo/sysinfo.h>
    4848
     
    7171        ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts");
    7272        if ((!prop) || (!prop->value)) {
    73                 printf("ns16550: Unable to find interrupts property\n");
     73                log(LF_ARCH, LVL_ERROR,
     74                    "ns16550: Unable to find interrupts property");
    7475                return false;
    7576        }
     
    8283        prop = ofw_tree_getprop(node, "reg");
    8384        if ((!prop) || (!prop->value)) {
    84                 printf("ns16550: Unable to find reg property\n");
     85                log(LF_ARCH, LVL_ERROR,
     86                    "ns16550: Unable to find reg property");
    8587                return false;
    8688        }
     
    9193        if (!ofw_ebus_apply_ranges(node->parent,
    9294            ((ofw_ebus_reg_t *) prop->value), &pa)) {
    93                 printf("ns16550: Failed to determine address\n");
     95                log(LF_ARCH, LVL_ERROR,
     96                    "ns16550: Failed to determine address");
    9497                return false;
    9598        }
     
    101104            ((ofw_ebus_reg_t *) prop->value), interrupts, &inr, &cir,
    102105            &cir_arg)) {
    103                 printf("ns16550: Failed to determine interrupt\n");
     106                log(LF_ARCH, LVL_ERROR,
     107                    "ns16550: Failed to determine interrupt");
    104108                return false;
    105109        }
     
    117121            PAGE_WRITE | PAGE_NOT_CACHEABLE) + offset);
    118122       
    119         ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir, cir_arg);
     123        ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir,
     124            cir_arg, NULL);
    120125        if (ns16550_instance) {
    121126                kbrd_instance_t *kbrd_instance = kbrd_init();
  • kernel/arch/sparc64/src/drivers/pci.c

    raacdb8e rfd07e57b  
    4343#include <typedefs.h>
    4444#include <debug.h>
    45 #include <print.h>
     45#include <log.h>
    4646#include <str.h>
    4747#include <arch/asm.h>
     
    213213                 * Unsupported model.
    214214                 */
    215                 printf("Unsupported PCI controller model (%s).\n",
     215                log(LF_ARCH, LVL_WARN, "Unsupported PCI controller model (%s).",
    216216                    (char *) prop->value);
    217217        }
  • kernel/arch/sparc64/src/drivers/scr.c

    raacdb8e rfd07e57b  
    8181       
    8282        if (scr_type == SCR_UNKNOWN) {
    83                 printf("Unknown screen device.\n");
     83                log(LF_ARCH, LVL_ERROR, "Unknown screen device.");
    8484                return;
    8585        }
     
    117117        case SCR_ATYFB:
    118118                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
    119                         printf("Too few screen registers.\n");
     119                        log(LF_ARCH, LVL_ERROR, "Too few screen registers.");
    120120                        return;
    121121                }
     
    124124               
    125125                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
    126                         printf("Failed to absolutize fb register.\n");
     126                        log(LF_ARCH, LVL_ERROR,
     127                            "Failed to absolutize fb register.");
    127128                        return;
    128129                }
     
    130131                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
    131132                    &fb_addr)) {
    132                         printf("Failed to determine screen address.\n");
     133                        log(LF_ARCH, LVL_ERROR,
     134                            "Failed to determine screen address.");
    133135                        return;
    134136                }
     
    152154                        break;
    153155                default:
    154                         printf("Unsupported bits per pixel.\n");
     156                        log(LF_ARCH, LVL_ERROR,
     157                            "Unsupported bits per pixel.");
    155158                        return;
    156159                }
     
    159162        case SCR_XVR:
    160163                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
    161                         printf("Too few screen registers.\n");
     164                        log(LF_ARCH, LVL_ERROR,
     165                            "Too few screen registers.");
    162166                        return;
    163167                }
     
    166170               
    167171                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
    168                         printf("Failed to absolutize fb register.\n");
     172                        log(LF_ARCH, LVL_ERROR,
     173                            "Failed to absolutize fb register.");
    169174                        return;
    170175                }
     
    172177                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
    173178                    &fb_addr)) {
    174                         printf("Failed to determine screen address.\n");
     179                        log(LF_ARCH, LVL_ERROR,
     180                            "Failed to determine screen address.");
    175181                        return;
    176182                }
     
    196202                        break;
    197203                default:
    198                         printf("Unsupported bits per pixel.\n");
     204                        log(LF_ARCH, LVL_ERROR,
     205                            "Unsupported bits per pixel.");
    199206                        return;
    200207                }
     
    207214                upa_reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP];
    208215                if (!ofw_upa_apply_ranges(node->parent, upa_reg, &fb_addr)) {
    209                         printf("Failed to determine screen address.\n");
     216                        log(LF_ARCH, LVL_ERROR,
     217                            "Failed to determine screen address.");
    210218                        return;
    211219                }
     
    219227                        break;
    220228                default:
    221                         printf("Not implemented.\n");
     229                        log(LF_ARCH, LVL_WARN, "Not implemented.");
    222230                        return;
    223231                }
     
    225233                sbus_reg = &((ofw_sbus_reg_t *) prop->value)[0];
    226234                if (!ofw_sbus_apply_ranges(node->parent, sbus_reg, &fb_addr)) {
    227                         printf("Failed to determine screen address.\n");
     235                        log(LF_ARCH, LVL_ERROR,
     236                            "Failed to determine screen address.");
    228237                        return;
    229238                }
     
    233242        case SCR_QEMU_VGA:
    234243                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
    235                         printf("Too few screen registers.\n");
     244                        log(LF_ARCH, LVL_ERROR, "Too few screen registers.");
    236245                        return;
    237246                }
     
    240249
    241250                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
    242                         printf("Failed to absolutize fb register.\n");
     251                        log(LF_ARCH, LVL_ERROR,
     252                            "Failed to absolutize fb register.");
    243253                        return;
    244254                }
     
    246256                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
    247257                    &fb_addr)) {
    248                         printf("Failed to determine screen address.\n");
     258                        log(LF_ARCH, LVL_ERROR,
     259                            "Failed to determine screen address.");
    249260                        return;
    250261                }
     
    268279                        break;
    269280                default:
    270                         printf("Unsupported bits per pixel.\n");
     281                        log(LF_ARCH, LVL_ERROR, "Unsupported bits per pixel.");
    271282                        return;
    272283                }
  • kernel/arch/sparc64/src/mm/sun4v/tlb.c

    raacdb8e rfd07e57b  
    4646#include <arch.h>
    4747#include <print.h>
     48#include <log.h>
    4849#include <typedefs.h>
    4950#include <config.h>
     
    335336void tlb_print(void)
    336337{
    337         printf("Operation not possible on Niagara.\n");
     338        log(LF_ARCH, LVL_WARN, "Operation not possible on Niagara.");
    338339}
    339340
  • kernel/arch/sparc64/src/smp/sun4u/smp.c

    raacdb8e rfd07e57b  
    4343#include <typedefs.h>
    4444#include <synch/waitq.h>
    45 #include <print.h>
     45#include <log.h>
    4646#include <arch/cpu_node.h>
    4747
     
    108108        if (waitq_sleep_timeout(&ap_completion_wq, 1000000, SYNCH_FLAGS_NONE) ==
    109109            ESYNCH_TIMEOUT)
    110                 printf("%s: waiting for processor (mid = %" PRIu32
    111                     ") timed out\n", __func__, mid);
     110                log(LF_ARCH, LVL_NOTE, "%s: waiting for processor (mid = %" PRIu32
     111                    ") timed out", __func__, mid);
    112112}
    113113
  • kernel/arch/sparc64/src/sun4v/md.c

    raacdb8e rfd07e57b  
    3636#include <panic.h>
    3737#include <func.h>
    38 #include <print.h>
     38#include <log.h>
    3939#include <str.h>
    4040#include <arch/sun4v/md.h>
     
    310310        retval = retval;
    311311        if (retval != HV_EOK) {
    312                 printf("Could not retrieve machine description, "
    313                     "error=%" PRIu64 ".\n", retval);
     312                log(LF_ARCH, LVL_ERROR, "Could not retrieve machine "
     313                    "description, error=%" PRIu64 ".", retval);
    314314        }
    315315}
  • kernel/arch/sparc64/src/trap/sun4u/interrupt.c

    raacdb8e rfd07e57b  
    4242#include <arch/asm.h>
    4343#include <arch/barrier.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <arch.h>
    4646#include <mm/tlb.h>
     
    9696                 */
    9797#ifdef CONFIG_DEBUG
    98                 printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64
    99                     ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0);
     98                log(LF_ARCH, LVL_DEBUG,
     99                    "cpu%u: spurious interrupt (intrcv=%#" PRIx64 ", data0=%#"
     100                    PRIx64 ")", CPU->id, intrcv, data0);
    100101#else
    101102                (void) intrcv;
  • kernel/arch/sparc64/src/trap/sun4v/interrupt.c

    raacdb8e rfd07e57b  
    4242#include <arch/asm.h>
    4343#include <arch/barrier.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <arch.h>
    4646#include <mm/tlb.h>
     
    111111                        ((void (*)(void)) data1)();
    112112                } else {
    113                         printf("Spurious interrupt on %" PRIu64 ", data = %" PRIx64 ".\n",
    114                             CPU->arch.id, data1);
     113                        log(LF_ARCH, LVL_DEBUG, "Spurious interrupt on %" PRIu64
     114                            ", data = %" PRIx64 ".", CPU->arch.id, data1);
    115115                }
    116116        }
  • kernel/doc/doxygroups.h

    raacdb8e rfd07e57b  
    167167 */
    168168 
    169 /** @defgroup genericklog KLog
    170  * @brief Kernel logging facility
     169/** @defgroup generickio KIO
     170 * @brief Kernel character input/output facility
    171171 * @ingroup genericconsole
    172172 */
  • kernel/genarch/src/acpi/acpi.c

    raacdb8e rfd07e57b  
    4141#include <mm/page.h>
    4242#include <mm/km.h>
    43 #include <print.h>
     43#include <log.h>
    4444
    4545#define RSDP_SIGNATURE      "RSD PTR "
     
    211211       
    212212        if ((acpi_rsdt) && (!acpi_sdt_check((uint8_t *) acpi_rsdt))) {
    213                 printf("RSDT: bad checksum\n");
     213                log(LF_ARCH, LVL_ERROR, "RSDT: bad checksum");
    214214                return;
    215215        }
    216216       
    217217        if ((acpi_xsdt) && (!acpi_sdt_check((uint8_t *) acpi_xsdt))) {
    218                 printf("XSDT: bad checksum\n");
     218                log(LF_ARCH, LVL_ERROR, "XSDT: bad checksum");
    219219                return;
    220220        }
  • kernel/genarch/src/acpi/madt.c

    raacdb8e rfd07e57b  
    4343#include <debug.h>
    4444#include <config.h>
    45 #include <print.h>
     45#include <log.h>
    4646#include <mm/slab.h>
    4747#include <memstr.h>
     
    236236                case MADT_L_SAPIC:
    237237                case MADT_PLATFORM_INTR_SRC:
    238                         printf("MADT: Skipping %s entry (type=%" PRIu8 ")\n",
     238                        log(LF_ARCH, LVL_WARN,
     239                            "MADT: Skipping %s entry (type=%" PRIu8 ")",
    239240                            entry[hdr->type], hdr->type);
    240241                        break;
     
    242243                        if ((hdr->type >= MADT_RESERVED_SKIP_BEGIN)
    243244                            && (hdr->type <= MADT_RESERVED_SKIP_END))
    244                                 printf("MADT: Skipping reserved entry (type=%" PRIu8 ")\n",
     245                                log(LF_ARCH, LVL_NOTE,
     246                                    "MADT: Skipping reserved entry (type=%" PRIu8 ")",
    245247                                    hdr->type);
    246248                               
    247249                        if (hdr->type >= MADT_RESERVED_OEM_BEGIN)
    248                                 printf("MADT: Skipping OEM entry (type=%" PRIu8 ")\n",
     250                                log(LF_ARCH, LVL_NOTE,
     251                                    "MADT: Skipping OEM entry (type=%" PRIu8 ")",
    249252                                    hdr->type);
    250253                       
  • kernel/genarch/src/drivers/via-cuda/cuda.c

    raacdb8e rfd07e57b  
    118118}
    119119
    120 #include <print.h>
     120#include <log.h>
    121121void cuda_wire(cuda_instance_t *instance, indev_t *kbrdin)
    122122{
     
    197197
    198198        if ((b & TREQ) != 0) {
    199                 printf("cuda_irq_listen: no TREQ?!\n");
     199                log(LF_OTHER, LVL_ERROR, "cuda_irq_listen: no TREQ?!");
    200200                return;
    201201        }
  • kernel/generic/include/console/console.h

    raacdb8e rfd07e57b  
    3939#include <print.h>
    4040#include <console/chardev.h>
     41#include <synch/spinlock.h>
    4142
    4243#define PAGING(counter, increment, before, after) \
     
    6263extern void console_init(void);
    6364
    64 extern void klog_init(void);
    65 extern void klog_update(void *);
     65extern void kio_init(void);
     66extern void kio_update(void *);
     67extern void kio_flush(void);
     68extern void kio_push_char(const wchar_t);
     69SPINLOCK_EXTERN(kio_lock);
    6670
    6771extern wchar_t getc(indev_t *indev);
    6872extern size_t gets(indev_t *indev, char *buf, size_t buflen);
    69 extern sysarg_t sys_klog(int cmd, const void *buf, size_t size);
     73extern sysarg_t sys_kio(int cmd, const void *buf, size_t size);
    7074
    7175extern void grab_console(void);
  • kernel/generic/include/debug.h

    raacdb8e rfd07e57b  
    107107#define LOG(format, ...) \
    108108        do { \
    109                 printf("%s() from %s at %s:%u: " format "\n", __func__, \
     109                log(LF_OTHER, LVL_DEBUG, \
     110                    "%s() from %s at %s:%u: " format,__func__, \
    110111                    symtab_fmt_name_lookup(CALLER), __FILE__, __LINE__, \
    111112                    ##__VA_ARGS__); \
  • kernel/generic/include/synch/spinlock.h

    raacdb8e rfd07e57b  
    137137#ifdef CONFIG_DEBUG_SPINLOCK
    138138
    139 #include <print.h>
     139#include <log.h>
    140140
    141141#define DEADLOCK_THRESHOLD  100000000
     
    146146        if ((pname)++ > (value)) { \
    147147                (pname) = 0; \
    148                 printf("Deadlock probe %s: exceeded threshold %u\n" \
     148                log(LF_OTHER, LVL_WARN, \
     149                    "Deadlock probe %s: exceeded threshold %u\n" \
    149150                    "cpu%u: function=%s, line=%u\n", \
    150151                    #pname, (value), CPU->id, __func__, __LINE__); \
  • kernel/generic/src/console/cmd.c

    raacdb8e rfd07e57b  
    4545#include <console/kconsole.h>
    4646#include <print.h>
     47#include <log.h>
    4748#include <panic.h>
    4849#include <typedefs.h>
     
    639640        for (i = 0; basic_commands[i]; i++) {
    640641                if (!cmd_register(basic_commands[i])) {
    641                         printf("Cannot register command %s\n",
     642                        log(LF_OTHER, LVL_ERROR,
     643                            "Cannot register command %s",
    642644                            basic_commands[i]->name);
    643645                }
     
    665667        unsigned int _len = (unsigned int) len;
    666668        if ((_len != len) || (((int) _len) < 0)) {
    667                 printf("Command length overflow\n");
     669                log(LF_OTHER, LVL_ERROR, "Command length overflow");
    668670                return 1;
    669671        }
  • kernel/generic/src/console/console.c

    raacdb8e rfd07e57b  
    5252#include <errno.h>
    5353#include <str.h>
    54 #include <abi/klog.h>
    55 
    56 #define KLOG_PAGES    8
    57 #define KLOG_LENGTH   (KLOG_PAGES * PAGE_SIZE / sizeof(wchar_t))
     54#include <abi/kio.h>
     55
     56#define KIO_PAGES    8
     57#define KIO_LENGTH   (KIO_PAGES * PAGE_SIZE / sizeof(wchar_t))
    5858
    5959/** Kernel log cyclic buffer */
    60 wchar_t klog[KLOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));
     60wchar_t kio[KIO_LENGTH] __attribute__((aligned(PAGE_SIZE)));
    6161
    6262/** Kernel log initialized */
    63 static atomic_t klog_inited = {false};
     63static atomic_t kio_inited = {false};
    6464
    6565/** First kernel log characters */
    66 static size_t klog_start = 0;
     66static size_t kio_start = 0;
    6767
    6868/** Number of valid kernel log characters */
    69 static size_t klog_len = 0;
     69static size_t kio_len = 0;
    7070
    7171/** Number of stored (not printed) kernel log characters */
    72 static size_t klog_stored = 0;
     72static size_t kio_stored = 0;
    7373
    7474/** Number of stored kernel log characters for uspace */
    75 static size_t klog_uspace = 0;
     75static size_t kio_uspace = 0;
    7676
    7777/** Kernel log spinlock */
    78 SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "klog_lock");
    79 
    80 /** Physical memory area used for klog buffer */
    81 static parea_t klog_parea;
     78SPINLOCK_INITIALIZE_NAME(kio_lock, "kio_lock");
     79
     80/** Physical memory area used for kio buffer */
     81static parea_t kio_parea;
    8282
    8383static indev_t stdin_sink;
     
    146146 *
    147147 */
    148 void klog_init(void)
    149 {
    150         void *faddr = (void *) KA2PA(klog);
     148void kio_init(void)
     149{
     150        void *faddr = (void *) KA2PA(kio);
    151151       
    152152        ASSERT((uintptr_t) faddr % FRAME_SIZE == 0);
    153153       
    154         klog_parea.pbase = (uintptr_t) faddr;
    155         klog_parea.frames = SIZE2FRAMES(sizeof(klog));
    156         klog_parea.unpriv = false;
    157         klog_parea.mapped = false;
    158         ddi_parea_register(&klog_parea);
    159        
    160         sysinfo_set_item_val("klog.faddr", NULL, (sysarg_t) faddr);
    161         sysinfo_set_item_val("klog.pages", NULL, KLOG_PAGES);
    162        
    163         event_set_unmask_callback(EVENT_KLOG, klog_update);
    164         atomic_set(&klog_inited, true);
     154        kio_parea.pbase = (uintptr_t) faddr;
     155        kio_parea.frames = SIZE2FRAMES(sizeof(kio));
     156        kio_parea.unpriv = false;
     157        kio_parea.mapped = false;
     158        ddi_parea_register(&kio_parea);
     159       
     160        sysinfo_set_item_val("kio.faddr", NULL, (sysarg_t) faddr);
     161        sysinfo_set_item_val("kio.pages", NULL, KIO_PAGES);
     162       
     163        event_set_unmask_callback(EVENT_KIO, kio_update);
     164        atomic_set(&kio_inited, true);
    165165}
    166166
     
    247247}
    248248
    249 void klog_update(void *event)
    250 {
    251         if (!atomic_get(&klog_inited))
     249void kio_update(void *event)
     250{
     251        if (!atomic_get(&kio_inited))
    252252                return;
    253253       
    254         spinlock_lock(&klog_lock);
    255        
    256         if (klog_uspace > 0) {
    257                 if (event_notify_3(EVENT_KLOG, true, klog_start, klog_len,
    258                     klog_uspace) == EOK)
    259                         klog_uspace = 0;
    260         }
    261        
    262         spinlock_unlock(&klog_lock);
     254        spinlock_lock(&kio_lock);
     255       
     256        if (kio_uspace > 0) {
     257                if (event_notify_3(EVENT_KIO, true, kio_start, kio_len,
     258                    kio_uspace) == EOK)
     259                        kio_uspace = 0;
     260        }
     261       
     262        spinlock_unlock(&kio_lock);
     263}
     264
     265/** Flush characters that are stored in the output buffer
     266 *
     267 */
     268void kio_flush(void)
     269{
     270        bool ordy = ((stdout) && (stdout->op->write));
     271       
     272        if (!ordy)
     273                return;
     274
     275        spinlock_lock(&kio_lock);
     276
     277        /* Print characters that weren't printed earlier */
     278        while (kio_stored > 0) {
     279                wchar_t tmp = kio[(kio_start + kio_len - kio_stored) % KIO_LENGTH];
     280                kio_stored--;
     281
     282                /*
     283                 * We need to give up the spinlock for
     284                 * the physical operation of writing out
     285                 * the character.
     286                 */
     287                spinlock_unlock(&kio_lock);
     288                stdout->op->write(stdout, tmp);
     289                spinlock_lock(&kio_lock);
     290        }
     291
     292        spinlock_unlock(&kio_lock);
     293}
     294
     295/** Put a character into the output buffer.
     296 *
     297 * The caller is required to hold kio_lock
     298 */
     299void kio_push_char(const wchar_t ch)
     300{
     301        kio[(kio_start + kio_len) % KIO_LENGTH] = ch;
     302        if (kio_len < KIO_LENGTH)
     303                kio_len++;
     304        else
     305                kio_start = (kio_start + 1) % KIO_LENGTH;
     306       
     307        if (kio_stored < kio_len)
     308                kio_stored++;
     309       
     310        /* The character is stored for uspace */
     311        if (kio_uspace < kio_len)
     312                kio_uspace++;
    263313}
    264314
     
    267317        bool ordy = ((stdout) && (stdout->op->write));
    268318       
    269         spinlock_lock(&klog_lock);
    270        
    271         /* Print charaters stored in kernel log */
    272         if (ordy) {
    273                 while (klog_stored > 0) {
    274                         wchar_t tmp = klog[(klog_start + klog_len - klog_stored) % KLOG_LENGTH];
    275                         klog_stored--;
    276                        
    277                         /*
    278                          * We need to give up the spinlock for
    279                          * the physical operation of writting out
    280                          * the character.
    281                          */
    282                         spinlock_unlock(&klog_lock);
    283                         stdout->op->write(stdout, tmp);
    284                         spinlock_lock(&klog_lock);
    285                 }
    286         }
    287        
    288         /* Store character in the cyclic kernel log */
    289         klog[(klog_start + klog_len) % KLOG_LENGTH] = ch;
    290         if (klog_len < KLOG_LENGTH)
    291                 klog_len++;
    292         else
    293                 klog_start = (klog_start + 1) % KLOG_LENGTH;
     319        spinlock_lock(&kio_lock);
     320        kio_push_char(ch);
     321        spinlock_unlock(&kio_lock);
     322       
     323        /* Output stored characters */
     324        kio_flush();
    294325       
    295326        if (!ordy) {
    296                 if (klog_stored < klog_len)
    297                         klog_stored++;
    298         }
    299        
    300         /* The character is stored for uspace */
    301         if (klog_uspace < klog_len)
    302                 klog_uspace++;
    303        
    304         spinlock_unlock(&klog_lock);
    305        
    306         if (ordy) {
    307                 /*
    308                  * Output the character. In this case
    309                  * it should be no longer buffered.
    310                  */
    311                 stdout->op->write(stdout, ch);
    312         } else {
    313327                /*
    314328                 * No standard output routine defined yet.
     
    326340        /* Force notification on newline */
    327341        if (ch == '\n')
    328                 klog_update(NULL);
     342                kio_update(NULL);
    329343}
    330344
     
    334348 *
    335349 */
    336 sysarg_t sys_klog(int cmd, const void *buf, size_t size)
     350sysarg_t sys_kio(int cmd, const void *buf, size_t size)
    337351{
    338352        char *data;
     
    340354
    341355        switch (cmd) {
    342         case KLOG_UPDATE:
    343                 klog_update(NULL);
     356        case KIO_UPDATE:
     357                kio_update(NULL);
    344358                return EOK;
    345         case KLOG_WRITE:
    346         case KLOG_COMMAND:
     359        case KIO_WRITE:
     360        case KIO_COMMAND:
    347361                break;
    348362        default:
     
    366380               
    367381                switch (cmd) {
    368                 case KLOG_WRITE:
     382                case KIO_WRITE:
    369383                        printf("%s", data);
    370384                        break;
    371                 case KLOG_COMMAND:
     385                case KIO_COMMAND:
    372386                        if (!stdin)
    373387                                break;
  • kernel/generic/src/lib/func.c

    raacdb8e rfd07e57b  
    3737
    3838#include <func.h>
    39 #include <print.h>
     39#include <log.h>
    4040#include <cpu.h>
    4141#include <arch/asm.h>
     
    7272       
    7373        if (CPU)
    74                 printf("cpu%u: halted\n", CPU->id);
     74                log(LF_OTHER, LVL_NOTE, "cpu%u: halted", CPU->id);
    7575        else
    76                 printf("cpu: halted\n");
     76                log(LF_OTHER, LVL_NOTE, "cpu: halted");
    7777       
    7878        cpu_halt();
  • kernel/generic/src/lib/rd.c

    raacdb8e rfd07e57b  
    3838 */
    3939
    40 #include <print.h>
     40#include <log.h>
    4141#include <lib/rd.h>
    4242#include <mm/frame.h>
     
    6868        sysinfo_set_item_val("rd.address.physical", NULL, (sysarg_t) base);
    6969       
    70         printf("RAM disk at %p (size %zu bytes)\n", (void *) base, size);
     70        log(LF_OTHER, LVL_NOTE, "RAM disk at %p (size %zu bytes)", (void *) base,
     71            size);
    7172}
    7273
  • kernel/generic/src/main/kinit.c

    raacdb8e rfd07e57b  
    5959#include <mm/km.h>
    6060#include <print.h>
     61#include <log.h>
    6162#include <memstr.h>
    6263#include <console/console.h>
     
    140141                                thread_ready(thread);
    141142                        } else
    142                                 printf("Unable to create kcpulb thread for cpu%u\n", i);
     143                                log(LF_OTHER, LVL_ERROR,
     144                                    "Unable to create kcpulb thread for cpu%u", i);
    143145                }
    144146        }
     
    156158                thread_ready(thread);
    157159        else
    158                 printf("Unable to create kload thread\n");
     160                log(LF_OTHER, LVL_ERROR, "Unable to create kload thread");
    159161       
    160162#ifdef CONFIG_KCONSOLE
     
    168170                        thread_ready(thread);
    169171                else
    170                         printf("Unable to create kconsole thread\n");
     172                        log(LF_OTHER, LVL_ERROR,
     173                            "Unable to create kconsole thread");
    171174        }
    172175#endif /* CONFIG_KCONSOLE */
     
    210213        for (i = 0; i < init.cnt; i++) {
    211214                if (init.tasks[i].paddr % FRAME_SIZE) {
    212                         printf("init[%zu]: Address is not frame aligned\n", i);
     215                        log(LF_OTHER, LVL_ERROR,
     216                            "init[%zu]: Address is not frame aligned", i);
    213217                        programs[i].task = NULL;
    214218                        continue;
     
    273277                        init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
    274278                } else
    275                         printf("init[%zu]: Init binary load failed "
    276                             "(error %d, loader status %u)\n", i, rc,
     279                        log(LF_OTHER, LVL_ERROR,
     280                            "init[%zu]: Init binary load failed "
     281                            "(error %d, loader status %u)", i, rc,
    277282                            programs[i].loader_status);
    278283        }
  • kernel/generic/src/main/main.c

    raacdb8e rfd07e57b  
    6262#include <console/kconsole.h>
    6363#include <console/console.h>
     64#include <log.h>
    6465#include <cpu.h>
    6566#include <align.h>
     
    281282        ipc_init();
    282283        event_init();
    283         klog_init();
     284        kio_init();
     285        log_init();
    284286        stats_init();
    285287       
  • kernel/generic/src/main/shutdown.c

    raacdb8e rfd07e57b  
    3939#include <func.h>
    4040#include <print.h>
     41#include <log.h>
    4142
    4243void reboot(void)
     
    4546       
    4647#ifdef CONFIG_DEBUG
    47         printf("Rebooting the system\n");
     48        log(LF_OTHER, LVL_DEBUG, "Rebooting the system");
    4849#endif
    4950       
  • kernel/generic/src/mm/frame.c

    raacdb8e rfd07e57b  
    5454#include <arch.h>
    5555#include <print.h>
     56#include <log.h>
    5657#include <align.h>
    5758#include <mm/slab.h>
     
    121122{
    122123        if (zones.count + 1 == ZONES_MAX) {
    123                 printf("Maximum zone count %u exceeded!\n", ZONES_MAX);
     124                log(LF_OTHER, LVL_ERROR, "Maximum zone count %u exceeded!",
     125                    ZONES_MAX);
    124126                return (size_t) -1;
    125127        }
     
    141143                            (!iswithin(zones.info[i].base, zones.info[i].count,
    142144                            base, count))) {
    143                                 printf("Zone (%p, %p) overlaps "
    144                                     "with previous zone (%p %p)!\n",
     145                                log(LF_OTHER, LVL_WARN,
     146                                    "Zone (%p, %p) overlaps "
     147                                    "with previous zone (%p %p)!",
    145148                                    (void *) PFN2ADDR(base), (void *) PFN2ADDR(count),
    146149                                    (void *) PFN2ADDR(zones.info[i].base),
     
    913916               
    914917#ifdef CONFIG_DEBUG
    915                 printf("Thread %" PRIu64 " waiting for %zu frames "
    916                     "(%zu available).\n", THREAD->tid, count, avail);
     918                log(LF_OTHER, LVL_DEBUG,
     919                    "Thread %" PRIu64 " waiting for %zu frames "
     920                    "%zu available.", THREAD->tid, count, avail);
    917921#endif
    918922               
     
    938942               
    939943#ifdef CONFIG_DEBUG
    940                 printf("Thread %" PRIu64 " woken up.\n", THREAD->tid);
     944                log(LF_OTHER, LVL_DEBUG, "Thread %" PRIu64 " woken up.",
     945                    THREAD->tid);
    941946#endif
    942947               
  • kernel/generic/src/proc/program.c

    raacdb8e rfd07e57b  
    4949#include <lib/elf_load.h>
    5050#include <errno.h>
    51 #include <print.h>
     51#include <log.h>
    5252#include <syscall/copy.h>
    5353#include <proc/program.h>
     
    155155               
    156156                program_loader = image_addr;
    157                 printf("Program loader at %p\n", (void *) image_addr);
     157                log(LF_OTHER, LVL_NOTE, "Program loader at %p", (void *) image_addr);
    158158               
    159159                return EOK;
     
    181181        if (!loader) {
    182182                as_destroy(as);
    183                 printf("Cannot spawn loader as none was registered\n");
     183                log(LF_OTHER, LVL_ERROR,
     184                    "Cannot spawn loader as none was registered");
    184185                return ENOENT;
    185186        }
     
    189190        if (prg->loader_status != EE_OK) {
    190191                as_destroy(as);
    191                 printf("Cannot spawn loader (%s)\n",
     192                log(LF_OTHER, LVL_ERROR, "Cannot spawn loader (%s)",
    192193                    elf_error(prg->loader_status));
    193194                return ENOENT;
  • kernel/generic/src/proc/scheduler.c

    raacdb8e rfd07e57b  
    6161#include <cpu.h>
    6262#include <print.h>
     63#include <log.h>
    6364#include <debug.h>
    6465#include <stacktrace.h>
     
    517518       
    518519#ifdef SCHEDULER_VERBOSE
    519         printf("cpu%u: tid %" PRIu64 " (priority=%d, ticks=%" PRIu64
    520             ", nrdy=%" PRIua ")\n", CPU->id, THREAD->tid, THREAD->priority,
     520        log(LF_OTHER, LVL_DEBUG,
     521            "cpu%u: tid %" PRIu64 " (priority=%d, ticks=%" PRIu64
     522            ", nrdy=%" PRIua ")", CPU->id, THREAD->tid, THREAD->priority,
    521523            THREAD->ticks, atomic_get(&CPU->nrdy));
    522524#endif
     
    663665                               
    664666#ifdef KCPULB_VERBOSE
    665                                 printf("kcpulb%u: TID %" PRIu64 " -> cpu%u, "
    666                                     "nrdy=%ld, avg=%ld\n", CPU->id, t->tid,
     667                                log(LF_OTHER, LVL_DEBUG,
     668                                    "kcpulb%u: TID %" PRIu64 " -> cpu%u, "
     669                                    "nrdy=%ld, avg=%ld", CPU->id, t->tid,
    667670                                    CPU->id, atomic_get(&CPU->nrdy),
    668671                                    atomic_get(&nrdy) / config.cpu_active);
  • kernel/generic/src/syscall/syscall.c

    raacdb8e rfd07e57b  
    5656#include <console/console.h>
    5757#include <udebug/udebug.h>
     58#include <log.h>
    5859
    5960/** Dispatch system call */
     
    8687                rc = syscall_table[id](a1, a2, a3, a4, a5, a6);
    8788        } else {
    88                 printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id);
     89                log(LF_OTHER, LVL_ERROR,
     90                    "Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id);
    8991                task_kill_self(true);
    9092        }
     
    120122syshandler_t syscall_table[SYSCALL_END] = {
    121123        /* System management syscalls. */
    122         (syshandler_t) sys_klog,
     124        (syshandler_t) sys_kio,
    123125        (syshandler_t) sys_tls_set,
    124126       
     
    190192       
    191193        /* Kernel console syscalls. */
    192         (syshandler_t) sys_debug_activate_console
     194        (syshandler_t) sys_debug_activate_console,
     195       
     196        (syshandler_t) sys_klog,
    193197};
    194198
  • uspace/Makefile

    raacdb8e rfd07e57b  
    5050        app/kill \
    5151        app/killall \
    52         app/klog \
     52        app/kio \
    5353        app/loc \
    5454        app/logset \
     
    9292        srv/locsrv \
    9393        srv/logger \
     94        srv/klog \
    9495        srv/devman \
    9596        srv/loader \
  • uspace/app/init/init.c

    raacdb8e rfd07e57b  
    336336                srv_start("/srv/tmpfs");
    337337       
     338        srv_start("/srv/klog");
    338339        srv_start("/srv/locfs");
    339340        srv_start("/srv/taskmon");
  • uspace/app/kio/Makefile

    raacdb8e rfd07e57b  
    3131LIBS = $(LIBCLUI_PREFIX)/libclui.a
    3232EXTRA_CFLAGS = -I$(LIBCLUI_PREFIX)
    33 BINARY = klog
     33BINARY = kio
    3434
    3535SOURCES = \
    36         klog.c
     36        kio.c
    3737
    3838include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/kio/kio.c

    raacdb8e rfd07e57b  
    2727 */
    2828
    29 /** @addtogroup klog KLog
    30  * @brief HelenOS KLog
     29/** @addtogroup kio KIO
     30 * @brief HelenOS KIO
    3131 * @{
    3232 */
     
    4242#include <errno.h>
    4343#include <str_error.h>
    44 #include <io/klog.h>
     44#include <io/kio.h>
    4545#include <sysinfo.h>
    4646#include <malloc.h>
     
    5050#include <tinput.h>
    5151
    52 #define NAME       "klog"
    53 #define LOG_FNAME  "/log/klog"
     52#define NAME       "kio"
     53#define LOG_FNAME  "/log/kio"
    5454
    5555/* Producer/consumer buffers */
     
    6262static prodcons_t pc;
    6363
    64 /* Pointer to klog area */
    65 static wchar_t *klog;
    66 static size_t klog_length;
     64/* Pointer to kio area */
     65static wchar_t *kio;
     66static size_t kio_length;
    6767
    6868/* Notification mutex */
     
    7575 *
    7676 * @param length Number of characters to copy.
    77  * @param data   Pointer to the kernel klog buffer.
     77 * @param data   Pointer to the kernel kio buffer.
    7878 *
    7979 */
     
    142142/** Kernel notification handler
    143143 *
    144  * Receives kernel klog notifications.
     144 * Receives kernel kio notifications.
    145145 *
    146146 * @param callid IPC call ID
     
    156156         * starving.
    157157         *
    158          * Note: Usually the automatic masking of the klog
     158         * Note: Usually the automatic masking of the kio
    159159         * notifications on the kernel side does the trick
    160160         * of limiting the chance of accidentally copying
    161161         * the same data multiple times. However, due to
    162          * the non-blocking architecture of klog notifications,
     162         * the non-blocking architecture of kio notifications,
    163163         * this possibility cannot be generally avoided.
    164164         */
     
    166166        fibril_mutex_lock(&mtx);
    167167       
    168         size_t klog_start = (size_t) IPC_GET_ARG1(*call);
    169         size_t klog_len = (size_t) IPC_GET_ARG2(*call);
    170         size_t klog_stored = (size_t) IPC_GET_ARG3(*call);
    171        
    172         size_t offset = (klog_start + klog_len - klog_stored) % klog_length;
     168        size_t kio_start = (size_t) IPC_GET_ARG1(*call);
     169        size_t kio_len = (size_t) IPC_GET_ARG2(*call);
     170        size_t kio_stored = (size_t) IPC_GET_ARG3(*call);
     171       
     172        size_t offset = (kio_start + kio_len - kio_stored) % kio_length;
    173173       
    174174        /* Copy data from the ring buffer */
    175         if (offset + klog_stored >= klog_length) {
    176                 size_t split = klog_length - offset;
    177                
    178                 producer(split, klog + offset);
    179                 producer(klog_stored - split, klog);
     175        if (offset + kio_stored >= kio_length) {
     176                size_t split = kio_length - offset;
     177               
     178                producer(split, kio + offset);
     179                producer(kio_stored - split, kio);
    180180        } else
    181                 producer(klog_stored, klog + offset);
    182        
    183         event_unmask(EVENT_KLOG);
     181                producer(kio_stored, kio + offset);
     182       
     183        event_unmask(EVENT_KIO);
    184184        fibril_mutex_unlock(&mtx);
    185185}
     
    188188{
    189189        size_t pages;
    190         int rc = sysinfo_get_value("klog.pages", &pages);
    191         if (rc != EOK) {
    192                 fprintf(stderr, "%s: Unable to get number of klog pages\n",
     190        int rc = sysinfo_get_value("kio.pages", &pages);
     191        if (rc != EOK) {
     192                fprintf(stderr, "%s: Unable to get number of kio pages\n",
    193193                    NAME);
    194194                return rc;
     
    196196       
    197197        uintptr_t faddr;
    198         rc = sysinfo_get_value("klog.faddr", &faddr);
    199         if (rc != EOK) {
    200                 fprintf(stderr, "%s: Unable to get klog physical address\n",
     198        rc = sysinfo_get_value("kio.faddr", &faddr);
     199        if (rc != EOK) {
     200                fprintf(stderr, "%s: Unable to get kio physical address\n",
    201201                    NAME);
    202202                return rc;
     
    204204       
    205205        size_t size = pages * PAGE_SIZE;
    206         klog_length = size / sizeof(wchar_t);
     206        kio_length = size / sizeof(wchar_t);
    207207       
    208208        rc = physmem_map(faddr, pages, AS_AREA_READ | AS_AREA_CACHEABLE,
    209             (void *) &klog);
    210         if (rc != EOK) {
    211                 fprintf(stderr, "%s: Unable to map klog\n", NAME);
     209            (void *) &kio);
     210        if (rc != EOK) {
     211                fprintf(stderr, "%s: Unable to map kio\n", NAME);
    212212                return rc;
    213213        }
     
    215215        prodcons_initialize(&pc);
    216216        async_set_interrupt_received(notification_received);
    217         rc = event_subscribe(EVENT_KLOG, 0);
    218         if (rc != EOK) {
    219                 fprintf(stderr, "%s: Unable to register klog notifications\n",
     217        rc = event_subscribe(EVENT_KIO, 0);
     218        if (rc != EOK) {
     219                fprintf(stderr, "%s: Unable to register kio notifications\n",
    220220                    NAME);
    221221                return rc;
     
    236236
    237237        fibril_add_ready(fid);
    238         event_unmask(EVENT_KLOG);
    239         klog_update();
    240        
    241         tinput_set_prompt(input, "klog> ");
     238        event_unmask(EVENT_KIO);
     239        kio_update();
     240       
     241        tinput_set_prompt(input, "kio> ");
    242242
    243243        char *str;
     
    248248                }
    249249
    250                 klog_command(str, str_size(str));
     250                kio_command(str, str_size(str));
    251251                free(str);
    252252        }
  • uspace/app/trace/syscalls.c

    raacdb8e rfd07e57b  
    3838
    3939const sc_desc_t syscall_desc[] = {
    40     [SYS_KLOG] ={ "klog",                               3,      V_INT_ERRNO },
     40    [SYS_KIO] ={ "kio",                                 3,      V_INT_ERRNO },
    4141    [SYS_TLS_SET] = { "tls_set",                        1,      V_ERRNO },
    4242
  • uspace/lib/c/Makefile

    raacdb8e rfd07e57b  
    107107        generic/io/log.c \
    108108        generic/io/logctl.c \
     109        generic/io/kio.c \
    109110        generic/io/klog.c \
    110111        generic/io/snprintf.c \
  • uspace/lib/c/generic/assert.c

    raacdb8e rfd07e57b  
    3333#include <assert.h>
    3434#include <stdio.h>
    35 #include <io/klog.h>
     35#include <io/kio.h>
    3636#include <stdlib.h>
    3737#include <atomic.h>
     
    4444{
    4545        /*
    46          * Send the message safely to klog. Nested asserts should not occur.
     46         * Send the message safely to kio. Nested asserts should not occur.
    4747         */
    48         klog_printf("Assertion failed (%s) in file \"%s\", line %u.\n",
     48        kio_printf("Assertion failed (%s) in file \"%s\", line %u.\n",
    4949            cond, file, line);
    5050       
  • uspace/lib/c/generic/io/io.c

    raacdb8e rfd07e57b  
    4242#include <malloc.h>
    4343#include <async.h>
    44 #include <io/klog.h>
     44#include <io/kio.h>
    4545#include <vfs/vfs.h>
    4646#include <vfs/vfs_sess.h>
     
    5757        .error = true,
    5858        .eof = true,
    59         .klog = false,
     59        .kio = false,
    6060        .sess = NULL,
    6161        .btype = _IONBF,
     
    6767};
    6868
    69 static FILE stdout_klog = {
     69static FILE stdout_kio = {
    7070        .fd = -1,
    7171        .error = false,
    7272        .eof = false,
    73         .klog = true,
     73        .kio = true,
    7474        .sess = NULL,
    7575        .btype = _IOLBF,
     
    8181};
    8282
    83 static FILE stderr_klog = {
     83static FILE stderr_kio = {
    8484        .fd = -1,
    8585        .error = false,
    8686        .eof = false,
    87         .klog = true,
     87        .kio = true,
    8888        .sess = NULL,
    8989        .btype = _IONBF,
     
    113113                stdout = fdopen(1, "w");
    114114        } else {
    115                 stdout = &stdout_klog;
     115                stdout = &stdout_kio;
    116116                list_append(&stdout->link, &files);
    117117        }
     
    120120                stderr = fdopen(2, "w");
    121121        } else {
    122                 stderr = &stderr_klog;
     122                stderr = &stderr_kio;
    123123                list_append(&stderr->link, &files);
    124124        }
     
    267267        stream->error = false;
    268268        stream->eof = false;
    269         stream->klog = false;
     269        stream->kio = false;
    270270        stream->sess = NULL;
    271271        stream->need_sync = false;
     
    289289        stream->error = false;
    290290        stream->eof = false;
    291         stream->klog = false;
     291        stream->kio = false;
    292292        stream->sess = NULL;
    293293        stream->need_sync = false;
     
    314314       
    315315        if ((stream != &stdin_null)
    316             && (stream != &stdout_klog)
    317             && (stream != &stderr_klog))
     316            && (stream != &stdout_kio)
     317            && (stream != &stderr_kio))
    318318                free(stream);
    319319       
     
    382382                ssize_t wr;
    383383               
    384                 if (stream->klog)
    385                         wr = klog_write(buf + done, left);
     384                if (stream->kio)
     385                        wr = kio_write(buf + done, left);
    386386                else
    387387                        wr = write(stream->fd, buf + done, left);
     
    705705        _fflushbuf(stream);
    706706       
    707         if (stream->klog) {
    708                 klog_update();
     707        if (stream->kio) {
     708                kio_update();
    709709                return EOK;
    710710        }
     
    740740int fileno(FILE *stream)
    741741{
    742         if (stream->klog) {
     742        if (stream->kio) {
    743743                errno = EBADF;
    744744                return -1;
  • uspace/lib/c/generic/io/klog.c

    raacdb8e rfd07e57b  
    11/*
    2  * Copyright (c) 2006 Josef Cejka
    3  * Copyright (c) 2006 Jakub Vana
     2 * Copyright (c) 2013 Martin Sucha
    43 * All rights reserved.
    54 *
     
    4140#include <abi/klog.h>
    4241#include <io/klog.h>
    43 #include <io/printf_core.h>
     42#include <abi/log.h>
    4443
    45 size_t klog_write(const void *buf, size_t size)
     44size_t klog_write(log_level_t lvl, const void *buf, size_t size)
    4645{
    47         ssize_t ret = (ssize_t) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf, size);
     46        ssize_t ret = (ssize_t) __SYSCALL4(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf,
     47            size, lvl);
    4848       
    4949        if (ret >= 0)
     
    5353}
    5454
    55 void klog_update(void)
     55int klog_read(void *data, size_t size)
    5656{
    57         (void) __SYSCALL3(SYS_KLOG, KLOG_UPDATE, (uintptr_t) NULL, 0);
    58 }
    59 
    60 void klog_command(const void *buf, size_t size)
    61 {
    62         (void) __SYSCALL3(SYS_KLOG, KLOG_COMMAND, (sysarg_t) buf, (sysarg_t) size);
    63 }
    64 
    65 /** Print formatted text to klog.
    66  *
    67  * @param fmt Format string
    68  *
    69  * \see For more details about format string see printf_core.
    70  *
    71  */
    72 int klog_printf(const char *fmt, ...)
    73 {
    74         va_list args;
    75         va_start(args, fmt);
    76        
    77         int ret = klog_vprintf(fmt, args);
    78        
    79         va_end(args);
    80        
    81         return ret;
    82 }
    83 
    84 static int klog_vprintf_str_write(const char *str, size_t size, void *data)
    85 {
    86         size_t wr = klog_write(str, size);
    87         return str_nlength(str, wr);
    88 }
    89 
    90 static int klog_vprintf_wstr_write(const wchar_t *str, size_t size, void *data)
    91 {
    92         size_t offset = 0;
    93         size_t chars = 0;
    94        
    95         while (offset < size) {
    96                 char buf[STR_BOUNDS(1)];
    97                 size_t sz = 0;
    98                
    99                 if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK)
    100                         klog_write(buf, sz);
    101                
    102                 chars++;
    103                 offset += sizeof(wchar_t);
    104         }
    105        
    106         return chars;
    107 }
    108 
    109 /** Print formatted text to klog.
    110  *
    111  * @param fmt Format string
    112  * @param ap  Format parameters
    113  *
    114  * \see For more details about format string see printf_core.
    115  *
    116  */
    117 int klog_vprintf(const char *fmt, va_list ap)
    118 {
    119         printf_spec_t ps = {
    120                 klog_vprintf_str_write,
    121                 klog_vprintf_wstr_write,
    122                 NULL
    123         };
    124        
    125         return printf_core(fmt, &ps, ap);
     57        return (int) __SYSCALL4(SYS_KLOG, KLOG_READ, (uintptr_t) data, size, 0);
    12658}
    12759
  • uspace/lib/c/generic/private/stdio.h

    raacdb8e rfd07e57b  
    5353        int eof;
    5454       
    55         /** Klog indicator */
    56         int klog;
     55        /** KIO indicator */
     56        int kio;
    5757       
    5858        /** Session to the file provider */
  • uspace/lib/c/include/io/klog.h

    raacdb8e rfd07e57b  
    11/*
    2  * Copyright (c) 2006 Jakub Vana
     2 * Copyright (c) 2013 Martin Sucha
    33 * All rights reserved.
    44 *
     
    3939#include <stdarg.h>
    4040#include <io/verify.h>
     41#include <stdio.h>
     42#include <stdlib.h>
     43#include <str.h>
     44#include <abi/log.h>
    4145
    42 extern size_t klog_write(const void *, size_t);
    43 extern void klog_update(void);
    44 extern void klog_command(const void *, size_t);
    45 extern int klog_printf(const char *, ...)
    46     PRINTF_ATTRIBUTE(1, 2);
    47 extern int klog_vprintf(const char *, va_list);
     46extern size_t klog_write(log_level_t, const void *, size_t);
     47extern int klog_read(void *, size_t);
     48
     49#define KLOG_PRINTF(lvl, fmt, ...) ({ \
     50        char *_fmt = str_dup(fmt); \
     51        size_t _fmtsize = str_size(_fmt); \
     52        if (_fmtsize > 0 && _fmt[_fmtsize - 1] == '\n') \
     53                _fmt[_fmtsize - 1] = 0; \
     54        char *_s; \
     55        int _c = asprintf(&_s, _fmt, ##__VA_ARGS__); \
     56        free(_fmt); \
     57        if (_c >= 0) { \
     58                _c = klog_write((lvl), _s, str_size(_s)); \
     59                free(_s); \
     60        }; \
     61        (_c >= 0); \
     62})
    4863
    4964#endif
  • uspace/lib/c/include/io/log.h

    raacdb8e rfd07e57b  
    3939#include <io/verify.h>
    4040
    41 /** Log message level. */
    42 typedef enum {
    43         /** Fatal error, program is not able to recover at all. */
    44         LVL_FATAL,
    45         /** Serious error but the program can recover from it. */
    46         LVL_ERROR,
    47         /** Easily recoverable problem. */
    48         LVL_WARN,
    49         /** Information message that ought to be printed by default. */
    50         LVL_NOTE,
    51         /** Debugging purpose message. */
    52         LVL_DEBUG,
    53         /** More detailed debugging message. */
    54         LVL_DEBUG2,
    55        
    56         /** For checking range of values */
    57         LVL_LIMIT
    58 } log_level_t;
     41#include <abi/log.h>
    5942
    6043/** Log itself (logging target). */
  • uspace/lib/c/include/stdio.h

    raacdb8e rfd07e57b  
    4040#include <str.h>
    4141#include <io/verify.h>
    42 #include <abi/klog.h>
     42#include <abi/kio.h>
    4343
    4444#define EOF  (-1)
     
    5252                int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
    5353                if (_n > 0) \
    54                         (void) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) _buf, str_size(_buf)); \
     54                        (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \
    5555        }
    5656
  • uspace/srv/logger/writer.c

    raacdb8e rfd07e57b  
    4040#include <io/log.h>
    4141#include <io/logctl.h>
     42#include <io/klog.h>
    4243#include <ns.h>
    4344#include <async.h>
     
    7980        }
    8081
    81         printf("[%s] %s: %s\n",
     82        KLOG_PRINTF(level, "[%s] %s: %s\n",
    8283            log->full_name, log_level_str(level),
    8384            (const char *) message);
Note: See TracChangeset for help on using the changeset viewer.