=================================================================== RCS file: /cvs/prex-old/sys/kern/system.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- prex-old/sys/kern/system.c 2008/06/03 10:38:46 1.1.1.1 +++ prex-old/sys/kern/system.c 2008/08/13 17:12:32 1.1.1.1.2.1 @@ -37,37 +37,37 @@ #include #include #include -#include -#include #include #include +#include /* * kernel information. */ -static const struct info_kernel kern_info = KERNEL_INFO(kern_info); +static const struct info_kernel kern_info = { + "Prex", VERSION, __DATE__, MACHINE, "preky" +}; /* * Logging system call. * - * Write a message to the logging device. - * The log function is available only when kernel is built with - * debug option. + * Write a message to the logging device. The log function is + * available only when kernel is built with debug option. */ int sys_log(const char *str) { #ifdef DEBUG - char buf[MSGBUFSZ]; + char buf[DBGMSG_SIZE]; size_t len; - if (umem_strnlen(str, MSGBUFSZ, &len)) + if (umem_strnlen(str, DBGMSG_SIZE, &len)) return EFAULT; - if (len >= MSGBUFSZ) + if (len >= DBGMSG_SIZE) return EINVAL; - if (umem_copyin((void *)str, buf, len + 1)) + if (umem_copyin(str, buf, len + 1)) return EFAULT; - printk(buf); + printf(buf); return 0; #else return ENOSYS; @@ -77,22 +77,22 @@ /* * Panic system call. * - * Kernel behavior for sys_panic() is different for its debug option. - * - Debug build - * Show a panic message and stop the entire system. - * - Release build - * Terminate the task which called sys_panic(). + * If kernel is built with debug option, sys_panic() displays + * a panic message and stops the enture system. Otherwise, it + * terminates the task which called sys_panic(). */ int sys_panic(const char *str) { #ifdef DEBUG + task_t self = cur_task(); + irq_lock(); - printk("\nUser mode panic: task:%s thread:%x\n", - cur_task()->name ? cur_task()->name : "no name", cur_thread); + printf("\nUser mode panic: task:%s thread:%x\n", + self->name != NULL ? self->name : "no name", cur_thread); sys_log(str); - printk("\n"); + printf("\n"); sched_lock(); irq_unlock(); @@ -123,13 +123,11 @@ switch (type) { case INFO_KERNEL: - err = umem_copyout((void *)&kern_info, buf, - sizeof(kern_info)); + err = umem_copyout(&kern_info, buf, sizeof(kern_info)); break; case INFO_MEMORY: page_info(&imem.total, &imem.free); - kmem_info(&imem.kernel); err = umem_copyout(&imem, buf, sizeof(imem)); break; @@ -158,12 +156,13 @@ default: err = EINVAL; + break; } return err; } /* - * Get system time - return ticks from OS boot. + * Get system time - return ticks since OS boot. */ int sys_time(u_long *ticks) @@ -171,42 +170,36 @@ u_long t; t = timer_count(); - return umem_copyout(&t, ticks, sizeof(u_long)); + return umem_copyout(&t, ticks, sizeof(t)); } /* * Kernel debug service. */ int -sys_debug(int cmd, u_long param) +sys_debug(int cmd, void *data) { #ifdef DEBUG int err = EINVAL; size_t size; - char *buf; + int item; - /* - * Check capability for some commands. - */ switch (cmd) { case DCMD_DUMP: - if (!task_capable(CAP_DEBUG)) - return EPERM; - } - - switch (cmd) { - case DCMD_DUMP: - err = debug_dump(param); + if (umem_copyin(data, &item, sizeof(item))) + err = EFAULT; + else + err = debug_dump(item); break; case DCMD_LOGSIZE: - if ((err = log_get(&buf, &size)) == 0) - err = umem_copyout(&size, (void *)param, sizeof(size)); + size = LOGBUF_SIZE; + err = umem_copyout(&size, data, sizeof(size)); break; case DCMD_GETLOG: - if ((err = log_get(&buf, &size)) == 0) - err = umem_copyout(buf, (void *)param, size); + err = debug_getlog(data); break; default: + /* DO NOTHING */ break; } return err;