Changeset 6119f24 in mainline for uspace/app/klog/klog.c


Ignore:
Timestamp:
2011-01-29T18:58:24Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
10477601, 6aef742
Parents:
d7533c7
Message:

map klog area and clock page directly in tasks which require them (do not use the memory sharing from naming service via IPC)
this avoids the circular dependency between gettimeofday() and the async framework (as reported by Jakub Jermar)
it also simplifies the code of the naming service (the memory sharing was never strictly necessary, it was only a demonstrator)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/klog/klog.c

    rd7533c7 r6119f24  
    3636
    3737#include <stdio.h>
    38 #include <ipc/ns.h>
    3938#include <async.h>
    40 #include <ipc/services.h>
    4139#include <as.h>
    42 #include <sysinfo.h>
     40#include <ddi.h>
    4341#include <event.h>
    4442#include <errno.h>
    4543#include <str_error.h>
    4644#include <io/klog.h>
     45#include <sysinfo.h>
    4746
    4847#define NAME       "klog"
     
    7978int main(int argc, char *argv[])
    8079{
    81         klog = service_klog_share_in(&klog_length);
    82         if (klog == NULL) {
    83                 printf("%s: Error accessing to klog\n", NAME);
    84                 return -1;
     80        size_t pages;
     81        int rc = sysinfo_get_value("klog.pages", &pages);
     82        if (rc != EOK) {
     83                fprintf(stderr, "%s: Unable to get number of klog pages\n",
     84                    NAME);
     85                return rc;
    8586        }
    8687       
    87         if (event_subscribe(EVENT_KLOG, 0) != EOK) {
    88                 printf("%s: Error registering klog notifications\n", NAME);
    89                 return -1;
     88        uintptr_t faddr;
     89        rc = sysinfo_get_value("klog.faddr", &faddr);
     90        if (rc != EOK) {
     91                fprintf(stderr, "%s: Unable to get klog physical address\n",
     92                    NAME);
     93                return rc;
     94        }
     95       
     96        size_t size = pages * PAGE_SIZE;
     97        klog_length = size / sizeof(wchar_t);
     98       
     99        klog = (wchar_t *) as_get_mappable_page(size);
     100        if (klog == NULL) {
     101                fprintf(stderr, "%s: Unable to allocate virtual memory area\n",
     102                    NAME);
     103                return ENOMEM;
     104        }
     105       
     106        rc = physmem_map((void *) faddr, (void *) klog, pages,
     107            AS_AREA_READ | AS_AREA_CACHEABLE);
     108        if (rc != EOK) {
     109                fprintf(stderr, "%s: Unable to map klog\n", NAME);
     110                return rc;
     111        }
     112       
     113        rc = event_subscribe(EVENT_KLOG, 0);
     114        if (rc != EOK) {
     115                fprintf(stderr, "%s: Unable to register klog notifications\n",
     116                    NAME);
     117                return rc;
    90118        }
    91119       
Note: See TracChangeset for help on using the changeset viewer.