Changes in uspace/app/klog/klog.c [382cd26:7dfd339] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/klog/klog.c
r382cd26 r7dfd339 36 36 37 37 #include <stdio.h> 38 #include <ipc/ipc.h> 38 39 #include <async.h> 40 #include <ipc/services.h> 39 41 #include <as.h> 40 #include < ddi.h>42 #include <sysinfo.h> 41 43 #include <event.h> 42 44 #include <errno.h> 43 45 #include <str_error.h> 44 46 #include <io/klog.h> 45 #include <sysinfo.h>46 47 47 48 #define NAME "klog" … … 78 79 int main(int argc, char *argv[]) 79 80 { 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; 81 size_t klog_pages; 82 if (sysinfo_get_value("klog.pages", &klog_pages) != EOK) { 83 printf("%s: Error getting klog address\n", NAME); 84 return -1; 86 85 } 87 86 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; 87 size_t klog_size = klog_pages * PAGE_SIZE; 88 klog_length = klog_size / sizeof(wchar_t); 89 90 klog = (wchar_t *) as_get_mappable_page(klog_size); 91 if (klog == NULL) { 92 printf("%s: Error allocating memory area\n", NAME); 93 return -1; 94 94 } 95 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; 96 int res = async_share_in_start_1_0(PHONE_NS, (void *) klog, 97 klog_size, SERVICE_MEM_KLOG); 98 if (res != EOK) { 99 printf("%s: Error initializing memory area\n", NAME); 100 return -1; 104 101 } 105 102 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; 103 if (event_subscribe(EVENT_KLOG, 0) != EOK) { 104 printf("%s: Error registering klog notifications\n", NAME); 105 return -1; 111 106 } 112 107 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; 118 } 119 120 log = fopen(LOG_FNAME, "a"); 108 /* 109 * Mode "a" would be definitively much better here, but it is 110 * not well supported by the FAT driver. 111 * 112 */ 113 log = fopen(LOG_FNAME, "w"); 121 114 if (log == NULL) 122 115 printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME,
Note:
See TracChangeset
for help on using the changeset viewer.