- Timestamp:
- 2014-01-05T17:50:01Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91db0280
- Parents:
- 208b5f5
- Location:
- uspace
- Files:
-
- 7 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r208b5f5 r6fa9a99d 50 50 app/kill \ 51 51 app/killall \ 52 app/k log\52 app/kio \ 53 53 app/loc \ 54 54 app/logset \ -
uspace/app/kio/Makefile
r208b5f5 r6fa9a99d 31 31 LIBS = $(LIBCLUI_PREFIX)/libclui.a 32 32 EXTRA_CFLAGS = -I$(LIBCLUI_PREFIX) 33 BINARY = k log33 BINARY = kio 34 34 35 35 SOURCES = \ 36 k log.c36 kio.c 37 37 38 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/kio/kio.c
r208b5f5 r6fa9a99d 27 27 */ 28 28 29 /** @addtogroup k log KLog30 * @brief HelenOS K Log29 /** @addtogroup kio KIO 30 * @brief HelenOS KIO 31 31 * @{ 32 32 */ … … 42 42 #include <errno.h> 43 43 #include <str_error.h> 44 #include <io/k log.h>44 #include <io/kio.h> 45 45 #include <sysinfo.h> 46 46 #include <malloc.h> … … 50 50 #include <tinput.h> 51 51 52 #define NAME "k log"53 #define LOG_FNAME "/log/k log"52 #define NAME "kio" 53 #define LOG_FNAME "/log/kio" 54 54 55 55 /* Producer/consumer buffers */ … … 62 62 static prodcons_t pc; 63 63 64 /* Pointer to k logarea */65 static wchar_t *k log;66 static size_t k log_length;64 /* Pointer to kio area */ 65 static wchar_t *kio; 66 static size_t kio_length; 67 67 68 68 /* Notification mutex */ … … 75 75 * 76 76 * @param length Number of characters to copy. 77 * @param data Pointer to the kernel k logbuffer.77 * @param data Pointer to the kernel kio buffer. 78 78 * 79 79 */ … … 142 142 /** Kernel notification handler 143 143 * 144 * Receives kernel k lognotifications.144 * Receives kernel kio notifications. 145 145 * 146 146 * @param callid IPC call ID … … 156 156 * starving. 157 157 * 158 * Note: Usually the automatic masking of the k log158 * Note: Usually the automatic masking of the kio 159 159 * notifications on the kernel side does the trick 160 160 * of limiting the chance of accidentally copying 161 161 * the same data multiple times. However, due to 162 * the non-blocking architecture of k lognotifications,162 * the non-blocking architecture of kio notifications, 163 163 * this possibility cannot be generally avoided. 164 164 */ … … 166 166 fibril_mutex_lock(&mtx); 167 167 168 size_t k log_start = (size_t) IPC_GET_ARG1(*call);169 size_t k log_len = (size_t) IPC_GET_ARG2(*call);170 size_t k log_stored = (size_t) IPC_GET_ARG3(*call);171 172 size_t offset = (k log_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; 173 173 174 174 /* Copy data from the ring buffer */ 175 if (offset + k log_stored >= klog_length) {176 size_t split = k log_length - offset;177 178 producer(split, k log+ offset);179 producer(k log_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); 180 180 } else 181 producer(k log_stored, klog+ offset);182 183 event_unmask(EVENT_K LOG);181 producer(kio_stored, kio + offset); 182 183 event_unmask(EVENT_KIO); 184 184 fibril_mutex_unlock(&mtx); 185 185 } … … 188 188 { 189 189 size_t pages; 190 int rc = sysinfo_get_value("k log.pages", &pages);191 if (rc != EOK) { 192 fprintf(stderr, "%s: Unable to get number of k logpages\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", 193 193 NAME); 194 194 return rc; … … 196 196 197 197 uintptr_t faddr; 198 rc = sysinfo_get_value("k log.faddr", &faddr);199 if (rc != EOK) { 200 fprintf(stderr, "%s: Unable to get k logphysical 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", 201 201 NAME); 202 202 return rc; … … 204 204 205 205 size_t size = pages * PAGE_SIZE; 206 k log_length = size / sizeof(wchar_t);206 kio_length = size / sizeof(wchar_t); 207 207 208 208 rc = physmem_map(faddr, pages, AS_AREA_READ | AS_AREA_CACHEABLE, 209 (void *) &k log);210 if (rc != EOK) { 211 fprintf(stderr, "%s: Unable to map k log\n", NAME);209 (void *) &kio); 210 if (rc != EOK) { 211 fprintf(stderr, "%s: Unable to map kio\n", NAME); 212 212 return rc; 213 213 } … … 215 215 prodcons_initialize(&pc); 216 216 async_set_interrupt_received(notification_received); 217 rc = event_subscribe(EVENT_K LOG, 0);218 if (rc != EOK) { 219 fprintf(stderr, "%s: Unable to register k lognotifications\n",217 rc = event_subscribe(EVENT_KIO, 0); 218 if (rc != EOK) { 219 fprintf(stderr, "%s: Unable to register kio notifications\n", 220 220 NAME); 221 221 return rc; … … 236 236 237 237 fibril_add_ready(fid); 238 event_unmask(EVENT_K LOG);239 k log_update();240 241 tinput_set_prompt(input, "k log> ");238 event_unmask(EVENT_KIO); 239 kio_update(); 240 241 tinput_set_prompt(input, "kio> "); 242 242 243 243 char *str; … … 248 248 } 249 249 250 k log_command(str, str_size(str));250 kio_command(str, str_size(str)); 251 251 free(str); 252 252 } -
uspace/app/trace/syscalls.c
r208b5f5 r6fa9a99d 38 38 39 39 const sc_desc_t syscall_desc[] = { 40 [SYS_K LOG] ={ "klog",3, V_INT_ERRNO },40 [SYS_KIO] ={ "kio", 3, V_INT_ERRNO }, 41 41 [SYS_TLS_SET] = { "tls_set", 1, V_ERRNO }, 42 42 -
uspace/lib/c/Makefile
r208b5f5 r6fa9a99d 107 107 generic/io/log.c \ 108 108 generic/io/logctl.c \ 109 generic/io/k log.c \109 generic/io/kio.c \ 110 110 generic/io/snprintf.c \ 111 111 generic/io/vprintf.c \ -
uspace/lib/c/generic/assert.c
r208b5f5 r6fa9a99d 33 33 #include <assert.h> 34 34 #include <stdio.h> 35 #include <io/k log.h>35 #include <io/kio.h> 36 36 #include <stdlib.h> 37 37 #include <atomic.h> … … 44 44 { 45 45 /* 46 * Send the message safely to k log. Nested asserts should not occur.46 * Send the message safely to kio. Nested asserts should not occur. 47 47 */ 48 k log_printf("Assertion failed (%s) in file \"%s\", line %u.\n",48 kio_printf("Assertion failed (%s) in file \"%s\", line %u.\n", 49 49 cond, file, line); 50 50 -
uspace/lib/c/generic/io/io.c
r208b5f5 r6fa9a99d 42 42 #include <malloc.h> 43 43 #include <async.h> 44 #include <io/k log.h>44 #include <io/kio.h> 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> … … 57 57 .error = true, 58 58 .eof = true, 59 .k log= false,59 .kio = false, 60 60 .sess = NULL, 61 61 .btype = _IONBF, … … 67 67 }; 68 68 69 static FILE stdout_k log= {69 static FILE stdout_kio = { 70 70 .fd = -1, 71 71 .error = false, 72 72 .eof = false, 73 .k log= true,73 .kio = true, 74 74 .sess = NULL, 75 75 .btype = _IOLBF, … … 81 81 }; 82 82 83 static FILE stderr_k log= {83 static FILE stderr_kio = { 84 84 .fd = -1, 85 85 .error = false, 86 86 .eof = false, 87 .k log= true,87 .kio = true, 88 88 .sess = NULL, 89 89 .btype = _IONBF, … … 113 113 stdout = fdopen(1, "w"); 114 114 } else { 115 stdout = &stdout_k log;115 stdout = &stdout_kio; 116 116 list_append(&stdout->link, &files); 117 117 } … … 120 120 stderr = fdopen(2, "w"); 121 121 } else { 122 stderr = &stderr_k log;122 stderr = &stderr_kio; 123 123 list_append(&stderr->link, &files); 124 124 } … … 267 267 stream->error = false; 268 268 stream->eof = false; 269 stream->k log= false;269 stream->kio = false; 270 270 stream->sess = NULL; 271 271 stream->need_sync = false; … … 289 289 stream->error = false; 290 290 stream->eof = false; 291 stream->k log= false;291 stream->kio = false; 292 292 stream->sess = NULL; 293 293 stream->need_sync = false; … … 314 314 315 315 if ((stream != &stdin_null) 316 && (stream != &stdout_k log)317 && (stream != &stderr_k log))316 && (stream != &stdout_kio) 317 && (stream != &stderr_kio)) 318 318 free(stream); 319 319 … … 382 382 ssize_t wr; 383 383 384 if (stream->k log)385 wr = k log_write(buf + done, left);384 if (stream->kio) 385 wr = kio_write(buf + done, left); 386 386 else 387 387 wr = write(stream->fd, buf + done, left); … … 705 705 _fflushbuf(stream); 706 706 707 if (stream->k log) {708 k log_update();707 if (stream->kio) { 708 kio_update(); 709 709 return EOK; 710 710 } … … 740 740 int fileno(FILE *stream) 741 741 { 742 if (stream->k log) {742 if (stream->kio) { 743 743 errno = EBADF; 744 744 return -1; -
uspace/lib/c/generic/io/kio.c
r208b5f5 r6fa9a99d 39 39 #include <unistd.h> 40 40 #include <errno.h> 41 #include <abi/k log.h>42 #include <io/k log.h>41 #include <abi/kio.h> 42 #include <io/kio.h> 43 43 #include <io/printf_core.h> 44 44 45 size_t k log_write(const void *buf, size_t size)45 size_t kio_write(const void *buf, size_t size) 46 46 { 47 ssize_t ret = (ssize_t) __SYSCALL3(SYS_K LOG, KLOG_WRITE, (sysarg_t) buf, size);47 ssize_t ret = (ssize_t) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) buf, size); 48 48 49 49 if (ret >= 0) … … 53 53 } 54 54 55 void k log_update(void)55 void kio_update(void) 56 56 { 57 (void) __SYSCALL3(SYS_K LOG, KLOG_UPDATE, (uintptr_t) NULL, 0);57 (void) __SYSCALL3(SYS_KIO, KIO_UPDATE, (uintptr_t) NULL, 0); 58 58 } 59 59 60 void k log_command(const void *buf, size_t size)60 void kio_command(const void *buf, size_t size) 61 61 { 62 (void) __SYSCALL3(SYS_K LOG, KLOG_COMMAND, (sysarg_t) buf, (sysarg_t) size);62 (void) __SYSCALL3(SYS_KIO, KIO_COMMAND, (sysarg_t) buf, (sysarg_t) size); 63 63 } 64 64 65 /** Print formatted text to k log.65 /** Print formatted text to kio. 66 66 * 67 67 * @param fmt Format string … … 70 70 * 71 71 */ 72 int k log_printf(const char *fmt, ...)72 int kio_printf(const char *fmt, ...) 73 73 { 74 74 va_list args; 75 75 va_start(args, fmt); 76 76 77 int ret = k log_vprintf(fmt, args);77 int ret = kio_vprintf(fmt, args); 78 78 79 79 va_end(args); … … 82 82 } 83 83 84 static int k log_vprintf_str_write(const char *str, size_t size, void *data)84 static int kio_vprintf_str_write(const char *str, size_t size, void *data) 85 85 { 86 size_t wr = k log_write(str, size);86 size_t wr = kio_write(str, size); 87 87 return str_nlength(str, wr); 88 88 } 89 89 90 static int k log_vprintf_wstr_write(const wchar_t *str, size_t size, void *data)90 static int kio_vprintf_wstr_write(const wchar_t *str, size_t size, void *data) 91 91 { 92 92 size_t offset = 0; … … 98 98 99 99 if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK) 100 k log_write(buf, sz);100 kio_write(buf, sz); 101 101 102 102 chars++; … … 107 107 } 108 108 109 /** Print formatted text to k log.109 /** Print formatted text to kio. 110 110 * 111 111 * @param fmt Format string … … 115 115 * 116 116 */ 117 int k log_vprintf(const char *fmt, va_list ap)117 int kio_vprintf(const char *fmt, va_list ap) 118 118 { 119 119 printf_spec_t ps = { 120 k log_vprintf_str_write,121 k log_vprintf_wstr_write,120 kio_vprintf_str_write, 121 kio_vprintf_wstr_write, 122 122 NULL 123 123 }; -
uspace/lib/c/generic/private/stdio.h
r208b5f5 r6fa9a99d 53 53 int eof; 54 54 55 /** K logindicator */56 int k log;55 /** KIO indicator */ 56 int kio; 57 57 58 58 /** Session to the file provider */ -
uspace/lib/c/include/io/kio.h
r208b5f5 r6fa9a99d 33 33 */ 34 34 35 #ifndef LIBC_IO_K LOG_H_36 #define LIBC_IO_K LOG_H_35 #ifndef LIBC_IO_KIO_H_ 36 #define LIBC_IO_KIO_H_ 37 37 38 38 #include <sys/types.h> … … 40 40 #include <io/verify.h> 41 41 42 extern size_t k log_write(const void *, size_t);43 extern void k log_update(void);44 extern void k log_command(const void *, size_t);45 extern int k log_printf(const char *, ...)42 extern size_t kio_write(const void *, size_t); 43 extern void kio_update(void); 44 extern void kio_command(const void *, size_t); 45 extern int kio_printf(const char *, ...) 46 46 PRINTF_ATTRIBUTE(1, 2); 47 extern int k log_vprintf(const char *, va_list);47 extern int kio_vprintf(const char *, va_list); 48 48 49 49 #endif -
uspace/lib/c/include/stdio.h
r208b5f5 r6fa9a99d 40 40 #include <str.h> 41 41 #include <io/verify.h> 42 #include <abi/k log.h>42 #include <abi/kio.h> 43 43 44 44 #define EOF (-1) … … 52 52 int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \ 53 53 if (_n > 0) \ 54 (void) __SYSCALL3(SYS_K LOG, KLOG_WRITE, (sysarg_t) _buf, str_size(_buf)); \54 (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \ 55 55 } 56 56
Note:
See TracChangeset
for help on using the changeset viewer.