From 1b929c6f3ac51372914c4c0d49be8f27caee5ca5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 16 Jan 2014 14:47:38 +0100 Subject: vm: remove the declaration of memory_object_create_proxy It is not clear to me why the declaration was put there in the first place. It is not used anywhere, and it conflicts with the declaration generated by mig. * vm/memory_object_proxy.h (memory_object_create_proxy): Remove declaration. --- vm/memory_object_proxy.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/vm/memory_object_proxy.h b/vm/memory_object_proxy.h index 3de6996..dc0ea74 100644 --- a/vm/memory_object_proxy.h +++ b/vm/memory_object_proxy.h @@ -30,17 +30,6 @@ extern void memory_object_proxy_init (void); extern boolean_t memory_object_proxy_notify (mach_msg_header_t *msg); -extern kern_return_t memory_object_create_proxy (const ipc_space_t space, - vm_prot_t max_protection, - ipc_port_t *object, - natural_t object_count, - const vm_offset_t *offset, - natural_t offset_count, - const vm_offset_t *start, - natural_t start_count, - const vm_offset_t *len, - natural_t len_count, - ipc_port_t *port); extern kern_return_t memory_object_proxy_lookup (ipc_port_t port, ipc_port_t *object, vm_prot_t *max_protection); -- cgit v1.2.3 From 62ca925c9a6b0d12bdf17ac4ab93f5434575cedc Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 16 Jan 2014 14:50:31 +0100 Subject: kern: include the mig-generated server headers in ipc_kobject.c GNU MIG recently gained support for emitting x_server_routine declarations in the generated server header file. Using this declaration, the x_server_routine functions can be inlined into the ipc_kobject_server function. * kern/ipc_kobject.c: Include the mig-generated server headers. --- kern/ipc_kobject.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/kern/ipc_kobject.c b/kern/ipc_kobject.c index 37d4eb9..13af820 100644 --- a/kern/ipc_kobject.c +++ b/kern/ipc_kobject.c @@ -49,6 +49,18 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + +#if MACH_DEBUG +#include +#endif + #if MACH_MACHINE_ROUTINES #include #endif @@ -146,17 +158,6 @@ ipc_kobject_server(request) * to perform the kernel function */ { - extern mig_routine_t mach_server_routine(), - mach_port_server_routine(), - mach_host_server_routine(), - device_server_routine(), - device_pager_server_routine(), - mach4_server_routine(), - gnumach_server_routine(); -#if MACH_DEBUG - extern mig_routine_t mach_debug_server_routine(); -#endif - #if MACH_MACHINE_ROUTINES extern mig_routine_t MACHINE_SERVER_ROUTINE(); #endif -- cgit v1.2.3 From fe7cd805567e1f4d1ed92d87b216e2dc78249892 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 02:02:02 +0100 Subject: kern: add snprintf * kern/printf.c (snprintf): New function. * kern/printf.h (snprintf): New declaration. --- kern/printf.c | 10 ++++++++++ kern/printf.h | 1 + 2 files changed, 11 insertions(+) diff --git a/kern/printf.c b/kern/printf.c index af59d5a..ea78d48 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -615,6 +615,16 @@ vsnprintf(char *buf, size_t size, const char *fmt, va_list args) return cookie.index; } +int +snprintf(char *buf, size_t size, const char *fmt, ...) +{ + int written; + va_list listp; + va_start(listp, fmt); + written = vsnprintf(buf, size, fmt, listp); + va_end(listp); + return written; +} void safe_gets(str, maxlen) char *str; diff --git a/kern/printf.h b/kern/printf.h index 8b4e760..0f8b328 100644 --- a/kern/printf.h +++ b/kern/printf.h @@ -40,6 +40,7 @@ extern void printnum (unsigned long u, int base, vm_offset_t putc_arg); extern int sprintf (char *buf, const char *fmt, ...); +extern int snprintf (char *buf, size_t size, const char *fmt, ...); extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args); extern int printf (const char *fmt, ...); -- cgit v1.2.3 From df47f83ed98e4ce356af8d34de05b549f4f9c912 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 02:15:05 +0100 Subject: kern: add a name field to struct task * kern/task.c (task_create): Initialize name with the address of the task. * kern/task.h (TASK_NAME_SIZE): New definition. (struct task): Add field name. --- kern/task.c | 3 +++ kern/task.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/kern/task.c b/kern/task.c index 13b3c76..0b5a6f7 100644 --- a/kern/task.c +++ b/kern/task.c @@ -45,6 +45,7 @@ #include #include #include +#include #include /* for thread_wakeup */ #include #include @@ -164,6 +165,8 @@ kern_return_t task_create( } #endif /* FAST_TAS */ + snprintf (new_task->name, sizeof new_task->name, "%p", new_task); + ipc_task_enable(new_task); *child_task = new_task; diff --git a/kern/task.h b/kern/task.h index e852033..7ae10cd 100644 --- a/kern/task.h +++ b/kern/task.h @@ -48,6 +48,13 @@ #include #include +/* + * Task name buffer size. The size is chosen so that struct task fits + * into three cache lines. The size of a cache line on a typical CPU + * is 64 bytes. + */ +#define TASK_NAME_SIZE 32 + struct task { /* Synchronization/destruction information */ decl_simple_lock_data(,lock) /* Task's lock */ @@ -113,6 +120,8 @@ struct task { natural_t cow_faults; /* copy-on-write faults counter */ natural_t messages_sent; /* messages sent counter */ natural_t messages_received; /* messages received counter */ + + char name[TASK_NAME_SIZE]; }; #define task_lock(task) simple_lock(&(task)->lock) -- cgit v1.2.3 From 42b8f0e06f9b3a4a089ddbebd851988e095b0c72 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 02:19:43 +0100 Subject: ipc: use the name of the task for error messages * ipc/mach_port.c (mach_port_destroy): Use the name of the task for error messages. (mach_port_deallocate): Likewise. --- ipc/mach_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/mach_port.c b/ipc/mach_port.c index fbc5e69..13572a1 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -571,7 +571,7 @@ mach_port_destroy( kr = ipc_right_lookup_write(space, name, &entry); if (kr != KERN_SUCCESS) { if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) { - printf("task %p destroying an invalid port %lu, most probably a bug.\n", current_task(), name); + printf("task %.*s destroying an invalid port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name); if (mach_port_deallocate_debug) SoftDebugger("mach_port_deallocate"); } @@ -615,7 +615,7 @@ mach_port_deallocate( kr = ipc_right_lookup_write(space, name, &entry); if (kr != KERN_SUCCESS) { if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) { - printf("task %p deallocating an invalid port %lu, most probably a bug.\n", current_task(), name); + printf("task %.*s deallocating an invalid port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name); if (mach_port_deallocate_debug) SoftDebugger("mach_port_deallocate"); } -- cgit v1.2.3 From 7353f589daccb7fb61880d6994f6471e103da902 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 02:09:02 +0100 Subject: include: add a fixed-size string type for debugging purposes * include/mach/debug.defs: New file. * include/mach/debug.h: Likewise. --- include/mach_debug/mach_debug_types.defs | 2 ++ include/mach_debug/mach_debug_types.h | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/mach_debug/mach_debug_types.defs b/include/mach_debug/mach_debug_types.defs index f60125a..d24b6f9 100644 --- a/include/mach_debug/mach_debug_types.defs +++ b/include/mach_debug/mach_debug_types.defs @@ -57,6 +57,8 @@ type vm_page_info_array_t = array[] of vm_page_info_t; type symtab_name_t = (MACH_MSG_TYPE_STRING_C, 8*32); +type kernel_debug_name_t = c_string[*: 64]; + import ; #endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_DEFS_ */ diff --git a/include/mach_debug/mach_debug_types.h b/include/mach_debug/mach_debug_types.h index 5d4efcd..9c7d1fd 100644 --- a/include/mach_debug/mach_debug_types.h +++ b/include/mach_debug/mach_debug_types.h @@ -37,4 +37,15 @@ typedef char symtab_name_t[32]; +/* + * A fixed-length string data type intended for names given to + * kernel objects. + * + * Note that it is not guaranteed that the in-kernel data + * structure will hold KERNEL_DEBUG_NAME_MAX bytes. The given + * name will be truncated to fit into the target data structure. + */ +#define KERNEL_DEBUG_NAME_MAX (64) +typedef char kernel_debug_name_t[KERNEL_DEBUG_NAME_MAX]; + #endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */ -- cgit v1.2.3