Changeset 1c03c17 in mainline
- Timestamp:
- 2008-06-06T23:16:37Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c05a50f
- Parents:
- b7b6753
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
rb7b6753 r1c03c17 131 131 spawn("/sbin/tetris"); 132 132 // FIXME: spawn("/sbin/tester"); 133 // FIXME:spawn("/sbin/klog");133 spawn("/sbin/klog"); 134 134 135 135 free(buf); -
uspace/app/klog/klog.c
rb7b6753 r1c03c17 41 41 #include <as.h> 42 42 #include <sysinfo.h> 43 #include <io/stream.h> 44 #include <errno.h> 45 46 #define NAME "klog" 47 48 #define KLOG_SIZE PAGE_SIZE 43 49 44 50 /* Pointer to klog area */ … … 47 53 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) 48 54 { 49 int i;55 async_serialize_start(); 50 56 51 async_serialize_start(); 52 for (i=0; klog[i + IPC_GET_ARG1(*call)] && i < IPC_GET_ARG2(*call); i++) 53 putchar(klog[i + IPC_GET_ARG1(*call)]); 54 putchar('\n'); 57 size_t klog_start = (size_t) IPC_GET_ARG1(*call); 58 size_t klog_len = (size_t) IPC_GET_ARG2(*call); 59 size_t klog_stored = (size_t) IPC_GET_ARG3(*call); 60 size_t i; 61 for (i = klog_len - klog_stored; i < klog_len; i++) 62 putchar(klog[(klog_start + i) % KLOG_SIZE]); 63 55 64 async_serialize_end(); 56 65 } … … 58 67 int main(int argc, char *argv[]) 59 68 { 60 int res; 61 void *mapping; 62 63 printf("Kernel console output.\n"); 69 klog = (char *) as_get_mappable_page(KLOG_SIZE); 70 if (klog == NULL) { 71 printf(NAME ": Error allocating memory area\n"); 72 return -1; 73 } 64 74 65 mapping = as_get_mappable_page(PAGE_SIZE); 66 res = ipc_share_in_start_1_0(PHONE_NS, mapping, PAGE_SIZE, 75 int res = ipc_share_in_start_1_0(PHONE_NS, (void *) klog, KLOG_SIZE, 67 76 SERVICE_MEM_KLOG); 68 if (res ) {69 printf( "Failed to initialize klog memarea\n");70 _exit(1);77 if (res != EOK) { 78 printf(NAME ": Error initializing memory area\n"); 79 return -1; 71 80 } 72 klog = mapping;73 81 74 82 int inr = sysinfo_value("klog.inr"); 75 83 int devno = sysinfo_value("klog.devno"); 76 if (ipc_register_irq(inr, devno, 0, NULL) ) {77 printf( "Error registering for klog service.\n");78 return 0;84 if (ipc_register_irq(inr, devno, 0, NULL) != EOK) { 85 printf(NAME ": Error registering klog notifications\n"); 86 return -1; 79 87 } 80 88 81 89 async_set_interrupt_received(interrupt_received); 82 90 klog_update(); 83 91 async_manager(); 84 92 -
uspace/lib/libc/generic/io/stream.c
rb7b6753 r1c03c17 83 83 return count; 84 84 } else 85 return __SYSCALL3(SYS_ IO, 1, (sysarg_t) buf, count);85 return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count); 86 86 } 87 87 … … 95 95 } 96 96 97 void klog_update(void) 98 { 99 (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0); 100 } 101 97 102 int get_cons_phone(void) 98 103 { -
uspace/lib/libc/include/io/stream.h
rb7b6753 r1c03c17 41 41 42 42 extern void open_console(void); 43 extern void klog_update(void); 43 44 44 45 extern ssize_t read_stdin(void *, size_t); -
uspace/lib/libc/include/stdio.h
rb7b6753 r1c03c17 50 50 n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \ 51 51 if (n > 0) \ 52 (void) __SYSCALL3(SYS_ IO, 1, (sysarg_t) buf, strlen(buf)); \52 (void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, strlen(buf)); \ 53 53 } 54 54
Note:
See TracChangeset
for help on using the changeset viewer.